home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / text / hyper / hsc_source.lha / hsc / source / ugly / ustrlist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-04  |  2.2 KB  |  117 lines

  1. /*
  2.  * ugly/ustrlist.c
  3.  *
  4.  * string list functions
  5.  *
  6.  * Copyright (C) 1996  Thomas Aglassinger
  7.  *
  8.  * This program 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.  * This program 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 this program; if not, write to the Free Software
  20.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  * updated:  4-Jan-1997
  23.  * created: 14-Oct-1996
  24.  *
  25.  *-------------------------------------------------------------------
  26.  *
  27.  */
  28.  
  29. #include <stdlib.h>
  30. #include <stdio.h>
  31. #include <string.h>
  32.  
  33. #define NOEXTERN_UGLY_USTRLIST_H
  34. #include "ustrlist.h"
  35.  
  36. /*
  37.  * del_string_node
  38.  */
  39. VOID del_string_node(APTR data)
  40. {
  41.     STRPTR s = (STRPTR) data;
  42.     ufreestr(s);
  43. }
  44.  
  45. /*
  46.  * new_string_node
  47.  */
  48. STRPTR new_string_node(STRPTR data)
  49. {
  50. #if 0
  51.     D(fprintf(stderr, DHL "new string `%s'\n", data));
  52. #endif
  53.     return (strclone(data));
  54. }
  55.  
  56. /*
  57.  * cmp_string_node
  58.  */
  59. int cmp_string_node(APTR cmp_data, APTR lst_data)
  60. {
  61.     STRPTR s1 = (STRPTR) cmp_data;
  62.     STRPTR s2 = (STRPTR) lst_data;
  63.  
  64. #ifdef DEBUG_UGLY
  65.     if (!cmp_data)
  66.         panic("cmp_data = NULL");
  67.     if (!lst_data)
  68.         panic("lst_data = NULL");
  69. #endif
  70.  
  71.     if (!strcmp(s1, s2))
  72.         return (-1);
  73.     else
  74.         return (0);
  75. }
  76.  
  77. /*
  78.  * del_strlist: cleanup whole list of strings
  79.  */
  80. VOID del_strlist(DLLIST * list)
  81. {
  82.     del_dllist(list);
  83. }
  84.  
  85. /*
  86.  * del_strlist: cleanup whole list of strings
  87.  */
  88. VOID clr_strlist(DLLIST * list)
  89. {
  90.     del_all_dlnodes(list);
  91. }
  92.  
  93. /*
  94.  * init_strlist: set up new list of strings
  95.  */
  96. DLLIST *init_strlist(VOID)
  97. {
  98.     return (init_dllist(del_string_node));
  99. }
  100.  
  101. /*
  102.  * app_strnode
  103.  *
  104.  * append new string to string-list
  105.  */
  106. DLNODE *app_strnode(DLLIST * list, STRPTR str)
  107. {
  108.     STRPTR scp = new_string_node(str);
  109.     DLNODE *nd = NULL;
  110.  
  111.     if (scp)
  112.         nd = app_dlnode(list, (APTR) scp);
  113.  
  114.     return nd;
  115. }
  116.  
  117.