Date:2012-07-02 01:51:47 (11 years 8 months ago)
Author:Werner Almesberger
Commit:236ef1dad0de8b848e6104743aae51f014df1e1a
Message:tools/libtxt/font.c: split load_image_file (load from open file) off load_image

Files: tools/libtxt/font.c (2 diffs)
tools/libtxt/libtxt.h (2 diffs)

Change Details

tools/libtxt/font.c
9999}
100100
101101
102struct image *load_image(const char *name, const char **error)
102struct image *load_image_file(FILE *file, const char **error)
103103{
104    FILE *file;
105104    struct image *img;
106105    const char *err;
107106
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
115107    img = alloc_type(struct image);
116108    err = read_xbm_file(file, img);
117109    if (err) {
...... 
124116}
125117
126118
119struct 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
127136void free_image(struct image *img)
128137{
129138    if (img) {
tools/libtxt/libtxt.h
1313#ifndef LIBTXT_H
1414#define LIBTXT_H
1515
16#include <stdio.h>
17
18
1619struct image;
1720
1821struct font;
...... 
5154 * Newline leaves one blank row between text lines.
5255 */
5356
57struct image *load_image_file(FILE *file, const char **error);
5458struct image *load_image(const char *name, const char **error);
5559void free_image(struct image *img);
5660

Archive Download the corresponding diff file

Branches:
master
tornado-v1



interactive