~ubuntu-branches/ubuntu/trusty/vice/trusty

« back to all changes in this revision

Viewing changes to src/arch/win32/utils/genwinres.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2013-07-28 20:38:23 UTC
  • mfrom: (1.1.10) (9.2.7 sid)
  • Revision ID: package-import@ubuntu.com-20130728203823-1h8s6bcv22oundul
Tags: 2.4.dfsg-1
* New upstream release (closes: #693065, #693641).
* Drop vice-ffmpeg.patch , applied upstream.
* Disable architecture specific compilation (closes: #686400, #714136).

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#define SKIP_LINE              4
37
37
#define OUTPUT_LINE            5
38
38
 
39
 
void process_file(char *filename, FILE *houtput, FILE *moutput)
 
39
void process_file(char *filename, FILE *houtput, FILE *moutput, FILE *soutput)
40
40
{
41
41
    FILE *infile;
42
42
    int state;
43
43
    int res_value = 0;
44
44
    int is_idm = 0;
 
45
    int is_ids = 0;
45
46
 
46
47
    infile = fopen(filename, "rb");
47
48
    if (infile) {
53
54
                switch (state) {
54
55
                    case GET_HEADER_FIRST_BYTE:
55
56
                        is_idm = 0;
 
57
                        is_ids = 0;
56
58
                        header[0] = buffer[buffer_readpointer];
57
59
                        if ((header[0] == 0x0a) || (header[1] == 0x0d)) {
58
60
                            // Empty line, find start of next line.
100
102
                                state = OUTPUT_LINE;
101
103
                            } else if ((header[0] == 'I') && (header[1] == 'D') && (header[2] == 'S')) {
102
104
                                res_value = ids_counter++;
 
105
                                is_ids = 1;
103
106
                                fprintf(houtput, "#define ");
104
107
                                fwrite(header, 1, 3, houtput);
 
108
                                fprintf(soutput, "  { \"");
 
109
                                fwrite(header, 1, 3, soutput);
105
110
                                state = OUTPUT_LINE;
106
111
                            } else if ((header[0] == 'I') && (header[1] == 'D') && (header[2] == 'M')) {
107
112
                                res_value = idm_counter++;
144
149
                            if (is_idm) {
145
150
                                fprintf(moutput, "\", %d }, \n", res_value);
146
151
                            }
 
152
                            if (is_ids) {
 
153
                                fprintf(soutput, "\", %d }, \n", res_value);
 
154
                            }
147
155
                            state = GET_HEADER_FIRST_BYTE;
148
156
                        } else {
149
157
                            fwrite(&buffer[buffer_readpointer], 1, 1, houtput);
150
158
                            if (is_idm) {
151
159
                                fwrite(&buffer[buffer_readpointer], 1, 1, moutput);
152
160
                            }
 
161
                            if (is_ids) {
 
162
                                fwrite(&buffer[buffer_readpointer], 1, 1, soutput);
 
163
                            }
153
164
                        }
154
165
                        buffer_readpointer++;
155
166
                        break;
157
168
            }
158
169
            read_buffer(infile);
159
170
        }
 
171
        fclose(infile);
160
172
    }
161
173
}
162
174
 
163
175
int main(int argc, char **argv)
164
176
{
165
 
    FILE *houtput, *moutput;
 
177
    FILE *houtput, *moutput, *soutput;
166
178
    int i;
167
179
 
168
 
    if (argc < 4) {
169
 
        printf("Usage: genwinres header-houtput menuid-houtput source-filename [source-filenames]\n");
 
180
    if (argc < 5) {
 
181
        printf("Usage: genwinres header-houtput menuid-houtput stringid-houtput source-filename [source-filenames]\n");
170
182
        exit(0);
171
183
    }
172
184
    houtput = fopen(argv[1], "wt");
173
185
    moutput = fopen(argv[2], "wt");
174
 
    if (houtput && moutput) {
 
186
    soutput = fopen(argv[3], "wt");
 
187
    if (houtput && moutput && soutput) {
175
188
        idr_start = idr_counter = 100;
176
189
        idd_start = idd_counter = 100;
177
190
        /* Command ID codes 0-11 and 32000 are used by the OS as well, to be safe we start at 100 */
221
234
        fprintf(moutput, " * Autogenerated genwinres file, DO NOT EDIT !!!\n");
222
235
        fprintf(moutput, " *\n");
223
236
        fprintf(moutput, " */\n");
224
 
        fprintf(moutput, "#ifndef _MENUID_H\n");
225
 
        fprintf(moutput, "#define _MENUID_H\n");
 
237
        fprintf(moutput, "#ifndef VICE_MENUID_H\n");
 
238
        fprintf(moutput, "#define VICE_MENUID_H\n");
226
239
        fprintf(moutput, "\n");
227
240
        fprintf(moutput, "static struct { char *str; int cmd; } idmlist[] = {\n");
228
241
 
229
 
        for (i = 3; i < argc; i++) {
 
242
        fprintf(soutput, "/*\n");
 
243
        fprintf(soutput, " * %s\n", argv[2]);
 
244
        fprintf(soutput, " *\n");
 
245
        fprintf(soutput, " * Autogenerated genwinres file, DO NOT EDIT !!!\n");
 
246
        fprintf(soutput, " *\n");
 
247
        fprintf(soutput, " */\n");
 
248
        fprintf(soutput, "#ifndef VICE_STRINGID_H\n");
 
249
        fprintf(soutput, "#define VICE_STRINGID_H\n");
 
250
        fprintf(soutput, "\n");
 
251
        fprintf(soutput, "static struct { char *str; int cmd; } idslist[] = {\n");
 
252
 
 
253
        for (i = 4; i < argc; i++) {
230
254
            fprintf(houtput, "/*  Definitions from %s  */\n\n", argv[i]);
231
 
            process_file(argv[i], houtput, moutput);
 
255
            process_file(argv[i], houtput, moutput, soutput);
232
256
            fprintf(houtput, "\n");
233
257
        }
234
258
        fprintf(houtput, "#define FIRST_IDR %d\n", idr_start);
251
275
        fprintf(moutput, " { NULL, 0 }\n};\n");
252
276
        fprintf(moutput, "#endif\n");
253
277
 
 
278
        fprintf(soutput, " { NULL, 0 }\n};\n\n");
 
279
        fprintf(soutput, "#define LAST_IDS %d\n\n", ids_counter);
 
280
        fprintf(soutput, "#endif\n");
 
281
    }
 
282
    if (houtput) {
254
283
        fclose(houtput);
 
284
    }
 
285
    if (moutput) {
255
286
        fclose(moutput);
256
287
    }
 
288
    if (soutput) {
 
289
        fclose(soutput);
 
290
    }
257
291
}