void register_common_functions(int id) { /* * When you add a new function here, then don't forget to delete it from * the database and smatch_data/. */ add_implied_return_hook("strlen", &match_strlen, NULL); add_implied_return_hook("strnlen", &match_strnlen, NULL); add_implied_return_hook("sprintf", &match_sprintf, INT_PTR(1)); add_implied_return_hook("snprintf", &match_sprintf, INT_PTR(2)); }
void check_kmalloc_wrong_size(int id) { my_id = id; if (option_project != PROJ_KERNEL) { add_function_assign_hook("malloc", &match_alloc, NULL); add_function_assign_hook("calloc", &match_calloc, INT_PTR(1)); return; } add_function_assign_hook("kmalloc", &match_alloc, NULL); add_function_assign_hook("kcalloc", &match_calloc, INT_PTR(1)); }
INT_PTR CVideoRendererDX9::GetRenderTarget( eRendererType eType ) { switch ( eType ) { case VRT_DX9: return INT_PTR( m_pTex ); case VRT_AUTO: case VRT_CE3: return INT_PTR( m_iTex ? gEnv->pRenderer->EF_GetTextureByID( m_iTex ) : NULL ); } return NULL; }
RemoteDesktop::CConsole::CConsole() : m_OwnConsole(false) { if (!AllocConsole()) return; SetConsoleCtrlHandler(MyConsoleCtrlHandler, TRUE); RemoveMenu(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE, MF_BYCOMMAND); const int in = _open_osfhandle(INT_PTR(GetStdHandle(STD_INPUT_HANDLE)), _O_TEXT); const int out = _open_osfhandle(INT_PTR(GetStdHandle(STD_OUTPUT_HANDLE)), _O_TEXT); m_OldStdin = *stdin; m_OldStdout = *stdout; auto sr = *stdout; *stdin = *_fdopen(in, "r"); *stdout = *_fdopen(out, "w"); m_OwnConsole = true; }
static void register_funcs_from_file(void) { struct token *token; const char *func; int arg; token = get_tokens_file("kernel.dma_funcs"); if (!token) return; if (token_type(token) != TOKEN_STREAMBEGIN) return; token = token->next; while (token_type(token) != TOKEN_STREAMEND) { if (token_type(token) != TOKEN_IDENT) return; func = show_ident(token->ident); token = token->next; if (token_type(token) != TOKEN_NUMBER) return; arg = atoi(token->number); add_function_hook(func, &match_dma_func, INT_PTR(arg)); token = token->next; } clear_token_alloc(); }
INT_PTR CALLBACK LastResultDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvt; switch(message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvt = HIWORD(wParam); switch (wmId) { case IDOK: EndDialog(hDlg, IDOK); return INT_PTR(TRUE); default: break; } break; case WM_CLOSE: EndDialog(hDlg, IDOK); return (INT_PTR)TRUE; case WM_SHOWWINDOW: { HighScores::HighScoresRepository scoresRepository; std::vector<HighScores::MatchResult> lastMatchResults = scoresRepository.select(50, 0); SendDlgItemMessageA(hDlg, IDC_LSTHIGHSCORES, LB_RESETCONTENT, 0, 0); for(auto item = lastMatchResults.begin(); item != lastMatchResults.end(); ++item) { SendDlgItemMessageA(hDlg, IDC_LSTHIGHSCORES, LB_ADDSTRING, 0, (LPARAM)item->strRepr().c_str()); } return (INT_PTR)TRUE; } } return (INT_PTR)FALSE; }
static void register_silenced_functions(void) { struct token *token; char *func; char name[256]; silenced_funcs = create_function_hashtable(500); if (option_project == PROJ_NONE) return; snprintf(name, 256, "%s.silenced_functions", option_project_str); token = get_tokens_file(name); if (!token) return; if (token_type(token) != TOKEN_STREAMBEGIN) return; token = token->next; while (token_type(token) != TOKEN_STREAMEND) { if (token_type(token) != TOKEN_IDENT) return; func = alloc_string(show_ident(token->ident)); insert_func(silenced_funcs, func, INT_PTR(1)); token = token->next; } clear_token_alloc(); }
TCHAR* GetContactUID(MCONTACT hContact) { char *szProto = GetContactProto(hContact); char *uid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); if (INT_PTR(uid) == CALLSERVICE_NOTFOUND || uid == 0) return NULL; DBVARIANT vrUid; if (db_get_s(hContact, szProto, uid, &vrUid, 0)) return NULL; if (vrUid.type == DBVT_DWORD) { TCHAR tmp[100]; _itot(vrUid.dVal, tmp, 10); return mir_tstrdup(tmp); } if (vrUid.type == DBVT_ASCIIZ) { TCHAR *res = mir_a2t(vrUid.pszVal); mir_free(vrUid.pszVal); return res; } if (vrUid.type == DBVT_UTF8) { TCHAR *res = mir_utf8decodeT(vrUid.pszVal); mir_free(vrUid.pszVal); return res; } return NULL; }
void check_ns_capable(int id) { if (option_project != PROJ_KERNEL) return; ns_capable_id = id; add_function_hook("ns_capable", &match_ns_capable, INT_PTR(0)); select_caller_info_hook(set_db_ns_capable, NS_CAPABLE); }
void check_bit_shift(int id) { my_id = id; shifters = create_function_hashtable(5000); register_shifters(); add_hook(&match_assign, ASSIGNMENT_HOOK); add_hook(&match_binop, BINOP_HOOK); if (option_info) { add_hook(&match_binop_info, BINOP_HOOK); if (option_project == PROJ_KERNEL) { add_function_hook("set_bit", &match_call, INT_PTR(0)); add_function_hook("test_bit", &match_call, INT_PTR(0)); } } }
INT_PTR TquantPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ED_Q_I_MIN: case IDC_ED_Q_I_MAX: case IDC_ED_Q_P_MIN: case IDC_ED_Q_P_MAX: case IDC_ED_Q_B_MIN: case IDC_ED_Q_B_MAX: case IDC_ED_Q_MB_MIN: case IDC_ED_Q_MB_MAX: if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) { HWND hed = GetDlgItem(m_hwnd, LOWORD(wParam)); if (hed != GetFocus()) { return FALSE; } repaint(hed); switch (LOWORD(wParam)) { case IDC_ED_Q_I_MIN : eval(hed, parent->qmin, parent->qmax, IDFF_enc_q_i_min); break; case IDC_ED_Q_I_MAX : eval(hed, parent->qmin, parent->qmax, IDFF_enc_q_i_max); break; } return TRUE; } break; } break; case WM_CTLCOLOREDIT: { HWND hwnd = HWND(lParam); bool ok; switch (getId(hwnd)) { case IDC_ED_Q_I_MIN: case IDC_ED_Q_I_MAX: ok = eval(hwnd, parent->qmin, parent->qmax); break; default: goto colorEnd; } if (!ok) { HDC dc = HDC(wParam); SetBkColor(dc, RGB(255, 0, 0)); return INT_PTR(getRed()); } else { return FALSE; } colorEnd: ; } } return TconfPageEnc::msgProc(uMsg, wParam, lParam); }
void register_annotate(int id) { /* * Technically snprintf() returns the number of bytes which *would* have * been printed. I do try caclulating that in check_snprintf(). But * it probably works better to assume the limitter is accurate. */ add_implied_return_hook("snprintf", ¶m_caps_return, INT_PTR(1)); }
INT_PTR TquantTablesPageBase::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: if (HIWORD(wParam)==EN_CHANGE && !isSetWindowText) { HWND hed=GetDlgItem(m_hwnd,LOWORD(wParam)); if (hed!=GetFocus()) { return FALSE; } repaint(hed); TwidgetMatrix *item=(TwidgetMatrix*)Twidget::getDlgItem(hed); if (item->id) { int valI; if (eval(hed,1,255,&valI)) { uint8_t *intra8,*inter8,*intra4Y,*inter4Y,*intra4C,*inter4C; getCustomQuantMatrixes(&intra8,&inter8,&intra4Y,&inter4Y,&intra4C,&inter4C); uint8_t *intra,*inter; switch (cbxGetCurSel(IDC_CBX_QUANT_TABLE)) { case 1: intra=intra4Y; inter=inter4Y; break; case 2: intra=intra4C; inter=inter4C; break; default: intra=intra8; inter=inter8; break; } (item->intra?intra:inter)[item->id-1]=(uint8_t)valI; setChange(); } } return TRUE; } break; case WM_CTLCOLOREDIT: { HWND hwnd=HWND(lParam); if (hwnd==GetDlgItem(m_hwnd,IDC_CBX_QUANT_TABLE)) { break; } bool ok=eval(hwnd,1,255); if (!ok) { HDC dc=HDC(wParam); SetBkColor(dc,RGB(255,0,0)); return INT_PTR(getRed()); } else { return FALSE; } } } return Twindow::msgProc(uMsg,wParam,lParam); }
void check_capable(int id) { if (option_project != PROJ_KERNEL) return; capable_id = id; add_function_hook("capable", &match_capable, INT_PTR(0)); add_hook(&save_call_info, FUNCTION_CALL_HOOK); add_split_return_callback(save_return_info); select_caller_info_hook(set_db_capable, CAPABLE); }
static TCHAR* parseProtoInfo(ARGUMENTSINFO *ai) { if (ai->argc != 3) return NULL; char *szRes = NULL; TCHAR *tszRes = NULL; ptrA szProto(mir_t2a(ai->targv[1])); if (!mir_tstrcmp(ai->targv[2], _T(STR_PINAME))) tszRes = Hlp_GetProtocolName(szProto); else if (!mir_tstrcmp(ai->targv[2], _T(STR_PIUIDTEXT))) { szRes = (char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDTEXT, 0); if (INT_PTR(szRes) == CALLSERVICE_NOTFOUND) return NULL; } else if (!mir_tstrcmp(ai->targv[2], _T(STR_PIUIDSETTING))) { szRes = (char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); if (INT_PTR(szRes) == CALLSERVICE_NOTFOUND) return NULL; } else if (!mir_tstrcmp(ai->targv[2], _T(STR_PINICK))) { CONTACTINFO ci; ci.cbSize = sizeof(CONTACTINFO); ci.dwFlag = CNF_DISPLAY | CNF_UNICODE; ci.hContact = NULL; ci.szProto = szProto; CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci); tszRes = ci.pszVal; } if (szRes == NULL && tszRes == NULL) return NULL; if (szRes != NULL && tszRes == NULL) tszRes = mir_a2t(szRes); return tszRes; }
//===================================================================== int GUI_DialogYN_CB (void *parent, void *data) { //===================================================================== /// INTERNAL callback of GUI_DialogYN int idat; void *pTab; printf("GUI_DialogYN_CB %d\n",INT_PTR(data)); // if ((GTK_TOGGLE_BUTTON (parent)->active) == 0) { // printf("skip disactivation\n"); // return 0; // } gtk_widget_destroy (UI_DialogYNWin); UI_DialogYNWin=NULL; // GUI_update__(); // update pending events // raus 2009-01-30 - blockiert Fun idat = UI_FuncCancel; if(INT_PTR(data) == GTK_RESPONSE_OK) { idat = UI_FuncOK; // case GTK_RESPONSE_CANCEL: // case GTK_RESPONSE_DELETE_EVENT: } pTab = &idat; (*UI_DialogYNFunc) (NULL, &pTab); return 0; }
void ipcFixupAddresses(THeaderIPC *pipch) { if (pipch->pServerBaseAddress == pipch->pClientBaseAddress) return; INT_PTR diff = INT_PTR(pipch->pClientBaseAddress) - INT_PTR(pipch->pServerBaseAddress); // fix up all the pointers in the header if (pipch->IconsBegin != NULL) pipch->IconsBegin = (TSlotIPC*)(UINT_PTR(pipch->IconsBegin) + diff); if (pipch->ContactsBegin != NULL) pipch->ContactsBegin = (TSlotIPC*)(UINT_PTR(pipch->ContactsBegin) + diff); if (pipch->GroupsBegin != NULL) pipch->GroupsBegin = (TSlotIPC*)(UINT_PTR(pipch->GroupsBegin) + diff); if (pipch->NewIconsBegin != NULL) pipch->NewIconsBegin = (TSlotIPC*)(UINT_PTR(pipch->NewIconsBegin) + diff); pipch->DataPtr = (TSlotIPC*)(UINT_PTR(pipch->DataPtr) + diff); pipch->DataPtrEnd = (TSlotIPC*)(UINT_PTR(pipch->DataPtrEnd) + diff); pipch->DataFramePtr = (void*)(UINT_PTR(pipch->DataFramePtr) + diff); // and the link list TSlotIPC *pct = pipch->DataPtr; while (pct != NULL) { // the first pointer is already fixed up, have to get a pointer // to the next pointer and modify where it jumps to TSlotIPC **q = &pct->Next; if (*q != NULL) *q = (TSlotIPC*)(UINT_PTR(*q) + diff); pct = *q; } }
void InitInjectedConsole() { AllocConsole(); SetConsoleTitle("PlayLethalLeague"); SetConsoleCtrlHandler(InjectedConsoleCtrlHandler, TRUE); SetConsoleOutputCP(CP_UTF8); // also this is needed when you want to use UTF8 #ifdef ENABLE_REDIRECT_STDINOUT const int in = _open_osfhandle(INT_PTR(GetStdHandle(STD_INPUT_HANDLE)), OPEN_MODE); const int out = _open_osfhandle(INT_PTR(GetStdHandle(STD_OUTPUT_HANDLE)), OPEN_MODE); const int err = _open_osfhandle(INT_PTR(GetStdHandle(STD_ERROR_HANDLE)), OPEN_MODE); oldStdin = in; oldStdout = out; oldStderr = err; *stdin = *_fdopen(in, "r"); *stdout = *_fdopen(out, "w"); *stderr = *_fdopen(err, "w"); // Redirect the CRT standard input, output, and error handles to the console freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); #endif //Clear the error state for each of the C++ standard stream objects. We need to do this, as //attempts to access the standard streams before they refer to a valid target will cause the //iostream objects to enter an error state. In versions of Visual Studio after 2005, this seems //to always occur during startup regardless of whether anything has been read from or written to //the console or not. std::wcout.clear(); std::cout.clear(); std::wcerr.clear(); std::cerr.clear(); std::wcin.clear(); std::cin.clear(); }
BOOL CSettingsSheet::OnInitDialog() { CSkinDialog::OnInitDialog(); SetWindowText( m_sCaption ); CRect rect; m_wndTree.Create( WS_CHILD|WS_TABSTOP|WS_VISIBLE|/*TVS_PRIVATEIMAGELISTS|*/ TVS_HASLINES|TVS_SHOWSELALWAYS|TVS_TRACKSELECT|TVS_NOHSCROLL, rect, this, IDC_SETTINGS_TREE ); m_wndOK.Create( _T("OK"), WS_CHILD|WS_TABSTOP|WS_VISIBLE|BS_DEFPUSHBUTTON, rect, this, IDOK ); m_wndOK.SetFont( &theApp.m_gdiFont ); m_wndCancel.Create( _T("Cancel"), WS_CHILD|WS_TABSTOP|WS_VISIBLE, rect, this, IDCANCEL ); m_wndCancel.SetFont( &theApp.m_gdiFont ); m_wndApply.Create( _T("Apply"), WS_CHILD|WS_TABSTOP|WS_VISIBLE, rect, this, IDRETRY ); m_wndApply.SetFont( &theApp.m_gdiFont ); if ( m_pFirst == NULL ) m_pFirst = GetPage( INT_PTR(0) ); SetActivePage( m_pFirst ); BuildTree(); return TRUE; }
INT_CONSTANT(CREATE_NEW), INT_CONSTANT(OPEN_ALWAYS), INT_CONSTANT(OPEN_EXISTING), INT_CONSTANT(TRUNCATE_EXISTING), // CreateFile attributes INT_CONSTANT(FILE_ATTRIBUTE_ARCHIVE), INT_CONSTANT(FILE_ATTRIBUTE_DIRECTORY), INT_CONSTANT(FILE_ATTRIBUTE_NORMAL), INT_CONSTANT(FILE_ATTRIBUTE_READONLY), INT_CONSTANT(FILE_ATTRIBUTE_REPARSE_POINT), INT_CONSTANT(FILE_ATTRIBUTE_TEMPORARY), INT_CONSTANT(FILE_FLAG_BACKUP_SEMANTICS), // CreateFile error constant { "INVALID_HANDLE_VALUE", INT_TO_JSVAL(INT_PTR(INVALID_HANDLE_VALUE)) }, // CreateFile flags INT_CONSTANT(FILE_FLAG_DELETE_ON_CLOSE), // SetFilePointer methods INT_CONSTANT(FILE_BEGIN), INT_CONSTANT(FILE_CURRENT), INT_CONSTANT(FILE_END), // SetFilePointer error constant INT_CONSTANT(INVALID_SET_FILE_POINTER), // File attributes INT_CONSTANT(FILE_ATTRIBUTE_DIRECTORY),
//================================================================ int TED_win__ (MemObj *parent, void *data) { //================================================================ // create Toolbar static MemObj lb1 = GUI_OBJ_NEW; // static void *TED_wa[3]; int ifunc; MemObj box0, box1, box2; ifunc = INT_PTR(data); printf("TED_win__ \n"); switch (ifunc) { //--------------------------------------------------------- case UI_FuncInit: // 90 if(GUI_OBJ_IS_VALID(&TEDtb)) { GUI_set_show (&TEDtb, 1); return 0; } // TEDtb = GUI_toolbar__ (parent); TEDtb = GUI_toolbox__ (parent); box0 = GUI_box_h (&TEDtb, ""); box1 = GUI_box_v (&box0, ""); GUI_label_htm__ (&box1, "<b> TextureEditor: </b>", ""); // GUI_HSpace (box1, 10); // "no texture active" // if(Tex_getRefInd() < 0) { if(TED_mode == 0) { lb1 = GUI_label__ (&box1, MSG_get_0("TED_no"), "l"); } else { lb1 = GUI_label__ (&box1, TED_name(), "l"); } box1 = GUI_box_v (&box0, ""); GUI_button__ (&box1, MSG_get_0("TED_ldf"), TED_CB1, (void*)"LdFile", ""); MSG_Tip ("TED_ldf"); GUI_button__ (&box1, MSG_get_0("TED_ldn"), TED_CB1, (void*)"Reload", ""); MSG_Tip ("TED_ldn"); box2 = GUI_box_v (&box0, ""); GUI_button__ (&box2, MSG_get_0("TED_miy"), TED_CB1, (void*)"MirrY", ""); GUI_button__ (&box2, MSG_get_0("TED_mix"), TED_CB1, (void*)"MirrX", ""); box2 = GUI_box_v (&box0, ""); GUI_button__ (&box2, MSG_get_0("TED_sz1"), TED_CB1, (void*)"Siz1", ""); // reset GUI_button__ (&box2, MSG_get_0("TED_sz2"), TED_CB1, (void*)"Siz2", ""); // fit box2 = GUI_box_v (&box0, ""); GUI_button__ (&box2, MSG_get_0("TED_rem"), TED_CB1, (void*)"Rem", ""); GUI_button__ (&box2, MSG_const__(MSG_cancel), TED_CB1, (void*)"Can", ""); MSG_Tip ("TED_can"); box2 = GUI_box_v (&box0, ""); GUI_button__ (&box2, MSG_const__(MSG_help), TED_CB1, (void*)"Help", ""); GUI_button__ (&box2, MSG_const__(MSG_exit), TED_CB1, (void*)"Exit", ""); MSG_Tip ("TED_end"); L_exit: GUI_set_show (&TEDtb, 1); TED_mode = 0; return (0); //--------------------------------------------------------- // case UI_FuncUCB1: // reset // GUI_CkButt_set (TED_wa[TED_mode], TRUE); // break; //--------------------------------------------------------- case UI_FuncUCB2: // display new textureInfo printf(" new lb1 |%s|\n",TED_name()); GUI_label_mod (&lb1, TED_name()); break; } return (-1); }
INT_CONSTANT(OPEN_EXISTING), INT_CONSTANT(TRUNCATE_EXISTING), // CreateFile attributes INT_CONSTANT(FILE_ATTRIBUTE_ARCHIVE), INT_CONSTANT(FILE_ATTRIBUTE_DIRECTORY), INT_CONSTANT(FILE_ATTRIBUTE_HIDDEN), INT_CONSTANT(FILE_ATTRIBUTE_NORMAL), INT_CONSTANT(FILE_ATTRIBUTE_READONLY), INT_CONSTANT(FILE_ATTRIBUTE_REPARSE_POINT), INT_CONSTANT(FILE_ATTRIBUTE_SYSTEM), INT_CONSTANT(FILE_ATTRIBUTE_TEMPORARY), INT_CONSTANT(FILE_FLAG_BACKUP_SEMANTICS), // CreateFile error constant { "INVALID_HANDLE_VALUE", JS::Int32Value(INT_PTR(INVALID_HANDLE_VALUE)) }, // CreateFile flags INT_CONSTANT(FILE_FLAG_DELETE_ON_CLOSE), // SetFilePointer methods INT_CONSTANT(FILE_BEGIN), INT_CONSTANT(FILE_CURRENT), INT_CONSTANT(FILE_END), // SetFilePointer error constant UINT_CONSTANT(INVALID_SET_FILE_POINTER), // File attributes INT_CONSTANT(FILE_ATTRIBUTE_DIRECTORY),
INT_PTR TvolumePage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_HSCROLL: switch (getId(HWND(lParam))) { case IDC_TBR_VOLUME_MASTER: volTbr2cfg(IDC_TBR_VOLUME_MASTER, IDFF_volume, 1); master2dlg(); return TRUE; } break; case WM_VSCROLL: switch (getId(HWND(lParam))) { case IDC_TBR_VOLUME_L: volTbr2cfg(IDC_TBR_VOLUME_L, IDFF_volumeL, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_C: volTbr2cfg(IDC_TBR_VOLUME_C, IDFF_volumeC, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_R: volTbr2cfg(IDC_TBR_VOLUME_R, IDFF_volumeR, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_SL: volTbr2cfg(IDC_TBR_VOLUME_SL, IDFF_volumeSL, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_SR: volTbr2cfg(IDC_TBR_VOLUME_SR, IDFF_volumeSR, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_AL: volTbr2cfg(IDC_TBR_VOLUME_AL, IDFF_volumeAL, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_AR: volTbr2cfg(IDC_TBR_VOLUME_AR, IDFF_volumeAR, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_LFE: volTbr2cfg(IDC_TBR_VOLUME_LFE, IDFF_volumeLFE, -1); speakers2dlg(); return TRUE; } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ED_VOLUME_NORMALIZE_MAX: if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) { HWND hed = GetDlgItem(m_hwnd, LOWORD(wParam)); if (hed != GetFocus()) { return FALSE; } repaint(hed); parent->setChange(); break; } break; case IDC_CHB_VOLUME_L_MUTE: case IDC_CHB_VOLUME_C_MUTE: case IDC_CHB_VOLUME_R_MUTE: case IDC_CHB_VOLUME_SL_MUTE: case IDC_CHB_VOLUME_SR_MUTE: case IDC_CHB_VOLUME_AL_MUTE: case IDC_CHB_VOLUME_AR_MUTE: case IDC_CHB_VOLUME_LFE_MUTE: { int idff = ((TwidgetMS*)Twidget::getDlgItem((HWND)lParam))->idff; cfgSet(idff, getCheck(LOWORD(wParam))); mute2dlg(); break; } case IDC_CHB_VOLUME_L_SOLO: case IDC_CHB_VOLUME_C_SOLO: case IDC_CHB_VOLUME_R_SOLO: case IDC_CHB_VOLUME_SL_SOLO: case IDC_CHB_VOLUME_SR_SOLO: case IDC_CHB_VOLUME_AL_SOLO: case IDC_CHB_VOLUME_AR_SOLO: case IDC_CHB_VOLUME_LFE_SOLO: { int idff = ((TwidgetMS*)Twidget::getDlgItem((HWND)lParam))->idff; for (int i = 0; i < countof(idffsMS); i++) if (idffsMS[i] == idff) { cfgSet(idff, getCheck(LOWORD(wParam)) ? 2 : 0); } else { cfgSet(idffsMS[i], 0); } mute2dlg(); break; } } break; case WM_CTLCOLOREDIT: { HWND hwnd = HWND(lParam); bool ok; switch (getId(hwnd)) { case IDC_ED_VOLUME_NORMALIZE_MAX: ok = eval(hwnd, 0, isdb ? 30 : MAX_AMPLIFICATION); break; default: return FALSE; } if (!ok) { HDC dc = HDC(wParam); SetBkColor(dc, RGB(255, 0, 0)); return INT_PTR(getRed()); } else { return FALSE; } } } return TconfPageDecAudio::msgProc(uMsg, wParam, lParam); }
void InitMenu() { CMenuItem mi; mi.flags = CMIF_TCHAR; mi.root = Menu_CreateRoot(MO_MAIN, LPGENT("Quotes"), 0, Quotes_GetIconHandle(IDI_ICON_MAIN)); Menu_ConfigureItem(mi.root, MCI_OPT_UID, "B474F556-22B6-42A1-A91E-22FE4F671388"); SET_UID(mi, 0x9de6716, 0x3591, 0x48c4, 0x9f, 0x64, 0x1b, 0xfd, 0xc6, 0xd1, 0x34, 0x97); mi.name.t = LPGENT("Enable/Disable Auto Update"); mi.position = 10100001; mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_MAIN); mi.pszService = g_pszAutoUpdateCmd; g_hEnableDisableMenu = Menu_AddMainMenuItem(&mi); CreateServiceFunction(mi.pszService, QuotesMenu_EnableDisable); UpdateMenu(g_bAutoUpdate); SET_UID(mi, 0x91cbabf6, 0x5073, 0x4a78, 0x84, 0x8, 0x34, 0x61, 0xc1, 0x8a, 0x34, 0xd9); mi.name.t = LPGENT("Refresh All Quotes\\Rates"); mi.position = 20100001; mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_MAIN); mi.pszService = "Quotes/RefreshAll"; Menu_AddMainMenuItem(&mi); CreateServiceFunction(mi.pszService, QuotesMenu_RefreshAll); SET_UID(mi, 0x3663409c, 0xbd36, 0x473b, 0x9b, 0x4f, 0xff, 0x80, 0xf6, 0x2c, 0xdf, 0x9b); mi.name.t = LPGENT("Currency Converter..."); mi.position = 20100002; mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_CURRENCY_CONVERTER); mi.pszService = g_pszCurrencyConverter; Menu_AddMainMenuItem(&mi); CreateServiceFunction(mi.pszService, QuotesMenu_CurrencyConverter); SET_UID(mi, 0x7cca4fd9, 0x903f, 0x4b7d, 0x93, 0x7a, 0x18, 0x63, 0x23, 0xd4, 0xa9, 0xa9); mi.name.t = LPGENT("Export All Quotes"); mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_EXPORT); mi.pszService = "Quotes/ExportAll"; mi.position = 20100003; Menu_AddMainMenuItem(&mi); CreateServiceFunction(mi.pszService, QuotesMenu_ExportAll); SET_UID(mi, 0xa994d3b, 0x77c2, 0x4612, 0x8d, 0x5, 0x6a, 0xae, 0x8c, 0x21, 0xbd, 0xc9); mi.name.t = LPGENT("Import All Quotes"); mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_IMPORT); mi.pszService = "Quotes/ImportAll"; mi.position = 20100004; Menu_AddMainMenuItem(&mi); CreateServiceFunction(mi.pszService, QuotesMenu_ImportAll); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Quotes_PrebuildContactMenu); g_hMenuRoot = mi.root = Menu_CreateRoot(MO_CONTACT, _T(QUOTES_PROTOCOL_NAME), 0, Quotes_GetIconHandle(IDI_ICON_MAIN)); Menu_ConfigureItem(mi.root, MCI_OPT_UID, "C259BE01-642C-461E-997D-0E756B2A3AD6"); SET_UID(mi, 0xb9812194, 0x3235, 0x4e76, 0xa3, 0xa4, 0x73, 0x32, 0x96, 0x1c, 0x1c, 0xf4); mi.name.t = LPGENT("Refresh"); mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_REFRESH); mi.pszService = "Quotes/RefreshContact"; g_hMenuRefresh = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); Menu_ConfigureItem(g_hMenuRefresh, MCI_OPT_EXECPARAM, INT_PTR(0)); CreateServiceFunction(mi.pszService, QuotesMenu_RefreshContact); SET_UID(mi, 0x19a16fa2, 0xf370, 0x4201, 0x92, 0x9, 0x25, 0xde, 0x4e, 0x55, 0xf9, 0x1a); mi.name.t = LPGENT("Open Log File..."); mi.hIcolibItem = NULL; mi.pszService = "Quotes/OpenLogFile"; g_hMenuOpenLogFile = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); Menu_ConfigureItem(g_hMenuOpenLogFile, MCI_OPT_EXECPARAM, 1); CreateServiceFunction(mi.pszService, QuotesMenu_OpenLogFile); #ifdef CHART_IMPLEMENT SET_UID(mi, 0x65da7256, 0x43a2, 0x4857, 0xac, 0x52, 0x1c, 0xb7, 0xff, 0xd7, 0x96, 0xfa); mi.name.t = LPGENT("Chart..."); mi.popupPosition = 2; mi.hIcolibItem = NULL; mi.pszService = "Quotes/Chart"; g_hMenuChart = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); CreateServiceFunction(mi.pszService, QuotesMenu_Chart); #endif SET_UID(mi, 0xac5fc17, 0x5640, 0x4f81, 0xa3, 0x44, 0x8c, 0xb6, 0x9a, 0x5c, 0x98, 0xf); mi.name.t = LPGENT("Edit Settings..."); mi.hIcolibItem = NULL; mi.pszService = "Quotes/EditSettings"; g_hMenuEditSettings = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); #ifdef CHART_IMPLEMENT Menu_ConfigureItem(g_hMenuEditSettings, MCI_OPT_EXECPARAM, 3); #else Menu_ConfigureItem(g_hMenuEditSettings, MCI_OPT_EXECPARAM, 2); #endif CreateServiceFunction(mi.pszService, QuotesMenu_EditSettings); }
INT_PTR TffdshowPageEnc::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_HSCROLL: if (HWND(lParam) == GetDlgItem(m_hwnd, IDC_TBR_QUICK)) { if (valIdff) { cfgSet(valIdff, tbrGet(IDC_TBR_QUICK)); quick2dlg(false); } return TRUE; } break; case WM_FFONCHANGE: if (wParam == IDFF_lang && ve) { ve->commonOptionChanged(IID_IffdshowEnc, IDFF_lang); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CBX_ENCODER: if (HIWORD(wParam) == CBN_SELCHANGE) { cfgSet(IDFF_enc_codecId, ((Tencoder*)cbxGetCurItemData(IDC_CBX_ENCODER))->id); codec2dlg(); HTREEITEM hti = TreeView_GetSelection(htv); if (hti) { selectPage(hti2page(hti)); } return TRUE; } break; case IDC_CBX_FOURCC: if (HIWORD(wParam) == CBN_SELCHANGE) { cfgSet(IDFF_enc_fourcc, (int)cbxGetCurItemData(IDC_CBX_FOURCC)); fourcc2dlg(); return TRUE; } break; case IDC_CBX_MODES: if (HIWORD(wParam) == CBN_SELCHANGE) { cfgSet(IDFF_enc_mode, (int)cbxGetCurItemData(IDC_CBX_MODES)); quick2dlg(true); return TRUE; } break; case IDC_ED_QUICK: if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) { HWND hed = GetDlgItem(m_hwnd, LOWORD(wParam)); if (hed != GetFocus()) { return FALSE; } repaint(hed); switch (LOWORD(wParam)) { case IDC_ED_QUICK: eval(hed, valMin, valMax, valIdff); tbrSet(IDC_TBR_QUICK, cfgGet(valIdff)); break; } return TRUE; } break; case IDC_BT_PRESET: if (HIWORD(wParam) == BN_CLICKED) { showPresets(); return TRUE; } break; case IDC_CHB_NOT_REGISTRY: cfgSet(IDFF_notreg, getCheck(IDC_CHB_NOT_REGISTRY)); return TRUE; } break; case WM_CTLCOLOREDIT: { HWND hwnd = HWND(lParam); bool ok; switch (getId(hwnd)) { case IDC_ED_QUICK: ok = eval(hwnd, valMin, valMax); break; default: return FALSE; } if (!ok) { HDC dc = HDC(wParam); SetBkColor(dc, RGB(255, 0, 0)); return INT_PTR(getRed()); } else { return FALSE; } } case WM_DRAWITEM: if (wParam == IDC_CBX_ENCODER) { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)lParam; COLORREF crOldTextColor = GetTextColor(dis->hDC); COLORREF crOldBkColor = GetBkColor(dis->hDC); HBRUSH br; if ((dis->itemAction | ODA_SELECT) && (dis->itemState & ODS_SELECTED)) { SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); SetBkColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHT)); br = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); } else { br = CreateSolidBrush(crOldBkColor); } FillRect(dis->hDC, &dis->rcItem, br); if (int(dis->itemData) != CB_ERR) { RECT r = dis->rcItem; r.left += 2; Tencoder *enc = (Tencoder*)dis->itemData; DrawText(dis->hDC, enc->name, (int)strlen(enc->name), &r, DT_LEFT | DT_SINGLELINE | DT_VCENTER); setDlgResult(TRUE); r.left += 180; FillRect(dis->hDC, &r, br); MoveToEx(dis->hDC, r.left, r.top, NULL); LineTo(dis->hDC, r.left, r.bottom); SetTextColor(dis->hDC, GetSysColor(COLOR_GRAYTEXT)); r.left += 4; char_t text[70]; SendMessage(hcbxE, CB_GETLBTEXT, dis->itemID, LPARAM(text)); DrawText(dis->hDC, text, (int)strlen(text), &r, DT_LEFT | DT_SINGLELINE | DT_VCENTER); } SetTextColor(dis->hDC, crOldTextColor); SetBkColor(dis->hDC, crOldBkColor); DeleteObject(br); return TRUE; } break; } return TffdshowPageBase::msgProc(uMsg, wParam, lParam); }
//================================================================ int OS_file_sig_cre (int mode, void *data) { //================================================================ /// \code /// OS_file_sig_cre create signal-file /// Input: /// mode 0 clear file; data = signalfilename; must be done first /// 1 write data = string (null terminated) -> signalfile /// 2 write data = int (4 bytes) -> signalfile /// 99 cancelled by user (following read gives retCod -1) /// -1 read data = string (null terminated) -> data (size of data !) /// -2 read data = int (4 bytes) -> data /// Output: /// data text or int (mode); /// RetCod: 0 OK, data valid /// -1 cancelled by user /// \endcode // after read must be clear befor next write ! long ls; char *fmact, *fmw = "w", *fmr = "r"; static char fn[256]; static int lastMode = -1; FILE *fpo; printf("..OS_file_sig_cre %d %d\n",mode,lastMode); // skip delete window before init if(mode > 0) { if(lastMode < 0) return 0; } // if(fnam) { if(mode == 0) { // fn = fnam; strcpy(fn, data); printf(" sig_cre fn=|%s|\n",fn); // delete file OS_file_delete (fn); lastMode = 0; return 0; } // write | read if(mode < 0) { // read ((char*)data)[0] ='\0'; if(lastMode == 99) { // user cancelled ! return -1; } fmact = fmr; ls = OS_FilSiz (fn); printf(" ls=%ld\n",ls); } else { // write fmact = fmw; } lastMode = mode; if((fpo=fopen(fn, fmact)) == NULL) { TX_Print("OS_file_sig_cre E001 %s",fn); return -1; } // if(data) { can be int=0 ! if (mode == 1) { fprintf(fpo, "%s", TXT_PTR(data)); printf(" wr s |%s|\n",TXT_PTR(data)); } else if(mode == 2) { fprintf(fpo, "%d", INT_PTR(data)); printf(" wr int %d\n",INT_PTR(data)); } else if(mode == -1) { // fgets(data, 250, fpo); fread(data, ls, 1, fpo); ((char*)data)[ls] = '\0'; printf(" rd s |%s|\n",(char*)data); } else if(mode == -2) { fscanf(fpo, "%d", (int*)data); printf(" rd int %d\n",*((int*)data)); } // } else { // if(mode > 0) fprintf(fpo, ""); // } fclose(fpo); // rename after write: necessary if > 1 processes return 0; }
INT_PTR CALLBACK LicenseDialogProc( HWND hWnd, // handle to dialog box UINT msg, // message WPARAM wParam, // first message parameter LPARAM lParam) // second message parameter { switch (msg) { case WM_INITDIALOG: g_brWhite = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW)); { const TCHAR* resource_name= MAKEINTRESOURCE(IDR_LICENSE); const TCHAR* resource_type= _T("FILE"); if (HRSRC rsrc= ::FindResource(g_instance_handle, resource_name, resource_type)) { if (HGLOBAL global= ::LoadResource(g_instance_handle, rsrc)) { DWORD size= ::SizeofResource(g_instance_handle, rsrc); const int MAX= size + 50; TCHAR* text= new TCHAR[MAX]; if (BYTE* data= reinterpret_cast<BYTE*>(::LockResource(global))) { if (text) { int len= ::MultiByteToWideChar(CP_ACP, 0, LPCSTR(data), size, text, MAX); //memcpy(text, data, size); if (len > 0 && len < MAX) text[len] = 0; text[MAX - 1] = 0; ::SetDlgItemText(hWnd, IDC_INFO, text); delete [] text; break; } } } } } ::EndDialog(hWnd, wParam); break; case WM_CTLCOLORSTATIC: return INT_PTR(g_brWhite); case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: ::EndDialog(hWnd, wParam); return true; } } return 0; }
INT_PTR TsubtitlesTextPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ED_SUB_MINDURATION: if (HIWORD(wParam)==EN_CHANGE && !isSetWindowText) { HWND hed=GetDlgItem(m_hwnd,LOWORD(wParam)); if (hed!=GetFocus()) { return FALSE; } repaint(hed); switch (LOWORD(wParam)) { case IDC_ED_SUB_MINDURATION: { static const int idffmins[]= {IDFF_subMinDurationSub,IDFF_subMinDurationLine,IDFF_subMinDurationChar}; eval(hed,1,3600000,idffmins[cbxGetCurSel(IDC_CBX_SUB_MINDURATION)]); break; } } return TRUE; } break; case IDC_CHB_SUBFIX_AP: case IDC_CHB_SUBFIX_IL: case IDC_CHB_SUBFIX_PUNCTUATION: case IDC_CHB_SUBFIX_ORTOGRAPHY: case IDC_CHB_SUBFIX_CAPITAL: case IDC_CHB_SUBFIX_NUMBERS: case IDC_CHB_SUBFIX_HEARING: { int fix=0; if (getCheck(IDC_CHB_SUBFIX_AP )) { fix|=TtextFixBase::fixAP; } if (getCheck(IDC_CHB_SUBFIX_IL )) { fix|=TtextFixBase::fixIl; } if (getCheck(IDC_CHB_SUBFIX_PUNCTUATION)) { fix|=TtextFixBase::fixPunctuation; } if (getCheck(IDC_CHB_SUBFIX_ORTOGRAPHY )) { fix|=TtextFixBase::fixOrtography; } if (getCheck(IDC_CHB_SUBFIX_CAPITAL )) { fix|=TtextFixBase::fixCapital; } if (getCheck(IDC_CHB_SUBFIX_NUMBERS )) { fix|=TtextFixBase::fixNumbers; } if (getCheck(IDC_CHB_SUBFIX_HEARING )) { fix|=TtextFixBase::fixHearingImpaired; } cfgSet(IDFF_subFix,fix); fix2dlg(); break; } } break; case WM_CTLCOLOREDIT: { HWND hwnd=HWND(lParam); bool ok; switch (getId(hwnd)) { case IDC_ED_SUB_MINDURATION: ok=eval(hwnd,1,3600000); break; default: return FALSE; } if (!ok) { HDC dc=HDC(wParam); SetBkColor(dc,RGB(255,0,0)); return INT_PTR(getRed()); } else { return FALSE; } } } return TconfPageDecVideo::msgProc(uMsg,wParam,lParam); }
BOOL CToolbar::AddSeparator() { return AddCustomButton(-1, 0, 0, 0, TBSTYLE_SEP, 0, INT_PTR( 0 )); }
namespace mozilla { /** * Define a simple read-only property holding an integer. * * @param name The name of the constant. Used both as the JS name for the * constant and to access its value. Must be defined. * * Produces a |ConstantSpec|. */ #define INT_CONSTANT(name) \ { #name, INT_TO_JSVAL(name) } /** * End marker for ConstantSpec */ #define PROP_END { NULL, JSVAL_VOID } // Define missing constants for Android #if !defined(S_IRGRP) #define S_IXOTH 0001 #define S_IWOTH 0002 #define S_IROTH 0004 #define S_IRWXO 0007 #define S_IXGRP 0010 #define S_IWGRP 0020 #define S_IRGRP 0040 #define S_IRWXG 0070 #define S_IXUSR 0100 #define S_IWUSR 0200 #define S_IRUSR 0400 #define S_IRWXU 0700 #endif // !defined(S_IRGRP) /** * The properties defined in libc. * * If you extend this list of properties, please * separate categories ("errors", "open", etc.), * keep properties organized by alphabetical order * and #ifdef-away properties that are not portable. */ static dom::ConstantSpec gLibcProperties[] = { // Arguments for open INT_CONSTANT(O_APPEND), INT_CONSTANT(O_CREAT), #if defined(O_DIRECTORY) INT_CONSTANT(O_DIRECTORY), #endif // defined(O_DIRECTORY) #if defined(O_EVTONLY) INT_CONSTANT(O_EVTONLY), #endif // defined(O_EVTONLY) INT_CONSTANT(O_EXCL), #if defined(O_EXLOCK) INT_CONSTANT(O_EXLOCK), #endif // defined(O_EXLOCK) #if defined(O_LARGEFILE) INT_CONSTANT(O_LARGEFILE), #endif // defined(O_LARGEFILE) #if defined(O_NOFOLLOW) INT_CONSTANT(O_NOFOLLOW), #endif // defined(O_NOFOLLOW) #if defined(O_NONBLOCK) INT_CONSTANT(O_NONBLOCK), #endif // defined(O_NONBLOCK) INT_CONSTANT(O_RDONLY), INT_CONSTANT(O_RDWR), #if defined(O_RSYNC) INT_CONSTANT(O_RSYNC), #endif // defined(O_RSYNC) #if defined(O_SHLOCK) INT_CONSTANT(O_SHLOCK), #endif // defined(O_SHLOCK) #if defined(O_SYMLINK) INT_CONSTANT(O_SYMLINK), #endif // defined(O_SYMLINK) #if defined(O_SYNC) INT_CONSTANT(O_SYNC), #endif // defined(O_SYNC) INT_CONSTANT(O_TRUNC), INT_CONSTANT(O_WRONLY), #if defined(AT_EACCESS) INT_CONSTANT(AT_EACCESS), #endif //defined(AT_EACCESS) #if defined(AT_FDCWD) INT_CONSTANT(AT_FDCWD), #endif //defined(AT_FDCWD) #if defined(AT_SYMLINK_NOFOLLOW) INT_CONSTANT(AT_SYMLINK_NOFOLLOW), #endif //defined(AT_SYMLINK_NOFOLLOW) // access #if defined(F_OK) INT_CONSTANT(F_OK), INT_CONSTANT(R_OK), INT_CONSTANT(W_OK), INT_CONSTANT(X_OK), #endif // defined(F_OK) // modes INT_CONSTANT(S_IRGRP), INT_CONSTANT(S_IROTH), INT_CONSTANT(S_IRUSR), INT_CONSTANT(S_IRWXG), INT_CONSTANT(S_IRWXO), INT_CONSTANT(S_IRWXU), INT_CONSTANT(S_IWGRP), INT_CONSTANT(S_IWOTH), INT_CONSTANT(S_IWUSR), INT_CONSTANT(S_IXOTH), INT_CONSTANT(S_IXGRP), INT_CONSTANT(S_IXUSR), // seek INT_CONSTANT(SEEK_CUR), INT_CONSTANT(SEEK_END), INT_CONSTANT(SEEK_SET), // error values INT_CONSTANT(EACCES), INT_CONSTANT(EAGAIN), INT_CONSTANT(EBADF), INT_CONSTANT(EEXIST), INT_CONSTANT(EFAULT), INT_CONSTANT(EFBIG), INT_CONSTANT(EINVAL), INT_CONSTANT(EIO), INT_CONSTANT(EISDIR), #if defined(ELOOP) // not defined with VC9 INT_CONSTANT(ELOOP), #endif // defined(ELOOP) INT_CONSTANT(EMFILE), INT_CONSTANT(ENAMETOOLONG), INT_CONSTANT(ENFILE), INT_CONSTANT(ENOENT), INT_CONSTANT(ENOMEM), INT_CONSTANT(ENOSPC), INT_CONSTANT(ENOTDIR), INT_CONSTANT(ENXIO), #if defined(EOPNOTSUPP) // not defined with VC 9 INT_CONSTANT(EOPNOTSUPP), #endif // defined(EOPNOTSUPP) #if defined(EOVERFLOW) // not defined with VC 9 INT_CONSTANT(EOVERFLOW), #endif // defined(EOVERFLOW) INT_CONSTANT(EPERM), INT_CONSTANT(ERANGE), #if defined(ETIMEDOUT) // not defined with VC 9 INT_CONSTANT(ETIMEDOUT), #endif // defined(ETIMEDOUT) #if defined(EWOULDBLOCK) // not defined with VC 9 INT_CONSTANT(EWOULDBLOCK), #endif // defined(EWOULDBLOCK) INT_CONSTANT(EXDEV), PROP_END }; #if defined(XP_WIN) /** * The properties defined in windows.h. * * If you extend this list of properties, please * separate categories ("errors", "open", etc.), * keep properties organized by alphabetical order * and #ifdef-away properties that are not portable. */ static dom::ConstantSpec gWinProperties[] = { // FormatMessage flags INT_CONSTANT(FORMAT_MESSAGE_FROM_SYSTEM), INT_CONSTANT(FORMAT_MESSAGE_IGNORE_INSERTS), // CreateFile desired access INT_CONSTANT(GENERIC_ALL), INT_CONSTANT(GENERIC_EXECUTE), INT_CONSTANT(GENERIC_READ), INT_CONSTANT(GENERIC_WRITE), // CreateFile share mode INT_CONSTANT(FILE_SHARE_DELETE), INT_CONSTANT(FILE_SHARE_READ), INT_CONSTANT(FILE_SHARE_WRITE), // CreateFile creation disposition INT_CONSTANT(CREATE_ALWAYS), INT_CONSTANT(CREATE_NEW), INT_CONSTANT(OPEN_ALWAYS), INT_CONSTANT(OPEN_EXISTING), INT_CONSTANT(TRUNCATE_EXISTING), // CreateFile attributes INT_CONSTANT(FILE_ATTRIBUTE_ARCHIVE), INT_CONSTANT(FILE_ATTRIBUTE_DIRECTORY), INT_CONSTANT(FILE_ATTRIBUTE_NORMAL), INT_CONSTANT(FILE_ATTRIBUTE_READONLY), INT_CONSTANT(FILE_ATTRIBUTE_TEMPORARY), // SetFilePointer error constant { "INVALID_HANDLE_VALUE", INT_TO_JSVAL(INT_PTR(INVALID_HANDLE_VALUE)) }, // CreateFile flags INT_CONSTANT(FILE_FLAG_DELETE_ON_CLOSE), // SetFilePointer methods INT_CONSTANT(FILE_BEGIN), INT_CONSTANT(FILE_CURRENT), INT_CONSTANT(FILE_END), // SetFilePointer error constant INT_CONSTANT(INVALID_SET_FILE_POINTER), // Errors INT_CONSTANT(ERROR_FILE_NOT_FOUND), INT_CONSTANT(ERROR_ACCESS_DENIED), PROP_END }; #endif // defined(XP_WIN) /** * Get a field of an object as an object. * * If the field does not exist, create it. If it exists but is not an * object, throw a JS error. */ JSObject *GetOrCreateObjectProperty(JSContext *cx, JSObject *aObject, const char *aProperty) { JS::Value val; if (!JS_GetProperty(cx, aObject, aProperty, &val)) { return NULL; } if (!val.isUndefined()) { if (val.isObject()) { return &val.toObject(); } JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_UNEXPECTED_TYPE, aProperty, "not an object"); return NULL; } return JS_DefineObject(cx, aObject, aProperty, NULL, NULL, JSPROP_ENUMERATE); } /** * Define OS-specific constants. * * This function creates or uses JS object |OS.Constants| to store * all its constants. */ bool DefineOSFileConstants(JSContext *cx, JSObject *global) { JSObject *objOS; if (!(objOS = GetOrCreateObjectProperty(cx, global, "OS"))) { return false; } JSObject *objConstants; if (!(objConstants = GetOrCreateObjectProperty(cx, objOS, "Constants"))) { return false; } JSObject *objLibc; if (!(objLibc = GetOrCreateObjectProperty(cx, objConstants, "libc"))) { return false; } if (!dom::DefineConstants(cx, objLibc, gLibcProperties)) { return false; } #if defined(XP_WIN) JSObject *objWin; if (!(objWin = GetOrCreateObjectProperty(cx, objConstants, "Win"))) { return false; } if (!dom::DefineConstants(cx, objWin, gWinProperties)) { return false; } #endif // defined(XP_WIN) return true; } } // namespace mozilla