root/trunk/src/fields_mgmt.c @ 12

Revision 2, 1.9 KB (checked in by andreu, 17 years ago)

First RENETCOL CVS Integration

  • Property svn:eol-style set to native
Line 
1/*
2 * File: fields_mgmt.c
3 *
4 * Authors: ANDREU François-Xavier
5 *
6 * Copyright (C) 2004 GIP RENATER
7 */
8
9/*  This file is part of renetcol.
10 *
11 *  renetcol is free software; you can redistribute it and/or modify
12 *  it under the terms of the GNU General Public License as published by
13 *  the Free Software Foundation; either version 2 of the License, or
14 *  (at your option) any later version.
15 *
16 *  renetcol is distributed in the hope that it will be useful,
17 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 *  GNU General Public License for more details.
20 *
21 *  You should have received a copy of the GNU General Public License
22 *  along with renetcol; if not, write to the Free Software
23 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 */
25
26#include <stdio.h>
27#include <stdlib.h>
28#include "fields_mgmt.h"
29
30/*
31 * print_fields_set
32 */
33void printFieldSet(FieldPtr pf)
34{
35  FieldPtr tmp = pf;
36  fprintf(stderr, "template definition: (field, size)\n");
37  for (; tmp; tmp=tmp->next) {
38    fprintf(stderr, "(%hu,%hu) ", tmp->fieldType, tmp->fieldLength);
39  }
40  fprintf(stderr,"\n");
41}
42
43/*
44 * invPrintFieldSet
45 */
46void invPrintFieldSet(FieldPtr pf)
47{
48  FieldPtr tmp = pf;
49  fprintf(stderr, "fields set (inv): \n");
50  for (; tmp; tmp=tmp->prev) {
51    fprintf(stderr, " %hu %hu \n", tmp->fieldType, tmp->fieldLength);
52  }
53}
54
55/*
56 * freeField
57 *
58 */
59void freeField(FieldPtr pf) {
60  if (pf) {
61    free(pf);
62    pf = NULL;
63  }
64}
65
66/*
67 * addField()
68 */
69FieldPtr
70addField (FieldPtr fp, unsigned short type, unsigned short length)
71{
72  FieldPtr tmp = (FieldPtr) malloc(sizeof(struct Field));
73  if (tmp==NULL) {
74    fprintf(stderr, "ERROR in malloc in addField function\n");
75    exit(1);
76  } else {
77    tmp->fieldType = type;
78    tmp->fieldLength = length;
79    tmp->next = fp;
80    tmp->prev = NULL;
81    return tmp;
82  }
83  return NULL;
84}
Note: See TracBrowser for help on using the browser.