Changeset 1519 for trunk/dll/command.c


Ignore:
Timestamp:
May 1, 2010, 9:39:04 PM (15 years ago)
Author:
Gregg Young
Message:

Add ENVIRONMENT_SIZE variable to standardize this size everywhere. Changes to move environment storage to INI file. The environment changes still don't actually get loaded in the new/child process (of course they never did).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/command.c

    r1498 r1519  
    3636  27 Dec 09 GKY Added QueryCommandSettings to streamline code
    3737  27 Dec 09 GKY Made command hotkeys user selectable.
    38   17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
     38  17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10).
     39                Mostly cast CHAR CONSTANT * as CHAR *.
     40  01 May 10 GKY Add ENVIRONMENT_SIZE variable to standardize this size everywhere.
     41  01 May 10 GKY Changes to move environment storage to INI file
    3942
    4043***********************************************************************/
     
    7780  PSZ pszCmdLine;
    7881  CHAR title[100];
    79   CHAR env[1002];
     82  CHAR env[ENVIRONMENT_SIZE];
    8083  ULONG flags;
    8184  ULONG ID;
     
    375378
    376379  size = sizeof(BOOL) * 300;
    377   PrfQueryProfileData(fmprof, (CHAR *) FM3Str, "COMMANDS.UsedCommandIDs", &UsedCommandIDs,
     380  PrfQueryProfileData(fmprof, FM3Str, "COMMANDS.UsedCommandIDs", &UsedCommandIDs,
    378381                      &size);
    379382  size = sizeof(BOOL) * 40;
    380   PrfQueryProfileData(fmprof, (CHAR *) FM3Str, "COMMANDS.UsedHotKeyIDs", &UsedHotKeyIDs,
     383  PrfQueryProfileData(fmprof, FM3Str, "COMMANDS.UsedHotKeyIDs", &UsedHotKeyIDs,
    381384                        &size); size = sizeof(BOOL);
    382   PrfQueryProfileData(fmprof, (CHAR *) FM3Str, "COMMANDS.LoadCommandsFromINI",
     385  PrfQueryProfileData(fmprof, FM3Str, "COMMANDS.LoadCommandsFromINI",
    383386                      &fLoadCommandsFromINI, &size);
    384387  if (!fLoadCommandsFromINI) {
     
    463466  ULONG ID = 0;
    464467  ULONG HotKeyID = 0;
    465   CHAR env[1002];
     468  CHAR env[ENVIRONMENT_SIZE];
    466469  CHAR key[120];
    467470  CHAR szTitle[100];
     
    481484      cmdloaded = TRUE;
    482485      size = sizeof(ULONG);
    483       PrfQueryProfileData(fmprof, (CHAR *) FM3Str, "COMMANDS.SizeSortOrder",
     486      PrfQueryProfileData(fmprof, FM3Str, "COMMANDS.SizeSortOrder",
    484487                          &ulSizeCommandsList, &size);
    485488      pszCommandsList = xmallocz(ulSizeCommandsList, pszSrcFile, __LINE__);
    486489      if (pszCommandsList) {
    487         PrfQueryProfileString(fmprof, (CHAR *) FM3Str, "COMMANDS.SortOrder",
     490        PrfQueryProfileString(fmprof, FM3Str, "COMMANDS.SortOrder",
    488491                              NullStr, pszCommandsList, ulSizeCommandsList);
    489492        p = pszCommandsList;
     
    502505            sprintf(key, "COMMAND.%sID", szTitle);
    503506            size = sizeof(ULONG);
    504             PrfQueryProfileData(fmprof, (CHAR *) FM3Str, key, &ID, &size);
     507            PrfQueryProfileData(fmprof, FM3Str, key, &ID, &size);
    505508            sprintf(key, "COMMAND.%sHotKeyID", szTitle);
    506509            size = sizeof(ULONG);
    507             PrfQueryProfileData(fmprof, (CHAR *) FM3Str, key, &HotKeyID, &size);
     510            PrfQueryProfileData(fmprof, FM3Str, key, &HotKeyID, &size);
    508511            sprintf(key, "COMMAND.%sflags", szTitle);
    509512            size = sizeof(ULONG);
    510             PrfQueryProfileData(fmprof, (CHAR *) FM3Str, key, &flags, &size);
     513            PrfQueryProfileData(fmprof, FM3Str, key, &flags, &size);
    511514            sprintf(key, "COMMAND.%senv", szTitle);
    512             PrfQueryProfileString(fmprof, (CHAR *) FM3Str, key, NullStr, env, sizeof(env));
     515            PrfQueryProfileString(fmprof, FM3Str, key, NullStr, env, sizeof(env));
    513516            sprintf(key, "COMMAND.%sCmdLine", szTitle);
    514             PrfQueryProfileString(fmprof, (CHAR *) FM3Str, key, NullStr, pszCmdLine, MaxComLineStrg);
     517            PrfQueryProfileString(fmprof, FM3Str, key, NullStr, pszCmdLine, MaxComLineStrg);
    515518          }
    516519          info = xmallocz(sizeof(LINKCMDS), pszSrcFile, __LINE__);
     
    551554        sprintf(key, "COMMAND.%sID", info->title);
    552555        size = sizeof(ULONG);
    553         PrfQueryProfileData(fmprof, (CHAR *) FM3Str, key, &ID, &size);
     556        PrfQueryProfileData(fmprof, FM3Str, key, &ID, &size);
    554557        sprintf(key, "COMMAND.%sHotKeyID", info->title);
    555558        size = sizeof(ULONG);
    556         PrfQueryProfileData(fmprof, (CHAR *) FM3Str, key, &HotKeyID, &size);
     559        PrfQueryProfileData(fmprof, FM3Str, key, &HotKeyID, &size);
    557560        sprintf(key, "COMMAND.%senv", info->title);
    558         PrfQueryProfileString(fmprof, (CHAR *) FM3Str, key, NullStr, env, sizeof(env));
     561        PrfQueryProfileString(fmprof, FM3Str, key, NullStr, env, sizeof(env));
    559562        if (ID != 0) {
    560563          if (env != NullStr)
     
    585588                     GetPString(IDS_COMMANDSLIMITREACHEDTEXT ));
    586589          }
    587           PrfQueryProfileString(fmprof, (CHAR *) FM3Str, info->pszCmdLine, NullStr, env, sizeof(env));
     590          PrfQueryProfileString(fmprof, FM3Str, info->pszCmdLine, NullStr, env, sizeof(env));
    588591          info->env = xstrdup(env, pszSrcFile, __LINE__);
    589592        }
     
    611614    while (info) {
    612615      sprintf(key, "COMMAND.%sflags", info->title);
    613       PrfWriteProfileData(fmprof, (CHAR *) FM3Str, key, &info->flags, sizeof(ULONG));
     616      PrfWriteProfileData(fmprof, FM3Str, key, &info->flags, sizeof(ULONG));
    614617      sprintf(key, "COMMAND.%sCmdLine", info->title);
    615       PrfWriteProfileString(fmprof, (CHAR *) FM3Str, key, info->pszCmdLine);
     618      PrfWriteProfileString(fmprof, FM3Str, key, info->pszCmdLine);
    616619      bstripcr(info->title);
    617620      sprintf(key, "COMMAND.%sID", info->title);
    618       PrfWriteProfileData(fmprof, (CHAR *) FM3Str, key, &info->ID, sizeof(INT));
     621      PrfWriteProfileData(fmprof, FM3Str, key, &info->ID, sizeof(INT));
    619622      sprintf(key, "COMMAND.%sHotKeyID", info->title);
    620       PrfWriteProfileData(fmprof, (CHAR *) FM3Str, key, &info->HotKeyID, sizeof(INT));
     623      PrfWriteProfileData(fmprof, FM3Str, key, &info->HotKeyID, sizeof(INT));
    621624      if (info->env != NullStr) {
    622625        sprintf(key, "COMMAND.%senv", info->title);
    623         PrfWriteProfileString(fmprof, (CHAR *) FM3Str, key, info->env);
     626        PrfWriteProfileString(fmprof, FM3Str, key, info->env);
    624627      }
    625628      if ((strlen(pszCommandsList) + strlen(info->title) + 1) > ulSizeCommandsList)
     
    631634      info = info->next;
    632635    } // while info
    633     PrfWriteProfileData(fmprof, (CHAR *) FM3Str, "COMMANDS.UsedCommandIDs", &UsedCommandIDs,
     636    PrfWriteProfileData(fmprof, FM3Str, "COMMANDS.UsedCommandIDs", &UsedCommandIDs,
    634637                        sizeof(BOOL) * 300);
    635     PrfWriteProfileData(fmprof, (CHAR *) FM3Str, "COMMANDS.UsedHotKeyIDs", &UsedHotKeyIDs,
     638    PrfWriteProfileData(fmprof, FM3Str, "COMMANDS.UsedHotKeyIDs", &UsedHotKeyIDs,
    636639                        sizeof(BOOL) * 40);
    637640    ulSizeCommandsList = strlen(pszCommandsList) + 1;
    638     PrfWriteProfileData(fmprof, (CHAR *) FM3Str, "COMMANDS.SizeSortOrder",
     641    PrfWriteProfileData(fmprof, FM3Str, "COMMANDS.SizeSortOrder",
    639642                        &ulSizeCommandsList, sizeof(ULONG));
    640     PrfWriteProfileString(fmprof, (CHAR *) FM3Str, "COMMANDS.SortOrder", pszCommandsList);
    641     PrfWriteProfileData(fmprof, (CHAR *) FM3Str, "COMMANDS.LoadCommandsFromINI",
     643    PrfWriteProfileString(fmprof, FM3Str, "COMMANDS.SortOrder", pszCommandsList);
     644    PrfWriteProfileData(fmprof, FM3Str, "COMMANDS.LoadCommandsFromINI",
    642645                        &fLoadCommandsFromINI, sizeof(BOOL));
    643646}
     
    748751    pszCommandsList = xmallocz(ulSizeCommandsList, pszSrcFile, __LINE__);
    749752    if (pszCommandsList)
    750       PrfQueryProfileString(fmprof, (CHAR *) FM3Str, "COMMANDS.SortOrder",
     753      PrfQueryProfileString(fmprof, FM3Str, "COMMANDS.SortOrder",
    751754                            NullStr, pszCommandsList, ulSizeCommandsList);
    752755    return 0;
     
    798801   PSZ pszWorkBuf;
    799802   APIRET ret;
    800    CHAR env[1002];
     803   CHAR env[ENVIRONMENT_SIZE];
    801804   INT x;
    802805
     
    825828   temp->flags = CheckExecutibleFlags(hwnd, 3);
    826829   *env = 0;
    827    WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env);
     830   WinQueryDlgItemText(hwnd, CMD_ENVIRON, ENVIRONMENT_SIZE - 1, env);
    828831   bstripcr(env);
    829832   if (*env)
     
    11031106          sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", temp);
    11041107          sprintf(keyenv, "COMMAND.%senv", temp);
    1105           PrfWriteProfileData(fmprof, (CHAR *) FM3Str, keyID, NULL, 0);
    1106           PrfWriteProfileData(fmprof, (CHAR *) FM3Str, keyHotKeyID, NULL, 0);
    1107           PrfWriteProfileString(fmprof, (CHAR *) FM3Str, keyenv, NULL);
     1108          PrfWriteProfileData(fmprof, FM3Str, keyID, NULL, 0);
     1109          PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, NULL, 0);
     1110          PrfWriteProfileString(fmprof, FM3Str, keyenv, NULL);
    11081111          x = (SHORT) WinSendDlgItemMsg(hwnd,
    11091112                                        CMD_LISTBOX,
     
    11581161        sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", temp->title);
    11591162        sprintf(keyenv, "COMMAND.%senv", temp->title);
    1160         PrfQueryProfileData(fmprof, (CHAR *) FM3Str, keyID, &ID, &size);
    1161         PrfQueryProfileData(fmprof, (CHAR *) FM3Str, keyHotKeyID, &HotKeyID, &size);
     1163        PrfQueryProfileData(fmprof, FM3Str, keyID, &ID, &size);
     1164        PrfQueryProfileData(fmprof, FM3Str, keyHotKeyID, &HotKeyID, &size);
    11621165        temp->ID = ID;
    11631166        if (temp->HotKeyID == HotKeyID || temp->HotKeyID == 0)
    11641167          fDontCheckHotKey = TRUE;
    11651168        if (kill_command(temp->title)) {
    1166           PrfWriteProfileData(fmprof, (CHAR *) FM3Str, keyID, NULL, 0);
    1167           PrfWriteProfileData(fmprof, (CHAR *) FM3Str, keyHotKeyID, NULL, 0);
    1168           PrfWriteProfileString(fmprof, (CHAR *) FM3Str, keyenv, NULL);
     1169          PrfWriteProfileData(fmprof, FM3Str, keyID, NULL, 0);
     1170          PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, NULL, 0);
     1171          PrfWriteProfileString(fmprof, FM3Str, keyenv, NULL);
    11691172          x = (SHORT) WinSendDlgItemMsg(hwnd,
    11701173                                        CMD_LISTBOX,
Note: See TracChangeset for help on using the changeset viewer.