int win32_start_vss(struct conf **confs) { int errors=0; if(SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE)) logp("Control handler registered.\n"); else logp("Could not register control handler.\n"); if(g_pVSSClient->InitializeForBackup()) { const char *vss_drives=get_string(confs[OPT_VSS_DRIVES]); char szWinDriveLetters[27]; // Tell vss which drives to snapshot. if(vss_drives) { unsigned int i=0; for(i=0; i<strlen(vss_drives) && i<26; i++) szWinDriveLetters[i]=toupper(vss_drives[i]); szWinDriveLetters[i]='\0'; } else { // Not given anything specific. Figure out what to do // from the given starting directories. int j=0; struct strlist *s; for(s=get_strlist(confs[OPT_STARTDIR]), j=0; s && j<26; s=s->next) { const char *path=NULL; if(!s->flag) continue; path=s->path; if(strlen(path)>2 && isalpha(path[0]) && path[1]==':') { int x=0; // Try not to add the same letter twice. for(x=0; x<j; x++) if(toupper(path[0])==szWinDriveLetters[x]) break; if(x<j) continue; szWinDriveLetters[j++]=toupper(path[0]); } } szWinDriveLetters[j]='\0'; } printf("Generate VSS snapshots.\n"); printf("Driver=\"%s\", Drive(s)=\"%s\"\n", g_pVSSClient->GetDriverName(), szWinDriveLetters); if(!g_pVSSClient->CreateSnapshots(szWinDriveLetters)) { logp("Generate VSS snapshots failed.\n"); errors++; } else { int i; for(i=0; i<(int)strlen(szWinDriveLetters); i++) { logp("VSS drive letters: %d\n", i); if(islower(szWinDriveLetters[i])) { logp(_("Generate VSS snapshot of drive \"%c:\\\" failed.\n"), szWinDriveLetters[i]); errors++; } } for(i=0; i<(int)g_pVSSClient->GetWriterCount(); i++) { logp("VSS writer count: %d\n", i); if(g_pVSSClient->GetWriterState(i)<1) { logp("VSS Writer (PrepareForBackup): %s\n", g_pVSSClient->GetWriterInfo(i)); errors++; } } } } else { berrno be; berrno_init(&be); logp("VSS was not initialized properly.\n"); logp("VSS support is disabled. ERR=%s\n", berrno_bstrerror(&be, b_errno_win32)); errors++; } return errors; }
LLSD LLDXHardware::getDisplayInfo() { LLTimer hw_timer; HRESULT hr; LLSD ret; CoInitialize(NULL); IDxDiagProvider *dx_diag_providerp = NULL; IDxDiagContainer *dx_diag_rootp = NULL; IDxDiagContainer *devices_containerp = NULL; IDxDiagContainer *device_containerp = NULL; IDxDiagContainer *file_containerp = NULL; IDxDiagContainer *driver_containerp = NULL; // CoCreate a IDxDiagProvider* llinfos << "CoCreateInstance IID_IDxDiagProvider" << llendl; hr = CoCreateInstance(CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER, IID_IDxDiagProvider, (LPVOID*) &dx_diag_providerp); if (FAILED(hr)) { llwarns << "No DXDiag provider found! DirectX 9 not installed!" << llendl; gWriteDebug("No DXDiag provider found! DirectX 9 not installed!\n"); goto LCleanup; } if (SUCCEEDED(hr)) // if FAILED(hr) then dx9 is not installed { // Fill out a DXDIAG_INIT_PARAMS struct and pass it to IDxDiagContainer::Initialize // Passing in TRUE for bAllowWHQLChecks, allows dxdiag to check if drivers are // digital signed as logo'd by WHQL which may connect via internet to update // WHQL certificates. DXDIAG_INIT_PARAMS dx_diag_init_params; ZeroMemory(&dx_diag_init_params, sizeof(DXDIAG_INIT_PARAMS)); dx_diag_init_params.dwSize = sizeof(DXDIAG_INIT_PARAMS); dx_diag_init_params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION; dx_diag_init_params.bAllowWHQLChecks = TRUE; dx_diag_init_params.pReserved = NULL; llinfos << "dx_diag_providerp->Initialize" << llendl; hr = dx_diag_providerp->Initialize(&dx_diag_init_params); if(FAILED(hr)) { goto LCleanup; } llinfos << "dx_diag_providerp->GetRootContainer" << llendl; hr = dx_diag_providerp->GetRootContainer( &dx_diag_rootp ); if(FAILED(hr) || !dx_diag_rootp) { goto LCleanup; } HRESULT hr; // Get display driver information llinfos << "dx_diag_rootp->GetChildContainer" << llendl; hr = dx_diag_rootp->GetChildContainer(L"DxDiag_DisplayDevices", &devices_containerp); if(FAILED(hr) || !devices_containerp) { goto LCleanup; } // Get device 0 llinfos << "devices_containerp->GetChildContainer" << llendl; hr = devices_containerp->GetChildContainer(L"0", &device_containerp); if(FAILED(hr) || !device_containerp) { goto LCleanup; } // Get the English VRAM string std::string ram_str = get_string(device_containerp, L"szDisplayMemoryEnglish"); // Dump the string as an int into the structure char *stopstring; ret["VRAM"] = strtol(ram_str.c_str(), &stopstring, 10); std::string device_name = get_string(device_containerp, L"szDescription"); ret["DeviceName"] = device_name; std::string device_driver= get_string(device_containerp, L"szDriverVersion"); ret["DriverVersion"] = device_driver; } LCleanup: SAFE_RELEASE(file_containerp); SAFE_RELEASE(driver_containerp); SAFE_RELEASE(device_containerp); SAFE_RELEASE(devices_containerp); SAFE_RELEASE(dx_diag_rootp); SAFE_RELEASE(dx_diag_providerp); CoUninitialize(); return ret; }
bool pp6day2muon() { //------Get the input file location bool success; std::string input; std::cout << " Type in the name of the file that you want to analyse with its location (e.g. \"../pp6calculator.git/observedparticles.dat\"): " << std::endl; input = get_string(success); //Define variables int numberofmuons(0), numberofantimuons(0); //Part 1 of homework day 1 prints out mu+ and mu- properties in run4.dat success = count(input,numberofmuons,numberofantimuons); //------------Define new arrays to hold values--------------- double muonE[numberofmuons]; double muonpx[numberofmuons]; double muonpy[numberofmuons]; double muonpz[numberofmuons]; int muonevtnumber[numberofmuons]; double antimuonE[numberofantimuons]; double antimuonpx[numberofantimuons]; double antimuonpy[numberofantimuons]; double antimuonpz[numberofantimuons]; int antimuonevtnumber[numberofantimuons]; //-------------------------------------------------------------- // Store the Event#,energy,px,py,pz values in the newly defined variables for mu+, mu- success = store4momentum(input,muonE,antimuonE,muonpx,antimuonpx,muonpy,antimuonpy,muonpz,antimuonpz,muonevtnumber,antimuonevtnumber); //Define variables to hold invariant mass int numberofinvmass2part = (numberofantimuons*numberofmuons); double M2[numberofinvmass2part]; int indexM2[numberofinvmass2part]; //-----------Get Invariant mass of mu+/mu- combinations------------------------- for(int j = 0; j < numberofmuons; j++) { for(int k = 0; k < numberofantimuons; k++) { M2[j*numberofantimuons+k] = InvMass2part(muonE[j], muonpx[j], muonpy[j], muonpz[j], antimuonE[k], antimuonpx[k], antimuonpy[k], antimuonpz[k]); indexM2[j*numberofantimuons+k] = j*numberofantimuons + k; } } //------------------------------------------------------------------------------- //sorts the inv. mass and it's corresponding index array according to descending value. bubble_sort_2(M2,indexM2,numberofinvmass2part,success); //------------Results------------------------------------- std::cout << "The 10 largest to lowest invariant mass that we got out of mu+/mu- combinations are: " << std::endl; for (int i = 0; i < 10; i++) { for(int j = 0; j < numberofmuons; j++) { for(int k = 0; k < numberofantimuons; k++) { int x = j*numberofantimuons+k; if(x == indexM2[i]) { std::cout<< "("<< i <<") Invariant Mass of mu+/mu- " << M2[i] << " the corresponding event number of mu+ is " << muonevtnumber[j] <<" and for mu- is " << antimuonevtnumber[k] << std::endl; success = true; } else { continue; } } } } //------------End of Results--------------------------------- return success; }
int eap_mschap(struct iked *env, struct iked_sa *sa, struct eap_message *eap) { struct iked_user *usr; struct eap_message *resp; struct eap_mschap_response *msr; struct eap_mschap_peer *msp; struct eap_mschap *ms; struct eap_mschap_success *mss; u_int8_t *ptr, *pass; size_t len, passlen; char *name, *msg; u_int8_t ntresponse[EAP_MSCHAP_NTRESPONSE_SZ]; u_int8_t successmsg[EAP_MSCHAP_SUCCESS_SZ]; struct ibuf *eapmsg = NULL; int ret = -1; if (!sa_stateok(sa, IKEV2_STATE_EAP)) { log_debug("%s: unexpected EAP", __func__); return (0); /* ignore */ } if (sa->sa_hdr.sh_initiator) { log_debug("%s: initiator EAP not supported", __func__); return (-1); } /* Only MSCHAP-V2 */ if (eap->eap_type != EAP_TYPE_MSCHAP_V2) { log_debug("%s: unsupported type EAP-%s", __func__, print_map(eap->eap_type, eap_type_map)); return (-1); } if (betoh16(eap->eap_length) < (sizeof(*eap) + sizeof(*ms))) { log_debug("%s: short message", __func__); return (-1); } ms = (struct eap_mschap *)(eap + 1); ptr = (u_int8_t *)(eap + 1); switch (ms->ms_opcode) { case EAP_MSOPCODE_RESPONSE: msr = (struct eap_mschap_response *)ms; if (betoh16(eap->eap_length) < (sizeof(*eap) + sizeof(*msr))) { log_debug("%s: short response", __func__); return (-1); } ptr += sizeof(*msr); len = betoh16(eap->eap_length) - sizeof(*eap) - sizeof(*msr); if (len == 0 && sa->sa_eapid != NULL) name = strdup(sa->sa_eapid); else name = get_string(ptr, len); if (name == NULL) { log_debug("%s: invalid response name", __func__); return (-1); } if ((usr = user_lookup(env, name)) == NULL) { log_debug("%s: unknown user '%s'", __func__, name); free(name); return (-1); } free(name); if ((pass = string2unicode(usr->usr_pass, &passlen)) == NULL) return (-1); msp = &msr->msr_response.resp_peer; mschap_nt_response(ibuf_data(sa->sa_eap.id_buf), msp->msp_challenge, usr->usr_name, strlen(usr->usr_name), pass, passlen, ntresponse); if (memcmp(ntresponse, msp->msp_ntresponse, sizeof(ntresponse)) != 0) { log_debug("%s: '%s' authentication failed", __func__, usr->usr_name); free(pass); /* XXX should we send an EAP failure packet? */ return (-1); } bzero(&successmsg, sizeof(successmsg)); mschap_auth_response(pass, passlen, ntresponse, ibuf_data(sa->sa_eap.id_buf), msp->msp_challenge, usr->usr_name, strlen(usr->usr_name), successmsg); if ((sa->sa_eapmsk = ibuf_new(NULL, MSCHAP_MSK_SZ)) == NULL) { log_debug("%s: failed to get MSK", __func__); free(pass); return (-1); } mschap_msk(pass, passlen, ntresponse, ibuf_data(sa->sa_eapmsk)); free(pass); log_info("%s: '%s' authenticated", __func__, usr->usr_name); if ((eapmsg = ibuf_static()) == NULL) return (-1); msg = " M=Welcome"; if ((resp = ibuf_advance(eapmsg, sizeof(*resp))) == NULL) goto done; resp->eap_code = EAP_CODE_REQUEST; resp->eap_id = eap->eap_id + 1; resp->eap_length = htobe16(sizeof(*resp) + sizeof(*mss) + sizeof(successmsg) + strlen(msg)); resp->eap_type = EAP_TYPE_MSCHAP_V2; if ((mss = ibuf_advance(eapmsg, sizeof(*mss))) == NULL) goto done; mss->mss_opcode = EAP_MSOPCODE_SUCCESS; mss->mss_id = msr->msr_id; mss->mss_length = htobe16(sizeof(*mss) + sizeof(successmsg) + strlen(msg)); if (ibuf_add(eapmsg, successmsg, sizeof(successmsg)) != 0) goto done; if (ibuf_add(eapmsg, msg, strlen(msg)) != 0) goto done; break; case EAP_MSOPCODE_SUCCESS: if ((eapmsg = ibuf_static()) == NULL) return (-1); if ((resp = ibuf_advance(eapmsg, sizeof(*resp))) == NULL) goto done; resp->eap_code = EAP_CODE_RESPONSE; resp->eap_id = eap->eap_id; resp->eap_length = htobe16(sizeof(*resp) + sizeof(*ms)); resp->eap_type = EAP_TYPE_MSCHAP_V2; if ((ms = ibuf_advance(eapmsg, sizeof(*ms))) == NULL) goto done; ms->ms_opcode = EAP_MSOPCODE_SUCCESS; break; case EAP_MSOPCODE_FAILURE: case EAP_MSOPCODE_CHANGE_PASSWORD: case EAP_MSOPCODE_CHALLENGE: default: log_debug("%s: EAP-%s unsupported " "responder operation %s", __func__, print_map(eap->eap_type, eap_type_map), print_map(ms->ms_opcode, eap_msopcode_map)); return (-1); } if (eapmsg != NULL) ret = ikev2_send_ike_e(env, sa, eapmsg, IKEV2_PAYLOAD_EAP, IKEV2_EXCHANGE_IKE_AUTH, 1); if (ret == 0) sa_state(env, sa, IKEV2_STATE_AUTH_SUCCESS); done: ibuf_release(eapmsg); return (ret); }
int probe_main(probe_ctx *ctx, void *mutex) { LDAP *ldp; LDAPMessage *ldpres, *entry; SEXP_t *se_ldap_behaviors = NULL, *se_relative_dn = NULL; SEXP_t *se_suffix = NULL, *se_attribute = NULL; SEXP_t *sa_scope, *sv_op; SEXP_t *item; SEXP_t *probe_in; char *relative_dn = NULL; char *suffix = NULL, *xattribute = NULL; char *uri_list, *uri, *uri_save, *attr; int scope; char base[2048]; char *attrs[3]; bool a_pattern_match = false, rdn_pattern_match = false; /* runtime */ #if defined(PROBE_LDAP_MUTEX) assume_r(mutex != NULL, PROBE_EINIT); #endif probe_in = probe_ctx_getobject(ctx); se_ldap_behaviors = probe_obj_getent(probe_in, "behaviors", 1); if (se_ldap_behaviors != NULL) { sa_scope = probe_ent_getattrval(se_ldap_behaviors, "scope"); SEXP_free(se_ldap_behaviors); if (sa_scope == NULL) { dE("Atrribute `scope' is missing!"); return (PROBE_ENOATTR); } if (!SEXP_stringp(sa_scope)) { dE("Invalid value type of the `scope' attribute."); SEXP_free(sa_scope); return (PROBE_EINVAL); } if (SEXP_strcmp(sa_scope, "ONE") == 0) scope = LDAP_SCOPE_ONELEVEL; else if (SEXP_strcmp(sa_scope, "BASE") == 0) scope = LDAP_SCOPE_BASE; else if (SEXP_strcmp(sa_scope, "SUBTREE") == 0) scope = LDAP_SCOPE_SUBTREE; else { dE("Invalid value of the `scope' attribute."); SEXP_free(sa_scope); return (PROBE_EINVAL); } SEXP_free(sa_scope); } else scope = LDAP_SCOPE_BASE; #define get_string(dst, se_dst, obj, ent_name) \ do { \ SEXP_t *__sval; \ \ __sval = probe_obj_getentval (obj, ent_name, 1); \ \ if (__sval != NULL) { \ (dst) = SEXP_string_cstr (__sval); \ \ if ((dst) == NULL) { \ SEXP_free(__sval); \ return (PROBE_EINVAL); \ } \ \ (se_dst) = __sval; \ } else { \ return (PROBE_ENOATTR); \ } \ } while (0) get_string(suffix, se_suffix, probe_in, "suffix"); get_string(relative_dn, se_relative_dn, probe_in, "relative_dn"); get_string(xattribute, se_attribute, probe_in, "attribute"); if ((sv_op = probe_ent_getattrval(se_relative_dn, "operation")) != NULL) { if (SEXP_number_geti_32(sv_op) == OVAL_OPERATION_PATTERN_MATCH) rdn_pattern_match = true; SEXP_free(sv_op); } if ((sv_op = probe_ent_getattrval(se_attribute, "operation")) != NULL) { if (SEXP_number_geti_32(sv_op) == OVAL_OPERATION_PATTERN_MATCH) a_pattern_match = true; SEXP_free(sv_op); } /* * Construct the attribute array for ldap_search_* * * nil -> "1.1" * .* -> "*" * "foo" -> "foo" */ attrs[0] = "objectClass"; if (xattribute == NULL) attrs[1] = strdup("1.1"); /* no attibutes */ else if (a_pattern_match) attrs[1] = strdup("*"); /* collect all, we'll filter them afterwards */ else attrs[1] = xattribute; /* no pattern match, use the string directly */ attrs[2] = NULL; /* * Construct `base' */ assume_r(((relative_dn ? strlen(relative_dn) : 0) + ( suffix ? strlen(suffix) : 0) + 2) < (sizeof base/sizeof(char)), PROBE_ERANGE); if (relative_dn != NULL) { strcpy(base, relative_dn); strcat(base, ","); strcat(base, suffix); } else strcpy(base, suffix); /* * Get URIs */ if (ldap_get_option(NULL, LDAP_OPT_URI, &uri_list) != LDAP_OPT_SUCCESS) { item = probe_item_creat("ldap57_item", NULL, NULL); probe_item_setstatus(item, SYSCHAR_STATUS_ERROR); probe_item_collect(ctx, item); dE("ldap_get_option failed"); goto fail0; } /* * Query each URI */ for (;;) { char *entry_dn = NULL; if ((uri = strtok_r(uri_list, " ,", &uri_save)) == NULL) break; ldp = NULL; if (ldap_initialize(&ldp, uri) != LDAP_SUCCESS) continue; if (ldap_search_ext_s(ldp, base, scope, NULL, attrs, 0, NULL /* serverctrls */, NULL /* clientctrls */, NULL /* timeout */, 0, &ldpres) != LDAP_SUCCESS) { item = probe_item_creat("ldap57_item", NULL, NULL); probe_item_setstatus(item, SYSCHAR_STATUS_ERROR); probe_item_collect(ctx, item); dE("ldap_search_ext_s failed"); goto fail0; } entry = ldap_first_entry(ldp, ldpres); entry_dn = ldap_get_dn(ldp, entry); while (entry != NULL) { BerElement *berelm = NULL; attr = ldap_first_attribute(ldp, entry, &berelm); /* XXX: pattern match filter */ while (attr != NULL) { SEXP_t *se_value = NULL; ber_tag_t bertag = LBER_DEFAULT; ber_len_t berlen = 0; Sockbuf *berbuf = NULL; SEXP_t se_tmp_mem; berbuf = ber_sockbuf_alloc(); /* * Prepare the value (record) entity. Collect only * primitive (i.e. simple) types. */ se_value = probe_ent_creat1("value", NULL, NULL); probe_ent_setdatatype(se_value, OVAL_DATATYPE_RECORD); /* * XXX: does ber_get_next() return LBER_ERROR after the last value? */ while ((bertag = ber_get_next(berbuf, &berlen, berelm)) != LBER_ERROR) { SEXP_t *field = NULL; oval_datatype_t field_type = OVAL_DATATYPE_UNKNOWN; switch(bertag & LBER_ENCODING_MASK) { case LBER_PRIMITIVE: dI("Found primitive value, bertag = %u", bertag); break; case LBER_CONSTRUCTED: dW("Don't know how to handle LBER_CONSTRUCTED values"); /* FALLTHROUGH */ default: dW("Skipping attribute value, bertag = %u", bertag); continue; } assume_d(bertag & LBER_PRIMITIVE, NULL); switch(bertag & LBER_BIG_TAG_MASK) { case LBER_BOOLEAN: { /* LDAPTYPE_BOOLEAN */ ber_int_t val = -1; if (ber_get_boolean(berelm, &val) == LBER_ERROR) { dW("ber_get_boolean: LBER_ERROR"); /* XXX: set error status on field */ continue; } assume_d(val != -1, NULL); field = probe_ent_creat1("field", NULL, SEXP_number_newb_r(&se_tmp_mem, (bool)val)); field_type = OVAL_DATATYPE_BOOLEAN; SEXP_free_r(&se_tmp_mem); } break; case LBER_INTEGER: { /* LDAPTYPE_INTEGER */ ber_int_t val = -1; if (ber_get_int(berelm, &val) == LBER_ERROR) { dW("ber_get_int: LBER_ERROR"); /* XXX: set error status on field */ continue; } field = probe_ent_creat1("field", NULL, SEXP_number_newi_r(&se_tmp_mem, (int)val)); field_type = OVAL_DATATYPE_INTEGER; SEXP_free_r(&se_tmp_mem); } break; case LBER_BITSTRING: /* LDAPTYPE_BIT_STRING */ dW("LBER_BITSTRING: not implemented"); continue; case LBER_OCTETSTRING: { /* * LDAPTYPE_PRINTABLE_STRING * LDAPTYPE_NUMERIC_STRING * LDAPTYPE_DN_STRING * LDAPTYPE_BINARY (?) */ char *val = NULL; if (ber_get_stringa(berelm, &val) == LBER_ERROR) { dW("ber_get_stringa: LBER_ERROR"); /* XXX: set error status on field */ continue; } assume_d(val != NULL, NULL); field = probe_ent_creat1("field", NULL, SEXP_string_new_r(&se_tmp_mem, val, strlen(val))); field_type = OVAL_DATATYPE_STRING; SEXP_free_r(&se_tmp_mem); ber_memfree(val); } break; case LBER_NULL: /* XXX: no equivalent LDAPTYPE_? or empty */ dI("LBER_NULL: skipped"); continue; case LBER_ENUMERATED: /* XXX: no equivalent LDAPTYPE_? */ dW("Don't know how to handle LBER_ENUMERATED type"); continue; default: dW("Unknown attribute value type, bertag = %u", bertag); continue; } if (field != NULL) { assume_d(field_type != OVAL_DATATYPE_UNKNOWN, NULL); probe_ent_setdatatype(field, field_type); probe_ent_attr_add(field, "name", SEXP_string_new_r(&se_tmp_mem, attr, strlen(attr))); SEXP_list_add(se_value, field); SEXP_free_r(&se_tmp_mem); SEXP_free(field); } } ber_sockbuf_free(berbuf); /* * Create the item */ item = probe_item_create(OVAL_INDEPENDENT_LDAP57, NULL, "suffix", OVAL_DATATYPE_STRING, suffix, "relative_dn", OVAL_DATATYPE_STRING, relative_dn, /* XXX: pattern match */ "attribute", OVAL_DATATYPE_STRING, attr, "object_class", OVAL_DATATYPE_STRING, "", "ldaptype", OVAL_DATATYPE_STRING, "", NULL); SEXP_list_add(item, se_value); SEXP_free(se_value); probe_item_collect(ctx, item); attr = ldap_next_attribute(ldp, entry, berelm); } ber_free(berelm, 0); ldap_memfree(entry_dn); entry = ldap_next_entry(ldp, entry); entry_dn = ldap_get_dn(ldp, entry); } /* * Close the LDAP connection and free resources */ ldap_unbind_ext_s(ldp, NULL, NULL); } ldap_memfree(uri_list); fail0: SEXP_free(se_suffix); SEXP_free(se_relative_dn); SEXP_free(se_attribute); free(suffix); free(relative_dn); free(attrs[1]); /* attribute */ return (0); }
void frontend_draw_define_key(struct GuiButton *gbtn) { long content, key_id; content = (long)gbtn->content; key_id = define_key_scroll_offset - content - 1; if (key_id >= GAME_KEYS_COUNT) { return; } unsigned char code; code = settings.kbkeys[key_id].code; long i; char chbuf[4]; const char * keyname; i = key_to_string[code]; if (i >= 0) { keyname = get_string(i); } else { chbuf[0] = -(char)i; chbuf[1] = 0; keyname = chbuf; } if (frontend_mouse_over_button == content) { LbTextSetFont(frontend_font[2]); } else { LbTextSetFont(frontend_font[1]); } lbDisplay.DrawFlags = Lb_TEXT_HALIGN_LEFT; int tx_units_per_px; // This text is a bit condensed - button size is smaller than text height tx_units_per_px = (gbtn->height*13/11) * 16 / LbTextLineHeight(); LbTextSetWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, gbtn->height); int height; height = LbTextLineHeight() * tx_units_per_px / 16; LbTextDrawResized(0, (gbtn->height - height) / 2, tx_units_per_px, get_string(definable_key_string[key_id])); unsigned char mods; mods = settings.kbkeys[key_id].mods; lbDisplay.DrawFlags = Lb_TEXT_HALIGN_RIGHT; char text[255]; text[0] = '\0'; if (mods & KMod_CONTROL) { strcat(text, get_string(GUIStr_KeyControl)); strcat(text, " "); } if (mods & KMod_ALT) { strcat(text, get_string(GUIStr_KeyAlt)); strcat(text, " "); } if (mods & KMod_SHIFT) { strcat(text, get_string(GUIStr_KeyShift)); strcat(text, " "); } const char *keytext; switch (code) { case KC_LSHIFT: case KC_RSHIFT: keytext = get_string(GUIStr_KeyShift); break; case KC_LCONTROL: case KC_RCONTROL: keytext = get_string(GUIStr_KeyControl); break; case KC_LALT: case KC_RALT: keytext = get_string(GUIStr_KeyAlt); break; default: keytext = keyname; break; } strcat(text, keytext); height = LbTextLineHeight() * tx_units_per_px / 16; LbTextDrawResized(0, (gbtn->height - height) / 2, tx_units_per_px, text); }
/* * Get the local->global table. Store it as an array from 0 and up, * this is waste of memory but we do not care right now. */ static void read_lgtable(struct get_conf_stat_store *g) { int top, i, base, cont, cnt, num; if (g->mapsz) return; /* Done already */ #if 0 /* It seems like some real conferences are marked as letterboxes. * so the below code seems to do more harm than good. /oj */ if (g->number != myuid && g->confer.rc_type & RK_CONF_TYPE_LETTERBOX) return; /* Do not try to read someones letterbox. */ #endif /* * First get the highest local text number. */ if (send_reply("78 %d\n", g->number)) { get_eat('\n'); /* Do what??? */ return; } get_string(); get_int(); top = get_int(); g->mapsz = top + 50; get_int(); get_accept('\n'); g->map = calloc(g->mapsz, sizeof(int)); base = 1; for (;;) { if (send_reply("103 %d %d 200\n", g->number, base)) { get_eat('\n'); return; /* XXX ??? */ } get_int(); base = get_int(); cont = get_int(); if (get_int() == 0) { /* Sparse block */ cnt = get_int(); if (cnt != 0) { get_accept('{'); for (i = 0; i < cnt; i++) { num = get_int(); g->map[num] = get_int(); } get_accept('}'); } else get_accept('*'); } else { /* Dense block */ num = get_int(); cnt = get_int(); get_accept('{'); for (i = 0; i < cnt; i++) g->map[num++] = get_int(); get_accept('}'); } get_accept('\n'); if (cont == 0) break; } }
std::string& last_name() const { return get_string("last_name"); }
static void check_regression (void) { mpfr_t x, y, z; int i; FILE *fp; char s[BUFSIZE]; mpfr_inits2 (6177, x, y, z, (mpfr_ptr) 0); /* we read long strings from a file since ISO C90 does not support strings of length > 509 */ fp = src_fopen ("tmul.dat", "r"); if (fp == NULL) { fprintf (stderr, "Error, cannot open tmul.dat in srcdir\n"); exit (1); } get_string (s, fp); mpfr_set_str (y, s, 16, MPFR_RNDN); get_string (s, fp); mpfr_set_str (z, s, 16, MPFR_RNDN); i = mpfr_mul (x, y, z, MPFR_RNDN); get_string (s, fp); if (mpfr_cmp_str (x, s, 16, MPFR_RNDN) != 0 || i != -1) { printf ("Regression test 1 failed (i=%d, expected -1)\nx=", i); mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); putchar ('\n'); exit (1); } fclose (fp); mpfr_set_prec (x, 606); mpfr_set_prec (y, 606); mpfr_set_prec (z, 606); mpfr_set_str (y, "-f.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff92daefc3f8052ca9f58736564d9e93e62d324@-1", 16, MPFR_RNDN); mpfr_set_str (z, "-f.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff92daefc3f8052ca9f58736564d9e93e62d324@-1", 16, MPFR_RNDN); i = mpfr_mul (x, y, z, MPFR_RNDU); mpfr_set_str (y, "f.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff25b5df87f00a5953eb0e6cac9b3d27cc5a64c@-1", 16, MPFR_RNDN); if (mpfr_cmp (x, y) || i <= 0) { printf ("Regression test (2) failed! (i=%d - Expected 1)\n", i); mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); putchar ('\n'); exit (1); } mpfr_set_prec (x, 184); mpfr_set_prec (y, 92); mpfr_set_prec (z, 1023); mpfr_set_str (y, "6.9b8c8498882770d8038c3b0@-1", 16, MPFR_RNDN); mpfr_set_str (z, "7.44e24b986e7fb296f1e936ce749fec3504cbf0d5ba769466b1c9f1578115efd5d29b4c79271191a920a99280c714d3a657ad6e3afbab77ffce9d697e9bb9110e26d676069afcea8b69f1d1541f2365042d80a97c21dcccd8ace4f1bb58b49922003e738e6f37bb82ef653cb2e87f763974e6ae50ae54e7724c38b80653e3289@255", 16, MPFR_RNDN); i = mpfr_mul (x, y, z, MPFR_RNDU); mpfr_set_prec (y, 184); mpfr_set_str (y, "3.0080038f2ac5054e3e71ccbb95f76aaab2221715025a28@255", 16, MPFR_RNDN); if (mpfr_cmp (x, y) || i <= 0) { printf ("Regression test (4) failed! (i=%d - expected 1)\n", i); printf ("Ref: 3.0080038f2ac5054e3e71ccbb95f76aaab2221715025a28@255\n" "Got: "); mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); printf ("\n"); exit (1); } mpfr_set_prec (x, 908); mpfr_set_prec (y, 908); mpfr_set_prec (z, 908); mpfr_set_str (y, "-f.fffffffffffffffffffffffffffffffffffffffffffffffffffffff" "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "ffffffffffffffffffffffffffffffffffffffffffffffffffffff99be91f83ec6f0ed28a3d42" "e6e9a327230345ea6@-1", 16, MPFR_RNDN); mpfr_set_str (z, "-f.fffffffffffffffffffffffffffffffffffffffffffffffffffffff" "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "ffffffffffffffffffffffffffffffffffffffffffffffffffffff99be91f83ec6f0ed28a3d42" "e6e9a327230345ea6@-1", 16, MPFR_RNDN); i = mpfr_mul (x, y, z, MPFR_RNDU); mpfr_set_str (y, "f.ffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "fffffffffffffffffffffffffffffffffffffffffffffffffffff337d23f07d8de1da5147a85c" "dd3464e46068bd4d@-1", 16, MPFR_RNDN); if (mpfr_cmp (x, y) || i <= 0) { printf ("Regression test (5) failed! (i=%d - expected 1)\n", i); mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); printf ("\n"); exit (1); } mpfr_set_prec (x, 50); mpfr_set_prec (y, 40); mpfr_set_prec (z, 53); mpfr_set_str (y, "4.1ffffffff8", 16, MPFR_RNDN); mpfr_set_str (z, "4.2000000ffe0000@-4", 16, MPFR_RNDN); i = mpfr_mul (x, y, z, MPFR_RNDN); if (mpfr_cmp_str (x, "1.104000041d6c0@-3", 16, MPFR_RNDN) != 0 || i <= 0) { printf ("Regression test (6) failed! (i=%d - expected 1)\nx=", i); mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); printf ("\nMore prec="); mpfr_set_prec (x, 93); mpfr_mul (x, y, z, MPFR_RNDN); mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); printf ("\n"); exit (1); } mpfr_set_prec (x, 439); mpfr_set_prec (y, 393); mpfr_set_str (y, "-1.921fb54442d18469898cc51701b839a252049c1114cf98e804177d" "4c76273644a29410f31c6809bbdf2a33679a748636600", 16, MPFR_RNDN); i = mpfr_mul (x, y, y, MPFR_RNDU); if (mpfr_cmp_str (x, "2.77a79937c8bbcb495b89b36602306b1c2159a8ff834288a19a08" "84094f1cda3dc426da61174c4544a173de83c2500f8bfea2e0569e3698", 16, MPFR_RNDN) != 0 || i <= 0) { printf ("Regression test (7) failed! (i=%d - expected 1)\nx=", i); mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); printf ("\n"); exit (1); } mpfr_set_prec (x, 1023); mpfr_set_prec (y, 1023); mpfr_set_prec (z, 511); mpfr_set_ui (x, 17, MPFR_RNDN); mpfr_set_ui (y, 42, MPFR_RNDN); i = mpfr_mul (z, x, y, MPFR_RNDN); if (mpfr_cmp_ui (z, 17*42) != 0 || i != 0) { printf ("Regression test (8) failed! (i=%d - expected 0)\nz=", i); mpfr_out_str (stdout, 16, 0, z, MPFR_RNDN); printf ("\n"); exit (1); } mpfr_clears (x, y, z, (mpfr_ptr) 0); }
std::string& password() const { return get_string("password"); }
std::string& first_name() const { return get_string("first_name"); }
std::string& username() const { return get_string("username"); }
std::string JSONBuilder::get_string(bool pretty) { std::unique_lock<std::mutex> lock(thread_safe_); Node node = std2::make_unique<RootNodeCopy>(builder_); std::string res = get_string(std::move(node), pretty); return res; }
/** * Reads in a vehicle part from a JsonObject. */ void vpart_info::load( JsonObject &jo, const std::string &src ) { vpart_info def; if( jo.has_string( "copy-from" ) ) { auto const base = vehicle_part_types.find( vpart_str_id( jo.get_string( "copy-from" ) ) ); auto const ab = abstract_parts.find( vpart_str_id( jo.get_string( "copy-from" ) ) ); if( base != vehicle_part_types.end() ) { def = base->second; } else if( ab != abstract_parts.end() ) { def = ab->second; } else { deferred.emplace_back( jo.str(), src ); } } if( jo.has_string( "abstract" ) ) { def.id = vpart_str_id( jo.get_string( "abstract" ) ); } else { def.id = vpart_str_id( jo.get_string( "id" ) ); } assign( jo, "name", def.name_ ); assign( jo, "item", def.item ); assign( jo, "location", def.location ); assign( jo, "durability", def.durability ); assign( jo, "damage_modifier", def.dmg_mod ); assign( jo, "power", def.power ); assign( jo, "epower", def.epower ); assign( jo, "fuel_type", def.fuel_type ); assign( jo, "folded_volume", def.folded_volume ); assign( jo, "size", def.size ); assign( jo, "difficulty", def.difficulty ); assign( jo, "bonus", def.bonus ); assign( jo, "flags", def.flags ); auto reqs = jo.get_object( "requirements" ); if( reqs.has_object( "install" ) ) { auto ins = reqs.get_object( "install" ); auto sk = ins.get_array( "skills" ); if( !sk.empty() ) { def.install_skills.clear(); } while( sk.has_more() ) { auto cur = sk.next_array(); def.install_skills.emplace( skill_id( cur.get_string( 0 ) ) , cur.size() >= 2 ? cur.get_int( 1 ) : 1 ); } assign( ins, "time", def.install_moves ); if( ins.has_string( "using" ) ) { def.install_reqs = { { requirement_id( ins.get_string( "using" ) ), 1 } }; } else if( ins.has_array( "using" ) ) { auto arr = ins.get_array( "using" ); while( arr.has_more() ) { auto cur = arr.next_array(); def.install_reqs.emplace_back( requirement_id( cur.get_string( 0 ) ), cur.get_int( 1 ) ); } } else { auto req_id = std::string( "inline_vehins_" ) += def.id.str(); requirement_data::load_requirement( ins, req_id ); def.install_reqs = { { requirement_id( req_id ), 1 } }; } def.legacy = false; } if( reqs.has_object( "removal" ) ) { auto rem = reqs.get_object( "removal" ); auto sk = rem.get_array( "skills" ); if( !sk.empty() ) { def.removal_skills.clear(); } while( sk.has_more() ) { auto cur = sk.next_array(); def.removal_skills.emplace( skill_id( cur.get_string( 0 ) ) , cur.size() >= 2 ? cur.get_int( 1 ) : 1 ); } assign( rem, "time", def.removal_moves ); if( rem.has_string( "using" ) ) { def.removal_reqs = { { requirement_id( rem.get_string( "using" ) ), 1 } }; } else if( rem.has_array( "using" ) ) { auto arr = rem.get_array( "using" ); while( arr.has_more() ) { auto cur = arr.next_array(); def.removal_reqs.emplace_back( requirement_id( cur.get_string( 0 ) ), cur.get_int( 1 ) ); } } else { auto req_id = std::string( "inline_vehins_" ) += def.id.str(); requirement_data::load_requirement( rem, req_id ); def.removal_reqs = { { requirement_id( req_id ), 1 } }; } def.legacy = false; } if( jo.has_member( "symbol" ) ) { def.sym = jo.get_string( "symbol" )[ 0 ]; } if( jo.has_member( "broken_symbol" ) ) { def.sym_broken = jo.get_string( "broken_symbol" )[ 0 ]; } if( jo.has_member( "color" ) ) { def.color = color_from_string( jo.get_string( "color" ) ); } if( jo.has_member( "broken_color" ) ) { def.color_broken = color_from_string( jo.get_string( "broken_color" ) ); } if( jo.has_member( "breaks_into" ) ) { JsonIn& stream = *jo.get_raw( "breaks_into" ); def.breaks_into_group = item_group::load_item_group( stream, "collection" ); } auto qual = jo.get_array( "qualities" ); if( !qual.empty() ) { def.qualities.clear(); while( qual.has_more() ) { auto pair = qual.next_array(); def.qualities[ quality_id( pair.get_string( 0 ) ) ] = pair.get_int( 1 ); } } if( jo.has_member( "damage_reduction" ) ) { JsonObject dred = jo.get_object( "damage_reduction" ); def.damage_reduction = load_damage_array( dred ); } else { def.damage_reduction.fill( 0.0f ); } if( jo.has_string( "abstract" ) ) { abstract_parts[ def.id ] = def; return; } auto const iter = vehicle_part_types.find( def.id ); if( iter != vehicle_part_types.end() ) { // Entry in the map already exists, so the pointer in the vector is already correct // and does not need to be changed, only the int-id needs to be taken from the old entry. def.loadid = iter->second.loadid; iter->second = def; } else { // The entry is new, "generate" a new int-id and link the new entry from the vector. def.loadid = vpart_id( vehicle_part_int_types.size() ); vpart_info &new_entry = vehicle_part_types[ def.id ]; new_entry = def; vehicle_part_int_types.push_back( &new_entry ); } }
/* * Try to create an item again. Output some statistics. -Bernd- * * The statistics are correct now. We acquire a clean grid, and then * repeatedly place an object in this grid, copying it into an item * holder, and then deleting the object. We fiddle with the artifact * counter flags to prevent weirdness. We use the items to collect * statistics on item creation relative to the initial item. */ static void wiz_statistics(object_type *o_ptr) { u32b i, matches, better, worse, other, correct; u32b test_roll = 1000000; char ch; cptr quality; u32b mode; object_type forge; object_type *q_ptr; cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld"; cptr p = "Enter number of items to roll: "; char tmp_val[80]; /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */ if (object_is_fixed_artifact(o_ptr)) a_info[o_ptr->name1].cur_num = 0; /* Interact */ while (TRUE) { cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? "; /* Display item */ wiz_display_item(o_ptr); /* Get choices */ if (!get_com(pmt, &ch, FALSE)) break; if (ch == 'n' || ch == 'N') { mode = 0L; quality = "normal"; } else if (ch == 'g' || ch == 'G') { mode = AM_GOOD; quality = "good"; } else if (ch == 'e' || ch == 'E') { mode = AM_GOOD | AM_GREAT; quality = "excellent"; } else { break; } sprintf(tmp_val, "%ld", test_roll); if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val); test_roll = MAX(1, test_roll); /* Let us know what we are doing */ msg_format("Creating a lot of %s items. Base level = %d.", quality, dun_level); msg_print(NULL); /* Set counters to zero */ correct = matches = better = worse = other = 0; /* Let's rock and roll */ for (i = 0; i <= test_roll; i++) { /* Output every few rolls */ if ((i < 100) || (i % 100 == 0)) { /* Do not wait */ inkey_scan = TRUE; /* Allow interupt */ if (inkey()) { /* Flush */ flush(); /* Stop rolling */ break; } /* Dump the stats */ prt(format(q, i, correct, matches, better, worse, other), 0, 0); Term_fresh(); } /* Get local object */ q_ptr = &forge; /* Wipe the object */ object_wipe(q_ptr); /* Create an object */ make_object(q_ptr, mode); /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */ if (object_is_fixed_artifact(q_ptr)) a_info[q_ptr->name1].cur_num = 0; /* Test for the same tval and sval. */ if ((o_ptr->tval) != (q_ptr->tval)) continue; if ((o_ptr->sval) != (q_ptr->sval)) continue; /* One more correct item */ correct++; /* Check for match */ if ((q_ptr->pval == o_ptr->pval) && (q_ptr->to_a == o_ptr->to_a) && (q_ptr->to_h == o_ptr->to_h) && (q_ptr->to_d == o_ptr->to_d) && (q_ptr->name1 == o_ptr->name1)) { matches++; } /* Check for better */ else if ((q_ptr->pval >= o_ptr->pval) && (q_ptr->to_a >= o_ptr->to_a) && (q_ptr->to_h >= o_ptr->to_h) && (q_ptr->to_d >= o_ptr->to_d)) { better++; } /* Check for worse */ else if ((q_ptr->pval <= o_ptr->pval) && (q_ptr->to_a <= o_ptr->to_a) && (q_ptr->to_h <= o_ptr->to_h) && (q_ptr->to_d <= o_ptr->to_d)) { worse++; } /* Assume different */ else { other++; } } /* Final dump */ msg_format(q, i, correct, matches, better, worse, other); msg_print(NULL); } /* Hack -- Normally only make a single artifact */ if (object_is_fixed_artifact(o_ptr)) a_info[o_ptr->name1].cur_num = 1; }
int champ_chooser_server(struct sdirs *sdirs, struct conf **confs, int resume) { int s; int ret=-1; int len; struct asfd *asfd=NULL; struct sockaddr_un local; struct lock *lock=NULL; struct async *as=NULL; int started=0; struct scores *scores=NULL; const char *directory=get_string(confs[OPT_DIRECTORY]); if(!(lock=lock_alloc_and_init(sdirs->champlock)) || build_path_w(sdirs->champlock)) goto end; lock_get(lock); switch(lock->status) { case GET_LOCK_GOT: log_fzp_set(sdirs->champlog, confs); logp("Got champ lock for dedup_group: %s\n", get_string(confs[OPT_DEDUP_GROUP])); break; case GET_LOCK_NOT_GOT: case GET_LOCK_ERROR: default: //logp("Did not get champ lock\n"); goto end; } if((s=socket(AF_UNIX, SOCK_STREAM, 0))<0) { logp("socket error in %s: %s\n", __func__, strerror(errno)); goto end; } memset(&local, 0, sizeof(struct sockaddr_un)); local.sun_family=AF_UNIX; snprintf(local.sun_path, sizeof(local.sun_path), "%s", sdirs->champsock); len=strlen(local.sun_path)+sizeof(local.sun_family)+1; unlink(sdirs->champsock); if(bind(s, (struct sockaddr *)&local, len)<0) { logp("bind error in %s: %s\n", __func__, strerror(errno)); goto end; } if(listen(s, 5)<0) { logp("listen error in %s: %s\n", __func__, strerror(errno)); goto end; } if(!(as=async_alloc()) || as->init(as, 0) || !(asfd=setup_asfd(as, "champ chooser main socket", &s, /*listen*/""))) goto end; asfd->fdtype=ASFD_FD_SERVER_LISTEN_MAIN; // I think that this is probably the best point at which to run a // cleanup job to delete unused data files, because no other process // can fiddle with the dedup_group at this point. // Cannot do it on a resume, or it will delete files that are // referenced in the backup we are resuming. if(delete_unused_data_files(sdirs, resume)) goto end; // Load the sparse indexes for this dedup group. if(!(scores=champ_chooser_init(sdirs->data))) goto end; while(1) { for(asfd=as->asfd->next; asfd; asfd=asfd->next) { if(!asfd->blist->head || asfd->blist->head->got==BLK_INCOMING) continue; if(results_to_fd(asfd)) goto end; } int removed; switch(as->read_write(as)) { case 0: // Check the main socket last, as it might add // a new client to the list. for(asfd=as->asfd->next; asfd; asfd=asfd->next) { while(asfd->rbuf->buf) { if(deal_with_client_rbuf(asfd, directory, scores)) goto end; // Get as much out of the // readbuf as possible. if(asfd->parse_readbuf(asfd)) goto end; } } if(as->asfd->new_client) { // Incoming client. as->asfd->new_client=0; if(champ_chooser_new_client(as, confs)) goto end; started=1; } break; default: removed=0; // Maybe one of the fds had a problem. // Find and remove it and carry on if possible. for(asfd=as->asfd->next; asfd; ) { struct asfd *a; if(!asfd->want_to_remove) { asfd=asfd->next; continue; } as->asfd_remove(as, asfd); logp("%s: disconnected fd %d\n", asfd->desc, asfd->fd); a=asfd->next; asfd_free(&asfd); asfd=a; removed++; } if(removed) break; // If we got here, there was no fd to remove. // It is a fatal error. goto end; } if(started && !as->asfd->next) { logp("All clients disconnected.\n"); ret=0; break; } } end: logp("champ chooser exiting: %d\n", ret); champ_chooser_free(&scores); log_fzp_set(NULL, confs); async_free(&as); asfd_free(&asfd); // This closes s for us. close_fd(&s); unlink(sdirs->champsock); // FIX THIS: free asfds. lock_release(lock); lock_free(&lock); return ret; }
void PCB_Grid::LoadGridSettings(CString fileName, BOOL warnFileOpen) { char line[255]; char *lp; FILE *fp; if ((fp = fopen(fileName,"rt")) == NULL) { if (warnFileOpen) ErrorMessage(fileName, "Unable to Open File!", MB_ICONEXCLAMATION | MB_OK); return; } double scale = 1; int decimal = GetDecimals(doc->getSettings().getPageUnits()); while (fgets(line,255,fp)) { if ((lp = get_string(line," \t\n")) == NULL) continue; if (lp[0] != '.') continue; if (!STRCMPI(lp,".Units")) { if ((lp = get_string(NULL," \t\n")) == NULL) continue; int units = GetUnitIndex(lp); if (units > -1) { m_pageUnits = units; scale = Units_Factor(units, doc->getSettings().getPageUnits()); } else { // unit error } } else if (!STRCMPI(lp,".Horizontal")) { if ((lp = get_string(NULL," \t\n")) == NULL) continue; m_horz = atoi(lp); if ((lp = get_string(NULL," \t\n")) == NULL) continue; m_hSteps = atoi(lp); if ((lp = get_string(NULL," \t\n")) == NULL) continue; setHSizePageUnits(atof(lp)); } else if (!STRCMPI(lp,".Vertical")) { if ((lp = get_string(NULL," \t\n")) == NULL) continue; m_vert = atoi(lp); if ((lp = get_string(NULL," \t\n")) == NULL) continue; m_vSteps = atoi(lp); if ((lp = get_string(NULL," \t\n")) == NULL) continue; setVSizePageUnits(atof(lp)); } else if (!STRCMPI(lp,".Thickness")) { if ((lp = get_string(NULL," \t\n")) == NULL) continue; m_gridThickness = atof(lp); } } fclose(fp); UpdateData(FALSE); }
void recipe_dictionary::load( JsonObject &jo, const std::string &src, bool uncraft ) { bool strict = src == "core"; recipe r; // defer entries dependent upon as-yet unparsed definitions if( jo.has_string( "copy-from" ) ) { auto base = jo.get_string( "copy-from" ); if( uncraft ) { if( !recipe_dict.uncraft.count( base ) ) { deferred.emplace_back( jo.str(), src ); return; } r = recipe_dict.uncraft[ base ]; } else { if( !recipe_dict.recipes.count( base ) ) { deferred.emplace_back( jo.str(), src ); return; } r = recipe_dict.recipes[ base ]; } } if( jo.has_string( "abstract" ) ) { r.ident_ = jo.get_string( "abstract" ); r.abstract = true; } else { r.ident_ = r.result = jo.get_string( "result" ); r.abstract = false; } if( !uncraft ) { if( jo.has_string( "id_suffix" ) ) { if( r.abstract ) { jo.throw_error( "abstract recipe cannot specify id_suffix", "id_suffix" ); } r.ident_ += "_" + jo.get_string( "id_suffix" ); } assign( jo, "category", r.category, strict ); assign( jo, "subcategory", r.subcategory, strict ); assign( jo, "reversible", r.reversible, strict ); } else { r.reversible = true; } assign( jo, "time", r.time, strict, 0 ); assign( jo, "difficulty", r.difficulty, strict, 0, MAX_SKILL ); assign( jo, "flags", r.flags ); // automatically set contained if we specify as container assign( jo, "contained", r.contained, strict ); r.contained |= assign( jo, "container", r.container, strict ); if( jo.has_array( "batch_time_factors" ) ) { auto batch = jo.get_array( "batch_time_factors" ); r.batch_rscale = batch.get_int( 0 ) / 100.0; r.batch_rsize = batch.get_int( 1 ); } assign( jo, "charges", r.charges ); assign( jo, "result_mult", r.result_mult ); assign( jo, "skill_used", r.skill_used, strict ); if( jo.has_member( "skills_required" ) ) { auto sk = jo.get_array( "skills_required" ); r.required_skills.clear(); if( sk.empty() ) { // clear all requirements } else if( sk.has_array( 0 ) ) { // multiple requirements while( sk.has_more() ) { auto arr = sk.next_array(); r.required_skills[skill_id( arr.get_string( 0 ) )] = arr.get_int( 1 ); } } else { // single requirement r.required_skills[skill_id( sk.get_string( 0 ) )] = sk.get_int( 1 ); } } // simplified autolearn sets requirements equal to required skills at finalization if( jo.has_bool( "autolearn" ) ) { assign( jo, "autolearn", r.autolearn ); } else if( jo.has_array( "autolearn" ) ) { r.autolearn = false; auto sk = jo.get_array( "autolearn" ); while( sk.has_more() ) { auto arr = sk.next_array(); r.autolearn_requirements[skill_id( arr.get_string( 0 ) )] = arr.get_int( 1 ); } } if( jo.has_member( "decomp_learn" ) ) { r.learn_by_disassembly.clear(); if( jo.has_int( "decomp_learn" ) ) { if( !r.skill_used ) { jo.throw_error( "decomp_learn specified with no skill_used" ); } assign( jo, "decomp_learn", r.learn_by_disassembly[r.skill_used] ); } else if( jo.has_array( "decomp_learn" ) ) { auto sk = jo.get_array( "decomp_learn" ); while( sk.has_more() ) { auto arr = sk.next_array(); r.learn_by_disassembly[skill_id( arr.get_string( 0 ) )] = arr.get_int( 1 ); } } } if( !uncraft && jo.has_member( "byproducts" ) ) { auto bp = jo.get_array( "byproducts" ); r.byproducts.clear(); while( bp.has_more() ) { auto arr = bp.next_array(); r.byproducts[ arr.get_string( 0 ) ] += arr.size() == 2 ? arr.get_int( 1 ) : 1; } } if( jo.has_member( "book_learn" ) ) { auto bk = jo.get_array( "book_learn" ); r.booksets.clear(); while( bk.has_more() ) { auto arr = bk.next_array(); r.booksets.emplace( arr.get_string( 0 ), arr.get_int( 1 ) ); } } // recipes not specifying any external requirements inherit from their parent recipe (if any) if( jo.has_string( "using" ) ) { r.reqs_external = { { requirement_id( jo.get_string( "using" ) ), 1 } }; } else if( jo.has_array( "using" ) ) { auto arr = jo.get_array( "using" ); r.reqs_external.clear(); while( arr.has_more() ) { auto cur = arr.next_array(); r.reqs_external.emplace_back( requirement_id( cur.get_string( 0 ) ), cur.get_int( 1 ) ); } } // inline requirements are always replaced (cannot be inherited) auto req_id = string_format( "inline_%s_%s", uncraft ? "uncraft" : "recipe", r.ident_.c_str() ); requirement_data::load_requirement( jo, req_id ); r.reqs_internal = { { requirement_id( req_id ), 1 } }; if( uncraft ) { recipe_dict.uncraft[ r.ident_ ] = r; } else { recipe_dict.recipes[ r.ident_ ] = r; } }
// cpool_info // { // u30 int_count // s32 integer[int_count] // u30 uint_count // u32 uinteger[uint_count] // u30 double_count // d64 double[double_count] // u30 string_count // string_info string[string_count] // u30 namespace_count // namespace_info namespace[namespace_count] // u30 ns_set_count // ns_set_info ns_set[ns_set_count] // u30 multiname_count // multiname_info multiname[multiname_count] // } void abc_def::read_cpool(stream* in) { int n; // integer pool n = in->read_vu30(); if (n > 0) { m_integer.resize(n); m_integer[0] = 0; // default value for (int i = 1; i < n; i++) { m_integer[i] = in->read_vs32(); IF_VERBOSE_PARSE(log_msg("cpool_info: integer[%d]=%d\n", i, m_integer[i])); } } else { IF_VERBOSE_PARSE(log_msg("cpool_info: no integer pool\n")); } // uinteger pool n = in->read_vu30(); if (n > 0) { m_uinteger.resize(n); m_uinteger[0] = 0; // default value for (int i = 1; i < n; i++) { m_uinteger[i] = in->read_vu32(); IF_VERBOSE_PARSE(log_msg("cpool_info: uinteger[%d]=%d\n", i, m_uinteger[i])); } } else { IF_VERBOSE_PARSE(log_msg("cpool_info: no uinteger pool\n")); } // double pool n = in->read_vu30(); if (n > 0) { m_double.resize(n); m_double[0] = 0; // default value for (int i = 1; i < n; i++) { m_double[i] = in->read_double(); IF_VERBOSE_PARSE(log_msg("cpool_info: double[%d]=%f\n", i, m_double[i])); } } else { IF_VERBOSE_PARSE(log_msg("cpool_info: no double pool\n")); } // string pool n = in->read_vu30(); if (n > 0) { m_string.resize(n); m_string[0] = ""; // default value for (int i = 1; i < n; i++) { int len = in->read_vs32(); in->read_string_with_length(len, &m_string[i]); IF_VERBOSE_PARSE(log_msg("cpool_info: string[%d]='%s'\n", i, m_string[i].c_str())); } } else { IF_VERBOSE_PARSE(log_msg("cpool_info: no string pool\n")); } // namespace pool n = in->read_vu30(); if (n > 0) { m_namespace.resize(n); namespac ns; m_namespace[0] = ns; // default value for (int i = 1; i < n; i++) { ns.m_kind = static_cast<namespac::kind>(in->read_u8()); ns.m_name = in->read_vu30(); m_namespace[i] = ns; // User-defined namespaces have kind CONSTANT_Namespace or // CONSTANT_ExplicitNamespace and a non-empty name. // System namespaces have empty names and one of the other kinds switch (ns.m_kind) { case namespac::CONSTANT_Namespace: case namespac::CONSTANT_ExplicitNamespace: //assert(*get_string(ns.m_name) != 0); break; case namespac::CONSTANT_PackageNamespace: case namespac::CONSTANT_PackageInternalNs: case namespac::CONSTANT_ProtectedNamespace: case namespac::CONSTANT_StaticProtectedNs: case namespac::CONSTANT_PrivateNs: //assert(*get_string(ns.m_name) == 0); break; default: assert(0); } IF_VERBOSE_PARSE(log_msg("cpool_info: namespace[%d]='%s', kind=0x%02X\n", i, get_string(ns.m_name), ns.m_kind)); } } else { IF_VERBOSE_PARSE(log_msg("cpool_info: no namespace pool\n")); } // namespace sets pool n = in->read_vu30(); if (n > 0) { m_ns_set.resize(n); swf_array<int> ns; m_ns_set[0] = ns; // default value for (int i = 1; i < n; i++) { int count = in->read_vu30(); ns.resize(count); for (int j = 0; j < count; j++) { ns[j] = in->read_vu30(); } m_ns_set[i] = ns; } } else { IF_VERBOSE_PARSE(log_msg("cpool_info: no namespace sets\n")); } // multiname pool n = in->read_vu30(); if (n > 0) { m_multiname.resize(n); multiname mn; m_multiname[0] = mn; // default value for (int i = 1; i < n; i++) { Uint8 kind = in->read_u8(); mn.m_kind = kind; switch (kind) { case multiname::CONSTANT_QName: case multiname::CONSTANT_QNameA: { mn.m_ns = in->read_vu30(); mn.m_name = in->read_vu30(); IF_VERBOSE_PARSE(log_msg("cpool_info: multiname[%d]='%s', ns='%s'\n", i, get_string(mn.m_name), get_namespace(mn.m_ns))); break; } case multiname::CONSTANT_RTQName: assert(0&&"todo"); break; case multiname::CONSTANT_RTQNameA: assert(0&&"todo"); break; case multiname::CONSTANT_RTQNameL: assert(0&&"todo"); break; case multiname::CONSTANT_RTQNameLA: assert(0&&"todo"); break; case multiname::CONSTANT_Multiname: case multiname::CONSTANT_MultinameA: mn.m_name = in->read_vu30(); mn.m_ns_set = in->read_vu30(); IF_VERBOSE_PARSE(log_msg("cpool_info: multiname[%d]='%s', ns_set='%s'\n", i, get_string(mn.m_name), "todo")); break; case multiname::CONSTANT_MultinameL: case multiname::CONSTANT_MultinameLA: mn.m_ns_set = in->read_vu30(); mn.m_name = -1; IF_VERBOSE_PARSE(log_msg("cpool_info: multiname[%d]=MultinameL, ns_set='%s'\n", i, "todo")); break; default: assert(0); } m_multiname[i] = mn; } } else { IF_VERBOSE_PARSE(log_msg("cpool_info: no multiname pool\n")); } }
std::string get_string(const Fbox &box) { return make_string( "[ min: %s - max: %s ]", get_string( box.min ).c_str(), get_string( box.max ).c_str() ); }
int do_restore_client(struct asfd *asfd, struct conf **confs, enum action act, int vss_restore) { int ret=-1; char msg[512]=""; struct sbuf *sb=NULL; struct blk *blk=NULL; BFILE *bfd=NULL; char *fullpath=NULL; char *style=NULL; char *datpath=NULL; struct cntr *cntr=get_cntr(confs); enum protocol protocol=get_protocol(confs); int strip=get_int(confs[OPT_STRIP]); int overwrite=get_int(confs[OPT_OVERWRITE]); const char *backup=get_string(confs[OPT_BACKUP]); const char *regex=get_string(confs[OPT_REGEX]); const char *restore_prefix=get_string(confs[OPT_RESTOREPREFIX]); const char *encryption_password=get_string(confs[OPT_ENCRYPTION_PASSWORD]); if(!(bfd=bfile_alloc())) goto end; bfile_init(bfd, 0, cntr); snprintf(msg, sizeof(msg), "%s %s:%s", act_str(act), backup?backup:"", regex?regex:""); logp("doing %s\n", msg); if(asfd->write_str(asfd, CMD_GEN, msg) || asfd->read_expect(asfd, CMD_GEN, "ok")) goto error; logp("doing %s confirmed\n", act_str(act)); #if defined(HAVE_WIN32) if(act==ACTION_RESTORE) win32_enable_backup_privileges(); #endif if(!(style=get_restore_style(asfd, confs))) goto error; if(!strcmp(style, RESTORE_SPOOL)) { if(restore_spool(asfd, confs, &datpath)) goto error; } else logp("Streaming restore direct\n"); printf("\n"); // if(get_int(confs[OPT_SEND_CLIENT_CNTR]) && cntr_recv(confs)) // goto error; if(!(sb=sbuf_alloc(protocol)) || (protocol==PROTO_2 && !(blk=blk_alloc()))) { log_and_send_oom(asfd, __func__); goto error; } while(1) { sbuf_free_content(sb); if(protocol==PROTO_1) sb->flags |= SBUF_CLIENT_RESTORE_HACK; switch(sbuf_fill_from_net(sb, asfd, blk, datpath, cntr)) { case 0: break; case 1: if(asfd->write_str(asfd, CMD_GEN, "restoreend_ok")) goto error; goto end; // It was OK. default: case -1: goto error; } if(protocol==PROTO_2 && blk->data) { int wret=0; if(act==ACTION_VERIFY) cntr_add(cntr, CMD_DATA, 1); else wret=write_data(asfd, bfd, blk); if(!datpath) blk_free_content(blk); blk->data=NULL; if(wret) goto error; continue; } switch(sb->path.cmd) { case CMD_DIRECTORY: case CMD_FILE: case CMD_ENC_FILE: case CMD_SOFT_LINK: case CMD_HARD_LINK: case CMD_SPECIAL: case CMD_METADATA: case CMD_ENC_METADATA: case CMD_VSS: case CMD_ENC_VSS: case CMD_VSS_T: case CMD_ENC_VSS_T: case CMD_EFS_FILE: if(strip) { int s; s=strip_path_components(asfd, sb, strip, cntr, protocol); if(s<0) goto error; if(s==0) { // Too many components stripped // - carry on. continue; } // It is OK, sb.path is now stripped. } free_w(&fullpath); if(!(fullpath=prepend_s(restore_prefix, sb->path.buf))) { log_and_send_oom(asfd, __func__); goto error; } if(act==ACTION_RESTORE) { strip_invalid_characters(&fullpath); if(!overwrite_ok(sb, overwrite, #ifdef HAVE_WIN32 bfd, #endif fullpath)) { char msg[512]=""; // Something exists at that path. snprintf(msg, sizeof(msg), "Path exists: %s\n", fullpath); if(restore_interrupt(asfd, sb, msg, cntr, protocol)) goto error; continue; } } break; case CMD_MESSAGE: case CMD_WARNING: log_recvd(&sb->path, cntr, 1); printf("\n"); continue; default: break; } switch(sb->path.cmd) { // These are the same in both protocol1 and protocol2. case CMD_DIRECTORY: if(restore_dir(asfd, sb, fullpath, act, cntr, protocol)) goto error; continue; case CMD_SOFT_LINK: case CMD_HARD_LINK: if(restore_link(asfd, sb, fullpath, act, cntr, protocol, restore_prefix)) goto error; continue; case CMD_SPECIAL: if(restore_special(asfd, sb, fullpath, act, cntr, protocol)) goto error; continue; default: break; } if(protocol==PROTO_2) { if(restore_switch_protocol2(asfd, sb, fullpath, act, bfd, vss_restore, cntr)) goto error; } else { if(restore_switch_protocol1(asfd, sb, fullpath, act, bfd, vss_restore, cntr, encryption_password)) goto error; } } end: ret=0; error: // It is possible for a fd to still be open. bfd->close(bfd, asfd); bfile_free(&bfd); cntr_print_end(cntr); cntr_print(cntr, act); if(!ret) logp("%s finished\n", act_str(act)); else logp("ret: %d\n", ret); sbuf_free(&sb); free_w(&style); if(datpath) { recursive_delete(datpath); free_w(&datpath); } free_w(&fullpath); return ret; }
LLSD LLDXHardware::getDisplayInfo() { LLTimer hw_timer; HRESULT hr; LLSD ret; hr = CoInitialize(NULL); if (FAILED(hr)) { LL_WARNS("AppInit") << "COM library initialization failed!" << LL_ENDL; gWriteDebug("COM library initialization failed!\n"); return ret; } IDxDiagProvider *dx_diag_providerp = NULL; IDxDiagContainer *dx_diag_rootp = NULL; IDxDiagContainer *devices_containerp = NULL; IDxDiagContainer *device_containerp = NULL; IDxDiagContainer *file_containerp = NULL; IDxDiagContainer *driver_containerp = NULL; // CoCreate a IDxDiagProvider* llinfos << "CoCreateInstance IID_IDxDiagProvider" << llendl; hr = CoCreateInstance(CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER, IID_IDxDiagProvider, (LPVOID*) &dx_diag_providerp); if (FAILED(hr)) { llwarns << "No DXDiag provider found! DirectX 9 not installed!" << llendl; gWriteDebug("No DXDiag provider found! DirectX 9 not installed!\n"); goto LCleanup; } if (SUCCEEDED(hr)) // if FAILED(hr) then dx9 is not installed { // Fill out a DXDIAG_INIT_PARAMS struct and pass it to IDxDiagContainer::Initialize // Passing in TRUE for bAllowWHQLChecks, allows dxdiag to check if drivers are // digital signed as logo'd by WHQL which may connect via internet to update // WHQL certificates. DXDIAG_INIT_PARAMS dx_diag_init_params; ZeroMemory(&dx_diag_init_params, sizeof(DXDIAG_INIT_PARAMS)); dx_diag_init_params.dwSize = sizeof(DXDIAG_INIT_PARAMS); dx_diag_init_params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION; dx_diag_init_params.bAllowWHQLChecks = TRUE; dx_diag_init_params.pReserved = NULL; llinfos << "dx_diag_providerp->Initialize" << llendl; hr = dx_diag_providerp->Initialize(&dx_diag_init_params); if(FAILED(hr)) { goto LCleanup; } llinfos << "dx_diag_providerp->GetRootContainer" << llendl; hr = dx_diag_providerp->GetRootContainer( &dx_diag_rootp ); if(FAILED(hr) || !dx_diag_rootp) { goto LCleanup; } HRESULT hr; // Get display driver information llinfos << "dx_diag_rootp->GetChildContainer" << llendl; hr = dx_diag_rootp->GetChildContainer(L"DxDiag_DisplayDevices", &devices_containerp); if(FAILED(hr) || !devices_containerp) { goto LCleanup; } // Get device 0 llinfos << "devices_containerp->GetChildContainer" << llendl; hr = devices_containerp->GetChildContainer(L"0", &device_containerp); if(FAILED(hr) || !device_containerp) { goto LCleanup; } // Get the English VRAM string std::string ram_str = get_string(device_containerp, L"szDisplayMemoryEnglish"); // Dump the string as an int into the structure char *stopstring; ret["VRAM"] = strtol(ram_str.c_str(), &stopstring, 10); std::string device_name = get_string(device_containerp, L"szDescription"); ret["DeviceName"] = device_name; std::string device_driver= get_string(device_containerp, L"szDriverVersion"); ret["DriverVersion"] = device_driver; // ATI has a slightly different version string if(device_name.length() >= 4 && device_name.substr(0,4) == "ATI ") { // get the key HKEY hKey; const DWORD RV_SIZE = 100; WCHAR release_version[RV_SIZE]; // Hard coded registry entry. Using this since it's simpler for now. // And using EnumDisplayDevices to get a registry key also requires // a hard coded Query value. if(ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\ATI Technologies\\CBT"), &hKey)) { // get the value DWORD dwType = REG_SZ; DWORD dwSize = sizeof(WCHAR) * RV_SIZE; if(ERROR_SUCCESS == RegQueryValueEx(hKey, TEXT("ReleaseVersion"), NULL, &dwType, (LPBYTE)release_version, &dwSize)) { // print the value // windows doesn't guarantee to be null terminated release_version[RV_SIZE - 1] = NULL; ret["DriverVersion"] = utf16str_to_utf8str(release_version); } RegCloseKey(hKey); } } } LCleanup: SAFE_RELEASE(file_containerp); SAFE_RELEASE(driver_containerp); SAFE_RELEASE(device_containerp); SAFE_RELEASE(devices_containerp); SAFE_RELEASE(dx_diag_rootp); SAFE_RELEASE(dx_diag_providerp); CoUninitialize(); return ret; }
int eap_parse(struct iked *env, struct iked_sa *sa, void *data, int response) { struct eap_header *hdr = data; struct eap_message *eap = data; size_t len; u_int8_t *ptr; struct eap_mschap *ms; struct eap_mschap_challenge *msc; struct eap_mschap_response *msr; struct eap_mschap_success *mss; struct eap_mschap_failure *msf; char *str; /* length is already verified by the caller */ len = betoh16(hdr->eap_length); ptr = (u_int8_t *)(eap + 1); switch (hdr->eap_code) { case EAP_CODE_REQUEST: case EAP_CODE_RESPONSE: if (len < sizeof(*eap)) { log_debug("%s: short message", __func__); return (-1); } break; case EAP_CODE_SUCCESS: return (0); case EAP_CODE_FAILURE: if (response) return (0); return (-1); default: log_debug("%s: unsupported EAP code %s", __func__, print_map(hdr->eap_code, eap_code_map)); return (-1); } switch (eap->eap_type) { case EAP_TYPE_IDENTITY: if (eap->eap_code == EAP_CODE_REQUEST) break; if ((str = eap_identity_response(eap)) == NULL) return (-1); if (response) { free(str); break; } if (sa->sa_eapid != NULL) { free(str); log_debug("%s: EAP identity already known", __func__); return (0); } sa->sa_eapid = str; return (eap_challenge_request(env, sa, hdr)); case EAP_TYPE_MSCHAP_V2: ms = (struct eap_mschap *)ptr; switch (ms->ms_opcode) { case EAP_MSOPCODE_CHALLENGE: msc = (struct eap_mschap_challenge *)ptr; ptr += sizeof(*msc); len = betoh16(eap->eap_length) - sizeof(*eap) - sizeof(*msc); if ((str = get_string(ptr, len)) == NULL) { log_debug("%s: invalid challenge name", __func__); return (-1); } log_info("%s: %s %s id %d " "length %d valuesize %d name '%s' length %d", __func__, print_map(eap->eap_type, eap_type_map), print_map(ms->ms_opcode, eap_msopcode_map), msc->msc_id, betoh16(msc->msc_length), msc->msc_valuesize, str, len); free(str); print_hex(msc->msc_challenge, 0, sizeof(msc->msc_challenge)); break; case EAP_MSOPCODE_RESPONSE: msr = (struct eap_mschap_response *)ptr; ptr += sizeof(*msr); len = betoh16(eap->eap_length) - sizeof(*eap) - sizeof(*msr); if ((str = get_string(ptr, len)) == NULL) { log_debug("%s: invalid response name", __func__); return (-1); } log_info("%s: %s %s id %d " "length %d valuesize %d name '%s' name-length %d", __func__, print_map(eap->eap_type, eap_type_map), print_map(ms->ms_opcode, eap_msopcode_map), msr->msr_id, betoh16(msr->msr_length), msr->msr_valuesize, str, len); free(str); print_hex(msr->msr_response.resp_data, 0, sizeof(msr->msr_response.resp_data)); break; case EAP_MSOPCODE_SUCCESS: if (eap->eap_code == EAP_CODE_REQUEST) { mss = (struct eap_mschap_success *)ptr; ptr += sizeof(*mss); len = betoh16(eap->eap_length) - sizeof(*eap) - sizeof(*mss); if ((str = get_string(ptr, len)) == NULL) { log_debug("%s: invalid response name", __func__); return (-1); } log_info("%s: %s %s request id %d " "length %d message '%s' message-len %d", __func__, print_map(eap->eap_type, eap_type_map), print_map(ms->ms_opcode, eap_msopcode_map), mss->mss_id, betoh16(mss->mss_length), str, len); free(str); } else { ms = (struct eap_mschap *)ptr; log_info("%s: %s %s response", __func__, print_map(eap->eap_type, eap_type_map), print_map(ms->ms_opcode, eap_msopcode_map)); if (response) break; if (!sa_stateok(sa, IKEV2_STATE_AUTH_SUCCESS)) return (-1); return (eap_success(env, sa, hdr)); } break; case EAP_MSOPCODE_FAILURE: msf = (struct eap_mschap_failure *)ptr; ptr += sizeof(*msf); len = betoh16(eap->eap_length) - sizeof(*eap) - sizeof(*msf); if ((str = get_string(ptr, len)) == NULL) { log_debug("%s: invalid failure message", __func__); return (-1); } log_info("%s: %s %s id %d " "length %d message '%s'", __func__, print_map(eap->eap_type, eap_type_map), print_map(ms->ms_opcode, eap_msopcode_map), msf->msf_id, betoh16(msf->msf_length), str); free(str); break; default: log_info("%s: unknown ms opcode %d", __func__, ms->ms_opcode); return (-1); } if (response) break; return (eap_mschap(env, sa, eap)); default: log_debug("%s: unsupported EAP type %s", __func__, print_map(eap->eap_type, eap_type_map)); return (-1); } return (0); }
/* * Go to any level */ static void do_cmd_wiz_jump(void) { /* Ask for level */ if (command_arg <= 0) { char ppp[80]; char tmp_val[160]; int tmp_dungeon_type; /* Prompt */ sprintf(ppp, "Jump which dungeon : "); /* Default */ sprintf(tmp_val, "%d", dungeon_type); /* Ask for a level */ if (!get_string(ppp, tmp_val, 2)) return; tmp_dungeon_type = atoi(tmp_val); if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND; /* Prompt */ sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[tmp_dungeon_type].mindepth, d_info[tmp_dungeon_type].maxdepth); /* Default */ sprintf(tmp_val, "%d", dun_level); /* Ask for a level */ if (!get_string(ppp, tmp_val, 10)) return; /* Extract request */ command_arg = atoi(tmp_val); dungeon_type = tmp_dungeon_type; } /* Paranoia */ if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0; /* Paranoia */ if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth; /* Accept request */ msg_format("You jump to dungeon level %d.", command_arg); if (autosave_l) do_cmd_save_game(TRUE); /* Change level */ dun_level = command_arg; prepare_change_floor_mode(CFM_RAND_PLACE); if (!dun_level) dungeon_type = 0; p_ptr->inside_arena = FALSE; p_ptr->wild_mode = FALSE; leave_quest_check(); if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL); p_ptr->inside_quest = 0; energy_use = 0; /* Prevent energy_need from being too lower than 0 */ p_ptr->energy_need = 0; /* * Clear all saved floors * and create a first saved floor */ prepare_change_floor_mode(CFM_FIRST_FLOOR); /* Leaving */ p_ptr->leaving = TRUE; }
BOOL LLDXHardware::getInfo(BOOL vram_only) { LLTimer hw_timer; BOOL ok = FALSE; HRESULT hr; CoInitialize(NULL); IDxDiagProvider *dx_diag_providerp = NULL; IDxDiagContainer *dx_diag_rootp = NULL; IDxDiagContainer *devices_containerp = NULL; // IDxDiagContainer *system_device_containerp= NULL; IDxDiagContainer *device_containerp = NULL; IDxDiagContainer *file_containerp = NULL; IDxDiagContainer *driver_containerp = NULL; // CoCreate a IDxDiagProvider* LL_DEBUGS("AppInit") << "CoCreateInstance IID_IDxDiagProvider" << LL_ENDL; hr = CoCreateInstance(CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER, IID_IDxDiagProvider, (LPVOID*) &dx_diag_providerp); if (FAILED(hr)) { LL_WARNS("AppInit") << "No DXDiag provider found! DirectX 9 not installed!" << LL_ENDL; gWriteDebug("No DXDiag provider found! DirectX 9 not installed!\n"); goto LCleanup; } if (SUCCEEDED(hr)) // if FAILED(hr) then dx9 is not installed { // Fill out a DXDIAG_INIT_PARAMS struct and pass it to IDxDiagContainer::Initialize // Passing in TRUE for bAllowWHQLChecks, allows dxdiag to check if drivers are // digital signed as logo'd by WHQL which may connect via internet to update // WHQL certificates. DXDIAG_INIT_PARAMS dx_diag_init_params; ZeroMemory(&dx_diag_init_params, sizeof(DXDIAG_INIT_PARAMS)); dx_diag_init_params.dwSize = sizeof(DXDIAG_INIT_PARAMS); dx_diag_init_params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION; dx_diag_init_params.bAllowWHQLChecks = TRUE; dx_diag_init_params.pReserved = NULL; LL_DEBUGS("AppInit") << "dx_diag_providerp->Initialize" << LL_ENDL; hr = dx_diag_providerp->Initialize(&dx_diag_init_params); if(FAILED(hr)) { goto LCleanup; } LL_DEBUGS("AppInit") << "dx_diag_providerp->GetRootContainer" << LL_ENDL; hr = dx_diag_providerp->GetRootContainer( &dx_diag_rootp ); if(FAILED(hr) || !dx_diag_rootp) { goto LCleanup; } HRESULT hr; // Get display driver information LL_DEBUGS("AppInit") << "dx_diag_rootp->GetChildContainer" << LL_ENDL; hr = dx_diag_rootp->GetChildContainer(L"DxDiag_DisplayDevices", &devices_containerp); if(FAILED(hr) || !devices_containerp) { goto LCleanup; } // Get device 0 LL_DEBUGS("AppInit") << "devices_containerp->GetChildContainer" << LL_ENDL; hr = devices_containerp->GetChildContainer(L"0", &device_containerp); if(FAILED(hr) || !device_containerp) { goto LCleanup; } // Get the English VRAM string { std::string ram_str = get_string(device_containerp, L"szDisplayMemoryEnglish"); // We don't need the device any more SAFE_RELEASE(device_containerp); // Dump the string as an int into the structure char *stopstring; mVRAM = strtol(ram_str.c_str(), &stopstring, 10); LL_INFOS("AppInit") << "VRAM Detected: " << mVRAM << " DX9 string: " << ram_str << LL_ENDL; } if (vram_only) { ok = TRUE; goto LCleanup; } /* for now, we ONLY do vram_only the rest of this is commented out, to ensure no-one is tempted to use it // Now let's get device and driver information // Get the IDxDiagContainer object called "DxDiag_SystemDevices". // This call may take some time while dxdiag gathers the info. DWORD num_devices = 0; WCHAR wszContainer[256]; LL_DEBUGS("AppInit") << "dx_diag_rootp->GetChildContainer DxDiag_SystemDevices" << LL_ENDL; hr = dx_diag_rootp->GetChildContainer(L"DxDiag_SystemDevices", &system_device_containerp); if (FAILED(hr)) { goto LCleanup; } hr = system_device_containerp->GetNumberOfChildContainers(&num_devices); if (FAILED(hr)) { goto LCleanup; } LL_DEBUGS("AppInit") << "DX9 iterating over devices" << LL_ENDL; S32 device_num = 0; for (device_num = 0; device_num < (S32)num_devices; device_num++) { hr = system_device_containerp->EnumChildContainerNames(device_num, wszContainer, 256); if (FAILED(hr)) { goto LCleanup; } hr = system_device_containerp->GetChildContainer(wszContainer, &device_containerp); if (FAILED(hr) || device_containerp == NULL) { goto LCleanup; } std::string device_name = get_string(device_containerp, L"szDescription"); std::string device_id = get_string(device_containerp, L"szDeviceID"); LLDXDevice *dxdevicep = new LLDXDevice; dxdevicep->mName = device_name; dxdevicep->mPCIString = device_id; mDevices[dxdevicep->mPCIString] = dxdevicep; // Split the PCI string based on vendor, device, subsys, rev. std::string str(device_id); typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep("&\\", "", boost::keep_empty_tokens); tokenizer tokens(str, sep); tokenizer::iterator iter = tokens.begin(); S32 count = 0; BOOL valid = TRUE; for (;(iter != tokens.end()) && (count < 3);++iter) { switch (count) { case 0: if (strcmp(iter->c_str(), "PCI")) { valid = FALSE; } break; case 1: dxdevicep->mVendorID = iter->c_str(); break; case 2: dxdevicep->mDeviceID = iter->c_str(); break; default: // Ignore it break; } count++; } // Now, iterate through the related drivers hr = device_containerp->GetChildContainer(L"Drivers", &driver_containerp); if (FAILED(hr) || !driver_containerp) { goto LCleanup; } DWORD num_files = 0; hr = driver_containerp->GetNumberOfChildContainers(&num_files); if (FAILED(hr)) { goto LCleanup; } S32 file_num = 0; for (file_num = 0; file_num < (S32)num_files; file_num++ ) { hr = driver_containerp->EnumChildContainerNames(file_num, wszContainer, 256); if (FAILED(hr)) { goto LCleanup; } hr = driver_containerp->GetChildContainer(wszContainer, &file_containerp); if (FAILED(hr) || file_containerp == NULL) { goto LCleanup; } std::string driver_path = get_string(file_containerp, L"szPath"); std::string driver_name = get_string(file_containerp, L"szName"); std::string driver_version = get_string(file_containerp, L"szVersion"); std::string driver_date = get_string(file_containerp, L"szDatestampEnglish"); LLDXDriverFile *dxdriverfilep = new LLDXDriverFile; dxdriverfilep->mName = driver_name; dxdriverfilep->mFilepath= driver_path; dxdriverfilep->mVersionString = driver_version; dxdriverfilep->mVersion.set(driver_version); dxdriverfilep->mDateString = driver_date; dxdevicep->mDriverFiles[driver_name] = dxdriverfilep; SAFE_RELEASE(file_containerp); } SAFE_RELEASE(device_containerp); } */ } // dumpDevices(); ok = TRUE; LCleanup: if (!ok) { LL_WARNS("AppInit") << "DX9 probe failed" << LL_ENDL; gWriteDebug("DX9 probe failed\n"); } SAFE_RELEASE(file_containerp); SAFE_RELEASE(driver_containerp); SAFE_RELEASE(device_containerp); SAFE_RELEASE(devices_containerp); SAFE_RELEASE(dx_diag_rootp); SAFE_RELEASE(dx_diag_providerp); CoUninitialize(); return ok; }
/* * Create desired feature */ static void do_cmd_wiz_create_feature(void) { static int prev_feat = 0; static int prev_mimic = 0; cave_type *c_ptr; feature_type *f_ptr; char tmp_val[160]; int tmp_feat, tmp_mimic; int y, x; if (!tgt_pt(&x, &y)) return; c_ptr = &cave[y][x]; /* Default */ sprintf(tmp_val, "%d", prev_feat); /* Query */ #ifdef JP if (!get_string("地形: ", tmp_val, 3)) return; #else if (!get_string("Feature: ", tmp_val, 3)) return; #endif /* Extract */ tmp_feat = atoi(tmp_val); if (tmp_feat < 0) tmp_feat = 0; else if (tmp_feat >= max_f_idx) tmp_feat = max_f_idx - 1; /* Default */ sprintf(tmp_val, "%d", prev_mimic); /* Query */ #ifdef JP if (!get_string("地形 (mimic): ", tmp_val, 3)) return; #else if (!get_string("Feature (mimic): ", tmp_val, 3)) return; #endif /* Extract */ tmp_mimic = atoi(tmp_val); if (tmp_mimic < 0) tmp_mimic = 0; else if (tmp_mimic >= max_f_idx) tmp_mimic = max_f_idx - 1; cave_set_feat(y, x, tmp_feat); c_ptr->mimic = tmp_mimic; f_ptr = &f_info[get_feat_mimic(c_ptr)]; if (have_flag(f_ptr->flags, FF_GLYPH) || have_flag(f_ptr->flags, FF_MINOR_GLYPH)) c_ptr->info |= (CAVE_OBJECT); else if (have_flag(f_ptr->flags, FF_MIRROR)) c_ptr->info |= (CAVE_GLOW | CAVE_OBJECT); /* Notice */ note_spot(y, x); /* Redraw */ lite_spot(y, x); /* Update some things */ p_ptr->update |= (PU_FLOW); prev_feat = tmp_feat; prev_mimic = tmp_mimic; }
void outcmd(int ch, int count) { struct instruction * n = calloc(1, sizeof*n), *n2; if (!n) { perror("bf2pas"); exit(42); } icount ++; n->ch = ch; n->count = count; n->icount = icount; if (ch == '"') n->cstr=strdup(get_string()); if (!last) { pgm = n; } else { last->next = n; } last = n; if (n->ch == '[') { n->ino = ++lblcount; n->loop = jmpstack; jmpstack = n; } else if (n->ch == ']') { n->loop = jmpstack; jmpstack = jmpstack->loop; n->loop->loop = n; } if (ch != '~') return; loutcmd(0, 0, 0); if (icount < MAXWHILE) { for(n=pgm; n; n=n->next) loutcmd(n->ch, n->count, n); } else { for(n=pgm; n; n=n->next) { if (n->ch != ']') continue; if (n->icount-n->loop->icount <= MAXWHILE) continue; loutcmd(1000, 1, n->loop); for(n2 = n->loop->next; n != n2; n2=n2->next) { if (n2->ch == '[' && n2->loop->icount-n2->icount > MAXWHILE) { loutcmd(n2->ch, n2->count, n); prv("bf%d()", n2->ino); n2 = n2->loop; loutcmd(n2->ch, n2->count, n); } else loutcmd(n2->ch, n2->count, n2); } loutcmd(1001, 1, n); } for(n=pgm; n; n=n->next) { if (n->ch != '[' || n->loop->icount-n->icount <= MAXWHILE) loutcmd(n->ch, n->count, n); else { loutcmd(n->ch, n->count, n); prv("bf%d()", n->ino); n=n->loop; loutcmd(n->ch, n->count, n); } } } while(pgm) { n = pgm; pgm = pgm->next; if (n->cstr) free(n->cstr); memset(n, '\0', sizeof*n); free(n); } }
/* * Aux function for "do_cmd_wiz_change()". -RAK- */ static void do_cmd_wiz_change_aux(void) { int i, j; int tmp_int; long tmp_long; s16b tmp_s16b; char tmp_val[160]; char ppp[80]; /* Query the stats */ for (i = 0; i < 6; i++) { /* Prompt */ sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]); /* Default */ sprintf(tmp_val, "%d", p_ptr->stat_max[i]); /* Query */ if (!get_string(ppp, tmp_val, 3)) return; /* Extract */ tmp_int = atoi(tmp_val); /* Verify */ if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i]; else if (tmp_int < 3) tmp_int = 3; /* Save it */ p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int; } /* Default */ sprintf(tmp_val, "%d", WEAPON_EXP_MASTER); /* Query */ #ifdef JP if (!get_string("熟練度: ", tmp_val, 9)) return; #else if (!get_string("Proficiency: ", tmp_val, 9)) return; #endif /* Extract */ tmp_s16b = atoi(tmp_val); /* Verify */ if (tmp_s16b < WEAPON_EXP_UNSKILLED) tmp_s16b = WEAPON_EXP_UNSKILLED; if (tmp_s16b > WEAPON_EXP_MASTER) tmp_s16b = WEAPON_EXP_MASTER; for (j = 0; j <= TV_WEAPON_END - TV_WEAPON_BEGIN; j++) { for (i = 0;i < 64;i++) { p_ptr->weapon_exp[j][i] = tmp_s16b; if (p_ptr->weapon_exp[j][i] > s_info[p_ptr->pclass].w_max[j][i]) p_ptr->weapon_exp[j][i] = s_info[p_ptr->pclass].w_max[j][i]; } } for (j = 0; j < 10; j++) { p_ptr->skill_exp[j] = tmp_s16b; if (p_ptr->skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) p_ptr->skill_exp[j] = s_info[p_ptr->pclass].s_max[j]; } for (j = 0; j < 32; j++) p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b); for (; j < 64; j++) p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b); /* Default */ sprintf(tmp_val, "%ld", (long)(p_ptr->au)); /* Query */ if (!get_string("Gold: ", tmp_val, 9)) return; /* Extract */ tmp_long = atol(tmp_val); /* Verify */ if (tmp_long < 0) tmp_long = 0L; /* Save */ p_ptr->au = tmp_long; /* Default */ sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp)); /* Query */ if (!get_string("Experience: ", tmp_val, 9)) return; /* Extract */ tmp_long = atol(tmp_val); /* Verify */ if (tmp_long < 0) tmp_long = 0L; if (p_ptr->prace != RACE_ANDROID) { /* Save */ p_ptr->max_exp = tmp_long; p_ptr->exp = tmp_long; /* Update */ check_experience(); } }
SC_FUNC char *get_path(int index) { return get_string(&includepaths,index); }
int child(struct async *as, int is_status_server, int status_wfd, struct conf **confs, struct conf **cconfs) { int ret=-1; int srestore=0; int timer_ret=0; char *incexc=NULL; const char *confs_user=get_string(confs[OPT_USER]); const char *cconfs_user=get_string(cconfs[OPT_USER]); const char *confs_group=get_string(confs[OPT_GROUP]); const char *cconfs_group=get_string(cconfs[OPT_GROUP]); const char *s_script_pre=get_string(cconfs[OPT_S_SCRIPT_PRE]); const char *s_script_post=get_string(cconfs[OPT_S_SCRIPT_POST]); // If we are not a status server, we are a normal child - set up the // parent socket to write status to. if(status_wfd>0 && !(wasfd=setup_asfd(as, "child status pipe", &status_wfd))) goto end; wasfd->attempt_reads=0; /* Has to be before the chuser/chgrp stuff to allow clients to switch to different clients when both clients have different user/group settings. */ if(extra_comms(as, &incexc, &srestore, confs, cconfs)) { log_and_send(as->asfd, "running extra comms failed on server"); goto end; } /* Now that the client conf is loaded, we might want to chuser or chgrp. The main process could have already done this, so we don't want to try doing it again if cconfs has the same values, because it will fail. */ if( (!confs_user || (cconfs_user && strcmp(confs_user, cconfs_user))) ||(!confs_group ||(cconfs_group && strcmp(confs_group,cconfs_group)))) { if(chuser_and_or_chgrp(cconfs_user, cconfs_group)) { log_and_send(as->asfd, "chuser_and_or_chgrp failed on server"); goto end; } } if(as->asfd->read(as->asfd)) goto end; // If this is a status server, run the status server. if(is_status_server) { ret=status_server(as, cconfs); goto end; } ret=0; // FIX THIS: Make the script components part of a struct, and just // pass in the correct struct. Same below. if(s_script_pre) ret=run_server_script(as->asfd, "pre", s_script_pre, get_strlist(cconfs[OPT_S_SCRIPT_PRE_ARG]), get_int(cconfs[OPT_S_SCRIPT_PRE_NOTIFY]), cconfs, ret, timer_ret); if(!ret) ret=run_action_server(as, incexc, srestore, &timer_ret, cconfs); if((!ret || get_int(cconfs[OPT_S_SCRIPT_POST_RUN_ON_FAIL])) && s_script_post) ret=run_server_script(as->asfd, "post", s_script_post, get_strlist(cconfs[OPT_S_SCRIPT_POST_ARG]), get_int(cconfs[OPT_S_SCRIPT_POST_NOTIFY]), cconfs, ret, timer_ret); end: return ret; }