root/trunk/src/fields_mgmt.c

Revision 154, 1.8 KB (checked in by andreu, 11 years ago)

Typo correction and copyright update

  • Property svn:eol-style set to native
Line 
1/*
2 * File: fields_mgmt.c
3 *
4 * Authors: ANDREU Francois-Xavier
5 *
6 * Copyright (C) 2004-2011 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(FILE *file, FieldPtr pf)
34{
35  FieldPtr tmp = pf;
36  for (; tmp; tmp=tmp->next) {
37    fprintf(file, "%hu;%hu ", tmp->fieldType, tmp->fieldLength);
38  }
39  fprintf(file,"\n");
40}
41
42/*
43 * invPrintFieldSet
44 */
45void invPrintFieldSet(FILE *file, FieldPtr pf)
46{
47  FieldPtr tmp = pf;
48  for (; tmp; tmp=tmp->prev) {
49    fprintf(file, "(%hu,%hu) ", tmp->fieldType, tmp->fieldLength);
50  }
51  fprintf(file,"\n");
52}
53
54/*
55 * freeField
56 *
57 */
58void freeField(FieldPtr pf) {
59  if (pf) {
60    free(pf);
61    pf = NULL;
62  }
63}
64
65/*
66 * addField()
67 */
68FieldPtr
69addField (FieldPtr fp, unsigned short type, unsigned short length)
70{
71  FieldPtr tmp = (FieldPtr) malloc(sizeof(struct Field));
72  if (tmp==NULL) {
73    fprintf(stderr, "ERROR in malloc in addField function\n");
74    exit(1);
75  } else {
76    tmp->fieldType = type;
77    tmp->fieldLength = length;
78    tmp->next = fp;
79    tmp->prev = NULL;
80    return tmp;
81  }
82  return NULL;
83}
Note: See TracBrowser for help on using the browser.