Updated all ChangeLogs to pick up all new commits
[geda-gaf/whiteaudio.git] / gsymcheck / src / gsymcheck.c
blob7ddc4e2247a8cc5a12837abd8b6939dcadf05e6d
1 /* gEDA - GPL Electronic Design Automation
2 * gsymcheck - gEDA Symbol Check
3 * Copyright (C) 1998-2007 Ales Hvezda
4 * Copyright (C) 1998-2007 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/struct.h"
35 #include "../include/globals.h"
36 #include "../include/prototype.h"
38 void
39 gsymcheck_quit(void)
42 s_clib_free();
43 s_slib_free();
47 void
48 main_prog(void *closure, int argc, char *argv[])
50 int i;
51 int argv_index;
52 int exit_status;
53 char *cwd;
55 char *logfile;
57 TOPLEVEL *pr_current;
59 argv_index = parse_commandline(argc, argv);
60 cwd = getcwd(NULL, 1024);
61 #ifdef __MINGW32__
62 u_basic_strip_trailing(cwd, G_DIR_SEPARATOR);
63 #endif
65 libgeda_init();
67 /* create log file right away */
68 /* even if logging is enabled */
69 logfile = g_build_path (G_DIR_SEPARATOR_S,
70 cwd,
71 "gsymcheck.log",
72 NULL);
73 s_log_init (logfile);
74 g_free (logfile);
76 logging_dest=STDOUT_TTY;
77 if (!quiet_mode)
79 s_log_message(
80 "gEDA/gsymcheck version %s%s.%s\n", PREPEND_VERSION_STRING,
81 DOTTED_VERSION, DATE_VERSION);
82 s_log_message(
83 "gEDA/symcheck comes with ABSOLUTELY NO WARRANTY; see COPYING for more details.\n");
84 s_log_message(
85 "This is free software, and you are welcome to redistribute it under certain\n");
86 s_log_message(
87 "conditions; please see the COPYING file for more details.\n\n");
90 #ifdef __MINGW32__
91 fprintf(stderr, "This is the MINGW32 port.\n");
92 #endif
94 logging_dest=-1; /* don't output to the screen for now */
96 /* register guile (scheme) functions */
97 g_register_funcs();
99 pr_current = s_toplevel_new ();
100 g_rc_parse(pr_current, "gsymcheckrc", rc_filename);
102 i_vars_set(pr_current);
104 i = argv_index;
105 while (argv[i] != NULL) {
107 gchar *filename;
108 GError *err = NULL;
110 if (g_path_is_absolute(argv[i]))
112 /* Path is already absolute so no need to do any concat of cwd */
113 filename = g_strdup (argv[i]);
114 } else {
115 filename = g_build_path (G_DIR_SEPARATOR_S, cwd, argv[i], NULL);
118 s_page_goto (pr_current,
119 s_page_new (pr_current, filename));
121 if (!f_open (pr_current,
122 pr_current->page_current->page_filename,
123 &err)) {
124 /* Not being able to load a file is apparently a fatal error */
125 logging_dest = STDOUT_TTY;
126 g_warning ("%s\n", err->message);
127 g_error_free (err);
128 exit(2);
129 } else {
130 g_message ("Loaded file [%s]\n", filename);
132 i++;
133 g_free (filename);
136 if (argv[argv_index] == NULL) {
137 fprintf(stderr, "\nERROR! You must specify at least one filename\n\n");
138 usage(argv[0]);
141 free(cwd); /* allocated with getcwd, should stay as free */
143 logging_dest=STDOUT_TTY;
145 #if DEBUG
146 s_page_print_all(pr_current);
147 #endif
149 if (!quiet_mode) s_log_message("\n");
151 exit_status = s_check_all(pr_current);
153 s_page_delete_list(pr_current);
154 gsymcheck_quit();
156 exit(exit_status);
159 int
160 main (int argc, char *argv[])
162 /* disable the deprecated warnings in guile 1.6.3 */
163 /* Eventually the warnings will need to be fixed */
164 if(getenv("GUILE_WARN_DEPRECATED")==NULL)
165 putenv("GUILE_WARN_DEPRECATED=no");
167 scm_boot_guile (argc, argv, main_prog, NULL);
168 return 0;