CValue CValueText::Method(int iName,CValue **p) { CValue Ret; switch(iName) { case enLinesCnt: Ret=aText.GetSize(); break; case enClear: aText.RemoveAll(); break; case enGetLine: { DEF_N_LINE() Ret=String(aText[n]); break; } case enAddLine: if (nTemplate) aText.Add(Template(p[0]->GetString())); else aText.Add(p[0]->GetString()); break; case enReplaceLine: { DEF_N_LINE() if (nTemplate) aText[n]=Template(p[1]->GetString()); else aText[n]=p[1]->GetString(); break; } case enDeleteLine: { DEF_N_LINE() aText.RemoveAt(n); break; } case enInsertLine: { DEF_N_LINE() if (nTemplate) aText.InsertAt(n,Template(p[1]->GetString())); else aText.InsertAt(n,p[1]->GetString()); break; } case enOpen: { CString csName=p[0]->GetString(); if(!FileExist(csName)) Error(CString("Файл ")+csName+" не найден"); aText.RemoveAll(); csTitle=csName; int nSize=0; char *buf=LoadFromFileBin(csName,nSize); if (!nSize) break; if(buf) { CString Str; Str.GetBuffer(10000); for(int i=0;i<nSize;i++) { if(buf[i]==0x0D&&buf[i+1]==0x0A) { if (nTemplate) aText.Add(Template(Str)); else aText.Add(Str); Str=""; i++; //i++; } else { Str+=buf[i]; } } if (nTemplate) aText.Add(Template(Str)); else aText.Add(Str); Str.ReleaseBuffer(); delete []buf; } break; } case enShow: { if(!pDoc) pDoc=(CModuleDoc*)OpenFormMDI("Модуль",1); pDoc->SetPathName(csTitle,0); pDoc->SetTitle(csTitle); pDoc->SetText(GetStr()); pDoc->m_xTextBuffer.SetReadOnly(bReadOnly); break; } case enWrite: { CString csName=p[0]->GetString(); csTitle=csName; extern void WritoToFileText(CString csCFile,CString Str); WritoToFileText(csName,GetStr()); break; } case enReadOnly: { Ret=bReadOnly; bReadOnly=p[0]->GetNumber(); if(pDoc) pDoc->m_xTextBuffer.SetReadOnly(bReadOnly); break; } case enCodePage: { Ret=nCodePage; if (p[0]->nType) nCodePage=p[0]->GetNumber(); break; } case enTemplate: { Ret=nTemplate; if (p[0]->nType) nTemplate=p[0]->GetNumber(); break; } case enFixTemplate: { Ret=nFixTemplate; if (p[0]->nType) nFixTemplate=p[0]->GetNumber(); break; } case enGetText: Ret=String(GetStr()); break; } return Ret; }
//***************************************************** // Грабер приватбанка //***************************************************** TPrivatBank::TPrivatBank() : TGrabber(GetStr(EStrPrivatBankGrabber)) { FLog = NULL; FKeyPassWnd = NULL; }
Object *CreatePrefsGroup(struct InstData_MCP *data) { Object *example; Object **objs = data->Objects; Object *group; static const char *key01[2]; static const char *key02[2]; static const char *key03[2]; static const char *key04[2]; static const char *key05[2]; static const char *key06[2]; static const char *key07[2]; static const char *key08[2]; static const char *key09[2]; static const char *key10[2]; static const char *key11[2]; static const char *key12[2]; static const char *key13[2]; static const char *key14[2]; static const char *key15[2]; static const char *key16[2]; static const char *key17[2]; static const char *key18[2]; static const char infotext1[] = "\033bBetterString.mcp " LIB_REV_STRING "\033n (" LIB_DATE ")\n" "Copyright (C) 1997-2000 Allan Odgaard\n" LIB_COPYRIGHT; static const char infotext2[] = "\n" "Distributed under the terms of the LGPL2.\n" "\n" "For the latest version, check out:\n" "http://www.sf.net/projects/bstring-mcc/\n" "\n"; static const char **keyinfo[] = { key01, key02, key03, key04, key05, key06, key07, key08, key09, key10, key11, key12, key13, key14, key15, key16, key17, key18, NULL }; key01[0] = GetStr(MSG_Help_Copy_Shortcut); key01[1] = GetStr(MSG_Help_Copy); key02[0] = GetStr(MSG_Help_Cut_Shortcut); key02[1] = GetStr(MSG_Help_Cut); key03[0] = GetStr(MSG_Help_Paste_Shortcut); key03[1] = GetStr(MSG_Help_Paste); key04[0] = GetStr(MSG_Help_Undo_Shortcut); key04[1] = GetStr(MSG_Help_Undo); key05[0] = GetStr(MSG_Help_Redo_Shortcut); key05[1] = GetStr(MSG_Help_Redo); key06[0] = GetStr(MSG_Help_ToggleBuffer_Shortcut); key06[1] = GetStr(MSG_Help_ToggleBuffer); key07[0] = GetStr(MSG_Help_ToggleCaseChar_Shortcut); key07[1] = GetStr(MSG_Help_ToggleCaseChar); key08[0] = GetStr(MSG_Help_ToggleCaseWord_Shortcut); key08[1] = GetStr(MSG_Help_ToggleCaseWord); key09[0] = GetStr(MSG_Help_IncreaseNumber_Shortcut); key09[1] = GetStr(MSG_Help_IncreaseNumber); key10[0] = GetStr(MSG_Help_DecreaseNumber_Shortcut); key10[1] = GetStr(MSG_Help_DecreaseNumber); key11[0] = GetStr(MSG_Help_HexToDecimal_Shortcut); key11[1] = GetStr(MSG_Help_HexToDecimal); key12[0] = GetStr(MSG_Help_DecimalToHex_Shortcut); key12[1] = GetStr(MSG_Help_DecimalToHex); key13[0] = GetStr(MSG_Help_FilenameCompletition_Shortcut); key13[1] = GetStr(MSG_Help_FilenameCompletition); key14[0] = GetStr(MSG_Help_Mark_Shortcut); key14[1] = GetStr(MSG_Help_Mark); key15[0] = GetStr(MSG_Help_GotoToStartEndOfLine_Shortcut); key15[1] = GetStr(MSG_Help_GotoToStartEndOfLine); key16[0] = GetStr(MSG_Help_DeleteToStartEndOfLine_Shortcut); key16[1] = GetStr(MSG_Help_DeleteToStartEndOfLine); key17[0] = GetStr(MSG_Help_GotoToPrevNextWord_Shortcut); key17[1] = GetStr(MSG_Help_GotoToPrevNextWord); key18[0] = GetStr(MSG_Help_DeleteToPrevNextWord_Shortcut); key18[1] = GetStr(MSG_Help_DeleteToPrevNextWord); group = VGroup, Child, PopobjectObject, MUIA_Popstring_String, example = BetterStringObject, StringFrame, MUIA_String_Contents, GetStr(MSG_String_TestString), MUIA_String_Format, MUIV_String_Format_Center, MUIA_CycleChain, TRUE, End, MUIA_Popstring_Button, PopButton(MUII_PopUp), MUIA_Popobject_Object, ListviewObject, MUIA_Listview_Input, FALSE, MUIA_Listview_List, ListObject, ReadListFrame, MUIA_List_DisplayHook, &DisplayHook, MUIA_List_Format, ",,", MUIA_List_SourceArray, keyinfo, End, End, End, Child, VSpace(4), Child, ColGroup(2), Child, HSpace(-1), Child, HGroup, MUIA_Group_SameWidth, TRUE, Child, TextObject, MUIA_Font, MUIV_Font_Tiny, MUIA_Text_Contents, GetStr(MSG_Label_Background), MUIA_Text_PreParse, "\33c", End, Child, TextObject, MUIA_Font, MUIV_Font_Tiny, MUIA_Text_Contents, GetStr(MSG_Label_Text), MUIA_Text_PreParse, "\33c", End, End, Child, TxtLabel(GetStr(MSG_Label_Inactive)), Child, HGroup, Child, objs[InactiveBack] = PopimageObject, MUIA_Imageadjust_Type, 2, MUIA_CycleChain, TRUE, MUIA_FixHeight, 0, End, Child, objs[InactiveText] = PoppenObject, MUIA_CycleChain, TRUE, MUIA_FixHeight, 0, End, End, Child, TxtLabel(GetStr(MSG_Label_Active)), Child, HGroup, Child, objs[ActiveBack] = PopimageObject, MUIA_Imageadjust_Type, 2, MUIA_CycleChain, TRUE, MUIA_FixHeight, 0, End, Child, objs[ActiveText] = PoppenObject, MUIA_CycleChain, TRUE, MUIA_FixHeight, 0, End, End, Child, HSpace(-1), Child, RectangleObject, MUIA_Rectangle_HBar, TRUE, MUIA_VertWeight, 0, End, Child, TxtLabel(GetStr(MSG_Label_Cursor)), Child, objs[Cursor] = PoppenObject, MUIA_CycleChain, TRUE, MUIA_FixHeight, 0, End, Child, TxtLabel(GetStr(MSG_Label_Marked)), Child, HGroup, Child, objs[MarkedBack] = PoppenObject, MUIA_CycleChain, TRUE, MUIA_FixHeight, 0, End, Child, objs[MarkedText] = PoppenObject, MUIA_CycleChain, TRUE, MUIA_FixHeight, 0, End, End, Child, HSpace(-1), Child, RectangleObject, MUIA_Rectangle_HBar, TRUE, MUIA_VertWeight, 0, End, Child, HSpace(-1), Child, HGroup, MUIA_Weight, 0, Child, objs[SelectOnActive] = MUI_MakeObject(MUIO_Checkmark, NULL), Child, TxtLLabel(GetStr(MSG_SelectOnActive)), Child, HSpace(-1), End, Child, HSpace(-1), Child, HGroup, MUIA_Weight, 0, Child, objs[SelectPointer] = MUI_MakeObject(MUIO_Checkmark, NULL), Child, TxtLLabel(GetStr(MSG_SelectPointer)), Child, HSpace(-1), End, End, Child, CrawlingObject, TextFrame, MUIA_FixHeightTxt, infotext1, MUIA_Background, "m1", Child, TextObject, MUIA_Text_Copy, FALSE, MUIA_Text_PreParse, "\033c", MUIA_Text_Contents, infotext1, End, Child, TextObject, MUIA_Text_Copy, FALSE, MUIA_Text_PreParse, "\033c", MUIA_Text_Contents, infotext2, End, Child, TextObject, MUIA_Text_Copy, FALSE, MUIA_Text_PreParse, "\033c", MUIA_Text_Contents, infotext1, End, End, End; // the inactive background will be the same as for String.mui on MUI4 if(objs[InactiveBack] != NULL) set(objs[InactiveBack], MUIA_Disabled, data->mui4x); // the active background will be the same as for String.mui on MUI4 if(objs[ActiveBack] != NULL) set(objs[ActiveBack], MUIA_Disabled, data->mui4x); if(objs[SelectOnActive] != NULL) set(objs[SelectOnActive], MUIA_ShortHelp, GetStr(MSG_HELP_SelectOnActive)); // disable the pointer checkmark in case MUI already handles custom pointer types if(objs[SelectPointer] != NULL) { SetAttrs(objs[SelectPointer], MUIA_ShortHelp, GetStr(MSG_HELP_SelectPointer), MUIA_Disabled, xget(example, MUIA_PointerType) != MUIV_PointerType_Normal, TAG_DONE); } return group; }
BYTE GetSBRRec() // read the next record from the current .sbr file // { BYTE col; int cbRead; // read rectype, check for EOF as we go if (cchBuf < CB_SBRMIN) { if (!fAllRead) { // copy what's left over (note there is no overlap) memcpy(sbrBuf, pchBuf, cchBuf); cbRead = _read(fhCur, sbrBuf + cchBuf, CB_SBRBUF - cchBuf); if (cbRead < 0) cbRead = 0; cchBuf += cbRead; pchBuf = sbrBuf; if (cchBuf != CB_SBRBUF) fAllRead = TRUE; } if (cchBuf == 0) { fFoundHeader = FALSE; // this is in case we are reinitialized fAllRead = FALSE; return S_EOF; } } char *pxBuf = pchBuf; GetByte(r_rectyp); int r = GetSbrRecType(r_rectyp); if (r >= SBR_REC_BUMP_N && r < SBR_REC_BUMP_N + 16) { int delta = 1 + r - SBR_REC_BUMP_N; r_lineno += delta; r = SBR_REC_LINDEF; } else switch(r) { case SBR_REC_HEADER: if (fFoundHeader) SBRCorrupt("Multiple Headers"); case SBR_REC_INFOSEP: fFoundHeader = 1; GetByte(r_majv); GetByte(r_minv); GetByte(r_lang); GetByte(r_fcol); fSbr11 = FALSE; if (r_majv == 1 && r_minv == 1) fSbr11 = TRUE; else if (r_majv != SBR_VER_MAJOR || r_minv != SBR_VER_MINOR) break; CopyStr (r_cwd); break; case SBR_REC_MODULE: case SBR_REC_PCHNAME: GetStr(r_bname); break; case SBR_REC_LINDELTA: { short delta; GetWord(delta); r_lineno += delta; r = SBR_REC_LINDEF; break; } case SBR_REC_LINDEF: GetWord(r_lineno); if (r_lineno) r_lineno--; break; case SBR_REC_BASE: if (!FExtRec()) { r_ordinal = 0; GetWord(r_ordinal); GetByte(r_type); if (r_ordinal & 0x8000) r_ordinal |= 0xffff0000; } else { r_ordinal = 0; Get24(r_ordinal); GetByte(r_type); if (r_ordinal & 0x800000) r_ordinal |= 0xff000000; } break; case SBR_REC_SYMDEF: if (!FExtRec()) { if (!fSbr11) { GetByte(r_type); GetWord(r_attrib); } else { GetWord(r_attrib); r_type = (BYTE)(r_attrib >> 11); r_attrib &= 0x07ff; } r_ordinal = 0; GetWord(r_ordinal); if (r_fcol) GetByte(col); GetStr(r_bname); if (r_ordinal & 0x8000) r_ordinal |= 0xffff0000; } else { GetByte(r_type); GetWord(r_attrib); r_ordinal = 0; Get24(r_ordinal); if (r_fcol) GetByte(col); GetStr(r_bname); if (r_ordinal & 0x800000) r_ordinal |= 0xff000000; } break; case SBR_REC_OWNER: case SBR_REC_FRIEND: if (!FExtRec()) { r_ordinal = 0; GetWord(r_ordinal); if (r_ordinal & 0x8000) r_ordinal |= 0xffff0000; } else { r_ordinal = 0; Get24(r_ordinal); if (r_ordinal & 0x800000) r_ordinal |= 0xff000000; } break; case SBR_REC_SYMREFUSE: case SBR_REC_SYMREFSET: if (!FExtRec()) { r_ordinal = 0; GetWord(r_ordinal); if (r_fcol) GetByte(col); if (r_ordinal & 0x8000) r_ordinal |= 0xffff0000; } else { r_ordinal = 0; Get24(r_ordinal); if (r_fcol) GetByte(col); if (r_ordinal & 0x800000) r_ordinal |= 0xff000000; } break; }
vector<int> Configuration::GetIntArray(string const & field) const { string const param_str = GetStr(field); return tokenize_int(param_str); }
const string OutDir() { return str(boost::format("%s/../%s") % boost::filesystem::path(__FILE__).parent_path().string() % GetStr("out_dir")); }
/* -------------------------------------------------------------------- */ static void makeSendFile(void) { char line[100], line2[100]; label troo; label fn; FILE *file; int i = 0, rm; if ((file = fopen(roomreqin, "rb")) == NULL) { perror("Error opening roomreq.in"); } doccr(); cPrintf(" Fetching:"); doccr(); GetStr(file, troo, LABELSIZE); while(strlen(troo) && !feof(file)) { if ((rm = roomExists(troo)) != ERROR) { if (nodecanseeroom(node.ndname, rm)) { sprintf(fn, "room.%d", i); cPrintf(" %-20s ", troo); if( !((i+1) % 3) ) doccr(); NewRoom(rm, fn); } else { doccr(); cPrintf(" No access to %s room.", troo); doccr(); amPrintf(" '%s' room not available to remote.\n", troo); netError = TRUE; } } else { doccr(); cPrintf(" No %s room on system.", troo); doccr(); amPrintf(" '%s' room not found for remote.\n", troo); netError = TRUE; } i++; GetStr(file, troo, LABELSIZE); } doccr(); fclose(file); unlink(roomreqin); cPrintf(" Copying mail file."); doccr(); sprintf(line, "%s\\%s", cfg.transpath, node.ndmailtmp); sprintf(line2, "%s\\mesg.tmp", cfg.temppath); if ((file = fopen(line2, "wb")) != NULL) { fclose(file); } copyfile(line, line2); cPrintf(" Compressing message files."); doccr(); /* * Zip them up */ sformat(line, node.zip, "df", roomdataout, "mesg.tmp room.*"); apsystem(line); /* * Remove them. */ ambigUnlink("room.*", FALSE); unlink("mesg.tmp"); }
/* -------------------------------------------------------------------- */ int editText(char *buf, int lim) { char ch, x; FILE *fd; int eom; dowhat = PROMPT; do { outFlag = IMPERVIOUS; while (MIReady()) /* flush modem input buffer */ getMod(); doCR(); strcpy(gprompt,"Entry command:"); /* in case of ^A? */ mtPrintf(TERM_REVERSE,gprompt); mPrintf(" "); switch (ch = (char) toupper(iChar())) { case 'A': mPrintf("\bAbort\n "); if (strblank(buf)) return FALSE; else if (getYesNo(confirm, 0)) { heldMessage = TRUE; memcpy(msgBuf2, msgBuf, sizeof(struct msgB)); dowhat = DUNO; return FALSE; } break; case 'C': mPrintf("\bContinue"); /* dump message to display */ outFlag = IMPERVIOUS; doCR(); putheader(); doCR(); outFlag = OUTOK; mFormat(buf); doBS(); eom = strlen(buf); if (eom > 0) buf[eom - 1] = '\0'; /* zap last character ('\n') */ outFlag = IMPERVIOUS; return ERROR; /* to return to this routine */ case 'F': mPrintf("\bFind & Replace text\n "); replaceString(buf, lim, TRUE); break; case 'P': mPrintf("\bPrint formatted\n "); doCR(); outFlag = IMPERVIOUS; putheader(); doCR(); outFlag = OUTOK; mFormat(buf); termCap(TERM_NORMAL); doCR(); break; case 'R': mPrintf("\bReplace text\n "); replaceString(buf, lim, FALSE); break; case 'S': mPrintf("\bSave buffer\n "); entered++; /* increment # messages entered */ dowhat = DUNO; return TRUE; case 'W': mPrintf("\bWord count\n "); wordcount(buf); break; case '?': nextmenu("edit", &(cfg.cnt.edittut), 1); break; default: if ((x = (char) strpos((char) tolower(ch), editcmd)) != 0) { x--; mPrintf("\b%s", edit[x].ed_name); doCR(); if (edit[x].ed_local && !onConsole) { mPrintf("\n Local editor only!\n "); } else { changedir(cfg.aplpath); if ((fd = fopen("message.apl", "wb")) != NULL) { xPutStr(fd, msgBuf->mbtext); fclose(fd); } readMessage = FALSE; extFmtRun(edit[x].ed_cmd, "message.apl"); changedir(cfg.aplpath); if ((fd = fopen("message.apl", "rb")) != NULL) { GetStr(fd, msgBuf->mbtext, cfg.maxtext); fclose(fd); unlink("message.apl"); } } break; } if (!gl_user.expert) nextmenu("edit", &(cfg.cnt.edittut), 1); else mPrintf("\n '?' for menu.\n \n"); break; } } while (!ExitToMsdos && (haveCarrier || onConsole)); dowhat = DUNO; return FALSE; }
void TERMWINDOWMEMBER makeSendFile(void) { char line[100], line2[100]; label troo; label fn; FILE *file; int i = 0; int crcounter = 0; if ((file = fopen(roomreqIn, FO_RB)) == NULL) { perror(getnetmsg(90)); return; // ok } doccr(); cPrintf(getnetmsg(2)); doccr(); GetStr(file, troo, LABELSIZE); while (*troo && !feof(file)) { r_slot rm = RoomExists(troo); if (rm == CERROR) { rm = IdExists(troo, TRUE); } if (rm != CERROR) { if (CurrentUser->CanAccessRoom(rm)) { sprintf(fn, getnetmsg(126), i); cPrintf(getnetmsg(128), deansi(troo)); if (!((crcounter+1) % 3)) { doccr(); } crcounter++; NewRoom(rm, fn, NULL); } else { doccr(); cPrintf(getnetmsg(111), deansi(troo)); doccr(); amPrintf(getnetmsg(4), troo, bn); netError = TRUE; } } else { doccr(); cPrintf(getnetmsg(97), deansi(troo)); doccr(); amPrintf(getnetmsg(6), troo, bn); netError = TRUE; } i++; GetStr(file, troo, LABELSIZE); } doccr(); fclose(file); unlink(roomreqIn); cPrintf(getnetmsg(98)); doccr(); sprintf(line, sbs, cfg.transpath, node->GetMailFileName()); sprintf(line2, sbs, LocalTempPath, mesgTmp); if ((file = fopen(line2, FO_WB)) != NULL) { fclose(file); } copyfile(line, line2); cPrintf(getnetmsg(99), cfg.Lmsg_nym); doccr(); // Zip them up sprintf(line2, getnetmsg(113), mesgTmp, roomStar); sformat(line, node->GetCreatePacket(), getmsg(49), roomdataOut, line2, 0); apsystem(line, TRUE); // Remove them. changedir(LocalTempPath); ambigUnlink(roomStar); unlink(mesgTmp); }
bool CClient::CanSkillUp(skillIndexes skillindex) { int currentskill = m_cSkillMastery[skillindex]; currentskill++; switch (skillindex) { case SKILL_MINING: case SKILL_HANDATTACK: case SKILL_MANUFACTURING: // limit: 2*str if (currentskill > (GetStr() * 2)) { return false; } break; case SKILL_MAGICRES: // limit: 2*lvl if (currentskill > (GetLevel() * 2)) { return false; } break; case SKILL_MAGIC: case SKILL_STAFF: // limit: 2*mag if (currentskill > (GetMag() * 2)) { return false; } break; case SKILL_FISHING: case SKILL_ARCHERY: case SKILL_SHORTSWORD: case SKILL_LONGSWORD: case SKILL_FENCING: case SKILL_AXE: case SKILL_SHIELD: case SKILL_HAMMER: // limit: 2*dex if (currentskill > (GetDex() * 2)) { return false; } break; case SKILL_FARMING: case SKILL_ALCHEMY: case SKILL_15: case SKILL_PRETENDCORPSE: // limit: 2*int if (currentskill > (GetInt() * 2)) { return false; } break; case SKILL_POISONRES: // limit: 2*vit if (currentskill > (GetVit() * 2)) { return false; } break; } return true; }
QString MenuCommands::Get(int ind, What w) const { int cur = 0; if (cur++ == ind) return (w == Key ? FileKey() : (w == Title? FileTitle() : "")); if (cur++ == ind) return (w == Key ? NewWinKey() : (w == Title? NewWinTitle() : GetStr(NewWinShortcuts()))); if (cur++ == ind) return (w == Key ? OpenFileKey() : (w == Title? OpenFileTitle() : GetStr(OpenFileShortcuts()))); if (cur++ == ind) return (w == Key ? OpenLocKey() : (w == Title? OpenLocTitle() : GetStr(OpenLocShortcuts()))); if (cur++ == ind) return (w == Key ? SaveAsKey() : (w == Title? SaveAsTitle() : GetStr(SaveAsShortcuts()))); if (cur++ == ind) return (w == Key ? SavePdfKey() : (w == Title? SavePdfTitle() : GetStr(SavePdfShortcuts()))); if (cur++ == ind) return (w == Key ? ImportKey() : (w == Title? ImportTitle() : "")); if (cur++ == ind) return (w == Key ? ImportIEKey() : (w == Title? ImportIETitle() : GetStr(ImportIEShortcuts()))); if (cur++ == ind) return (w == Key ? ImportFFKey() : (w == Title? ImportFFTitle() : GetStr(ImportFFShortcuts()))); if (cur++ == ind) return (w == Key ? ImportHtmlKey() : (w == Title? ImportHtmlTitle() : GetStr(ImportHtmlShortcuts()))); if (cur++ == ind) return (w == Key ? ImportXmlKey() : (w == Title? ImportXmlTitle() : GetStr(ImportXmlShortcuts()))); if (cur++ == ind) return (w == Key ? ExportKey() : (w == Title? ExportTitle() : GetStr(ExportShortcuts()))); if (cur++ == ind) return (w == Key ? PrintKey() : (w == Title? PrintTitle() : GetStr(PrintShortcuts()))); if (cur++ == ind) return (w == Key ? PreviewKey() : (w == Title? PreviewTitle() : GetStr(PreviewShortcuts()))); if (cur++ == ind) return (w == Key ? QuitKey() : (w == Title? QuitTitle() : GetStr(QuitShortcuts()))); if (cur++ == ind) return (w == Key ? EditKey() : (w == Title? EditTitle() : "")); if (cur++ == ind) return (w == Key ? UndoKey() : (w == Title? UndoTitle() : GetStr(UndoShortcuts()))); if (cur++ == ind) return (w == Key ? RedoKey() : (w == Title? RedoTitle() : GetStr(RedoShortcuts()))); if (cur++ == ind) return (w == Key ? CutKey() : (w == Title? CutTitle() : GetStr(CutShortcuts()))); if (cur++ == ind) return (w == Key ? CopyKey() : (w == Title? CopyTitle() : GetStr(CopyShortcuts()))); if (cur++ == ind) return (w == Key ? PasteKey() : (w == Title? PasteTitle() : GetStr(PasteShortcuts()))); if (cur++ == ind) return (w == Key ? FindKey() : (w == Title? FindTitle() : GetStr(FindShortcuts()))); if (cur++ == ind) return (w == Key ? NextKey() : (w == Title? NextTitle() : GetStr(NextShortcuts()))); if (cur++ == ind) return (w == Key ? PrevKey() : (w == Title? PrevTitle() : GetStr(PrevShortcuts()))); if (cur++ == ind) return (w == Key ? PrefsKey() : (w == Title? PrefsTitle() : GetStr(PrefsShortcuts()))); if (cur++ == ind) return (w == Key ? ViewKey() : (w == Title? ViewTitle() : "")); if (cur++ == ind) return (w == Key ? AppStylesKey() : (w == Title? AppStylesTitle() : "")); if (cur++ == ind) return (w == Key ? StatusKey() : (w == Title? StatusTitle() : GetStr(StatusShortcuts()))); if (cur++ == ind) return (w == Key ? MenuKey() : (w == Title? MenuTitle() : GetStr(MenuShortcuts()))); if (cur++ == ind) return (w == Key ? TabKey() : (w == Title? TabTitle() : GetStr(TabShortcuts()))); if (cur++ == ind) return (w == Key ? NavKey() : (w == Title? NavTitle() : GetStr(NavShortcuts()))); if (cur++ == ind) return (w == Key ? BooksKey() : (w == Title? BooksTitle() : GetStr(BooksShortcuts()))); // if (cur++ == ind) // return (w == Key ? Key() : (w == Title? Title() : GetStr(Shortcuts()))); if (cur++ == ind) return (w == Key ? StopKey() : (w == Title? StopTitle() : GetStr(StopShortcuts()))); if (cur++ == ind) return (w == Key ? ReloadKey() : (w == Title? ReloadTitle() : GetStr(ReloadShortcuts()))); if (cur++ == ind) return (w == Key ? LargerKey() : (w == Title? LargerTitle() : GetStr(LargerShortcuts()))); if (cur++ == ind) return (w == Key ? NormalKey() : (w == Title? NormalTitle() : GetStr(NormalShortcuts()))); if (cur++ == ind) return (w == Key ? SmallerKey() : (w == Title? SmallerTitle() : GetStr(SmallerShortcuts()))); if (cur++ == ind) return (w == Key ? TextOnlyKey() : (w == Title? TextOnlyTitle() : GetStr(TextOnlyShortcuts()))); if (cur++ == ind) return (w == Key ? EncodeKey() : (w == Title? EncodeTitle() : "")); if (cur++ == ind) return (w == Key ? SourceKey() : (w == Title? SourceTitle() : GetStr(SourceShortcuts()))); if (cur++ == ind) return (w == Key ? FullKey() : (w == Title? FullTitle() : GetStr(FullShortcuts()))); if (cur++ == ind) return (w == Key ? HistoryKey() : (w == Title? HistoryTitle() : "")); if (cur++ == ind) return (w == Key ? BackKey() : (w == Title? BackTitle() : GetStr(BackShortcuts()))); if (cur++ == ind) return (w == Key ? ForwKey() : (w == Title? ForwTitle() : GetStr(ForwShortcuts()))); if (cur++ == ind) return (w == Key ? HomeKey() : (w == Title? HomeTitle() : GetStr(HomeShortcuts()))); if (cur++ == ind) return (w == Key ? LastTabKey() : (w == Title? LastTabTitle() : GetStr(LastTabShortcuts()))); if (cur++ == ind) return (w == Key ? LastTabsKey() : (w == Title? LastTabsTitle() : GetStr(LastTabsShortcuts()))); if (cur++ == ind) return (w == Key ? SessionKey() : (w == Title? SessionTitle() : GetStr(SessionShortcuts()))); if (cur++ == ind) return (w == Key ? AllHistKey() : (w == Title? AllHistTitle() : GetStr(AllHistShortcuts()))); if (cur++ == ind) return (w == Key ? ClearKey() : (w == Title? ClearTitle() : GetStr(ClearShortcuts()))); if (cur++ == ind) return (w == Key ? BookmarksKey() : (w == Title? BookmarksTitle() : "")); if (cur++ == ind) return (w == Key ? AllBooksKey() : (w == Title? AllBooksTitle() : GetStr(AllBooksShortcuts()))); if (cur++ == ind) return (w == Key ? AddBookKey() : (w == Title? AddBookTitle() : GetStr(AddBookShortcuts()))); if (cur++ == ind) return (w == Key ? PrivacyKey() : (w == Title? PrivacyTitle() : "")); if (cur++ == ind) return (w == Key ? PrivateKey() : (w == Title? PrivateTitle() : GetStr(PrivateShortcuts()))); if (cur++ == ind) return (w == Key ? JavaScriptKey() : (w == Title? JavaScriptTitle() : GetStr(JavaScriptShortcuts()))); if (cur++ == ind) return (w == Key ? ImagesKey() : (w == Title? ImagesTitle() : GetStr(ImagesShortcuts()))); if (cur++ == ind) return (w == Key ? CookiesKey() : (w == Title? CookiesTitle() : GetStr(CookiesShortcuts()))); if (cur++ == ind) return (w == Key ? PlugInsKey() : (w == Title? PlugInsTitle() : GetStr(PlugInsShortcuts()))); if (cur++ == ind) return (w == Key ? AgentKey() : (w == Title? AgentTitle() : GetStr(AgentShortcuts()))); if (cur++ == ind) return (w == Key ? PopUpsKey() : (w == Title? PopUpsTitle() : GetStr(PopUpsShortcuts()))); if (cur++ == ind) return (w == Key ? ProxyKey() : (w == Title? ProxyTitle() : GetStr(ProxyShortcuts()))); if (cur++ == ind) return (w == Key ? EmptyKey() : (w == Title? EmptyTitle() : GetStr(EmptyShortcuts()))); if (cur++ == ind) return (w == Key ? ResetKey() : (w == Title? ResetTitle() : GetStr(ResetShortcuts()))); if (cur++ == ind) return (w == Key ? FullResetKey() : (w == Title? FullResetTitle() : GetStr(FullResetShortcuts()))); if (cur++ == ind) return (w == Key ? ToolsKey() : (w == Title? ToolsTitle() : "")); if (cur++ == ind) return (w == Key ? CompatKey() : (w == Title? CompatTitle() : "")); if (cur++ == ind) return (w == Key ? SearchKey() : (w == Title? SearchTitle() : GetStr(SearchShortcuts()))); if (cur++ == ind) return (w == Key ? KeyboardKey() : (w == Title? KeyboardTitle() : GetStr(KeyboardShortcuts()))); if (cur++ == ind) return (w == Key ? InspectorKey() : (w == Title? InspectorTitle() : GetStr(InspectorShortcuts()))); if (cur++ == ind) return (w == Key ? InspectKey() : (w == Title? InspectTitle() : GetStr(InspectShortcuts()))); if (cur++ == ind) return (w == Key ? OptionsKey() : (w == Title? OptionsTitle() : GetStr(OptionsShortcuts()))); if (cur++ == ind) return (w == Key ? WindowKey() : (w == Title? WindowTitle() : "")); if (cur++ == ind) return (w == Key ? NextTabKey() : (w == Title? NextTabTitle() : GetStr(NextTabShortcuts()))); if (cur++ == ind) return (w == Key ? PrevTabKey() : (w == Title? PrevTabTitle() : GetStr(PrevTabShortcuts()))); if (cur++ == ind) return (w == Key ? NewTabKey() : (w == Title? NewTabTitle() : GetStr(NewTabShortcuts()))); if (cur++ == ind) return (w == Key ? CloseTabKey() : (w == Title? CloseTabTitle() : GetStr(CloseTabShortcuts()))); if (cur++ == ind) return (w == Key ? CloseOtherKey() : (w == Title? CloseOtherTitle() : GetStr(CloseOtherShortcuts()))); if (cur++ == ind) return (w == Key ? CloneTabKey() : (w == Title? CloneTabTitle() : GetStr(CloneTabShortcuts()))); if (cur++ == ind) return (w == Key ? ReloadTabKey() : (w == Title? ReloadTabTitle() : GetStr(ReloadTabShortcuts()))); if (cur++ == ind) return (w == Key ? ReloadAllKey() : (w == Title? ReloadAllTitle() : GetStr(ReloadAllShortcuts()))); if (cur++ == ind) return (w == Key ? OpenNewTabKey() : (w == Title? OpenNewTabTitle() : GetStr(OpenNewTabShortcuts()))); if (cur++ == ind) return (w == Key ? OpenAdBlockKey() : (w == Title? OpenAdBlockTitle() : GetStr(OpenAdBlockShortcuts()))); if (cur++ == ind) return (w == Key ? SwapFocusKey() : (w == Title? SwapFocusTitle() : GetStr(SwapFocusShortcuts()))); if (cur++ == ind) return (w == Key ? CopyAddrKey() : (w == Title? CopyAddrTitle() : "")); if (cur++ == ind) return (w == Key ? DownsKey() : (w == Title? DownsTitle() : GetStr(DownsShortcuts()))); if (cur++ == ind) return (w == Key ? TorrentsKey() : (w == Title? TorrentsTitle() : GetStr(TorrentsShortcuts()))); if (cur++ == ind) return (w == Key ? HelpKey() : (w == Title? HelpTitle() : GetStr(HelpShortcuts()))); if (cur++ == ind) return (w == Key ? OnlineKey() : (w == Title? OnlineTitle() : GetStr(OnlineShortcuts()))); if (cur++ == ind) return (w == Key ? UpdatesKey() : (w == Title? UpdatesTitle() : GetStr(UpdatesShortcuts()))); if (cur++ == ind) return (w == Key ? AboutKey() : (w == Title? AboutTitle() : GetStr(AboutShortcuts()))); return ""; }
void CClient::ValidateSkills(bool logInvalidSkills) { if(IsGM()) return; int invalidSkills = 0; char logMessage[100]; for (int skillIndex = 0; skillIndex < MAXSKILLTYPE; skillIndex++) { switch (skillIndex) { case SKILL_MINING: case SKILL_MANUFACTURING: case SKILL_HANDATTACK: if (m_cSkillMastery[skillIndex] > (GetStr() * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (GetStr() * 2); m_cSkillMastery[skillIndex] = GetStr() * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; case SKILL_MAGICRES: if (m_cSkillMastery[skillIndex] > (m_iLevel * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (m_iLevel * 2); m_cSkillMastery[skillIndex] = m_iLevel * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; case SKILL_MAGIC: case SKILL_STAFF: if (m_cSkillMastery[skillIndex] > (GetMag() * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (GetMag() * 2); m_cSkillMastery[skillIndex] = GetMag() * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; case SKILL_FISHING: case SKILL_ARCHERY: case SKILL_SHORTSWORD: case SKILL_LONGSWORD: case SKILL_FENCING: case SKILL_AXE: case SKILL_SHIELD: case SKILL_HAMMER: if (m_cSkillMastery[skillIndex] > (GetDex() * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (GetDex() * 2); m_cSkillMastery[skillIndex] = GetDex() * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; case SKILL_ALCHEMY: case SKILL_FARMING: case SKILL_PRETENDCORPSE: if (m_cSkillMastery[skillIndex] > (GetInt() * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (GetInt() * 2); m_cSkillMastery[skillIndex] = GetInt() * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; case SKILL_POISONRES: if (m_cSkillMastery[skillIndex] > (GetVit() * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (GetVit() * 2); m_cSkillMastery[skillIndex] = GetVit() * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; default: m_iSkillSSN[skillIndex] = 0; break; } } if(logInvalidSkills && (invalidSkills > 0)) { wsprintf(logMessage, "PC(%s) A skill was too high, reduced by (%d) points", m_cCharName, invalidSkills); PutLogList(logMessage); } }
int TInifile::GetInt(const char *key, int default_val) { char buf[100]; if (GetStr(key, buf, sizeof(buf), "") <= 0) return default_val; return atoi(buf); }
// обработка единичного меню int UserMenu::ProcessSingleMenu(DList<UserMenuItem> *Menu, int MenuPos, DList<UserMenuItem> *MenuRoot, const string& MenuFileName, const wchar_t *Title) { for (;;) { int NumLine=0, ExitCode, FuncPos[24]; UserMenuItem *CurrentMenuItem = nullptr; // очистка F-хоткеев for (size_t I=0 ; I < ARRAYSIZE(FuncPos) ; I++) FuncPos[I]=-1; string strName,strShortName; CtrlObject->Cp()->ActivePanel->GetCurName(strName,strShortName); /* $ 24.07.2000 VVM + При показе главного меню в заголовок добавляет тип - FAR/Registry */ string strMenuTitle; if (Title && *Title) { strMenuTitle = Title; } else { switch (MenuMode) { case MM_LOCAL: strMenuTitle = MSG(MLocalMenuTitle); break; case MM_GLOBAL: strMenuTitle = MSG(MMainMenuTitle); strMenuTitle += L" ("; strMenuTitle += MSG(MMainMenuGlobal); strMenuTitle += L")"; break; default: strMenuTitle = MSG(MMainMenuTitle); strMenuTitle += L" ("; strMenuTitle += MSG(MMainMenuUser); strMenuTitle += L")"; } } { VMenu UserMenu(strMenuTitle,nullptr,0,ScrY-4); UserMenu.SetFlags(VMENU_WRAPMODE); UserMenu.SetHelp(L"UserMenu"); UserMenu.SetPosition(-1,-1,0,0); UserMenu.SetBottomTitle(MSG(MMainMenuBottomTitle)); MenuNeedRefresh=true; while (!UserMenu.Done()) { if (MenuNeedRefresh) { UserMenu.Hide(); // спрячем // "изнасилуем" (перезаполним :-) NumLine=FillUserMenu(UserMenu,Menu,MenuPos,FuncPos,strName,strShortName); // заставим манагер менюхи корректно отрисовать ширину и // высоту, а заодно и скорректировать вертикальные позиции UserMenu.SetPosition(-1,-1,-1,-1); UserMenu.Show(); MenuNeedRefresh=false; } int Key=UserMenu.ReadInput(); MenuPos=UserMenu.GetSelectPos(); void* userdata = UserMenu.GetUserData(nullptr, 0, MenuPos); CurrentMenuItem = userdata? *static_cast<UserMenuItem**>(userdata):nullptr; if ((unsigned int)Key>=KEY_F1 && (unsigned int)Key<=KEY_F24) { int FuncItemPos; if ((FuncItemPos=FuncPos[Key-KEY_F1])!=-1) { UserMenu.Modal::SetExitCode(FuncItemPos); continue; } } else if (Key == L' ') // исключаем пробел из "хоткеев"! continue; switch (Key) { /* $ 24.08.2001 VVM + Стрелки вправо/влево открывают/закрывают подменю соответственно */ case KEY_RIGHT: case KEY_NUMPAD6: case KEY_MSWHEEL_RIGHT: if (CurrentMenuItem && CurrentMenuItem->Submenu) UserMenu.SetExitCode(MenuPos); break; case KEY_LEFT: case KEY_NUMPAD4: case KEY_MSWHEEL_LEFT: if (Title && *Title) UserMenu.SetExitCode(-1); break; case KEY_NUMDEL: case KEY_DEL: if (CurrentMenuItem) DeleteMenuRecord(Menu,CurrentMenuItem); break; case KEY_INS: case KEY_F4: case KEY_SHIFTF4: case KEY_NUMPAD0: { bool bNew = Key == KEY_INS || Key == KEY_NUMPAD0; if (!bNew && !CurrentMenuItem) break; EditMenu(Menu,CurrentMenuItem,bNew); break; } case KEY_CTRLUP: case KEY_RCTRLUP: case KEY_CTRLDOWN: case KEY_RCTRLDOWN: { int Pos=UserMenu.GetSelectPos(); if (Pos!=UserMenu.GetItemCount()-1 && CurrentMenuItem) { if (!((Key==KEY_CTRLUP || Key==KEY_RCTRLUP) && !Pos) && !((Key==KEY_CTRLDOWN || Key==KEY_RCTRLDOWN) && Pos==UserMenu.GetItemCount()-2)) { MenuModified = MenuNeedRefresh = true; if (Key==KEY_CTRLUP || Key==KEY_RCTRLUP) { Menu->MoveBefore(Menu->Prev(CurrentMenuItem),CurrentMenuItem); MenuPos--; } else { Menu->MoveAfter(Menu->Next(CurrentMenuItem),CurrentMenuItem); MenuPos++; } } } } break; case KEY_ALTF4: // редактировать все меню case KEY_RALTF4: { File MenuFile; (*FrameManager)[0]->Unlock(); { ConsoleTitle *OldTitle=new ConsoleTitle; SaveMenu(MenuFileName); FileEditor ShellEditor(MenuFileName,CP_UNICODE,FFILEEDIT_DISABLEHISTORY,-1,-1,nullptr); delete OldTitle; ShellEditor.SetDynamicallyBorn(false); FrameManager->EnterModalEV(); FrameManager->ExecuteModal(); FrameManager->ExitModalEV(); if (!ShellEditor.IsFileChanged() || (!MenuFile.Open(MenuFileName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING))) { return 0; } } MenuRoot->Clear(); GetFileString GetStr(MenuFile); MenuFileToList(MenuRoot, MenuFile, GetStr); MenuFile.Close(); MenuModified=true; UserMenu.Hide(); return 0; // Закрыть меню } /* $ 28.06.2000 tran выход из пользовательского меню по ShiftF10 из любого уровня вложенности просто задаем ExitCode -1, и возвращаем FALSE - по FALSE оно и выйдет откуда угодно */ case KEY_SHIFTF10: //UserMenu.SetExitCode(-1); return EC_CLOSE_MENU; case KEY_SHIFTF2: // Показать главное меню return(EC_MAIN_MENU); case KEY_BS: // Показать меню из родительского каталога только в MM_LOCAL режиме if (MenuMode == MM_LOCAL) return EC_PARENT_MENU; default: UserMenu.ProcessInput(); if (MenuPos!=UserMenu.GetSelectPos()) { MenuPos=UserMenu.GetSelectPos(); userdata = UserMenu.GetUserData(nullptr, 0, MenuPos); CurrentMenuItem = userdata? *static_cast<UserMenuItem**>(userdata):nullptr; } if (Key == KEY_F1) MenuNeedRefresh=true; break; } // switch(Key) } // while (!UserMenu.Done()) ExitCode=UserMenu.Modal::GetExitCode(); if (ExitCode<0 || ExitCode>=NumLine || !CurrentMenuItem) return EC_CLOSE_LEVEL; // вверх на один уровень void* userdata = UserMenu.GetUserData(nullptr, 0, ExitCode); CurrentMenuItem = userdata? *static_cast<UserMenuItem**>(userdata):nullptr; if (!CurrentMenuItem) return EC_CLOSE_LEVEL; // вверх на один уровень } if (CurrentMenuItem->Submenu) { /* $ 20.08.2001 VVM + При вложенных меню показывает заголовки предыдущих */ string strSubMenuLabel = CurrentMenuItem->strLabel; SubstFileName(strSubMenuLabel,strName,strShortName,nullptr,nullptr,nullptr,nullptr,TRUE); apiExpandEnvironmentStrings(strSubMenuLabel, strSubMenuLabel); size_t pos; if (strSubMenuLabel.Pos(pos,L'&')) strSubMenuLabel.LShift(1,pos); string strSubMenuTitle; if (Title && *Title) { strSubMenuTitle = Title; strSubMenuTitle += L" -> "; strSubMenuTitle += strSubMenuLabel; } else { strSubMenuTitle = strSubMenuLabel; } /* $ 14.07.2000 VVM ! Если закрыли подменю, то остаться. Инече передать управление выше */ MenuPos = ProcessSingleMenu(CurrentMenuItem->Menu, 0, MenuRoot, MenuFileName, strSubMenuTitle); if (MenuPos!=EC_CLOSE_LEVEL) return MenuPos; MenuPos = ExitCode; continue; } /* $ 01.05.2001 IS Отключим до лучших времен */ //int LeftVisible,RightVisible,PanelsHidden=0; string strCmdLineDir; CtrlObject->CmdLine->GetCurDir(strCmdLineDir); string strOldCmdLine; CtrlObject->CmdLine->GetString(strOldCmdLine); int OldCmdLineCurPos = CtrlObject->CmdLine->GetCurPos(); int OldCmdLineLeftPos = CtrlObject->CmdLine->GetLeftPos(); int OldCmdLineSelStart, OldCmdLineSelEnd; CtrlObject->CmdLine->GetSelection(OldCmdLineSelStart,OldCmdLineSelEnd); CtrlObject->CmdLine->LockUpdatePanel(TRUE); // Цикл исполнения команд меню (CommandX) for (string *str=CurrentMenuItem->Commands.First(); str; str=CurrentMenuItem->Commands.Next(str)) { string strCommand = *str; string strListName, strAnotherListName; string strShortListName, strAnotherShortListName; if (!((!StrCmpNI(strCommand,L"REM",3) && IsSpaceOrEos(strCommand.At(3))) || !StrCmpNI(strCommand,L"::",2))) { /* Осталось корректно обработать ситуацию, например: if exist !#!\!^!.! far:edit < diff -c -p !#!\!^!.! !\!.! Т.е. сначала "вычислить" кусок "if exist !#!\!^!.!", ну а если выполнится, то делать дальше. Или еще пример, if exist ..\a.bat D:\FAR\170\DIFF.MY\mkdiff.bat !?&Номер патча?! ЭТО выполняется всегда, т.к. парсинг всей строки идет, а надо проверить фазу "if exist ..\a.bat", а уж потом делать выводы... */ //if(ExtractIfExistCommand(Command)) { /* $ 01.05.2001 IS Отключим до лучших времен */ /* if (!PanelsHidden) { LeftVisible=CtrlObject->Cp()->LeftPanel->IsVisible(); RightVisible=CtrlObject->Cp()->RightPanel->IsVisible(); CtrlObject->Cp()->LeftPanel->Hide(); CtrlObject->Cp()->RightPanel->Hide(); CtrlObject->Cp()->LeftPanel->SetUpdateMode(FALSE); CtrlObject->Cp()->RightPanel->SetUpdateMode(FALSE); PanelsHidden=TRUE; } */ //; int PreserveLFN=SubstFileName(strCommand, strName, strShortName, &strListName, &strAnotherListName, &strShortListName, &strAnotherShortListName, FALSE, strCmdLineDir); bool ListFileUsed=!strListName.IsEmpty()||!strAnotherListName.IsEmpty()||!strShortListName.IsEmpty()||!strAnotherShortListName.IsEmpty(); if (ExtractIfExistCommand(strCommand)) { PreserveLongName PreserveName(strShortName,PreserveLFN); RemoveExternalSpaces(strCommand); if (!strCommand.IsEmpty()) { bool isSilent=false; if (strCommand.At(0) == L'@') { strCommand.LShift(1); isSilent=true; } ProcessOSAliases(strCommand); // TODO: Ахтунг. В режиме isSilent имеем проблемы с командами, которые выводят что-то на экран // Здесь необходимо переделка, например, перед исполнением подсунуть временный экранный буфер, а потом его содержимое подсунуть в ScreenBuf... if (!isSilent) { CtrlObject->CmdLine->ExecString(strCommand,FALSE, 0, 0, ListFileUsed); } else { SaveScreen SaveScr; CtrlObject->Cp()->LeftPanel->CloseFile(); CtrlObject->Cp()->RightPanel->CloseFile(); Execute(strCommand,TRUE, 0, 0, 0, ListFileUsed, true); } } } } } // strCommand != "REM" if (!strListName.IsEmpty()) apiDeleteFile(strListName); if (!strAnotherListName.IsEmpty()) apiDeleteFile(strAnotherListName); if (!strShortListName.IsEmpty()) apiDeleteFile(strShortListName); if (!strAnotherShortListName.IsEmpty()) apiDeleteFile(strAnotherShortListName); } // while (1) CtrlObject->CmdLine->LockUpdatePanel(FALSE); if (!strOldCmdLine.IsEmpty()) // восстановим сохраненную командную строку { CtrlObject->CmdLine->SetString(strOldCmdLine, FrameManager->IsPanelsActive()); CtrlObject->CmdLine->SetCurPos(OldCmdLineCurPos, OldCmdLineLeftPos); CtrlObject->CmdLine->Select(OldCmdLineSelStart, OldCmdLineSelEnd); } /* $ 01.05.2001 IS Отключим до лучших времен */ /* if (PanelsHidden) { CtrlObject->Cp()->LeftPanel->SetUpdateMode(TRUE); CtrlObject->Cp()->RightPanel->SetUpdateMode(TRUE); CtrlObject->Cp()->LeftPanel->Update(UPDATE_KEEP_SELECTION); CtrlObject->Cp()->RightPanel->Update(UPDATE_KEEP_SELECTION); if (RightVisible) CtrlObject->Cp()->RightPanel->Show(); if (LeftVisible) CtrlObject->Cp()->LeftPanel->Show(); } */ /* $ 14.07.2000 VVM ! Закрыть меню */ /* $ 25.04.2001 DJ - сообщаем, что была выполнена команда (нужно перерисовать панели) */ return EC_COMMAND_SELECTED; } }
/* -------------------------------------------------------------------- */ BOOL GetMessage(FILE *fl) { struct unkLst *lul; /* brent, I dunno */ char c; /* clear message buffer out */ clearmsgbuf(); /* find start of message */ do { c = (uchar)fgetc(fl); } while (c != -1 && !feof(fl)); if (feof(fl)) return FALSE; /* get message's attribute byte */ msgBuf->mbattr = (uchar)fgetc(fl); GetStr(fl, msgBuf->mbId, LABELSIZE); do { c = (uchar)fgetc(fl); switch (c) { case 'A': GetFStr(fl, msgBuf->mbauth, LABELSIZE, 0); break; case 'B': GetFStr(fl, msgBuf->mbsub, 79 , 0); break; case 'D': GetStr(fl, msgBuf->mbtime, LABELSIZE); break; case 'F': GetFStr(fl, msgBuf->mbfwd, LABELSIZE, 0); break; case 'G': GetFStr(fl, msgBuf->mbgroup, LABELSIZE, 0); break; case 'I': GetStr(fl, msgBuf->mbreply, LABELSIZE); break; case 'J': GetFStr(fl, msgBuf->mbcreg, LABELSIZE, 0); break; case 'j': GetFStr(fl, msgBuf->mbccont, LABELSIZE, 0); break; case 'M': /* will be read off disk later */ break; case 'N': GetFStr(fl, msgBuf->mbtitle, LABELSIZE, 0); break; case 'n': GetFStr(fl, msgBuf->mbsur, LABELSIZE, 0); break; case 'O': GetFStr(fl, msgBuf->mboname, LABELSIZE, 0); break; case 'o': GetFStr(fl, msgBuf->mboreg, LABELSIZE, 0); break; case 'P': GetFStr(fl, msgBuf->mbfpath, 256 , 0); break; case 'p': GetFStr(fl, msgBuf->mbtpath, 256 , 0); break; case 'Q': GetFStr(fl, msgBuf->mbocont, LABELSIZE, 0); break; case 'q': GetFStr(fl, msgBuf->mbczip, LABELSIZE, 0); break; case 'R': GetFStr(fl, msgBuf->mbroom, LABELSIZE, 0); break; case 'S': GetStr(fl, msgBuf->mbsrcId, LABELSIZE); break; case 's': GetFStr(fl, msgBuf->mbsoft, LABELSIZE, 0); break; case 'T': GetFStr(fl, msgBuf->mbto, LABELSIZE, 0); break; /* case 'X': GetStr(fl, msgBuf->mbx, LABELSIZE); break; */ case 'Z': GetFStr(fl, msgBuf->mbzip, LABELSIZE, 0); break; case 'z': GetFStr(fl, msgBuf->mbrzip, LABELSIZE, 0); break; case '.': GetFStr(fl, msgBuf->mbsig, 90 , 0); break; case '_': GetFStr(fl, msgBuf->mbusig, 90 , 0); break; /* nodephone */ case 'H': GetFStr(fl, msgBuf->mbophone,LABELSIZE, 0); break; case 'h': GetFStr(fl, msgBuf->mbzphone,LABELSIZE, 0); break; case '\0': break; #ifdef GOODBYE default: GetStr(fl, msgBuf->mbtext, cfg.maxtext); /* discard unknown field */ msgBuf->mbtext[0] = '\0'; break; #endif default: { /* try to store unknown field */ if ((lul = addUnknownList()) != NULL) { lul->whatField = c; GetStr(fl, lul->theValue, MAXUNKLEN); } else { /* cannot save it - discard unknown field */ GetStr(fl, msgBuf->mbtext, MAXTEXT); msgBuf->mbtext[0] = '\0'; } } } } while (c != 'M' && !feof(fl)); if (feof(fl)) { return FALSE; } GetFStr(fl, msgBuf->mbtext, MAXTEXT, 0); /* get the message field */ if (!*msgBuf->mboname) { strcpy(msgBuf->mboname, node.ndname); } if (!*msgBuf->mboreg) { strcpy(msgBuf->mboreg, node.ndregion); } if (!*msgBuf->mbsrcId) { strcpy(msgBuf->mbsrcId, msgBuf->mbId); } /* * If the other node did not set up a from path, do it. */ if (!*msgBuf->mbfpath) { if (strcmpi(msgBuf->mboname, node.ndname) == 0) { strcpy(msgBuf->mbfpath, msgBuf->mboname); } else { /* last node did not originate, make due with what we got... */ strcpy(msgBuf->mbfpath, msgBuf->mboname); strcat(msgBuf->mbfpath, "!..!"); strcat(msgBuf->mbfpath, node.ndname); } } return TRUE; }
CString NL_QQwry::GetCountryLocal(BYTE bMode,int ioffset) { CString buf=""; if(bMode==1)//X 没有跳 { buf=GetStr(ioffset); buf+=" "; buf+=GetStr(); } if(bMode==2)//X Country不跳 Local 跳 { buf=GetStr(ioffset); buf+=" "; buf+=GetStr(m_ei.offset1); } if(bMode==3)//2 Country跳 local不跳 { buf=GetStr(m_ei.offset1); buf+=" "; buf+=GetStr(ioffset+4); } if(bMode==4)//2 Country跳 local跳 { buf=GetStr(m_ei.offset1); buf+=" "; buf+=GetStr(m_ei.offset2); } if(bMode==5)//1 没有跳 { buf=GetStr(m_ei.offset1); buf+=" "; buf+=GetStr(); } if(bMode==6)//1 Country不跳 Local 跳 { buf=GetStr(m_ei.offset1); buf+=" "; buf+=GetStr(m_ei.offset2); } if(bMode==7)//1 Country跳 Local 不跳 { buf=GetStr(m_ei.offset2); buf+=" "; buf+=GetStr(m_ei.offset1+4); } if(bMode==8)//1 Country跳 Local跳 { buf=GetStr(m_ei.offset1); buf+=" "; buf+=GetStr(m_ei.offset2); } return buf; }
string GetFn(const std::string& k) { return boost::regex_replace(GetStr(k), boost::regex("~"), Util::HomeDir()); }
void LoadTable() { FILE *stream; TCHAR szStr[1200] = {0}; TCHAR szTabFileName[MAX_PATH << 1]={ 0}; LPTSTR lpTabFileName = szTabFileName; lpTabFileName += GetSystemDirectory(szTabFileName, MAX_PATH); if (*(lpTabFileName - 1) != _T('\\')) { *lpTabFileName++ = _T('\\'); } *lpTabFileName = 0; _tcscpy_s(lpTabFileName, MAX_PATH, TABFILENAME); if(EINVAL == _tfopen_s(&stream, szTabFileName, TEXT("r")) || !stream) { TRACE(TEXT("%s can not found"), szTabFileName); exit(1); } while( !feof( stream )) { GetStr(stream,szStr); switch( GetSegment(szStr)) { case 1: //END_SEGMENT break; case 2: //COMMENT break; case 3: //PUNCTUATION if( feof( stream ) ) { goto my_exit; } GetStr(stream,szStr); while(GetSegment(szStr) != 1) { if( GetSegment(szStr) != 2) { LoadPunct( szStr ); } if( feof( stream ) ) { goto my_exit; } GetStr(stream,szStr); } break; case 4: //DICTIONARY if( feof( stream ) ) { goto my_exit; } GetStr(stream,szStr); while(GetSegment(szStr) != 1) { if( GetSegment(szStr) != 2) { LoadHZDictionary( szStr ); } if( feof( stream ) ) { goto my_exit; } GetStr(stream,szStr); } break; default: break; } } my_exit: fclose(stream); return; }
vd::string ParamSet::GetStr( Core::Symbol name) const { return GetStr(name, ParamSet::Empty); }
/* Terminal writig */ void terminal( char * string){ int retPls = 0; char string_save[200]; int n; float m,o; if(strcmp (string,"help")==0){ SendStr(" \n\r"); SendStr(" \r"); SendStr("\r\n ***********************************************************************************"); SendStr("\r\n ** help menu **"); SendStr("\r\n ***********************************************************************************"); SendStr("\r\n "); SendStr(" \r auto start automatic mode and stop manual mode \r\n"); SendStr(" \r manual start manual mode and stop automatic mode \r\n"); SendStr(" \r speed update speed value (only in manual mode) \r\n"); SendStr(" \r steering update steering value (only in manual mode) \r\n"); SendStr(" \r camera update position and voltage analog values for propulsion module \r\n"); SendStr(" \r meas print currents and voltage analog values for propulsion module \r\n"); SendStr(" \r help print supported commands \r\n"); SendStr("\r control:# "); } else if(strcmp (string,"auto")==0){ SendStr("\n\r automatic mode is running\n\r"); i2c_cgroup_function(1); SendStr("\r control:# "); } else if(strcmp (string,"manual")==0){ SendStr("\n\r manual mode is running\n\r"); SendStr("\r control:# "); } else if(strcmp (string,"speed")==0){ SendStr("\n\r enter a value between 0 (stop) and 254 (full speed), 255 (reverse, speed is fixed): \n\r"); char value[4]; int i; GetStr(value); if(value[0]=='-') SendStr("\n\r error : failed value (0 to 255) "); if ( value[0] == '2'){ if ( value[1] == '5'){ if (value[2] == '5'){ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH2_Pulse(retPls); PWM_CH1_Pulse(0); } } } else if(value[3]=='\0'){ if(value[2]!='\0'){ if(value[0] =='2'){ if(value[1]<='5'){ if(value[2]<='5'){ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH1_Pulse(retPls); PWM_CH2_Pulse(0); } else SendStr("\n\r error : failed value (0 to 255) "); } else SendStr("\n\r error : failed value (0 to 255) "); } else if (value[0]<='2'){ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH1_Pulse(retPls); PWM_CH2_Pulse(0); } else SendStr("\n\r error : failed value (0 to 255)"); } else for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH1_Pulse(retPls); PWM_CH2_Pulse(0); } else SendStr("\n\r error : failed value (0 to 255) "); SendStr("\n\r control:# "); } else if(strcmp (string,"steering")==0){ SendStr("\n\r enter value between -127 (full left) and 128 (full right), 0 is the middle position : \n\r"); char value[5]; int i; GetStr(value); if(value[0]=='-'){ if(value[1]=='0') SendChar(value[1]); else if (value[3]=='\0' || value[2]=='\0'){ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH3_Pulse(retPls); HAL_Delay(500); PWM_CH3_Pulse(65499); HAL_Delay(500); } else if(value[4]=='\0'){ if(value[3]!='\0'){ if(value[1] =='1'){ if(value[2]<='2'){ if(value[3]<='7'){ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH3_Pulse(retPls); HAL_Delay(500); PWM_CH3_Pulse(65499); HAL_Delay(500); } else SendStr("\n\r error : failed value (-127 to 128) "); } else SendStr("\n\r error : failed value (-127 to 128) "); } else SendStr("\n\r error : failed value (-127 to 128) "); } else for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH3_Pulse(retPls); HAL_Delay(500); PWM_CH3_Pulse(65499); HAL_Delay(500); } else { SendStr("\n\r error : failed value (-127 to 128) "); } } else{ if(value[3]=='\0'){ if(value[2]!='\0'){ if(value[0] =='1'){ if(value[1]<='2'){ if(value[2]<='8'){ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH3_Pulse(retPls); HAL_Delay(500); PWM_CH3_Pulse(65499); HAL_Delay(500); } else SendStr("\n\r error : failed value (-127 to 128) "); } else SendStr("\n\r error : failed value (-127 to 128) "); } else SendStr("\n\r error : failed value (-127 to 128) "); } else for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH3_Pulse(retPls); HAL_Delay(500); PWM_CH3_Pulse(65499); HAL_Delay(500); } else{ SendStr("\n\r error : failed value (-127 to 128) "); } } SendStr("\n\r control:# "); } else if(strcmp (string,"camera")==0){ SendStr("\n\r enter value between -127 (full left) and 128 (full right), 0 is the middle position : \n\r"); char value[5]; int i; GetStr(value); if(value[0]=='-'){ if(value[1]=='0'){ SendChar(value[1]); retPls = atoi(value); PWM_CH4_Pulse(retPls); HAL_Delay(5000); } else if (value[3]=='\0' || value[2]=='\0'){ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH4_Pulse(retPls); HAL_Delay(5000); } else if(value[4]=='\0'){ if(value[3]!='\0'){ if(value[1] =='1'){ if(value[2]<='2'){ if(value[3]<='7'){ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH4_Pulse(retPls); HAL_Delay(5000); } else SendStr("\n\r error : failed value (-127 to 128) "); } else SendStr("\n\r error : failed value (-127 to 128) "); } else SendStr("\n\r error : failed value (-127 to 128) "); } else{ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH4_Pulse(retPls); HAL_Delay(5000); } } else SendStr("\n\r error : failed value (-127 to 128) "); } else{ if(value[3]=='\0'){ if(value[2]!='\0'){ if(value[0] =='1'){ if(value[1]<='2'){ if(value[2]<='8'){ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH4_Pulse(retPls); HAL_Delay(5000); } else SendStr("\n\r error : failed value (-127 to 128) "); } else SendStr("\n\r error : failed value (-127 to 128) "); } else SendStr("\n\r error : failed value (-127 to 128) "); } else{ for(i=0;i<=3;i++){ SendChar(value[i]); } retPls = atoi(value); PWM_CH4_Pulse(retPls); HAL_Delay(5000); } } else SendStr("\n\r error : failed value (-127 to 128) "); } SendStr("\n\r control:# "); } else if(strcmp (string,"meas")==0){ SendStr("\n\r currents and voltage analog values for propulsion module : \n\r"); n=adc1(); m=n*3.3/255; o=m*100/24; sprintf(string_save," ADC value: adc1=%d, V=%f, I=%f \r\n control :# ", n,m,o); SendStr(string_save); SendStr("\n\r control:# "); } else{ SendStr("\n\r ERROR : command not supported. Enter help to know the supported command \n\r"); SendStr("\r control:# "); } }
int parse_metalink(struct Configurable *config, struct OutStruct *outs, const char *metalink_url) { metalink_error_t r; metalink_t* metalink; metalink_file_t **files; bool warnings = FALSE; /* metlaink_parse_final deletes outs->metalink_parser */ r = metalink_parse_final(outs->metalink_parser, NULL, 0, &metalink); outs->metalink_parser = NULL; if(r != 0) { return -1; } if(metalink->files == NULL) { fprintf(config->errors, "Metalink: parsing (%s) WARNING " "(missing or invalid file name)\n", metalink_url); metalink_delete(metalink); return -1; } for(files = metalink->files; *files; ++files) { struct getout *url; /* Skip an entry which has no resource. */ if(!(*files)->resources) { fprintf(config->errors, "Metalink: parsing (%s) WARNING " "(missing or invalid resource)\n", metalink_url, (*files)->name); continue; } if(config->url_get || ((config->url_get = config->url_list) != NULL)) { /* there's a node here, if it already is filled-in continue to find an "empty" node */ while(config->url_get && (config->url_get->flags & GETOUT_URL)) config->url_get = config->url_get->next; } /* now there might or might not be an available node to fill in! */ if(config->url_get) /* existing node */ url = config->url_get; else /* there was no free node, create one! */ url = new_getout(config); if(url) { metalinkfile *mlfile; mlfile = new_metalinkfile(*files); if(!mlfile->checksum) { warnings = TRUE; fprintf(config->errors, "Metalink: parsing (%s) WARNING " "(digest missing)\n", metalink_url); } /* Set name as url */ GetStr(&url->url, mlfile->filename); /* set flag metalink here */ url->flags |= GETOUT_URL | GETOUT_METALINK; if(config->metalinkfile_list) { config->metalinkfile_last->next = mlfile; config->metalinkfile_last = mlfile; } else { config->metalinkfile_list = config->metalinkfile_last = mlfile; } } } metalink_delete(metalink); return (warnings) ? -2 : 0; }
int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) { STATUSMSGINFO smi; bool bEnablePopup = true, bEnableSound = true; char *szProto = GetContactProto(hContact); smi.proto = szProto; smi.hContact = hContact; smi.compare = CompareStatusMsg(&smi, cws, "LastStatusMsg"); if (smi.compare == COMPARE_SAME) goto skip_notify; if (cws->value.type == DBVT_DELETED) db_unset(hContact, "UserOnline", "LastStatusMsg"); else db_set(hContact, "UserOnline", "LastStatusMsg", &cws->value); //don't show popup when mradio connecting and disconnecting if (_stricmp(szProto, "mRadio") == 0 && !cws->value.type == DBVT_DELETED) { wchar_t buf[MAX_PATH]; mir_snwprintf(buf, L" (%s)", TranslateT("connecting")); T2Utf pszUtf(buf); mir_snwprintf(buf, L" (%s)", TranslateT("aborting")); T2Utf pszUtf2(buf); mir_snwprintf(buf, L" (%s)", TranslateT("playing")); T2Utf pszUtf3(buf); if (_stricmp(cws->value.pszVal, pszUtf) == 0 || _stricmp(cws->value.pszVal, pszUtf2) == 0 || _stricmp(cws->value.pszVal, pszUtf3) == 0) goto skip_notify; } // check per-contact ignored events if (db_get_b(hContact, MODULE, "EnableSMsgNotify", 1) == 0) bEnableSound = bEnablePopup = false; // we're offline or just connecting int myStatus = Proto_GetStatus(szProto); if (myStatus == ID_STATUS_OFFLINE) goto skip_notify; char dbSetting[64]; mir_snprintf(dbSetting, "%s_enabled", szProto); // this proto is not set for status message notifications if (db_get_b(NULL, MODULE, dbSetting, 1) == 0) goto skip_notify; mir_snprintf(dbSetting, "%d", IDC_CHK_STATUS_MESSAGE); // status message change notifications are disabled if (db_get_b(NULL, MODULE, dbSetting, 1) == 0) goto skip_notify; if (SkipHiddenContact(hContact)) goto skip_notify; // check if our status isn't on autodisable list if (opt.AutoDisable) { char statusIDs[12], statusIDp[12]; mir_snprintf(statusIDs, "s%d", myStatus); mir_snprintf(statusIDp, "p%d", myStatus); bEnableSound = db_get_b(0, MODULE, statusIDs, 1) ? FALSE : bEnableSound; bEnablePopup = db_get_b(0, MODULE, statusIDp, 1) ? FALSE : bEnablePopup; } // check flags if ((!(templates.PopupSMsgFlags & NOTIFY_REMOVE_MESSAGE) && (smi.compare == COMPARE_DEL)) || (!(templates.PopupSMsgFlags & NOTIFY_NEW_MESSAGE) && (smi.compare == COMPARE_DIFF))) bEnablePopup = false; if (db_get_b(0, MODULE, szProto, 1) == 0 && !opt.PSMsgOnConnect) bEnablePopup = false; if (bEnablePopup && db_get_b(hContact, MODULE, "EnablePopups", 1) && !opt.TempDisabled) { // cut message if needed wchar_t *copyText = nullptr; if (opt.PSMsgTruncate && (opt.PSMsgLen > 0) && smi.newstatusmsg && (mir_wstrlen(smi.newstatusmsg) > opt.PSMsgLen)) { wchar_t buff[MAX_TEXT_LEN + 3]; copyText = mir_wstrdup(smi.newstatusmsg); wcsncpy(buff, smi.newstatusmsg, opt.PSMsgLen); buff[opt.PSMsgLen] = 0; mir_wstrcat(buff, L"..."); replaceStrW(smi.newstatusmsg, buff); } wchar_t *str; if (smi.compare == COMPARE_DEL) { char protoname[MAX_PATH]; mir_snprintf(protoname, "%s_TPopupSMsgRemoved", szProto); DBVARIANT dbVar = { 0 }; if (db_get_ws(NULL, MODULE, protoname, &dbVar)) { str = GetStr(&smi, DEFAULT_POPUP_SMSGREMOVED); } else { str = GetStr(&smi, dbVar.ptszVal); db_free(&dbVar); } } else { char protoname[MAX_PATH]; mir_snprintf(protoname, "%s_TPopupSMsgChanged", szProto); DBVARIANT dbVar = { 0 }; if (db_get_ws(NULL, MODULE, protoname, &dbVar)) { str = GetStr(&smi, DEFAULT_POPUP_SMSGCHANGED); } else { str = GetStr(&smi, dbVar.ptszVal); db_free(&dbVar); } } ShowChangePopup(hContact, Skin_LoadProtoIcon(szProto, db_get_w(hContact, szProto, "Status", ID_STATUS_ONLINE)), ID_STATUS_STATUSMSG, str); mir_free(str); if (copyText) { mir_free(smi.newstatusmsg); smi.newstatusmsg = copyText; } } if (opt.BlinkIcon && opt.BlinkIcon_ForMsgs && !opt.TempDisabled) { HICON hIcon = opt.BlinkIcon_Status ? Skin_LoadProtoIcon(szProto, db_get_w(hContact, szProto, "Status", ID_STATUS_ONLINE)) : Skin_LoadIcon(SKINICON_OTHER_USERONLINE); wchar_t str[256]; mir_snwprintf(str, TranslateT("%s changed status message to %s"), Clist_GetContactDisplayName(hContact), smi.newstatusmsg); BlinkIcon(hContact, hIcon, str); } if (bEnableSound && db_get_b(0, "Skin", "UseSound", TRUE) && db_get_b(hContact, MODULE, "EnableSounds", 1) && !opt.TempDisabled) { if (smi.compare == COMPARE_DEL) PlayChangeSound(hContact, StatusListEx[ID_STATUS_SMSGREMOVED].lpzSkinSoundName); else PlayChangeSound(hContact, StatusListEx[ID_STATUS_SMSGCHANGED].lpzSkinSoundName); } BOOL bEnableLog = opt.SMsgLogToDB && db_get_b(hContact, MODULE, "EnableSMsgLogging", 1); if (bEnableLog && (!opt.SMsgLogToDB_WinOpen || CheckMsgWnd(hContact))) LogSMsgToDB(&smi, smi.compare == COMPARE_DEL ? templates.LogSMsgRemoved : templates.LogSMsgChanged); if (opt.SMsgLogToFile && db_get_b(hContact, MODULE, "EnableSMsgLogging", 1)) { wchar_t stzDate[MAX_STATUSTEXT], stzTime[MAX_STATUSTEXT], stzText[MAX_TEXT_LEN]; GetTimeFormat(LOCALE_USER_DEFAULT, 0, nullptr, L"HH':'mm", stzTime, _countof(stzTime)); GetDateFormat(LOCALE_USER_DEFAULT, 0, nullptr, L"dd/MM/yyyy", stzDate, _countof(stzDate)); wchar_t *str; if (smi.compare == COMPARE_DEL) str = GetStr(&smi, templates.LogSMsgRemoved); else str = GetStr(&smi, templates.LogSMsgChanged); mir_snwprintf(stzText, L"%s, %s. %s %s\r\n", stzDate, stzTime, Clist_GetContactDisplayName(hContact), str); LogToFile(stzText); mir_free(str); } skip_notify: replaceStrW(smi.newstatusmsg, nullptr); replaceStrW(smi.oldstatusmsg, nullptr); return 1; }
vector<string> Configuration::GetStrArray(string const & field) const { string const param_str = GetStr(field); return tokenize_str(param_str); }
void DizList::Read(const string& Path, const string* DizName) { Reset(); TPreRedrawFuncGuard preRedrawFuncGuard(DizList::PR_ReadingMsg); const wchar_t *NamePtr=Opt.Diz.strListNames; for (;;) { if (DizName) { strDizFileName = *DizName; } else { strDizFileName = Path; if (!PathCanHoldRegularFile(strDizFileName)) break; string strArgName; if (!(NamePtr=GetCommaWord(NamePtr,strArgName))) break; AddEndSlash(strDizFileName); strDizFileName += strArgName; } File DizFile; if (DizFile.Open(strDizFileName,GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING)) { GetFileString GetStr(DizFile); wchar_t *DizText; int DizLength; clock_t StartTime=clock(); uintptr_t CodePage=CP_DEFAULT; bool bSigFound=false; if (!GetFileFormat(DizFile,CodePage,&bSigFound,false) || !bSigFound) CodePage = Opt.Diz.AnsiByDefault ? CP_ACP : CP_OEMCP; while (GetStr.GetString(&DizText, CodePage, DizLength) > 0) { if (!(DizCount & 127) && clock()-StartTime>1000) { SetCursorType(FALSE,0); PR_ReadingMsg(); if (CheckForEsc()) break; } RemoveTrailingSpaces(DizText); if (*DizText) AddRecord(DizText); } OrigCodePage=CodePage; Modified=false; DizFile.Close(); return; } if (DizName) break; } Modified=false; strDizFileName.Clear(); }
vector<double> Configuration::GetFloatArray(string const & field) const { string const param_str = GetStr(field); return tokenize_float(param_str); }
int SysopMenu(void) { char ibuf[200]; char nbuf[200]; int i; char ch; USERINFO uinfo; FILE *fp; DIR *dp; int menu=TRUE; int done=FALSE; int twit=FALSE; struct dirent *dirinfo; struct stat *st; syslog(LOG_INFO,"%s USER EDITING.",username); printf("\n\033[1;35mUser to edit>\033[0m "); GetStrName(nbuf,30); if(nbuf[0] == '\n') return 0; if(is_sysop(nbuf) == TRUE) { printf("\n\033[1;35mUser [\033[31m%s\033[1;35m] ",nbuf); printf("is a sysop\033[31m!\033[35m can not edit\033[31m!"); return -1; } if(existuser(nbuf) == FALSE) { printf("\n\033[1;35mUser [\033[31m%s\033[35m] Does Not Exist\033[31m!\033[0m",nbuf); return -1; } else { printf("\n\033[1;35mUser [\033[31m%s\033[35m] Found\033[31m!\n\033[0m",nbuf); } sprintf(ibuf,"%s/users/%s/info",BBSDIR,nbuf); if((fp = fopen(ibuf,"r")) == NULL) return -1; if(fread((char *)&uinfo,sizeof(USERINFO),1,fp) != 1) return -1; fclose(fp); while(!done) { if(menu) { printf("\n"); printf("\033[1;32m"); printf("%s \033[31m(\033[1;35m",nbuf); if(uinfo.sex == 'f'||uinfo.sex == 'F') printf("female"); else if(uinfo.sex == 'm'||uinfo.sex == 'M') printf("male"); else printf("unknown"); printf("\033[1;31m)\n"); printf("\033[1;31m1st login was \033[1;31m"); printf("%ld, \033[1;35m[\033[31mD\033[35m]elete\n",uinfo.time_firston); sprintf(ibuf,"%s/users/%s/twit",BBSDIR,nbuf); if((fp = fopen(ibuf,"r")) != NULL) { printf("\033[1;35mThis User *\033[1;31mIS\033[1;35m* a [\033[1;31mT\033[1;35m]wit"); twit = TRUE; fclose(fp); } else { printf("\033[1;35mThis User is *\033[1;31mNOT\033[1;35m* a [\033[1;31mT\033[1;35m]wit"); twit = FALSE; } printf("\n\n"); printf("\033[1;35m1\033[0m> \033[1;32mEmail Address"); printf("\033[0m: \033[1;35m%s\n",uinfo.email); printf("\033[1;35m2\033[0m> \033[1;32mPassword"); printf("\033[0m: \033[1;35m"); //for(i=0;i<strlen(uinfo.pass);i++) printf("x"); printf("%s",uinfo.pass); printf("\n"); printf("\033[1;35m3\033[0m> \033[1;32mStatus"); printf("\033[0m: \033[1;35m"); sprintf(ibuf,"%s/users/%s/keycode",BBSDIR,nbuf); if((fp = fopen(ibuf,"r")) == NULL) { printf("Regular User"); } else { printf("New User"); fclose(fp); } printf("\n\033[1;35m4\033[0m> \033[1;32mView \033[1;31m%s\033[1;32m'\033[1;31ms \033[1;32miP Log.\033[0m",nbuf); printf("\n\n"); } printf("\033[1;35mEdit %s> ",nbuf); ch = GetKey(0); switch(ch) { case 'D': case 'd': printf("\n\n\033[1;35m -> Type delete the bastard to Delete [\033[1;31m%s\033[1;35m] <-\n\n",nbuf); printf("Just Hit [\033[1;31mENTER\033[1;35m] to Cancel\033[1;31m:\033[1;33m "); GetStr(ibuf,18,0); if(!strcmp(ibuf,"delete the bastard")) { // TRUE delete user! printf("\n"); sprintf(ibuf,"%s/users/%s/",BBSDIR,nbuf); dp = opendir(ibuf); while((dirinfo = readdir(dp)) != NULL) { if(dirinfo->d_name[0] == '.') continue; sprintf(ibuf,"%s/users/%s/%s", BBSDIR, nbuf, dirinfo->d_name); if(unlink(ibuf)) { printf("\033[0;32m%s..not deleted!\n",dirinfo->d_name); } else { printf("\033[0;32m%s..deleted!\n",dirinfo->d_name); } } closedir(dp); sprintf(ibuf,"%s/users/%s",BBSDIR,nbuf); if(rmdir(ibuf)) { printf("\033[1;35m[\033[1;31m%s\033[1;35m] failed to delete!",nbuf); } else { printf("\033[1;35m[\033[1;31m%s\033[1;35m] deleted successfully",nbuf); } } else { printf("\n\033[1;32mDid *not* delete %s!",nbuf); } done = TRUE; break; case '3': sprintf(ibuf,"%s/users/%s/keycode",BBSDIR,nbuf); if(unlink(ibuf)) { printf("\nno keycode deleted!"); } else { printf("\nkeycode deleted!"); } done = TRUE; break; case '4': printf("iP Log..\n\n\033[0m"); sprintf(ibuf,"%s/users/%s/ipRecord",BBSDIR,nbuf); CatFileDirect(ibuf); done = TRUE; break; case 'T': case 't': sprintf(ibuf,"%s/users/%s/twit",BBSDIR,nbuf); if(twit) { if(unlink(ibuf)) { printf("\n\n\033[1;33m%s *NOT* UnTwited!!\n",nbuf); } else { printf("\n\n\033[1;33m%s UnTwited!!\n",nbuf); } } else { if((fp = fopen(ibuf,"w")) == NULL) { printf("\n\n\033[1;33mCan't create TWIT for %s!!\n",nbuf); return; } fprintf(fp,"%s, you are a twit\n",nbuf); fclose(fp); printf("\n\n\033[1;33m%s is a Twit!!\n",nbuf); } done = FALSE; break; default: done = TRUE; break; } } }
DWORD WINAPI RlogindClientThread(LPVOID param) { RLOGIND rlogind = *((RLOGIND *)param); RLOGIND *rloginds = (RLOGIND *)param; rloginds->gotinfo = TRUE; int threadnum=rlogind.cthreadnum; char LocalUser[16], RemoteUser[16], TerminalType[64], HostName[100], Buffer[16]; LPHOSTENT HostEnt; SOCKADDR_IN csin; TIMEVAL timeout; timeout.tv_sec = 10; timeout.tv_usec = 0; fd_set fd; FD_ZERO(&fd); FD_SET(threads[threadnum].sock, &fd); if (fselect(0, &fd, NULL, NULL, &timeout) == 0) { fclosesocket(threads[threadnum].sock); clearthread(threadnum); ExitThread(0); } frecv(threads[threadnum].sock, (char *)&Buffer, 1, 0); GetStr(threads[threadnum].sock, RemoteUser, sizeof(RemoteUser)); GetStr(threads[threadnum].sock, LocalUser, sizeof(LocalUser)); GetStr(threads[threadnum].sock, TerminalType, sizeof(TerminalType)); int csin_len = sizeof(csin); if (fgetpeername(threads[threadnum].sock, (LPSOCKADDR)&csin, &csin_len) != 0) { addlogv("[RLOGIND]: Error: getpeername(): <%d>.", fWSAGetLastError()); fclosesocket(threads[threadnum].sock); clearthread(threadnum); ExitThread(0); } if ((HostEnt = fgethostbyaddr((char *)&csin.sin_addr, sizeof(csin.sin_addr), PF_INET)) == NULL) sprintf(HostName, finet_ntoa(csin.sin_addr)); else strcpy(HostName, HostEnt->h_name); frecv(threads[threadnum].sock, (char *)Buffer, sizeof(Buffer), 0); fsend(threads[threadnum].sock, "", 1, 0); if (!InsecureFlag && !CheckLogin(RemoteUser,HostName,rlogind.username,csin.sin_addr.s_addr)) { fsend(threads[threadnum].sock, "PERMISSION DENIED.", sizeof("PERMISSION DENIED."), 0); fshutdown(threads[threadnum].sock,SD_BOTH); fclosesocket(threads[threadnum].sock); clearthread(threadnum); ExitThread(0); } addlogv("[RLOGIND]: User logged in: <%s@%s>.", RemoteUser, HostName); if (!SessionRun(threadnum)) { addlogv("[RLOGIND]: Error: SessionRun(): <%d>.", GetLastError()); fshutdown(threads[threadnum].sock,SD_BOTH); fclosesocket(threads[threadnum].sock); clearthread(threadnum); ExitThread(1); } addlogv("[RLOGIND]: User logged out: <%s@%s>.", RemoteUser, HostName); fshutdown(threads[threadnum].sock,SD_BOTH); fclosesocket(threads[threadnum].sock); clearthread(threadnum); ExitThread(0); }
//#include <cplex.h> // void CliquePartitionProblem::cps(std::string const &fileName, ILpSolver & solver) const { int const n(nV()); // char const binary(solver.binary()); char const continuous(solver.continuous()); char const leq(solver.leq()); char const eq(solver.eq()); char const geq(solver.geq()); // ColumnBuffer columnBuffer(continuous); DoubleVector denseCost(n * (n - 1), 0); for (auto const & e : _costs) { int const u(e._i); int const v(e._j); int const id(ijtok(n, u, v)); denseCost[id] = e._v; } //cpCost(denseCost); //IntVector index(n * (n - 1)); int nCols(0); for (int u(0); u < nV(); ++u) { for (int v(u + 1); v < nV(); ++v, ++nCols) { int const id(ijtok(n, u, v)); columnBuffer.add(denseCost[id], binary, 0, 1, GetStr("x_", u, "_", v)); if (id != nCols) { std::cout << "wrong numbering" << std::endl; std::exit(-1); } } } columnBuffer.add(cst(), continuous, 1, 1, "CST"); solver.add(columnBuffer); RowBuffer rowBuffer; double const eps(1e-20); for (int u(0); u < nV(); ++u) { for (int v(u + 1); v < nV(); ++v) { int const uv(ijtok(n, u, v)); for (int w(v + 1); w < nV(); ++w) { int const uw(ijtok(n, u, w)); int const vw(ijtok(n, v, w)); if (denseCost[uv] > -eps || denseCost[vw] > -eps) { rowBuffer.add(1, leq, GetStr("T_", u, "_", v, "_", w)); rowBuffer.add(uv, 1); rowBuffer.add(vw, 1); rowBuffer.add(uw, -1); } if (denseCost[vw] > -eps || denseCost[uw] > -eps) { rowBuffer.add(1, leq, GetStr("T_", v, "_", w, "_", u)); rowBuffer.add(vw, 1); rowBuffer.add(uw, 1); rowBuffer.add(uv, -1); } if (denseCost[uw] > -eps || denseCost[uv] > -eps) { rowBuffer.add(1, leq, GetStr("T_", w, "_", u, "_", v)); rowBuffer.add(uw, 1); rowBuffer.add(uv, 1); rowBuffer.add(vw, -1); } } } } solver.add(rowBuffer); solver.maximize(); solver.write(fileName + ".lp"); solver.run(); double objval = solver.objValue(); std::cout << "optimal solution value : " << std::setprecision(20) << objval << std::endl; }
void UserMenu::ProcessUserMenu(bool ChoiceMenuType) { // Путь к текущему каталогу с файлом LocalMenuFileName string strMenuFilePath; CtrlObject->CmdLine->GetCurDir(strMenuFilePath); // по умолчанию меню - это FarMenu.ini MenuMode = MM_LOCAL; MenuModified = MenuNeedRefresh = false; if (ChoiceMenuType) { int EditChoice=Message(0,3,MSG(MUserMenuTitle),MSG(MChooseMenuType),MSG(MChooseMenuMain),MSG(MChooseMenuLocal),MSG(MCancel)); if (EditChoice<0 || EditChoice==2) return; if (!EditChoice) { MenuMode = MM_GLOBAL; strMenuFilePath = Opt.GlobalUserMenuDir; } } // основной цикл обработки bool FirstRun=true; int ExitCode = 0; while ((ExitCode != EC_CLOSE_LEVEL) && (ExitCode != EC_CLOSE_MENU) && (ExitCode != EC_COMMAND_SELECTED)) { string strMenuFileFullPath = strMenuFilePath; AddEndSlash(strMenuFileFullPath); strMenuFileFullPath += LocalMenuFileName; Menu.Clear(); // Пытаемся открыть файл на локальном диске File MenuFile; bool FileOpened = PathCanHoldRegularFile(strMenuFilePath) ? MenuFile.Open(strMenuFileFullPath,GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING) : false; if (FileOpened) { GetFileString GetStr(MenuFile); MenuFileToList(&Menu, MenuFile, GetStr); MenuFile.Close(); } else if (MenuMode != MM_USER) { // Файл не открылся. Смотрим дальше. if (MenuMode == MM_GLOBAL) // был в %FARHOME%? { MenuMode = MM_USER; strMenuFilePath = Opt.ProfilePath; continue; } else if (!ChoiceMenuType) { if (!FirstRun) { // подымаемся выше... if(!IsRootPath(strMenuFilePath)) { size_t pos; if (FindLastSlash(pos,strMenuFilePath)) { strMenuFilePath.SetLength(pos--); continue; } } } FirstRun = false; MenuMode = MM_GLOBAL; strMenuFilePath = Opt.GlobalUserMenuDir; continue; } } int PrevMacroMode=CtrlObject->Macro.GetMode(); int _CurrentFrame=FrameManager->GetCurrentFrame()->GetType(); CtrlObject->Macro.SetMode(MACRO_USERMENU); // вызываем меню ExitCode=ProcessSingleMenu(&Menu, 0, &Menu, strMenuFileFullPath); if (_CurrentFrame == FrameManager->GetCurrentFrame()->GetType()) //??? CtrlObject->Macro.SetMode(PrevMacroMode); // ...запишем изменения обратно в файл SaveMenu(strMenuFileFullPath); // что было после вызова меню? switch (ExitCode) { // Показать меню родительского каталога case EC_PARENT_MENU: { if (MenuMode == MM_LOCAL) { if(!IsRootPath(strMenuFilePath)) { size_t pos; if (FindLastSlash(pos,strMenuFilePath)) { strMenuFilePath.SetLength(pos--); continue; } } MenuMode = MM_GLOBAL; strMenuFilePath = Opt.GlobalUserMenuDir; } else { MenuMode = MM_USER; strMenuFilePath = Opt.ProfilePath; } break; } // Показать главное меню case EC_MAIN_MENU: { // $ 14.07.2000 VVM: Shift+F2 переключает Главное меню/локальное в цикле switch (MenuMode) { case MM_LOCAL: MenuMode = MM_GLOBAL; strMenuFilePath = Opt.GlobalUserMenuDir; break; case MM_GLOBAL: MenuMode = MM_USER; strMenuFilePath = Opt.ProfilePath; break; default: // MM_USER CtrlObject->CmdLine->GetCurDir(strMenuFilePath); MenuMode=MM_LOCAL; } break; } } } if (FrameManager->IsPanelsActive() && (ExitCode == EC_COMMAND_SELECTED || MenuModified)) ShellUpdatePanels(CtrlObject->Cp()->ActivePanel,FALSE); }
Bool TERMWINDOWMEMBER Net1Slave(void) { char line[100]; label troo; label fn; FILE *file; int i = 0; const protocols *theProt = GetProtocolByKey(node->GetProtocol(), TRUE); if (!theProt) { doccr(); cPrintf(getnetmsg(177)); doCR(); return (FALSE); } cPrintf(getnetmsg(178)); doccr(); sprintf(line, sbs, cfg.transpath, node->GetMailFileName()); // create empty mail file if there is none if ((file = fopen(line, FO_AB)) != NULL) { fclose(file); } wxsnd(LocalTempPath, line, theProt, 0); if (!CommPort->HaveConnection()) { return (FALSE); } cPrintf(getnetmsg(179)); doccr(); sprintf(line, sbs, LocalTempPath, roomreqTmp); unlink(line); wxrcv(LocalTempPath, roomreqTmp, theProt); changedir(LocalTempPath); if (!CommPort->HaveConnection()) { return (FALSE); } sprintf(line, sbs, LocalTempPath, roomreqTmp); if ((file = fopen(line, FO_RB)) == NULL) { perror(getnetmsg(1)); return (FALSE); } doccr(); cPrintf(getnetmsg(2)); doccr(); GetStr(file, troo, LABELSIZE); while (*troo && !feof(file)) { KBReady(); r_slot rm; if ((rm = RoomExists(troo)) != CERROR) { if (CurrentUser->CanAccessRoom(rm)) { sprintf(fn, getnetmsg(126), i); cPrintf(getnetmsg(166), deansi(troo)); if (!((i+1) % 3)) { doccr(); } NewRoom(rm, fn, NULL); } else { doccr(); cPrintf(getnetmsg(111), deansi(troo)); doccr(); amPrintf(getnetmsg(4), troo, bn); netError = TRUE; } } else { doccr(); cPrintf(getnetmsg(5), deansi(troo)); doccr(); amPrintf(getnetmsg(167), troo, bn); netError = TRUE; } i++; GetStr(file, troo, LABELSIZE); } doccr(); fclose(file); unlink(line); cPrintf(getnetmsg(7), cfg.Lmsg_nym); doccr(); if (!CommPort->HaveConnection()) { return (FALSE); } wxsnd(LocalTempPath, getnetmsg(162), theProt, 0); ambigUnlink(getnetmsg(162)); return (TRUE); }