93 if ((fd = fopen (file, flag)) == NULL) {
94 fprintf (stderr,
"cannot open file `%s': %s, using %s instead\n",
95 file, strerror (errno), flag[0] ==
'r' ?
"stdin" :
"stdout");
96 fd = flag[0] ==
'r' ? stdin : stdout;
100 fd = flag[0] ==
'r' ? stdin : stdout;
106 int main (
int argc,
char ** argv) {
108 char * infile = NULL, * outfile = NULL, *
input = NULL, * output = NULL;
114 for (
int i = 1;
i < argc;
i++) {
115 if (!strcmp (argv[
i],
"-v") || !strcmp (argv[i],
"--version")) {
117 "QucsConverter " PACKAGE_VERSION
"\n"
118 "Copyright (C) 2004, 2005, 2006, 2007 Stefan Jahn <stefan@lkcc.org>\n"
119 "\nThis is free software; see the source for copying "
120 "conditions. There is NO\n"
121 "warranty; not even for MERCHANTABILITY or FITNESS FOR A "
122 "PARTICULAR PURPOSE.\n");
125 if (!strcmp (argv[i],
"-h") || !strcmp (argv[i],
"--help")) {
127 "Usage: %s [OPTION]...\n\n"
128 " -h, --help display this help and exit\n"
129 " -v, --version display version information and exit\n"
130 " -i FILENAME use file as input file (default stdin)\n"
131 " -o FILENAME use file as output file (default stdout)\n"
132 " -if FORMAT input data specification (e.g. spice)\n"
133 " -of FORMAT output data specification (e.g. qucs)\n"
134 " -a, --noaction do not include netlist actions in the output\n"
135 " -g GNDNODE replace ground node\n"
136 " -d DATANAME data variable specification\n"
137 " -c, --correct enable node correction\n"
138 "\nReport bugs to <" PACKAGE_BUGREPORT
">.\n", argv[0]);
141 else if (!strcmp (argv[i],
"-i")) {
144 else if (!strcmp (argv[i],
"-o")) {
147 else if (!strcmp (argv[i],
"-if")) {
150 else if (!strcmp (argv[i],
"-of")) {
153 else if (!strcmp (argv[i],
"-a") || !strcmp (argv[i],
"--noaction")) {
156 else if (!strcmp (argv[i],
"-g")) {
159 else if (!strcmp (argv[i],
"-d")) {
162 else if (!strcmp (argv[i],
"-c") || !strcmp (argv[i],
"--correct")) {
170 for (
int j = 0; actionset[j].
in != NULL; j++) {
172 if (input && !strcmp (input, actionset[j].in)) {
175 if (output && !strcmp (output, actionset[j].
out)) {
179 return actionset[j].
execute (&actionset[j], infile, outfile);
185 fprintf (stderr,
"invalid input data specification `%s'\n",
186 input ? input :
"not given");
189 fprintf (stderr,
"invalid output data specification `%s'\n",
190 output ? output :
"not given");
192 fprintf (stderr,
"invalid input/output data specification `%s->%s'\n",
193 input ? input :
"not given", output ? output :
"not given");
217 if (!strcmp (action->
out,
"qucs"))
247 if (!strcmp (action->
out,
"qucsdata"))
278 if (!strcmp (action->
out,
"csv")) {
282 fprintf (stderr,
"no data variable given (passed by -d option)\n");
315 if (!strcmp (action->
out,
"touchstone")) {
347 if (!strcmp (action->
out,
"matlab")) {
374 if (!strcmp (action->
out,
"qucsdata")) {
401 if (!strcmp (action->
out,
"qucsdata")) {
428 if (!strcmp (action->
out,
"qucsdata")) {
454 if (!strcmp (action->
out,
"qucsdata")) {
480 if (!strcmp (action->
out,
"qucsdata")) {