/* ** Name: icevar ** ** Description: ** ** ** Inputs: ** parms command line parameters. ** ** Outputs: ** None. ** ** Returns: ** OK Completed successfully ** !OK Failed. ** ** History: ** 23-May-2001 (fanra01) ** Created. */ ICE_STATUS icevar( PARAMS* parms ) { ICE_STATUS status = OK; II_CHAR cookie[80]; HICECTX hicectx; STprintf( cookie, "ii_cookie=%s", progparms.cookie ); if ((status = ic_initialize( NULL, NULL, NULL, cookie, &hicectx )) == OK) { switch(parms->action) { case IC_VAR_SET: status = ic_setvariable( hicectx, parms->scope, parms->variable, parms->value ); break; case IC_VAR_RET: status = ic_retvariable( hicectx, parms->scope, parms->variable, &parms->value ); break; } ic_close( hicectx ); } if (status != OK) { IIUGerr( status, UG_ERR_ERROR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); } else { SIprintf("%s: %s=%s\n", parms->name, parms->variable, ((parms->value != NULL) ? parms->value : "\0") ); } return(status); }
/* ** Name: regdocs ** ** Description: ** Function drives the registration loop according to whether the ** parameters are from an input file or the command line. ** ** Inputs: ** prog Program level global parameters. ** ** Outputs: ** None. ** ** Returns: ** OK Completed successfully ** E_IC_INVALID_UNIT_NAME Specified unit does not exist. ** E_IC_INVALID_LOC_NAME Specified location does not exist. ** ** History: ** 21-Feb-2001 (fanra01) ** Created. ** 04-May-2001 (fanra01) ** Add NULL cookie session parameter to function call. NULL denotes ** exclusive session. */ ICE_STATUS regdocs( PARAMS* prog ) { ICE_STATUS status = OK; LOCATION inloc; II_CHAR pathstr[MAX_LOC + 1]; REGPARAMS regparams; II_CHAR user[80] = ""; II_CHAR passwd[80]= ""; HICECTX icectx = NULL; II_CHAR* bu; II_CHAR* loc; /* ** Get user an password information in preparation to connect to the ** ice server */ IIUGprompt("ICE Admin User?", 1, 0, user, sizeof(user), 0); IIUGprompt("Password?", 1, 1, passwd, sizeof(passwd), 0); /* ** if the connection to ice server is successful get business unit id ** and location id from their names. */ if ((status = ic_initialize( prog->node, user, passwd, NULL, &icectx )) == OK) { if ((prog->unit != NULL) && ((status = ic_getitem( icectx, ICE_UNIT, "unit_name", prog->unit, "unit_id", &bu )) == OK)) { if (bu != NULL) { ASCTOI( bu, &prog->buid ); } } else { if (status == E_IC_OUT_OF_DATA) { status = E_IC_INVALID_UNIT_NAME; } } if ((status == OK) && (prog->loc != NULL)) { status = ic_getitem( icectx, ICE_LOCATION, "loc_name", prog->loc, "loc_id", &loc ); if((status == OK) && (loc != NULL)) { ASCTOI( loc, &prog->locid ); } else { if (status == E_IC_OUT_OF_DATA) { status = E_IC_INVALID_LOC_NAME; } } } if (prog->inpfile) { /* ** Options contain an input file. Open file and scan. ** ** -o owner -u unit -l location -t doctype -f flags filename.ext */ FILE* inpfile = NULL; if (*prog->inpfile == '-') { inpfile = stdin; } else { STcopy( prog->inpfile, pathstr ); if ((status = LOfroms( (PATH&FILENAME), pathstr, &inloc )) == OK) { status = SIopen( &inloc, "r", &inpfile ); } } if (inpfile != NULL) { while ((status == OK) && (readinpfile( inpfile, ®params ) == OK)) { status = registerdoc( icectx, prog, ®params ); if(regparams.owner) { MEMFREE( regparams.owner ); } if(regparams.unit) { MEMFREE( regparams.unit ); } if(regparams.location) { MEMFREE( regparams.location ); } if(regparams.filename) { MEMFREE( regparams.filename ); } } if (inpfile != stdin) { SIclose( inpfile ); } } } if (prog->xmlfile) { /* ** Options contain an XML input file. Open and scan. ** ** <unit name="unit_name" owner="owner_name"> ** <location name="location_name"> ** <page name="filename" ext="ext" type="external|global|repository"/> ** <facet name="filename" ext="ext" type="external|global|repository"/> ** </location> ** </unit> */ FILE* xmlfile; STcopy( prog->xmlfile, pathstr ); if ((status = LOfroms( (PATH&FILENAME), pathstr, &inloc )) == OK) { if ((status = SIopen( &inloc, "r", &xmlfile )) == OK) { /* ** No action until XML parser included. ** Just close the file for now. */ SIclose( xmlfile ); } } } if(prog->args != NULL) { /* ** Command line arguments contains a list of filenames. */ II_INT4 i; MEMFILL( sizeof(REGPARAMS), 0, ®params ); for (i=0; (status == OK) && (i < prog->nargs); i+=1) { regparams.filename = prog->args[i]; status = registerdoc( icectx, prog, ®params ); } } /* ** Disconnect from ice server. */ status = ic_close( icectx ); icectx = NULL; ic_terminate(); } else { IIUGerr( status, UG_ERR_ERROR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); } return(status); }