1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
/* gEDA - GPL Electronic Design Automation
* libgeda - gEDA's library
* Copyright (C) 1998-2010 Ales Hvezda
* Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "libgeda_priv.h"
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
#endif
/*! \brief */
struct st_papersizes_names {
char *papersize_name;
int width, height;
};
/*! \brief */
static int papersizes_index=0;
/*! \brief */
#define MAX_PAGESIZES 60
/*! \brief
* and eventually make this unlimited
* hack hack
*/
static struct st_papersizes_names papersizes[MAX_PAGESIZES];
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
* width and height in portrait mode
*/
int s_papersizes_add_entry(char *new_papersize, int width, int height)
{
if (new_papersize == NULL) {
return(-1);
}
if (papersizes_index >= MAX_PAGESIZES) {
return(-1);
}
papersizes[papersizes_index].papersize_name = g_strdup (new_papersize);
papersizes[papersizes_index].width = width;
papersizes[papersizes_index].height = height;
papersizes_index++;
return(papersizes_index);
}
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
*
*/
void s_papersizes_print()
{
int i;
for (i = 0; i < papersizes_index; i++) {
printf("%s\n", papersizes[i].papersize_name);
}
}
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
* true for uniqueness, zero for duplication
*/
int s_papersizes_uniq(char *name)
{
int i;
for (i = 0; i < papersizes_index; i++) {
if (strcmp(papersizes[i].papersize_name, name) == 0) {
return(0);
}
}
return(1);
}
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
*
*/
void s_papersizes_free()
{
int i;
for (i = 0; i < papersizes_index; i++) {
g_free(papersizes[i].papersize_name);
}
papersizes_index=0;
}
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
*
*/
void s_papersizes_init()
{
int i;
for (i = 0; i < MAX_PAGESIZES; i++) {
papersizes[i].papersize_name = NULL;
}
}
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
*
*/
char *s_papersizes_get(int counter)
{
if (counter < papersizes_index) {
return(papersizes[counter].papersize_name);
}
return(NULL);
}
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
*
*/
void s_papersizes_get_size(char *string, int *width, int *height)
{
int i;
for (i = 0; i < papersizes_index; i++) {
if (strcmp(papersizes[i].papersize_name, string) == 0) {
*width = papersizes[i].width;
*height = papersizes[i].height;
return;
}
}
*width = 0;
*height = 0;
}
|