gaf: Fix memory leak
[geda-gaf.git] / utils / gschlas / g_rc.c
blobed769e4780ed0b38719bd9a0c8775d913e8a3e84
1 /* gEDA - GPL Electronic Design Automation
2 * gschlas - gEDA Load and Save
3 * Copyright (C) 2002-2010 Ales Hvezda
4 * Copyright (C) 2002-2019 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,
19 * MA 02111-1301 USA.
22 #include <config.h>
23 #include <version.h>
25 #include <stdio.h>
26 #include <ctype.h>
27 #include <sys/stat.h>
28 #ifdef HAVE_STRING_H
29 #include <string.h>
30 #endif
31 #ifdef HAVE_STDLIB_H
32 #include <stdlib.h>
33 #endif
34 #ifdef HAVE_UNISTD_H
35 #include <unistd.h>
36 #endif
38 #include <libgeda/libgeda.h>
40 #include "../include/globals.h"
41 #include "../include/prototype.h"
43 /*! \brief Test the version of gschlas and gEDA/gaf
45 * \param version Version being tested
46 * \returns false if incorrect version, true if OK
48 SCM g_rc_gschlas_version(SCM scm_version)
50 char *version;
51 SCM ret = SCM_BOOL_T;
52 SCM rc_filename;
53 char *sourcefile;
55 SCM_ASSERT (scm_is_string (scm_version), scm_version,
56 SCM_ARG1, "gschlas-version");
58 scm_dynwind_begin (0);
59 version = scm_to_utf8_string (scm_version);
60 scm_dynwind_free (version);
62 if (g_ascii_strcasecmp (version, PACKAGE_DATE_VERSION) != 0) {
63 sourcefile = NULL;
64 rc_filename = g_rc_rc_filename ();
65 if (scm_is_false (rc_filename)) {
66 rc_filename = scm_from_utf8_string ("unknown");
68 sourcefile = scm_to_utf8_string (rc_filename);
69 scm_dynwind_free (sourcefile);
70 fprintf(stderr,
71 "You are running gEDA/gaf version [%s%s.%s],\n",
72 PREPEND_VERSION_STRING, PACKAGE_DOTTED_VERSION,
73 PACKAGE_DATE_VERSION);
74 fprintf(stderr,
75 "but you have a version [%s] gschlasrc file:\n[%s]\n",
76 version, sourcefile);
77 fprintf(stderr,
78 "Please be sure that you have the latest rc file.\n");
79 ret = SCM_BOOL_F;
81 scm_dynwind_end();
83 return ret;