void Web_docommand(dccrec *d, char *buf) { cmdrec_t *wc; /* fix buf so we don't get empty fields */ rmspace(buf); /* Web command variables must be preset */ strcpy(Web->from_n,d->nick); strcpy(Web->from_uh,d->uh); split(Web->cmdname,buf); strcpy(Web->cmdparam,buf); /* Set DCC connection record */ Web->d = d; /* Set user and account pointers */ Web->user = d->user; Web->account = d->account; /* Now we're ready */ if(Web->cmdname[0] == 0) { Log_write(LOG_DEBUG,"*","Web_docommand() invoked with empty cmdname."); return; } /* Mark command as active */ Web->cmdinuse = 1; /* Find the command */ wc = Web_cmd(Web->cmdname); if(wc == NULL) { /* Not found. */ websay("No such command \"%s\".",Web->cmdname); Web->cmdinuse = 0; Web_reset(); return; } /* Check levels */ if(wc->levels != 0L) { if(!(Web->user->flags & wc->levels)) { char flags[USERFLAGLEN]; User_flags2str(wc->levels,flags); websay("That command requires +%s and you don't have it. Go away.",flags); Web->cmdinuse = 0; Web_reset(); return; } } /* Ok here we go */ str_element(Web->tok1,Web->cmdparam,1); str_element(Web->tok2,Web->cmdparam,2); str_element(Web->tok3,Web->cmdparam,3); Web->istok1 = Web->tok1[0] ? 1 : 0; Web->istok2 = Web->tok2[0] ? 1 : 0; Web->istok3 = Web->tok3[0] ? 1 : 0; Web->num_elements = num_elements(Web->cmdparam); Web->paramlen = strlen(Web->cmdparam); Web->isparam = Web->cmdparam[0] ? 1 : 0; /* Execute command */ wc->accessed++; wc->function(); /* Reset */ Web_reset(); Web->cmdinuse = 0; }
/**************************************************************** * TclDirectory: * Perform directory function ****************************************************************/ int TclDirectory() { unsigned int usage; char *tagnam; char textLine[128]; static char fmtTotal[] = "Total of %d node%s."; static char fmtGrandTotal[] = "Grand total of %d node%s."; static DYNAMIC_DESCRIPTOR(dsc_nodnam); static DYNAMIC_DESCRIPTOR(dsc_nodeList); static DYNAMIC_DESCRIPTOR(dsc_outline); char *pathnam; int nid; int status; void *ctx = 0; void *ctx2 = 0; int found = 0; int grand_found = 0; int first_tag; int full; static int nodnamLen; static int retlen; int last_parent_nid = -1; int version; static int parent_nid; static char nodnamC[12+1]; static int relationship; int previous_relationship; static unsigned char nodeUsage; static NCI_ITM general_info_list[] = { {4,NciPARENT,&parent_nid,0} ,{12,NciNODE_NAME,nodnamC,&nodnamLen} ,{4,NciPARENT_RELATIONSHIP,&relationship,0} ,{1,NciUSAGE,&nodeUsage,0} ,{0,NciEND_OF_LIST,0,0} }; static int elmnt; static DYNAMIC_DESCRIPTOR(dsc_allUsage); static DYNAMIC_DESCRIPTOR(dsc_usageStr); int usageMask = -1; parent_nid = 0; full = cli_present("FULL") & 1; if (cli_present("USAGE") & 1) { usageMask = 0; str_free1_dx(&dsc_allUsage); while (cli_get_value("USAGE",&dsc_usageStr) & 1) { str_concat(&dsc_allUsage,&dsc_allUsage,&dsc_usageStr,",",0); str_concat(&dsc_usageStr,"USAGE.",&dsc_usageStr,0); if (cli_get_value(&dsc_usageStr,&dsc_usageStr) & 1) { sscanf(dsc_usageStr.dscA_pointer,"%d",&usage); usageMask = usageMask | (1 << usage); } else MdsMsg(0,"Error getting usage id#",0); } } str_free1_dx(&dsc_outline); while (cli_get_value("NODE",&dsc_nodeList) & 1) { l2u(dsc_nodeList.dscA_pointer,0); for (elmnt=0; str_element(&dsc_nodnam,elmnt,',',&dsc_nodeList) & 1; elmnt++) { while ((status = TreeFindNodeWild(dsc_nodnam.dscA_pointer,&nid,&ctx,usageMask)) & 1) { grand_found++; status = TreeGetNci(nid,general_info_list); nodnamC[nodnamLen] = '\0'; if (parent_nid != last_parent_nid) { if (found) { if (!full && dsc_outline.dscW_length) { TclTextOut(dsc_outline.dscA_pointer); str_free1_dx(&dsc_outline); } TclTextOut(" "); sprintf(textLine,fmtTotal,found,(found>1)?"s":""); TclTextOut(textLine); } TclTextOut(" "); pathnam = TreeGetPath(parent_nid); TclTextOut(pathnam); TreeFree(pathnam); /* free the string */ TclTextOut(" "); found = 0; last_parent_nid = parent_nid; previous_relationship = relationship; } found++; if (full) { if (previous_relationship != relationship) { TclTextOut(" "); previous_relationship = relationship; } if (relationship == NciK_IS_CHILD) str_concat(&dsc_outline," ",nodnamC,0); else str_concat(&dsc_outline," :",nodnamC,0); ctx2 = 0; first_tag = 1; while (tagnam = TreeFindNodeTags(nid,&ctx2)) { str_concat(&dsc_outline,&dsc_outline, (first_tag?" tags: \\":",\\"),tagnam,0); TreeFree(tagnam); first_tag = 0; } TclTextOut(dsc_outline.dscA_pointer); str_free1_dx(&dsc_outline); version=0; while(doFull(nid,nodeUsage,version++)&1); #ifdef vms else lib$signal(status,0); #endif } else { if (previous_relationship != relationship) { TclTextOut(dsc_outline.dscA_pointer); str_free1_dx(&dsc_outline); TclTextOut(" "); previous_relationship = relationship; } if (relationship == NciK_IS_CHILD) str_concat(&dsc_outline, &dsc_outline," ",nodnamC,0); else str_concat(&dsc_outline, &dsc_outline," :",nodnamC,0); if (dsc_outline.dscW_length > 60) { TclTextOut(dsc_outline.dscA_pointer); str_free1_dx(&dsc_outline); } } } TreeFindNodeEnd(&ctx); }