Debian Codegraph @

demos/unsupported/uilsymdump/uilsymdump.c

raw symbols SCIP
1 /*
2 * Motif
3 *
4 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
5 *
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
16 * details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
22 */
23 #ifdef REV_INFO
24 #ifndef lint
25 static char rcsid[] = "$TOG: uilsymdump.c /main/6 1998/04/17 11:26:22 mgreess $"
26 #endif
27 #endif
28
29 #include <uil/UilDef.h>
30 #include <stdio.h>
31 #include <ctype.h>
32
33 /*
34 **
35 ** Table of Contents
36 **
37 */
38 Uil_status_type MessageCB ();
39 Uil_status_type StatusCB ();
40
41
42 /*
43 ** globals
44 */
45 FILE *source_file;
46
47
48 /*
49 ** Entry point
50 */
51 int
52 main(int argc, char *argv[])
53 {
54 Uil_command_type command_desc;
55 Uil_compile_desc_type compile_desc;
56 Uil_status_type return_status;
57 int x = 1, y = 1;
58 char *include_list[3];
59 char file_name[255], listing_name[255], uid_name[255];
60
61 /*
62 ** Ask for the file name.
63 */
64 printf("Enter file to be compiled (leave off the .uil): ");
65
66 *file_name = '\0';
67 fgets (file_name, sizeof(file_name), stdin);
68 if (strlen(file_name) && file_name[strlen(file_name)-1] == '\n')
69 file_name[strlen(file_name)-1] = '\0';
70
71 strcpy (uid_name, file_name); strcat (uid_name, ".uid");
72 strcpy (listing_name, file_name); strcat (listing_name, ".lis");
73 strcat (file_name, ".uil");
74
75 /*
76 ** Fill in the command decs
77 */
78 command_desc.resource_file = uid_name;
79 command_desc.listing_file = listing_name;
80 command_desc.include_dir_count = 2;
81 command_desc.include_dir = (char **)include_list;
82 command_desc.source_file = file_name;
83 include_list[0] = "com:";
84 include_list[1] = "../include";
85
86
87 command_desc.listing_file_flag = 1;
88 command_desc.resource_file_flag = 1;
89 command_desc.machine_code_flag = 1;
90 command_desc.report_info_msg_flag = 1;
91 command_desc.report_warn_msg_flag = 1;
92 command_desc.parse_tree_flag = 1;
93 command_desc.status_update_delay = 400;
94
95 return_status = Uil(&command_desc, &compile_desc, MessageCB, (char *)&x,
96 StatusCB, (char *)&y);
97
98 UilDumpSymbolTable( (sym_entry_type *)compile_desc.parse_tree_root );
99 return return_status;
100 }
101
102 Uil_status_type MessageCB( message_user_data,
103 msg_number,
104 msg_severity,
105 msg_text,
106 src_text,
107 ptr_text,
108 loc_text,
109 message_summary)
110
111 int *message_user_data; /* Opaque, user-supplied argument */
112 int msg_number; /* constant to identify the error */
113 int msg_severity; /* severity level */
114 char *msg_text; /* text of message */
115 char *src_text; /* text of source line on which error occured */
116 char *ptr_text; /* source column information */
117 char *loc_text; /* location line */
118 unsigned int (*message_summary)[Uil_k_max_status+1];
119
120 {
121 printf ("Message(%d) -- %d-%d-%s\n %s\n %s\n %s\n",
122 *message_user_data, msg_number, msg_severity, msg_text,
123 src_text, ptr_text, loc_text);
124
125 *message_user_data = *message_user_data + 1;
126 return Uil_k_continue;
127 }
128
129
130
131 Uil_status_type StatusCB( status_user_data,
132 percent_complete,
133 lines_processed,
134 current_file,
135 message_summary)
136
137 int *status_user_data;
138 unsigned int percent_complete;
139 unsigned int lines_processed;
140 char *current_file;
141 unsigned int (*message_summary)[Uil_k_max_status+1];
142
143 {
144 printf("Status(%d) -- Percent: %d, Lines: %d, File: %s\n",
145 *status_user_data, percent_complete, lines_processed, current_file);
146
147 *status_user_data = *status_user_data + 1;
148 return Uil_k_continue;
149 }
150