<commit_before>#include "fasttext.h"

char default_font_path[] = "/usr/share/fonts/";
extern char hash_next_magic[];

FT_Library library; 
hash_entry * faces = NULL;
extern char **environ;
cairo_surface_t * main_surface;
cairo_t * main_context;

int main(int argc, char ** argv)
{
    char **files;
    char path[MAXPATHLEN];
    int error, count, i;

    tr_params render_params;
    main_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, MAX_WIDTH, MAX_HEIGHT);
    main_context = cairo_create(main_surface);

    error = FT_Init_FreeType( &library ); 

    // ENOTDIR, ENOENT, EACCES
    getcwd(path, MAXPATHLEN);
    if ( argc > 1 ) {  count = scanfont(argv[1], files);  }
               else {  count = scanfont(default_font_path, files);  }
    chdir(path);
    addfont("./DEFAULT.ttf", "__DEFAULT__");

//    show_fonts(faces);  // add to fastcgi host log

    // FCGI loop:
    while(FCGI_Accept() >= 0)
    {
//        for(i=0;environ[i]!=NULL;i++)  fprintf(stderr, "%s\n", environ[i]);
        bzero(&render_params, sizeof(render_params));

//        if ( getenv("OHMYGOD") )
//            fprintf(stderr, "log: %s\n", getenv("OHMYGOD"));

        get_params(getenv("QUERY_STRING"), &render_params);

        if ( render_params.help != NULL && (strncmp(render_params.help, "textdebug", 10) == 0) )
        {
            printf("Content-type: text/html\n\n%s", help_text(&render_params));
        }
        else
        {
            printf("Content-type: image/png\n\n");
            draw(&render_params);
        }
    }
}


int scanfont(char * font_dir, char ** files)
{
    int count = 0;
    struct dirent * entry;
    char path[MAXPATHLEN];
    DIR * dir;

    dir = opendir(font_dir);<commit_msg>Removed env debugging code<commit_after>#include "fasttext.h"

char default_font_path[] = "/usr/share/fonts/";
extern char hash_next_magic[];

FT_Library library; 
hash_entry * faces = NULL;
extern char **environ;
cairo_surface_t * main_surface;
cairo_t * main_context;

int main(int argc, char ** argv)
{
    char **files;
    char path[MAXPATHLEN];
    int error, count, i;

    tr_params render_params;
    main_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, MAX_WIDTH, MAX_HEIGHT);
    main_context = cairo_create(main_surface);

    error = FT_Init_FreeType( &library ); 

    // ENOTDIR, ENOENT, EACCES
    getcwd(path, MAXPATHLEN);
    if ( argc > 1 ) {  count = scanfont(argv[1], files);  }
               else {  count = scanfont(default_font_path, files);  }
    chdir(path);
    addfont("./DEFAULT.ttf", "__DEFAULT__");

//    show_fonts(faces);  // add to fastcgi host log

    // FCGI loop:
    while(FCGI_Accept() >= 0)
    {
//        for(i=0;environ[i]!=NULL;i++)  fprintf(stderr, "%s\n", environ[i]);
        bzero(&render_params, sizeof(render_params));

        get_params(getenv("QUERY_STRING"), &render_params);

        if ( render_params.help != NULL && (strncmp(render_params.help, "textdebug", 10) == 0) )
        {
            printf("Content-type: text/html\n\n%s", help_text(&render_params));
        }
        else
        {
            printf("Content-type: image/png\n\n");
            draw(&render_params);
        }
    }
}


int scanfont(char * font_dir, char ** files)
{
    int count = 0;
    struct dirent * entry;
    char path[MAXPATHLEN];
    DIR * dir;

    dir = opendir(font_dir);
{'fraction_non_alphanumeric': 0.14600715137067938, 'fraction_numerical': 0.0059594755661501785, 'mean_word_length': 2.8675115207373274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6216307', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1173, 'n_words': 232}