Changeset 421 for pwntcha


Ignore:
Timestamp:
Jan 5, 2005, 1:18:49 AM (16 years ago)
Author:
Sam Hocevar
Message:
  • keep the font loaded across decodings.
Location:
pwntcha/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pwntcha/trunk/src/linuxfr.c

    r420 r421  
    1919
    2020#define FONTNAME "share/font_linuxfr.png"
     21static struct image *font = NULL;
    2122
    2223/* Main function */
     
    2728                 "0123456789";
    2829    char *result;
    29     struct image *tmp, *font;
     30    struct image *tmp;
    3031    int x, y, r, g, b, i, j, c;
    3132    int stats[40];
    3233
    33     font = image_load(FONTNAME);
    3434    if(!font)
    3535    {
    36         fprintf(stderr, "cannot load font %s\n", FONTNAME);
    37         exit(-1);
     36        font = image_load(FONTNAME);
     37        if(!font)
     38        {
     39            fprintf(stderr, "cannot load font %s\n", FONTNAME);
     40            exit(-1);
     41        }
    3842    }
    3943
     
    142146
    143147    image_free(tmp);
    144     image_free(font);
    145148
    146149    if(strlen(result) != 7)
  • pwntcha/trunk/src/phpbb.c

    r418 r421  
    2020/* Our macros */
    2121#define FONTNAME "share/font_phpbb.png"
     22static struct image *font = NULL;
    2223
    2324/* Main function */
     
    2728    char *result;
    2829    struct image *tmp1, *tmp2, *tmp3;
    29     struct image *font = image_load(FONTNAME);
    3030    int x, y, i = 0;
    3131    int r, g, b;
     
    3535    if(!font)
    3636    {
    37         fprintf(stderr, "cannot load font %s\n", FONTNAME);
    38         exit(-1);
     37        font = image_load(FONTNAME);
     38        if(!font)
     39        {
     40            fprintf(stderr, "cannot load font %s\n", FONTNAME);
     41            exit(-1);
     42        }
    3943    }
    4044
     
    126130    image_free(tmp2);
    127131    image_free(tmp3);
    128     image_free(font);
    129132
    130133    return result;
  • pwntcha/trunk/src/slashdot.c

    r411 r421  
    1919#include "common.h"
    2020
     21static struct image *count_objects(struct image *img);
     22static struct image *rotate(struct image *img);
     23static struct image *cut_cells(struct image *img);
     24static struct image *find_glyphs(struct image *img);
     25
    2126/* Our macros */
    2227#define FACTOR 1
     
    2429//#define FONTNAME "share/font.png" // use with FACTOR = 2
    2530//#define FONTNAME "share/font_dilated.png" // use with FACTOR = 2
    26 
    27 static struct image *count_objects(struct image *img);
    28 static struct image *rotate(struct image *img);
    29 static struct image *cut_cells(struct image *img);
    30 static struct image *find_glyphs(struct image *img);
     31static struct image *font = NULL;
    3132
    3233/* Global stuff */
     
    238239    glyphs[22];
    239240    struct image *dst;
    240     struct image *font = image_load(FONTNAME);
    241241    int x, y, i = 0;
    242242    int r, g, b;
     
    246246    if(!font)
    247247    {
    248         fprintf(stderr, "cannot load font %s\n", FONTNAME);
    249         exit(-1);
     248        font = image_load(FONTNAME);
     249        if(!font)
     250        {
     251            fprintf(stderr, "cannot load font %s\n", FONTNAME);
     252            exit(-1);
     253        }
    250254    }
    251255
  • pwntcha/trunk/src/vbulletin.c

    r414 r421  
    1919
    2020#define FONTNAME "share/font_vbulletin.png"
     21static struct image *font = NULL;
    2122
    2223/* Main function */
     
    2526    char all[] = "2346789ABCDEFGHJKLMNPRTWXYZ";
    2627    char *result;
    27     struct image *tmp1, *tmp2, *tmp3, *font;
     28    struct image *tmp1, *tmp2, *tmp3;
    2829    int limits[6] = { 26, 53, 80, 107, 134, 160 };
    2930    int x, y, r, g, b, i, j;
    3031
    31     font = image_load(FONTNAME);
    3232    if(!font)
    3333    {
    34         fprintf(stderr, "cannot load font %s\n", FONTNAME);
    35         exit(-1);
     34        font = image_load(FONTNAME);
     35        if(!font)
     36        {
     37            fprintf(stderr, "cannot load font %s\n", FONTNAME);
     38            exit(-1);
     39        }
    3640    }
    3741
     
    135139    image_free(tmp2);
    136140    image_free(tmp3);
    137     image_free(font);
    138141
    139142    return result;
Note: See TracChangeset for help on using the changeset viewer.