pcb 4.1.1
An interactive printed circuit board layout editor.

named.c

Go to the documentation of this file.
00001 /* GTS - Library for the manipulation of triangulated surfaces
00002  * Copyright (C) 1999 Stéphane Popinet
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  */
00019 
00020 #include <string.h>
00021 #include "gts.h"
00022 
00023 static void nvertex_read (GtsObject ** po, GtsFile * fp)
00024 {
00025   if ((*po)->klass->parent_class->read)
00026     (* (*po)->klass->parent_class->read) (po, fp);
00027 
00028   if (fp->type != '\n' && fp->type != GTS_ERROR) {
00029     strncpy (GTS_NVERTEX (*po)->name, fp->token->str, GTS_NAME_LENGTH);
00030     gts_file_next_token (fp);
00031   }
00032 }
00033 
00034 static void nvertex_write (GtsObject * o, FILE * fptr)
00035 {
00036   GtsNVertex * nv = GTS_NVERTEX (o);
00037 
00038   (* o->klass->parent_class->write) (o, fptr);
00039   if (nv->name[0] != '\0')
00040     fprintf (fptr, " %s", nv->name);
00041 }
00042 
00043 static void nvertex_class_init (GtsNVertexClass * klass)
00044 {
00045   GTS_OBJECT_CLASS (klass)->read = nvertex_read;
00046   GTS_OBJECT_CLASS (klass)->write = nvertex_write;
00047 }
00048 
00049 static void nvertex_init (GtsNVertex * nvertex)
00050 {
00051   nvertex->name[0] = '\0';
00052 }
00053 
00059 GtsNVertexClass * gts_nvertex_class (void)
00060 {
00061   static GtsNVertexClass * klass = NULL;
00062 
00063   if (klass == NULL) {
00064     GtsObjectClassInfo nvertex_info = {
00065       "GtsNVertex",
00066       sizeof (GtsNVertex),
00067       sizeof (GtsNVertexClass),
00068       (GtsObjectClassInitFunc) nvertex_class_init,
00069       (GtsObjectInitFunc) nvertex_init,
00070       (GtsArgSetFunc) NULL,
00071       (GtsArgGetFunc) NULL
00072     };
00073     klass = gts_object_class_new (GTS_OBJECT_CLASS (gts_vertex_class ()), 
00074                                   &nvertex_info);
00075   }
00076 
00077   return klass;
00078 }
00079 
00080 static void nedge_read (GtsObject ** po, GtsFile * fp)
00081 {
00082   if (fp->type != GTS_STRING) {
00083     gts_file_error (fp, "expecting a string (name)");
00084     return;
00085   }
00086   strncpy (GTS_NEDGE (*po)->name, fp->token->str, GTS_NAME_LENGTH);
00087   gts_file_next_token (fp);
00088 }
00089 
00090 static void nedge_write (GtsObject * o, FILE * fptr)
00091 {
00092   GtsNEdge * ne = GTS_NEDGE (o);
00093 
00094   if (ne->name[0] != '\0')
00095     fprintf (fptr, " %s", ne->name);
00096 }
00097 
00098 static void nedge_class_init (GtsNEdgeClass * klass)
00099 {
00100   GTS_OBJECT_CLASS (klass)->read = nedge_read;
00101   GTS_OBJECT_CLASS (klass)->write = nedge_write;
00102 }
00103 
00104 static void nedge_init (GtsNEdge * nedge)
00105 {
00106   nedge->name[0] = '\0';
00107 }
00108 
00114 GtsNEdgeClass * gts_nedge_class (void)
00115 {
00116   static GtsNEdgeClass * klass = NULL;
00117 
00118   if (klass == NULL) {
00119     GtsObjectClassInfo nedge_info = {
00120       "GtsNEdge",
00121       sizeof (GtsNEdge),
00122       sizeof (GtsNEdgeClass),
00123       (GtsObjectClassInitFunc) nedge_class_init,
00124       (GtsObjectInitFunc) nedge_init,
00125       (GtsArgSetFunc) NULL,
00126       (GtsArgGetFunc) NULL
00127     };
00128     klass = gts_object_class_new (GTS_OBJECT_CLASS (gts_edge_class ()), 
00129                                   &nedge_info);
00130   }
00131 
00132   return klass;
00133 }
00134 
00135 static void nface_read (GtsObject ** po, GtsFile * fp)
00136 {
00137   if (fp->type != GTS_STRING) {
00138     gts_file_error (fp, "expecting a string (name)");
00139     return;
00140   }
00141   strncpy (GTS_NFACE (*po)->name, fp->token->str, GTS_NAME_LENGTH);
00142   gts_file_next_token (fp);
00143 }
00144 
00145 static void nface_write (GtsObject * o, FILE * fptr)
00146 {
00147   GtsNFace * nf = GTS_NFACE (o);
00148 
00149   if (nf->name[0] != '\0')
00150     fprintf (fptr, " %s", GTS_NFACE (o)->name);
00151 }
00152 
00153 static void nface_class_init (GtsNFaceClass * klass)
00154 {
00155   GTS_OBJECT_CLASS (klass)->read = nface_read;
00156   GTS_OBJECT_CLASS (klass)->write = nface_write;
00157 }
00158 
00159 static void nface_init (GtsNFace * nface)
00160 {
00161   nface->name[0] = '\0';
00162 }
00163 
00169 GtsNFaceClass * gts_nface_class (void)
00170 {
00171   static GtsNFaceClass * klass = NULL;
00172 
00173   if (klass == NULL) {
00174     GtsObjectClassInfo nface_info = {
00175       "GtsNFace",
00176       sizeof (GtsNFace),
00177       sizeof (GtsNFaceClass),
00178       (GtsObjectClassInitFunc) nface_class_init,
00179       (GtsObjectInitFunc) nface_init,
00180       (GtsArgSetFunc) NULL,
00181       (GtsArgGetFunc) NULL
00182     };
00183     klass = gts_object_class_new (GTS_OBJECT_CLASS (gts_face_class ()), 
00184                                   &nface_info);
00185   }
00186 
00187   return klass;
00188 }