Change Details
tools/libtxt/font.c |
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | | struct image *load_image(const char *name, const char **error) |
| 102 | struct image *load_image_file(FILE *file, const char **error) |
103 | 103 | { |
104 | | FILE *file; |
105 | 104 | struct image *img; |
106 | 105 | const char *err; |
107 | 106 | |
108 | | file = fopen(name, "r"); |
109 | | if (!file) { |
110 | | if (error) |
111 | | *error = alloc_sprintf("%s: %s", name, strerror(errno)); |
112 | | return NULL; |
113 | | } |
114 | | |
115 | 107 | img = alloc_type(struct image); |
116 | 108 | err = read_xbm_file(file, img); |
117 | 109 | if (err) { |
... | ... | |
124 | 116 | } |
125 | 117 | |
126 | 118 | |
| 119 | struct image *load_image(const char *name, const char **error) |
| 120 | { |
| 121 | FILE *file; |
| 122 | struct image *img; |
| 123 | |
| 124 | file = fopen(name, "r"); |
| 125 | if (!file) { |
| 126 | if (error) |
| 127 | *error = alloc_sprintf("%s: %s", name, strerror(errno)); |
| 128 | return NULL; |
| 129 | } |
| 130 | img = load_image_file(file, error); |
| 131 | fclose(file); |
| 132 | return img; |
| 133 | } |
| 134 | |
| 135 | |
127 | 136 | void free_image(struct image *img) |
128 | 137 | { |
129 | 138 | if (img) { |
tools/libtxt/libtxt.h |
13 | 13 | #ifndef LIBTXT_H |
14 | 14 | #define LIBTXT_H |
15 | 15 | |
| 16 | #include <stdio.h> |
| 17 | |
| 18 | |
16 | 19 | struct image; |
17 | 20 | |
18 | 21 | struct font; |
... | ... | |
51 | 54 | * Newline leaves one blank row between text lines. |
52 | 55 | */ |
53 | 56 | |
| 57 | struct image *load_image_file(FILE *file, const char **error); |
54 | 58 | struct image *load_image(const char *name, const char **error); |
55 | 59 | void free_image(struct image *img); |
56 | 60 | |
Download the corresponding diff file