Revert "Remove GTS sources in favour of the libgts package."
[geda-pcb/pcjc2.git] / gts / named.c
blob379f9f61b017dea187fe6bca6d4291ca051143e7
1 /* GTS - Library for the manipulation of triangulated surfaces
2 * Copyright (C) 1999 Stéphane Popinet
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include <string.h>
21 #include "gts.h"
23 static void nvertex_read (GtsObject ** po, GtsFile * fp)
25 if ((*po)->klass->parent_class->read)
26 (* (*po)->klass->parent_class->read) (po, fp);
28 if (fp->type != '\n' && fp->type != GTS_ERROR) {
29 strncpy (GTS_NVERTEX (*po)->name, fp->token->str, GTS_NAME_LENGTH);
30 gts_file_next_token (fp);
34 static void nvertex_write (GtsObject * o, FILE * fptr)
36 GtsNVertex * nv = GTS_NVERTEX (o);
38 (* o->klass->parent_class->write) (o, fptr);
39 if (nv->name[0] != '\0')
40 fprintf (fptr, " %s", nv->name);
43 static void nvertex_class_init (GtsNVertexClass * klass)
45 GTS_OBJECT_CLASS (klass)->read = nvertex_read;
46 GTS_OBJECT_CLASS (klass)->write = nvertex_write;
49 static void nvertex_init (GtsNVertex * nvertex)
51 nvertex->name[0] = '\0';
54 /**
55 * gts_nvertex_class:
57 * Returns: the #GtsNVertexClass.
59 GtsNVertexClass * gts_nvertex_class (void)
61 static GtsNVertexClass * klass = NULL;
63 if (klass == NULL) {
64 GtsObjectClassInfo nvertex_info = {
65 "GtsNVertex",
66 sizeof (GtsNVertex),
67 sizeof (GtsNVertexClass),
68 (GtsObjectClassInitFunc) nvertex_class_init,
69 (GtsObjectInitFunc) nvertex_init,
70 (GtsArgSetFunc) NULL,
71 (GtsArgGetFunc) NULL
73 klass = gts_object_class_new (GTS_OBJECT_CLASS (gts_vertex_class ()),
74 &nvertex_info);
77 return klass;
80 static void nedge_read (GtsObject ** po, GtsFile * fp)
82 if (fp->type != GTS_STRING) {
83 gts_file_error (fp, "expecting a string (name)");
84 return;
86 strncpy (GTS_NEDGE (*po)->name, fp->token->str, GTS_NAME_LENGTH);
87 gts_file_next_token (fp);
90 static void nedge_write (GtsObject * o, FILE * fptr)
92 GtsNEdge * ne = GTS_NEDGE (o);
94 if (ne->name[0] != '\0')
95 fprintf (fptr, " %s", ne->name);
98 static void nedge_class_init (GtsNEdgeClass * klass)
100 GTS_OBJECT_CLASS (klass)->read = nedge_read;
101 GTS_OBJECT_CLASS (klass)->write = nedge_write;
104 static void nedge_init (GtsNEdge * nedge)
106 nedge->name[0] = '\0';
110 * gts_nedge_class:
112 * Returns: the #GtsNEdgeClass.
114 GtsNEdgeClass * gts_nedge_class (void)
116 static GtsNEdgeClass * klass = NULL;
118 if (klass == NULL) {
119 GtsObjectClassInfo nedge_info = {
120 "GtsNEdge",
121 sizeof (GtsNEdge),
122 sizeof (GtsNEdgeClass),
123 (GtsObjectClassInitFunc) nedge_class_init,
124 (GtsObjectInitFunc) nedge_init,
125 (GtsArgSetFunc) NULL,
126 (GtsArgGetFunc) NULL
128 klass = gts_object_class_new (GTS_OBJECT_CLASS (gts_edge_class ()),
129 &nedge_info);
132 return klass;
135 static void nface_read (GtsObject ** po, GtsFile * fp)
137 if (fp->type != GTS_STRING) {
138 gts_file_error (fp, "expecting a string (name)");
139 return;
141 strncpy (GTS_NFACE (*po)->name, fp->token->str, GTS_NAME_LENGTH);
142 gts_file_next_token (fp);
145 static void nface_write (GtsObject * o, FILE * fptr)
147 GtsNFace * nf = GTS_NFACE (o);
149 if (nf->name[0] != '\0')
150 fprintf (fptr, " %s", GTS_NFACE (o)->name);
153 static void nface_class_init (GtsNFaceClass * klass)
155 GTS_OBJECT_CLASS (klass)->read = nface_read;
156 GTS_OBJECT_CLASS (klass)->write = nface_write;
159 static void nface_init (GtsNFace * nface)
161 nface->name[0] = '\0';
165 * gts_nface_class:
167 * Returns: the #GtsNFaceClass.
169 GtsNFaceClass * gts_nface_class (void)
171 static GtsNFaceClass * klass = NULL;
173 if (klass == NULL) {
174 GtsObjectClassInfo nface_info = {
175 "GtsNFace",
176 sizeof (GtsNFace),
177 sizeof (GtsNFaceClass),
178 (GtsObjectClassInitFunc) nface_class_init,
179 (GtsObjectInitFunc) nface_init,
180 (GtsArgSetFunc) NULL,
181 (GtsArgGetFunc) NULL
183 klass = gts_object_class_new (GTS_OBJECT_CLASS (gts_face_class ()),
184 &nface_info);
187 return klass;