gnetlist: Add basic concatenated net support for verilog.
[geda-gaf/whiteaudio.git] / libgeda / src / s_papersizes.c
blobaf1acb0f65fd1b6d81c9f2b46f2b673d13e686f4
1 /* gEDA - GPL Electronic Design Automation
2 * libgeda - gEDA's library
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <config.h>
22 #include <stdio.h>
23 #include <sys/types.h>
24 #ifdef HAVE_STDLIB_H
25 #include <stdlib.h>
26 #endif
27 #ifdef HAVE_STRING_H
28 #include <string.h>
29 #endif
31 #include "libgeda_priv.h"
33 #ifdef HAVE_LIBDMALLOC
34 #include <dmalloc.h>
35 #endif
37 /*! \brief */
38 struct st_papersizes_names {
39 char *papersize_name;
40 int width, height;
43 /*! \brief */
44 static int papersizes_index=0;
46 /*! \brief */
47 #define MAX_PAGESIZES 60
49 /*! \brief
50 * and eventually make this unlimited
51 * hack hack
53 static struct st_papersizes_names papersizes[MAX_PAGESIZES];
55 /*! \todo Finish function documentation!!!
56 * \brief
57 * \par Function Description
58 * width and height in portrait mode
60 int s_papersizes_add_entry(char *new_papersize, int width, int height)
62 if (new_papersize == NULL) {
63 return(-1);
66 if (papersizes_index >= MAX_PAGESIZES) {
67 return(-1);
70 papersizes[papersizes_index].papersize_name = g_strdup (new_papersize);
72 papersizes[papersizes_index].width = width;
73 papersizes[papersizes_index].height = height;
75 papersizes_index++;
76 return(papersizes_index);
79 /*! \todo Finish function documentation!!!
80 * \brief
81 * \par Function Description
84 void s_papersizes_print()
86 int i;
88 for (i = 0; i < papersizes_index; i++) {
89 printf("%s\n", papersizes[i].papersize_name);
93 /*! \todo Finish function documentation!!!
94 * \brief
95 * \par Function Description
96 * true for uniqueness, zero for duplication
98 int s_papersizes_uniq(char *name)
100 int i;
102 for (i = 0; i < papersizes_index; i++) {
103 if (strcmp(papersizes[i].papersize_name, name) == 0) {
104 return(0);
108 return(1);
111 /*! \todo Finish function documentation!!!
112 * \brief
113 * \par Function Description
116 void s_papersizes_free()
118 int i;
120 for (i = 0; i < papersizes_index; i++) {
121 g_free(papersizes[i].papersize_name);
124 papersizes_index=0;
127 /*! \todo Finish function documentation!!!
128 * \brief
129 * \par Function Description
132 void s_papersizes_init()
134 int i;
135 for (i = 0; i < MAX_PAGESIZES; i++) {
136 papersizes[i].papersize_name = NULL;
140 /*! \todo Finish function documentation!!!
141 * \brief
142 * \par Function Description
145 char *s_papersizes_get(int counter)
147 if (counter < papersizes_index) {
148 return(papersizes[counter].papersize_name);
151 return(NULL);
154 /*! \todo Finish function documentation!!!
155 * \brief
156 * \par Function Description
159 void s_papersizes_get_size(char *string, int *width, int *height)
161 int i;
163 for (i = 0; i < papersizes_index; i++) {
164 if (strcmp(papersizes[i].papersize_name, string) == 0) {
165 *width = papersizes[i].width;
166 *height = papersizes[i].height;
167 return;
171 *width = 0;
172 *height = 0;