refdes_renum: warn of possible number clash with non-conforming values
[geda-gaf/whiteaudio.git] / gsymcheck / src / gsymcheck.c
blob83bd8624edae1dcd2ceb4c46fd48569c4e8b81ac
1 /* gEDA - GPL Electronic Design Automation
2 * gsymcheck - gEDA Symbol Check
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-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.
21 #include <config.h>
22 #include <version.h>
24 #include <stdio.h>
25 #include <sys/stat.h>
26 #ifdef HAVE_STRING_H
27 #include <string.h>
28 #endif
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
33 #include <libgeda/libgeda.h>
35 #include "../include/struct.h"
36 #include "../include/globals.h"
37 #include "../include/prototype.h"
39 void
40 gsymcheck_quit(void)
43 s_clib_free();
44 s_slib_free();
48 void
49 main_prog(void *closure, int argc, char *argv[])
51 int i;
52 int argv_index;
53 int exit_status;
54 char *cwd;
56 TOPLEVEL *pr_current;
58 argv_index = parse_commandline(argc, argv);
59 cwd = g_get_current_dir();
61 libgeda_init();
63 /* create log file right away */
64 /* even if logging is enabled */
65 x_log_update_func = s_log_update;
66 s_log_init ("gsymcheck");
68 logging_dest=STDOUT_TTY;
70 #if defined(__MINGW32__) && defined(DEBUG)
71 fprintf(stderr, "This is the MINGW32 port.\n");
72 #endif
74 logging_dest=-1; /* don't output to the screen for now */
76 /* register guile (scheme) functions */
77 g_register_funcs();
79 pr_current = s_toplevel_new ();
80 g_rc_parse (pr_current, argv[0], "gsymcheckrc", rc_filename);
82 i_vars_set(pr_current);
84 i = argv_index;
85 while (argv[i] != NULL) {
87 gchar *filename;
88 GError *err = NULL;
90 if (g_path_is_absolute(argv[i]))
92 /* Path is already absolute so no need to do any concat of cwd */
93 filename = g_strdup (argv[i]);
94 } else {
95 filename = g_build_filename (cwd, argv[i], NULL);
98 s_page_goto (pr_current,
99 s_page_new (pr_current, filename));
101 if (!f_open (pr_current,
102 pr_current->page_current,
103 pr_current->page_current->page_filename,
104 &err)) {
105 /* Not being able to load a file is apparently a fatal error */
106 logging_dest = STDOUT_TTY;
107 g_warning ("%s\n", err->message);
108 g_error_free (err);
109 exit(2);
110 } else {
111 g_message ("Loaded file [%s]\n", filename);
113 i++;
114 g_free (filename);
117 if (argv[argv_index] == NULL) {
118 fprintf(stderr, "\nERROR! You must specify at least one filename\n\n");
119 usage(argv[0]);
122 g_free(cwd);
124 logging_dest=STDOUT_TTY;
126 #if DEBUG
127 s_page_print_all(pr_current);
128 #endif
130 if (!quiet_mode) s_log_message("\n");
132 exit_status = s_check_all(pr_current);
134 s_page_delete_list(pr_current);
135 gsymcheck_quit();
137 exit(exit_status);
140 int
141 main (int argc, char *argv[])
143 /* disable the deprecated warnings in guile 1.6.3 */
144 /* Eventually the warnings will need to be fixed */
145 if(getenv("GUILE_WARN_DEPRECATED")==NULL)
146 putenv("GUILE_WARN_DEPRECATED=no");
148 scm_boot_guile (argc, argv, main_prog, NULL);
149 return 0;