void database_free(database_t *database) { size_t i; if(!database) { return; } for(i = 0; i < array_size(database->records); i++) { record_free((record_t *) array_get(database->records, i)); } for(i = 0; i < database->num_fields; i++) { free(database->fields[i]); } free(database->filename); free(database->fields); array_free(database->records); free(database); }
int hashify_check_collisions( const char* string, hash_t hash_value, const hashify_string_t* history ) { int ihist, history_size; for( ihist = 0, history_size = array_size( history ); ihist < history_size; ++ihist ) { if( history[ihist].hash == hash_value ) { if( string_equal( history[ihist].string, string ) ) { log_errorf( ERROR_INVALID_VALUE, " global string duplication, \"%s\" ", string ); return HASHIFY_RESULT_STRING_COLLISION; } else { log_errorf( ERROR_INVALID_VALUE, " global hash collision, 0x%llx between: \"%s\" and \"%s\" ", hash_value, string, history[ihist].string ); return HASHIFY_RESULT_HASH_COLLISION; } } } return 0; }
static int aggregate_size (Dwarf_Die *die, Dwarf_Word *size, Dwarf_Die *type_mem) { Dwarf_Attribute attr_mem; if (INTUSE(dwarf_attr_integrate) (die, DW_AT_byte_size, &attr_mem) != NULL) return INTUSE(dwarf_formudata) (&attr_mem, size); switch (INTUSE(dwarf_tag) (die)) { case DW_TAG_typedef: case DW_TAG_subrange_type: return aggregate_size (get_type (die, &attr_mem, type_mem), size, type_mem); /* Tail call. */ case DW_TAG_array_type: return array_size (die, size, &attr_mem, type_mem); } /* Most types must give their size directly. */ return -1; }
/* DO NOT CHANGE CODE BELOW THIS LINE */ void rotate_reference(char s[], int n) { int size = array_size(s); char new_array[size]; int i; int pos = 0; if (size - 1 != 0) { for (i = n % (size - 1); i < (size - 1); i++) { new_array[pos] = s[i]; pos++; } for (i = 0; i < n % (size - 1); i++) { new_array[pos] = s[i]; pos++; } } new_array[size-1] = '\0'; printf("%s\n", new_array); }
/* allocate room specified number of events */ int snd_seq_pool_init(struct snd_seq_pool *pool) { int cell; struct snd_seq_event_cell *cellptr; unsigned long flags; if (snd_BUG_ON(!pool)) return -EINVAL; cellptr = vmalloc(array_size(sizeof(struct snd_seq_event_cell), pool->size)); if (!cellptr) return -ENOMEM; /* add new cells to the free cell list */ spin_lock_irqsave(&pool->lock, flags); if (pool->ptr) { spin_unlock_irqrestore(&pool->lock, flags); vfree(cellptr); return 0; } pool->ptr = cellptr; pool->free = NULL; for (cell = 0; cell < pool->size; cell++) { cellptr = pool->ptr + cell; cellptr->pool = pool; cellptr->next = pool->free; pool->free = cellptr; } pool->room = (pool->size + 1) / 2; /* init statistics */ pool->max_used = 0; pool->total_elements = pool->size; spin_unlock_irqrestore(&pool->lock, flags); return 0; }
int hashify_read_hashes( stream_t* file, hashify_string_t** hashes ) { //Read in hashes in file char* line; char line_buffer[HASHIFY_LINEBUFFER_LENGTH]; do { stream_read_line_buffer( file, line_buffer, HASHIFY_LINEBUFFER_LENGTH-1, '\n' ); line = string_strip( line_buffer, "\n\r" ); if( ( string_find_string( line, "define", 0 ) != STRING_NPOS ) && ( string_find_string( line, "static_hash", 0 ) != STRING_NPOS ) ) { //Format is: #define HASH_<hashstring> static_hash_string( "<string>", 0x<hashvalue>ULL ) char** tokens = string_explode( line, " \t", false ); if( array_size( tokens ) >= 6 ) { hashify_string_t hash_string; string_copy( hash_string.string, string_strip( string_strip( tokens[3], "," ), "\"" ), HASHIFY_STRING_LENGTH ); hash_string.hash = string_to_uint64( tokens[4], true ); if( hash( hash_string.string, string_length( hash_string.string ) ) != hash_string.hash ) { log_errorf( ERROR_INVALID_VALUE, " hash output file is out of date, %s is set to 0x%llx but should be 0x%llx ", hash_string.string, hash_string.hash, hash( hash_string.string, string_length( hash_string.string ) ) ); string_array_deallocate( tokens ); return HASHIFY_RESULT_OUTPUT_FILE_OUT_OF_DATE; } array_push_memcpy( *hashes, &hash_string ); } string_array_deallocate( tokens ); } } while( !stream_eos( file ) ); return 0; }
/** Iterate over the partitions on a device. * @param disk Disk to iterate over. * @param cb Callback function. * @return Whether the device contained an MBR partition table. */ static bool mbr_partition_iterate(disk_device_t *disk, partition_iterate_cb_t cb) { mbr_t *mbr __cleanup_free; bool seen_extended; /* Read in the MBR, which is in the first block on the device. */ mbr = malloc(sizeof(*mbr)); if (!read_mbr(disk, mbr, 0) || mbr->signature != MBR_SIGNATURE) return false; /* Check if this is a GPT partition table (technically we should not get * here if this is a GPT disk as the GPT code should be reached first). This * is just a safeguard. */ if (mbr->partitions[0].type == MBR_PARTITION_TYPE_GPT) return false; /* Loop through all partitions in the table. */ seen_extended = false; for (size_t i = 0; i < array_size(mbr->partitions); i++) { mbr_partition_t *partition = &mbr->partitions[i]; if (!is_valid(disk, partition)) continue; if (is_extended(partition)) { if (seen_extended) { dprintf("mbr: warning: ignoring multiple extended partitions\n"); continue; } handle_extended(disk, partition->start_lba, cb); seen_extended = true; } else { cb(disk, i, partition->start_lba, partition->num_sectors); } } return true; }
static void queue_while(hre_context_t ctx,int*condition){ int me=HREme(ctx); hre_msg_t msg=NULL; int max_comm=array_size(HREcommManager(ctx)); int comm; for(;;){ pthread_mutex_lock(&ctx->queues[me].lock); Debug("scanning queue %d below %d",me,max_comm); for(comm=0;comm<max_comm;comm++){ msg=hre_get_msg(&ctx->queues[me].comm[comm]); if (msg) break; } while(!msg && *condition) { Debug("blocking %d",*condition); pthread_cond_wait(&ctx->queues[me].cond, &ctx->queues[me].lock); Debug("scanning queue %d below %d",me,max_comm); for(comm=0;comm<max_comm;comm++){ msg=hre_get_msg(&ctx->queues[me].comm[comm]); if (msg) break; } } pthread_mutex_unlock(&ctx->queues[me].lock); if (!msg) break; /* Messages are put in the queue with the sending context. They have to be processed with respect to the receiving context. */ msg->context=ctx; if (me==(int)msg->target) { Debug("delivering message %p",msg); // Message is sent to us. HREdeliverMessage(msg); } else { Debug("completed message %p",msg); // Message is being returned to us. HREmsgReady(msg); } } }
/* Open log stream */ struct zlog *openzlog(const char *progname, zlog_proto_t protocol, int syslog_flags, int syslog_facility) { struct zlog *zl; u_int i; zl = XCALLOC(MTYPE_ZLOG, sizeof(struct zlog)); zl->ident = progname; zl->protocol = protocol; zl->facility = syslog_facility; zl->syslog_options = syslog_flags; /* Set default logging levels. */ for (i = 0; i < array_size(zl->maxlvl); i++) zl->maxlvl[i] = ZLOG_DISABLED; zl->maxlvl[ZLOG_DEST_MONITOR] = LOG_DEBUG; zl->default_lvl = LOG_DEBUG; openlog(progname, syslog_flags, zl->facility); return zl; }
void sprite_touch(struct sprite* self, struct touch_event* touch_event) { struct array* children = self->children; for (int i = 0 ;i < array_size(children); ++i) { struct sprite* child = (struct sprite*)array_at(children, i); if (child) { // NULL indicates that the child has been removed // recursively visit the children. sprite_touch(child, touch_event); } } if(touch_event->swallowd) { return; } if (sprite_contains(self, touch_event->x, touch_event->y)) { if (self->swallow) { touch_event->swallowd = true; } //TODO: this call is ugly, refactor someday. lua_handler_exe_func(GAME->lua_handler, GAME->lstate, self, NULL); } }
/* Function to check constraints on table entries */ static void check(void) { int j; /* ms_none */ assert(list[0].size == 0); for (j = 1; j < array_size(list); j++) { assert(list[j].size == j); assert(list[j].dimen[0] <= list[j].dimen[1]); assert(strlen(list[j].name) < LONGER_THAN_NAMES); assert(list[j].dimen[0] == 0.0 || list[j-1].dimen[0] < list[j].dimen[0] || list[j-1].dimen[0] == list[j].dimen[0] && list[j-1].dimen[1] <= list[j].dimen[1]); } /* Check that the highest accepted value does not collide with the flags */ assert((ms_MaxPage & MS_FLAG_MASK) == 0); checked = 1; return; }
int hashify_check_collisions(string_const_t string, hash_t hash_value, const hashify_string_t* history) { size_t ihist, history_size; for (ihist = 0, history_size = array_size(history); ihist < history_size; ++ihist) { if (history[ihist].hash == hash_value) { if (string_equal(history[ihist].string.str, history[ihist].string.length, string.str, string.length)) { log_errorf(0, ERROR_INVALID_VALUE, STRING_CONST(" global string duplication, \"%.*s\""), STRING_FORMAT(string)); return HASHIFY_RESULT_STRING_COLLISION; } else { log_errorf(0, ERROR_INVALID_VALUE, STRING_CONST(" global hash collision, 0x%" PRIx64 " between: \"%.*s\" and \"%.*s\" "), hash_value, STRING_FORMAT(string), STRING_FORMAT(history[ihist].string)); return HASHIFY_RESULT_HASH_COLLISION; } } } return 0; }
static void _json_write_array(FILE * file, array_t array, unsigned int depth) { if (array_size(array) == 0) { fputs("[]", file); } else { bool first = true; fputs("[\n", file); for_each_array(it, array) { if (first) first = false; else fputs(",\n", file) for (int i = 0; i < depth + 1; i++) fputs(" ", file); _json_write(file, iterator, depth + 1); } fputs("\n", file); for (int i = 0; i < depth; i++) fputs(" ", file); fputs("]", file); } }
/** * @brief Removes slots by type from the weapon set. */ void pilot_weapSetRmSlot( Pilot *p, int id, OutfitSlotType type ) { int i, n, l; PilotWeaponSet *ws; /* We must clean up the slots. */ n = 0; /* Number to remove. */ ws = pilot_weapSet(p,id); if (ws->slots == NULL) return; l = array_size(ws->slots); for (i=0; i<l; i++) { if (ws->slots->slot->sslot->slot.type != type) continue; /* Move down. */ memmove( &ws->slots[i], &ws->slots[i+1], sizeof(PilotWeaponSetOutfit) * (l-i-1) ); n++; } /* Remove surplus. */ array_erase( &ws->slots, &ws->slots[l-n], &ws->slots[l] ); }
static void removePlugin(PluginData* pluginData) { // Remove the plugin data for (int i = 0; i < PRODBG_PLUGIN_COUNT; ++i) { int count = array_size(s_plugins[i]); for (int t = 0; t < count; ++t) { PluginData* plugin = s_plugins[i][t]; if (pluginData != plugin) continue; printf("removed plugin %s\n", plugin->fullFilename); library_unload(plugin->lib); free((void*)plugin->fullFilename); free(plugin); array_erase(s_plugins[i], t); return; } } }
void server_update(msg_Conn *conn, msg_Event event, msg_Data data) { // We expect to hear events in this order. int expected_events[] = { msg_listening, msg_connection_ready, msg_message, msg_message, msg_message, msg_connection_closed}; test_printf("Server: Received event %s\n", event_names[event]); if (event == msg_error) { char *err_str = msg_as_str(data); test_printf("Server: Error: %s\n", err_str); if (strcmp(err_str, "bind: Address already in use") == 0) { if (server_ctx.num_tries < max_tries) { test_printf("Will wait briefly and try again at address %s.\n", server_ctx.address); sleep(5); server_ctx.num_tries++; msg_listen(server_ctx.address, server_update); return; // Don't count this as a server event. } else { test_printf("Server: max_tries reached; giving up listening (at %s).\n", server_ctx.address); } } } test_that(server_event_num < array_size(expected_events)); test_that(event == expected_events[server_event_num]); if (event == msg_message) { char *str = msg_as_str(data); test_str_eq(str, "why hello"); server_done = true; num_msg_recd++; } server_event_num++; }
/** * @brief Fires a weapon set. */ static int pilot_weapSetFire( Pilot *p, PilotWeaponSet *ws, int level ) { int i, j, ret, s; /* Case no outfits. */ if (ws->slots == NULL) return 0; /* Fire. */ ret = 0; for (i=0; i<array_size(ws->slots); i++) { /* Only "active" outfits. */ if ((level != -1) && (ws->slots[i].level != level)) continue; /* Only run once for each weapon type in the group. */ s = 0; for (j=0; j<i; j++) { /* Only active outfits. */ if ((level != -1) && (ws->slots[j].level != level)) continue; /* Found a match. */ if (ws->slots[j].slot->outfit == ws->slots[i].slot->outfit) { s = 1; break; } } if (s!=0) continue; /* Shoot the weapon of the weaponset. */ ret += pilot_shootWeaponSetOutfit( p, ws, ws->slots[i].slot->outfit, level ); } return ret; }
static void *do_add(void *arg) { int tid=(int)(arg); for(int i=0;i<20;i++) { /* Creating a password */ SInt32 v_eighty = (tid+1)*1000+i; CFNumberRef eighty = CFNumberCreate(NULL, kCFNumberSInt32Type, &v_eighty); const char *v_data = "test"; CFDataRef pwdata = CFDataCreate(NULL, (UInt8 *)v_data, strlen(v_data)); const void *keys[] = { kSecClass, kSecAttrServer, kSecAttrAccount, kSecAttrPort, kSecAttrProtocol, kSecAttrAuthenticationType, kSecValueData }; const void *values[] = { kSecClassInternetPassword, CFSTR("members.spamcop.net"), CFSTR("smith"), eighty, CFSTR("http"), CFSTR("dflt"), pwdata }; CFDictionaryRef item = CFDictionaryCreate(NULL, keys, values, array_size(keys), NULL, NULL); ok_status(SecItemAdd(item, NULL), "add internet password"); } return NULL; }
/** * @brief Removes a slot from a weapon set. * * @param p Pilot who owns the weapon set. * @param id ID of the weapon set. * @param o Outfit to remove. */ void pilot_weapSetRm( Pilot* p, int id, PilotOutfitSlot *o ) { PilotWeaponSet *ws; int i, j; /* Make sure it has slots. */ ws = pilot_weapSet(p,id); if (ws->slots == NULL) return; /* Find the slot. */ for (i=0; i<array_size(ws->slots); i++) { if (ws->slots[i].slot != o) continue; array_erase( &ws->slots, &ws->slots[i], &ws->slots[i+1] ); /* Update range. */ pilot_weapSetUpdateRange( ws ); /* Update if needed. */ if (id == p->active_set) pilot_weapSetUpdateOutfits( p, ws ); /* Updated cached weapset. */ o->weapset = -1; for (j=0; j<PILOT_WEAPON_SETS; j++) { if (pilot_weapSetCheck(p, j, o) != -1) { o->weapset = j; break; } } return; } }
void ft_setenv(t_env **env) { char **split; if (array_size((*env)->av) > 1) if (ft_strchr((*env)->av[1], '=') != NULL) { split = ft_strsplit((*env)->av[1], '='); if (is_env(*env, split[0]) != -1) ft_replaceenv(&(*env), split, (*env)->av[1]); else (*env)->e = ft_arradd((*env)->e, (*env)->av[1]); } else { if (is_env(*env, split[0]) == -1) { split[0] = ft_strjoin(split[0], "="); (*env)->e = ft_arradd((*env)->e, split[0]); } } else ft_putendl("Usage : setenv KEY=VALUE"); }
/** * @brief Approaches the NPC. * * @param i Index of the NPC to approach. */ int npc_approach( int i ) { NPC_t *npc; lua_State *L; /* Make sure in bounds. */ if ((i<0) || (i>=array_size(npc_array))) return -1; /* Comfortability. */ npc = &npc_array[i]; /* Handle type. */ switch (npc->type) { case NPC_TYPE_GIVER: return npc_approach_giver( npc ); case NPC_TYPE_MISSION: L = misn_runStart( npc->u.m.misn, npc->u.m.func ); lua_pushnumber( L, npc->id ); misn_runFunc( npc->u.m.misn, npc->u.m.func, 1 ); break; case NPC_TYPE_EVENT: L = event_runStart( npc->u.e.id, npc->u.e.func ); lua_pushnumber( L, npc->id ); event_runFunc( npc->u.e.id, npc->u.e.func, 1 ); break; default: WARN("Unknown NPC type!"); return -1; } return 0; }
/** * @brief Removes all the npc belonging to a mission. */ int npc_rm_parentMission( Mission *misn ) { int i, n; NPC_t *npc; if (npc_array == NULL) return 0; n = 0; for (i=0; i<array_size(npc_array); i++) { npc = &npc_array[i]; if (npc->type != NPC_TYPE_MISSION) continue; if (npc->u.m.misn->id != misn->id ) continue; /* Invalidates iterators. */ npc_rm( npc ); i--; n++; } return n; }
/** * @brief Removes all the npc belonging to an event. */ int npc_rm_parentEvent( unsigned int id ) { int i, n; NPC_t *npc; if (npc_array == NULL) return 0; n = 0; for (i=0; i<array_size(npc_array); i++) { npc = &npc_array[i]; if (npc->type != NPC_TYPE_EVENT) continue; if (npc->u.e.id != id ) continue; /* Invalidates iterators. */ npc_rm( npc ); i--; n++; } return n; }
static int UVERBS_HANDLER(UVERBS_METHOD_COUNTERS_READ)( struct ib_uverbs_file *file, struct uverbs_attr_bundle *attrs) { struct ib_counters_read_attr read_attr = {}; const struct uverbs_attr *uattr; struct ib_counters *counters = uverbs_attr_get_obj(attrs, UVERBS_ATTR_READ_COUNTERS_HANDLE); int ret; if (!counters->device->read_counters) return -EOPNOTSUPP; if (!atomic_read(&counters->usecnt)) return -EINVAL; ret = uverbs_get_flags32(&read_attr.flags, attrs, UVERBS_ATTR_READ_COUNTERS_FLAGS, IB_UVERBS_READ_COUNTERS_PREFER_CACHED); if (ret) return ret; uattr = uverbs_attr_get(attrs, UVERBS_ATTR_READ_COUNTERS_BUFF); read_attr.ncounters = uattr->ptr_attr.len / sizeof(u64); read_attr.counters_buff = uverbs_zalloc( attrs, array_size(read_attr.ncounters, sizeof(u64))); if (IS_ERR(read_attr.counters_buff)) return PTR_ERR(read_attr.counters_buff); ret = counters->device->read_counters(counters, &read_attr, attrs); if (ret) return ret; return uverbs_copy_to(attrs, UVERBS_ATTR_READ_COUNTERS_BUFF, read_attr.counters_buff, read_attr.ncounters * sizeof(u64)); }
/** * @brief Renders the background images. */ static void background_renderImages( background_image_t *bkg_arr ) { int i; background_image_t *bkg; double px,py, x,y, xs,ys, z; /* Must have an image array created. */ if (bkg_arr == NULL) return; /* Render images in order. */ for (i=0; i<array_size(bkg_arr); i++) { bkg = &bkg_arr[i]; cam_getPos( &px, &py ); x = px + (bkg->x - px) * bkg->move - bkg->scale*bkg->image->sw/2.; y = py + (bkg->y - py) * bkg->move - bkg->scale*bkg->image->sh/2.; gl_gameToScreenCoords( &xs, &ys, x, y ); z = cam_getZoom(); z *= bkg->scale; gl_blitScale( bkg->image, xs, ys, z*bkg->image->sw, z*bkg->image->sh, &bkg->col ); } }
void test_array_add_at_index() { array a; int ints[] = {2, 5, 3, 10, 1}; int ints_size = ARRAY_SIZE(ints); array_init(&a, sizeof(int), comp_int_member); insert_ints(&a, (add_fn_t)array_add, ints, ints_size); /* Add elements at specific indexes - expected array. */ int exp[] = {0, 2, 4, 5, 3, 10, 1, 11}; /* ^ ^ ^ */ int exp_size = ARRAY_SIZE(exp); array_add_at_index(&a, &exp[0], 0); /* Start of array. */ array_add_at_index(&a, &exp[2], 2); array_add_at_index(&a, &exp[7], 7); /* End of array. */ assert_ints(&a, (search_fn_t)array_search, exp, exp_size); /* Add elements at non-existend index - should not be possible. */ array_add_at_index(&a, &exp[0], ARRAY_SIZE(exp) + 2); /* The array has not been changed. */ TEST_ASSERT_EQUAL(array_size(&a), ARRAY_SIZE(exp)); assert_ints(&a, (search_fn_t)array_search, exp, exp_size); }
static void arp_header_init(struct proto_hdr *hdr) { struct proto_hdr *lower; lower = proto_lower_default_add(hdr, PROTO_ETH); if (lower->id == PROTO_ETH) { uint8_t bcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; proto_field_set_default_bytes(lower, ETH_DST_ADDR, bcast); } proto_header_fields_add(hdr, arp_fields, array_size(arp_fields)); /* Generate Announce request by default */ proto_field_set_default_be16(hdr, ARP_HTYPE, ARPHRD_ETHER); proto_field_set_default_be16(hdr, ARP_PTYPE, ETH_P_IP); proto_field_set_default_u8(hdr, ARP_HLEN, 6); proto_field_set_default_u8(hdr, ARP_PLEN, 4); proto_field_set_default_be16(hdr, ARP_OPER, ARPOP_REQUEST); proto_field_set_default_dev_mac(hdr, ARP_SHA); proto_field_set_default_dev_ipv4(hdr, ARP_SPA); proto_field_set_default_dev_ipv4(hdr, ARP_TPA); }
static void testdigestandsign(SecKeyRef privKey, SecKeyRef pubKey) { static const SecAsn1Oid *oids[] = { &CSSMOID_ECDSA_WithSHA1, #if 0 &CSSMOID_ECDSA_WithSHA224, &CSSMOID_ECDSA_WithSHA256, &CSSMOID_ECDSA_WithSHA384, &CSSMOID_ECDSA_WithSHA512, #endif }; uint32_t ix; SecAsn1AlgId algId = {}; for (ix = 0; ix < array_size(oids); ++ix) { if (oids[ix]) { algId.algorithm = *oids[ix]; } else { algId.algorithm.Length = 0; algId.algorithm.Data = NULL; } testdigestandsignalg(privKey, pubKey, &algId); } }
/* * rotates string s (given size of char array, INCLUDING the null terminator) by n places * edits the s character array formed by pushing leftmost characters to the right; only alphanumeric characters rotate. * the result is saved in the local variable new_array, then printed. * * EX: rotate("hello", 1) --> "elloh" * EX: rotate("hello", 2) --> "llohe" * EX: rotate("hello", 5) --> "hello" * * Please SIMD-ize this standard implementation of rotate_vectorized!! */ void rotate_vectorized(char s[], int n) { int size = array_size(s); char new_array[size]; /* YOUR CODE HERE */ int pos = 0; if (size - 1 != 0) { int i =n % (size - 1), j = 0; for (; i < (size - 1)/256-16; i+=16) { __m128i temp = _mm_loadu_si128 ((__m128i*)(s+i)); _mm_storeu_si128((__m128i*)(new_array+pos), temp); pos +=16; } for (; i < (size - 1); i++) new_array[pos++] = s[i]; for (; j < (n % (size - 1))/16*16-16; j+=16) { __m128i temp = _mm_loadu_si128 ((__m128i*)(s+j)); _mm_storeu_si128((__m128i*)(new_array+pos), temp); pos +=16; } for (; j < n % (size - 1); j++) new_array[pos++] = s[j]; } new_array[size-1] = '\0'; /* DO NOT CHANGE CODE BELOW THIS LINE */ printf("%s\n", new_array); }
AutoDetectResult CompilerICC::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); wxString extraDir = _T(""); if (platform::windows) { if (wxDirExists(_T("C:\\Program Files\\Intel\\Compiler"))) { wxDir icc_dir(_T("C:\\Program Files\\Intel\\Compiler\\C++")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; m_MasterPath.Append(_T("\\IA32")); // Now check for the installation of MSVC const wxString msvcIds[4] = { _T("msvc6"), _T("msvctk"), _T("msvc8"), _T("msvc10") }; bool msvcFound = false; for (unsigned int which_msvc = 0; which_msvc < array_size(msvcIds); ++which_msvc) { Compiler* vcComp = CompilerFactory::GetCompiler(msvcIds[which_msvc]); if (vcComp) { if (vcComp->AutoDetectInstallationDir() == adrDetected) { const wxString& vcMasterPath = vcComp->GetMasterPath(); if (m_ExtraPaths.Index(vcMasterPath) == wxNOT_FOUND && wxDirExists(vcMasterPath)) { m_ExtraPaths.Add(vcMasterPath); } AddIncludeDir(vcMasterPath + _T("\\Include")); AddLibDir(vcMasterPath + _T("\\Lib")); AddResourceIncludeDir(vcMasterPath + _T("\\Include")); const wxArrayString& vcExtraPaths = vcComp->GetExtraPaths(); for (size_t i = 0; i < vcExtraPaths.GetCount(); ++i) { if (m_ExtraPaths.Index(vcExtraPaths[i]) == wxNOT_FOUND && wxDirExists(vcExtraPaths[i])) { m_ExtraPaths.Add(vcExtraPaths[i]); } } const wxArrayString& vcIncludeDirs = vcComp->GetIncludeDirs(); for (size_t i = 0; i < vcIncludeDirs.GetCount(); ++i) { if (wxDirExists(vcIncludeDirs[i])) { if (m_IncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) { AddIncludeDir(vcIncludeDirs[i]); } if (m_ResIncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) { AddResourceIncludeDir(vcIncludeDirs[i]); } } } const wxArrayString& vcLibDirs = vcComp->GetLibDirs(); for (size_t i = 0; i < vcLibDirs.GetCount(); ++i) { if (m_LibDirs.Index(vcLibDirs[i]) == wxNOT_FOUND && wxDirExists(vcLibDirs[i])) { AddLibDir(vcLibDirs[i]); } } msvcFound = true; break; } } } if (!msvcFound) { cbMessageBox(_T("It seems your computer doesn't have a working MSVC compiler.\n\n" "This compiler requires MS compiler for proper functioning and\n" "it may not work without it."), _T("Error"), wxOK | wxICON_ERROR); } } } } // Read the ICPP_COMPILER90 environment variable wxGetEnv(_T("ICPP_COMPILER90"), &m_MasterPath); extraDir = sep + _T("IA32");// Intel also provides compiler for Itanium processors if (m_MasterPath.IsEmpty()) { // just a guess the default installation dir wxString Programs = _T("C:\\Program Files"); // what's the "Program Files" location // TO DO : support 64 bit -> 32 bit apps are in "ProgramFiles(x86)" // 64 bit apps are in "ProgramFiles" wxGetEnv(_T("ProgramFiles"), &Programs); m_MasterPath = Programs + _T("\\Intel\\Compiler\\C++\\9.0"); } } else { m_MasterPath = _T("/opt/intel/cc/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_dir(_T("/opt/intel/cc")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; } } } } AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrDetected) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("Include"), 0); m_LibDirs.Insert(m_MasterPath + sep + _T("Lib"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("Include"), 0); } // Try to detect the debugger. If not detected successfully the debugger plugin will // complain, so only the autodetection of compiler is considered in return value wxString path; wxString dbg; if (platform::windows) { dbg = _T("idb.exe"); wxGetEnv(_T("IDB_PATH"), &path); path += _T("IDB\\9.0\\IA32"); } else { dbg = _T("idb"); path= _T("/opt/intel/idb/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_debug_dir(_T("/opt/intel/idb")); if (icc_debug_dir.IsOpened()) { wxArrayString debug_dirs; wxIccDirTraverser IccDebugDirTraverser(debug_dirs); icc_debug_dir.Traverse(IccDebugDirTraverser); if (!debug_dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path debug_dirs.Sort(true); path = debug_dirs[0]; } } } } if (wxFileExists(path + sep + _T("bin") + sep + dbg)) m_ExtraPaths.Add(path); return ret; }