gnetlist

i_vars.c

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * gnetlist - gEDA Netlist
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, MA 02110-1301 USA
00019  */
00020 
00021 #include <config.h>
00022 
00023 #include <stdio.h>
00024 
00025 #ifdef HAVE_STRING_H
00026 #include <string.h>
00027 #endif
00028 
00029 #include <libgeda/libgeda.h>
00030 
00031 #include "../include/papersizes.h"
00032 #include "../include/prototype.h"
00033 
00034 #ifdef HAVE_LIBDMALLOC
00035 #include <dmalloc.h>
00036 #endif
00037 
00038 #define DEFAULT_UNTITLED_NAME    "untitled"
00039 #define DEFAULT_BITMAP_DIRECTORY   "non-existant"
00040 #define DEFAULT_HIERARCHY_NETNAME_SEPARATOR "/"
00041 #define DEFAULT_HIERARCHY_NETATTRIB_SEPARATOR "/"
00042 #define DEFAULT_HIERARCHY_UREF_SEPARATOR "/"
00043 #define DEFAULT_UNNAMED_NETNAME "unnamed_net"
00044 #define DEFAULT_UNNAMED_BUSNAME "unnamed_bus"
00045 
00046 #define INIT_STR(w, name, str) {                            \
00047     g_free((w)->name);                                      \
00048     (w)->name = g_strdup (((default_ ## name) != NULL) ?    \
00049                           (default_ ## name) : (str));      \
00050 }
00051 
00052 int default_net_naming_priority = NETATTRIB_ATTRIBUTE;
00053 int default_hierarchy_traversal = TRUE;
00054 int default_hierarchy_uref_mangle = TRUE;
00055 int default_hierarchy_netname_mangle = TRUE;
00056 int default_hierarchy_netattrib_mangle = TRUE;
00057 int default_hierarchy_netattrib_order = APPEND;
00058 int default_hierarchy_netname_order = APPEND;
00059 int default_hierarchy_uref_order = APPEND;
00060 char *default_hierarchy_netname_separator = NULL;
00061 char *default_hierarchy_netattrib_separator = NULL;
00062 char *default_hierarchy_uref_separator = NULL;
00063 char *default_unnamed_netname = NULL;
00064 char *default_unnamed_busname = NULL;
00065 
00066 void i_vars_set(TOPLEVEL * pr_current)
00067 {
00068     i_vars_libgeda_set(pr_current);
00069 
00070     pr_current->net_naming_priority = default_net_naming_priority;
00071     pr_current->hierarchy_traversal = default_hierarchy_traversal;
00072     pr_current->hierarchy_uref_mangle = default_hierarchy_uref_mangle;
00073     pr_current->hierarchy_netname_mangle =
00074     default_hierarchy_netname_mangle;
00075     pr_current->hierarchy_netattrib_mangle =
00076     default_hierarchy_netattrib_mangle;
00077     pr_current->hierarchy_netattrib_order =
00078     default_hierarchy_netattrib_order;
00079     pr_current->hierarchy_netname_order = default_hierarchy_netname_order;
00080     pr_current->hierarchy_uref_order = default_hierarchy_uref_order;
00081 
00082     if (pr_current->hierarchy_uref_mangle == FALSE) {
00083     if (pr_current->hierarchy_uref_separator) {
00084         strcpy(pr_current->hierarchy_uref_separator, "/");
00085     } else {
00086         pr_current->hierarchy_uref_separator = g_strdup("/");
00087     }
00088     }
00089 
00090     if (!default_hierarchy_netname_separator) {
00091       default_hierarchy_netname_separator =
00092         g_strdup (DEFAULT_HIERARCHY_NETNAME_SEPARATOR);
00093     }
00094     if (!default_hierarchy_netattrib_separator) {
00095       default_hierarchy_netattrib_separator =
00096         g_strdup (DEFAULT_HIERARCHY_NETATTRIB_SEPARATOR);
00097     }
00098     if (!default_hierarchy_uref_separator) {
00099       default_hierarchy_uref_separator =
00100         g_strdup (DEFAULT_HIERARCHY_UREF_SEPARATOR);
00101     }
00102     if (!default_unnamed_netname) {
00103       default_unnamed_netname =
00104         g_strdup (DEFAULT_UNNAMED_NETNAME);
00105     }
00106     if (!default_unnamed_busname) {
00107       default_unnamed_busname =
00108         g_strdup (DEFAULT_UNNAMED_BUSNAME);
00109     }
00110 
00111     INIT_STR(pr_current, hierarchy_netname_separator,
00112              default_hierarchy_netname_separator);
00113     INIT_STR(pr_current, hierarchy_netattrib_separator,
00114              default_hierarchy_netattrib_separator);
00115     INIT_STR(pr_current, hierarchy_uref_separator,
00116              default_hierarchy_uref_separator);
00117 
00118     INIT_STR(pr_current, unnamed_netname, default_unnamed_netname);
00119     INIT_STR(pr_current, unnamed_busname, default_unnamed_busname);
00120 }
00121 
 All Data Structures Files Functions Variables Defines