Removed unused variable
[geda-gaf/whiteaudio.git] / utils / gschlas / gschlas.c
blob4d8d95487efdcc3fc419f0e6e99d1828615176e7
1 /* gEDA - GPL Electronic Design Automation
2 * gschlas - gEDA Load and Save
3 * Copyright (C) 2002-2008 Ales Hvezda
4 * Copyright (C) 2002-2008 gEDA Contributors (see ChangeLog for details)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <config.h>
23 #include <stdio.h>
24 #include <sys/stat.h>
25 #ifdef HAVE_STRING_H
26 #include <string.h>
27 #endif
28 #ifdef HAVE_UNISTD_H
29 #include <unistd.h>
30 #endif
32 #include <libgeda/libgeda.h>
34 #include "../include/globals.h"
35 #include "../include/prototype.h"
37 #ifdef HAVE_LIBDMALLOC
38 #include <dmalloc.h>
39 #endif
41 void
42 gschlas_quit(void)
45 s_clib_free();
46 s_slib_free();
50 void
51 main_prog(void *closure, int argc, char *argv[])
53 int i;
54 int argv_index;
55 char *cwd;
56 char *logfile;
58 TOPLEVEL *pr_current;
60 argv_index = parse_commandline(argc, argv);
61 cwd = g_get_current_dir();
63 libgeda_init();
65 /* Ensure object->sel_func can be used to correctly determine object
66 * locking when the project is saved out */
67 select_func = o_select_dummy;
69 /* create log file right away */
70 /* even if logging is enabled */
71 logfile = g_build_filename (cwd, "gschlas.log", NULL);
72 s_log_init (logfile);
73 g_free (logfile);
75 logging_dest=STDOUT_TTY;
76 if (!quiet_mode)
78 s_log_message(
79 "gEDA/gschlas version %s%s.%s\n", PREPEND_VERSION_STRING,
80 DOTTED_VERSION, DATE_VERSION);
81 s_log_message(
82 "gEDA/gschlas comes with ABSOLUTELY NO WARRANTY; see COPYING for more details.\n");
83 s_log_message(
84 "This is free software, and you are welcome to redistribute it under certain\n");
85 s_log_message(
86 "conditions; please see the COPYING file for more details.\n\n");
89 #ifdef __MINGW32__
90 fprintf(stderr, "This is the MINGW32 port.\n");
91 #endif
93 logging_dest=-1; /* don't output to the screen for now */
95 /* register guile (scheme) functions */
96 g_register_funcs();
98 pr_current = s_toplevel_new ();
99 g_rc_parse(pr_current, "gschlasrc", rc_filename);
100 i_vars_set(pr_current);
102 i = argv_index;
103 while (argv[i] != NULL) {
105 gchar *filename;
106 GError *err = NULL;
108 if (g_path_is_absolute(argv[i]))
110 /* Path is already absolute so no need to do any concat of cwd */
111 filename = g_strdup (argv[i]);
112 } else {
113 filename = g_build_filename (cwd, argv[i], NULL);
116 if (!f_open (pr_current,
117 pr_current->page_current->page_filename,
118 &err)) {
119 /* Not being able to load a file is apparently a fatal error */
120 logging_dest = STDOUT_TTY;
121 g_warning ("%s\n", err->message);
122 g_error_free (err);
123 exit(2);
124 } else {
125 g_message ("Loaded file [%s]\n", filename);
128 i++;
129 g_free (filename);
132 if (argv[argv_index] == NULL) {
133 fprintf(stderr, "\nERROR! You must specify at least one filename\n\n");
134 usage(argv[0]);
137 g_free(cwd);
139 logging_dest=STDOUT_TTY;
141 #if DEBUG
142 s_page_print_all(pr_current);
143 #endif
145 if (!quiet_mode) s_log_message("\n");
147 if (embed_mode) {
148 s_util_embed(pr_current, TRUE);
151 if (unembed_mode) {
152 s_util_embed(pr_current, FALSE);
155 /* save all the opened files */
156 s_page_save_all(pr_current);
158 s_page_delete_list (pr_current);
159 gschlas_quit();
161 exit(0);
164 int
165 main (int argc, char *argv[])
167 /* disable the deprecated warnings in guile 1.6.3 */
168 /* Eventually the warnings will need to be fixed */
169 if(getenv("GUILE_WARN_DEPRECATED")==NULL)
170 putenv("GUILE_WARN_DEPRECATED=no");
172 scm_boot_guile (argc, argv, main_prog, NULL);
173 return 0;