ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

static int gc_to_bin ( grammar  id,
const char in,
const char out 
) [static]

Definition at line 10 of file gc_to_bin.c.

Referenced by main().

{
    FILE *f;
    byte *source, *prod;
    unsigned int size, i, line = 0;

    printf ("Precompiling %s\n", in);

    f = fopen (in, "r");
    if (f == NULL)
        return 1;
    fseek (f, 0, SEEK_END);
    size = ftell (f);
    fseek (f, 0, SEEK_SET);
    source = (byte *) grammar_alloc_malloc (size + 1);
    source[fread (source, 1, size, f)] = '\0';
    fclose (f);

    if (!grammar_fast_check (id, source, &prod, &size, 65536))
    {
        grammar_alloc_free (source);
        return 1;
    }

    f = fopen (out, "w");
    fprintf (f, "\n");
    fprintf (f, "/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */\n");
    fprintf (f, "/* %s */\n", in);
    fprintf (f, "\n");
    for (i = 0; i < size; i++)
    {
        unsigned int a;
        if (prod[i] < 10)
            a = 1;
        else if (prod[i] < 100)
            a = 2;
        else
            a = 3;
        if (i < size - 1)
            a++;
        if (line + a >= 100)
        {
            fprintf (f, "\n");
            line = 0;
        }
        line += a;
        fprintf (f, "%d", prod[i]);
        if (i < size - 1)
            fprintf (f, ",");
    }
    fprintf (f, "\n");
    fclose (f);
    grammar_alloc_free (prod);
   return 0;
}

Generated on Sun May 27 2012 04:59:23 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.