static SERVER_ENTRY * AddServer( char *name, LPVOID lpMapping, HANDLE hMapping, HANDLE levent, HANDLE revent ) { SERVER_ENTRY *server; server = (SERVER_ENTRY *) MEreqmem(0, sizeof( SERVER_ENTRY ), TRUE, NULL ); server->name = ( char * ) MEreqmem(0, strlen( name ) + 1, TRUE, NULL ); strcpy( server->name, name ); server->lpMapping = lpMapping; server->hMapping = hMapping; server->RequestingEvent = revent; server->ListeningEvent = levent; server->nConnections = 0; /* add to server list */ server->next = server_list; server_list = server; nServers++; return server; }
/* Name: adu_map_init_charmap - Initializes a charmap array. ** Description: ** This routine, initializes a charmap array which holds information to ** convert from local characterset to unicode. ** ** Input: ** Base pointer to charmap table. ** Default2D pointer to 2D default array. ** Default pointer to default array. ** Output: ** ** None. ** ** History: ** 23-Jan-2004 (gupsh01) ** Added. */ static DB_STATUS adu_map_init_charmap( u_i4 ****Base, u_i4 ***Default2D, u_i4 **Default) { i4 i = 0; if ((Base == NULL) || (Default2D == NULL) || (Default == NULL)) return (E_DB_ERROR); /* AN ERROR CONDITION */ *Base = (u_i4 ***)MEreqmem(0, sizeof(u_i4 **) * 256, FALSE, NULL); /* array of unicode values (default for conversion) */ *Default2D = (u_i4 **)MEreqmem(0, sizeof(u_i4 *) * 256, FALSE, NULL); /* saves if ptr = NULL return DEFAULT test. */ *Default = (u_i4 *)MEreqmem(0, sizeof(u_i4) * 256, FALSE, NULL); for (i=0;i<256;i++) { (*Default)[i] = 0xFFFD; (*Default2D)[i] = *Default; (*Base)[i] = *Default2D; } return (E_DB_OK); }
/* Name: adu_map_add_charmap - adds the charmap values to character mapping table. ** Description: ** This routines, inserts a unicode mapping value ** to the character map table. ** ** Input: ** Base pointer to validity table. ** Default2D pointer to 2D default array. ** Default pointer to default array. ** bval byte value to add. ** unicode unicode value to add. ** uhsur higher surrogate value for unicode if any. ** ** Output: ** None. ** ** History: ** 23-Jan-2004 (gupsh01) ** Added. */ static void adu_map_add_charmap( u_i4 ***Base, u_i4 **Default2D, u_i4 *Default, u_i4 bval, u_i2 unicode, u_i2 uhsur) { i4 i = 0; u_i2 inbyte[3]; inbyte[0] = (bval & 0xFFFFFF) >> 16; inbyte[1] = (bval & 0xFFFF) >> 8; inbyte[2] = (bval & 0xFF); if (Base[inbyte[0]] == Default2D) { Base[inbyte[0]] = (u_i4 **)MEreqmem(0, sizeof(u_i4 *) * 256, FALSE, NULL); for (i=0;i<256;i++) Base[inbyte[0]][i] = Default; } if (Base[inbyte[0]][inbyte[1]] == Default) { Base[inbyte[0]][inbyte[1]] = (u_i4 *)MEreqmem(0, sizeof(u_i4) * 256, FALSE, NULL); for (i=0;i<256;i++) Base[inbyte[0]][inbyte[1]][i] = 0xFFFD; } Base[inbyte[0]][inbyte[1]][inbyte[2]] = unicode; }
static void yyadd_path( char *idirectory ) { STATUS sts; IPATH *ipath_cur; IPATH *ipath_new; char *buf; /* Locate the last directory in the list of include paths */ for (ipath_cur = &ihead; ipath_cur->next != NULL; ipath_cur = ipath_cur->next) continue; /* Allocate memory for the new path structure */ ipath_new = (IPATH *)MEreqmem(0, sizeof(IPATH), FALSE, &sts); if (ipath_new == NULL || sts != OK) { SIfprintf( stderr, E_YAPP002 ); yydump(); } /* ** Anchor the new structure and fill it in */ ipath_cur->next = ipath_new; ipath_new->pathloc = (LOCATION *)MEreqmem(0, sizeof(LOCATION), FALSE, &sts); ipath_new->next = NULL; if (ipath_new->pathloc == NULL || sts != OK ) { SIfprintf( stderr, E_YAPP003 ); yydump( ); } buf = (char *)MEreqmem(0, MAX_LOC + 1, FALSE, &sts); if (buf == NULL || sts != OK ) { SIfprintf( stderr, E_YAPP004 ); yydump(); } STcopy(idirectory, buf); if (LOfroms(PATH, buf, ipath_new->pathloc) != OK) { SIfprintf( stderr, E_YAPP005 ); yydump(); } }
/* ** DO_IF_NAME - Allocate an FE_DEL structure for the current word and call ** do_expand_name() to process it. ** ** Parameters: ** fd file descriptor of file to read. ** buf_ptr buffer to hold text string from file line. ** maxchar maximum number of characters to return. ** ** Returns: ** Number of characters read. This may be zero for empty lines. ** The terminating LF or FF is NEVER returned. ** -1 indicates EOF or an error. ** ** History: ** 12-jan-1993 (rdrane) ** Created. */ static VOID do_if_name(char *wrd_ptr,OOID del_obj_type) { FE_DEL *fd; FE_DEL *prev_fd; /* ** Allocate a new FE_DEL for this FE object name */ fd = (FE_DEL *)MEreqmem(0,sizeof(FE_DEL),TRUE,NULL); /* ** If Ptr_fd_top is NULL, then there were no FE object ** names on the command line, so start the FE_DEL chain ** here. Otherwise, chain on to whatever currently exists. */ if (Ptr_fd_top == (FE_DEL *)NULL) { Ptr_fd_top = fd; prev_fd = (FE_DEL *)NULL; } else { Cact_fd->fd_below = fd; prev_fd = Cact_fd; } /* ** Make this the new current FE_DEL */ Cact_fd = fd; Cact_fd->fd_name_info = (FE_RSLV_NAME *)MEreqmem(0, sizeof(FE_RSLV_NAME),TRUE,NULL); Cact_fd->fd_name_info->name = STalloc(wrd_ptr); Cact_fd->fd_below = (FE_DEL *)NULL; Cact_fd = do_expand_name(Cact_fd,&prev_fd,del_obj_type); /* ** Returns ptr to current end of FE_DEL chain which ** may be NULL if 1st and no match. If no match, the ** FE_DEL and its name will have been de-allocated, ** and prev_fd and and Ptr_fd_top will be altered as ** required. */ return; }
/* --------------------------------------------------------------------------- ** SAXImportHandlers: Constructors and Destructor ** --------------------------------------------------------------------------- */ SAXImportHandlers::SAXImportHandlers( const char* const encodingName, const XMLFormatter::UnRepFlags unRepFlags, char *currentTagName) : fFormatter ( encodingName, 0 , this , XMLFormatter::NoEscapes , unRepFlags ) { /* ** Go ahead and output an XML Decl with our known encoding. This ** is not the best answer, but its the best we can do until we ** have SAX2 support. */ /* initialize the tablist and the indlist and xmlData */ tablist = NULL; indlist = NULL; xmlData = NULL; isMetaInfoSet = FALSE; dataval = (char *)MEreqmem(0, DB_MAXSTRING + 32, TRUE, NULL); if (currentTagName) STcopy(currentTagName, currentTag); }
static void define(char *symbol, char *value, bool hist) { SYMBOL **symptr_anchor; SYMBOL *symptr_new; STATUS sts; char *buf; /* Locate the last defined symbol in the list */ for (symptr_anchor = &symtab.head; *symptr_anchor != NULL; symptr_anchor = &((*symptr_anchor)->next) ) continue; /* Allocate memory for the new symbol structure */ symptr_new = (SYMBOL *)MEreqmem(0, sizeof(SYMBOL), FALSE, &sts); if (symptr_new == NULL || sts != OK) { SIfprintf( stderr, E_YAPP008 ); yydump(); } /* ** Anchor the new symbol structure and fill it in */ *symptr_anchor = symptr_new; symptr_new->name = STalloc( symbol ); symptr_new->value = STalloc( value ); symptr_new->hist_flag = hist; symptr_new->next = NULL; symtab.nsym++; }
/*{ ** Name: IIAG4iosInqObjectStack - Inquire info about Known Object stack. ** ** Description: ** This returns the current value of the static's used here for the ** list of objects known by 3GL. This function is used so that the caller ** knows how many objects need to be freed (using IIAG4fosFreeObjectStack). ** This is necessary, as 3GL can be re-entered recursively in ABF, as ** 3GL can call back into 4GL (using callproc), which can call another ** 3GL procedure. We'll always want to free objects that were made known ** on the last call to 3GL, once this procedure returns. ** ** This also doubles as an initial stack allocator - if called when ** current_alloc is zero, an initial known object stack will get ** allocated. ** ** Inputs: ** NONE. ** ** Outputs: ** current_sp {nat *} current stackpointer. ** current_alloc {nat *} current allocated stacksize. ** ** Returns: ** OK, unless initialize fails; then FAIL. ** ** History: ** 15-dec-92 (davel) ** Initial version. */ STATUS IIAG4iosInqObjectStack(i4 *current_sp, i4 *current_alloc) { /* see if we should initialize stack */ if (alloc_stacksize == 0) { u_i4 size = G4_INITIAL_STACKSIZE * sizeof(PTR); objectstack = (PTR *)MEreqmem(0, size, TRUE, NULL); if (objectstack == (PTR *)NULL) { return FAIL; } else { alloc_stacksize = G4_INITIAL_STACKSIZE; } } if (current_sp != NULL) { *current_sp = stackpointer; } if (current_alloc != NULL) { *current_alloc = alloc_stacksize; } return OK; }
static VOID i_EX_t_setcontext( EX_CONTEXT *context ) { EX_CONTEXT **ex_psptr; STATUS status; if ( EXcontextkey == 0 ) { ME_tls_createkey( &EXcontextkey, &status ); ME_tls_set( EXcontextkey, NULL, &status ); if ( EXcontextkey == 0 ) { /* not linked with threaded libraries */ EXcontextkey = -1; } } if ( EXcontextkey == -1 ) { /* not linked with threaded libraries */ ex_sptr = context; } else { ex_psptr = (EX_CONTEXT **) MEreqmem( 0, sizeof(EX_CONTEXT **), TRUE, NULL ); ME_tls_set( EXcontextkey, (PTR)ex_psptr, &status ); *ex_psptr = context; } return; }
GCD_CIB * gcd_new_cib( u_i2 count ) { GCD_CIB *cib = NULL; u_i2 len = sizeof( GCD_CIB ) + (sizeof(CONN_PARM) * (count - 1)); if ( count < ARR_SIZE( GCD_global.cib_free ) ) if (! (cib = (GCD_CIB *)QUremove(GCD_global.cib_free[count].q_next))) if ( (cib = (GCD_CIB *)MEreqmem( 0, len, FALSE, NULL )) ) cib->id = GCD_global.cib_total++; if ( ! cib ) gcu_erlog(0, GCD_global.language, E_GC4808_NO_MEMORY, NULL, 0, NULL); else { u_i4 id = cib->id; char buff[16]; MEfill( len, 0, (PTR)cib ); cib->id = id; cib->parm_max = count; QUinit( &cib->caps ); MOulongout( 0, (u_i8)cib->id, sizeof( buff ), buff ); MOattach( MO_INSTANCE_VAR, GCD_MIB_DBMS, buff, (PTR)cib ); GCD_global.cib_active++; if ( GCD_global.gcd_trace_level >= 6 ) TRdisplay( "%4d GCD new CIB (%d)\n", -1, cib->id ); } return( cib ); }
static char * ns_login( API_PARSE *parse, i4 buflen, char *buffer ) { char *user, *pwd, *value; i4 usrlen, pwdlen, len; STATUS status; if ( parse->opcode == API_KW_ADD ) { /* ** Password required and must be sent encrypted. */ user = ns_resolve_param( parse, API_FIELD_PARM, FALSE ); usrlen = STlength( user ); pwd = ns_resolve_param( parse, API_FIELD_PARM + 1, FALSE ); pwdlen = (STlength( pwd ) + 8) * 2; /* estimate encrypted length */ } else { /* ** Use GCN wild card format for password. */ user = ns_resolve_param( parse, API_FIELD_PARM, TRUE ); usrlen = STlength( user ); pwd = empty; pwdlen = 0; } /* Allow room for EOS and separating ',' */ len = usrlen + pwdlen + 2; /* ** Allocate storage for the final value ** and build it from the parameters ** retrieved above. */ value = (len <= buflen) ? buffer : (char *)MEreqmem( 0, len, FALSE, &status ); if ( ! value ) { IIAPI_TRACE( IIAPI_TR_FATAL ) ( "ns_login: can't allocate value buffer\n" ); return( NULL ); } if ( parse->opcode != API_KW_ADD ) STpolycat( 3, user, ",", pwd, value ); else { /* ** Encrypt password directly into formatted output. */ STpolycat( 2, user, ",", value ); gcu_encode( user, pwd, &value[ usrlen + 1 ] ); } return( value ); }
/* Memory allocator functions */ static PTR GCC_alloc(int size) { PTR ptr; STATUS status; ptr = MEreqmem( 0, size , TRUE, &status ) ; return(ptr); }
II_EXTERN IIAPI_THREAD * IIapi_thread( II_VOID ) { IIAPI_THREAD *thread; STATUS status; i4 tid = PCtid(); IIAPI_TRACE( IIAPI_TR_VERBOSE ) ( "IIapi_thread(%d): retrieving local storage\n", tid ); status = MEtls_get( &IIapi_static->api_thread, (PTR *)&thread ); if ( status != OK ) { IIAPI_TRACE( IIAPI_TR_ERROR ) ( "IIapi_thread: error retrieving local storage: 0x%x\n", status ); return( NULL ); } if ( ! thread ) { thread = (IIAPI_THREAD *)MEreqmem( 0, sizeof( IIAPI_THREAD ), TRUE, &status ); if ( ! thread ) { IIAPI_TRACE( IIAPI_TR_FATAL ) ( "IIapi_thread: error allocating local storage 0x%x\n", status ); } else { IIAPI_TRACE( IIAPI_TR_INFO ) ("IIapi_thread(%d): allocated local storage %p\n",tid,thread); QUinit( &thread->api_op_q ); status = MEtls_set( &IIapi_static->api_thread, (PTR)thread ); if ( status != OK ) { IIAPI_TRACE( IIAPI_TR_ERROR ) ( "IIapi_thread: error saving local storage 0x%x\n", status ); MEfree( (PTR)thread ); thread = NULL; } } } IIAPI_TRACE( IIAPI_TR_DETAIL ) ( "IIapi_thread(%d): retrieved local storage %p\n", tid, thread ); return( thread ); }
RETCODE SQL_API SQLSetConnectOption( SQLHDBC hdbc, UWORD fOption, SQLUINTEGER vParam) { RETCODE rc, traceRet = 1; pDBC pdbc = (pDBC)hdbc; IISETCONNECTOPTION_PARAM *iiSetConnectOptionParam; ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLSetConnectOption(hdbc, fOption, vParam), traceRet); if (!hdbc) { ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE)); return SQL_INVALID_HANDLE; } /* ** If the driver isn't loaded yet, set a placeholder to do this ** later. */ if ( !IISetConnectOption ) { iiSetConnectOptionParam = (IISETCONNECTOPTION_PARAM *)MEreqmem(0, sizeof(IISETCONNECTOPTION_PARAM), TRUE, NULL); QUinsert((QUEUE *)iiSetConnectOptionParam, &pdbc->setConnectOption_q); iiSetConnectOptionParam->ConnectionHandle = hdbc; iiSetConnectOptionParam->Option = fOption; iiSetConnectOptionParam->Value = vParam; pdbc->setConnectOption_count++; ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_SUCCESS)); return SQL_SUCCESS; } else { resetErrorBuff(pdbc, SQL_HANDLE_DBC); rc = IISetConnectOption( pdbc->hdr.driverHandle, fOption, vParam); applyLock(SQL_HANDLE_DBC, pdbc); if (rc != SQL_SUCCESS) { pdbc->hdr.driverError = TRUE; pdbc->errHdr.rc = rc; } else if (fOption == SQL_ATTR_AUTOCOMMIT) pdbc->autocommit = TRUE; releaseLock(SQL_HANDLE_DBC, pdbc); } ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc)); return rc; }
/*{ ** Name: IIME_adAddTag - Add a node of allocated memory to a tag. ** ** Description: ** This routine is called when a new block of dynamic memory is being ** allocated under a tag. It is called by MEdoAlloc. The job ** of this routine is to store the allocated memory so that it ** will be freed with the other blocks allocated under this tag when ** MEtfree is called. ** ** It works by checking the hash table for an METAGNODE for this tag. ** If none is found, a new METAGNODE is allocated for this tag. ** Then the block of memory is put on the QUEUE for the METAGNODE. ** ** Inputs: ** tag The tag under which this block of memory is ** being allocated. ** ** node The block of memory being allocated. ** ** Side Effects: ** This will take a node off freelist, and if necessary will allocate ** dynamic memory. ** ** History: ** 5-dec-1989 (Joe) ** First Written */ VOID IIME_atAddTag( i4 tag, ME_NODE *node) { register METAGNODE **first; # ifdef OS_THREADS_USED CS_synch_lock( &MEtaglist_mutex ); # endif /* OS_THREADS_USED */ /* ** Note that first is a pointer to a pointer. ** The loop will cause a return from the routine if the tag already ** has an METAGNODE in the hash table. ** If the loop finishes, then first will point to the pointer ** that must contain the METAGNODE. */ for (first = &(htab[tag%256]); *first != NULL; first = &((*first)->met_hash)) { if ((*first)->met_tag == tag) { (void)QUinsert((QUEUE *) node, (QUEUE *) (*first)->met_list.MElast); # ifdef OS_THREADS_USED CS_synch_unlock( &MEtaglist_mutex ); # endif /* OS_THREADS_USED */ return; } } if (freelist == NULL) { register METAGNODE *next; register int i; freelist = (METAGNODE *) MEreqmem(0, sizeof(METAGNODE)*50, TRUE, NULL); for (i = 0, next = freelist; i < 49; i++) { next->met_hash = next + 1; next = next->met_hash; } next->met_hash = NULL; } *first = freelist; freelist = freelist->met_hash; (*first)->met_hash = NULL; (*first)->met_tag = tag; QUinit((QUEUE *)&((*first)->met_list)); (void)QUinsert((QUEUE *) node, (QUEUE *) (*first)->met_list.MElast); # ifdef OS_THREADS_USED CS_synch_unlock( &MEtaglist_mutex ); # endif /* OS_THREADS_USED */ return; }
FUNC_EXTERN DB_STATUS IICXcreate_icas_xn_cb( IICX_ID *cx_id, /* IN */ IICX_CB **cx_cb_p_p /* OUT */ ) { DB_STATUS db_status; STATUS cl_status; char ebuf[20]; IICX_ICAS_XN_CB *icas_xn_cb_p; i4 i; /* LOCK the ICAS XN MAIN CB. CHECK !!! */ if (IIcx_icas_xn_main_cb->num_free_icas_xn_cbs > 0) { *cx_cb_p_p = IIcx_icas_xn_main_cb->icas_xn_cb_free_list; IIcx_icas_xn_main_cb->icas_xn_cb_free_list = (*cx_cb_p_p)->cx_next; if ((*cx_cb_p_p)->cx_next != NULL) (*cx_cb_p_p)->cx_next->cx_prev = (*cx_cb_p_p)->cx_prev; IIcx_icas_xn_main_cb->num_free_icas_xn_cbs--; } if (*cx_cb_p_p != NULL) { /* UNLOCK the ICAS XN Main CB. CHECK !!! */ return( E_DB_OK ); } /* UNLOCK the ICAS XN Main CB. CHECK !!! */ /* No free ICAS XN CBs. Create one if appropriate */ db_status = IICXget_new_cx_cb( cx_cb_p_p ); if (DB_FAILURE_MACRO(db_status)) { return(db_status); } if ((icas_xn_cb_p = (IICX_ICAS_XN_CB *)MEreqmem((u_i4)0, (u_i4)sizeof(IICX_ICAS_XN_CB), TRUE, (STATUS *)&cl_status)) == NULL) { CVna((i4)cl_status, ebuf); IICXerror(GE_NO_RESOURCE, E_CX0002_CX_CB_ALLOC, 2, ebuf, ERx("IICX_ICAS_XN_CB")); return( E_DB_FATAL ); } (*cx_cb_p_p)->cx_sub_cb.icas_xn_cb_p = icas_xn_cb_p; return( E_DB_OK ); } /* IICXcreate_icas_xn_cb */
static char * ns_value( API_PARSE *parse, i4 buflen, char *buffer ) { char *parms[ API_FIELD_MAX ]; char *value; i4 len, fld, fld_cnt; STATUS status; /* ** Get each (possibly optional) parameter ** and determine the size of the final ** combined value. */ fld_cnt = max( 0, parse->parms->parm_max - API_FIELD_PARM ); for( fld = len = 0; fld < fld_cnt; fld++ ) { parms[ fld ] = ns_resolve_param( parse, fld + API_FIELD_PARM, (parse->opcode != API_KW_ADD) ); len += STlength( parms[ fld ] ); } len += fld_cnt; /* Allow room for EOS and separating ',' */ if ( ! len ) len++; /* ** Use passed in buffer if large enough. ** Otherwise, allocate temp buffer. */ value = (len <= buflen) ? buffer : (char *)MEreqmem( 0, len, FALSE, &status ); if ( ! value ) { IIAPI_TRACE( IIAPI_TR_FATAL ) ( "ns_value: can't allocate value buffer\n" ); return( NULL ); } /* ** Build the comma separated list of parameters. */ if ( fld_cnt ) STcopy( parms[ 0 ], value ); else *value = EOS; for( fld = 1; fld < fld_cnt; fld++ ) { STcat( value, "," ); STcat( value, parms[ fld ] ); } return( value ); }
STATUS gcn_request( char *gcn_host, i4 *assoc_no, i4 *protocol ) { GCA_RQ_PARMS request; STATUS status = OK; char tbuff[ GC_HOSTNAME_MAX + 12 ]; char *target; i4 len; /* ** Prepare for GCA_REQUEST service call */ len = (gcn_host ? STlength( gcn_host ) + 2 : 0) + 10; target = (len <= sizeof( tbuff )) ? tbuff : (char *)MEreqmem( 0, len, FALSE, NULL ); if ( ! target ) return( E_GC0013_ASSFL_MEM ); STprintf( target, "%s%s/IINMSVR", gcn_host ? gcn_host : "", gcn_host ? "::" : "" ); MEfill( sizeof( request ), '\0', (PTR)&request ); request.gca_peer_protocol = GCA_PROTOCOL_LEVEL_63; request.gca_partner_name = target; /* ** Make GCA_REQUEST service call */ gca_call( &gcn_gca_cb, GCA_REQUEST, (GCA_PARMLIST *)&request, GCA_SYNC_FLAG, NULL, GCN_RCV_TIMEOUT, &status ); gcn_checkerr( "GCA_REQUEST", &status, request.gca_status, &request.gca_os_status ); if ( status != OK ) goto done; if ( gcn_host && request.gca_peer_protocol < GCA_PROTOCOL_LEVEL_50 ) { gcn_release( request.gca_assoc_id ); CL_CLEAR_ERR( &request.gca_os_status ); gcn_checkerr( "GCA_REQUEST", &status, E_GC000A_INT_PROT_LVL, &request.gca_os_status ); goto done; } *assoc_no = request.gca_assoc_id; *protocol = request.gca_peer_protocol; done : if ( target != tbuff ) MEfree( (PTR)target ); return( status ); }
/* Name: adu_map_init_unimap - Initializes a unimap array. ** ** Description: ** This routine, initializes a unimap array which holds information to ** convert from unicode to local characterset. ** ** A substitution character can be provided which will be used to ** initialize the default arrays. ** Input: ** UniBase pointer to unimap table. ** Unidefault pointer to default array. ** subchar substitution character for initialization. ** Output: ** ** None. ** ** History: ** 23-Jan-2004 (gupsh01) ** Added. */ static DB_STATUS adu_map_init_unimap( u_i2 ***UniBase, u_i2 **Unidefault, u_i2 subchar) { i4 i=0; DB_STATUS stat = E_DB_OK; if ((UniBase == NULL) || (Unidefault == NULL)) return (E_DB_ERROR); /*Error Condition*/ *UniBase = (u_i2 **)MEreqmem(0, sizeof(u_i2 *) * 256, FALSE, NULL); *Unidefault = (u_i2 *)MEreqmem(0, sizeof(u_i2) * 256, FALSE, NULL); for (i=0;i<256;i++) { (*Unidefault)[i] = subchar; (*UniBase)[i] = *Unidefault; } return stat; }
bool gcd_alloc_qdesc( QDATA *qdata, u_i2 count, PTR desc ) { qdata->max_rows = 0; qdata->max_cols = count; qdata->col_cnt = 0; qdata->cur_col = 0; qdata->more_segments = FALSE; qdata->desc = NULL; if ( ! qdata->max_cols ) return( FALSE ); if ( desc ) qdata->desc = desc; else { /* ** Expand descriptor array if needed. */ if ( qdata->max_cols > qdata->desc_max ) { if ( qdata->param_desc ) { IIAPI_DESCRIPTOR *desc = (IIAPI_DESCRIPTOR *)qdata->param_desc; u_i2 i; for( i = 0; i < qdata->desc_max; i++ ) if ( desc[i].ds_columnName ) MEfree( desc[i].ds_columnName ); MEfree( qdata->param_desc ); } if ( ! (qdata->param_desc = MEreqmem( 0, sizeof(IIAPI_DESCRIPTOR) * qdata->max_cols, TRUE, NULL )) ) { gcu_erlog( 0, GCD_global.language, E_GC4808_NO_MEMORY, NULL, 0, NULL); return( FALSE ); } qdata->desc_max = qdata->max_cols; } qdata->desc = qdata->param_desc; } return( TRUE ); }
/* ** Name: SAopen - open an operating system audit trail ** ** Description: ** Open an operating system audit trail. Initialy this routine will ** only support the writing of audit records (which are appended to ** the end of the trail), thus the caller may only open the trail in ** one mode, SA_WRITE. A descriptor will be returned from this routine ** which may be used to refference the audit trail in future calls to ** SA. The default operating system audit trail will be the only ** supported trail, and this case the parameter aud_desc will be NULL. ** ** Inputs: ** aud_desc description of the audit trail to open ** flags flags to use when opening the audit trail ** ** Outputs: ** aud_trail_d descriptor to use for this audit trail ** err_code pointer to a variable used to return OS errors ** ** Returns: ** OK if operation succeeded ** SA_NOACCESS user has no access to this audit trail ** SA_BADPARAM bad parameter values were passed to the routine ** SA_NOPRIV the user does not have privileges to read audit trails ** SA_NOSUPP the operation is not supported by this implimentation of** SA. ** FAIL the operation failed ** ** History: ** 7-jan-94 (stephenb) ** Initialy created as a stub. ** 28-feb-94 (stephenb) ** Update to current SA spec. */ STATUS SAopen( char *aud_desc, i4 flags, PTR *aud_trail_d, CL_ERR_DESC *err_code) { /* ** Alocate Memory for descriptor */ *aud_trail_d = MEreqmem(0, sizeof(SA_DESC), TRUE, (STATUS *) NULL); if (*aud_trail_d == NULL) return (SA_NOMEM); STcopy("OS", ((SA_DESC *)*aud_trail_d)->sa_desc); return (OK); }
static VOID psy_push(PSY_STK *base, PTR val, STATUS *sts) { /* Point to true list head block */ PSY_STK *stk = base->head ? base->head : base; if (stk->sp >= N_STK) { base->head = (PSY_STK*)MEreqmem(0, sizeof(PSY_STK), FALSE, sts); if (!base->head || DB_FAILURE_MACRO(*sts)) return; base->head->head = stk; stk = base->head; stk->sp = 0; } stk->list[stk->sp++] = val; }
GCD_PCB * gcd_new_pcb( GCD_CCB *ccb ) { GCD_PCB *pcb; if ( ! (pcb = (GCD_PCB *)MEreqmem( 0, sizeof( GCD_PCB ), TRUE, NULL )) ) gcu_erlog(0, GCD_global.language, E_GC4808_NO_MEMORY, NULL, 0, NULL); else { if ( GCD_global.gcd_trace_level >= 6 ) TRdisplay( "%4d GCD new PCB (%p)\n", ccb->id, pcb ); pcb->ccb = ccb; } return( pcb ); }
/*{ ** Name: RSmem_allocate - Rep server large memory allocation. ** ** Description: ** Computes and allocates memory size needed for buffers to hold ** replicator server internal queries. ** ** Inputs: ** row_width - Total row width of registered cols. ** num_cols - Number of registered cols. ** colname_space - Maximum name space of registered cols. ** overhead - Additional query overhead ** ** Outputs: ** NONE ** ** Returns: ** buf - NULL or Buffer successfully allocated. */ char * RSmem_allocate( i4 row_width, i4 num_cols, i4 colname_space, i4 overhead) { char *buf = (char *)MEreqmem(0, (num_cols * colname_space + row_width + overhead), TRUE, NULL); if (buf == NULL) { /* Error allocating buf */ messageit(1, 1900); return(buf) ; } return(buf); }
/*{ ** Name: new_node - new node ** ** Description: ** Create a new structure and append it to the bottom of the linklist. ** ** Inputs: ** none ** ** Outputs: ** none ** ** Returns: ** A pointer to the new node. ** ** Side effects: ** Some of the static pointers above are changed. */ RLIST * new_node() { RLIST *mark; /* top %d, atop %d */ messageit(5, 1264, top, atop); if (atop) { mark = atop; atop = atop->link; } else { mark = (RLIST *)MEreqmem(0, sizeof(RLIST), TRUE, (STATUS *)NULL); if (mark == NULL) { /* Error Allocating Memory for Record List: Aborting */ messageit(1, 1266); RSshutdown(FAIL); } } mark->link = (RLIST *)NULL; mark->blink = (RLIST *)NULL; if (bottom) /* there is already a linklist */ { bottom->link = mark; mark->blink = bottom; bottom = mark; } else /* first structure in the linklist */ { top = mark; bottom = mark; } /* top %d, atop %d, mark %d */ messageit(5, 1265, top, atop, mark); return (mark); }
STATUS IILQasAdfcbSetup( II_THR_CB *thr_cb ) { II_LBQ_CB *IIlbqcb = thr_cb->ii_th_session; II_LBQ_CB *def = &thr_cb->ii_th_defsess; /* ** Setup the static ADF CB. */ /* ??? Semaphore protect adf_cb/FEadfcb() */ if ( ! adf_cb && ! (adf_cb = FEadfcb()) ) { IIlocerr(GE_NO_RESOURCE, E_LQ0003_ADFINIT, II_ERR, 0, (char *)0); return FAIL; } /* ** Default sessions use the static ADF CB. */ if ( ! def->ii_lq_adf ) def->ii_lq_adf = adf_cb; /* ** Real sessions receive their own copy of the ADF CB. */ if ( ! IIlbqcb->ii_lq_adf ) { if ((IIlbqcb->ii_lq_adf = (ADF_CB *)MEreqmem((u_i4)0, (u_i4)sizeof(ADF_CB), TRUE, (STATUS *) NULL)) == NULL) { char ebuf[10]; CVna(IIlbqcb->ii_lq_sid, ebuf); IIlocerr(GE_NO_RESOURCE, E_LQ00E8_ADFALLOC, II_ERR, 1, ebuf); return FAIL; } /* Fill with the default values of the static ADF control block */ MEcopy((PTR)def->ii_lq_adf, (u_i2)sizeof(ADF_CB), (PTR)IIlbqcb->ii_lq_adf); } return OK; }
void SAXImportHandlers::writeChars ( const XMLByte* const toWrite # if XERCES_VERSION_MAJOR > 2 , XMLSize_t count # else , const unsigned int count # endif , XMLFormatter* const formatter) { /* format each piece of CDATA value based on other information */ int inlen = STlength((char *)toWrite); if (!(isMetaInfoSet)) { cerr<<"ERROR: Either table or table metadata information is not found."<<endl; ThrowXML(RuntimeException, XMLExcepts::NoError); } /* collect the string parsed */ if (datalen == 0) { datalen = inlen; MEcopy (toWrite, datalen, dataval); } else { int oldlen = datalen; datalen += inlen; /* Increase the buffer size to hold the value */ if (datalen > oldlen) { char *temp = dataval; int factor = (datalen/(DB_MAXSTRING + 32)) + 1; temp = (char *)MEreqmem(0, (DB_MAXSTRING + 32)*factor, TRUE, NULL); MEcopy (dataval, oldlen, temp); MEfree(dataval); dataval = temp; } MEcopy (toWrite, inlen, dataval + oldlen); } }
/* ** Name: gcu_alloc_str() - allocate buffer and copy var string from input. ** ** Description: ** allocate memory with the size of input buff size. ** Copies the string from input buff into the allocated ptr, ** null terminating ptr. ** assign ptr to output str. ** ** Returns: ** Amount of buffer used. ** ** History: ** 19-Jul-2001 (wansh01) ** created */ i4 gcu_alloc_str( char *buff, char **str) { i4 len; STATUS status; char *ptr; I4ASSIGN_MACRO( *buff, len ); if ((ptr = (char *)MEreqmem(0,len+1, FALSE, &status)) == NULL) return 0; MEcopy( buff + sizeof( len ), len, ptr ); if( !len || buff[ len - 1 ] ) ptr[ len ] = '\0'; *str = ptr; return sizeof( len ) + len; }
GCD_CCB * gcd_new_ccb( void ) { GCD_CCB *ccb; if ( ! (ccb = (GCD_CCB *)QUremove( GCD_global.ccb_free.q_next )) ) if ( (ccb = (GCD_CCB *)MEreqmem( 0, sizeof(GCD_CCB), FALSE, NULL )) ) ccb->id = GCD_global.ccb_total++; if ( ! ccb ) gcu_erlog(0, GCD_global.language, E_GC4808_NO_MEMORY, NULL, 0, NULL); else { u_i4 id = ccb->id; MEfill( sizeof( GCD_CCB ), 0, (PTR)ccb ); ccb->id = id; ccb->use_cnt = 1; ccb->max_buff_len = 1 << DAM_TL_PKT_MIN; ccb->tl.proto_lvl = DAM_TL_PROTO_1; ccb->xact.auto_mode = GCD_XACM_DBMS; ccb->api.env = NULL; QUinit( &ccb->q ); QUinit( &ccb->rcb_q ); QUinit( &ccb->gcc.send_q ); QUinit( &ccb->msg.msg_q ); QUinit( &ccb->msg.info_q ); QUinit( &ccb->stmt.stmt_q ); QUinit( &ccb->rqst.rqst_q ); GCD_global.ccb_active++; QUinsert( &ccb->q, &GCD_global.ccb_q ); if ( GCD_global.gcd_trace_level >= 5 ) TRdisplay( "%4d GCD new CCB (%d)\n", ccb->id, ccb->id ); } return( ccb ); }
/* Name: adu_map_add_unimap - adds unimap values to unicode mapping table. ** ** Description: ** ** This routines, inserts a unicode mapping value to the unicode map table. ** ** Input: ** UniBase pointer to unitochar table. ** Unidefault pointer to default array. ** local byte value to add. ** unicode unicode value to add. ** uhsur higher surrogate value for unicode if any. ** subchar substitution character for initialization. ** ** Output: ** None. ** ** History: ** 23-Jan-2004 (gupsh01) ** Added. */ static void adu_map_add_unimap ( u_i2 **UniBase, u_i2 *Unidefault, u_i2 local, u_i2 unicode, u_i2 uhsur, u_i2 subchar) { int i = 0; u_i2 unibytes[2]; unibytes[0] = (unicode & 0xFFFF) >> 8; unibytes[1] = unicode & 0xFF; if (UniBase[unibytes[0]] == Unidefault) { UniBase[unibytes[0]] = (u_i2 *)MEreqmem(0, sizeof(u_i2) * 256, FALSE, NULL); for (i=0;i<256;i++) UniBase[unibytes[0]][i] = subchar; } UniBase[unibytes[0]][unibytes[1]] = local; }