1 /* gEDA - GPL Electronic Design Automation
2 * gschlas - gEDA Load and Save
3 * Copyright (C) 2002-2010 Ales Hvezda
4 * Copyright (C) 2002-2020 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., 51 Franklin Street, Fifth Floor, Boston,
35 #include <libgeda/libgeda.h>
37 #include "../include/globals.h"
38 #include "../include/prototype.h"
49 /*! \brief The "real" main for gschlas.
51 * This is the main program body for gschlas. A pointer to this
52 * function is passed to scm_boot_guile() at startup.
55 * - initialises libgeda;
56 * - parses the command line;
58 * - registers the Scheme functions with Guile;
59 * - parses the RC files;
62 * \param argc Number of command line arguments
63 * \param argv Command line arguments
66 main_prog(void *closure
, int argc
, char *argv
[])
74 argv_index
= parse_commandline(argc
, argv
);
75 cwd
= g_get_current_dir();
79 /* create log file right away */
80 /* even if logging is enabled */
81 s_log_init ("gschlas");
83 #if defined(__MINGW32__) && defined(DEBUG)
84 fprintf(stderr
, "This is the MINGW32 port.\n");
88 ("gEDA/gschlas version %s%s.%s\ngEDA/gschlas comes with ABSOLUTELY NO WARRANTY; see COPYING for more details.\nThis is free software, and you are welcome to redistribute it under certain\nconditions; please see the COPYING file for more details.\n\n",
89 PREPEND_VERSION_STRING
, PACKAGE_DOTTED_VERSION
,
90 PACKAGE_DATE_VERSION
);
92 /* register guile (scheme) functions */
95 pr_current
= s_toplevel_new ();
96 g_rc_parse (pr_current
, argv
[0], "gschlasrc", NULL
);
97 i_vars_set(pr_current
);
100 while (argv
[i
] != NULL
) {
105 if (g_path_is_absolute(argv
[i
]))
107 /* Path is already absolute so no need to do any concat of cwd */
108 filename
= g_strdup (argv
[i
]);
110 filename
= g_build_filename (cwd
, argv
[i
], NULL
);
113 s_page_goto (pr_current
, s_page_new (pr_current
, filename
));
115 if (!f_open (pr_current
, pr_current
->page_current
,
116 pr_current
->page_current
->page_filename
, &err
)) {
117 /* Not being able to load a file is apparently a fatal error */
118 g_warning ("%s\n", err
->message
);
122 g_message ("Loaded file [%s]\n", filename
);
129 if (argv
[argv_index
] == NULL
) {
130 fprintf(stderr
, "\nERROR! You must specify at least one filename\n\n");
136 s_page_print_all(pr_current
);
139 if (!quiet_mode
) s_log_message("\n");
142 s_util_embed(pr_current
, TRUE
);
146 s_util_embed(pr_current
, FALSE
);
149 /* save all the opened files */
150 s_page_save_all(pr_current
);
152 s_page_delete_list (pr_current
);
158 /*! \brief Entry point to gschlas
160 * This is just a wrapper which invokes the guile stuff, and
161 * points to the real main program main_prog().
163 * \param argc Number of command line arguments
164 * \param argv Command line arguments
167 main (int argc
, char *argv
[])
169 scm_boot_guile (argc
, argv
, main_prog
, NULL
);