[pisa-src] r1375 - trunk/libpisa/util.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 28 Oct 2009 13:28:49 +0100

Author: tjansen
Date: Wed Oct 28 13:28:48 2009
New Revision: 1375

Log:
Removed unused functions initlist, insert, length, destroy, findsubstring,
extractsubstrings, getitem, and setdataitem.

Modified:
   trunk/libpisa/util.c

Modified: trunk/libpisa/util.c
==============================================================================
--- trunk/libpisa/util.c        Wed Oct 28 13:10:41 2009        (r1374)
+++ trunk/libpisa/util.c        Wed Oct 28 13:28:48 2009        (r1375)
@@ -566,128 +566,6 @@
        return 0;
 }
 
-
-/* functions for simple linked list */
-void initlist(Pisa_List *ilist) {
-  ilist->head = NULL;
-}
-
-void insert(Pisa_List *ilist, char *data) {
-  Pisa_Listitem *new;
-  new = (Pisa_Listitem *)malloc(sizeof(Pisa_Listitem));
-  new->next = ilist->head;
-  strncpy(new->data, data, MAX_ITEM_LEN);
-  ilist->head = new;
-}
-
-int length(Pisa_List *ilist) {
-  Pisa_Listitem *ptr;
-  int count = 1;
-
-  if(!ilist->head) return 0;
-  ptr = ilist->head;
-  while (ptr->next) {
-    ptr = ptr->next;
-    count++;
-  }
-  return count;
-}
-
-void destroy(Pisa_List *ilist) {
-  Pisa_Listitem *ptr1,*ptr2;
-  if(!ilist) return;
-  ptr1 = ilist->head;
-  while (ptr1) {
-    ptr2 = ptr1;
-    ptr1 = ptr1->next;
-    free(ptr2);
-  }
-  ilist->head = NULL;
-}
-
-/*
- * Checks if a string contains a particular substring.
- *
- * If string contains substring, the return value is the location of
- * the first matching instance of substring in string.  If string doesn't
- * contain substring, the return value is NULL.  
- */
-char *findsubstring(const char *string, const char *substring) {
-  char *str = (char *) string, *sub = (char *) substring;
-  char *a, *b;
-  
-  for (b = sub; *str != 0; str += 1) {
-    if (*str != *b)
-      continue;
-    a = str;
-    for (;;) {
-      if (*b == 0)
-       return(str);
-      if (*a++ != *b++)
-       break;
-    }
-    b = sub;
-  }
-  return((char *) NULL);
-}
-
-void extractsubstrings(char *string, Pisa_List *list) {
-
-       char *sub_string;
-       char delims[] = " \t";
-       
-       sub_string = strtok(string, delims);
-       
-       if(sub_string)
-               insert(list, sub_string);
-       else 
-               return;
-       
-       sub_string = NULL;
-       
-       while ((sub_string = strtok(NULL, delims)) != NULL) {
-               insert(list, sub_string);
-               sub_string = NULL;
-       }
-}
-
-char *getitem(Pisa_List *ilist, int n) {
-  Pisa_Listitem *ptr;
-  int count = 0;
-
-  if (!ilist->head) return NULL;
-  ptr = ilist->head;
-  if (n==0) return ptr->data;
-  while(ptr->next) {
-    ptr=ptr->next;
-    count++;
-    if(n==count)
-      return ptr->data;
-  }
-  return NULL;
-}
-
-
-char *setdataitem(Pisa_List *ilist, int n, char *data){
-  Pisa_Listitem *ptr;
-  int count = 0;
-
-  if (!ilist->head) return NULL;
-  ptr = ilist->head;
-  if (n==0) return ptr->data;
-  while(ptr->next) {
-    ptr=ptr->next;
-    count++;
-    if(n==count){
-      //memset(new->data, 0, MAX_ITEM_LEN);
-      strncpy(ptr->data, data, MAX_ITEM_LEN);
-      return ptr->data;
-    }
-  }
-  return NULL;
-
-}
-
 /**
  * Daemonize the running process.
  */

Other related posts:

  • » [pisa-src] r1375 - trunk/libpisa/util.c - Thomas Jansen