/* ** Name: GetMSroot ** ** Description: ** Display the home HTML directory for MS IIS ** ** Inputs: ** conf pointer to the MS config structure. ** regkey generated registry key. ** ** Outputs: ** docpath contains the HTML root path ** ** Returns: ** none ** ** History: ** 09-Oct-98 (fanra01) ** Created. ** 20-Nov-1998 (fanra01) ** Add docpath. ** 24-Mar-1999 (fanra01) ** Store error return from RegQueryValueEx and retry on not found ** or not exist errors. */ STATUS GetMSroot (PW3CONF conf, char* regkey, char** docpath) { STATUS status = FAIL; i4 i =0; DWORD dwstat = 0; char val[10]; HKEY key; char regval[256]; DWORD valtype; DWORD valsize = sizeof(regval); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey, 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS) { /* ** Need this loop as microsoft annoyingly adds a comma to the key name ** when any HTTP paths have been updated. */ for (i = 0; i < 2; i++) { STcopy (httpsrv[enumwebsrv].val, val); if (i == 1) STcat (val, ","); if ((dwstat = RegQueryValueEx (key, val, NULL, &valtype, regval, &valsize)) == ERROR_SUCCESS) { char* p; if ((p = STindex (regval, ",", 0)) != NULL) *p = EOS; *docpath = STalloc (regval); status = OK; } else { switch (dwstat) { case ERROR_FILE_NOT_FOUND: case ERROR_CLASS_DOES_NOT_EXIST: case ERROR_ENVVAR_NOT_FOUND: /* ** Can't find? Try again with a comma */ break; default: SIprintf ("Error : %d Retrieving value %s. Info %d\n", dwstat, val, GetLastError()); i = 2; /* terminate loop */ break; } } } } else { DISPERROR(errflg)("Error : No Microsoft servers found\n"); } return (status); }
static VOID error_exit(DWORD errcode) { ex_handler(NULL); if (!SilentMode) SIprintf("\nERROR : The execution of this command failed. Please verify with your\n Ingres System Administrator that the Ingres service\n was started successfully. The operating system error was %d.\n", errcode); }
int main(argc, argv) { MEadvise( ME_INGRES_ALLOC ); SIprintf( "iimerge is for UNIX only!\n"); PCexit( FAIL ); }
static void display_err(char *etxt, STATUS status) { if (OK != ERreport(status, &etxt[STlength(etxt)])) STprintf(&etxt[STlength(etxt)], "(Reason unknown)", status); SIprintf("%s\n",etxt); }
/* ** Name: display_help ** ** Description: ** This function displays "help" information. ** ** Return value: ** void. ** ** Re-entrancy: ** This function does not update shared memory. ** ** Parameters: ** None. ** ** History: ** 01-Mar-04 (loera01) ** Created. */ static void display_help() { SIprintf("%sodbcinst help\n---------------\n", SYSTEM_CFG_PREFIX); SIprintf("Usage: %sodbcinst [-batch ] [ -m drvMgr ] [ -p altPath ] [ -rmpkg ] [ -r ]\n", SYSTEM_CFG_PREFIX); SIprintf("Arguments:\n"); SIprintf("-batch\t\tRun silently, without prompts\n"); SIprintf("-m driverMgr\tDriver Manager. Must be either \"unixODBC\" or \"CAI/PT\"\n"); SIprintf("-p altPath\tAlternate installation path for odbcinst.ini\n"); SIprintf("-rmpkg\t\tRemove Ingres driver definition from odbcinst.ini\n"); SIprintf("-r\t\tSpecify read-only driver as default\n"); SIprintf("-h or -help\tDisplay this help page\n"); }
static void show( char *classid, char *instance, char *sval, i4 perms, PTR arg ) { SIprintf("%-40s|%-40s|%-40s|0%o\n", classid, instance, sval, perms ); }
void main(int argc, char *argv[]) { char buf[ MAXBUF+1 ]; int ibuf, ichr; /* ** Set the set command. */ STprintf(buf, ERx( "@set " )); switch(argc) { /* ** Construct the rest of the command from the ** command line argument and standard input. */ case 2: ibuf = sizeof(ERx("@set ")) - 1; for ( ichr = 0 ;(ibuf < MAXBUF) && argv[1][ichr]; ) { buf[ibuf++] = argv[1][ichr++]; } buf[ibuf++] = '='; /* ** Set EOS in case there is nothing from standard input. */ buf[ibuf] = '\0'; SIgetrec(&buf[ibuf], MAXBUF-ibuf, stdin); break; default: SIprintf(stderr,"echo Usage: ipsetp variable_name"); break; } /* ** Print out the set command. */ SIprintf("%s\n",buf); }
static void show( char *classid, char *instance, char *sval, i4 perms, PTR arg ) { char classidbuf[ MAXCLASSID + MAXINSTANCE + 1 ]; STprintf( classidbuf, "%s:%s:", classid, instance ); SIprintf(classidbuf, "%-50s '%-12s'\t0%o\n", classidbuf, sval, perms ); }
static void yyputline( char *outtext) { char token_buf[MAX_LINE+1]; char token_val[MAX_LINE+1]; char *p = token_buf; static char *symc = ERx( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_$"); i4 symc_l = STlength(symc); i4 defidx; static i4 iterate_level = 0; /* Check to make sure we don't have runaway recursion */ if (iterate_level++ > MAX_ITERATION) { SIfprintf( stderr, E_YAPP006 ); yydump(); } /* Break up the string into tokens and try to resolve symbols */ while (*outtext != EOS) { p = token_buf; while (STindex(symc, outtext, symc_l) != NULL) { STlcopy(outtext, p, 1); CMnext(outtext); CMnext(p); } /* Found a token that may be defined as a symbol */ if (p != token_buf) { /* If the token is defined then translate the */ /* value of the substituted text, otherwise just */ /* output the untranslated text. */ STcopy(ERx(""), p); if (OK == is_defined(token_buf, token_val)) yyputline( token_val ); else SIprintf("%s", token_buf); } /* The text being processed at this point is whitespace, */ /* operators, or some other characters that are not */ /* valid for tokens. */ else { SIputc(*outtext, stdout); CMnext(outtext); } } iterate_level--; }
static STATUS gcn_open( char *name, char *mode, FILE **file, i4 *reclen ) { GCN_DB_RECORD record; STATUS status; if ( (status = gcn_nq_fopen( name, mode, file )) != OK ) return( status ); if ( gcn_read_rec( *file, (u_i1 *)&record, sizeof( record ) ) == OK ) switch( record.rec1.gcn_rec_type ) { case GCN_DBREC_V1 : case GCN_DBREC_DEL : if ( record.rec1.gcn_rec_len != *reclen ) { SIclose( *file ); *file = NULL; *reclen = record.rec1.gcn_rec_len; status = gcn_nq_fopen( name, mode, file ); if ( status != OK ) return( status ); } break; default : if ( *reclen != sizeof( GCN_DB_RECORD ) ) { SIprintf( "Warning: mismatch in record length: \n" ); SIprintf( " using %d instead of %d\n", *reclen, sizeof( GCN_DB_RECORD ) ); } } SIfseek( *file, (i4) 0, SI_P_START ); return( OK ); }
static STATUS mymonitor( char *classid, char *twinid, char *instance, char *value, PTR mon_data, i4 msg ) { SIprintf( "mymonitor.%p called for %s (oid %s):%s, value `%s', msg %d\n", mon_data, classid, twinid ? twinid : "<NULL>", instance, value ? value : "<NULL>", msg); return( OK ); }
static VOID gcn_read_rec0( i4 rec_no, GCN_DB_REC0 *record, i4 tup_id ) { i4 uidlen = min( record->gcn_l_uid, sizeof( record->gcn_uid ) ); i4 objlen = min( record->gcn_l_obj, sizeof( record->gcn_obj ) ); i4 vallen = min( record->gcn_l_val, sizeof( record->gcn_val ) ); record->gcn_uid[ uidlen ] = EOS; record->gcn_obj[ objlen ] = EOS; record->gcn_val[ vallen ] = EOS; SIprintf( "record %d: v0 0x%x '%s', '%s', '%s'\n", rec_no, tup_id, record->gcn_uid, record->gcn_obj, record->gcn_val ); return; }
/* ** Name: dumpparms ** ** Description: ** Function displays the parameters as gathered from the command line. ** ** Inputs: ** p Pointer to structure containing command line ** parameter values. ** ** Outputs: ** None. ** ** Returns: ** None. ** ** History: ** 21-Feb-2001 (fanra01) ** Created. */ II_VOID dumpparms( PARAMS* p ) { II_INT4 i; SIprintf("Node: %s\n", (p->node) ? p->node : "Local"); SIprintf("Owner: %s\n", (p->owner) ? p->owner : "Not specified"); SIprintf("Unit: %s\n", (p->unit) ? p->unit : "Not specified"); SIprintf("Loc: %s\n", (p->loc) ? p->loc : "Not specified"); SIprintf("Input: %s\n", (p->inpfile) ? p->inpfile : "Not specified"); SIprintf("Type: %08x\n", p->type); SIprintf("Flag: %08x\n", p->flags); for(i = 0; (i < p->nargs) && (p->args[i] != NULL); i+=1) { SIprintf("%03d %s\n", i, p->args[i]); } }
int main() { #ifdef LNX #ifndef SIMULATE_PROCESS_SHARED if ( sysconf(_SC_THREAD_PROCESS_SHARED) < 0 ) { if (errno == EINVAL) PCexit( OK ); SIprintf("\n\nIngres build is not compatible with the OS POSIX threading library.\n"); PCexit( FAIL ); } #endif #endif PCexit( OK ); }
static STATUS tbl_detach( i4 nelem, MO_INSTANCE_DEF *idp ) { STATUS ret_val = OK; for( ; nelem-- && idp->classid != NULL; idp++ ) if( (ret_val = MOdetach( idp->classid, idp->instance ) ) != OK ) break; if( ret_val != OK ) SIprintf("stat detaching %s:%s:\n%s\n", idp->classid, idp->instance, er_decode( ret_val )); return( ret_val ); }
i4 MO_instance_compare( const char *aptr, const char *bptr ) { MO_INSTANCE *a = (MO_INSTANCE *)aptr; MO_INSTANCE *b = (MO_INSTANCE *)bptr; register i4 res; res = *(char *)a->classdef->node.key - *(char *)b->classdef->node.key; if( res == 0 ) { { res = STcompare( a->classdef->node.key, b->classdef->node.key ); if( res == 0 ) { if( a->instance == NULL ) { res = b->instance == NULL? 0 : 1; } else if( b->instance == NULL ) { res = 1; } else { res = a->instance[0] - b->instance[0]; if( res == 0 ) res = STcompare( a->instance, b->instance ); } } } } # ifdef xDEBUG SIprintf("compare %s:%s %s:%s -> %d\n", a->classdef->node.key, a->instance ? a->instance : "<nil>", b->classdef->node.key, b->instance ? b->instance : "<nil>", res ); # endif return( res ); }
BOOL IIodbc_createPoolThread() { TH_THREAD_ID threadID ZERO_FILL; STATUS status=OK; TH_create_thread( 32768, /* stack size */ NULL, /* stack addr */ IIodbc_timeOutThread, /* init routine */ (void *)NULL, /* parm */ &threadID, /* thread id */ TH_DETACHED, /* release resource on xit */ &status ); if (status != OK) { SIprintf("NO POOLING THREAD CREATED\n"); return FALSE; } return TRUE; }
MO_INSTANCE * MO_getinstance( char *classid, char *instance ) { MO_CLASS cb; MO_INSTANCE ib; MO_INSTANCE *ip; cb.node.key = classid; ib.classdef = &cb; ib.instance = instance; ib.node.key = (PTR)&ib; if( instance != NULL ) /* find exact match */ { ip = (MO_INSTANCE *)SPlookup( &ib.node, MO_instances ); } else /* find first of that class */ { /* ** This relies on the comparison function returning -1 ** when classids are equal, and the input instance is NULL. ** After the enq, ib is the lowest block of the class; the ** next one is the old first. */ (VOID) SPenq( &ib.node, MO_instances ); ip = (MO_INSTANCE *)SPnext( &ib.node, MO_instances ); SPdelete( &ib.node, MO_instances ); if( ip != NULL && !STequal( (char *)ip->classdef->node.key, classid ) ) ip = NULL; } # ifdef xDEBUG SIprintf("getinstance %s:%s -> %s:%s\n", classid ? classid : "<nil>", instance ? instance : "<nil>", ip ? ip->classdef->node.key : "<nil>", ip ? ip->instance : "<nil>" ); # endif return( ip ); }
/* ** Name: log_errmsg - logs a user and VMS error status to errlog.log ** ** Description: ** This routine converts OpenVMS status code to an OpenVMS text ** error message, then puts the specified message with ": status" ** appended and then the VMS error message output to the errlog.log ** ** Inputs: ** usrmsg - user specified error text (24 characters) ** code - VMS status code ** flg - 0 send message to error.log only, ** 1 write to standard out and to errlog.log ** ** Outputs: ** None ** ** Returns: ** void ** ** History: ** 22-nov-1993 (eml) ** Created to allow the use ot ERoptlog to write all error messages. ** 31-jan-1994 (bryanp) ** Even if SYS$GETMSG fails, report the "usrmsg" anyway. */ static void log_errmsg( const char *usrmsg, const unsigned int code, const unsigned int flg ) { static $DESCALLOC( bufadr ); char stsbuf[256]; char msgbuf[256]; unsigned short len; STATUS status; $DESCFILL( bufadr, sizeof( stsbuf ), stsbuf ); status = sys$getmsg( code, &len, &bufadr, 0x0F, NULL ); if ( !(status & 1) ) { /* ** "code" was not a valid VMS message status, or at least not one which ** we could turn into message text. So just format it in hex. Assume ** that the result is exactly eight characters long (does CVlx null ** terminate its output? If so, could set len = STlength(stsbuf);). */ CVlx(code, stsbuf); len = 8; } STcopy( usrmsg, msgbuf ); STcat( msgbuf, ": Status" ); stsbuf[len] = '\0'; ERoptlog( msgbuf, stsbuf ); if ( flg ) { SIprintf( "%s = %s\n", msgbuf, stsbuf ); SIflush( stdout ); } return; }
static void addusertables(void) { i4 i; char inststr[ 10 ]; MO_INSTANCE_DEF *idp; STATUS ret_stat; (VOID) MOclassdef( MAXI2, mib_cdefs ); for( idp = mib_idefs; idp->classid != NULL; idp++ ) idp->instance = inststr; for( i = 1; i < MAXUSERS ; i++ ) { CVlx( i * 64, inststr ); ret_stat = tbl_attach( MAXI2, mib_idefs ); SIprintf("stat attaching user %s: %s\n", inststr, er_decode( ret_stat ) ); } }
/* ** Name: GetNSroot ** ** Description: ** Display the home HTML directory for NS ** ** Inputs: ** conf pointer to the NS config structure. ** regkey generated registry key. ** ** Outputs: ** docpath contains the HTML root path ** ** Returns: ** none ** ** History: ** 09-Oct-98 (fanra01) ** Created. ** 20-Nov-1998 (fanra01) ** Add docpath. */ STATUS GetNSroot (PW3CONF conf, char* mc, char** docpath) { STATUS status = FAIL; PW3CONF p = conf+1; char reg[256]; i4 i; errflg = FALSE; for (i=0; (STbcompare (p->id, 2, "NS", 2, TRUE) == 0) && (status == FAIL); i+=1, p+=1) { STprintf (reg, p->reg, mc); status = p->gethtml (p, reg, docpath); } if (status != OK) { SIprintf ("Error : No Netscape servers found\n"); } return (status); }
static void showall(void) { i4 lsbuf; char classid[ MAXCLASSID ]; char instance[ MAXINSTANCE ]; char sbuf[ MAXVAL ]; i4 perms; classid[0] = EOS; instance[0] = EOS; for( lsbuf = sizeof(sbuf); ; lsbuf = sizeof( sbuf ) ) { if( OK != MOgetnext( ~0, sizeof(classid), sizeof(instance), classid, instance, &lsbuf, sbuf, &perms ) ) break; show( classid, instance, sbuf, perms, (PTR)NULL ); } SIprintf("\n"); }
/* ** 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); }
int main(int argc, char* argv[]) { time_t ltime; time_t tm_0, tm_1; char szIIdate[64]; char szCommandLineString[1024]; int i; double dtime; time( &tm_0 ); g_pLoadData = (LOADDATA*)malloc (sizeof(LOADDATA)); memset (g_pLoadData, 0, sizeof(LOADDATA)); memset (&g_ReadSizeEvent, 0, sizeof(g_ReadSizeEvent)); memset (&g_dataLoaderStruct, 0, sizeof (g_dataLoaderStruct)); g_dataLoaderStruct.nArraySize = 5; g_dataLoaderStruct.arrayFiles = (INFILES*)malloc (g_dataLoaderStruct.nArraySize * sizeof(INFILES)); memset (&g_mutexWrite2Log, 0, sizeof (g_mutexWrite2Log)); szIIdate[0] = '\0'; if (!IsInputDateCompatible(szIIdate)) { if (szIIdate[0]) DTSTRUCT_SetDateFormat(&g_dataLoaderStruct, szIIdate); } CreateDTLMutex(&g_mutexWrite2Log); /* ** Construct the command line string from the argv[] */ szCommandLineString[0] = '\0'; for (i=1; i<argc; i++) { if (i>1) STcat (szCommandLineString, " "); STcat (szCommandLineString, argv[i]); } /* ** Parse the command line string and update the ** Data Loader structure: */ memset (&g_cmd, 0, sizeof (g_cmd)); if (szCommandLineString[0]) { STATUS st; LOCATION lf; char* strFle = NULL; int nOk = ParseCommandLine (szCommandLineString, &g_cmd); if (nOk == 0) { free (g_pLoadData); /* ** Command line syntax error: */ SIprintf("Command line syntax error !!!\n"); return 1; } else { /* ** Check the MANDATORY command line: */ char* strItem = CMD_GetVnode(&g_cmd); if (strItem && !strItem[0]) { free (g_pLoadData); SIprintf("Command line option missing: the connection string <vnode> is mandatory.\n"); return 1; } strItem = CMD_GetControlFile(&g_cmd); if (strItem && !strItem[0]) { free (g_pLoadData); SIprintf("Command line option missing: the control file is mandatory.\n"); return 1; } } if (CMD_GetReadSize(&g_cmd) > 0) g_lReadSize = CMD_GetReadSize(&g_cmd); /* ** Create the log file if needed: */ strFle = CMD_GetLogFile(&g_cmd); if (!strFle || !strFle[0]) { char szBuff[1024]; char* pFound; STcopy (CMD_GetControlFile(&g_cmd), szBuff); pFound = STrindex (szBuff, ".ctl", -1); if (pFound && (STlength (pFound) == 4) && STcompare(pFound, ".ctl") == 0) { pFound[0] = '\0'; STcat (szBuff, ".log"); CMD_SetLogFile(&g_cmd, szBuff); } } else { char szBuff[1024]; char* pFound; STcopy (CMD_GetLogFile(&g_cmd), szBuff); pFound = STrindex (szBuff, ".", -1); if (!pFound) /* if logfile has no extension then add a .log extension */ { STcopy (strFle, szBuff); STcat (szBuff, ".log"); CMD_SetLogFile(&g_cmd, szBuff); } } LOfroms (PATH&FILENAME, strFle, &lf); st = SIfopen (&lf, "w", SI_TXT, DT_SI_MAX_TXT_REC, &g_fLogFile); if (st != OK) { g_fLogFile = NULL; SIprintf ("Failed to create log file\n"); } time( <ime ); WRITE2LOG3("%s: Release %s - Production on %s\n\n", INGRES_DATA_LOADER, g_sVersion, ctime(<ime)); WRITE2LOG0("Copyright (C) 2005-2006 Ingres Corporation. All Rights Reserved.\n\n"); WRITE2LOG1("Control File:\t%s\n", CMD_GetControlFile(&g_cmd)); if (!g_mutexWrite2Log.nCreated) { E_WRITE2LOG1("%s: Failed to create the Mutex 'g_mutexWrite2Log' for writing log file\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } nOk = ParseControlFile(&g_dataLoaderStruct, &g_cmd); if (nOk == 0) { E_WRITE2LOG1("%s: Syntax error in the control file.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } else if (nOk == -1) { E_WRITE2LOG1("%s: Cannot open control file.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } else { int i; int nErrorAccesInfile=0; int nAllwithPosition=1; int nWithPosition = 0; int nPosError = 0; int nMax=0; int nWrongSep = 0; FIELDSTRUCT* pField = &(g_dataLoaderStruct.fields); FIELD* listField = pField->listField; int* aSet = GetControlFileMandatoryOptionSet(); if (aSet[0] == 0) { E_WRITE2LOG1("%s: LOAD DATA is mandatory at the begining of the control file.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } if (aSet[1] == 0 || !DTSTRUCT_GetInfile(&g_dataLoaderStruct, 0)) { E_WRITE2LOG1("%s: INFILE is mandatory in the control file.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } for (i=0; i<g_dataLoaderStruct.nFileCount; i++) { strFle = DTSTRUCT_GetInfile(&g_dataLoaderStruct, i); if (access(strFle, 0) == -1) { nErrorAccesInfile = 1; E_WRITE2LOG2("%s: INFILE '%s' cannot be accessed.\n", INGRES_DATA_LOADER, strFle); } } if (nErrorAccesInfile == 1) { CleanVariables(); return 1; } if (aSet[5] == 0 || STlength (DTSTRUCT_GetTable(&g_dataLoaderStruct)) == 0) { E_WRITE2LOG1("%s: INTO TABLE <table>, a table name is mandatory in the control file.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } if (aSet[6] == 0) { E_WRITE2LOG1("%s: APPEND key word is mandatory in the control file.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } if (aSet[8] == 0) { E_WRITE2LOG1("%s: The table columns must be specified in the control file.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } if (g_dataLoaderStruct.fields.szTerminator[0] && g_dataLoaderStruct.fields.szTerminator[0] == '\n') nWrongSep = 1; if (listField) { int p1 = 0, p2 = 0; while (listField) { if (listField->szTerminator[0] && strcmp (listField->szTerminator, "\\n") == 0) nWrongSep = 1; if (listField->pos1 <= p2) nPosError = 1; p1 = listField->pos1; p2 = listField->pos2; if (listField->pos1 <= 0 || listField->pos2 <= 0) nPosError = 1; if (listField->pos1 > listField->pos2 ) nPosError = 1; if (listField->pos2 > nMax) nMax = listField->pos2; if (listField->pos1 == 0 && listField->pos2 == 0) { listField = listField->next; nAllwithPosition = 0; continue; } nWithPosition = 1; listField = listField->next; } } if (nWrongSep == 1) { E_WRITE2LOG1("%s: You should not use the '\\n' as field separator.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } for (i=0; i<g_dataLoaderStruct.nFileCount; i++) { int j; if ((i>0) && (DTSTRUCT_GetFixLength(&g_dataLoaderStruct, 0) != DTSTRUCT_GetFixLength(&g_dataLoaderStruct, i))) { E_WRITE2LOG1("%s: FIX n, fixed record length must be the same for all INFILE clauses.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } /* ** Check if there are multiple bad files with the same name: */ for (j=i+1; j<g_dataLoaderStruct.nFileCount;j++) { if (stricmp (g_dataLoaderStruct.arrayFiles[i].badfile, g_dataLoaderStruct.arrayFiles[j].badfile)==0) { E_WRITE2LOG1("%s: Multiple bad files with the same name. You should specify different BADFILE for each INFILE.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } } } if (DTSTRUCT_GetFixLength(&g_dataLoaderStruct, 0) > 0) { if (nWithPosition && !nAllwithPosition) { E_WRITE2LOG1("%s: FIX n, fixed record length is specified, if you use POSITION (n, p) then all columns must use the POSITION.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } if (nPosError == 1) { E_WRITE2LOG1("%s: If you use POSITION (n, p) then n, p should be > 0.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } if (nMax > DTSTRUCT_GetFixLength(&g_dataLoaderStruct, 0)) { E_WRITE2LOG1("%s: In the last POSITION (n, p), p should be <= FIX value.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } } else { if (nWithPosition == 1) { E_WRITE2LOG1("%s: If you use POSITION (n, p) then you should also specify FIX value.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } } if (FIELDSTRUCT_GetColumnCount (pField) <= 0) { E_WRITE2LOG1("%s: The list of columns should be specified.\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } } for (i=0; i<g_dataLoaderStruct.nFileCount; i++) { WRITE2LOG1("Data File:\t%s\n", DTSTRUCT_GetInfile(&g_dataLoaderStruct, i)); if (DTSTRUCT_GetFixLength(&g_dataLoaderStruct, i) > 0) WRITE2LOG1(" File processing option string: \"fix %d\"\n", DTSTRUCT_GetFixLength(&g_dataLoaderStruct, i)); WRITE2LOG1(" Bad File:\t%s\n", DTSTRUCT_GetBadfile(&g_dataLoaderStruct, i)); if (DTSTRUCT_GetDiscardFile(&g_dataLoaderStruct, i)) WRITE2LOG1(" Discard File:\t%s\n", DTSTRUCT_GetDiscardFile(&g_dataLoaderStruct, i)); } WRITE2LOG1(" (Allow %d discards)\n", DTSTRUCT_GetDiscardMax(&g_dataLoaderStruct)); WRITE2LOG0("\n\n"); WRITE2LOG1("Table %s\n", DTSTRUCT_GetTable(&g_dataLoaderStruct)); WRITE2LOG0("Insert option in effect for this table: APPEND\n"); /* WRITE2LOG1("Load to Table:\t%s\n", DTSTRUCT_GetTable(&g_dataLoaderStruct)); WRITE2LOG1("Read Size:\t%d\n", g_lReadSize); WRITE2LOG1("Parallel:\t%c\n", (CMD_GetParallel(&g_cmd) == 1)? 'Y': 'N'); */ if (!CheckForKnownDateFormat()) E_WRITE2LOG1("%s: The setting value of II_DATE_FORMAT is unknown.\n", INGRES_DATA_LOADER); memset (&g_mutexLoadData, 0, sizeof (DTLMUTEX)); if (!CreateDTLMutex(&g_mutexLoadData)) { E_WRITE2LOG1("%s: Failed to create the Mutex 'g_mutexLoadData'\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } if (!CreateReadsizeEvent(&g_ReadSizeEvent)) { E_WRITE2LOG1 ("%s: Failed to create the Readsize Condition 'g_ReadSizeEvent'\n", INGRES_DATA_LOADER); CleanVariables(); return 1; } /* ** Create the session: */ nOk = INGRESII_llConnectSession(CMD_GetVnode(&g_cmd)); if (nOk == 0) /* SQL Error */ { char* strError = INGRESII_llGetLastSQLError(); if (strError && strError[0]) /* Error while connecting to the DBMS:*/ WRITE2LOG0(strError); CleanVariables(); return 1; } for (i=0; i<g_dataLoaderStruct.nFileCount; i++) { /* ** Start the thread that reads the input data file and ** puts the data in the FIFO queue: */ StartInputReaderThread(&g_dataLoaderStruct); /* ** The main thread begins a loop reading the data ** from the FIFO queue, transfer the data to the DBMS by ** using the COPY INTO callback program: */ nOk = StartTransferDataThread(&g_dataLoaderStruct); if (nOk == 0) /* SQL Error */ { char* strError = INGRESII_llGetLastSQLError(); if (strError && strError[0]) WRITE2LOG0 (strError); } g_dataLoaderStruct.nCurrent++; memset (g_pLoadData, 0, sizeof(LOADDATA)); } nOk = INGRESII_llDisconnectSession(1, 1); if (nOk == 0) /* SQL Error */ { char* strError = INGRESII_llGetLastSQLError(); if (strError && strError[0]) WRITE2LOG0 (strError); } } else { SIprintf("Usage: \tdataldr [vnode::]dbname[/serverclass] control=controlfile\n"); SIprintf("\t[log=logfile][parallel=y] [direct=y] [readsize=value]"); } time( &tm_1 ); dtime = difftime (tm_1, tm_0); WRITE2LOG0("\n\n"); WRITE2LOG1("Run began on %s", ctime(&tm_0)); WRITE2LOG1("Run ended on %s\n", ctime(&tm_1)); WRITE2LOG0("\n\n"); Time2Chars(dtime, szIIdate); WRITE2LOG1("Elapsed time was: %s\n", szIIdate); STcopy ("00:00:00", szIIdate); if ((g_lCpuEnded - g_lCpuStarted) >= 0) { double ds = 0.0, d1; int lms = g_lCpuEnded - g_lCpuStarted; while (lms >=1000) { lms -= 1000; ds += 1.0; } d1 = (double)lms / 10.0; /* 1/100 s == 10 ms */ d1 = d1 / 100.0; /* into the seconds */ ds += d1; Time2Chars(ds, szIIdate); } WRITE2LOG1("CPU time was: %s\n", szIIdate); /* ** Free the structure before exiting: */ CleanVariables(); return 0; }
int main( int argc, char **argv ) { CL_ERR_DESC err; PTR handle; PTR handle1; PTR handle2; PTR addr; STATUS status; int (*int_fcn)(); char *(*str_fcn)(); int int_ret; char *cp_ret; LOCATION srcfile; char srcbuf[MAX_LOC+1]; LOCATION objfile; char objbuf[MAX_LOC+1]; bool pristine; LOCATION modloc; char modbuf[MAX_LOC+1]; LOCATION dlloc; char dlbuf[MAX_LOC+1]; LOCATION errloc; char errbuf[MAX_LOC+1]; LOCATION nameloc; char namebuf[MAX_LOC+1]; char *nameptr; char *parms[2]; i4 flags; STATUS mod2status = OK; /* find the working directory */ NMgtAt( "IIDLDIR", &cp_ret ); if ( cp_ret == NULL || *cp_ret == EOS ) { SIprintf( "%sDLDIR not set\n", SystemVarPrefix ); PCexit( 1 ); } /* save the directory name into a larger buffer for LO */ STcopy( cp_ret, srcbuf ); /* initialize a LOCATION with the directory */ LOfroms( PATH, srcbuf, &srcfile ); /* initialize the object file LOCATION with same directory */ LOcopy( &srcfile, objbuf, &objfile ); LOcopy( &srcfile, modbuf, &modloc ); LOcopy( &srcfile, dlbuf, &dlloc ); LOcopy( &srcfile, errbuf, &errloc ); /* add filenames to LOCATION */ LOfstfile( srcs[0], &srcfile ); LOfstfile( objs[0], &objfile ); LOfstfile( erroutput, &errloc ); /* compile with error */ #ifdef NT_GENERIC parms[0] = "-g"; #else NT_GENERIC parms[0] = "-Zi"; #endif NT_GENERIC parms[1] = NULL; status = UTcompile_ex( &srcfile, &objfile, &errloc, parms, FALSE, &pristine, &err ); if ( status != OK ) { SIprintf( "Compile error test returns: " ); if ( status == UT_CO_FILE ) SIprintf( "\n utcom.def file not found or II_COMPILE_DEF not set\n" ); else if ( status == UT_CO_IN_NOT ) SIprintf( "source file not found.\n" ); else SIprintf( "%d\n", status ); SIprintf( "Contents of error file:\n" ); SIprintf( "------------------------------------------------------\n" ); SIcat( &errloc, stdout ); SIprintf( "------------------------------------------------------\n" ); SIprintf( "\n" ); } else { SIprintf( "Test of compile error returned OK.\n" ); SIprintf( "Contents of error file:\n" ); SIprintf( "------------------------------------------------------\n" ); SIcat( &errloc, stdout ); SIprintf( "------------------------------------------------------\n" ); SIprintf( "\n" ); } /* add filenames to LOCATION */ LOfstfile( srcs[0], &srcfile ); LOfstfile( objs[0], &objfile ); /* do a good compile */ #ifdef NT_GENERIC parms[0] = "-Zi"; #else NT_GENERIC parms[0] = "-g"; #endif NT_GENERIC status = UTcompile_ex( &srcfile, &objfile, NULL, parms, FALSE, &pristine, &err ); if ( status != OK ) { SIprintf( "Error compiling module: %d\n", status ); PCexit( 1 ); } LOfstfile( srcs1[0], &srcfile ); LOfstfile( objs1[0], &objfile ); status = UTcompile( &srcfile, &objfile, NULL, &pristine, &err ); if ( status != OK ) { SIprintf( "Error compiling module1\n" ); PCexit( 1 ); } LOfstfile( srcs2[0], &srcfile ); LOfstfile( objs2[0], &objfile ); mod2status = UTcompile( &srcfile, &objfile, NULL, &pristine, &err ); if ( mod2status != OK ) { SIprintf( "Error compiling module2\n" ); SIprintf( "This is not an error if C++ is not installed.\n" ); SIprintf( "Skipping further processing of this module\n\n" ); } /* link first module into shared library */ if ( DLcreate( NULL, NULL, module, objs, NULL, lookups, &err) != OK ) { SIprintf( "Error creating module\n" ); PCexit( 1 ); } if ( DLcreate_loc( NULL, NULL, module1, objs1, NULL, lookups1, &dlloc, NULL, &errloc, FALSE, NULL, &err) != OK ) { SIprintf( "Error creating module1\n" ); PCexit( 1 ); } SIprintf( "Contents of DLcreate_loc() error file for module1:\n" ); SIprintf( "------------------------------------------------------\n" ); SIcat( &errloc, stdout ); SIprintf( "------------------------------------------------------\n" ); SIprintf( "\n" ); if ( mod2status == OK ) { if ( DLcreate_loc( NULL, NULL, module2, objs2, NULL, lookups2, &dlloc, NULL, &errloc, FALSE, "C++", &err) != OK ) { SIprintf( "Error creating module2\n" ); PCexit( 1 ); } SIprintf( "Contents of DLcreate_loc() error file for module2:\n" ); SIprintf( "------------------------------------------------------\n" ); SIcat( &errloc, stdout ); SIprintf( "------------------------------------------------------\n" ); SIprintf( "\n" ); } STcopy( module1, namebuf ); LOfroms( FILENAME, namebuf, &nameloc ); DLconstructloc( &nameloc, namebuf, &nameloc, &err ); LOtos( &nameloc, &nameptr ); SIprintf( "Full path for %s is \"%s\"\n", module1, nameptr ); LOcopy( &dlloc, namebuf, &nameloc ); LOfstfile( module, &nameloc ); DLconstructloc( &nameloc, namebuf, &nameloc, &err); LOtos( &nameloc, &nameptr ); SIprintf( "Full path for %s is \"%s\"\n", module, nameptr ); /* test an error */ SIprintf( "Testing DLprepare of non-existant module.\n" ); if ( DLprepare((char *)NULL, "XXX", lookups, &handle, &err) == OK ) { SIprintf( "Error: returned success, should be failure.\n" ); PCexit( 1 ); } /* load the modules into the executable */ SIprintf( "Now loading the real modules.\n" ); if ( DLprepare((char *)NULL, module, lookups, &handle, &err) != OK ) { SIprintf( "Error loading module\n" ); PCexit( 1 ); } if ( mod2status == OK && DLprepare((char *)NULL, module2, lookups2, &handle2, &err) != OK ) { SIprintf( "Error loading module2\n" ); PCexit( 1 ); } putenv( "IIDLDIR=XXX" ); flags=0; if ( DLprepare_loc((char *)NULL, module1, lookups1, &dlloc, flags, &handle1, &err) != OK ) { SIprintf( "Error loading module1\n" ); PCexit( 1 ); } /* get the address of a function and test it */ if ( DLbind(handle1, "returns_onehundred", &addr, &err) != OK ) { /* "returns_onehundred" function isn't there */ DLunload( handle, &err ); PCexit( 1 ); } int_fcn = (int (*)()) addr; int_ret = (*int_fcn)(); SIprintf( "\"returns_onehundred\" returns %d\n", int_ret ); if ( int_ret != 100 ) { /* function didn't correctly return 100 */ PCexit( 1 ); } if ( mod2status == OK ) { if ( DLbind(handle2, "returns_ninetynine", &addr, &err) != OK ) { SIprintf( "Error binding \"returns_ninetynine\"\n" ); /* "returns_ninetynine" function isn't there */ DLunload( handle2, &err ); PCexit( 1 ); } int_fcn = (int (*)()) addr; int_ret = (*int_fcn)(); SIprintf( "\"returns_ninetynine\" returns %d\n", int_ret ); if ( int_ret != 99 ) { /* function didn't correctly return 99 */ PCexit( 1 ); } } if ( DLbind(handle, "returns_one", &addr, &err) != OK ) { /* "returns_one" function isn't there */ DLunload( handle, &err ); PCexit( 1 ); } int_fcn = (int (*)()) addr; int_ret = (*int_fcn)(); SIprintf( "\"returns_one\" returns %d\n", int_ret ); if ( int_ret != 1 ) { /* function didn't correctly return 1 */ PCexit( 1 ); } if ( DLbind(handle, "returns_zero", &addr, &err) != OK ) { /* "returns_zero" function isn't there */ DLunload( handle, &err ); PCexit( 1 ); } int_fcn = (int (*)()) addr; int_ret = (*int_fcn)(); SIprintf( "\"returns_zero\" returns %d\n", int_ret ); if ( int_ret != 0 ) { /* function didn't correctly return 0 */ PCexit( 1 ); } if ( DLbind(handle, "returns_minus_one", &addr, &err) != OK ) { /* "returns_minus_one" function isn't there */ DLunload( handle, &err ); PCexit( 1 ); } int_fcn = (int (*)()) addr; int_ret = (*int_fcn)(); SIprintf( "\"returns_minus_one\" returns %d\n", int_ret ); if ( int_ret != -1 ) { /* function didn't correctly return -1 */ PCexit( 1 ); } if ( DLbind(handle, "returns_string", &addr, &err) != OK ) { /* "returns_string" function isn't there */ DLunload( handle, &err ); PCexit( 1 ); } str_fcn = (char *(*)()) addr; cp_ret = (*str_fcn)(); SIprintf( "\"returns_string\" returns \"%s\"\n", cp_ret ); if ( STcompare(cp_ret, "String") != OK ) { /* function didn't correctly return "String" */ PCexit( 1 ); } /* functions were called successfully, now unload the modules */ if ( DLunload( handle, &err ) != OK ) { SIprintf( "Error unloading module.\n" ); PCexit( 1 ); } if ( DLunload( handle1, &err ) != OK ) { SIprintf( "Error unloading module.\n" ); PCexit( 1 ); } if ( mod2status == OK && DLunload( handle2, &err ) != OK ) { SIprintf( "Error unloading module2.\n" ); PCexit( 1 ); } if ( DLdelete_loc( module1, &dlloc, &err ) != OK ) { SIprintf( "Error deleting module1.\n" ); PCexit( 1 ); } SIprintf( "Successfully executed.\n" ); PCexit( 0 ); }
int main(int argc, char *argv[]) { #define MAXBUF 4095 char buf[ MAXBUF+1 ]; int iarg, ibuf, ichr; bool debug = FALSE; CL_ERR_DESC err_code; char *p1 = NULL; char pid[MAXBUF]; char *database = ERx(""); char *user = ERx(""); char *xmlfile = ERx(""); char sql_fname[LO_NM_LEN + 1]; char *work_dir = NULL; char directory[MAX_LOC + 1]; char *tmp_dir = NULL; char tmp_buf[MAX_LOC + 1]; char subdir_buf[MAX_LOC + 1]; char sql_loc_buf[MAX_LOC + 1]; char *progname; LOCATION tmp_dir_loc; LOCATION tmp_subdir_loc; LOCATION tmp_buff_loc; LOCATION curr_loc; LOCATION sql_file_loc; char *password = ERx(""); char *groupid = ERx(""); ARGRET rarg; i4 pos; LOCATION xmlfile_loc; FILE *xmlfile_read; STATUS stat = FAIL; char dbuf[256]; char encode[32]; u_i4 tmppid; TM_STAMP tm_stamp; /* Tell EX this is an ingres tool. */ (void) EXsetclient(EX_INGRES_TOOL); /* Call IIUGinit to initialize character set attribute table */ if ( IIUGinit() != OK) PCexit(FAIL); progname = ERget(F_XM0006_IMPXML); FEcopyright(progname, ERx("2001")); /* ** Get arguments from command line */ /* required parameters */ if (FEutaopen(argc, argv, ERx("xmlimport")) != OK) PCexit(FAIL); /* database name is required */ if (FEutaget(ERx("database"), 0, FARG_PROMPT, &rarg, &pos) != OK) PCexit(FAIL); database = rarg.dat.name; if (FEutaget(ERx("xmlfile"), 0, FARG_PROMPT, &rarg, &pos) != OK) PCexit(FAIL); xmlfile = rarg.dat.name; if (FEutaget(ERx("user"), 0, FARG_FAIL, &rarg, &pos) == OK) user = rarg.dat.name; if (FEutaget(ERx("password"), 0, FARG_FAIL, &rarg, &pos) == OK) { char *IIUIpassword(); if ((password = IIUIpassword(ERx("-P"))) == NULL) { FEutaerr(BADARG, 1, ERx("")); PCexit(FAIL); } } if (FEutaget(ERx("groupid"), 0, FARG_FAIL, &rarg, &pos) == OK) groupid = rarg.dat.name; if (FEutaget(ERx("debug"), 0, FARG_FAIL, &rarg, &pos) == OK) debug = TRUE; ibuf = STlength(buf); /* b121678: pid is no longer based on process id, but it's ** a random number instead. */ PCpid(&tmppid); TMget_stamp(&tm_stamp); MHsrand2(tmppid * tm_stamp.tms_usec); STprintf(pid, "%x", MHrand2()); #ifdef xDEBUG SIprintf(" the pid is: %s \n", pid); #endif /* create the sql file */ /* Avoid a name like "foo.xml.sql" on VMS, use pid.sql instead */ STcopy(pid, sql_fname); STcat(sql_fname, ".sql"); /* ** create in the temp location a directory ** with the name pid. set this directory ** as the working directory for impxml */ NMloc (TEMP, PATH, NULL, &tmp_dir_loc); /* make a location for TMP loc */ /* print location name */ LOcopy (&tmp_dir_loc, tmp_buf, &tmp_buff_loc); LOtos (&tmp_buff_loc, &tmp_dir); #ifdef xDEBUG SIprintf ("temploc: %s \n", tmp_dir); #endif /* make a subdir location with filename, pid */ STcopy (pid, subdir_buf); /* Initialize result loc so that everyone is happy */ LOcopy (&tmp_dir_loc, sql_loc_buf, &sql_file_loc); /* Generate location for temp subdirectory */ if (LOfaddpath (&tmp_dir_loc, subdir_buf, &sql_file_loc) != OK) { IIUGerr(E_XM0007_Locname_Failed, UG_ERR_FATAL, 2, tmp_dir, subdir_buf); /* NOTREACHED */ } /* print the location name */ LOcopy (&sql_file_loc, tmp_buf, &tmp_buff_loc); LOtos (&tmp_buff_loc, &work_dir); #ifdef xDEBUG SIprintf ("work dir loc: %s \n", work_dir); #endif /* create the subdir */ if (LOcreate (&sql_file_loc) != OK) { IIUGerr(E_XM0008_Create_Temp_Dir, UG_ERR_ERROR, 1, work_dir); PCexit(FAIL); } STcopy(work_dir, directory); #ifdef xDEBUG SIprintf ("sql file name: %s \n", sql_fname); SIprintf ("xml file name: %s \n", xmlfile); #endif /* Execute the command impxml */ STprintf (buf, ERx( "impxml -d=\"%s\" -o=\"%s\" " ), directory, sql_fname); /* encoding? */ if ( (LOfroms(PATH & FILENAME, xmlfile, &xmlfile_loc) != OK) || (SIopen(&xmlfile_loc, "r", &xmlfile_read) != OK) || (xmlfile_read == NULL) ) { IIUGerr(E_XM0009_Cannot_Open_File, UG_ERR_ERROR, 1, xmlfile); PCexit(FAIL); } /* scan XML declaration for encoding, if any */ if (stat = SIgetrec(dbuf, sizeof(dbuf) - 1, xmlfile_read) == OK) { char *d = dbuf; i4 i = 0; for (d = dbuf; d != (dbuf + sizeof(dbuf)); d++) { if (MEcmp(d, ERx("encoding="), sizeof(ERx("encoding=")) - 1) == 0) { d += sizeof(ERx("encoding=")); while (MEcmp (d, "\'", sizeof(char)) && MEcmp(d, "\"", sizeof(char))) MEcopy(d++, sizeof(char), &encode[i++]); encode[i++] = MIN_CHAR; encode[i] = EOS; STcat(buf, ERx("-x=")); STcat(buf, encode); break; } } } else if (stat != ENDFILE) { /* unable to read file, report error */ IIUGerr(E_XM000A_Cannot_Read_File, UG_ERR_ERROR, 1, xmlfile); PCexit(FAIL); } stat = SIclose(xmlfile_read); STcat(buf, xmlfile); #ifdef xDEBUG SIprintf ( " query send: %s \n", buf); #endif /* Execute the command. */ if( PCcmdline((LOCATION *) NULL, buf, PC_WAIT, (LOCATION *)NULL, &err_code) != OK ) { if (!debug) LOdelete(&sql_file_loc); PCexit(FAIL); } /* ** we should run the sql script ** sql dbname < new_filename */ /* save the current location */ LOcopy(&sql_file_loc, tmp_buf, &curr_loc); /* make a full location path to the location first */ LOfroms(FILENAME, sql_fname, &tmp_buff_loc); LOstfile(&tmp_buff_loc, &curr_loc); LOcopy (&curr_loc, tmp_buf, &tmp_buff_loc); LOtos (&tmp_buff_loc, &tmp_dir); #ifdef xDEBUG SIprintf ("sql file is: %s \n", tmp_dir); #endif /* No space between < and input file for VMS */ STprintf(buf, ERx( "sql -s %s %s %s %s <%s" ), database, user, password, groupid, tmp_dir); #ifdef xDEBUG SIprintf (" query send: %s \n", buf); #endif /* ** Execute the command. */ if( PCcmdline((LOCATION *) NULL, buf, PC_WAIT, (LOCATION *)NULL, &err_code) != OK ) { if (!debug) LOdelete(&sql_file_loc); PCexit(FAIL); } /* ** Delete the location */ if (!debug) LOdelete(&sql_file_loc); PCexit(OK); }
bool r_rep_do() { char *_Retrieving = ERget(F_RW0003_Retrieving_data); LOCATION loc; /* file where the report will be written */ char title[80+1]; /* the help title buffer */ char help_scr[80+1]; /* the help screen buffer */ char pr_title[80+1]; /* print report title */ char file_title[80+1]; /* file report title */ /* ** The following is for scrollable output. */ FUNC_EXTERN BCB *IIUFint_Init(); FUNC_EXTERN bool IIUFmro_MoreOutput(); bool scrl_fl; r_rep_set(&loc); if (St_ing_error != 0) return FALSE; if (!St_silent) { /* give message while waiting for retrieve */ SIprintf(_Retrieving); SIflush(stdout); } if (St_to_term) { if( Warning_count != 0 ) { r_prompt(ERget(S_RW0025_Hit_RETURN_when_done), FALSE); } /* ** If output is the terminal, then initialize forms to do ** scrollable output. */ if (r_init_frms() != OK) { return FALSE; } /* set up the bcb (buffer control block) */ STprintf (title, ERget(S_RW1400_report_title), En_report); En_bcb = IIUFint_Init((char *)NULL, title); if (En_bcb == NULL) /* IIUFint_Init failed */ { return FALSE; } /* initialize bcb */ En_bcb->nxrec = r_scroll; /* routine to handle scrolling */ En_bcb->req_begin = TRUE; En_bcb->req_complete = FALSE; En_bcb->eor_warning = FALSE; LOdelete(&En_bcb->bfloc); /* check directory is writable */ En_bcb->nrecs = 0; En_bcb->mxcol = 0; En_bcb->print_time = FALSE; if (En_bcb->rd_ahead) { MEfree(En_bcb->rd_ahead); En_bcb->rd_ahead = NULL; } /* get first screen to display */ if (!IIUFmro_MoreOutput(En_bcb, En_bcb->mx_rows-2, NULL)) { r_end_frms(); /* suppress message if undocumented flag is used */ if (!St_copyright) { SIprintf(ERget(S_RW0045_No_data_in_table)); } SIflush(stdout); return FALSE; } STcopy (ERx("rwoutput.hlp"), help_scr); STcopy (ERget(S_RW13F1_RW_output_helpfile), title); STcopy (ERget(S_RW1408_print_report_title), pr_title); STcopy (ERget(S_RW1409_file_report_title), file_title); /* If there is nothing to display, then just exit */ if (En_bcb->rows_added != 0) { /* ** If the pagelength is equal to screen display size ** (4 less lines for the report title, status line, ** solid line and menu line in the scrollable output) ** then do NOT scroll keeping the current line visible. ** This is the default behavior. Want to scroll a ** full page at a time. */ if (St_p_length == (En_lines-4)) /* ** page length is the same as window size, so ** want page scrolling */ scrl_fl = FALSE; else /* ** different page size so want to scroll, ** leaving the one line for context. */ scrl_fl = TRUE; if (!IIUFdsp_Display(En_bcb, NULL, help_scr, title, scrl_fl, pr_title, file_title, FALSE)) { return FALSE; } } IIUFdone (En_bcb); } else { while (r_getrow() == OK) { r_nxt_row(); /* process next row */ } return (r_do_end(&loc)); } return TRUE; }
i4 main (int argc, char **argv) { STATUS status=OK; PTR drvH=NULL; char **list=NULL; ATTR_ID **attrList=NULL; char **defAttr=NULL; i4 count=0, attrCount = 0, retcount; i4 i; bool badCmdLine = FALSE, rmPkg = FALSE, has_default = FALSE, has_alt = FALSE, isReadOnly = FALSE, mgrSpecified = FALSE, batch = FALSE, def_or_alt=FALSE; i4 pathType = OCFG_SYS_PATH; char altPath[OCFG_MAX_STRLEN] = "\0"; char drvMgr[OCFG_MAX_STRLEN] = "\0"; char line[MAXLINE],prompt[MAXLINE]; char driverPath[OCFG_MAX_STRLEN]; char *dirPath; char driverName[OCFG_MAX_STRLEN]; char *ii_installation; char *p = NULL; char custName[OCFG_MAX_STRLEN]; char etxt[512]; ATTR_ID driverList[6] = { { DRV_ATTR_DRIVER, "\0" }, { DRV_ATTR_DRIVER_ODBC_VER, DRV_STR_VERSION }, { DRV_ATTR_DRIVER_READONLY, DRV_STR_N }, { DRV_ATTR_DRIVER_TYPE, DRV_STR_INGRES }, { DRV_ATTR_VENDOR, DRV_STR_INGRES_CORP }, { DRV_ATTR_DONT_DLCLOSE, DRV_STR_ONE } }; int drvCount = sizeof(driverList) / sizeof(driverList[0]); ATTR_ID **drvList = (ATTR_ID **)MEreqmem( (u_i2) 0, (u_i4)drvCount, TRUE, (STATUS *) NULL); for (i = 0; i < drvCount; i++) { drvList[i] = (ATTR_ID *)MEreqmem( (u_i2) 0, (u_i4)sizeof(ATTR_ID), TRUE, (STATUS *) NULL); drvList[i]->id = driverList[i].id; drvList[i]->value = (char *)MEreqmem( (u_i2) 0, (u_i4)OCFG_MAX_STRLEN, TRUE, (STATUS *) NULL); STcopy(driverList[i].value, drvList[i]->value); } if ( argc > 7 ) badCmdLine = TRUE; /* ** Parse the command line. Reject invalid arguments. */ if ( !badCmdLine && argc > 1 ) { if (checkArgs("-h", argc, argv, NULL, NULL ) ) { display_help(); PCexit(0); } if (checkArgs("-help", argc, argv, NULL, NULL ) ) { display_help(); PCexit(0); } if ( checkArgs("-batch", argc, argv, NULL, NULL ) ) batch = TRUE; if ( checkArgs("-rmpkg", argc, argv, NULL, NULL ) ) rmPkg = TRUE; if (checkArgs("-r", argc, argv, NULL, NULL ) ) isReadOnly = TRUE; if ( checkArgs("-p", argc, argv, altPath, NULL ) ) pathType = OCFG_ALT_PATH; if ( checkArgs("-m", argc, argv, NULL, drvMgr ) ) mgrSpecified = TRUE; } /* ** Set driver manager according to user input. Default is unixODBC. */ if (mgrSpecified && !STbcompare( drvMgr, 0, MGR_STR_CAI_PT, 0, TRUE ) ) driverManager = MGR_VALUE_CAI_PT; else driverManager = MGR_VALUE_UNIX_ODBC; /* ** If none of the arguments are recognized, flag an error. */ if ( !batch && !rmPkg && !isReadOnly && pathType != OCFG_ALT_PATH && !mgrSpecified && argc > 1) badCmdLine = TRUE; if ( badCmdLine ) { display_help(); PCexit(FAIL); } if ( isReadOnly ) STcopy(DRV_STR_Y, drvList[2]->value); else STcopy(DRV_STR_N, drvList[2]->value); if ( !writeMgrFile( altPath ) ) { SIprintf("Aborting due to error writing %s/files/%s\n", SYSTEM_LOCATION_SUBDIRECTORY, MGR_STR_FILE_NAME); PCexit(FAIL); } defAttr = getDefaultInfo(); if (defAttr == NULL) { SIprintf("Aborting due to error reading %s/install/%s\n", SYSTEM_LOCATION_VARIABLE, INFO_STR_FILE_NAME); PCexit(FAIL); } /* ** Get the path of the driver library and create the path/libname string. */ NMgtAt(SYSTEM_LOCATION_VARIABLE,&dirPath); /* usually II_SYSTEM */ if (dirPath != NULL && *dirPath) STlcopy(dirPath,driverPath,sizeof(driverPath)-20-1); else { SIprintf("Error--%s is not defined\n",SYSTEM_LOCATION_VARIABLE); PCexit(FAIL); } # ifdef VMS STcat(driverPath,"["); STcat(driverPath,SYSTEM_LOCATION_SUBDIRECTORY); /* usually "ingres" */ STcat(driverPath,".library]"); if ( isReadOnly ) STcat(driverPath,defAttr[INFO_ATTR_RONLY_DRV_FNAME]); else STcat(driverPath,defAttr[INFO_ATTR_DRIVER_FILE_NAME]); # else STcat(driverPath,"/"); STcat(driverPath,SYSTEM_LOCATION_SUBDIRECTORY); /* usually "ingres" */ STcat(driverPath,"/lib/"); if ( isReadOnly ) STcat(driverPath,defAttr[INFO_ATTR_RONLY_DRV_FNAME]); else STcat(driverPath,defAttr[INFO_ATTR_DRIVER_FILE_NAME]); # endif /* ifdef VMS */ STcopy(driverPath,drvList[0]->value); /* ** Initialize the cache from the odbcinst.ini file. */ openConfig(NULL, pathType, altPath, &drvH, &status); if (status != OK) { STprintf(etxt,"Could not open from path %s.\n", pathType == OCFG_ALT_PATH ? altPath : "/usr/local/etc"); display_err(etxt,status); PCexit(FAIL); } if (rmPkg) { delConfigEntry( drvH, defAttr[INFO_ATTR_DRIVER_NAME], &status ); delConfigEntry( drvH, defAttr[INFO_ATTR_ALT_DRIVER_NAME], &status ); closeConfig(drvH, &status); PCexit(OK); } /* ** Get the driver count. */ retcount = listConfig( drvH, count, list, &status ); if (status != OK) { STprintf(etxt,"Could not list drivers.\n"); display_err(etxt,status); PCexit(FAIL); } count = retcount; if (count) { /* ** Get the list of recognized drivers. */ list = (char **)MEreqmem( (u_i2) 0, (u_i4)(count * sizeof(char *)), TRUE, (STATUS *) NULL); for (i = 0; i < count; i++) list[i] = (char *)MEreqmem( (u_i2) 0, (u_i4)OCFG_MAX_STRLEN, TRUE, (STATUS *) NULL); listConfig( drvH, count, list, &status ); if (status != OK) { STprintf(etxt,"Could not list drivers.\n"); display_err(etxt,status); PCexit(FAIL); } } for (i = 0; i < count; i++) { def_or_alt = FALSE; if (!has_default) { has_default = STbcompare( list[i], 0, defAttr[INFO_ATTR_DRIVER_NAME], 0, TRUE ) == 0 ? TRUE : FALSE; if (has_default) def_or_alt = TRUE; } if (!has_alt) { has_alt = STbcompare( list[i], 0, defAttr[INFO_ATTR_ALT_DRIVER_NAME], 0, TRUE ) == 0 ? TRUE : FALSE; if (has_alt) def_or_alt = TRUE; } if (def_or_alt) { if ( !batch ) { STprintf(prompt, "\tInstallation has pre-defined version of %s.\n\tOverwrite? (Yes/No)", list[i]); if ( line_get( prompt, "", FALSE, line ) == EOF ) { SIprintf("ODBC driver installation safely aborted\n"); PCexit(OK); } STzapblank(line,line); if ( line[0] != 'y' && line [0] != 'Y' ) { SIprintf( "%s left untouched\n", list[i] ); continue; } } /* if (!batch) */ STcopy(list[i],driverName); setConfigEntry( drvH, driverName, drvCount, drvList, &status ); if (status != OK) { STprintf(etxt,"Could not write driver entry.\n"); display_err(etxt,status); PCexit(FAIL); } } /* if (has_default || has_alt) */ else if ( !batch ) { STprintf(prompt, "\tInstallation has custom version of %s.\n\tDelete? (Yes/No)", list[i]); if ( line_get( prompt, "", FALSE, line ) == EOF ) { SIprintf("ODBC driver installation safely aborted\n"); PCexit(OK); } STzapblank(line,line); if ( line[0] != 'y' && line [0] != 'Y' ) { SIprintf( "%s left untouched\n", list[i] ); continue; } STcopy(list[i],driverName); delConfigEntry( drvH, driverName, &status ); if (status != OK) { STprintf(etxt,"Could not write driver entry.\n"); display_err(etxt,status); PCexit(FAIL); } } /* if (!batch) && !has_default */ } /* for (count... */ if (!has_default) { setConfigEntry( drvH, defAttr[INFO_ATTR_DRIVER_NAME], drvCount, drvList, &status ); if (status != OK) { STprintf(etxt,"Could not write driver entry.\n"); display_err(etxt,status); PCexit(FAIL); } } if (!has_alt) { setConfigEntry( drvH, defAttr[INFO_ATTR_ALT_DRIVER_NAME], drvCount, drvList, &status ); if (status != OK) { STprintf(etxt,"Could not write driver entry.\n"); display_err(etxt,status); PCexit(FAIL); } } closeConfig(drvH, &status); if (status != OK) { STprintf(etxt,"Could not close driver info.\n"); display_err(etxt,status); PCexit(FAIL); } if (count) { for (i = 0; i < count; i++) MEfree((PTR)list[i]); MEfree((PTR)list); } for (i = 0; i < drvCount; i++) { MEfree((PTR)drvList[i]->value); MEfree((PTR)drvList[i]); } MEfree((PTR)drvList); PCexit(OK); }
/*{ ** Name: CXget_context - Parse command arguments for NUMA args. ** ** Description: ** ** One particularly ugly requirement of NUMA clusters, is the need ** to specify the target context of certain commands that ** normally could easily determine a default context by themselves. ** ** E.g. 'lockstat' run on any node of a non-NUMA cluster "knows" ** implicitly that the current node corresponds to the current host. ** ** However, in a NUMA cluster, this happy state, no longer applies. ** If our sysadm logs onto a node which is configured into two or ** more virtual NUMA nodes, there is no way for 'lockstat', etc., ** to guess which of the virtual nodes is the target for the Ingres ** tool. ** ** We try to make a virtue of this neccesity by centralizing the ** parsing needed for these commands and in passing pick up a ** generalized way of setting processor affinity for Ingres tools. ** ** Two types of arguments are checked here: ** '-rad' is a RAD spec, in which the host machine is implicitly ** the local machine. ** ** '-node' may refer to either a local RAD by its node name or ** node alias, or to a node anywhere in thr cluster if CX_NSC_NODE_GLOBAL ** is set. ** ** Both arguments can be in the form -arg=value, or -arg value. ** ** The users input is checked against the following rules: ** ** R1: If NOT running clusters, '-node' parameter will always ** cause an error. ** ** R2: Only one of either "-node" or "-rad" is allowed. ** ** R3: If "-rad" is present, value must correspond to a valid RAD. ** ** R4: If "-node" is present, it must be a valid node, or node alias. ** ** R4a: If CX_NSC_NODE_GLOBAL is not set, node must match local host ** name or be hosted (virtual nodes only) by local host. ** ** R5: If not otherwise specified, and running NUMA clusters, ** RAD value is taken from environment variable II_DEFAULT_RAD. ** ** R6: If running NUMA clusters, and CX_NSC_RAD_OPTIONAL is not ** set, an error will be reported if context is not set by a ** valid -rad, or -node, or II_DEFAULT_RAD value. ** ** R7: If rules R2-R6 are not violated, and CX_NSC_CONSUME is set, ** and an matching parameter or parameter pair was provided, ** the parameters are removed from the argument vector, and ** the argument count is adjusted. ** ** R8: If CX_NSC_SET_CONTEXT is set, and not running NUMA clusters, ** and a valid RAD value was provided with an explicit '-rad' ** argument, CXnuma_bind_to_rad is called to set process affinity ** to the specified RAD. ** ** R9: If CX_NSC_SET_CONTEXT is set, running NUMA clusters, or ** if a valid '-node' parameter was supplied, CXset_cluster ** is called for the specified node. ** ** R10: If CX_NSC_REPORT_ERRS is set, and an error occurred, ** message is sent to stdout. ** ** If all appropriate rules are met, then OK is returned. ** Caller should be set up to catch and complain about any ** extra invalid parameters. ** ** If outbuf is not NULL, node name if copied out if status = ** OK, else error message text is copies out. In both cases ** only a max of outlen chars are returned, including an EOS. ** ** Inputs: ** ** pargc - Address of integer holding # of arg strings. ** ** argv - Array of string pointers to argument values. ** ** flags - Flag bits OR'ed together. Valid flags are: ** ** CX_NSC_REPORT_ERRS - Emit any error message to stdout. ** ** CX_NSC_NODE_GLOBAL - Allow node argument to refer to ** Nodes outside the current host. ** ** CX_NSC_CONSUME - Eat any -rad/-node args & values if OK. ** ** CX_NSC_IGNORE_NODE - Ignore '-node' params in scan. ** ** CX_NSC_SET_CONTEXT - Set CX context based on good params. ** ** CX_NSC_RAD_OPTIONAL - Don't fail if NUMA & RAD not set. ** If running NUMA clusters, only ** set this in combination with ** CX_NSC_SET_CONTEXT if you are sure ** that shared memory won't be accessed, ** and all you need is to retreive the ** context later (e.g. iirun). ** ** outbuf - buffer to receive nodename, or error message text. ** ** outlen - limit to # bytes copied to outbuf. ** ** Outputs: ** ** *pargc - decremented by if argument(s) are consumed. ** ** argv - Adjused to remove consumed argument(s). ** ** outbuf - Holds '\0' terminated string with either nodename ** or error message depending on status. ** ** Returns: ** OK - All is well. ** E_CL2C40_CX_E_BAD_PARAMETER - Bad params values, ** or bad combination ** of parameters. ** E_CL2C43_CX_E_REMOTE_NODE - Node specified was not on ** current host machine. ** E_CL2C2F_CX_E_BADRAD - Rad value out of range. ** E_CL2C42_CX_E_NOT_CONFIGURED - Node or RAD not configured ** as part of a cluster. ** E_CL2C41_CX_E_MUST_SET_RAD - Running NUMA clusters, ** and no argument, or ** environment variable, set ** the RAD context. ** ** Exceptions: ** none ** ** Side Effects: ** See CXnuma_bind_to_rad(), if called with a '-rad' ** argument outside a NUMA cluster, else see ** CXset_context(). ** ** Notes: ** Typically in a NUMA cluster configuration, the target RAD ** information is needed very early in the applications logic, ** since it cannot implicitly determine the virtual node it ** is intended to be running on. ** ** History: ** 18-sep-2002 (devjo01) ** Created. */ STATUS CXget_context( i4 *pargc, char *argv[], i4 flags, char *outbuf, i4 outlen ) { STATUS status = OK; CX_NODE_INFO *pni = NULL; bool numa; i4 arg, radarg = 0, nodearg = 0, badarg = 0; i4 target_rad; i4 argstokill = 1; char *pvalue = NULL, *argp, *host; char lclbuf[256]; i4 erargc; ER_ARGUMENT erargs[2]; host = CXhost_name(); do { /* Scan passed arguments for "-rad" & "-node" */ for ( arg = 1; arg < *pargc; arg++ ) { argp = argv[arg]; if ( '-' != *argp ) continue; if ( 0 == STxcompare(argp, 4, ERx( "-rad" ), 4, FALSE, FALSE) ) { if ( radarg || nodearg ) { /* R2 */ badarg = arg; break; } radarg = arg; if ( *(argp + 4) == '=' ) { pvalue = argp + 5; } else if ( '\0' != *(argp + 4) || (arg >= (*pargc - 1)) ) { /* R3 */ badarg = arg; break; } else { /* Next argument must be a valid RAD ID */ pvalue = argv[++arg]; argstokill = 2; } if ( '\0' == *pvalue ) { /* R3 */ badarg = radarg; break; } if ( OK != CVan( pvalue, &target_rad ) || target_rad <= 0 ) { /* R3 */ badarg = arg; break; } } else if ( !(CX_NSC_IGNORE_NODE & flags) && 0 == STxcompare(argp, 5, ERx( "-node" ), 5, FALSE, FALSE ) ) { if ( radarg || nodearg ) { /* R2 */ badarg = arg; break; } nodearg = arg; if ( *(argp + 5) == '=' ) { pvalue = argp + 6; } else if ( ('\0' != *(argp + 5)) || (arg >= (*pargc - 1)) ) { /* R4 */ badarg = arg; break; } else { /* Next argument must be a node ID */ pvalue = argv[++arg]; argstokill = 2; } if ( '\0' == *pvalue ) { /* R4 */ badarg = nodearg; break; } } } /* end for */ /* If bad syntax seen, scram & fail */ if ( badarg ) { status = E_CL2C40_CX_E_BAD_PARAMETER; erargc = 1; erargs[0].er_size = 0; erargs[0].er_value = (PTR)argv[badarg]; break; } numa = CXnuma_cluster_configured(); /* If no explicit parameters seen, try default */ if ( numa && !pvalue && !(flags & CX_NSC_RAD_OPTIONAL) ) { /* R5 */ argp = ERx( "II_DEFAULT_RAD" ); pvalue = getenv( argp ); if ( pvalue && ( ( '\0' == *pvalue ) || OK != CVan(pvalue, &target_rad) ) ) pvalue = NULL; } /* Got a value either from command line or environment */ if ( pvalue ) { if ( nodearg ) { if ( CXcluster_configured() ) { pni = CXnode_info(pvalue, 0); if ( pni ) { /* If can't be global, make sure its local */ if ( !(flags & CX_NSC_NODE_GLOBAL) && !( ( 0 == STxcompare( host, 0, pni->cx_node_name, pni->cx_node_name_l, TRUE, FALSE ) ) || ( ( 0 != pni->cx_host_name_l ) && ( 0 == STxcompare( host, 0, pni->cx_host_name, pni->cx_host_name_l, TRUE, FALSE ) ) ) ) ) { /* Node must be local and was not. (R4a) */ status = E_CL2C43_CX_E_REMOTE_NODE; erargc = 2; erargs[0].er_size = 0; erargs[0].er_value = (PTR)argv[0]; erargs[1].er_size = pni->cx_host_name_l; erargs[1].er_value = (PTR)(pni->cx_host_name); break; } } } } else if ( numa ) { pni = CXnode_info(host, target_rad); } else if ( target_rad > CXnuma_rad_count() ) { if ( !(flags & CX_NSC_RAD_OPTIONAL) ) { /* R3 */ status = E_CL2C2F_CX_E_BADRAD; erargc = 0; break; } target_rad = 0; } if ( ( numa || nodearg ) && ( NULL == pni ) ) { /* Requested node/rad not configured */ /* R3, R4 */ if ( !argp ) argp = argv[radarg+nodearg]; status = E_CL2C42_CX_E_NOT_CONFIGURED; erargc = 1; erargs[0].er_size = 0; erargs[0].er_value = (PTR)argp; break; } } else { if ( numa && !(flags & CX_NSC_RAD_OPTIONAL) ) { /* If required argument missing, scram & fail */ status = E_CL2C41_CX_E_MUST_SET_RAD; erargc = 1; erargs[0].er_size = 0; erargs[0].er_value = (PTR)argv[0]; break; } } if ( (flags & CX_NSC_CONSUME) && (radarg || nodearg) ) { for ( arg = radarg + nodearg + argstokill; arg < *pargc; arg++ ) { argv[arg-argstokill] = argv[arg]; } *pargc = *pargc - argstokill; argv[*pargc] = NULL; } } while (0); if ( OK == status ) { lclbuf[CX_MAX_NODE_NAME_LEN] = '\0'; if ( NULL == pni ) { (void)STlcopy(host, lclbuf, CX_MAX_NODE_NAME_LEN); } else { (void)STlcopy(pni->cx_node_name, lclbuf, CX_MAX_NODE_NAME_LEN); } CVlower( lclbuf ); if ( flags & CX_NSC_SET_CONTEXT ) { if ( !numa && 0 != target_rad ) { (void)CXnuma_bind_to_rad( target_rad ); } (void)CXset_context(lclbuf, 0); } } if ( OK != status ) { cx_fmt_msg( status, lclbuf, sizeof(lclbuf), erargc, erargs ); if ( flags & CX_NSC_REPORT_ERRS ) (void)SIprintf( "\n%s\n", lclbuf ); } if ( outbuf ) { STlcopy( lclbuf, outbuf, outlen - 1 ); *(outbuf + outlen - 1) = '\0'; } return status; } /*CXget_context*/
/* PROGRAM = iijobdef ** NEEDLIBS = UTILLIB MALLOCLIB COMPATLIB GLLIB ** UNDEFS = II_copyright ** DEST = utility */ # endif /* VMS */ main( i4 argc, char **argv) { # ifdef VMS char *host; i4 i; PM_SCAN_REC state; STATUS status; char *lnm_table_name; struct dsc$descriptor lnm_table; char *regexp; char *name, *value; PM_CONTEXT *config; struct dsc$descriptor lnm_name; ILE3 item_list[ 2 ]; long access_mode = PSL$C_SUPER; bool failed_once = FALSE; /* lib$set_logical works? */ const match_1 = LIB$_NOCLI; /* Process has no CLI. */ const match_2 = LIB$_UNECLIERR; /* Unexpected CLI error * (non-standard CLI?). */ const match_3 = SS$_NORMAL; /* Normal return. */ const match_4 = SS$_SUPERSEDE; /* Replaced old value. */ const match_5 = SS$_NOLOGNAM; /* Not currently defined. */ bool delete_logs = FALSE; /* What are we doing? */ char *act_str; /* String for action. */ char *err_str; /* String for error exit. */ char *log_str; /* String to log action. */ char tmp_buf[BIG_ENOUGH]; MEadvise( ME_INGRES_ALLOC ); if( argc != 1 ) delete_logs = TRUE; (void) PMmInit( &config ); if( PMmLoad( config, NULL, PMerror ) != OK ) PCexit( FAIL ); host = PMmHost( config ); PMmSetDefault( config, HOST_PM_IDX, host ); /* get logical table name */ STprintf (tmp_buf , ERx( "%s.$.lnm.table.id" ), SystemCfgPrefix); if( PMmGet( config, tmp_buf , &lnm_table_name ) != OK ) { F_ERROR( "%s not found.", PMmExpandRequest( config, tmp_buf ) ); } /* set logical name table */ lnm_table_name = ERx( "LNM$JOB" ); /* compose string descriptor for logical table name */ lnm_table.dsc$w_length = STlength( lnm_table_name ); lnm_table.dsc$a_pointer = lnm_table_name; lnm_table.dsc$b_class = DSC$K_CLASS_S; lnm_table.dsc$b_dtype = DSC$K_DTYPE_T; if ( delete_logs ) { act_str = ERx( "\nDeleting %s logicals...\n\n(%s)\n\n" ); err_str = ERx( "Unable to deassign %s.\n\n" ); log_str = ERx( "" ); } else { act_str = ERx( "\nDeleting %s logicals...\n\n(%s)\n\n" ); err_str = ERx( "Unable to set %s to \"%s\".\n\n" ); log_str = ERx( "\"%s\" = \"%s\"\n" ); } F_PRINT2( act_str, SystemDBMSName, lnm_table_name ); /* scan and set node-specific logicals */ regexp = PMmExpToRegExp( config, ERx( "ii.$.lnm.%") ); for( status = PMmScan( config, regexp, &state, NULL, &name, &value ); status == OK; status = PMmScan( config, NULL, &state, NULL, &name, &value ) ) { name = PMmGetElem( config, 3, name ); lnm_name.dsc$w_length = STlength( name ); lnm_name.dsc$a_pointer = name; lnm_name.dsc$b_class = DSC$K_CLASS_S; lnm_name.dsc$b_dtype = DSC$K_DTYPE_T; item_list[ 0 ].ile3$w_length = STlength( value ); item_list[ 0 ].ile3$w_code = LNM$_STRING; item_list[ 0 ].ile3$ps_bufaddr = value; item_list[ 0 ].ile3$ps_retlen_addr = NULL; item_list[ 1 ].ile3$w_length = 0; item_list[ 1 ].ile3$w_code = 0; if ( !failed_once ) { if ( delete_logs ) status = lib$delete_logical( &lnm_name, &lnm_table ); else status = lib$set_logical( &lnm_name, NULL, &lnm_table, NULL, item_list ); if ( lib$match_cond( &status, &match_1, &match_2 )) failed_once = TRUE; } if ( failed_once ) { if ( delete_logs ) status = sys$dellnm( &lnm_table, &lnm_name, &access_mode ); else status = sys$crelnm( NULL, &lnm_table, &lnm_name, &access_mode, item_list ); } if ( !lib$match_cond( &status, &match_3, &match_4, &match_5 )) { SIfprintf( stderr, err_str, name, value ); PCexit( FAIL ); } SIprintf( log_str, name, value ); } PCexit( OK ); # else /* VMS */ SIprintf( "\nThis doesn't do much.\n\n" ); # endif /* VMS */ }