Main Page | Class List | Directories | File List | Class Members | File Members

2Dlist.c File Reference

#include "cf.defs.h"
#include "cf.extern.h"

Go to the source code of this file.

Defines

#define TD_wrapped   1
#define TD_nowrap   2

Functions

void Set2DList (struct TwoDimList *list)
char * Get2DListEnt (struct TwoDimList *list)
void Build2DListFromVarstring (struct TwoDimList **TwoDimlist, char *varstring, char sep)
int IncrementTwoDimList (struct TwoDimList *from, struct TwoDimList *list)
int EndOfTwoDimList (struct TwoDimList *list)
void AppendTwoDimItem (struct TwoDimList **liststart, struct Item *itemlist, char sep)
void Delete2DList (struct TwoDimList *item)


Define Documentation

#define TD_nowrap   2
 

Definition at line 40 of file 2Dlist.c.

Referenced by IncrementTwoDimList().

#define TD_wrapped   1
 

Definition at line 39 of file 2Dlist.c.

Referenced by IncrementTwoDimList().


Function Documentation

void AppendTwoDimItem struct TwoDimList **  liststart,
struct Item itemlist,
char  sep
 

Definition at line 244 of file 2Dlist.c.

References cferror, CfLog(), TwoDimList::current, Debug, Debug1, FatalError(), TwoDimList::ilist, TwoDimList::is2d, malloc(), Item::next, TwoDimList::next, NULL, TwoDimList::rounds, and TwoDimList::sep.

Referenced by Build2DListFromVarstring().

00250 { struct TwoDimList *ip, *lp;
00251 
00252 Debug1("AppendTwoDimItem(itemlist, sep=%c)\n",sep);
00253 
00254  if (liststart == NULL)
00255     {
00256     Debug("SOFTWARE ERROR in AppendTwoDimItem()\n ");
00257     return;
00258     }
00259  
00260 if ((ip = (struct TwoDimList *)malloc(sizeof(struct TwoDimList))) == NULL)
00261    {
00262    CfLog(cferror,"AppendTwoDimItem","malloc");
00263    FatalError("");
00264    }
00265 
00266 if (*liststart == NULL)
00267    {
00268    *liststart = ip;
00269    }
00270 else
00271    {
00272    for (lp = *liststart; lp->next != NULL; lp=lp->next)
00273       {
00274       }
00275 
00276    lp->next = ip;
00277    }
00278 
00279 ip->ilist = itemlist;
00280 ip->current = itemlist; /* init to start of list */
00281 ip->next = NULL;
00282 ip->rounds = 0;
00283 ip->sep = sep;
00284 
00285 if (itemlist == NULL || itemlist->next == NULL)
00286    {
00287    ip->is2d = false;
00288    }
00289 else
00290    {
00291    ip->is2d = true;
00292    }
00293 }

void Build2DListFromVarstring struct TwoDimList **  TwoDimlist,
char *  varstring,
char  sep
 

Definition at line 101 of file 2Dlist.c.

References AppendTwoDimItem(), bufsize, bzero, Debug1, i, LISTSEPARATOR, maxlinksize, snprintf(), sp, and SplitVarstring().

Referenced by AppendDisable(), AppendIgnore(), AppendScript(), InstallAuthItem(), InstallFileListItem(), InstallImageItem(), InstallLinkChildrenItem(), InstallRequiredPath(), and InstallTidyItem().

00111 { char format[6], *sp;
00112   char node[bufsize];
00113   int i;
00114 
00115 Debug1("Build2DListFromVarstring(%s,sep=%c)\n",varstring,sep);
00116 
00117 if ((strlen(varstring) == 1) && (varstring[0] == sep))
00118    {
00119    AppendTwoDimItem(TwoDimlist,SplitVarstring("",'$'),sep);
00120    return;
00121    }
00122 
00123 snprintf(format,6,"%%[^%c]",sep);   /* set format string to search */
00124 
00125 for (sp = varstring; *sp != '\0'; sp++)
00126    {
00127    bzero(node,maxlinksize);
00128 
00129    *node = *sp;;
00130       
00131    for (i = 1; (*(sp+i) != '$') && (*(sp+i) != '\0'); i++)
00132       {
00133       *(node+i) = *(sp+i);
00134       }
00135 
00136       *(node+i) = '\0';
00137       sp += i-1;
00138    
00139    if (strlen(node) == 0)
00140       {
00141       continue;
00142       }
00143 
00144    AppendTwoDimItem(TwoDimlist,SplitVarstring(node,LISTSEPARATOR),sep);
00145 
00146    if (*sp == '\0')
00147       {
00148       break;
00149       }
00150    }
00151 }

void Delete2DList struct TwoDimList item  ) 
 

Definition at line 297 of file 2Dlist.c.

References DeleteItemList(), and NULL.

Referenced by AppendDisable(), AppendIgnore(), AppendScript(), InstallAuthItem(), InstallFileListItem(), InstallImageItem(), InstallLinkChildrenItem(), InstallRequiredPath(), and InstallTidyItem().

00301 {
00302 if (item != NULL)
00303    {
00304    Delete2DList(item->next);
00305    item->next = NULL;
00306 
00307    DeleteItemList(item->ilist);
00308    
00309    free((char *)item);
00310    }
00311 }

int EndOfTwoDimList struct TwoDimList list  ) 
 

Definition at line 197 of file 2Dlist.c.

References TwoDimList::is2d, TwoDimList::next, NULL, and TwoDimList::rounds.

Referenced by Get2DListEnt().

00204 { struct TwoDimList *tp;
00205 
00206 for (tp = list; tp != NULL; tp=tp->next)
00207    {
00208    if (tp->is2d)
00209        {
00210        break;
00211        }
00212    }
00213 
00214 if (list == NULL)
00215    {
00216    return true;
00217    }
00218 
00219 if (tp == NULL)             /* Need a case when there are no lists! */
00220    {
00221    if (list->rounds == 0)
00222       {
00223       list->rounds = 1;
00224       return false;
00225       }
00226    else
00227       {
00228       return true;
00229       }
00230    }
00231 
00232 if (tp->rounds > 0)
00233     {
00234     return true;
00235     }
00236 else
00237     {
00238     return false;
00239     }
00240 }

char* Get2DListEnt struct TwoDimList list  ) 
 

Definition at line 62 of file 2Dlist.c.

References bufsize, bzero, TwoDimList::current, Debug1, EndOfTwoDimList(), IncrementTwoDimList(), TwoDimList::next, NULL, and TwoDimList::sep.

Referenced by AppendDisable(), AppendIgnore(), AppendScript(), InstallAuthItem(), InstallFileListItem(), InstallImageItem(), InstallLinkChildrenItem(), InstallRequiredPath(), and InstallTidyItem().

00068 { static char entry[bufsize];
00069   struct TwoDimList *tp;
00070   char seps[2];
00071 
00072 Debug1("Get2DListEnt()\n");
00073 
00074 if (EndOfTwoDimList(list))
00075    {
00076    return NULL;
00077    }
00078 
00079 bzero(entry,bufsize);
00080 
00081 for (tp = list; tp != NULL; tp=tp->next)
00082    {
00083    sprintf(seps,"%c",tp->sep);
00084 
00085    if (tp->current != NULL)
00086       {
00087       strcat(entry,(tp->current)->name);
00088       }
00089    }
00090 
00091 
00092 Debug1("Get2DLIstEnt returns %s\n",entry);
00093 
00094 IncrementTwoDimList(list,list);
00095 
00096 return entry;
00097 }

int IncrementTwoDimList struct TwoDimList from,
struct TwoDimList list
 

Definition at line 155 of file 2Dlist.c.

References TwoDimList::current, Debug1, TwoDimList::ilist, TwoDimList::is2d, Item::next, TwoDimList::next, NULL, TwoDimList::rounds, TD_nowrap, and TD_wrapped.

Referenced by Get2DListEnt().

00159 { struct TwoDimList *tp;
00160 
00161 Debug1("IncrementTwoDimList()\n");
00162 
00163 for (tp = from; tp != NULL; tp=tp->next)
00164    {
00165    if (tp->is2d)
00166       {
00167       break;
00168       }
00169    }
00170 
00171 if (tp == NULL)
00172    {
00173    return TD_wrapped;
00174    }
00175 
00176 if (IncrementTwoDimList(tp->next,list) == TD_wrapped)
00177    {
00178    tp->current = (tp->current)->next;
00179 
00180    if (tp->current == NULL)
00181       {
00182       tp->current = tp->ilist;
00183       tp->rounds++;             /* count iterations to ident eolist*/
00184       return TD_wrapped;
00185       }
00186    else
00187       {
00188       return TD_nowrap;
00189       }
00190    }
00191 
00192 return TD_nowrap; /* Shouldn't get here */
00193 }

void Set2DList struct TwoDimList list  ) 
 

Definition at line 46 of file 2Dlist.c.

References TwoDimList::current, Debug1, TwoDimList::ilist, TwoDimList::next, and NULL.

Referenced by AppendDisable(), AppendIgnore(), AppendScript(), InstallAuthItem(), InstallFileListItem(), InstallImageItem(), InstallLinkChildrenItem(), InstallRequiredPath(), and InstallTidyItem().

00050 { struct TwoDimList *tp;
00051 
00052 Debug1("Set2DLIst()\n");
00053 
00054 for (tp = list; tp != NULL; tp=tp->next)
00055    {
00056    tp->current = tp->ilist;
00057    }
00058 }


© sourcejam.com 2005-2008