Beispiel #1
0
void saveInt(char *name, int value, char *fname) 
{
	char buf[4];
	sprintf(buf, "%d", value); 
	WritePrivateProfileString("options", name, buf, fname);
}
Beispiel #2
0
void cmd_setinipw(const char *iniPW, SERVER_REC *server, WI_ITEM_REC *item)
{
    int i=0, pw_len, re_enc=0;
    char B64digest[50], SHA256digest[35];
    char bfKey[512], new_iniKey[KEYBUF_SIZE], old_iniKey[KEYBUF_SIZE], *fptr, *ok_ptr, line_buf[1000], iniPath_new[300];
    FILE *h_ini, *h_ini_new;


    if (!unsetiniFlag) {
        pw_len=strlen(iniPW);
        if (pw_len < 1 || (size_t)pw_len > sizeof(new_iniKey)) {
            printtext(server, item!=NULL ? window_item_get_target(item) : NULL, MSGLEVEL_CRAP,
                      "\002FiSH:\002 No parameters. Usage: /setinipw <sekure_blow.ini_password>");
            return;
        }

        if (strfcpy(new_iniKey, (char *)iniPW, sizeof(new_iniKey))==NULL) return;
        ZeroMemory(iniPW, pw_len);
        pw_len=strlen(new_iniKey);

        if (pw_len < 8) {
            printtext(server, item!=NULL ? window_item_get_target(item) : NULL, MSGLEVEL_CRAP,
                      "\002FiSH:\002 Password too short, at least 8 characters needed! Usage: /setinipw <sekure_blow.ini_password>");
            return;
        }

        SHA256_memory(new_iniKey, pw_len, SHA256digest);
        ZeroMemory(new_iniKey, sizeof(new_iniKey));
        for (i=0; i<40872; i++) SHA256_memory(SHA256digest, 32, SHA256digest);
        htob64(SHA256digest, B64digest, 32);
    }

    strcpy(old_iniKey, iniKey);

    if (unsetiniFlag) strcpy(iniKey, default_iniKey);	// unsetinipw -> use default blow.ini key
    else strcpy(iniKey, B64digest);	// this is used for encrypting blow.ini

    for (i=0; i<30752; i++) SHA256_memory(SHA256digest, 32, SHA256digest);
    htob64(SHA256digest, B64digest, 32);	// this is used to verify the entered password
    ZeroMemory(SHA256digest, sizeof(SHA256digest));


    // re-encrypt blow.ini with new password
    strcpy(iniPath_new, iniPath);
    strcat(iniPath_new, "_new");
    h_ini_new=fopen(iniPath_new, "w");
    h_ini=fopen(iniPath,"r");
    if (h_ini && h_ini_new) {
        while (!feof(h_ini)) {
            fptr=fgets(line_buf, sizeof(line_buf)-2, h_ini);
            if (fptr) {
                ok_ptr=strstr(line_buf, "+OK ");
                if (ok_ptr) {
                    re_enc=1;
                    strtok(ok_ptr+4, " \n\r");
                    decrypt_string(old_iniKey, ok_ptr+4, bfKey, strlen(ok_ptr+4));
                    ZeroMemory(ok_ptr+4, strlen(ok_ptr+4)+1);
                    encrypt_string(iniKey, bfKey, ok_ptr+4, strlen(bfKey));
                    strcat(line_buf, "\n");
                }
                if (fprintf(h_ini_new, "%s", line_buf) < 0) {
                    ZeroMemory(B64digest, sizeof(B64digest));
                    ZeroMemory(bfKey, sizeof(bfKey));
                    ZeroMemory(line_buf, sizeof(line_buf));
                    ZeroMemory(old_iniKey, sizeof(old_iniKey));
                    fclose(h_ini);
                    fclose(h_ini_new);
                    remove(iniPath_new);

                    printtext(server, item!=NULL ? window_item_get_target(item) : NULL,	MSGLEVEL_CRAP,
                              "\002FiSH ERROR:\002 Unable to write new blow.ini, probably out of disc space.");

                    return;
                }
            }
        }

        ZeroMemory(bfKey, sizeof(bfKey));
        ZeroMemory(line_buf, sizeof(line_buf));
        ZeroMemory(old_iniKey, sizeof(old_iniKey));
        fclose(h_ini);
        fclose(h_ini_new);
        remove(iniPath);
        rename(iniPath_new, iniPath);
    } else return;

    if (WritePrivateProfileString("FiSH", "ini_password_Hash", B64digest, iniPath) == -1) {
        ZeroMemory(B64digest, sizeof(B64digest));
        printtext(server, item!=NULL ? window_item_get_target(item) : NULL,	MSGLEVEL_CRAP,
                  "\002FiSH ERROR:\002 Unable to write to blow.ini, probably out of space or permission denied.");
        return;
    }

    ZeroMemory(B64digest, sizeof(B64digest));

    if (re_enc) printtext(server, item!=NULL ? window_item_get_target(item) : NULL,
                              MSGLEVEL_CRAP, "\002FiSH: Re-encrypted blow.ini\002 with new password.");

    if (!unsetiniFlag) printtext(server, item!=NULL ? window_item_get_target(item) : NULL,
                                     MSGLEVEL_CRAP, "\002FiSH:\002 blow.ini password hash saved.");
}
Beispiel #3
0
BOOL WritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, int value, LPCTSTR lpFileName)
{
	TCHAR sz[32];
	wsprintf(sz, TEXT("%d"), value);
	return WritePrivateProfileString(lpAppName, lpKeyName, sz, lpFileName);
}
Beispiel #4
0
void WritePrivateProfileBool(char* appname, char* keyname, bool val, char* file)
{
	char temp[256] = "";
	sprintf(temp, "%d", val?1:0);
	WritePrivateProfileString(appname, keyname, temp, file);
}
Beispiel #5
0
bool
IniFile::WriteString(char *key1, char *key2,char *value)
{
	//vnclog.Print(LL_INTERR, VNCLOG("%s \n"),myInifile);
	return (FALSE != WritePrivateProfileString(key1,key2, value,myInifile));
}
Beispiel #6
0
void loadIniFile()
{
	FILE *IntFile=NULL;
	fopen_s(&IntFile,".\\set.ini","r");
	if (IntFile)
	{
		fclose(IntFile);

	}
	else
	{
		WritePrivateProfileString(_T("SystemSet"),_T("winW"),_T("800"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("winH"),_T("600"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("bits"),_T("32"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("depth"),_T("24"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("isFullScreem"),_T("0"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("SYNC"),_T("0"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("LOW"),_T("0"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("AA"),_T("0"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("FPS"),_T("60"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("Light"),_T("0"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("Water"),_T("0"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("Bloom"),_T("0"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("Shadow"),_T("0"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("MoveBlur"),_T("0"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("Cloud"),_T("0"),_T(".\\set.ini"));
		
		WritePrivateProfileString(_T("SystemSet"),_T("LineWidth"),_T("1"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("FogColorR"),_T("255"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("FogColorG"),_T("255"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("FogColorB"),_T("255"),_T(".\\set.ini"));
		WritePrivateProfileString(_T("SystemSet"),_T("FogDensity"),_T("35"),_T(".\\set.ini"));
		}

		SystemSet.winW=GetPrivateProfileInt(_T("SystemSet"),_T("winW"),800,_T(".\\set.ini"));
		SystemSet.winH=GetPrivateProfileInt(_T("SystemSet"),_T("winH"),600,_T(".\\set.ini"));
		SystemSet.bits=GetPrivateProfileInt(_T("SystemSet"),_T("bits"),32,_T(".\\set.ini"));
		SystemSet.depth=GetPrivateProfileInt(_T("SystemSet"),_T("depth"),24,_T(".\\set.ini"));
		if(GetPrivateProfileInt(_T("SystemSet"),_T("isFullScreem"),0,_T(".\\set.ini"))>0)
			SystemSet.isFullScreem=true;
		else
			SystemSet.isFullScreem=false;
		if(GetPrivateProfileInt(_T("SystemSet"),_T("SYNC"),0,_T(".\\set.ini"))>0)
			SystemSet.SYNC=true;
		else
			SystemSet.SYNC=false;
		if(GetPrivateProfileInt(_T("SystemSet"),_T("LOW"),0,_T(".\\set.ini"))>0)
			SystemSet.LOW=true;
		else
			SystemSet.LOW=false;
		SystemSet.AA=GetPrivateProfileInt(_T("SystemSet"),_T("AA"),0,_T(".\\set.ini"));
		SystemSet.FPS=GetPrivateProfileInt(_T("SystemSet"),_T("FPS"),60,_T(".\\set.ini"));
		SystemSet.Light=GetPrivateProfileInt(_T("SystemSet"),_T("Light"),0,_T(".\\set.ini"));
		SystemSet.Water=GetPrivateProfileInt(_T("SystemSet"),_T("Water"),0,_T(".\\set.ini"));
		SystemSet.Bloom=GetPrivateProfileInt(_T("SystemSet"),_T("Bloom"),0,_T(".\\set.ini"));
		SystemSet.Shadow=GetPrivateProfileInt(_T("SystemSet"),_T("Shadow"),0,_T(".\\set.ini"));
		SystemSet.MoveBlur=GetPrivateProfileInt(_T("SystemSet"),_T("MoveBlur"),0,_T(".\\set.ini"));
		SystemSet.Cloud=GetPrivateProfileInt(_T("SystemSet"),_T("Cloud"),0,_T(".\\set.ini"));
		
		SystemSet.LineWidth=max(1,GetPrivateProfileInt(_T("SystemSet"),_T("LineWidth"),1,_T(".\\set.ini")));
		SystemSet.FogColorR=GetPrivateProfileInt(_T("SystemSet"),_T("FogColorR"),255,_T(".\\set.ini"));
		SystemSet.FogColorG=GetPrivateProfileInt(_T("SystemSet"),_T("FogColorG"),255,_T(".\\set.ini"));
		SystemSet.FogColorB=GetPrivateProfileInt(_T("SystemSet"),_T("FogColorB"),255,_T(".\\set.ini"));
		SystemSet.FogDensity=GetPrivateProfileInt(_T("SystemSet"),_T("FogDensity"),35,_T(".\\set.ini"));
}
int TDBXIN::ReadDB(PGLOBAL g)
  {
  /*********************************************************************/
  /*  Now start the pseudo reading process.                            */
  /*********************************************************************/
#if 0               // XIN tables are not indexable
  if (To_Kindex) {
    /*******************************************************************/
    /*  Reading is by an index table.                                  */
    /*******************************************************************/
    int recpos = To_Kindex->Fetch(g);

    switch (recpos) {
      case -1:           // End of file reached
        return RC_EF;
      case -2:           // No match for join
        return RC_NF;
      case -3:           // Same record as last non null one
        return RC_OK;
      default:
        SetRecpos(g, recpos);
      } // endswitch recpos

  } else {
#endif // 0
    do {
      if (!Keycur || !*Keycur) {
        if (!Section)
          Section = Seclist;
        else
          Section += (strlen(Section) + 1);

        if (*Section)
          Keycur = GetKeylist(g, Section);
        else
          return RC_EF;

      } else
        Keycur += (strlen(Keycur) + 1);

      } while (!*Keycur);

    N++;
//} // endif To_Kindex

  return RC_OK;
  } // end of ReadDB

/***********************************************************************/
/*  WriteDB: Data Base write routine for XIN access methods.           */
/***********************************************************************/
int TDBXIN::WriteDB(PGLOBAL g)
  {
  // To check that section and key names were given when inserting
  if (Mode == MODE_INSERT) {
    Section = NULL;
    Keycur = NULL;
    } // endif Mode

  // Nothing else to do because all was done in WriteColumn
  return RC_OK;
  } // end of WriteDB

/***********************************************************************/
/*  Data Base delete line routine for XIN access methods.              */
/***********************************************************************/
int TDBXIN::DeleteDB(PGLOBAL g, int irc)
  {
  if (irc == RC_EF) {
  } else if (irc == RC_FX) {
    for (Section = Seclist; *Section; Section += (strlen(Section) + 1))
      if (!WritePrivateProfileString(Section, NULL, NULL, Ifile)) {
        sprintf(g->Message, "Error %d accessing %s", 
                            GetLastError(), Ifile);
        return RC_FX;
        } // endif

  } else if (!Section) {
    strcpy(g->Message, MSG(NO_SECTION_NAME));
    return RC_FX;
  } else
    if (!WritePrivateProfileString(Section, Keycur, NULL, Ifile)) {
      sprintf(g->Message, "Error %d accessing %s", 
                          GetLastError(), Ifile);
      return RC_FX;
      } // endif

  return RC_OK;
  } // end of DeleteDB

// ------------------------ XINCOL functions ----------------------------

/***********************************************************************/
/*  XINCOL public constructor.                                         */
/***********************************************************************/
XINCOL::XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
      : INICOL(cdp, tdbp, cprec, i, am)
  {
  } // end of XINCOL constructor

/***********************************************************************/
/*  XINCOL constructor used for copying columns.                       */
/*  tdbp is the pointer to the new table descriptor.                   */
/***********************************************************************/
XINCOL::XINCOL(XINCOL *col1, PTDB tdbp) : INICOL(col1, tdbp)
  {
  } // end of XINCOL copy constructor

/***********************************************************************/
/*  ReadColumn: what this routine does is to access the key buffer set */
/*  from the corresponding section, extract from it the key value      */
/*  corresponding to this column name and convert it to buffer type.   */
/***********************************************************************/
void XINCOL::ReadColumn(PGLOBAL g)
  {
  PTDBXIN tdbp = (PTDBXIN)To_Tdb;

  /*********************************************************************/
  /*  Get the key value from the XIN file.                             */
  /*********************************************************************/
  switch (Flag) {
    case 1:
      strncpy(Valbuf, tdbp->Section, Long);              // Section name
      Valbuf[Long] = '\0';
      break;
    case 2:
      strncpy(Valbuf, tdbp->Keycur, Long);               // Key name
      Valbuf[Long] = '\0';
      break;
    default:
      GetPrivateProfileString(tdbp->Section, tdbp->Keycur, "",
                                        Valbuf, Long + 1, tdbp->Ifile);
      break;
    } // endswitch Flag

  Value->SetValue_psz(Valbuf);
  } // end of ReadColumn
void SetPriorityBoost() {
  CheckMenuItem(vmPrefsMenu, ID_PRIORITYBOOST, MF_BYCOMMAND | 
		(fPriorityBoost ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("PriorityBoost"),
			    fPriorityBoost ? U_ON : U_OFF,squeakIniName);
}
void SetB3DXUsesOpenGL() {
  CheckMenuItem(vmPrefsMenu, ID_USEOPENGL, MF_BYCOMMAND | 
		(fUseOpenGL ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("B3DXUsesOpenGL"),
			    fUseOpenGL ? U_ON : U_OFF,squeakIniName);
}
Beispiel #10
0
void IniFile::write_string(pcchar key, pcchar value)
{
    WritePrivateProfileString(m_section,key,value,m_file);
}
void SetUseDirectSound() {
  CheckMenuItem(vmPrefsMenu, ID_DIRECTSOUND, MF_BYCOMMAND | 
		(fUseDirectSound ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("UseDirectSound"),
			    fUseDirectSound ? U_ON : U_OFF,squeakIniName);
}
Beispiel #12
0
static bool WritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, int value, LPCTSTR lpFileName)
{
	TCHAR valBuf[16];
	_itot(value, valBuf, 10);
	return WritePrivateProfileString(lpAppName, lpKeyName, valBuf, lpFileName);
}
Beispiel #13
0
void SetWMode(int width, int height, bool state)
{
    // Compatibility for Xen W-Mode
    if ( ghMainWnd && !(GetWindowLong(ghMainWnd, GWL_STYLE) & WS_SYSMENU) )
        return;

    if ( !isCorrectVersion )
        return;

    if ( state )
    {
        wmode = true;
        if ( !ghMainWnd )
            return;

        // Call the DirectDraw destructor
        DDrawDestroy();
        InitializeWModeBitmap(BW::BWDATA::GameScreenBuffer->width(), BW::BWDATA::GameScreenBuffer->height());

        // Hack to enable drawing in Broodwar
        *BW::BWDATA::PrimarySurface = (LPDIRECTDRAWSURFACE)1;

        POINT pos = { windowRect.left + (gdwProcNum ? 32 : 0), windowRect.top + (gdwProcNum ? 32 : 0) };
        // Change the window settings
        SetWindowLong(ghMainWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
        SetWindowPos(ghMainWnd, HWND_NOTOPMOST, pos.x, pos.y, width, height, SWP_SHOWWINDOW);
        ShowWindow(ghMainWnd, SW_RESTORE);

        SIZE border;
        GetBorderSize(ghMainWnd, &border);
        int w = width + border.cx;
        int h = height + border.cy;

        int cx = GetSystemMetrics(SM_CXFULLSCREEN);
        int cy = GetSystemMetrics(SM_CYFULLSCREEN);
        while ( pos.x < 0 )
            pos.x = 0;
        while ( pos.y < 0 )
            pos.y = 0;
        if ( pos.y + h >= cy )
        {
            if ( gdwProcNum )
                pos.y -= cy - h;
            else
                pos.y = cy - h;
        }
        if ( pos.x + w >= cx )
        {
            if ( gdwProcNum )
                pos.x -= cx - w;
            else
                pos.x = cx - w;
        }
        MoveWindow(ghMainWnd, pos.x, pos.y, w, h, TRUE);
        SetCursor(NULL);
        SetCursorShowState(false);

        SetDIBColorTable(hdcMem, 0, 256, wmodebmp.bmiColors);
        WritePrivateProfileString("window", "windowed", "ON", configPath.c_str());
    }
    else
    {
        wmode = false;
        *BW::BWDATA::PrimarySurface = NULL;
        if ( hdcMem )
            DeleteDC(hdcMem);
        hdcMem = NULL;

        SetWindowLong(ghMainWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE | WS_SYSMENU);
        SetWindowPos(ghMainWnd, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
        SetCursor(NULL);
        SetCursorShowState(false);
        SetFocus(ghMainWnd);

        DDrawDestroy();
        DDrawInitialize(width, height);
        WritePrivateProfileString("window", "windowed", "OFF", configPath.c_str());
    }
}
Beispiel #14
0
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    if ( wmode )
    {
        // Perform W-Mode only functionality
        switch ( uMsg )
        {
        case WM_SIZING:
        {
            SIZE border;
            GetBorderSize(hWnd, &border);

            RECT *rct = (RECT*)lParam;
            SIZE ws   = { rct->right - rct->left - border.cx, rct->bottom - rct->top - border.cy };
            if ( ws.cx < WMODE_MIN_WIDTH )
            {
                ws.cx = WMODE_MIN_WIDTH;
                CorrectWindowWidth(wParam, &ws, rct, &border);
            }
            if ( ws.cy < WMODE_MIN_HEIGHT )
            {
                ws.cy = WMODE_MIN_HEIGHT;
                CorrectWindowHeight(wParam, &ws, rct, &border);
            }

            if ( GetKeyState(VK_CONTROL) & 0x8000 && ws.cy != ws.cx * 3 / 4 )
            {
                if ( wParam == WMSZ_TOP || wParam == WMSZ_BOTTOM )
                {
                    ws.cx = ws.cy * 4 / 3;
                    CorrectWindowWidth(WMSZ_RIGHT, &ws, rct, &border);
                }
                else
                {
                    ws.cy = ws.cx * 3 / 4;
                    CorrectWindowHeight( (wParam == WMSZ_RIGHT || wParam == WMSZ_LEFT) ? WMSZ_BOTTOM : wParam, &ws, rct, &border);
                }
            }

            if ( isCorrectVersion ) // must be correct version to reference BWDATA
            {
                if ( ws.cx >= BW::BWDATA::GameScreenBuffer->width() - WMODE_SNAP_RANGE &&
                        ws.cx <= BW::BWDATA::GameScreenBuffer->width() + WMODE_SNAP_RANGE )
                {
                    ws.cx = BW::BWDATA::GameScreenBuffer->width();
                    CorrectWindowWidth( (wParam == WMSZ_TOP || wParam == WMSZ_BOTTOM) ? WMSZ_RIGHT : wParam, &ws, rct, &border);
                }
                if ( ws.cy >= BW::BWDATA::GameScreenBuffer->height() - WMODE_SNAP_RANGE &&
                        ws.cy <= BW::BWDATA::GameScreenBuffer->height() + WMODE_SNAP_RANGE )
                {
                    ws.cy = BW::BWDATA::GameScreenBuffer->height();
                    CorrectWindowHeight( (wParam == WMSZ_RIGHT || wParam == WMSZ_LEFT) ? WMSZ_BOTTOM : wParam, &ws, rct, &border);
                }
            }
            break;
        } // case WM_SIZING
        case WM_SIZE:
        {
            switch ( wParam )
            {
            case SIZE_RESTORED:
            {
                char szTemp[32];
                RECT tempRect;
                GetClientRect(hWnd, &tempRect);
                windowRect.right  = tempRect.right;
                windowRect.bottom = tempRect.bottom;
                WritePrivateProfileString("window", "width",  _itoa(tempRect.right,  szTemp, 10), configPath.c_str());
                WritePrivateProfileString("window", "height", _itoa(tempRect.bottom, szTemp, 10), configPath.c_str());
                break;
            }
            }// wParam switch
            break;
        } // case WM_SIZE
        case WM_MOVE:
        {
            RECT tempRect;
            GetWindowRect(hWnd, &tempRect);
            if ( tempRect.right > 0 &&
                    tempRect.bottom > 0 &&
                    tempRect.left < GetSystemMetrics(SM_CXFULLSCREEN) &&
                    tempRect.top  < GetSystemMetrics(SM_CYFULLSCREEN) )
            {
                windowRect.left = tempRect.left;
                windowRect.top  = tempRect.top;

                char szTemp[32];
                WritePrivateProfileString("window", "left", _itoa(tempRect.left, szTemp, 10), configPath.c_str());
                WritePrivateProfileString("window", "top",  _itoa(tempRect.top, szTemp, 10), configPath.c_str());
            }
            break;
        } // case WM_MOVE
        case WM_PAINT:
            if ( gbWantUpdate && pBits)
            {
                static DWORD dwLastUpdate = 0;
                DWORD dwNewTick = GetTickCount();
                if ( dwLastUpdate + (IsIconic(hWnd) ? 200 : 20) > dwNewTick )
                    break;
                dwLastUpdate = dwNewTick;
                gbWantUpdate = false;

                // begin paint
                PAINTSTRUCT paint;
                HDC hdc = BeginPaint(hWnd, &paint);

                if ( isCorrectVersion ) // must be correct version, @todo: make independent
                {
                    // Blit to the screen
                    RECT cRect;
                    GetClientRect(hWnd, &cRect);
                    if ( cRect.right == BW::BWDATA::GameScreenBuffer->width() && cRect.bottom == BW::BWDATA::GameScreenBuffer->height() )
                    {
                        BitBlt(hdc, 0, 0, BW::BWDATA::GameScreenBuffer->width(), BW::BWDATA::GameScreenBuffer->height(), hdcMem, 0, 0, SRCCOPY);
                    }
                    else
                    {
                        SetStretchBltMode(hdc, HALFTONE);
                        //StretchBlt(hdc, 0, 0, cRect.right, cRect.bottom, hdcMem, 0, 0, BW::BWDATA::GameScreenBuffer->wid, BW::BWDATA::GameScreenBuffer->ht, SRCCOPY);
                        StretchDIBits(hdc, 0, 0, cRect.right, cRect.bottom, 0, 0, BW::BWDATA::GameScreenBuffer->width(), BW::BWDATA::GameScreenBuffer->height(), pBits, (BITMAPINFO*)&wmodebmp, DIB_RGB_COLORS, SRCCOPY);
                    }
                }

                // end paint
                EndPaint(hWnd, &paint);
            } // data
            break;
        case WM_NCMOUSEMOVE:
            SetCursorShowState(true);
            break;
        case WM_MOUSEMOVE:
            SetCursorShowState(false);
            lParam = FixPoints(lParam);
            break;
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
        case WM_MBUTTONDOWN:
        {
            RECT clientRct;
            GetClientRect(hWnd, &clientRct);
            ClientToScreen(hWnd, (LPPOINT)&clientRct.left);
            ClientToScreen(hWnd, (LPPOINT)&clientRct.right);
            ClipCursor(&clientRct);
            lParam = FixPoints(lParam);
            break;
        }
        case WM_MBUTTONUP:
        case WM_LBUTTONUP:
        case WM_RBUTTONUP:
            ClipCursor(NULL);
            lParam = FixPoints(lParam);
            break;
        case WM_MOUSEWHEEL:
        case WM_RBUTTONDBLCLK:
        case WM_LBUTTONDBLCLK:
        case WM_MBUTTONDBLCLK:
            lParam = FixPoints(lParam);
            break;
        case WM_ACTIVATEAPP:
            if ( wOriginalProc )
                return wOriginalProc(hWnd, WM_ACTIVATEAPP, (WPARAM)1, NULL);
        case WM_SETCURSOR:
        case WM_ERASEBKGND:
            return DefWindowProc(hWnd, uMsg, wParam, lParam);
        case WM_SYSKEYDOWN:
        case WM_KEYDOWN:
            if ( wParam == VK_MENU && !(lParam & 0x40000000))
            {
                RECT rct;
                GetClientRect(hWnd, &rct);
                ClientToScreen(hWnd, (LPPOINT)&rct.left);
                ClientToScreen(hWnd, (LPPOINT)&rct.right);
                ClipCursor(&rct);
                gbHoldingAlt = true;
            }
            break;
        case WM_SYSKEYUP:
        case WM_KEYUP:
            if ( wParam == VK_MENU )
            {
                ClipCursor(NULL);
                gbHoldingAlt = false;
            }
            break;
        } // switch
    } // if wmode

    if ( isCorrectVersion )
    {
        // Perform BWAPI-added functionality
        switch ( uMsg )
        {
        case WM_SYSKEYDOWN:
            if ( wParam == VK_RETURN && (lParam & 0x20000000) && !(lParam & 0x40000000) )
            {
                SetWMode(BW::BWDATA::GameScreenBuffer->width(), BW::BWDATA::GameScreenBuffer->height(), !wmode);
                return TRUE;
            }
            break;
        case WM_MOUSEMOVE:
            if ( GetWindowLong(ghMainWnd, GWL_STYLE) & WS_SYSMENU ) // Compatibility for Xen W-Mode
            {
                (*BW::BWDATA::InputFlags) |= 1;
                POINTS pt = MAKEPOINTS(lParam);
                BW::BWDATA::Mouse->x = pt.x;
                BW::BWDATA::Mouse->y = pt.y;
                return TRUE;
            }
            break;
        case WM_LBUTTONDOWN:
        case WM_LBUTTONUP:
        case WM_LBUTTONDBLCLK:
        case WM_RBUTTONDOWN:
        case WM_RBUTTONUP:
        case WM_RBUTTONDBLCLK:
        case WM_MBUTTONDOWN:
        case WM_MBUTTONUP:
        case WM_MBUTTONDBLCLK:
            if ( GetWindowLong(ghMainWnd, GWL_STYLE) & WS_SYSMENU ) // Compatibility for Xen W-Mode
            {
                ButtonEvent(uMsg - WM_MOUSEFIRST + BW_EVN_MOUSEFIRST, lParam);
                return TRUE;
            }
            break;
        case WM_SYSCOMMAND:
            if ( wParam == SC_MAXIMIZE )
            {
                SetWMode(BW::BWDATA::GameScreenBuffer->width(), BW::BWDATA::GameScreenBuffer->height(), false);
                return TRUE;
            }
            break;
        }
    }

    // Register Broodwar thread name
    RegisterThreadName("Broodwar Main");

    // Call the original WndProc
    if ( wOriginalProc )
        return wOriginalProc(hWnd, uMsg, wParam, lParam);
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
void Set1ButtonMouse() {
  CheckMenuItem(vmPrefsMenu, ID_1BUTTONMOUSE, MF_BYCOMMAND | 
		(f1ButtonMouse ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("1ButtonMouse"),
			    f1ButtonMouse ? U_ON : U_OFF,squeakIniName);
}
void SetCaseSensitiveFileMode() {
  CheckMenuItem(vmPrefsMenu, ID_CASEFILES, MF_BYCOMMAND | 
		(caseSensitiveFileMode ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("CaseSensitiveFileMode"),
			    caseSensitiveFileMode ? U_ON : U_OFF,squeakIniName);
}
Beispiel #17
0
void SaveIniFile()
{

	_itoa_s(SystemSet.winW,Writeini,sizeof(Writeini),10);			WritePrivateProfileString(_T("SystemSet"),_T("winW"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.winH,Writeini,sizeof(Writeini),10);			WritePrivateProfileString(_T("SystemSet"),_T("winH"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.bits,Writeini,sizeof(Writeini),10);			WritePrivateProfileString(_T("SystemSet"),_T("bits"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.depth,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("depth"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.isFullScreem,Writeini,sizeof(Writeini),10);	WritePrivateProfileString(_T("SystemSet"),_T("isFullScreem"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.SYNC,Writeini,sizeof(Writeini),10);			WritePrivateProfileString(_T("SystemSet"),_T("SYNC"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.LOW,Writeini,sizeof(Writeini),10);			WritePrivateProfileString(_T("SystemSet"),_T("LOW"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.AA,Writeini,sizeof(Writeini),10);			WritePrivateProfileString(_T("SystemSet"),_T("AA"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.FPS,Writeini,sizeof(Writeini),10);			WritePrivateProfileString(_T("SystemSet"),_T("FPS"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.Light,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("Light"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.Water,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("Water"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.Bloom,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("Bloom"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.Shadow,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("Shadow"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.MoveBlur,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("MoveBlur"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.Cloud,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("Cloud"),Writeini,_T(".\\set.ini"));

	_itoa_s(SystemSet.LineWidth,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("LineWidth"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.FogColorR,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("FogColorR"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.FogColorG,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("FogColorG"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.FogColorB,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("FogColorB"),Writeini,_T(".\\set.ini"));
	_itoa_s(SystemSet.FogDensity,Writeini,sizeof(Writeini),10);		WritePrivateProfileString(_T("SystemSet"),_T("FogDensity"),Writeini,_T(".\\set.ini"));
}
/****************************************************************************/
#ifdef WCE_PREFERENCES
#define GetCursorPos(pt) *(pt) = mousePosition;
#define WritePrivateProfileString(a1,a2,a3,a4);
#endif

void SetDeferredUpdate() {
  CheckMenuItem(vmPrefsMenu, ID_DEFERUPDATES, MF_BYCOMMAND | 
		(fDeferredUpdate ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("DeferUpdate"),
			    fDeferredUpdate ? U_ON : U_OFF,squeakIniName);
}

void SetShowConsole() {
  CheckMenuItem(vmPrefsMenu, ID_SHOWCONSOLE, MF_BYCOMMAND | 
		(fShowConsole ? MF_CHECKED : MF_UNCHECKED));
  if(IsWindow(stWindow)) 
    ShowWindow(consoleWindow, fShowConsole ? SW_SHOW : SW_HIDE);
  WritePrivateProfileString(U_GLOBAL,TEXT("ShowConsole"),
			    fShowConsole ? U_ON:U_OFF,squeakIniName);
}

void SetDynamicConsole() {
  CheckMenuItem(vmPrefsMenu, ID_DYNAMICCONSOLE, MF_BYCOMMAND | 
		(fDynamicConsole ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("DynamicConsole"),
			    fDynamicConsole ? U_ON:U_OFF,squeakIniName);
}

void SetReduceCPUUsage() {
  CheckMenuItem(vmPrefsMenu, ID_REDUCECPUUSAGE, MF_BYCOMMAND | 
		(fReduceCPUUsage ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("ReduceCPUUsage"),
			    fReduceCPUUsage ? U_ON:U_OFF,squeakIniName);
}

void SetReduceCPUInBackground() {
  CheckMenuItem(vmPrefsMenu, ID_REDUCEBACKGROUNDCPU, MF_BYCOMMAND | 
		(fReduceCPUInBackground ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("ReduceCPUInBackground"),
			    fReduceCPUInBackground ? U_ON:U_OFF,squeakIniName);
}

void Set3ButtonMouse() {
  CheckMenuItem(vmPrefsMenu, ID_3BUTTONMOUSE, MF_BYCOMMAND | 
		(f3ButtonMouse ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("3ButtonMouse"),
			    f3ButtonMouse ? U_ON : U_OFF,squeakIniName);
}

void Set1ButtonMouse() {
  CheckMenuItem(vmPrefsMenu, ID_1BUTTONMOUSE, MF_BYCOMMAND | 
		(f1ButtonMouse ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("1ButtonMouse"),
			    f1ButtonMouse ? U_ON : U_OFF,squeakIniName);
}

void SetUseDirectSound() {
  CheckMenuItem(vmPrefsMenu, ID_DIRECTSOUND, MF_BYCOMMAND | 
		(fUseDirectSound ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("UseDirectSound"),
			    fUseDirectSound ? U_ON : U_OFF,squeakIniName);
}

void SetAllowFileAccess() {
  CheckMenuItem(vmPrefsMenu, ID_FILEACCESS, MF_BYCOMMAND | 
		(ioHasFileAccess() ? MF_CHECKED : MF_UNCHECKED));
}

void SetAllowImageWrite() {
  CheckMenuItem(vmPrefsMenu, ID_IMAGEWRITE, MF_BYCOMMAND | 
		(ioCanWriteImage() ? MF_CHECKED : MF_UNCHECKED));
}
#ifndef NO_NETWORK
void SetAllowSocketAccess() {
  CheckMenuItem(vmPrefsMenu, ID_SOCKETACCESS, MF_BYCOMMAND | 
		(ioHasSocketAccess() ? MF_CHECKED : MF_UNCHECKED));
}
#endif

void SetShowAllocations() {
  CheckMenuItem(vmPrefsMenu, ID_SHOWALLOCATIONS, MF_BYCOMMAND | 
		(fShowAllocations ? MF_CHECKED : MF_UNCHECKED));
}

void SetPriorityBoost() {
  CheckMenuItem(vmPrefsMenu, ID_PRIORITYBOOST, MF_BYCOMMAND | 
		(fPriorityBoost ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("PriorityBoost"),
			    fPriorityBoost ? U_ON : U_OFF,squeakIniName);
}

void SetB3DXUsesOpenGL() {
  CheckMenuItem(vmPrefsMenu, ID_USEOPENGL, MF_BYCOMMAND | 
		(fUseOpenGL ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("B3DXUsesOpenGL"),
			    fUseOpenGL ? U_ON : U_OFF,squeakIniName);
}

void SetCaseSensitiveFileMode() {
  CheckMenuItem(vmPrefsMenu, ID_CASEFILES, MF_BYCOMMAND | 
		(caseSensitiveFileMode ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("CaseSensitiveFileMode"),
			    caseSensitiveFileMode ? U_ON : U_OFF,squeakIniName);
}

int prefsEnableAltF4Quit(void) {
  fEnableAltF4Quit   = 
    GetPrivateProfileInt(U_GLOBAL,TEXT("EnableAltF4Quit"),
			 fEnableAltF4Quit,squeakIniName);
  return fEnableAltF4Quit;
}

int prefsEnableF2Menu(void) {
  fEnableF2Menu   = 
    GetPrivateProfileInt(U_GLOBAL,TEXT("EnableF2Menu"),
			 fEnableF2Menu,squeakIniName);
  return fEnableF2Menu;
}



#if 0 /* I don't think we need those in the menu */
void SetEnableF2Menu() {
  CheckMenuItem(vmPrefsMenu, ID_ENABLEF2MENU, MF_BYCOMMAND | 
		(fEnableF2Menu ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("EnableF2Menu"),
			    fEnableF2Menu ? U_ON : U_OFF,squeakIniName);
}
int TDBINI::ReadDB(PGLOBAL g)
  {
  /*********************************************************************/
  /*  Now start the pseudo reading process.                            */
  /*********************************************************************/
#if 0                // INI tables are not indexable
  if (To_Kindex) {
    /*******************************************************************/
    /*  Reading is by an index table.                                  */
    /*******************************************************************/
    int recpos = To_Kindex->Fetch(g);

    switch (recpos) {
      case -1:           // End of file reached
        return RC_EF;
      case -2:           // No match for join
        return RC_NF;
      case -3:           // Same record as last non null one
        return RC_OK;
      default:
        Section = (char*)recpos;    // No good on 64 bit machines
      } // endswitch recpos

  } else {
#endif // 0
    if (!Section)
      Section = Seclist;
    else
      Section += (strlen(Section) + 1);

    if (trace > 1)
      htrc("INI ReadDB: section=%s N=%d\n", Section, N);

    N++;
//} // endif To_Kindex

  return (*Section) ? RC_OK : RC_EF;
  } // end of ReadDB

/***********************************************************************/
/*  WriteDB: Data Base write routine for INI access methods.           */
/***********************************************************************/
int TDBINI::WriteDB(PGLOBAL g)
  {
  // This is to check that section name was given when inserting
  if (Mode == MODE_INSERT)
    Section = NULL;

  // Nothing else to do because all was done in WriteColumn
  return RC_OK;
  } // end of WriteDB

/***********************************************************************/
/*  Data Base delete line routine for INI access methods.              */
/***********************************************************************/
int TDBINI::DeleteDB(PGLOBAL g, int irc)
  {
  switch (irc) {
    case RC_EF:
      break;
    case RC_FX:
      while (ReadDB(g) == RC_OK)
        if (!WritePrivateProfileString(Section, NULL, NULL, Ifile)) {
          sprintf(g->Message, "Error %d accessing %s", 
                              GetLastError(), Ifile);
          return RC_FX;
          } // endif

      break;
    default:
      if (!Section) {
        strcpy(g->Message, MSG(NO_SECTION_NAME));
        return RC_FX;
      } else
        if (!WritePrivateProfileString(Section, NULL, NULL, Ifile)) {
          sprintf(g->Message, "Error %d accessing %s", 
                              GetLastError(), Ifile);
          return RC_FX;
          } // endif rc

    } // endswitch irc

  return RC_OK;
  } // end of DeleteDB

/***********************************************************************/
/*  Data Base close routine for INI access methods.                    */
/***********************************************************************/
void TDBINI::CloseDB(PGLOBAL g)
  {
#if !defined(WIN32)
  PROFILE_Close(Ifile);
#endif   // !WIN32
  } // end of CloseDB
void SetEnableAltF4Quit() {
  CheckMenuItem(vmPrefsMenu, ID_ENABLEALTF4QUIT, MF_BYCOMMAND | 
		(fEnableAltF4Quit ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("EnableAltF4Quit"),
			    enableAltF4Quit ? U_ON : U_OFF,squeakIniName);
}
void XINCOL::WriteColumn(PGLOBAL g)
  {
  char   *p;
  bool    rc;
  PTDBXIN tdbp = (PTDBXIN)To_Tdb;

  if (trace > 1)
    htrc("XIN WriteColumn: col %s R%d coluse=%.4X status=%.4X\n",
          Name, tdbp->GetTdb_No(), ColUse, Status);

  /*********************************************************************/
  /*  Get the string representation of Value according to column type. */
  /*********************************************************************/
  if (Value != To_Val)
    Value->SetValue_pval(To_Val, false);    // Convert the updated value

  p = Value->GetCharString(Valbuf);

  if (strlen(p) > (unsigned)Long) {
    sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
    longjmp(g->jumper[g->jump_level], 31);
  } else if (Flag == 1) {
    if (tdbp->Mode == MODE_UPDATE) {
      strcpy(g->Message, MSG(NO_SEC_UPDATE));
      longjmp(g->jumper[g->jump_level], 31);
    } else if (*p) {
      tdbp->Section = p;
    } else
      tdbp->Section = NULL;

    return;
  } else if (Flag == 2) {
    if (tdbp->Mode == MODE_UPDATE) {
      strcpy(g->Message, MSG(NO_KEY_UPDATE));
      longjmp(g->jumper[g->jump_level], 31);
    } else if (*p) {
      tdbp->Keycur = p;
    } else
      tdbp->Keycur = NULL;

    return;
  } else if (!tdbp->Section || !tdbp->Keycur) {
    strcpy(g->Message, MSG(SEC_KEY_FIRST));
    longjmp(g->jumper[g->jump_level], 31);
  } // endif's

  /*********************************************************************/
  /*  Updating must be done only when not in checking pass.            */
  /*********************************************************************/
  if (Status) {
    rc = WritePrivateProfileString(tdbp->Section, tdbp->Keycur, p, tdbp->Ifile);
    
    if (!rc) {
      sprintf(g->Message, "Error %d writing to %s", 
                          GetLastError(), tdbp->Ifile);
      longjmp(g->jumper[g->jump_level], 31);
      } // endif rc

    } // endif Status

  } // end of WriteColumn
void SetDeferredUpdate() {
  CheckMenuItem(vmPrefsMenu, ID_DEFERUPDATES, MF_BYCOMMAND | 
		(fDeferredUpdate ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("DeferUpdate"),
			    fDeferredUpdate ? U_ON : U_OFF,squeakIniName);
}
Beispiel #23
0
void WritePrivateProfileInt(char* appname, char* keyname, int val, char* file)
{
	char temp[256] = "";
	sprintf(temp, "%d", val);
	WritePrivateProfileString(appname, keyname, temp, file);
}
void SetDynamicConsole() {
  CheckMenuItem(vmPrefsMenu, ID_DYNAMICCONSOLE, MF_BYCOMMAND | 
		(fDynamicConsole ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("DynamicConsole"),
			    fDynamicConsole ? U_ON:U_OFF,squeakIniName);
}
BOOL INSTAPI
SQLWritePrivateProfileString (LPCSTR lpszSection, LPCSTR lpszEntry,
    LPCSTR lpszString, LPCSTR lpszFilename)
{
  char pathbuf[1024];
  BOOL retcode = FALSE;

  /* Check input parameters */
  CLEAR_ERROR ();

  /* Else go through user/system odbc.ini */
  switch (configMode)
    {
    case ODBC_USER_DSN:
      wSystemDSN = USERDSN_ONLY;
      if (lpszFilename)
	{
	  retcode =
	      WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	      lpszFilename);
	  goto quit;
	}
      if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE))
	retcode =
	    WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	    pathbuf);
      goto quit;

    case ODBC_SYSTEM_DSN:
      wSystemDSN = SYSTEMDSN_ONLY;
      if (lpszFilename)
	{
	  retcode =
	      WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	      lpszFilename);
	  goto quit;
	}
      if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE))
	retcode =
	    WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	    pathbuf);
      goto quit;

    case ODBC_BOTH_DSN:
      wSystemDSN = USERDSN_ONLY;
      if (lpszFilename)
	{
	  retcode =
	      WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	      lpszFilename);
	  if (!retcode)
	    {
	      CLEAR_ERROR ();
	      wSystemDSN = SYSTEMDSN_ONLY;
	      retcode =
		  WritePrivateProfileString (lpszSection, lpszEntry,
		  lpszString, lpszFilename);
	    }
	  goto quit;
	}
      if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE))
	retcode =
	    WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	    pathbuf);
      else
	{
	  CLEAR_ERROR ();
	  wSystemDSN = SYSTEMDSN_ONLY;
	  if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE))
	    retcode =
		WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
		pathbuf);
	}
      goto quit;
    }

  PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
  goto quit;

quit:
  wSystemDSN = USERDSN_ONLY;
  configMode = ODBC_BOTH_DSN;
  return retcode;
}
void SetReduceCPUUsage() {
  CheckMenuItem(vmPrefsMenu, ID_REDUCECPUUSAGE, MF_BYCOMMAND | 
		(fReduceCPUUsage ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("ReduceCPUUsage"),
			    fReduceCPUUsage ? U_ON:U_OFF,squeakIniName);
}
Beispiel #27
0
void ConfigSave(void)
{
  int i;
  char ignore_string[MAX_IGNORE_LIST * (MAX_CHARNAME + 1) + 1];
  
   WriteConfigInt(misc_section, INISaveOnExit, config.save_settings, ini_file);
   WriteConfigInt(misc_section, INIPlayMusic, config.play_music, ini_file);
   WriteConfigInt(misc_section, INIPlaySound, config.play_sound, ini_file);
   WriteConfigInt(misc_section, INIMusicVolume, config.music_volume, ini_file);
   WriteConfigInt(misc_section, INISoundVolume, config.sound_volume, ini_file);
   WriteConfigInt(misc_section, INIPlayLoopSounds, config.play_loop_sounds, ini_file);
   WriteConfigInt(misc_section, INIPlayRandomSounds, config.play_random_sounds, ini_file);
   WriteConfigInt(misc_section, INITimeout, config.timeout, ini_file);
   WriteConfigInt(misc_section, INIArea, gLargeArea, ini_file);
   WriteConfigInt(misc_section, INIAnimate, config.animate, ini_file);
   WriteConfigInt(misc_section, INIVersion, config.ini_version, ini_file);
   WriteConfigInt(misc_section, INIDefaultBrowser, config.default_browser, ini_file);
   WritePrivateProfileString(misc_section, INIBrowser, config.browser, ini_file);

   WriteConfigInt(misc_section, INICacheBalance, config.CacheBalance, ini_file);
   WriteConfigInt(misc_section, INIObjectCacheMin, config.ObjectCacheMin, ini_file);
   WriteConfigInt(misc_section, INIGridCacheMin, config.GridCacheMin, ini_file);

   WriteConfigInt(users_section, INIDrawNames, config.draw_names, ini_file);
   WriteConfigInt(users_section, INIIgnoreAll, config.ignore_all, ini_file);
   WriteConfigInt(users_section, ININoBroadcast, config.no_broadcast, ini_file);

   // Build up comma-separated list of character names
   ignore_string[0] = 0;
   for (i = 0; i < MAX_IGNORE_LIST; ++i) {
     if (config.ignore_list[i][0] != 0) {
       strcat(ignore_string, config.ignore_list[i]);
       strcat(ignore_string, ",");
     }
   }
   WritePrivateProfileString(users_section, INIIgnoreList, ignore_string, ini_file);

   WritePrivateProfileString(misc_section, INIUserName, config.username, ini_file);

   WriteConfigInt(interface_section, INIScrollLock, config.scroll_lock, ini_file);
   WriteConfigInt(interface_section, INITooltips, config.tooltips, ini_file);
   WriteConfigInt(interface_section, INIInventory, config.inventory_num, ini_file);
   WriteConfigInt(interface_section, INIAggressive, config.aggressive, ini_file);
   WriteConfigInt(interface_section, INIBounce, config.bounce, ini_file);
   WriteConfigInt(interface_section, INIToolbar, config.toolbar, ini_file);
   WriteConfigInt(interface_section, INIDrawMap, config.drawmap, ini_file);

   WriteConfigInt(interface_section, INIPainFX, config.pain, ini_file);
   WriteConfigInt(interface_section, INIWeatherFX, config.weather, ini_file);
   WriteConfigInt(interface_section, INIAntiProfane, config.antiprofane, ini_file);
   WriteConfigInt(interface_section, INIIgnoreProfane, config.ignoreprofane, ini_file);
   WriteConfigInt(interface_section, INIExtraProfane, config.extraprofane, ini_file);
   WriteConfigInt(interface_section, INILagbox, config.lagbox, ini_file);
   WriteConfigInt(interface_section, INIHaloColor, config.halocolor, ini_file);
   WriteConfigInt(interface_section, INIColorCodes, config.colorcodes, ini_file);
   WriteConfigInt(interface_section, INIMapAnnotations, config.map_annotations, ini_file);
   
   // Don't write out "guest" option; user can't set it

   WriteConfigInt(misc_section, INIServerLow, config.server_low, ini_file);
   WriteConfigInt(misc_section, INIServerHigh, config.server_high, ini_file);
   WriteConfigInt(misc_section, INIServerGuest, config.server_guest, ini_file);
   WriteConfigInt(misc_section, INILastPass, config.lastPasswordChange, ini_file);

   // "Special" section options NOT saved, so that they're not normally visible

   WritePrivateProfileString(interface_section, INIOldProfane, NULL, ini_file); // remove old string
}
void SetReduceCPUInBackground() {
  CheckMenuItem(vmPrefsMenu, ID_REDUCEBACKGROUNDCPU, MF_BYCOMMAND | 
		(fReduceCPUInBackground ? MF_CHECKED : MF_UNCHECKED));
  WritePrivateProfileString(U_GLOBAL,TEXT("ReduceCPUInBackground"),
			    fReduceCPUInBackground ? U_ON:U_OFF,squeakIniName);
}
Beispiel #29
0
BOOL LoadIME()
{
  BOOL Err;
#if 0
  PTTSet tempts;
#endif
  char uimsg[MAX_UIMSG];
  char imm32_dll[MAX_PATH];

  if (HIMEDLL != NULL) return TRUE;
  GetSystemDirectory(imm32_dll, sizeof(imm32_dll));
  strncat_s(imm32_dll, sizeof(imm32_dll), "\\imm32.dll", _TRUNCATE);
  HIMEDLL = LoadLibrary(imm32_dll);
  if (HIMEDLL == NULL)
  {
    get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg),  "Tera Term: Error", ts.UILanguageFile);
    get_lang_msg("MSG_USE_IME_ERROR", ts.UIMsg, sizeof(ts.UIMsg), "Can't use IME", ts.UILanguageFile);
    MessageBox(0,ts.UIMsg,uimsg,MB_ICONEXCLAMATION);
    WritePrivateProfileString("Tera Term","IME","off",ts.SetupFName);
    ts.UseIME = 0;
#if 0
    tempts = (PTTSet)malloc(sizeof(TTTSet));
    if (tempts!=NULL)
    {
      GetDefaultSet(tempts);
      tempts->UseIME = 0;
      ChangeDefaultSet(tempts,NULL);
      free(tempts);
    }
#endif
    return FALSE;
  }

  Err = FALSE;

  PImmGetCompositionString = (TImmGetCompositionString)GetProcAddress(
    HIMEDLL, "ImmGetCompositionStringA");
  if (PImmGetCompositionString==NULL) Err = TRUE;

  PImmGetContext = (TImmGetContext)GetProcAddress(
    HIMEDLL, "ImmGetContext");
  if (PImmGetContext==NULL) Err = TRUE;

  PImmReleaseContext = (TImmReleaseContext)GetProcAddress(
    HIMEDLL, "ImmReleaseContext");
  if (PImmReleaseContext==NULL) Err = TRUE;

  PImmSetCompositionFont = (TImmSetCompositionFont)GetProcAddress(
    HIMEDLL, "ImmSetCompositionFontA");
  if (PImmSetCompositionFont==NULL) Err = TRUE;

  PImmSetCompositionWindow = (TImmSetCompositionWindow)GetProcAddress(
    HIMEDLL, "ImmSetCompositionWindow");
  if (PImmSetCompositionWindow==NULL) Err = TRUE;

  PImmGetOpenStatus = (TImmGetOpenStatus)GetProcAddress(
    HIMEDLL, "ImmGetOpenStatus");
  if (PImmGetOpenStatus==NULL) Err = TRUE;

  PImmSetOpenStatus = (TImmSetOpenStatus)GetProcAddress(
    HIMEDLL, "ImmSetOpenStatus");
  if (PImmSetOpenStatus==NULL) Err = TRUE;

  if ( Err )
  {
    FreeLibrary(HIMEDLL);
    HIMEDLL = NULL;
    return FALSE;
  }
  else
    return TRUE;
}
Beispiel #30
0
void WritePrivateProfileInt(LPCSTR lpszSection, LPCSTR lpszEntry, int value, LPCSTR lpszFilename)
{
	char szConverted[8];
	_itoa_s(value, szConverted, 10);
	WritePrivateProfileString(lpszSection, lpszEntry, szConverted, lpszFilename);
}