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
23 #include <sys/types.h>
38 #include "../include/prototype.h"
40 #ifdef HAVE_LIBDMALLOC
45 struct st_papersizes_names
{
51 static int papersizes_index
=0;
54 #define MAX_PAGESIZES 60
57 * and eventually make this unlimited
60 static struct st_papersizes_names papersizes
[MAX_PAGESIZES
];
62 /*! \todo Finish function documentation!!!
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
) {
73 if (papersizes_index
>= MAX_PAGESIZES
) {
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
;
86 return(papersizes_index
);
89 /*! \todo Finish function documentation!!!
91 * \par Function Description
94 void s_papersizes_print()
98 for (i
= 0; i
< papersizes_index
; i
++) {
99 printf("%s\n", papersizes
[i
].papersize_name
);
103 /*! \todo Finish function documentation!!!
105 * \par Function Description
106 * true for uniqueness, zero for duplication
108 int s_papersizes_uniq(char *name
)
112 for (i
= 0; i
< papersizes_index
; i
++) {
113 if (strcmp(papersizes
[i
].papersize_name
, name
) == 0) {
121 /*! \todo Finish function documentation!!!
123 * \par Function Description
126 void s_papersizes_free()
130 for (i
= 0; i
< papersizes_index
; i
++) {
131 if (papersizes
[i
].papersize_name
)
132 g_free(papersizes
[i
].papersize_name
);
138 /*! \todo Finish function documentation!!!
140 * \par Function Description
143 void s_papersizes_init()
146 for (i
= 0; i
< MAX_PAGESIZES
; i
++) {
147 papersizes
[i
].papersize_name
= NULL
;
151 /*! \todo Finish function documentation!!!
153 * \par Function Description
156 char *s_papersizes_get(int counter
)
158 if (counter
< papersizes_index
) {
159 return(papersizes
[counter
].papersize_name
);
165 /*! \todo Finish function documentation!!!
167 * \par Function Description
170 void s_papersizes_get_size(char *string
, int *width
, int *height
)
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
;