/[dtapublic]/projs/ets/trunk/src/lib_c/c_datd/cu_msgs.c
ViewVC logotype

Contents of /projs/ets/trunk/src/lib_c/c_datd/cu_msgs.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 222 - (show annotations) (download)
Sun Jul 22 16:09:29 2018 UTC (6 years ago) by dashley
File MIME type: text/plain
File size: 6192 byte(s)
Reorganize.
1 //$Header$
2 //-------------------------------------------------------------------------------------------------
3 //This file is part of "David T. Ashley's Shared Source Code", a set of shared components
4 //integrated into many of David T. Ashley's projects.
5 //-------------------------------------------------------------------------------------------------
6 //This source code and any program in which it is compiled/used is provided under the MIT License,
7 //reproduced below.
8 //-------------------------------------------------------------------------------------------------
9 //Permission is hereby granted, free of charge, to any person obtaining a copy of
10 //this software and associated documentation files(the "Software"), to deal in the
11 //Software without restriction, including without limitation the rights to use,
12 //copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the
13 //Software, and to permit persons to whom the Software is furnished to do so,
14 //subject to the following conditions :
15 //
16 //The above copyright notice and this permission notice shall be included in all
17 //copies or substantial portions of the Software.
18 //
19 //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
22 //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 //SOFTWARE.
26 //-------------------------------------------------------------------------------------------------
27 #define MODULE_CU_MSGS
28
29 #include <assert.h>
30 #include <stdio.h>
31 #include <string.h>
32 #include <time.h>
33
34 #include "cu_msgs.h"
35 #include "fcmiof.h"
36
37
38 #define CU_MSGS_TOOLSET_VERSION "1.06.0000"
39
40
41 void CU_MSGS_too_few_args_msg(FILE *s, const char *pname)
42 {
43 assert(s != NULL);
44 assert(pname != NULL);
45
46 fprintf(s, "Too few command-line arguments. Use \"%s -help\" for help.\n", pname);
47 }
48
49
50 void CU_MSGS_toolset_info_msg(FILE *s, const char *pname)
51 {
52 int i;
53
54 static char *p[] =
55 {
56 "This command-line tool is part of The ESRG Tool Set, Version "
57 CU_MSGS_TOOLSET_VERSION ",",
58 "available for free download at http://ijutools.sourceforge.net. This is an",
59 "open-source product, licensed under the GNU Public License, and all source",
60 "code and many additional tools and supplemental materials are also available",
61 "for free download from the URL cited above. Full documentation for this",
62 "utility is maintained in the book (a work in progress) entitled \"A Practit-",
63 "ioner's Guide To The Design And Development Of Small Microcontroller Soft-",
64 "ware\", also available for free download both in .PDF format and as LaTeX",
65 "source code from the URL cited above."
66 };
67
68 assert(s != NULL);
69 assert(pname != NULL);
70
71 for (i=0; i<sizeof(p)/sizeof(p[0]); i++)
72 {
73 fprintf(s, "%s\n", p[i]);
74 }
75 }
76
77
78 void CU_MSGS_std_options(FILE *s, const char *pname)
79 {
80 assert(s != NULL);
81 assert(pname != NULL);
82
83 printf(" -help\n");
84 printf(" Displays the help message for this tool.\n");
85 printf(" -verbose (-v)\n");
86 printf(" Displays intermediate results and other useful information leading to\n");
87 printf(" final result.\n");
88 printf(" -noformat (-nf)\n");
89 printf(" Suppresses attractive formatting of information. This option is\n");
90 printf(" useful if the output will be captured and supplied as input to another\n");
91 printf(" program.\n");
92 printf(" -debug\n");
93 printf(" Displays information useful in debugging.\n");
94 }
95
96
97 void CU_MSGS_cmd_line_par_results_struct_create(
98 CU_MSGS_std_cmd_line_par_results_struct *arg)
99 {
100 assert(arg != NULL);
101
102 memset(arg, 0, sizeof(CU_MSGS_std_cmd_line_par_results_struct));
103 }
104
105
106 void CU_MSGS_cmd_line_par_results_struct_process_arg(
107 CU_MSGS_std_cmd_line_par_results_struct *argblock,
108 const char *arg,
109 int *recognized)
110 {
111 assert(argblock != NULL);
112 assert(arg != NULL);
113 assert(recognized != NULL);
114
115 *recognized = 1;
116
117 if (!strcmp("-debug", arg))
118 {
119 argblock->debug = 1;
120 }
121 else if (!strcmp("-nf", arg) || !strcmp("-noformat", arg))
122 {
123 argblock->noformat = 1;
124 }
125 else if (!strcmp("-v", arg) || !strcmp("-verbose", arg))
126 {
127 argblock->verbose = 1;
128 }
129 else if (!strcmp("-help", arg) || !strcmp("-h", arg))
130 {
131 argblock->help = 1;
132 }
133 else
134 {
135 *recognized = 0;
136 }
137 }
138
139
140 void CU_MSGS_cmd_line_par_results_struct_finalize(
141 CU_MSGS_std_cmd_line_par_results_struct *arg)
142 {
143 assert(arg != NULL);
144
145 //-verbose and -debug cancel out -noformat.
146 if (arg->verbose || arg->debug)
147 arg->noformat = 0;
148 }
149
150
151 void CU_MSGS_cmd_line_par_results_struct_destroy(
152 CU_MSGS_std_cmd_line_par_results_struct *arg)
153 {
154 assert(arg != NULL);
155
156 //Do nothing. No destruction required. Just left as a hook
157 //in case dynamic allocation is ever required.
158 }
159
160
161 void CU_MSGS_emit_vcinfo_from_ptr_table(FILE *s,
162 const char *(**ptrs)(void),
163 const char *pname)
164 {
165 const char *mptr;
166
167 //Be sure the stream block is OK.
168 assert(s != NULL);
169
170 //Be sure the passed pointer to a pointer is not NULL.
171 assert(ptrs != NULL);
172
173 //Be sure the description is alright.
174 assert(pname != NULL);
175
176 //Print explanation.
177 fprintf(s, "%s Version Control Manifest\n", pname);
178 FCMIOF_stream_hline(s);
179
180 //As long as the pointers are not NULL, call the function,
181 //emit the information returned.
182
183 while (*ptrs)
184 {
185 mptr = (**ptrs)();
186 assert(mptr != NULL);
187 fprintf(s, "%s\n", mptr);
188 ptrs++;
189 }
190 }
191
192
193 const char *CU_MSGS_cvcinfo(void)
194 {
195 return("$Header$");
196 }
197
198
199 const char *CU_MSGS_hvcinfo(void)
200 {
201 return(CU_MSGS_H_VERSION);
202 }
203
204 //End of cu_msgs.c.

Properties

Name Value
svn:eol-style native
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25