STATUS SIeqinit() { # if defined (UNIX) || defined (NT_GENERIC) /* Just verify the environment is normal */ if (!SIisopen(stdin)) return(INCHAN_ERR); if (!SIisopen(stdout)) return(OUTCHAN_ERR); if (!SIisopen(stderr)) return(ERRCHAN_ERR); return(OK); # endif # ifdef VMS LOCATION loc; FILE *fp; char buf[MAX_LOC +1]; /* ** If stdin cannot be opened, attempt to open stdout, stderr for ** possible error messages. */ STATUS in_status, out_status, err_status; if (SIisopen(stdin)) return (OK); STcopy("SYS$INPUT", buf); LOfroms(PATH & FILENAME, buf, &loc); in_status = SIopen(&loc, "r", &fp); STcopy("SYS$OUTPUT", buf); LOfroms(PATH & FILENAME, buf, &loc); out_status = SIopen(&loc, "w", &fp); STcopy("SYS$ERROR", buf); LOfroms(PATH & FILENAME, buf, &loc); err_status = SIopen(&loc, "w", &fp); if (in_status != OK){ if (in_status == iicl__siopen) return(INCHAN_ERR); else return (in_status); } if (out_status != OK){ if (out_status == iicl__siopen) return(OUTCHAN_ERR); else return (out_status); } if (err_status == iicl__siopen) return(ERRCHAN_ERR); else return (err_status); /* OK or a real status */ # endif }
/* ** Function: ** ** rfapi_writeSecHeader ** ** Description: ** ** Write given section header to open response file. ** ** Inputs: ** ** II_RFAPI_HANDLE *handle - Pointer to intialized respone file handle ** II_RFAPI_STRING header - Section header to be written ** FILE *fd - Pointer to an open response file ** ** Outputs: ** ** None ** ** Returns: ** ** II_RFAPI_STATUS: ** II_RF_ST_OK on success ** ** on failure: ** II_RF_ST_NULL_ARG ** II_RF_ST_FAIL */ II_RFAPI_STATUS rfapi_writeSecHeader( II_RFAPI_HANDLE *handle, II_RFAPI_STRING header, FILE *fd ) { /* check handle is valid */ if ( (*handle) == NULL ) return( II_RF_ST_NULL_ARG ); else if ( ! (*handle)->flags & II_RF_OP_INITIALIZED ) return( II_RF_ST_FAIL ); /* check for valid header */ if ( header == NULL || *header == '\0' ) return( II_RF_ST_NULL_ARG ); /* check response file is open */ if ( SIisopen( fd ) != TRUE ) return( II_RF_ST_FAIL ); /* write the header */ SIfprintf( fd, RFAPI_SECTION_HEADER, header ); return( II_RF_ST_OK ) ; }
/* ** Function: ** ** rfapi_writeRFHeader ** ** Description: ** ** Write response file header to open file descriptor ** ** Inputs: ** ** II_RFAPI_HANDLE *handle - Pointer to intialized respone file handle ** FILE *fd - Pointer to an open response file ** ** Outputs: ** ** None ** ** Returns: ** ** II_RFAPI_STATUS: ** II_RF_ST_OK on success ** ** on failure: ** II_RF_ST_NULL_ARG ** II_RF_ST_FAIL ** ** History: ** 02-Jul-2009 (hanje04) ** Bug 122227 ** SD 137277 ** Increase size of datebuf to prevent buffer overrun in ** when calling rfapi_GetDateTime() :-( ** 12-Jul-2010 (hanje04) ** BUG 124081 ** Add APPEND_HEADER if we're appending */ II_RFAPI_STATUS rfapi_writeRFHeader( II_RFAPI_HANDLE *handle, FILE *fd ) { char date_buf[50]; /* buffer date and time string string */ /* check handle is valid */ if ( (*handle) == NULL ) return( II_RF_ST_NULL_ARG ); else if ( ! (*handle)->flags & II_RF_OP_INITIALIZED ) return( II_RF_ST_FAIL ); if ( SIisopen( fd ) != TRUE ) return( II_RF_ST_FAIL ); /* get time info */ rfapi_getDateTime( date_buf ); /* write out header */ if ( (*handle)->flags & II_RF_OP_APPEND ) SIfprintf( fd, RFAPI_RESPONSE_FILE_APPEND_HEADER, date_buf ); else SIfprintf( fd, RFAPI_RESPONSE_FILE_HEADER, date_buf ); return( II_RF_ST_OK ); }
/* ** Function: ** ** rfapi_doWrite ** ** Description: ** ** Write given parameter list to open response file ** ** Inputs: ** ** II_RFAPI_HANDLE *handle - Pointer to intialized respone file handle ** RFAPI_VAR **var_list - List of response file variable to write ** FILE *fd - Pointer to an open response file ** ** Outputs: ** ** None ** ** Returns: ** ** II_RFAPI_STATUS: ** II_RF_ST_OK on success ** ** on failure: ** II_RF_ST_IO_ERROR ** ... ** II_RF_ST_FAIL */ II_RFAPI_STATUS rfapi_doWrite( II_RFAPI_HANDLE *handle, RFAPI_VAR **var_list, FILE *fd ) { RFAPI_PARAMS *params_ptr; i4 i=0; if ( SIisopen( fd ) != TRUE ) return( II_RF_ST_IO_ERROR ); /* ** scroll through the list of parameters in order and write out ** the names and values */ while ( var_list[i] != NULL ) { /* only print parameters valid for specified output format */ if ( (*handle)->output_format & var_list[i]->valid_on ) { if ( params_ptr = rfapi_findParam( handle, var_list[i]->pname ) ) SIfprintf( fd, "%s=%s\n", var_list[i]->vname, (params_ptr)->param.value ); else if ( (*handle)->flags & II_RF_OP_WRITE_DEFAULTS && (*handle)->output_format & var_list[i]->default_on ) SIfprintf( fd, "%s=%s\n", var_list[i]->vname, (*handle)->output_format & II_RF_DP_LINUX ? var_list[i]->default_lnx : var_list[i]->default_win ); } i++; } return( II_RF_ST_OK ); }