int find_keyword(const char* inbytes, size_t* length, const language_zh_map *m, int begin, int end, const int whence) { int location, offset; size_t wwidth, nwidth; if((offset = binary_find(inbytes, length, m, begin, end)) == -1) return -1; /* match the most accurate value */ wwidth = *length; do{ location = offset; *length = wwidth; nwidth = utf8_char_width(const_bin_c_str(inbytes+wwidth)); wwidth += nwidth; } while(nwidth != 0 && (offset = binary_find(inbytes, &wwidth, m, offset, end)) != -1); /* extention word fix */ if(!match_cond(cond_ptr(m, location), inbytes, strlen(map_key(m, location)), whence)) { *length = utf8_char_width(const_bin_c_str(inbytes)); return -1; } return location; }
void* SharedLibraryImpl::findSymbolImpl(const std::string& name) { FastMutex::ScopedLock lock(_mutex); if (_path.empty()) return NULL; Path p(_path); std::string filename = p.getBaseName(); std::string ext = p.getExtension(); std::string imageSpec = p.makeParent().toString(); if (!imageSpec.empty() && !ext.empty()) { imageSpec.append("."); imageSpec.append(ext); } int value = 0; long flags = LIB$M_FIS_MIXEDCASE; POCO_DESCRIPTOR_STRING(filenameDsc, filename); POCO_DESCRIPTOR_STRING(symbolDsc, name); POCO_DESCRIPTOR_STRING(imageSpecDsc, imageSpec); try { // lib$find_image_symbol only accepts 32-bit pointers #pragma pointer_size save #pragma pointer_size 32 lib$find_image_symbol(&filenameDsc, &symbolDsc, &value, imageSpec.empty() ? 0 : &imageSpecDsc, flags); #pragma pointer_size restore } catch (struct chf$signal_array& sigarr) { unsigned sig = sigarr.chf$is_sig_name; unsigned act = LIB$_ACTIMAGE; if (lib$match_cond(&sig, &act)) throw LibraryLoadException(_path); } return (void*) value; }
/* 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 */ }