home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / fax-3.2.1 / lib / libutil / list.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-31  |  3.7 KB  |  289 lines

  1. /*
  2.   This file is part of the NetFax system.
  3.  
  4.   (c) Copyright 1989 by David M. Siegel and Sundar Narasimhan.
  5.       All rights reserved.
  6.  
  7.     This program is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation.
  10.  
  11.     This program is distributed in the hope that it will be useful, 
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of 
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. #ifndef INClisth
  22. #define INClisth 1
  23.  
  24. #define LIST_ASCENDING    -1
  25. #define LIST_DESCENDING     1
  26.  
  27. typedef struct _node {
  28.     struct _node *next;
  29.     struct _node *previous;
  30.     char *value;
  31. } NODE;
  32.  
  33. typedef struct _list {
  34.     int count;
  35.     int (*cmp_func)();
  36.     int (*free_func)();
  37.     NODE *head;
  38.     NODE *tail;
  39. } LIST;
  40.  
  41. #define list_node_value(x) ((x == 0) ? 0 : x->value)
  42.  
  43. /*
  44.   Prototypes:
  45. */
  46.  
  47. int list_init(
  48. #ifdef _PROTO
  49.     LIST *list,
  50.     int (*cmp_func)(),
  51.     int (*free_func)()
  52. #endif
  53. );
  54.  
  55. LIST *list_make(
  56. #ifdef _PROTO
  57.     int (*cmp_func)(),
  58.     int (*free_func)()
  59. #endif
  60. );
  61.  
  62. int list_free(
  63. #ifdef _PROTO
  64.     LIST *list
  65. #endif
  66. );
  67.  
  68. int list_length(
  69. #ifdef _PROTO
  70.     LIST *list
  71. #endif
  72. );
  73.  
  74. NODE *list_nth_node(
  75. #ifdef _PROTO
  76.     LIST *list,
  77.     int n
  78. #endif
  79. );
  80.  
  81. char *list_nth(
  82. #ifdef _PROTO
  83.     LIST *list,
  84.     int n
  85. #endif
  86. );
  87.  
  88. NODE *list_last_node(
  89. #ifdef _PROTO
  90.     LIST *list
  91. #endif
  92. );
  93.  
  94. char *list_last(
  95. #ifdef _PROTO
  96.     LIST *list
  97. #endif
  98. );
  99.  
  100. NODE *list_first_node(
  101. #ifdef _PROTO
  102.     LIST *list
  103. #endif
  104. );
  105.  
  106. char *list_first(
  107. #ifdef _PROTO
  108.     LIST *list
  109. #endif
  110. );
  111.  
  112. LIST *list_add_node(
  113. #ifdef _PROTO
  114.     LIST *list,
  115.     NODE *node
  116. #endif
  117. );
  118.  
  119. LIST *list_add(
  120. #ifdef _PROTO
  121.     LIST *list,
  122.     char *value
  123. #endif
  124. );
  125.  
  126. LIST *list_add_first_node(
  127. #ifdef _PROTO
  128.     LIST *list,
  129.     NODE *node
  130. #endif
  131. );
  132.  
  133. LIST *list_add_first(
  134. #ifdef _PROTO
  135.     LIST *list,
  136.     char *value
  137. #endif
  138. );
  139.  
  140. LIST *list_append(
  141. #ifdef _PROTO
  142.     LIST *list1,
  143.     LIST *list2
  144. #endif
  145. );
  146.  
  147. LIST *list_delete_node(
  148. #ifdef _PROTO
  149.     LIST *list,
  150.     NODE *node
  151. #endif
  152. );
  153.  
  154. LIST *list_delete(
  155. #ifdef _PROTO
  156.     LIST *list,
  157.     char *value
  158. #endif
  159. );
  160.  
  161. LIST *list_delete_with_function(
  162. #ifdef _PROTO
  163.     LIST *list,
  164.     char *value,
  165.     int (*function)()
  166. #endif
  167. );
  168.  
  169. LIST *list_filter(
  170. #ifdef _PROTO
  171.     LIST *list,
  172.     char *value
  173. #endif
  174. );
  175.  
  176. LIST *list_filter_with_function(
  177. #ifdef _PROTO
  178.     LIST *list,
  179.     char *value,
  180.     int (*function)()
  181. #endif
  182. );
  183.  
  184. LIST *list_delete_first(
  185. #ifdef _PROTO
  186.     LIST *list
  187. #endif
  188. );
  189.  
  190. LIST *list_delete_last(
  191. #ifdef _PROTO
  192.     LIST *list
  193. #endif
  194. );
  195.  
  196. char *list_car(
  197. #ifdef _PROTO
  198.     LIST *list
  199. #endif
  200. );
  201.  
  202. LIST *list_cdr(
  203. #ifdef _PROTO
  204.     LIST *list
  205. #endif
  206. );
  207.  
  208. LIST *list_push(
  209. #ifdef _PROTO
  210.     LIST *list,
  211.     char *value
  212. #endif
  213. );
  214.  
  215. LIST *list_push_new(
  216. #ifdef _PROTO
  217.     LIST *list,
  218.     char *value
  219. #endif
  220. );
  221.  
  222. char *list_pop(
  223. #ifdef _PROTO
  224.     LIST *list
  225. #endif
  226. );
  227.  
  228. char *list_find(
  229. #ifdef _PROTO
  230.     LIST *list,
  231.     char *value
  232. #endif
  233. );
  234.  
  235. LIST *list_insert(
  236. #ifdef _PROTO
  237.     LIST *list,
  238.     char *value,
  239.     int order
  240. #endif
  241. );
  242.  
  243. NODE *list_next_node(
  244. #ifdef _PROTO
  245.     LIST *list,
  246.     NODE **node
  247. #endif
  248. );
  249.  
  250. char *list_next(
  251. #ifdef _PROTO
  252.     LIST *list,
  253.     NODE **node
  254. #endif
  255. );
  256.  
  257. char *list_delete_next(
  258. #ifdef _PROTO
  259.     LIST *list,
  260.     NODE **node
  261. #endif
  262. );
  263.  
  264. /*VARARGS*/
  265. int list_map();
  266.  
  267. /*VARARGS*/
  268. int list_map_node();
  269.  
  270. int list_describe(
  271. #ifdef _PROTO
  272.     LIST *list,
  273.     FILE *fp
  274. #endif
  275. );
  276.  
  277. #ifdef __RPC_HEADER__
  278. bool_t xdr_list(
  279. #ifdef _PROTO
  280.     XDR *xdrs,
  281.     LIST **listpp,
  282.     int size,
  283.     xdrproc_t xdrel
  284. #endif
  285. );
  286. #endif
  287.  
  288. #endif
  289.