gsymcheck

gsymcheck.c

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * gsymcheck - gEDA Symbol Check 
00003  * Copyright (C) 1998-2010 Ales Hvezda
00004  * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00019  * MA 02111-1301 USA.
00020  */
00021 
00022 #include <config.h>
00023 #include <version.h>
00024 
00025 #include <stdio.h>
00026 #include <sys/stat.h>
00027 #ifdef HAVE_STRING_H
00028 #include <string.h>
00029 #endif
00030 #ifdef HAVE_UNISTD_H
00031 #include <unistd.h>
00032 #endif
00033 
00034 #include <libgeda/libgeda.h>
00035 
00036 #include "../include/struct.h"
00037 #include "../include/globals.h"
00038 #include "../include/prototype.h"
00039 
00040 void
00041 gsymcheck_quit(void)
00042 {
00043   
00044   s_clib_free();
00045   s_slib_free();
00046 
00047 }
00048 
00049 void 
00050 main_prog(void *closure, int argc, char *argv[])
00051 {
00052   int i;
00053   int argv_index;
00054   int exit_status;
00055   char *cwd;
00056 
00057   TOPLEVEL *pr_current;
00058   
00059   argv_index = parse_commandline(argc, argv);
00060   cwd = g_get_current_dir();
00061 
00062   libgeda_init();
00063 
00064   /* create log file right away */
00065   /* even if logging is enabled */
00066   x_log_update_func = s_log_update;
00067   s_log_init ("gsymcheck");
00068 
00069   logging_dest=STDOUT_TTY;
00070 
00071 #if defined(__MINGW32__) && defined(DEBUG)
00072   fprintf(stderr, "This is the MINGW32 port.\n");
00073 #endif  
00074 
00075   logging_dest=-1; /* don't output to the screen for now */
00076   
00077   /* register guile (scheme) functions */
00078   g_register_funcs();
00079 
00080   pr_current = s_toplevel_new ();
00081   g_rc_parse (pr_current, argv[0], "gsymcheckrc", rc_filename);
00082 
00083   i_vars_set(pr_current);
00084   
00085   i = argv_index;
00086   while (argv[i] != NULL) {
00087 
00088     gchar *filename;
00089     GError *err = NULL;
00090 
00091     if (g_path_is_absolute(argv[i]))
00092     {
00093       /* Path is already absolute so no need to do any concat of cwd */
00094       filename = g_strdup (argv[i]);
00095     } else {
00096       filename = g_build_filename (cwd, argv[i], NULL);
00097     }
00098 
00099     s_page_goto (pr_current,
00100                  s_page_new (pr_current, filename));
00101 
00102     if (!f_open (pr_current,
00103                  pr_current->page_current,
00104                  pr_current->page_current->page_filename,
00105                  &err)) {
00106       /* Not being able to load a file is apparently a fatal error */
00107       logging_dest = STDOUT_TTY;
00108       g_warning ("%s\n", err->message);
00109       g_error_free (err);
00110       exit(2);
00111     } else {
00112       g_message ("Loaded file [%s]\n", filename);
00113     }
00114     i++;
00115     g_free (filename);
00116   }
00117 
00118   if (argv[argv_index] == NULL) {
00119     fprintf(stderr, "\nERROR! You must specify at least one filename\n\n");
00120     usage(argv[0]);
00121   }
00122 
00123   g_free(cwd);
00124 
00125   logging_dest=STDOUT_TTY;
00126 
00127 #if DEBUG 
00128   s_page_print_all(pr_current);
00129 #endif
00130   
00131   if (!quiet_mode) s_log_message("\n");
00132 
00133   exit_status = s_check_all(pr_current);
00134 
00135   s_page_delete_list(pr_current);
00136   gsymcheck_quit();
00137 
00138   exit(exit_status);
00139 }
00140 
00141 int 
00142 main (int argc, char *argv[])
00143 {
00144   /* disable the deprecated warnings in guile 1.6.3 */
00145   /* Eventually the warnings will need to be fixed */
00146   if(getenv("GUILE_WARN_DEPRECATED")==NULL)
00147     putenv("GUILE_WARN_DEPRECATED=no");
00148 
00149   scm_boot_guile (argc, argv, main_prog, NULL);
00150   return 0;
00151 }
 All Data Structures Files Functions Variables Typedefs Defines