Changeset 122 for trunk/dll


Ignore:
Timestamp:
Dec 5, 2004, 1:19:43 AM (21 years ago)
Author:
root
Message:

Localize functions
Rework fixup usage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/avv.c

    r107 r122  
    33
    44  $Id$
     5
     6  archiver.bb2 editor
    57
    68  Copyright (c) 1993-98 M. Kimes
     
    911  Archive containers
    1012
    11   Revisions     31 Jul 04 SHL - ArcReviewDlgProc: correct nameis... decodes
     13  Revisions     31 Jul 04 SHL ArcReviewDlgProc: correct nameis... decodes
     14                01 Aug 04 SHL Localize functions
     15                01 Aug 04 SHL Rework fixup usage
    1216
    1317***********************************************************************/
     
    2933
    3034#pragma data_seg(DATA1)
    31 #pragma alloc_text(AVV,EditArchiverData,assign,reassign_from_window)
     35#pragma alloc_text(AVV,EditArchiverData,xstrdup,xstrdup_from_window)
    3236#pragma alloc_text(AVV,get_int_from_window,get_int2_from_window)
    3337#pragma alloc_text(AVV,get_long_from_window,get_int3_from_window)
    3438#pragma alloc_text(AVV,get_int4_from_window)
    3539
    36 
    37 APIRET EditArchiverData (HWND hwnd,DIRCNRDATA *arc) {
    38 
     40static PSZ checkfile(PSZ file,INT *error);
     41static ULONG checkfile2(PSZ file,INT *error);
     42static PSZ checksayfile(HWND hwnd,PSZ file,INT *error);
     43static INT check_archiver (HWND hwnd,ARC_TYPE *info);
     44static INT get_int_from_window (HWND hwnd,USHORT id);
     45static LONG get_long_from_window (HWND hwnd,USHORT id);
     46static PSZ nonull(PSZ a);
     47static PSZ xstrdup(PSZ pszDest,PSZ pszSrc);
     48static PSZ xstrdup_from_window(HWND hwnd,USHORT id,PSZ pszDest);
     49
     50APIRET EditArchiverData(HWND hwnd,DIRCNRDATA *arc)
     51{
    3952  ARCDUMP ad;
    4053  FILE   *fp;
     
    101114
    102115
    103 CHAR * assign (CHAR *a,CHAR *b) {
    104 
     116static PSZ xstrdup(PSZ a,PSZ b)
     117{
    105118  if(a)
    106119    free(a);
     
    114127
    115128
    116 CHAR * reassign_from_window (HWND hwnd,USHORT id,char *a) {
    117 
    118   char s[257] = "";
     129static PSZ xstrdup_from_window(HWND hwnd,USHORT id,PSZ pszDest)
     130{
     131  char sz[257] = "";
    119132
    120133  WinQueryDlgItemText(hwnd,
    121134                      id,
    122135                      255,
    123                       s);
    124   a = assign(a,s);
    125   return a;
    126 }
    127 
    128 
    129 INT get_int_from_window (HWND hwnd,USHORT id) {
    130 
     136                      sz);
     137  pszDest = xstrdup(pszDest,sz);
     138  return pszDest;
     139}
     140
     141
     142static INT get_int_from_window(HWND hwnd,USHORT id)
     143{
    131144  char s[257] = "";
    132145
     
    136149
    137150
    138 INT get_int2_from_window (HWND hwnd,USHORT id) {
    139 
     151static INT get_int2_from_window(HWND hwnd,USHORT id)
     152{
    140153  char s[257] = "",*p;
    141154
     
    148161
    149162
    150 INT get_int3_from_window (HWND hwnd,USHORT id) {
    151 
     163INT get_int3_from_window (HWND hwnd,USHORT id)
     164{
    152165  char s[257] = "",*p;
    153166
     
    164177
    165178
    166 INT get_int4_from_window (HWND hwnd,USHORT id) {
    167 
     179INT get_int4_from_window (HWND hwnd,USHORT id)
     180{
    168181  char s[257] = "",*p;
    169182
     
    184197
    185198
    186 LONG get_long_from_window (HWND hwnd,USHORT id) {
    187 
     199LONG get_long_from_window (HWND hwnd,USHORT id)
     200{
    188201  char s[257] = "";
    189202
     
    195208#pragma alloc_text (AVV2,nonull,rewrite_archiverbb2,checkfile,checkfile2)
    196209
    197 CHAR * nonull (CHAR *a) {
    198 
    199   if(!a)
    200     return NullStr;
    201   return a;
    202 }
    203 
    204 
    205 VOID rewrite_archiverbb2 (CHAR *archiverbb2) {
    206 
     210// nonull - convert NULL pointer to empty string
     211
     212static PSZ nonull(PSZ psz)
     213{
     214  if(!psz)
     215    psz = NullStr;
     216  return psz;
     217}
     218
     219
     220VOID rewrite_archiverbb2 (PSZ archiverbb2)
     221{
    207222  FILE        *fp;
    208223  INT         counter = 0;
     
    274289              fixup(info->signature,
    275290                    s,
    276                     255,
     291                    sizeof(s),
    277292                    strlen(info->signature)),
    278293              nonull(info->startlist),
     
    295310
    296311
    297 CHAR * checkfile (CHAR *file,INT *error) {
    298 
     312static PSZ  checkfile(PSZ file,INT *error)
     313{
    299314  CHAR  *p,*pp = NULL;
    300315  INT   ret;
     
    335350
    336351
    337 ULONG checkfile2 (CHAR *file,INT *error) {
    338 
     352static ULONG checkfile2 (PSZ file,INT *error)
     353{
    339354  CHAR  *p,*pp = NULL;
    340355  INT   ret;
     
    376391#pragma alloc_text (AVV3,checksayfile,check_archiver,ArcReviewDlgProc)
    377392
    378 CHAR *checksayfile (HWND hwnd,CHAR *file,INT *error) {
    379 
    380   CHAR *p,*pp = NULL;
     393static PSZ checksayfile (HWND hwnd,PSZ file,INT *error)
     394{
     395  PSZ p;
     396  PSZ pp = NULL;
    381397
    382398  p = checkfile(file,error);
     
    421437
    422438
    423 INT check_archiver (HWND hwnd,ARC_TYPE *info) {
    424 
     439static INT check_archiver(HWND hwnd,ARC_TYPE *info)
     440{
    425441  BOOL fStart = FALSE,fEnd = FALSE,fNpos = FALSE;
    426442  INT  List = 0,Create = 0,Extract = 0;
    427   static CHAR *aerrors[3];
     443  static PSZ aerrors[3];
    428444
    429445  aerrors[0] = GetPString(IDS_STARTLISTEMPTYTEXT);
     
    481497
    482498
    483 MRESULT EXPENTRY ArcReviewDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    484 
    485   ARCDUMP        *admp;
    486   static CHAR    s[258];
    487   SHORT          sSelect;
     499MRESULT EXPENTRY ArcReviewDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     500{
     501  ARCDUMP       *admp;
     502  CHAR          s[256];
     503  SHORT         sSelect;
    488504
    489505  if(msg != WM_INITDLG)
     
    497513        return 0;
    498514      }
     515
    499516      WinSetWindowPtr(hwnd,0,mp2);
     517
     518      WinSendDlgItemMsg(hwnd,
     519                        AD_LISTBOX,
     520                        LM_DELETEALL,
     521                        MPVOID,
     522                        MPVOID);
     523      for(sSelect = AD_ID;sSelect < AD_ADDWPATHS + 1;sSelect++)
    500524      {
    501         WinSendDlgItemMsg(hwnd,
    502                           AD_LISTBOX,
    503                           LM_DELETEALL,
    504                           MPVOID,
     525        WinSendDlgItemMsg(hwnd,
     526                          sSelect,
     527                          EM_SETTEXTLIMIT,
     528                          MPFROM2SHORT(sizeof(s) - 1,0),
    505529                          MPVOID);
    506         for(sSelect = AD_ID;sSelect < AD_ADDWPATHS + 1;sSelect++)
    507           WinSendDlgItemMsg(hwnd,
    508                             sSelect,
    509                             EM_SETTEXTLIMIT,
    510                             MPFROM2SHORT(255,0),
    511                             MPVOID);
    512         if(admp->info->id)
    513           WinSetDlgItemText(hwnd,
    514                             AD_ID,
    515                             admp->info->id);
    516         if(admp->info->ext)
    517           WinSetDlgItemText(hwnd,
    518                             AD_EXT,
    519                             admp->info->ext);
    520         sprintf(s,
    521                 "%ld",
    522                 admp->info->file_offset);
     530      }
     531      if (admp->info->id) {
    523532        WinSetDlgItemText(hwnd,
    524                           AD_SIGPOS,
    525                           s);
    526         if(admp->info->signature)
    527           WinSetDlgItemText(hwnd,
    528                             AD_SIG,
    529                             fixup(admp->info->signature,
    530                                   s,
    531                                   255,
    532                                   strlen(admp->info->signature)));
    533         if(admp->info->startlist)
    534           WinSetDlgItemText(hwnd,
    535                             AD_STARTLIST,
    536                             admp->info->startlist);
    537         if(admp->info->endlist)
    538           WinSetDlgItemText(hwnd,
    539                             AD_ENDLIST,
    540                             admp->info->endlist);
    541         if(admp->info->list)
    542           WinSetDlgItemText(hwnd,
    543                             AD_LIST,
    544                             admp->info->list);
    545         sprintf(s,
    546                 "%d,%d,%d,%d",
    547                 admp->info->fnpos,
    548                 admp->info->nameislast,
    549                 admp->info->nameisnext,
    550                 admp->info->nameisfirst);
    551         WinSetDlgItemText(hwnd,AD_FNAMEPOS,s);
    552         sprintf(s,"%d",admp->info->osizepos);
    553         WinSetDlgItemText(hwnd,AD_OLDSZ,s);
    554         sprintf(s,"%d",admp->info->nsizepos);
    555         WinSetDlgItemText(hwnd,AD_NEWSZ,s);
    556         sprintf(s,"%d,%d",admp->info->fdpos,admp->info->datetype);
    557         WinSetDlgItemText(hwnd,AD_DATEPOS,s);
    558         sprintf(s,"%d",admp->info->fdflds);
    559         WinSetDlgItemText(hwnd,AD_NUMDATEFLDS,s);
    560         if(admp->info->extract)
    561           WinSetDlgItemText(hwnd,AD_EXTRACT,admp->info->extract);
    562         if(admp->info->exwdirs)
    563           WinSetDlgItemText(hwnd,AD_WDIRS,admp->info->exwdirs);
    564         if(admp->info->test)
    565           WinSetDlgItemText(hwnd,AD_TEST,admp->info->test);
    566         if(admp->info->create)
    567           WinSetDlgItemText(hwnd,AD_ADD,admp->info->create);
    568         if(admp->info->move)
    569           WinSetDlgItemText(hwnd,AD_MOVE,admp->info->move);
    570         if(admp->info->delete)
    571           WinSetDlgItemText(hwnd,AD_DELETE,admp->info->delete);
    572         if(admp->info->createrecurse)
    573           WinSetDlgItemText(hwnd,AD_ADDRECURSE,admp->info->createrecurse);
    574         if(admp->info->createwdirs)
    575           WinSetDlgItemText(hwnd,AD_ADDWPATHS,admp->info->createwdirs);
    576         if(admp->info->movewdirs)
    577           WinSetDlgItemText(hwnd,AD_MOVEWPATHS,admp->info->movewdirs);
    578       }
     533                          AD_ID,
     534                          admp->info->id);
     535      }
     536      if (admp->info->ext) {
     537        WinSetDlgItemText(hwnd,
     538                          AD_EXT,
     539                          admp->info->ext);
     540      }
     541      sprintf(s,
     542              "%ld",
     543              admp->info->file_offset);
     544      WinSetDlgItemText(hwnd,
     545                        AD_SIGPOS,
     546                        s);
     547      if (admp->info->signature) {
     548        WinSetDlgItemText(hwnd,
     549                          AD_SIG,
     550                          fixup(admp->info->signature,
     551                                s,
     552                                sizeof(s),
     553                                strlen(admp->info->signature)));
     554      }
     555      if (admp->info->startlist) {
     556        WinSetDlgItemText(hwnd,
     557                          AD_STARTLIST,
     558                          admp->info->startlist);
     559      }
     560      if (admp->info->endlist) {
     561        WinSetDlgItemText(hwnd,
     562                          AD_ENDLIST,
     563                          admp->info->endlist);
     564      }
     565      if (admp->info->list) {
     566        WinSetDlgItemText(hwnd,
     567                          AD_LIST,
     568                          admp->info->list);
     569      }
     570      sprintf(s,
     571              "%d,%d,%d,%d",
     572              admp->info->fnpos,
     573              admp->info->nameislast,
     574              admp->info->nameisnext,
     575              admp->info->nameisfirst);
     576      WinSetDlgItemText(hwnd,AD_FNAMEPOS,s);
     577      sprintf(s,"%d",admp->info->osizepos);
     578      WinSetDlgItemText(hwnd,AD_OLDSZ,s);
     579      sprintf(s,"%d",admp->info->nsizepos);
     580      WinSetDlgItemText(hwnd,AD_NEWSZ,s);
     581      sprintf(s,"%d,%d",admp->info->fdpos,admp->info->datetype);
     582      WinSetDlgItemText(hwnd,AD_DATEPOS,s);
     583      sprintf(s,"%d",admp->info->fdflds);
     584      WinSetDlgItemText(hwnd,AD_NUMDATEFLDS,s);
     585      if(admp->info->extract)
     586        WinSetDlgItemText(hwnd,AD_EXTRACT,admp->info->extract);
     587      if(admp->info->exwdirs)
     588        WinSetDlgItemText(hwnd,AD_WDIRS,admp->info->exwdirs);
     589      if(admp->info->test)
     590        WinSetDlgItemText(hwnd,AD_TEST,admp->info->test);
     591      if(admp->info->create)
     592        WinSetDlgItemText(hwnd,AD_ADD,admp->info->create);
     593      if(admp->info->move)
     594        WinSetDlgItemText(hwnd,AD_MOVE,admp->info->move);
     595      if(admp->info->delete)
     596        WinSetDlgItemText(hwnd,AD_DELETE,admp->info->delete);
     597      if(admp->info->createrecurse)
     598        WinSetDlgItemText(hwnd,AD_ADDRECURSE,admp->info->createrecurse);
     599      if(admp->info->createwdirs)
     600        WinSetDlgItemText(hwnd,AD_ADDWPATHS,admp->info->createwdirs);
     601      if(admp->info->movewdirs)
     602        WinSetDlgItemText(hwnd,AD_MOVEWPATHS,admp->info->movewdirs);
     603
    579604      PostMsg(hwnd,
    580605              UM_SETUP,
    581606              MPVOID,
    582607              MPVOID);
    583       break;
     608      break;                            // WM_INITDLG
    584609
    585610
     
    599624        else {
    600625          while(!feof(fp)) {
    601             if(!fgets(s,256,fp)) break;
     626            if(!fgets(s,sizeof(s),fp)) break;
    602627            stripcr(s);
    603628            WinSendDlgItemMsg(hwnd,
     
    654679                if(*s) {
    655680
    656                   char *p,*pp;
     681                  PSZ p;
     682                  PSZ pp;
    657683
    658684                  p = s;
     
    890916            else {
    891917
    892               CHAR *p;
    893 
    894               p = lstrip(tempargs);
     918              PSZ p;
     919
     920              lstrip(tempargs);
    895921              p = strchr(tempargs,' ');
    896922              if(p)
     
    921947
    922948        case DID_OK:
    923           admp->info->startlist = reassign_from_window(hwnd,AD_STARTLIST,admp->info->startlist);
    924           admp->info->endlist = reassign_from_window(hwnd,AD_ENDLIST,admp->info->endlist);
    925           admp->info->id = reassign_from_window(hwnd,AD_ID,admp->info->id);
    926           admp->info->create = reassign_from_window(hwnd,AD_ADD,admp->info->create);
    927           admp->info->createwdirs = reassign_from_window(hwnd,AD_ADDWPATHS,admp->info->createwdirs);
    928           admp->info->createrecurse = reassign_from_window(hwnd,AD_ADDRECURSE,admp->info->createrecurse);
    929           admp->info->movewdirs = reassign_from_window(hwnd,AD_MOVEWPATHS,admp->info->movewdirs);
    930           admp->info->move = reassign_from_window(hwnd,AD_MOVE,admp->info->move);
    931           admp->info->delete = reassign_from_window(hwnd,AD_DELETE,admp->info->delete);
    932           admp->info->test = reassign_from_window(hwnd,AD_TEST,admp->info->test);
    933           admp->info->extract = reassign_from_window(hwnd,AD_EXTRACT,admp->info->extract);
    934           admp->info->exwdirs = reassign_from_window(hwnd,AD_WDIRS,admp->info->exwdirs);
    935           admp->info->ext = reassign_from_window(hwnd,AD_EXT,admp->info->ext);
    936           literal(reassign_from_window(hwnd,
     949          admp->info->startlist = xstrdup_from_window(hwnd,AD_STARTLIST,admp->info->startlist);
     950          admp->info->endlist = xstrdup_from_window(hwnd,AD_ENDLIST,admp->info->endlist);
     951          admp->info->id = xstrdup_from_window(hwnd,AD_ID,admp->info->id);
     952          admp->info->create = xstrdup_from_window(hwnd,AD_ADD,admp->info->create);
     953          admp->info->createwdirs = xstrdup_from_window(hwnd,AD_ADDWPATHS,admp->info->createwdirs);
     954          admp->info->createrecurse = xstrdup_from_window(hwnd,AD_ADDRECURSE,admp->info->createrecurse);
     955          admp->info->movewdirs = xstrdup_from_window(hwnd,AD_MOVEWPATHS,admp->info->movewdirs);
     956          admp->info->move = xstrdup_from_window(hwnd,AD_MOVE,admp->info->move);
     957          admp->info->delete = xstrdup_from_window(hwnd,AD_DELETE,admp->info->delete);
     958          admp->info->test = xstrdup_from_window(hwnd,AD_TEST,admp->info->test);
     959          admp->info->extract = xstrdup_from_window(hwnd,AD_EXTRACT,admp->info->extract);
     960          admp->info->exwdirs = xstrdup_from_window(hwnd,AD_WDIRS,admp->info->exwdirs);
     961          admp->info->ext = xstrdup_from_window(hwnd,AD_EXT,admp->info->ext);
     962          literal(xstrdup_from_window(hwnd,
    937963                                       AD_SIG,
    938964                                       admp->info->signature));
    939           admp->info->list = reassign_from_window(hwnd,
     965          admp->info->list = xstrdup_from_window(hwnd,
    940966                                                  AD_LIST,
    941967                                                  admp->info->list);
     
    963989               MBID_YES) {
    964990
    965               CHAR *ab2;
     991              PSZ ab2;
    966992
    967993              ab2 = searchpath(GetPString(IDS_ARCHIVERBB2));
Note: See TracChangeset for help on using the changeset viewer.