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

Diff of /projs/ets/trunk/src/c_datd/cu_msgs.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.56  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25