Changeset 551 for trunk/dll/instant.c


Ignore:
Timestamp:
Feb 28, 2007, 2:33:51 AM (19 years ago)
Author:
Gregg Young
Message:

Indentation cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/instant.c

    r342 r551  
    3838static INT batches = 0;
    3939
    40 MRESULT EXPENTRY InstantDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     40MRESULT EXPENTRY InstantDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    4141{
    42   CHAR  *path;
     42  CHAR *path;
    4343  APIRET rc;
    4444  static CHAR *bat = NULL;
    45   static HWND  myhwnd = (HWND)0;
     45  static HWND myhwnd = (HWND) 0;
    4646
    47   switch(msg) {
    48     case WM_INITDLG:
    49       if (myhwnd) {
    50         Runtime_Error(pszSrcFile, __LINE__, "busy");
    51         WinSendMsg(myhwnd,WM_SYSCOMMAND,MPFROM2SHORT(SC_RESTORE,0),MPVOID);
    52         WinSetActiveWindow(HWND_DESKTOP,myhwnd);
    53         WinDismissDlg(hwnd,0);
    54         break;
     47  switch (msg) {
     48  case WM_INITDLG:
     49    if (myhwnd) {
     50      Runtime_Error(pszSrcFile, __LINE__, "busy");
     51      WinSendMsg(myhwnd, WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     52      WinSetActiveWindow(HWND_DESKTOP, myhwnd);
     53      WinDismissDlg(hwnd, 0);
     54      break;
     55    }
     56    if (!mp2) {
     57      Runtime_Error(pszSrcFile, __LINE__, "no data");
     58      WinDismissDlg(hwnd, 0);
     59      break;
     60    }
     61    WinSetWindowPtr(hwnd, 0, mp2);
     62    path = (CHAR *) mp2;
     63    {
     64      CHAR s[CCHMAXPATH + 81];
     65
     66      sprintf(s, GetPString(IDS_INSTANTTITLETEXT), path);
     67      WinSetWindowText(hwnd, s);
     68    }
     69    WinSendMsg(hwndMLE,
     70               MLM_SETTEXTLIMIT, MPFROMLONG((LONG) (10240L)), MPVOID);
     71    WinSendMsg(hwndMLE, MLM_FORMAT, MPFROM2SHORT(MLFIE_NOTRANS, 0), MPVOID);
     72    if (bat) {
     73
     74      ULONG tlen = strlen(bat);
     75      IPT iptOffset = 0L;
     76
     77      WinSendMsg(hwndMLE, MLM_SETIMPORTEXPORT,
     78                 MPFROMP(bat), MPFROMLONG(12287L));
     79      WinSendMsg(hwndMLE, MLM_IMPORT, MPFROMP(&iptOffset), MPFROMP(tlen));
     80      DosFreeMem(bat);
     81      bat = NULL;
     82    }
     83    break;
     84
     85  case WM_COMMAND:
     86    switch (SHORT1FROMMP(mp1)) {
     87    case DID_OK:
     88      path = (CHAR *) WinQueryWindowPtr(hwnd, 0);
     89      {
     90        CHAR s[CCHMAXPATH + 1];
     91        FILE *fp;
     92        IPT iptOffset = 0L;
     93        LONG len, tlen, mem;
     94        CHAR *rexx = "";
     95
     96        mem = MLEgetlen(hwndMLE);
     97        if (mem) {
     98          rc = DosAllocMem((PVOID) & bat, mem,
     99                           PAG_COMMIT | PAG_READ | PAG_WRITE);
     100          if (rc || !bat) {
     101            Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     102                      GetPString(IDS_OUTOFMEMORY));
     103            WinDismissDlg(hwnd, 0);
     104            break;
     105          }
     106          tlen =
     107            (LONG) WinSendMsg(hwndMLE, MLM_QUERYTEXTLENGTH, MPVOID, MPVOID);
     108          if (!tlen)
     109            Runtime_Error(pszSrcFile, __LINE__, "no data");
     110          else {
     111            WinSendMsg(hwndMLE, MLM_SETIMPORTEXPORT,
     112                       MPFROMP(bat), MPFROMLONG(mem));
     113            len = (LONG) WinSendMsg(hwndMLE, MLM_EXPORT,
     114                                    MPFROMP(&iptOffset), MPFROMP(&tlen));
     115            bat[len] = 0;
     116            lstrip(bat);
     117            while (strlen(bat) && bat[strlen(bat) - 1] == '\n' ||
     118                   bat[strlen(bat) - 1] == ' ') {
     119              // fixme to understand
     120              stripcr(bat);
     121              rstrip(bat);
     122              stripcr(bat);
     123              rstrip(bat);
     124            }
     125            if (!*bat)
     126              Runtime_Error(pszSrcFile, __LINE__, "no data");
     127            else {
     128              sprintf(s, "%s%sFMTMP%d.CMD", path,
     129                      (path[strlen(path) - 1] == '\\') ? "" : "\\",
     130                      batches++);
     131              fp = fopen(s, "w");
     132              if (!fp)
     133                Runtime_Error(pszSrcFile, __LINE__, "fopen");
     134              else {
     135                if (!strncmp(bat, "/*", 2)) {
     136                  rexx = "'";
     137                  fprintf(fp, "%s\n", GetPString(IDS_REXXCOMMENT));
     138                }
     139                fprintf(fp, "%s%c:%s\n", rexx, toupper(*path), rexx);
     140                fprintf(fp, "%sCD \"%s%s\"%s\n", rexx, path,
     141                        (strlen(path) < 3) ? "\\" : "", rexx);
     142                fprintf(fp, "%s", bat);
     143                fprintf(fp, "\n%sDEL \"%s\"%s\n", rexx, s, rexx);
     144                fclose(fp);
     145                runemf2(WINDOWED | SEPARATE,
     146                        hwnd,
     147                        path, NULL, "%s /C \"%s\"", GetCmdSpec(FALSE), s);
     148              }
     149            }
     150          }
     151        }
    55152      }
    56       if (!mp2) {
    57         Runtime_Error(pszSrcFile, __LINE__, "no data");
    58         WinDismissDlg(hwnd,0);
    59         break;
    60       }
    61       WinSetWindowPtr(hwnd,0,mp2);
    62       path = (CHAR *)mp2;
    63       {
    64         CHAR s[CCHMAXPATH + 81];
    65 
    66         sprintf(s,
    67                 GetPString(IDS_INSTANTTITLETEXT),
    68                 path);
    69         WinSetWindowText(hwnd,s);
    70       }
    71       WinSendMsg(hwndMLE,
    72                  MLM_SETTEXTLIMIT,
    73                  MPFROMLONG((LONG)(10240L)),
    74                  MPVOID);
    75       WinSendMsg(hwndMLE,
    76                  MLM_FORMAT,
    77                  MPFROM2SHORT(MLFIE_NOTRANS,0),
    78                  MPVOID);
    79       if(bat) {
    80 
    81         ULONG tlen = strlen(bat);
    82         IPT   iptOffset = 0L;
    83 
    84         WinSendMsg(hwndMLE,MLM_SETIMPORTEXPORT,
    85                    MPFROMP(bat),
    86                    MPFROMLONG(12287L));
    87         WinSendMsg(hwndMLE,MLM_IMPORT,MPFROMP(&iptOffset),MPFROMP(tlen));
    88         DosFreeMem(bat);
    89         bat = NULL;
    90       }
     153      WinDismissDlg(hwnd, 0);
    91154      break;
    92155
    93     case WM_COMMAND:
    94       switch(SHORT1FROMMP(mp1)) {
    95         case DID_OK:
    96           path = (CHAR *)WinQueryWindowPtr(hwnd,0);
    97           {
    98             CHAR  s[CCHMAXPATH + 1];
    99             FILE *fp;
    100             IPT   iptOffset = 0L;
    101             LONG  len,tlen,mem;
    102             CHAR *rexx = "";
     156    case DID_CANCEL:
     157      WinDismissDlg(hwnd, 0);
     158      break;
    103159
    104             mem = MLEgetlen(hwndMLE);
    105             if(mem) {
    106               rc = DosAllocMem((PVOID)&bat,mem,
    107                                 PAG_COMMIT | PAG_READ | PAG_WRITE);
    108               if(rc || !bat) {
    109                 Dos_Error(MB_CANCEL,rc,HWND_DESKTOP,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY));
    110                 WinDismissDlg(hwnd,0);
    111                 break;
    112               }
    113               tlen = (LONG)WinSendMsg(hwndMLE,MLM_QUERYTEXTLENGTH,MPVOID,MPVOID);
    114               if(!tlen)
    115                 Runtime_Error(pszSrcFile, __LINE__, "no data");
    116               else {
    117                 WinSendMsg(hwndMLE,MLM_SETIMPORTEXPORT,
    118                            MPFROMP(bat),
    119                            MPFROMLONG(mem));
    120                 len = (LONG)WinSendMsg(hwndMLE,MLM_EXPORT,
    121                                        MPFROMP(&iptOffset),
    122                                        MPFROMP(&tlen));
    123                 bat[len] = 0;
    124                 lstrip(bat);
    125                 while(strlen(bat) && bat[strlen(bat) - 1] == '\n' ||
    126                       bat[strlen(bat) - 1] == ' ') {
    127                   // fixme to understand
    128                   stripcr(bat);
    129                   rstrip(bat);
    130                   stripcr(bat);
    131                   rstrip(bat);
    132                 }
    133                 if(!*bat)
    134                   Runtime_Error(pszSrcFile, __LINE__, "no data");
    135                 else {
    136                   sprintf(s,"%s%sFMTMP%d.CMD",path,
    137                           (path[strlen(path) - 1] == '\\') ? "" : "\\",
    138                           batches++);
    139                   fp = fopen(s,"w");
    140                   if(!fp)
    141                     Runtime_Error(pszSrcFile, __LINE__, "fopen");
    142                   else {
    143                     if(!strncmp(bat,"/*",2)) {
    144                       rexx = "'";
    145                       fprintf(fp,
    146                               "%s\n",
    147                               GetPString(IDS_REXXCOMMENT));
    148                     }
    149                     fprintf(fp,"%s%c:%s\n",rexx,toupper(*path),rexx);
    150                     fprintf(fp,"%sCD \"%s%s\"%s\n",rexx,path,
    151                             (strlen(path) < 3) ? "\\" : "",rexx);
    152                     fprintf(fp,"%s",bat);
    153                     fprintf(fp,"\n%sDEL \"%s\"%s\n",rexx,s,rexx);
    154                     fclose(fp);
    155                     runemf2(WINDOWED | SEPARATE,
    156                             hwnd,
    157                             path,
    158                             NULL,
    159                             "%s /C \"%s\"",
    160                             GetCmdSpec(FALSE),
    161                             s);
    162                   }
    163                 }
    164               }
    165             }
    166           }
    167           WinDismissDlg(hwnd,0);
    168           break;
     160    case IDM_HELP:
     161      path = WinQueryWindowPtr(hwnd, 0);
     162      rc = saymsg(MB_YESNOCANCEL,
     163                  hwnd,
     164                  GetPString(IDS_INSTANTHELPTITLETEXT),
     165                  GetPString(IDS_INSTANTHELPTEXT),
     166                  path, (strlen(path) < 3) ? "\\" : "", path,
     167                  (path[strlen(path) - 1] == '\\') ? "" : "\\", batches);
     168      if (rc == MBID_YES)
     169        runemf2(WINDOWED | INVISIBLE | BACKGROUND,
     170                hwnd, NULL, NULL, "%s /C HELP BATCH", GetCmdSpec(FALSE));
     171      else if (rc == MBID_CANCEL)
     172        WinDismissDlg(hwnd, 0);
     173      break;
     174    }
     175    return 0;
    169176
    170         case DID_CANCEL:
    171           WinDismissDlg(hwnd,0);
    172           break;
    173 
    174         case IDM_HELP:
    175           path = WinQueryWindowPtr(hwnd,0);
    176           rc = saymsg(MB_YESNOCANCEL,
    177                         hwnd,
    178                         GetPString(IDS_INSTANTHELPTITLETEXT),
    179                         GetPString(IDS_INSTANTHELPTEXT),
    180                         path,(strlen(path) < 3) ? "\\" : "",path,
    181                         (path[strlen(path) - 1] == '\\') ? "" : "\\",
    182                         batches);
    183           if(rc ==  MBID_YES)
    184             runemf2(WINDOWED | INVISIBLE | BACKGROUND,
    185                     hwnd,
    186                     NULL,
    187                     NULL,
    188                     "%s /C HELP BATCH",
    189                     GetCmdSpec(FALSE));
    190           else if(rc == MBID_CANCEL)
    191             WinDismissDlg(hwnd,0);
    192           break;
    193       }
    194       return 0;
    195 
    196     case WM_CLOSE:
    197     case WM_DESTROY:
    198       myhwnd = (HWND)0;
    199       break;
     177  case WM_CLOSE:
     178  case WM_DESTROY:
     179    myhwnd = (HWND) 0;
     180    break;
    200181  }
    201   return WinDefDlgProc(hwnd,msg,mp1,mp2);
     182  return WinDefDlgProc(hwnd, msg, mp1, mp2);
    202183}
    203 
Note: See TracChangeset for help on using the changeset viewer.