| 1 |
/* list_routines.c: Types used in this program. |
| 2 |
|
| 3 |
This file is part of Omega, |
| 4 |
which is based on the web2c distribution of TeX, |
| 5 |
|
| 6 |
Copyright (c) 1994--2001 John Plaice and Yannis Haralambous |
| 7 |
|
| 8 |
Omega is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 2 of the License, or |
| 11 |
(at your option) any later version. |
| 12 |
|
| 13 |
Omega is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with Omega; if not, write to the Free Software Foundation, Inc., |
| 20 |
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
| 21 |
|
| 22 |
*/ |
| 23 |
|
| 24 |
#include "cpascal.h" |
| 25 |
#include "list_routines.h" |
| 26 |
|
| 27 |
static list |
| 28 |
list1 (void *x) |
| 29 |
{ |
| 30 |
list temp; |
| 31 |
temp = (list) xmalloc(sizeof(cell)); |
| 32 |
temp->contents = x; |
| 33 |
temp->ptr = NULL; |
| 34 |
return temp; |
| 35 |
} |
| 36 |
|
| 37 |
/* Attribute-value list function */ |
| 38 |
|
| 39 |
av_list |
| 40 |
av_list1 (int attr, int val) |
| 41 |
{ |
| 42 |
av_list temp; |
| 43 |
temp = (av_list) xmalloc(sizeof(av_cell)); |
| 44 |
temp->attribute = attr; |
| 45 |
temp->value = val; |
| 46 |
temp->ptr = NULL; |
| 47 |
return temp; |
| 48 |
} |
| 49 |
|
| 50 |
/* Index-value list function */ |
| 51 |
|
| 52 |
in_list |
| 53 |
in_list1 (int val, in_list N) |
| 54 |
{ |
| 55 |
in_list temp; |
| 56 |
temp = (in_list) xmalloc(sizeof(in_cell)); |
| 57 |
temp->index = 0; |
| 58 |
temp->value = val; |
| 59 |
temp->actual = N; |
| 60 |
temp->ptr = NULL; |
| 61 |
return temp; |
| 62 |
} |
| 63 |
|
| 64 |
/* Attribute-value list function */ |
| 65 |
|
| 66 |
hash_list |
| 67 |
hash_list1 (int x, int y, int new_class, int lig_z, hash_list N) |
| 68 |
{ |
| 69 |
hash_list temp; |
| 70 |
temp = (hash_list) xmalloc(sizeof(hash_cell)); |
| 71 |
temp->x = x; |
| 72 |
temp->y = y; |
| 73 |
temp->new_class = new_class; |
| 74 |
temp->lig_z = lig_z; |
| 75 |
temp->ptr = N; |
| 76 |
return temp; |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
void |
| 81 |
append_to_queue(queue *q, void *content) |
| 82 |
{ |
| 83 |
if (q->front == NULL) { |
| 84 |
q->front = list1(content); |
| 85 |
q->tail = q->front; |
| 86 |
} else { |
| 87 |
q->tail->ptr = list1(content); |
| 88 |
q->tail = q->tail->ptr; |
| 89 |
} |
| 90 |
} |