1 /* gEDA - GPL Electronic Design Automation
2 * gschlas - gEDA Load and Save
3 * Copyright (C) 2002-2010 Ales Hvezda
4 * Copyright (C) 2002-2010 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.
32 #include <libgeda/libgeda.h>
34 #include "../include/globals.h"
35 #include "../include/prototype.h"
37 #ifdef HAVE_LIBDMALLOC
51 main_prog(void *closure
, int argc
, char *argv
[])
59 argv_index
= parse_commandline(argc
, argv
);
60 cwd
= g_get_current_dir();
64 /* Ensure object->sel_func can be used to correctly determine object
65 * locking when the project is saved out */
66 select_func
= o_select_dummy
;
68 /* create log file right away */
69 /* even if logging is enabled */
70 s_log_init ("gschlas");
72 logging_dest
=STDOUT_TTY
;
74 #if defined(__MINGW32__) && defined(DEBUG)
75 fprintf(stderr
, "This is the MINGW32 port.\n");
78 logging_dest
=-1; /* don't output to the screen for now */
80 /* register guile (scheme) functions */
83 pr_current
= s_toplevel_new ();
84 g_rc_parse(pr_current
, "gschlasrc", rc_filename
);
85 i_vars_set(pr_current
);
88 while (argv
[i
] != NULL
) {
93 if (g_path_is_absolute(argv
[i
]))
95 /* Path is already absolute so no need to do any concat of cwd */
96 filename
= g_strdup (argv
[i
]);
98 filename
= g_build_filename (cwd
, argv
[i
], NULL
);
101 s_page_goto (pr_current
, s_page_new (pr_current
, filename
));
103 if (!f_open (pr_current
, pr_current
->page_current
->page_filename
, &err
)) {
104 /* Not being able to load a file is apparently a fatal error */
105 logging_dest
= STDOUT_TTY
;
106 g_warning ("%s\n", err
->message
);
110 g_message ("Loaded file [%s]\n", filename
);
117 if (argv
[argv_index
] == NULL
) {
118 fprintf(stderr
, "\nERROR! You must specify at least one filename\n\n");
124 logging_dest
=STDOUT_TTY
;
127 s_page_print_all(pr_current
);
130 if (!quiet_mode
) s_log_message("\n");
133 s_util_embed(pr_current
, TRUE
);
137 s_util_embed(pr_current
, FALSE
);
140 /* save all the opened files */
141 s_page_save_all(pr_current
);
143 s_page_delete_list (pr_current
);
150 main (int argc
, char *argv
[])
152 /* disable the deprecated warnings in guile 1.6.3 */
153 /* Eventually the warnings will need to be fixed */
154 if(getenv("GUILE_WARN_DEPRECATED")==NULL
)
155 putenv("GUILE_WARN_DEPRECATED=no");
157 scm_boot_guile (argc
, argv
, main_prog
, NULL
);