/* * @OPENGROUP_COPYRIGHT@ * COPYRIGHT NOTICE * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc. * Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for * the full copyright text. * * This software is subject to an open license. It may only be * used on, with or for operating systems which are themselves open * source systems. You must contact The Open Group for a license * allowing distribution and sublicensing of this software on, with, * or for operating systems which are not Open Source programs. * * See http://www.opengroup.org/openmotif/license for full * details of the license agreement. Any use, reproduction, or * distribution of the program constitutes recipient's acceptance of * this agreement. * * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS * PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY * WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY * OR FITNESS FOR A PARTICULAR PURPOSE * * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT * NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE * EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. */ /* * HISTORY */ #ifdef REV_INFO #ifndef lint static char rcsid[] = "$TOG: wmldbcreate.c /main/8 1997/04/14 12:55:30 dbl $" #endif #endif /* * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */ /* * This is the program creates binary databases from WML output. */ #include #ifndef X_NOT_STDC_ENV #include #endif #include #include #include #include
#include
#include
#include
#include
#include
#include
#include
/* * User supplied widget public.h and/or private.h files are to be added here * #ifdef for automatic use in uilwmdcreate script file */ /* * End of User supplied widget files */ #include "UilDBDef.h" #include "UilLexPars.h" #include "UilSymGen.h" /* from WML */ #include "UilSymArTy.h" /* from WML */ #include "UilSymRArg.h" /* from WML */ #include "UilSymArTa.h" /* from WML */ #include "UilSymReas.h" /* from WML */ #include "UilSymCtl.h" /* from WML */ #include "UilConst.h" /* from WML */ #include "UilSymNam.h" /* from WML */ #include "UilSymEnum.h" /* from WML */ #include "UilSymCSet.h" /* from WML */ #include "UilUrmClas.h" /* from WML */ #include "UilKeyTab.h" /* from WML */ #include "UilSymChCl.h" /* from WML */ #include "UilSymChTa.h" /* from WML */ void emit_globals(); void emit_header(_db_header_ptr header); void emit_chars(int table_id); void emit_ints_and_string( int table_id); void emit_char_table( int table_id); void emit_length_and_string( int table_id); void emit_shorts( int table_id); void emit_int_and_table_shorts( int table_id); void emit_ints( int table_id); FILE *bfile, *afile; int DEBUG=FALSE; char outfilename[80]; char debugfilename[80]; main(argc, argv) int argc; char **argv; { _db_header header; strcpy(outfilename, "motif.wmd"); strcpy(debugfilename, "motif.dbg"); for (argc--, argv++; argc; argc--, argv++) { if (strcmp("-debug", *argv) == 0) { DEBUG=TRUE; } else if ((strcmp("-o", *argv) == 0)) { strcpy(outfilename, argv[1]); } } bfile = fopen(outfilename, "w"); if (bfile == (FILE *) NULL) { printf("\nCouldnt't open %s", outfilename); exit (1); } if (DEBUG) { afile = fopen(debugfilename, "w"); if (afile == (FILE *) NULL) { printf("\nCouldn't open %s", debugfilename); exit (1); } } emit_globals(); /* * UilConst * UilSymArty * UilSymCset - parts of it * UilSymChCl */ emit_chars(Constraint_Tab); emit_chars(Argument_Type_Table_Value); emit_chars(Charset_Wrdirection_Table); emit_chars(Charset_Parsdirection_Table); emit_chars(Charset_Charsize_Table); emit_chars(Child_Class_Table); /* * UilKeyTab */ emit_ints_and_string (Key_Table); emit_ints_and_string (Key_Table_Case_Ins); /* * UilSymArTa * UilSymCtl * UilSymReas * UilSymChTa */ emit_char_table (Allowed_Argument_Table); emit_char_table (Allowed_Control_Table); emit_char_table (Allowed_Reason_Table); emit_char_table (Allowed_Child_Table); /* * UilSymCset * UilSymNam * UilUrmClas */ emit_length_and_string (Charset_Xmstring_Names_Table); emit_length_and_string (Charset_Lang_Names_Table); emit_length_and_string (Uil_Widget_Names); emit_length_and_string (Uil_Argument_Names); emit_length_and_string (Uil_Reason_Names); emit_length_and_string (Uil_Enumval_names); emit_length_and_string (Uil_Charset_Names); emit_length_and_string (Uil_Widget_Funcs); emit_length_and_string (Uil_Argument_Toolkit_Names); emit_length_and_string (Uil_Reason_Toolkit_Names); emit_length_and_string (Uil_Children_Names); /* * UilSymCset * UilSymEnum * UilSymRArg * UilUrmClas */ emit_shorts (Charset_Lang_Codes_Table); emit_shorts (Argument_Enum_Set_Table); emit_shorts (Related_Argument_Table); emit_shorts (Uil_Gadget_Funcs); emit_shorts (Uil_Urm_Nondialog_Class); emit_shorts (Uil_Urm_Subtree_Resource); /* * UilSymEnum */ emit_int_and_table_shorts(Enum_Set_Table); /* * UilSymEnum */ emit_ints (Enumval_Values_Table); exit (0); } void emit_globals() { _db_globals globals; globals.version = DB_Compiled_Version; globals.uil_max_arg = uil_max_arg; globals.uil_max_charset = uil_max_charset; globals.charset_lang_table_max = charset_lang_table_max; globals.uil_max_object = uil_max_object; globals.uil_max_reason = uil_max_reason; globals.uil_max_enumval = uil_max_enumval; globals.uil_max_enumset = uil_max_enumset; globals.key_k_keyword_count = key_k_keyword_count; globals.key_k_keyword_max_length = key_k_keyword_max_length; globals.uil_max_child = uil_max_child; fwrite (&globals, sizeof (_db_globals), 1, bfile); if (DEBUG) fprintf(afile, "%d %d %d %d %d %d %d %d %d %d ", globals.version, globals.uil_max_arg, globals.uil_max_charset, globals.charset_lang_table_max, globals.uil_max_object, globals.uil_max_reason, globals.uil_max_enumval, globals.uil_max_enumset, globals.key_k_keyword_count, globals.key_k_keyword_max_length); } void emit_header(header) _db_header_ptr header; { fwrite (header, sizeof(_db_header), 1, bfile); if (DEBUG) fprintf(afile, "\n\nTableId=%d, NumEntries=%d, TableSize=%d \n", header->table_id, header->num_items, header->table_size); } void emit_chars(table_id) int table_id; { _db_header header; unsigned char *ptr; int i; switch (table_id) { case Constraint_Tab: /* * NOTE: The first entry is not used but we copy it anyway */ header.table_size = sizeof(constraint_tab_vec); header.num_items = header.table_size; header.table_id = Constraint_Tab; ptr = constraint_tab; break; case Argument_Type_Table_Value: /* * NOTE: The first entry is not used but we copy it anyway */ header.table_size = sizeof(argument_type_table_vec); header.num_items = header.table_size; header.table_id = Argument_Type_Table_Value; ptr = argument_type_table; break; case Charset_Wrdirection_Table: /* * NOTE: The first entry is not used but we copy it anyway */ header.table_size = sizeof(charset_wrdirection_table_vec); header.num_items = header.table_size; header.table_id = Charset_Wrdirection_Table; ptr = charset_writing_direction_table; break; case Charset_Parsdirection_Table: /* * NOTE: The first entry is not used but we copy it anyway */ header.table_size = sizeof(charset_parsdirection_table_vec); header.num_items = header.table_size; header.table_id = Charset_Parsdirection_Table; ptr = charset_parsing_direction_table; break; case Charset_Charsize_Table: /* * NOTE: The first entry is not used but we copy it anyway */ header.table_size = sizeof(charset_charsize_table_vec); header.num_items = header.table_size; header.table_id = Charset_Charsize_Table; ptr = charset_character_size_table; break; case Child_Class_Table: /* * NOTE: The first entry is not used but we copy it anyway */ header.table_size = sizeof(child_class_table_vec); header.num_items = header.table_size; header.table_id = Child_Class_Table; ptr = child_class_table; break; } emit_header(&header); fwrite (ptr, header.table_size, 1, bfile); if (DEBUG) { for (i=0; i<=header.num_items; i++) { fprintf(afile, "%d ", ptr[i]); } } } void emit_ints_and_string(table_id) int table_id; { _db_header header; key_keytable_entry_type *table; int i; switch (table_id) { /* * All tables are zero based unless otherwise noted */ case Key_Table: header.table_size = sizeof(key_table_vec); header.num_items = key_k_keyword_count; header.table_id = Key_Table; table = key_table; break; case Key_Table_Case_Ins: header.table_size = sizeof(key_table_case_ins_vec); header.num_items = key_k_keyword_count; header.table_id = Key_Table_Case_Ins; table = key_table_case_ins; break; } emit_header(&header); fwrite (table, header.table_size, 1, bfile); for (i=0; i