1 /* gEDA - GPL Electronic Design Automation
2 * gnetlist - gEDA Netlist
3 * Copyright (C) 1998-2000 Ales V. Hvezda
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
34 #include <libgeda/libgeda.h>
36 #include "../include/globals.h"
37 #include "../include/prototype.h"
39 #ifdef HAVE_LIBDMALLOC
43 #define OPTIONS "o:qieIhvsg:c:l:m:O:"
45 #ifndef OPTARG_IN_UNISTD
51 /* Added by SDB 3.3.2006. */
52 #ifdef HAVE_GETOPT_LONG
53 struct option long_options
[] =
56 /* will add other args later */
65 printf("Usage: %s [OPTIONS] filename1 ... filenameN\n", cmd
);
66 printf(" -e Force embedding contents of .include file\n");
67 printf(" -h --help Print this help string\n");
68 printf(" -i Interactive scheme mode\n");
69 printf(" -I Put .INCLUDE <filename> in output file instead\n");
70 printf(" of model file's contents\n");
71 printf(" -q Quiet mode\n");
72 printf(" -l filename Load scheme file before loading backend\n");
73 printf(" -m filename Load scheme file after loading backend,\n");
74 printf(" but still before executing procedure\n");
75 printf(" -g proc Scheme procedure to execute.\n");
76 printf(" Use '-g help' to list available backends.\n");
77 printf(" -o filename Output netlist filename\n");
78 printf(" -c string Execute string as a scheme script\n");
79 printf(" -O option Pass the given option to the backend\n");
80 printf(" -v Verbose mode on\n");
81 printf(" -s Sort output netlist (for Gnucap)\n");
86 /* --------------------------------------------------------------- *
87 * create_command_line takes argc and argv, and returns a single
88 * string which is the command line used to invoke the program.
89 * It is used to pass the command invocation to the SPICE netlist
90 * for inclusion on the first SPICE line.
92 * --------------------------------------------------------------- */
93 char *create_command_line(int argc
, char *argv
[])
96 char *local_command_line
= NULL
;
98 local_command_line
= g_strdup (argv
[0]); /* Initialize command line string */
99 for (i
= 1; i
< argc
; i
++) {
100 local_command_line
= g_strconcat (local_command_line
, " ", argv
[i
], NULL
);
102 return local_command_line
;
107 /* from guile (libguile/gh_init.c) */
109 catch_handler (void *data
, SCM tag
, SCM throw_args
)
111 fprintf (stderr
, "\nJust got an error; tag is\n ");
112 scm_display (tag
, scm_current_output_port ());
113 scm_newline (scm_current_output_port ());
114 scm_newline (scm_current_output_port ());
119 int parse_commandline(int argc
, char *argv
[])
123 /* Converted to getopt_long by SDB 3.3.2006 */
124 #ifdef HAVE_GETOPT_LONG
125 int option_index
= 0;
127 while ((ch
= getopt_long(argc
, argv
, OPTIONS
, long_options
, &option_index
)) != -1) {
129 while ((ch
= getopt(argc
, argv
, OPTIONS
)) != -1) {
134 backend_params
= g_slist_append(backend_params
, "verbose_mode");
139 backend_params
= g_slist_append(backend_params
, "interactive_mode");
140 interactive_mode
= TRUE
;
144 backend_params
= g_slist_append(backend_params
, "include_mode");
149 backend_params
= g_slist_append(backend_params
, "embedd_mode");
154 backend_params
= g_slist_append(backend_params
, "quiet_mode");
159 guile_proc
= (char *) g_malloc(sizeof(char) *
160 (strlen(optarg
) + 1));
161 strcpy(guile_proc
, optarg
);
166 pre_backend_list
= g_slist_append(pre_backend_list
, optarg
);
170 post_backend_list
= g_slist_append(post_backend_list
, optarg
);
174 if (output_filename
) {
175 g_free(output_filename
);
177 output_filename
= (char *) g_malloc(sizeof(char) *
178 (strlen(optarg
) + 1));
179 strcpy(output_filename
, optarg
);
183 backend_params
= g_slist_append(backend_params
, optarg
);
187 scm_internal_stack_catch (SCM_BOOL_T
,
188 (scm_t_catch_body
) scm_c_eval_string
,
190 (scm_t_catch_handler
) catch_handler
,
195 backend_params
= g_slist_append(backend_params
, "sort_mode");
212 verbose_mode
= FALSE
;