Updated copyright text/header in most source files.
[geda-gaf.git] / libgeda / src / s_papersizes.c
blob2b04324a393fed7394beff269307c0548be86df4
1 /* gEDA - GPL Electronic Design Automation
2 * libgeda - gEDA's library
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., 59 Temple Place, Suite 330, Boston, MA 02111 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 <gtk/gtk.h>
32 #include <libguile.h>
34 #include "defines.h"
35 #include "struct.h"
36 #include "globals.h"
38 #include "../include/prototype.h"
40 #ifdef HAVE_LIBDMALLOC
41 #include <dmalloc.h>
42 #endif
44 /*! \brief */
45 struct st_papersizes_names {
46 char *papersize_name;
47 int width, height;
50 /*! \brief */
51 static int papersizes_index=0;
53 /*! \brief */
54 #define MAX_PAGESIZES 60
56 /*! \brief
57 * and eventually make this unlimited
58 * hack hack
60 static struct st_papersizes_names papersizes[MAX_PAGESIZES];
62 /*! \todo Finish function documentation!!!
63 * \brief
64 * \par Function Description
65 * width and height in portrait mode
67 int s_papersizes_add_entry(char *new_papersize, int width, int height)
69 if (new_papersize == NULL) {
70 return(-1);
73 if (papersizes_index >= MAX_PAGESIZES) {
74 return(-1);
77 papersizes[papersizes_index].papersize_name =
78 (char *) g_malloc(sizeof(char)*strlen(new_papersize)+1);
80 strcpy(papersizes[papersizes_index].papersize_name, new_papersize);
82 papersizes[papersizes_index].width = width;
83 papersizes[papersizes_index].height = height;
85 papersizes_index++;
86 return(papersizes_index);
89 /*! \todo Finish function documentation!!!
90 * \brief
91 * \par Function Description
94 void s_papersizes_print()
96 int i;
98 for (i = 0; i < papersizes_index; i++) {
99 printf("%s\n", papersizes[i].papersize_name);
103 /*! \todo Finish function documentation!!!
104 * \brief
105 * \par Function Description
106 * true for uniqueness, zero for duplication
108 int s_papersizes_uniq(char *name)
110 int i;
112 for (i = 0; i < papersizes_index; i++) {
113 if (strcmp(papersizes[i].papersize_name, name) == 0) {
114 return(0);
118 return(1);
121 /*! \todo Finish function documentation!!!
122 * \brief
123 * \par Function Description
126 void s_papersizes_free()
128 int i;
130 for (i = 0; i < papersizes_index; i++) {
131 if (papersizes[i].papersize_name)
132 g_free(papersizes[i].papersize_name);
135 papersizes_index=0;
138 /*! \todo Finish function documentation!!!
139 * \brief
140 * \par Function Description
143 void s_papersizes_init()
145 int i;
146 for (i = 0; i < MAX_PAGESIZES; i++) {
147 papersizes[i].papersize_name = NULL;
151 /*! \todo Finish function documentation!!!
152 * \brief
153 * \par Function Description
156 char *s_papersizes_get(int counter)
158 if (counter < papersizes_index) {
159 return(papersizes[counter].papersize_name);
162 return(NULL);
165 /*! \todo Finish function documentation!!!
166 * \brief
167 * \par Function Description
170 void s_papersizes_get_size(char *string, int *width, int *height)
172 int i;
174 for (i = 0; i < papersizes_index; i++) {
175 if (strcmp(papersizes[i].papersize_name, string) == 0) {
176 *width = papersizes[i].width;
177 *height = papersizes[i].height;
178 return;
182 *width = 0;
183 *height = 0;