~ubuntu-branches/ubuntu/quantal/openmotif/quantal

« back to all changes in this revision

Viewing changes to tools/wml/wmldbcreate.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bauer
  • Date: 2010-06-23 12:12:31 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100623121231-u89gxdp51sg9wjj2
Tags: 2.3.0-1
* New Maintainer (Closes: #379258) 
* Acknowledge NMU changes
* New upstream release (Closes: #494375)
* Get rid of security patches as they are already part of new upstream
  release (00-xpmvuln.openmotif.patch, 342092-CVE-2005-3964.patch)
* Bump Standards to 3.8.4
* Added {misc:Depends} to make the package lintian cleaner
* Fix weak-library-dev-dependency by adding ${binary:Version}) for the
  -dev Package of openmotif
* Let package depend on autotools-dev to use newer autotools-helper-files
* Work around an autoconf-bug (Gentoo-Bug #1475)
* Added Client-side anti-aliased fonts support via XFT
* Added UTF-8 and UTF8_STRING atom support
* Ability to show text and pixmaps in Label, LabelGadget and all
  derived widgets
* Support of PNG/JPEG image formats in the same way as XPM is supported
* Increase FILE_OFFSET_BITS to 64 to show files >2GB in file-selector
  Idea taken from Magne Oestlyngen (Closes: #288537)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 *  @OPENGROUP_COPYRIGHT@
 
3
 *  COPYRIGHT NOTICE
 
4
 *  Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
 
5
 *  Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
 
6
 *  ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
 
7
 *  the full copyright text.
 
8
 *  
 
9
 *  This software is subject to an open license. It may only be
 
10
 *  used on, with or for operating systems which are themselves open
 
11
 *  source systems. You must contact The Open Group for a license
 
12
 *  allowing distribution and sublicensing of this software on, with,
 
13
 *  or for operating systems which are not Open Source programs.
 
14
 *  
 
15
 *  See http://www.opengroup.org/openmotif/license for full
 
16
 *  details of the license agreement. Any use, reproduction, or
 
17
 *  distribution of the program constitutes recipient's acceptance of
 
18
 *  this agreement.
 
19
 *  
 
20
 *  EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
 
21
 *  PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
22
 *  KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
 
23
 *  WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
 
24
 *  OR FITNESS FOR A PARTICULAR PURPOSE
 
25
 *  
 
26
 *  EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
 
27
 *  NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
 
28
 *  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
29
 *  DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
 
30
 *  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
31
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 
32
 *  ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
 
33
 *  EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
 
34
 *  POSSIBILITY OF SUCH DAMAGES.
 
35
*/ 
 
36
/* 
 
37
 * HISTORY
 
38
*/ 
 
39
#ifdef REV_INFO
 
40
#ifndef lint
 
41
static char rcsid[] = "$TOG: wmldbcreate.c /main/8 1997/04/14 12:55:30 dbl $"
 
42
#endif
 
43
#endif
 
44
 
 
45
#ifdef HAVE_CONFIG_H
 
46
#include <config.h>
 
47
#endif
 
48
 
 
49
 
 
50
/*
 
51
*  (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
 
52
 
 
53
/*
 
54
 * This is the program creates binary databases from WML output.
 
55
 */
 
56
 
 
57
 
 
58
#include <stdio.h>
 
59
#ifndef X_NOT_STDC_ENV
 
60
#include <stdlib.h>
 
61
#endif
 
62
 
 
63
#include <Mrm/MrmWidget.h> 
 
64
#include <Xm/Xm.h> 
 
65
#include <Xm/MwmUtil.h>
 
66
 
 
67
#include <Dt/Editor.h>
 
68
#include <Dt/Help.h>
 
69
#include <Dt/HelpDialog.h>
 
70
#include <Dt/HelpQuickD.h>
 
71
#include <Dt/MenuButton.h>
 
72
#include <Dt/Print.h>
 
73
#include <Dt/TermPrim.h>
 
74
#include <Dt/Term.h>
 
75
 
 
76
 
 
77
 
 
78
/*
 
79
 * User supplied widget public.h and/or private.h files are to be added here
 
80
 * #ifdef for automatic use in uilwmdcreate script file
 
81
 */
 
82
 
 
83
 
 
84
/*
 
85
 * End of User supplied widget files
 
86
 */
 
87
 
 
88
 
 
89
#include "UilDBDef.h"
 
90
#include "UilLexPars.h"
 
91
 
 
92
#include "UilSymGen.h" /* from WML */
 
93
#include "UilSymArTy.h" /* from WML */
 
94
#include "UilSymRArg.h" /* from WML */
 
95
#include "UilSymArTa.h" /* from WML */
 
96
#include "UilSymReas.h" /* from WML */
 
97
#include "UilSymCtl.h" /* from WML */
 
98
#include "UilConst.h" /* from WML */
 
99
#include "UilSymNam.h" /* from WML */
 
100
#include "UilSymEnum.h" /* from WML */
 
101
#include "UilSymCSet.h" /* from WML */
 
102
#include "UilUrmClas.h" /* from WML */
 
103
#include "UilKeyTab.h"  /* from WML */
 
104
#include "UilSymChCl.h" /* from WML */
 
105
#include "UilSymChTa.h" /* from WML */
 
106
 
 
107
void emit_globals();
 
108
void emit_header(_db_header_ptr header);
 
109
void emit_chars(int         table_id);
 
110
void emit_ints_and_string( int      table_id);
 
111
void emit_char_table( int       table_id);
 
112
void emit_length_and_string( int        table_id);
 
113
void emit_shorts( int       table_id);
 
114
void emit_int_and_table_shorts( int         table_id);
 
115
void emit_ints( int         table_id);
 
116
 
 
117
FILE *bfile, *afile;
 
118
int DEBUG=FALSE;
 
119
char outfilename[80];
 
120
char debugfilename[80];
 
121
 
 
122
int main(argc, argv)
 
123
int argc;
 
124
char **argv;
 
125
{
 
126
    _db_header  header;
 
127
 
 
128
    strcpy(outfilename, "motif.wmd");
 
129
    strcpy(debugfilename, "motif.dbg");
 
130
 
 
131
    for (argc--, argv++; argc; argc--, argv++)
 
132
        {
 
133
        if (strcmp("-debug", *argv) == 0) 
 
134
            {
 
135
            DEBUG=TRUE;
 
136
            }
 
137
        else if ((strcmp("-o", *argv) == 0))
 
138
                 {
 
139
                 strcpy(outfilename, argv[1]);
 
140
                 }
 
141
        }
 
142
 
 
143
    bfile = fopen(outfilename, "w");
 
144
    if (bfile == (FILE *) NULL)
 
145
        {
 
146
        printf("\nCouldnt't open %s", outfilename);
 
147
        exit (1);
 
148
        }
 
149
    if (DEBUG)
 
150
        {
 
151
        afile = fopen(debugfilename, "w");
 
152
        if (afile == (FILE *) NULL)
 
153
            {
 
154
            printf("\nCouldn't open %s", debugfilename);
 
155
            exit (1);
 
156
            }
 
157
        }
 
158
 
 
159
    emit_globals();
 
160
 
 
161
/*
 
162
 *   UilConst
 
163
 *   UilSymArty
 
164
 *   UilSymCset - parts of it
 
165
 *   UilSymChCl
 
166
 */
 
167
    emit_chars(Constraint_Tab);
 
168
    emit_chars(Argument_Type_Table_Value);
 
169
    emit_chars(Charset_Wrdirection_Table);
 
170
    emit_chars(Charset_Parsdirection_Table);
 
171
    emit_chars(Charset_Charsize_Table);
 
172
    emit_chars(Child_Class_Table); 
 
173
/*
 
174
 *    UilKeyTab
 
175
 */
 
176
    emit_ints_and_string (Key_Table);
 
177
    emit_ints_and_string (Key_Table_Case_Ins);
 
178
/*
 
179
 *   UilSymArTa
 
180
 *   UilSymCtl
 
181
 *   UilSymReas
 
182
 *   UilSymChTa
 
183
 */
 
184
    emit_char_table (Allowed_Argument_Table);
 
185
    emit_char_table (Allowed_Control_Table);
 
186
    emit_char_table (Allowed_Reason_Table);
 
187
    emit_char_table (Allowed_Child_Table);
 
188
/*
 
189
 *   UilSymCset
 
190
 *   UilSymNam
 
191
 *   UilUrmClas
 
192
 */
 
193
    emit_length_and_string (Charset_Xmstring_Names_Table);
 
194
    emit_length_and_string (Charset_Lang_Names_Table);
 
195
    emit_length_and_string (Uil_Widget_Names);
 
196
    emit_length_and_string (Uil_Argument_Names);
 
197
    emit_length_and_string (Uil_Reason_Names);
 
198
    emit_length_and_string (Uil_Enumval_names);
 
199
    emit_length_and_string (Uil_Charset_Names);
 
200
    emit_length_and_string (Uil_Widget_Funcs);
 
201
    emit_length_and_string (Uil_Argument_Toolkit_Names);
 
202
    emit_length_and_string (Uil_Reason_Toolkit_Names);
 
203
    emit_length_and_string (Uil_Children_Names);
 
204
/*
 
205
 *   UilSymCset
 
206
 *   UilSymEnum
 
207
 *   UilSymRArg
 
208
 *   UilUrmClas
 
209
 */
 
210
    emit_shorts (Charset_Lang_Codes_Table);
 
211
    emit_shorts (Argument_Enum_Set_Table);
 
212
    emit_shorts (Related_Argument_Table);
 
213
    emit_shorts (Uil_Gadget_Funcs);
 
214
    emit_shorts (Uil_Urm_Nondialog_Class);
 
215
    emit_shorts (Uil_Urm_Subtree_Resource);
 
216
/*
 
217
 *   UilSymEnum
 
218
 */
 
219
    emit_int_and_table_shorts(Enum_Set_Table);
 
220
/*
 
221
 *   UilSymEnum
 
222
 */
 
223
    emit_ints (Enumval_Values_Table);
 
224
 
 
225
    exit (0);
 
226
 
 
227
    return 0;    /* make compiler happy */
 
228
}
 
229
 
 
230
 
 
231
void emit_globals()
 
232
{
 
233
    _db_globals globals;
 
234
 
 
235
    globals.version = DB_Compiled_Version;
 
236
    globals.uil_max_arg = uil_max_arg;
 
237
    globals.uil_max_charset = uil_max_charset;
 
238
    globals.charset_lang_table_max = charset_lang_table_max;
 
239
    globals.uil_max_object = uil_max_object;
 
240
    globals.uil_max_reason = uil_max_reason;
 
241
    globals.uil_max_enumval = uil_max_enumval;
 
242
    globals.uil_max_enumset = uil_max_enumset;
 
243
    globals.key_k_keyword_count = key_k_keyword_count;
 
244
    globals.key_k_keyword_max_length = key_k_keyword_max_length;
 
245
    globals.uil_max_child = uil_max_child;
 
246
    
 
247
    fwrite (&globals, sizeof (_db_globals), 1, bfile);
 
248
    if (DEBUG)
 
249
        fprintf(afile, "%d %d %d %d %d %d %d %d %d %d ", globals.version,
 
250
                globals.uil_max_arg, globals.uil_max_charset, 
 
251
                globals.charset_lang_table_max, globals.uil_max_object,
 
252
                globals.uil_max_reason, globals.uil_max_enumval, 
 
253
                globals.uil_max_enumset, globals.key_k_keyword_count,
 
254
                globals.key_k_keyword_max_length);
 
255
    }
 
256
 
 
257
 
 
258
 
 
259
void emit_header(header)
 
260
_db_header_ptr header;
 
261
{
 
262
 
 
263
    fwrite (header, sizeof(_db_header), 1, bfile);
 
264
    if (DEBUG)
 
265
        fprintf(afile, 
 
266
                "\n\nTableId=%d, NumEntries=%d, TableSize=%d \n",
 
267
                 header->table_id, header->num_items, header->table_size);
 
268
    }
 
269
 
 
270
 
 
271
 
 
272
void emit_chars(table_id)
 
273
    int     table_id;
 
274
{
 
275
    _db_header      header;
 
276
    unsigned char   *ptr;
 
277
    int             i;
 
278
 
 
279
    switch (table_id)
 
280
        {
 
281
        case Constraint_Tab:
 
282
            /*
 
283
             * NOTE: The first entry is not used but we copy it anyway
 
284
             */
 
285
            header.table_size = sizeof(constraint_tab_vec);
 
286
            header.num_items = header.table_size;
 
287
            header.table_id = Constraint_Tab;
 
288
            ptr = constraint_tab;
 
289
            break;
 
290
        case Argument_Type_Table_Value:
 
291
            /*
 
292
             * NOTE: The first entry is not used but we copy it anyway
 
293
             */
 
294
            header.table_size = sizeof(argument_type_table_vec);
 
295
            header.num_items = header.table_size;
 
296
            header.table_id = Argument_Type_Table_Value;
 
297
            ptr = argument_type_table;
 
298
            break;
 
299
        case Charset_Wrdirection_Table:
 
300
            /*
 
301
             * NOTE: The first entry is not used but we copy it anyway
 
302
             */
 
303
            header.table_size = sizeof(charset_wrdirection_table_vec);
 
304
            header.num_items = header.table_size;
 
305
            header.table_id = Charset_Wrdirection_Table;
 
306
            ptr = charset_writing_direction_table;
 
307
            break;
 
308
        case Charset_Parsdirection_Table:
 
309
            /*
 
310
             * NOTE: The first entry is not used but we copy it anyway
 
311
             */
 
312
            header.table_size = sizeof(charset_parsdirection_table_vec);
 
313
            header.num_items = header.table_size;
 
314
            header.table_id = Charset_Parsdirection_Table;
 
315
            ptr = charset_parsing_direction_table;
 
316
            break;
 
317
        case Charset_Charsize_Table:
 
318
            /*
 
319
             * NOTE: The first entry is not used but we copy it anyway
 
320
             */
 
321
            header.table_size = sizeof(charset_charsize_table_vec);
 
322
            header.num_items = header.table_size;
 
323
            header.table_id = Charset_Charsize_Table;
 
324
            ptr = charset_character_size_table;
 
325
            break;
 
326
        case Child_Class_Table:
 
327
            /*
 
328
             * NOTE: The first entry is not used but we copy it anyway
 
329
             */
 
330
            header.table_size = sizeof(child_class_table_vec);
 
331
            header.num_items = header.table_size;
 
332
            header.table_id = Child_Class_Table;
 
333
            ptr = child_class_table;
 
334
            break;
 
335
        }
 
336
 
 
337
    emit_header(&header);
 
338
 
 
339
    fwrite (ptr, header.table_size, 1, bfile);  
 
340
    if (DEBUG)
 
341
        {
 
342
        for (i=0; i<=header.num_items; i++)
 
343
            {
 
344
            fprintf(afile, "%d ", ptr[i]);
 
345
            }
 
346
        }
 
347
}
 
348
 
 
349
 
 
350
void emit_ints_and_string(table_id)
 
351
    int     table_id;
 
352
{
 
353
    _db_header              header;
 
354
    key_keytable_entry_type *table;
 
355
    int                     i;
 
356
 
 
357
    switch (table_id)
 
358
        {
 
359
        /*
 
360
         * All tables are zero based unless otherwise noted
 
361
         */
 
362
        case Key_Table:
 
363
            header.table_size = sizeof(key_table_vec);
 
364
            header.num_items = key_k_keyword_count;
 
365
            header.table_id = Key_Table;
 
366
            table = key_table;
 
367
            break;
 
368
        case Key_Table_Case_Ins:
 
369
            header.table_size = sizeof(key_table_case_ins_vec);
 
370
            header.num_items = key_k_keyword_count;
 
371
            header.table_id = Key_Table_Case_Ins;
 
372
            table = key_table_case_ins;
 
373
            break;
 
374
        }
 
375
    emit_header(&header);
 
376
 
 
377
    fwrite (table, header.table_size, 1, bfile);
 
378
    for (i=0; i<header.num_items; i++)
 
379
        {
 
380
        fwrite (table[i].at_name, table[i].b_length + 1, 1, bfile);
 
381
        if (DEBUG)
 
382
            fprintf (afile, "%d %d %d %d %s", table[i].b_class, table[i].b_subclass,
 
383
                 table[i].b_length, table[i].b_token, table[i].at_name);
 
384
        }
 
385
               
 
386
}
 
387
 
 
388
 
 
389
void emit_char_table(table_id)
 
390
int     table_id;
 
391
{
 
392
    unsigned char **table;
 
393
    _db_header header;
 
394
    unsigned char *entry_vec;
 
395
    int i, j;
 
396
    int num_bits = (uil_max_object + 7) / 8;
 
397
 
 
398
    switch (table_id)
 
399
        {
 
400
        /*
 
401
         * All tables are 1 based unless otherwise specified
 
402
         */
 
403
        case Allowed_Argument_Table:
 
404
            header.table_size = sizeof(allowed_argument_table_vec);
 
405
            header.num_items = uil_max_arg;
 
406
            header.table_id = Allowed_Argument_Table;
 
407
            table = allowed_argument_table;
 
408
            break;
 
409
        case Allowed_Control_Table:
 
410
            header.table_size = sizeof(allowed_control_table_vec);
 
411
            header.num_items = uil_max_object;
 
412
            header.table_id = Allowed_Control_Table;
 
413
            table = allowed_control_table;
 
414
            break;
 
415
        case Allowed_Reason_Table:
 
416
            header.table_size = sizeof(allowed_reason_table_vec);
 
417
            header.num_items = uil_max_reason;
 
418
            header.table_id = Allowed_Reason_Table;
 
419
            table = allowed_reason_table;
 
420
            break;
 
421
        case Allowed_Child_Table:
 
422
            header.table_size = sizeof(allowed_child_table_vec);
 
423
            header.num_items = uil_max_child;
 
424
            header.table_id = Allowed_Child_Table;
 
425
            table = allowed_child_table;
 
426
            break;
 
427
        }
 
428
 
 
429
    emit_header(&header);
 
430
 
 
431
    for (i=1; i<=header.num_items; i++)   /* First not used */
 
432
        {
 
433
        entry_vec = table[i];
 
434
        fwrite (entry_vec, sizeof (char) * num_bits, 1, bfile);
 
435
        if (DEBUG)
 
436
            {
 
437
            for (j=0; j<num_bits; j++)
 
438
                {
 
439
                fprintf (afile, "%d, ", entry_vec[j]);
 
440
                }
 
441
            fprintf (afile, "\n");
 
442
            }
 
443
        }
 
444
}
 
445
 
 
446
 
 
447
void emit_length_and_string(table_id)
 
448
int     table_id;
 
449
{
 
450
    _db_header  header;
 
451
    int         *lengths;
 
452
    char        *string_table;
 
453
    char        **table;
 
454
    int         i;
 
455
 
 
456
    switch (table_id)
 
457
        {
 
458
        /*
 
459
         * all the tables are 1 based unless otherwise documented
 
460
         */
 
461
        case Charset_Xmstring_Names_Table:
 
462
            header.table_size = sizeof(charset_xmstring_names_table_vec);
 
463
            header.num_items = uil_max_charset;
 
464
            header.table_id = Charset_Xmstring_Names_Table;
 
465
            table = charset_xmstring_names_table;
 
466
            break;
 
467
        case Charset_Lang_Names_Table:
 
468
            /*
 
469
             * This table is 0 based
 
470
             */
 
471
            header.table_size = sizeof(charset_lang_names_table_vec);
 
472
            header.num_items = charset_lang_table_max - 1;
 
473
            header.table_id = Charset_Lang_Names_Table;
 
474
            table = charset_lang_names_table;
 
475
            break;
 
476
        case Uil_Widget_Names:
 
477
            header.table_size = sizeof(uil_widget_names_vec);
 
478
            header.num_items = uil_max_object;
 
479
            header.table_id = Uil_Widget_Names;
 
480
            table = uil_widget_names ;
 
481
            break;
 
482
        case Uil_Argument_Names:
 
483
            header.table_size = sizeof(uil_argument_names_vec);
 
484
            header.num_items = uil_max_arg;
 
485
            header.table_id = Uil_Argument_Names;
 
486
            table = uil_argument_names;
 
487
            break;
 
488
        case Uil_Reason_Names:
 
489
            header.table_size = sizeof(uil_reason_names_vec);
 
490
            header.num_items = uil_max_reason;
 
491
            header.table_id = Uil_Reason_Names;
 
492
            table = uil_reason_names;
 
493
            break;
 
494
        case Uil_Enumval_names:
 
495
            header.table_size = sizeof(uil_enumval_names_vec);
 
496
            header.num_items = uil_max_enumval;
 
497
            header.table_id = Uil_Enumval_names;
 
498
            table = uil_enumval_names;
 
499
            break;
 
500
        case Uil_Charset_Names:
 
501
            header.table_size = sizeof(uil_charset_names_vec);
 
502
            header.num_items = uil_max_charset;
 
503
            header.table_id = Uil_Charset_Names;
 
504
            table = uil_charset_names;
 
505
            break;
 
506
        case Uil_Widget_Funcs:
 
507
            header.table_size = sizeof(uil_widget_funcs_vec);
 
508
            header.num_items = uil_max_object;
 
509
            header.table_id = Uil_Widget_Funcs;
 
510
            table = uil_widget_funcs;
 
511
            break;
 
512
        case Uil_Argument_Toolkit_Names:
 
513
            header.table_size = sizeof(uil_argument_toolkit_names_vec);
 
514
            header.num_items = uil_max_arg;
 
515
            header.table_id = Uil_Argument_Toolkit_Names;
 
516
            table = uil_argument_toolkit_names;
 
517
            break;
 
518
        case Uil_Reason_Toolkit_Names:
 
519
            header.table_size = sizeof(uil_reason_toolkit_names_vec);
 
520
            header.num_items = uil_max_reason;
 
521
            header.table_id = Uil_Reason_Toolkit_Names;
 
522
            table = uil_reason_toolkit_names;
 
523
            break;
 
524
        case Uil_Children_Names:
 
525
            header.table_size = sizeof(uil_child_names_vec);
 
526
            header.num_items = uil_max_child;
 
527
            header.table_id = Uil_Children_Names;
 
528
            table = uil_child_names ;
 
529
            break;
 
530
        }
 
531
 
 
532
    emit_header(&header);
 
533
 
 
534
    lengths = (int *) malloc (sizeof (int) * (header.num_items + 1));
 
535
 
 
536
    for (i=0; i<=header.num_items; i++)
 
537
        {
 
538
        if (table[i] != NULL)
 
539
            {
 
540
            /*
 
541
             * Add one to the length for the null terminator
 
542
             */
 
543
            lengths[i] = strlen(table[i]) + 1;
 
544
            }
 
545
        else
 
546
            {
 
547
            lengths[i] = 0;
 
548
            }
 
549
        if (DEBUG)
 
550
            fprintf (afile, "%d ", lengths[i]);
 
551
        }
 
552
    fwrite (lengths, sizeof (int) * (header.num_items + 1), 1, bfile);
 
553
    for (i=0; i<=header.num_items; i++)
 
554
        {
 
555
        if (lengths[i])
 
556
            {
 
557
            /*
 
558
             * assumed lengths[i] = lengths[i] * sizeof(char)
 
559
             * Add one for the null terminator
 
560
             */
 
561
            fwrite (table[i], lengths[i] + 1, 1, bfile);
 
562
            if (DEBUG)
 
563
                fprintf (afile, "%s ", table[i]);
 
564
            }
 
565
        }
 
566
    free (lengths);
 
567
}
 
568
 
 
569
 
 
570
void emit_shorts(table_id)
 
571
    int     table_id;
 
572
{
 
573
    _db_header          header;
 
574
    unsigned short int  *ptr;
 
575
    int                 i;
 
576
 
 
577
    switch (table_id)
 
578
        {
 
579
        /* 
 
580
         * All tables are 1 based unless otherwise noted
 
581
         */
 
582
        case Charset_Lang_Codes_Table:
 
583
            /*
 
584
             * 0 based table
 
585
             */
 
586
            header.table_size = sizeof(charset_lang_codes_table_vec);
 
587
            header.num_items = charset_lang_table_max - 1;
 
588
            header.table_id = Charset_Lang_Codes_Table;
 
589
            ptr = charset_lang_codes_table;
 
590
            break;
 
591
        case Argument_Enum_Set_Table:
 
592
            header.table_size = sizeof(argument_enumset_table_vec);
 
593
            header.num_items = uil_max_arg;
 
594
            header.table_id = Argument_Enum_Set_Table;
 
595
            ptr = argument_enumset_table;
 
596
            break;
 
597
        case Related_Argument_Table:
 
598
            header.table_size = sizeof(related_argument_table_vec);
 
599
            header.num_items = uil_max_arg;
 
600
            header.table_id = Related_Argument_Table;
 
601
            ptr = related_argument_table;
 
602
            break;
 
603
        case Uil_Gadget_Funcs:
 
604
            header.table_size = sizeof(uil_gadget_variants_vec);
 
605
            header.num_items = uil_max_object;
 
606
            header.table_id = Uil_Gadget_Funcs;
 
607
            ptr = uil_gadget_variants;
 
608
            break;
 
609
        case Uil_Urm_Nondialog_Class:
 
610
            header.table_size = sizeof(uil_urm_nondialog_class_vec);
 
611
            header.num_items = uil_max_object;
 
612
            header.table_id = Uil_Urm_Nondialog_Class;
 
613
            ptr = uil_urm_nondialog_class;
 
614
            break;
 
615
        case Uil_Urm_Subtree_Resource:
 
616
            header.table_size = sizeof(uil_urm_subtree_resource_vec);
 
617
            header.num_items = uil_max_object;
 
618
            header.table_id = Uil_Urm_Subtree_Resource;
 
619
            ptr = uil_urm_subtree_resource;
 
620
            break;
 
621
        }
 
622
 
 
623
    emit_header(&header);
 
624
 
 
625
    fwrite (ptr, header.table_size, 1, bfile);  
 
626
    if (DEBUG)
 
627
        {
 
628
        for (i=0; i<header.num_items; i++)
 
629
            {
 
630
            fprintf(afile, "%d ", ptr[i]);
 
631
            }
 
632
        }
 
633
}
 
634
 
 
635
 
 
636
void emit_int_and_table_shorts(table_id)
 
637
    int     table_id;
 
638
{
 
639
    _db_header          header;
 
640
    UilEnumSetDescDef   *table;
 
641
    int                 j, i;
 
642
    unsigned short int  *value_vec;
 
643
 
 
644
    switch (table_id)
 
645
        {
 
646
        /*
 
647
         * All tables are 1 based unless otherwise noted
 
648
         */
 
649
        case Enum_Set_Table:
 
650
            header.table_size = sizeof(enum_set_table_vec);
 
651
            header.num_items = uil_max_enumset;
 
652
            header.table_id = Enum_Set_Table;
 
653
            table = enum_set_table;
 
654
            break;
 
655
        }
 
656
 
 
657
    emit_header(&header);
 
658
    fwrite (table, header.table_size, 1, bfile);
 
659
    for (i=0; i<=header.num_items; i++) /* first is not used */
 
660
        {
 
661
        if (table[i].values_cnt)
 
662
            {
 
663
            fwrite (table[i].values, sizeof (short) * table[i].values_cnt, 1, bfile);
 
664
            }
 
665
        }
 
666
}
 
667
 
 
668
 
 
669
void emit_ints(table_id)
 
670
    int     table_id;
 
671
{
 
672
    _db_header  header;
 
673
    int         *ptr;
 
674
    int         i;
 
675
 
 
676
    switch (table_id)
 
677
        /*
 
678
         * all tables are 1 based unless otherwise noted
 
679
         */
 
680
        {
 
681
        case Enumval_Values_Table:
 
682
            header.table_size = sizeof(enumval_values_table_vec);
 
683
            header.num_items = uil_max_enumval;
 
684
            header.table_id = Enumval_Values_Table;
 
685
            ptr = enumval_values_table;
 
686
            break;
 
687
        }
 
688
 
 
689
    emit_header(&header);
 
690
 
 
691
    fwrite (ptr, header.table_size, 1, bfile);  
 
692
    if (DEBUG)
 
693
        {
 
694
        for (i=0; i<header.num_items; i++)
 
695
            {
 
696
            fprintf(afile, "%d ", ptr[i]);
 
697
            }
 
698
        }
 
699
}
 
700