/** BEGIN COPYRIGHT BLOCK * Copyright 2001 Sun Microsystems, Inc. * Portions copyright 1999, 2001-2003 Netscape Communications Corporation. * All rights reserved. * END COPYRIGHT BLOCK **/ /* * vlvindex.c: Creates a VLV index for a given search * * Rob Weltman */ #include #include #include "libadminutil/admutil.h" #include "dsalib.h" #include "init_ds_env.h" #include int main(int argc, char *argv[]) { int status; char *backendNames = NULL; char *attributes = NULL; char *tmparg = NULL; char **attrList = NULL; char **backendList = NULL; int nItem = 0; char *nextItem = NULL; int i=0; fprintf(stdout, "Content-type: text/html\n\n"); if ( init_ds_env() ) return 1; ds_send_status("Creating vlv index ..."); /* * Get var's value */ backendNames = ds_get_cgi_var("backendID"); if ( (NULL == backendNames) || (strlen(backendNames) < 1) ) { rpt_err( DS_UNDEFINED_VARIABLE, "backendID", NULL, NULL ); return 1; } attributes = ds_get_cgi_var("vlvTags"); if ( (NULL == attributes) || (strlen(attributes) < 1) ) { rpt_err( DS_UNDEFINED_VARIABLE, "vlvTags", NULL, NULL ); return 1; } tmparg = strdup( attributes ); nItem = 0; for(i=0 ; i < strlen(attributes) ; i++) { if ( tmparg[i] == ';' ) nItem++; } /* Allocate for worst possible case */ attrList = (char **)malloc(sizeof(*attrList) * (nItem + 2) ); nItem = 0; /* strtok() is not MT safe, but it is okay to call here because this is a command line */ attrList[nItem++] = strtok( tmparg, ";" ); do { nextItem = strtok( NULL, ";" ); attrList[nItem++] = nextItem; } while( nextItem != NULL ); tmparg = strdup( backendNames ); nItem = 0; for(i=0;i