FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/ccd/cdt.c @ 648:970d6199f2c5
gsm-fw/ccd/*.[ch]: initial import from the LoCosto source
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 04 Sep 2014 05:48:57 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
647:a60b375014e3 | 648:970d6199f2c5 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : | |
4 | Modul : cdt.c | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : Ccddata tool. Delivers informations from ccddata_dll.dll. | |
18 +----------------------------------------------------------------------------- | |
19 */ | |
20 | |
21 /*==== INCLUDES =============================================================*/ | |
22 #include "typedefs.h" | |
23 #include "ccdtable.h" | |
24 #include "ccddata.h" | |
25 | |
26 #include <stdio.h> | |
27 #include <string.h> | |
28 | |
29 static char* | |
30 #include "ccddata_version.h" | |
31 ; | |
32 | |
33 /*==== CONSTS ================================================================*//*==== TYPES =================================================================*/ | |
34 /*==== LOCALS ================================================================*/ | |
35 static int ccddata_version; | |
36 static int ccddata_table_version; | |
37 static char* cdt_ccddata_dllname; | |
38 /*==== PRIVATE FUNCTIONS =====================================================*/ | |
39 /* | |
40 +------------------------------------------------------------------------------ | |
41 | Function : parse_cmdline | |
42 +------------------------------------------------------------------------------ | |
43 | Description : Checks options and parameters. | |
44 | | |
45 | Parameters : Argc and argv from main. | |
46 | | |
47 | Return : 0 if correct cmdline, -1 otherwise. | |
48 | | |
49 +------------------------------------------------------------------------------ | |
50 */ | |
51 static int parse_cmdline (int argc, char* argv[]) | |
52 { | |
53 int ac = 1; | |
54 | |
55 if (argc < 2) | |
56 return -1; | |
57 | |
58 while (ac < argc) | |
59 { | |
60 char* av; | |
61 av = argv[ac]; | |
62 switch (av[0]) | |
63 { | |
64 case '-': | |
65 if (!strcmp (&av[1], "cdv")) /* Ccddata version */ | |
66 { | |
67 ccddata_version = 1; | |
68 } | |
69 else if (!strcmp (&av[1], "tv")) /* Table version */ | |
70 { | |
71 ccddata_table_version = 1; | |
72 } | |
73 else if (!strcmp (&av[1], "l")) /* Cccdata dll */ | |
74 { | |
75 ++ac; | |
76 cdt_ccddata_dllname = argv[ac]; | |
77 } | |
78 else | |
79 { | |
80 fprintf (stderr, "Unknown option: %s\n", av); | |
81 return -1; | |
82 } | |
83 break; | |
84 default: | |
85 return -1; | |
86 } | |
87 ac++; | |
88 } | |
89 return 0; | |
90 } | |
91 | |
92 | |
93 /* | |
94 +------------------------------------------------------------------------------ | |
95 | Function : usage | |
96 +------------------------------------------------------------------------------ | |
97 | Description : Print usage information. | |
98 | | |
99 | Parameters : tapname - The name of the tap executable. | |
100 | | |
101 | Return : - | |
102 | | |
103 +------------------------------------------------------------------------------ | |
104 */ | |
105 | |
106 static void usage (char* cdtname) | |
107 { | |
108 fprintf (stderr, "Usage: %s [options]\n", cdtname); | |
109 fprintf (stderr, " Options:\n"); | |
110 fprintf (stderr, " -cdv: print version of ccddata dll\n"); | |
111 fprintf (stderr, " -tv: print version ccddata tables\n"); | |
112 fprintf (stderr, " -l <ccddata-dll>: select dedicated ccddata dll\n"); | |
113 } | |
114 | |
115 /*==== PUBLIC FUNCTIONS ======================================================*/ | |
116 | |
117 /* | |
118 +------------------------------------------------------------------------------ | |
119 | Function : main | |
120 +------------------------------------------------------------------------------ | |
121 | Description : The start into happiness. | |
122 | | |
123 | Parameters : As usual. See parse_cmdline() and usage() for details. | |
124 | | |
125 | Return : 0 | |
126 | | |
127 +------------------------------------------------------------------------------ | |
128 */ | |
129 | |
130 int main (int argc, char** argv) | |
131 { | |
132 printf ("Ccddata tool %s\n", CCDDATA_VERSION); | |
133 | |
134 if (parse_cmdline (argc, argv) < 0) | |
135 { | |
136 char *cdtbase; | |
137 cdtbase = strrchr (argv[0], '\\'); | |
138 if (!cdtbase) | |
139 cdtbase = strrchr (argv[0], '/'); | |
140 usage (cdtbase ? cdtbase+1 : argv[0]); | |
141 return -1; | |
142 } | |
143 | |
144 if (ccddata_init (cdt_ccddata_dllname, 0, NULL, NULL) != CCDDATA_DLL_OK) | |
145 { | |
146 fprintf (stderr, "Cannot load ccddata dll"); | |
147 return -1; | |
148 } | |
149 | |
150 if (ccddata_version) | |
151 printf ("Version: %s\n", ccddata_get_version()); | |
152 if (ccddata_table_version) | |
153 printf ("Table version: %d\n", ccddata_get_table_version()); | |
154 | |
155 ccddata_exit (); | |
156 | |
157 return 0; | |
158 } |