#ident "$URL: svn://elmer/devel/SVN/SDDAS/trunk/libCfg/SourceByNum.c $ %D% SwRI" #include #include "LinkList.h" #include "StrHier.h" #define MAXARGS 10 /* * LinkList List - root to tree to start query * * This routine returns the node defined by their number. The routine may take a * varing number of arguments to query a specific node. The last argument must be 0. */ StrHier SourceByNum(LinkList List, ...) { va_list ap; int *arg, args[MAXARGS]; int argno = 0; LinkList L; static StrHier S; int number; va_start (ap, List); number = va_arg(ap, int); while ((args[argno++] = va_arg(ap, int)) != (int)0); va_end (ap); for (L=List; L != NULL; L=L->next) { S = (StrHier)L->data; if (SNUM(S) == number) { for(arg=args; *arg != 0; arg++) { if ((S = SourceByNum(SUBLIST(S), *arg, 0)) == NULL) { return (StrHier)NULL; } } return S; } } return (StrHier) NULL; }