Changeset 247
- Timestamp:
- Aug 14, 2005, 1:03:52 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/dll/avl.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/avl.c
r123 r247 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2004 Steven H.Levine 10 11 Revisions 01 Aug 04 SHL Rework lstrip/rstrip usage 9 Copyright (c) 2004, 2005 Steven H.Levine 10 11 01 Aug 04 SHL Rework lstrip/rstrip usage 12 13 Aug 05 SHL Beautify with indent 12 13 13 14 ***********************************************************************/ … … 30 31 #pragma alloc_text(MISC9,quick_find_type,find_type) 31 32 32 33 ARC_TYPE * quick_find_type (CHAR *filespec,ARC_TYPE *topsig) { 34 35 ARC_TYPE *info,*found = NULL; 36 CHAR *p; 37 38 if(!loadedarcs) 39 load_archivers(); 40 p = strrchr(filespec,'.'); 41 if(p) { 42 p++; 43 info = (topsig) ? topsig : arcsighead; 44 while(info) { 45 if(info->ext && 46 *(info->ext) && 47 !stricmp(p,info->ext)) { 48 found = find_type(filespec,topsig); 49 break; 50 } 51 info = info->next; 33 ARC_TYPE *quick_find_type(CHAR * filespec, ARC_TYPE * topsig) 34 { 35 ARC_TYPE *info, *found = NULL; 36 CHAR *p; 37 38 if (!loadedarcs) 39 load_archivers(); 40 p = strrchr(filespec, '.'); 41 if (p) 42 { 43 p++; 44 info = (topsig) ? topsig : arcsighead; 45 while (info) 46 { 47 if (info -> ext && 48 *(info -> ext) && 49 !stricmp(p, info -> ext)) 50 { 51 found = find_type(filespec, topsig); 52 break; 53 } 54 info = info -> next; 55 } 52 56 } 53 } 54 return found; 57 return found; 55 58 } 56 59 57 58 ARC_TYPE * find_type (CHAR *filespec,ARC_TYPE *topsig) { 59 60 HFILE handle; 61 ULONG action,len,l; 62 ARC_TYPE *info; 63 CHAR *p,buffer[80]; /* Read buffer for the signatures. */ 64 65 if(!loadedarcs) 66 load_archivers(); 67 if(topsig == NULL) 68 topsig = arcsighead; 69 DosError(FERR_DISABLEHARDERR); 70 if(DosOpen(filespec, 71 &handle, 72 &action, 73 0L, 74 0L, 75 OPEN_ACTION_FAIL_IF_NEW | 76 OPEN_ACTION_OPEN_IF_EXISTS, 77 OPEN_FLAGS_FAIL_ON_ERROR | 78 OPEN_FLAGS_NOINHERIT | 79 OPEN_FLAGS_RANDOMSEQUENTIAL | 80 OPEN_SHARE_DENYNONE | 81 OPEN_ACCESS_READONLY, 82 0L)) 83 return NULL; 84 info = topsig; /* start of signatures */ 85 while(info) { 86 if(!info->signature || 87 !*info->signature) { /* no signature -- work on extension only */ 88 p = strrchr(filespec,'.'); 89 if(p) { 90 p++; 91 if(info->ext && 92 *(info->ext) && 93 !stricmp(p,info->ext)) 94 break; 95 } 60 ARC_TYPE *find_type(CHAR * filespec, ARC_TYPE * topsig) 61 { 62 HFILE handle; 63 ULONG action, len, l; 64 ARC_TYPE *info; 65 CHAR *p, buffer[80]; /* Read buffer for the signatures. */ 66 67 if (!loadedarcs) 68 load_archivers(); 69 if (topsig == NULL) 70 topsig = arcsighead; 71 DosError(FERR_DISABLEHARDERR); 72 if (DosOpen(filespec, 73 &handle, 74 &action, 75 0L, 76 0L, 77 OPEN_ACTION_FAIL_IF_NEW | 78 OPEN_ACTION_OPEN_IF_EXISTS, 79 OPEN_FLAGS_FAIL_ON_ERROR | 80 OPEN_FLAGS_NOINHERIT | 81 OPEN_FLAGS_RANDOMSEQUENTIAL | 82 OPEN_SHARE_DENYNONE | 83 OPEN_ACCESS_READONLY, 84 0L)) 85 return NULL; 86 info = topsig; /* start of signatures */ 87 while (info) 88 { 89 if (!info -> signature || 90 !*info -> signature) 91 { /* no signature -- work on extension only */ 92 p = strrchr(filespec, '.'); 93 if (p) 94 { 95 p++; 96 if (info -> ext && 97 *(info -> ext) && 98 !stricmp(p, info -> ext)) 99 break; 100 } 101 } 102 l = strlen(info -> signature); /* Get the signature length. */ 103 l = min(l, 79); 104 if (!DosChgFilePtr(handle, 105 abs(info -> file_offset), 106 (info -> file_offset >= 0L) ? 107 FILE_BEGIN : 108 FILE_END, 109 &len)) 110 { 111 if (!DosRead(handle, 112 buffer, 113 l, 114 &len) && 115 len == l) 116 { 117 if (!memcmp(info -> signature, 118 buffer, 119 l)) 120 break; 121 } 122 } 123 info = info -> next; 96 124 } 97 l = strlen(info->signature); /* Get the signature length. */ 98 l = min(l,79); 99 if(!DosChgFilePtr(handle, 100 abs(info->file_offset), 101 (info->file_offset >= 0L) ? 102 FILE_BEGIN : 103 FILE_END, 104 &len)) { 105 if(!DosRead(handle, 106 buffer, 107 l, 108 &len) && 109 len == l) { 110 if(!memcmp(info->signature, 111 buffer, 112 l)) 113 break; 114 } 125 DosClose(handle); /* Either way, we're done for now */ 126 return info; /* return signature, if any */ 127 } 128 129 #pragma alloc_text(AVL,load_archivers) 130 131 INT load_archivers(VOID) 132 { 133 FILE *handle; 134 CHAR s[257], *p; 135 ARC_TYPE *info = NULL, *last = NULL; 136 INT numlines = NUMLINES, x; 137 138 loadedarcs = TRUE; 139 DosEnterCritSec(); 140 p = searchpath(GetPString(IDS_ARCHIVERBB2)); 141 if (!p || !*p) 142 { 143 DosExitCritSec(); 144 return -1; 115 145 } 116 info = info->next; 117 } 118 DosClose(handle); /* Either way, we're done for now */ 119 return info; /* return signature, if any */ 146 handle = _fsopen(p, "r", SH_DENYWR); 147 DosExitCritSec(); 148 if (!handle) 149 return -2; 150 strcpy(archiverbb2, p); 151 if (!fgets(s, 256, handle)) 152 { 153 fclose(handle); 154 return -3; 155 } 156 p = strchr(s, ';'); 157 if (p) 158 *p = 0; 159 bstripcr(s); 160 if (*s) 161 numlines = atoi(s); 162 if (!*s || numlines < NUMLINES) 163 return -3; 164 while (!feof(handle)) 165 { 166 if (!fgets(s, 256, handle)) 167 break; 168 p = strchr(s, ';'); 169 if (p) 170 *p = 0; // Chop comment 171 172 bstripcr(s); 173 if (*s) 174 { 175 info = malloc(sizeof(ARC_TYPE)); 176 if (!info) 177 break; 178 memset(info, 0, sizeof(ARC_TYPE)); 179 if (*s) 180 info -> id = strdup(s); 181 else 182 info -> id = NULL; 183 if (!fgets(s, 256, handle)) 184 break; 185 p = strchr(s, ';'); 186 if (p) 187 *p = 0; 188 bstripcr(s); 189 if (*s) 190 info -> ext = strdup(s); 191 else 192 info -> ext = NULL; 193 if (!fgets(s, 256, handle)) 194 break; 195 p = strchr(s, ';'); 196 if (p) 197 *p = 0; 198 info -> file_offset = atol(s); 199 if (!fgets(s, 256, handle)) 200 break; 201 p = strchr(s, ';'); 202 if (p) 203 *p = 0; 204 bstripcr(s); 205 if (*s) 206 info -> list = strdup(s); 207 else 208 info -> list = NULL; 209 if (!info -> list) 210 break; 211 if (!fgets(s, 256, handle)) 212 break; 213 p = strchr(s, ';'); 214 if (p) 215 *p = 0; 216 bstripcr(s); 217 if (*s) 218 info -> extract = strdup(s); 219 else 220 info -> extract = NULL; 221 if (!fgets(s, 256, handle)) 222 break; 223 p = strchr(s, ';'); 224 if (p) 225 *p = 0; 226 bstripcr(s); 227 if (*s) 228 info -> exwdirs = strdup(s); 229 else 230 info -> exwdirs = NULL; 231 if (!fgets(s, 256, handle)) 232 break; 233 p = strchr(s, ';'); 234 if (p) 235 *p = 0; 236 bstripcr(s); 237 if (*s) 238 info -> test = strdup(s); 239 else 240 info -> test = NULL; 241 if (!fgets(s, 256, handle)) 242 break; 243 p = strchr(s, ';'); 244 if (p) 245 *p = 0; 246 bstripcr(s); 247 if (*s) 248 info -> create = strdup(s); 249 else 250 info -> create = NULL; 251 if (!fgets(s, 256, handle)) 252 break; 253 p = strchr(s, ';'); 254 if (p) 255 *p = 0; // Chop comment 256 257 bstripcr(s); 258 if (*s) 259 info -> createwdirs = strdup(s); 260 else 261 info -> createwdirs = NULL; 262 if (!fgets(s, 256, handle)) 263 break; 264 p = strchr(s, ';'); 265 if (p) 266 *p = 0; 267 bstripcr(s); 268 if (*s) 269 info -> createrecurse = strdup(s); 270 else 271 info -> createrecurse = NULL; 272 if (!fgets(s, 256, handle)) 273 break; 274 p = strchr(s, ';'); 275 if (p) 276 *p = 0; 277 bstripcr(s); 278 if (*s) 279 info -> move = strdup(s); 280 else 281 info -> move = NULL; 282 if (!fgets(s, 256, handle)) 283 break; 284 p = strchr(s, ';'); 285 if (p) 286 *p = 0; 287 bstripcr(s); 288 if (*s) 289 info -> movewdirs = strdup(s); 290 else 291 info -> movewdirs = NULL; 292 if (!fgets(s, 256, handle)) 293 break; 294 p = strchr(s, ';'); 295 if (p) 296 *p = 0; 297 bstripcr(s); 298 info -> delete = strdup(s); 299 if (!fgets(s, 256, handle)) 300 break; 301 stripcr(s); 302 literal(s); 303 if (*s) 304 { 305 info -> signature = strdup(s); 306 if (!info -> signature) 307 break; 308 } 309 else 310 info -> signature = NULL; 311 if (!fgets(s, 256, handle)) 312 break; 313 stripcr(s); 314 info -> startlist = strdup(s); 315 if (!fgets(s, 256, handle)) 316 break; 317 stripcr(s); 318 if (*s) 319 info -> endlist = strdup(s); 320 else 321 info -> endlist = NULL; 322 if (!fgets(s, 256, handle)) 323 break; 324 p = strchr(s, ';'); 325 if (p) 326 *p = 0; 327 info -> osizepos = atoi(s); 328 if (!fgets(s, 256, handle)) 329 break; 330 p = strchr(s, ';'); 331 if (p) 332 *p = 0; 333 info -> nsizepos = atoi(s); 334 if (!fgets(s, 256, handle)) 335 break; 336 p = strchr(s, ';'); 337 if (p) 338 *p = 0; 339 info -> fdpos = atoi(s); 340 p = strchr(s, ','); 341 if (p) 342 { 343 p++; 344 info -> datetype = atoi(p); 345 } 346 if (!fgets(s, 256, handle)) 347 break; 348 p = strchr(s, ';'); 349 if (p) 350 *p = 0; 351 info -> fdflds = atoi(s); 352 if (!fgets(s, 256, handle)) 353 break; 354 p = strchr(s, ';'); 355 if (p) 356 *p = 0; 357 info -> fnpos = atoi(s); 358 p = strchr(s, ','); 359 if (p) 360 { 361 p++; 362 info -> nameislast = (BOOL) (*p && atol(p) == 0) ? FALSE : TRUE; 363 p = strchr(p, ','); 364 if (p) 365 { 366 p++; 367 info -> nameisnext = (BOOL) (*p && atol(p) == 0) ? FALSE : TRUE; 368 p = strchr(p, ','); 369 if (p) 370 { 371 p++; 372 info -> nameisfirst = (BOOL) (*p && atol(p) == 0) ? FALSE : TRUE; 373 } 374 } 375 } 376 for (x = NUMLINES; x < numlines; x++) 377 { 378 if (!fgets(s, 256, handle)) 379 break; 380 } 381 info -> next = NULL; 382 if (!arcsighead) 383 { 384 arcsighead = last = info; 385 info -> prev = NULL; 386 } 387 else 388 { 389 last -> next = info; 390 info -> prev = last; 391 last = info; 392 } 393 if (info -> extract && 394 !*info -> extract) 395 { 396 free(info -> extract); 397 info -> extract = NULL; 398 } 399 } 400 info = NULL; 401 } 402 fclose(handle); 403 if (info) 404 { 405 if (info -> id) 406 free(info -> id); 407 if (info -> ext) 408 free(info -> ext); 409 if (info -> list) 410 free(info -> list); 411 if (info -> extract) 412 free(info -> extract); 413 if (info -> create) 414 free(info -> create); 415 if (info -> move) 416 free(info -> move); 417 if (info -> delete) 418 free(info -> delete); 419 if (info -> signature) 420 free(info -> signature); 421 if (info -> startlist) 422 free(info -> startlist); 423 if (info -> endlist) 424 free(info -> endlist); 425 if (info -> exwdirs) 426 free(info -> exwdirs); 427 if (info -> test) 428 free(info -> test); 429 if (info -> createrecurse) 430 free(info -> createrecurse); 431 if (info -> createwdirs) 432 free(info -> createwdirs); 433 if (info -> movewdirs) 434 free(info -> movewdirs); 435 } 436 if (!arcsighead) 437 return -4; 438 return 0; 120 439 } 121 440 122 #pragma alloc_text(AVL,load_archivers) 123 124 INT load_archivers (VOID) { 125 126 FILE *handle; 127 CHAR s[257],*p; 128 ARC_TYPE *info = NULL,*last = NULL; 129 INT numlines = NUMLINES,x; 130 131 loadedarcs = TRUE; 132 DosEnterCritSec(); 133 p = searchpath(GetPString(IDS_ARCHIVERBB2)); 134 if(!p || !*p) { 135 DosExitCritSec(); 136 return -1; 137 } 138 handle = _fsopen(p,"r",SH_DENYWR); 139 DosExitCritSec(); 140 if(!handle) 141 return -2; 142 strcpy(archiverbb2,p); 143 if(!fgets(s,256,handle)) { 144 fclose(handle); 145 return -3; 146 } 147 p = strchr(s,';'); 148 if(p) 149 *p = 0; 150 bstripcr(s); 151 if(*s) 152 numlines = atoi(s); 153 if(!*s || numlines < NUMLINES) 154 return -3; 155 while(!feof(handle)) { 156 if(!fgets(s,256,handle)) 157 break; 158 p = strchr(s,';'); 159 if(p) 160 *p = 0; // Chop comment 161 bstripcr(s); 162 if(*s) { 163 info = malloc(sizeof(ARC_TYPE)); 164 if(!info) 165 break; 166 memset(info,0,sizeof(ARC_TYPE)); 167 if(*s) 168 info->id = strdup(s); 169 else 170 info->id = NULL; 171 if(!fgets(s,256,handle)) 172 break; 173 p = strchr(s,';'); 174 if(p) 175 *p = 0; 176 bstripcr(s); 177 if(*s) 178 info->ext = strdup(s); 179 else 180 info->ext = NULL; 181 if(!fgets(s,256,handle)) 182 break; 183 p = strchr(s,';'); 184 if(p) 185 *p = 0; 186 info->file_offset = atol(s); 187 if(!fgets(s,256,handle)) 188 break; 189 p = strchr(s,';'); 190 if(p) 191 *p = 0; 192 bstripcr(s); 193 if(*s) 194 info->list = strdup(s); 195 else 196 info->list = NULL; 197 if(!info->list) 198 break; 199 if(!fgets(s,256,handle)) 200 break; 201 p = strchr(s,';'); 202 if(p) 203 *p = 0; 204 bstripcr(s); 205 if(*s) 206 info->extract = strdup(s); 207 else 208 info->extract = NULL; 209 if(!fgets(s,256,handle)) 210 break; 211 p = strchr(s,';'); 212 if(p) 213 *p = 0; 214 bstripcr(s); 215 if(*s) 216 info->exwdirs = strdup(s); 217 else 218 info->exwdirs = NULL; 219 if(!fgets(s,256,handle)) 220 break; 221 p = strchr(s,';'); 222 if(p) 223 *p = 0; 224 bstripcr(s); 225 if(*s) 226 info->test = strdup(s); 227 else 228 info->test = NULL; 229 if(!fgets(s,256,handle)) 230 break; 231 p = strchr(s,';'); 232 if(p) 233 *p = 0; 234 bstripcr(s); 235 if(*s) 236 info->create = strdup(s); 237 else 238 info->create = NULL; 239 if(!fgets(s,256,handle)) 240 break; 241 p = strchr(s,';'); 242 if(p) 243 *p = 0; // Chop comment 244 bstripcr(s); 245 if(*s) 246 info->createwdirs = strdup(s); 247 else 248 info->createwdirs = NULL; 249 if(!fgets(s,256,handle)) 250 break; 251 p = strchr(s,';'); 252 if(p) 253 *p = 0; 254 bstripcr(s); 255 if(*s) 256 info->createrecurse = strdup(s); 257 else 258 info->createrecurse = NULL; 259 if(!fgets(s,256,handle)) 260 break; 261 p = strchr(s,';'); 262 if(p) 263 *p = 0; 264 bstripcr(s); 265 if(*s) 266 info->move = strdup(s); 267 else 268 info->move = NULL; 269 if(!fgets(s,256,handle)) 270 break; 271 p = strchr(s,';'); 272 if(p) 273 *p = 0; 274 bstripcr(s); 275 if(*s) 276 info->movewdirs = strdup(s); 277 else 278 info->movewdirs = NULL; 279 if(!fgets(s,256,handle)) 280 break; 281 p = strchr(s,';'); 282 if(p) 283 *p = 0; 284 bstripcr(s); 285 info->delete = strdup(s); 286 if(!fgets(s,256,handle)) 287 break; 288 stripcr(s); 289 literal(s); 290 if(*s) { 291 info->signature = strdup(s); 292 if(!info->signature) 293 break; 294 } 295 else 296 info->signature = NULL; 297 if(!fgets(s,256,handle)) 298 break; 299 stripcr(s); 300 info->startlist = strdup(s); 301 if(!fgets(s,256,handle)) 302 break; 303 stripcr(s); 304 if(*s) 305 info->endlist = strdup(s); 306 else 307 info->endlist = NULL; 308 if(!fgets(s,256,handle)) 309 break; 310 p = strchr(s,';'); 311 if(p) 312 *p = 0; 313 info->osizepos = atoi(s); 314 if(!fgets(s,256,handle)) 315 break; 316 p = strchr(s,';'); 317 if(p) 318 *p = 0; 319 info->nsizepos = atoi(s); 320 if(!fgets(s,256,handle)) 321 break; 322 p = strchr(s,';'); 323 if(p) 324 *p = 0; 325 info->fdpos = atoi(s); 326 p = strchr(s,','); 327 if(p) { 328 p++; 329 info->datetype = atoi(p); 330 } 331 if(!fgets(s,256,handle)) 332 break; 333 p = strchr(s,';'); 334 if(p) 335 *p = 0; 336 info->fdflds = atoi(s); 337 if(!fgets(s,256,handle)) 338 break; 339 p = strchr(s,';'); 340 if(p) 341 *p = 0; 342 info->fnpos = atoi(s); 343 p = strchr(s,','); 344 if(p) { 345 p++; 346 info->nameislast = (BOOL)(*p && atol(p) == 0) ? FALSE : TRUE; 347 p = strchr(p,','); 348 if(p) { 349 p++; 350 info->nameisnext = (BOOL)(*p && atol(p) == 0) ? FALSE : TRUE; 351 p = strchr(p,','); 352 if(p) { 353 p++; 354 info->nameisfirst = (BOOL)(*p && atol(p) == 0) ? FALSE : TRUE; 355 } 356 } 357 } 358 for(x = NUMLINES;x < numlines;x++) { 359 if(!fgets(s,256,handle)) 360 break; 361 } 362 info->next = NULL; 363 if(!arcsighead) { 364 arcsighead = last = info; 365 info->prev = NULL; 366 } 367 else { 368 last->next = info; 369 info->prev = last; 370 last = info; 371 } 372 if(info->extract && 373 !*info->extract) { 374 free(info->extract); 375 info->extract = NULL; 376 } 441 #pragma alloc_text(FMARCHIVE,SBoxDlgProc) 442 443 MRESULT EXPENTRY SBoxDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 444 { 445 /* dlg proc that allows selecting an archiver entry */ 446 447 ARC_TYPE **info, *temp, *test; 448 SHORT sSelect, x; 449 CHAR text[256]; 450 451 switch (msg) 452 { 453 case WM_INITDLG: 454 if (!loadedarcs) 455 load_archivers(); 456 if (!(ARC_TYPE **) mp2) 457 { 458 DosBeep(100, 100); 459 WinDismissDlg(hwnd, 0); 460 break; 461 } 462 info = (ARC_TYPE **) mp2; 463 if (*info) 464 *info = arcsighead; 465 WinSetWindowPtr(hwnd, 0L, (PVOID) info); 466 temp = arcsighead; 467 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID); 468 /* this loop fills the listbox */ 469 { 470 BOOL found = FALSE; 471 472 while (temp) 473 { 474 /* 475 * this inner loop tests for a dupe signature entry and assures 476 * that only the entry at the top of the list gets used for 477 * conversion; editing any is okay 478 */ 479 if (*info) 480 { 481 test = arcsighead; 482 while (test && test != temp) 483 { 484 if (!strcmp(test -> signature, temp -> signature)) 485 goto ContinueHere; 486 test = test -> next; 487 } 488 } 489 490 if (!*info || (temp -> id && temp -> extract && temp -> create)) 491 { 492 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM, 493 MPFROM2SHORT(LIT_END, 0), 494 MPFROMP((temp -> id) ? 495 temp -> id : "?")); 496 if (!found && *szDefArc && temp -> id && !strcmp(szDefArc, temp -> id)) 497 { 498 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM, 499 MPFROMSHORT(sSelect), MPFROMSHORT(TRUE)); 500 found = TRUE; 501 } 502 } 503 else 504 { 505 if (!temp -> id || !*temp -> id) 506 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM, 507 MPFROM2SHORT(LIT_END, 0), 508 MPFROMP(GetPString(IDS_UNKNOWNUNUSABLETEXT))); 509 else 510 { 511 CHAR s[81]; 512 513 sprintf(s, "%0.12s %s", 514 temp -> id, 515 GetPString(IDS_UNUSABLETEXT)); 516 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM, 517 MPFROM2SHORT(LIT_END, 0), 518 MPFROMP(s)); 519 } 520 } 521 522 ContinueHere: 523 524 temp = temp -> next; 525 } 526 if (found) 527 PosOverOkay(hwnd); 528 } 529 break; 530 531 case WM_COMMAND: 532 info = (ARC_TYPE **) WinQueryWindowPtr(hwnd, 0L); 533 switch (SHORT1FROMMP(mp1)) 534 { 535 case DID_OK: 536 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, 537 ASEL_LISTBOX, 538 LM_QUERYSELECTION, 539 MPFROMSHORT(LIT_FIRST), 540 MPVOID); 541 if (sSelect >= 0) 542 { 543 temp = arcsighead; 544 if (*info) 545 { 546 *text = 0; 547 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT, 548 MPFROM2SHORT(sSelect, 255), MPFROMP(text)); 549 if (*text) 550 { 551 while (temp) 552 { 553 if (temp -> id) 554 { 555 if (!strcmp(text, temp -> id)) 556 break; 557 } 558 temp = temp -> next; 559 } 560 } 561 else 562 temp = NULL; 563 } 564 else 565 { 566 x = 0; 567 while (temp) 568 { 569 if (x >= sSelect) 570 break; 571 x++; 572 temp = temp -> next; 573 } 574 } 575 if (temp && (!*info || (temp -> id && temp -> extract && 576 temp -> create))) 577 { 578 *info = temp; 579 } 580 else 581 { 582 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM, 583 MPFROMSHORT(LIT_NONE), FALSE); 584 DosBeep(100, 100); 585 temp = NULL; 586 return 0; 587 } 588 } 589 else 590 { 591 DosBeep(100, 100); 592 return 0; 593 } 594 WinDismissDlg(hwnd, TRUE); 595 return 0; 596 597 case DID_CANCEL: 598 *info = NULL; 599 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); 600 break; 601 602 default: 603 break; 604 } 605 return 0; 606 607 case WM_CONTROL: 608 if (SHORT1FROMMP(mp1) == ASEL_LISTBOX && SHORT2FROMMP(mp1) == LN_ENTER) 609 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID); 610 return 0; 611 612 case WM_CLOSE: 613 WinDismissDlg(hwnd, FALSE); 614 return 0; 615 616 default: 617 break; 377 618 } 378 info = NULL; 379 } 380 fclose(handle); 381 if(info) { 382 if(info->id) free(info->id); 383 if(info->ext) free(info->ext); 384 if(info->list) free(info->list); 385 if(info->extract) free(info->extract); 386 if(info->create) free(info->create); 387 if(info->move) free(info->move); 388 if(info->delete) free(info->delete); 389 if(info->signature) free(info->signature); 390 if(info->startlist) free(info->startlist); 391 if(info->endlist) free(info->endlist); 392 if(info->exwdirs) free(info->exwdirs); 393 if(info->test) free(info->test); 394 if(info->createrecurse) 395 free(info->createrecurse); 396 if(info->createwdirs) 397 free(info->createwdirs); 398 if(info->movewdirs) free(info->movewdirs); 399 } 400 if(!arcsighead) 401 return -4; 402 return 0; 619 return WinDefDlgProc(hwnd, msg, mp1, mp2); 403 620 } 404 621 405 406 #pragma alloc_text(FMARCHIVE,SBoxDlgProc) 407 408 MRESULT EXPENTRY SBoxDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 409 410 /* dlg proc that allows selecting an archiver entry */ 411 412 ARC_TYPE **info,*temp,*test; 413 SHORT sSelect,x; 414 CHAR text[256]; 415 416 switch(msg) { 417 case WM_INITDLG: 418 if(!loadedarcs) 419 load_archivers(); 420 if(!(ARC_TYPE **)mp2) { 421 DosBeep(100,100); 422 WinDismissDlg(hwnd,0); 423 break; 424 } 425 info = (ARC_TYPE **)mp2; 426 if(*info) 427 *info = arcsighead; 428 WinSetWindowPtr(hwnd,0L,(PVOID)info); 429 temp = arcsighead; 430 WinSendDlgItemMsg(hwnd,ASEL_LISTBOX,LM_DELETEALL,MPVOID,MPVOID); 431 /* this loop fills the listbox */ 432 { 433 BOOL found = FALSE; 434 435 while(temp) { 436 /* 437 * this inner loop tests for a dupe signature entry and assures 438 * that only the entry at the top of the list gets used for 439 * conversion; editing any is okay 440 */ 441 if(*info) { 442 test = arcsighead; 443 while(test && test != temp) { 444 if(!strcmp(test->signature,temp->signature)) 445 goto ContinueHere; 446 test = test->next; 447 } 448 } 449 450 if(!*info || (temp->id && temp->extract && temp->create)) { 451 sSelect = (SHORT)WinSendDlgItemMsg(hwnd,ASEL_LISTBOX,LM_INSERTITEM, 452 MPFROM2SHORT(LIT_END,0), 453 MPFROMP((temp->id) ? 454 temp->id : "?")); 455 if(!found && *szDefArc && temp->id && !strcmp(szDefArc,temp->id)) { 456 WinSendDlgItemMsg(hwnd,ASEL_LISTBOX,LM_SELECTITEM, 457 MPFROMSHORT(sSelect),MPFROMSHORT(TRUE)); 458 found = TRUE; 459 } 460 } 461 else { 462 if(!temp->id || !*temp->id) 463 WinSendDlgItemMsg(hwnd,ASEL_LISTBOX,LM_INSERTITEM, 464 MPFROM2SHORT(LIT_END,0), 465 MPFROMP(GetPString(IDS_UNKNOWNUNUSABLETEXT))); 466 else { 467 CHAR s[81]; 468 469 sprintf(s,"%0.12s %s", 470 temp->id, 471 GetPString(IDS_UNUSABLETEXT)); 472 WinSendDlgItemMsg(hwnd,ASEL_LISTBOX,LM_INSERTITEM, 473 MPFROM2SHORT(LIT_END,0), 474 MPFROMP(s)); 475 } 476 } 477 478 ContinueHere: 479 480 temp = temp->next; 481 } 482 if(found) 483 PosOverOkay(hwnd); 484 } 485 break; 486 487 case WM_COMMAND: 488 info = (ARC_TYPE **)WinQueryWindowPtr(hwnd,0L); 489 switch(SHORT1FROMMP(mp1)) { 490 case DID_OK: 491 sSelect = (SHORT)WinSendDlgItemMsg(hwnd, 492 ASEL_LISTBOX, 493 LM_QUERYSELECTION, 494 MPFROMSHORT(LIT_FIRST), 495 MPVOID); 496 if(sSelect >= 0) { 497 temp = arcsighead; 498 if(*info) { 499 *text = 0; 500 WinSendDlgItemMsg(hwnd,ASEL_LISTBOX,LM_QUERYITEMTEXT, 501 MPFROM2SHORT(sSelect,255),MPFROMP(text)); 502 if(*text) { 503 while(temp) { 504 if(temp->id) { 505 if(!strcmp(text,temp->id)) 506 break; 507 } 508 temp = temp->next; 509 } 510 } 511 else 512 temp = NULL; 513 } 514 else { 515 x = 0; 516 while(temp) { 517 if(x >= sSelect) 518 break; 519 x++; 520 temp = temp->next; 521 } 522 } 523 if(temp && (!*info || (temp->id && temp->extract && 524 temp->create))) { 525 *info = temp; 526 } 527 else { 528 WinSendDlgItemMsg(hwnd,ASEL_LISTBOX,LM_SELECTITEM, 529 MPFROMSHORT(LIT_NONE),FALSE); 530 DosBeep(100,100); 531 temp = NULL; 532 return 0; 533 } 534 } 535 else { 536 DosBeep(100,100); 537 return 0; 538 } 539 WinDismissDlg(hwnd,TRUE); 540 return 0; 541 542 case DID_CANCEL: 543 *info = NULL; 544 PostMsg(hwnd,WM_CLOSE,MPVOID,MPVOID); 545 break; 546 547 default: 548 break; 549 } 550 return 0; 551 552 case WM_CONTROL: 553 if(SHORT1FROMMP(mp1) == ASEL_LISTBOX && SHORT2FROMMP(mp1) == LN_ENTER) 554 PostMsg(hwnd,WM_COMMAND,MPFROM2SHORT(DID_OK,0),MPVOID); 555 return 0; 556 557 case WM_CLOSE: 558 WinDismissDlg(hwnd,FALSE); 559 return 0; 560 561 default: 562 break; 563 } 564 return WinDefDlgProc(hwnd,msg,mp1,mp2); 622 /* 623 02-08-96 23:55 1 624 8 Feb 96 23:55:32 2 625 8 Feb 96 11:55p 3 626 96-02-08 23:55:32 4 627 */ 628 629 #pragma alloc_text(ARCCNRS,ArcDateTime) 630 631 BOOL ArcDateTime(CHAR * dt, INT type, CDATE * cdate, CTIME * ctime) 632 { 633 INT x; 634 BOOL ret = FALSE; 635 CHAR *p, *pp, *pd; 636 637 if (dt && cdate && ctime) 638 { 639 memset(cdate, 0, sizeof(CDATE)); 640 memset(ctime, 0, sizeof(CTIME)); 641 if (type) 642 { 643 p = dt; 644 while (*p && *p == ' ') 645 p++; 646 pd = dt; 647 switch (type) 648 { 649 case 1: 650 cdate -> month = atoi(pd); 651 p = to_delim(pd, "-/."); 652 if (p) 653 { 654 p++; 655 cdate -> day = atoi(p); 656 pd = p; 657 p = to_delim(pd, "-/."); 658 if (p) 659 { 660 p++; 661 cdate -> year = atoi(p); 662 if (cdate -> year > 80 && cdate -> year < 1900) 663 cdate -> year += 1900; 664 else if (cdate -> year < 1900) 665 cdate -> year += 2000; 666 ret = TRUE; 667 p = strchr(p, ' '); 668 if (p) 669 { 670 while (*p && *p == ' ') 671 p++; 672 ctime -> hours = atoi(p); 673 p = to_delim(pd, ":."); 674 if (p) 675 { 676 p++; 677 ctime -> minutes = atoi(p); 678 p = to_delim(pd, ":."); 679 if (p) 680 { 681 p++; 682 ctime -> seconds = atoi(p); 683 } 684 } 685 } 686 } 687 } 688 break; 689 690 case 2: 691 cdate -> day = atoi(p); 692 p = strchr(p, ' '); 693 if (p) 694 { 695 p++; 696 for (x = 0; x < 12; x++) 697 { 698 if (!strnicmp(p, GetPString(IDS_JANUARY + x), 3)) 699 break; 700 } 701 if (x < 12) 702 { 703 cdate -> month = x; 704 p = strchr(p, ' '); 705 if (p) 706 { 707 p++; 708 cdate -> year = atoi(p); 709 if (cdate -> year > 80 && cdate -> year < 1900) 710 cdate -> year += 1900; 711 else if (cdate -> year < 1900) 712 cdate -> year += 2000; 713 ret = TRUE; 714 p = strchr(p, ' '); 715 if (p) 716 { 717 while (*p && *p == ' ') 718 p++; 719 ctime -> hours = atoi(p); 720 p = to_delim(pd, ":."); 721 if (p) 722 { 723 p++; 724 ctime -> minutes = atoi(p); 725 p = to_delim(pd, ":."); 726 if (p) 727 { 728 p++; 729 ctime -> seconds = atoi(p); 730 } 731 } 732 } 733 } 734 } 735 } 736 break; 737 738 case 3: 739 cdate -> day = atoi(p); 740 p = strchr(p, ' '); 741 if (p) 742 { 743 p++; 744 for (x = 0; x < 12; x++) 745 { 746 if (!strnicmp(p, GetPString(IDS_JANUARY + x), 3)) 747 break; 748 } 749 if (x < 12) 750 { 751 cdate -> month = x; 752 p = strchr(p, ' '); 753 if (p) 754 { 755 p++; 756 cdate -> year = atoi(p); 757 if (cdate -> year > 80 && cdate -> year < 1900) 758 cdate -> year += 1900; 759 else if (cdate -> year < 1900) 760 cdate -> year += 2000; 761 ret = TRUE; 762 p = strchr(p, ' '); 763 if (p) 764 { 765 while (*p && *p == ' ') 766 p++; 767 ctime -> hours = atoi(p); 768 p = to_delim(pd, ":."); 769 if (p) 770 { 771 p++; 772 pp = p; 773 ctime -> minutes = atoi(p); 774 p = to_delim(pd, ":."); 775 if (p) 776 { 777 p++; 778 ctime -> seconds = atoi(p); 779 p += 2; 780 if (toupper(*p) == 'P') 781 ctime -> hours += 12; 782 } 783 else 784 { 785 p = pp; 786 p += 2; 787 if (toupper(*p) == 'P') 788 ctime -> hours += 12; 789 } 790 } 791 } 792 } 793 } 794 } 795 break; 796 797 case 4: 798 cdate -> year = atoi(p); 799 if (cdate -> year > 80 && cdate -> year < 1900) 800 cdate -> year += 1900; 801 else if (cdate -> year < 1900) 802 cdate -> year += 2000; 803 p = to_delim(pd, "-/."); 804 if (p) 805 { 806 p++; 807 cdate -> month = atoi(p); 808 pd = p; 809 p = to_delim(pd, "-/."); 810 if (p) 811 { 812 p++; 813 cdate -> day = atoi(p); 814 ret = TRUE; 815 p = strchr(p, ' '); 816 if (p) 817 { 818 while (*p && *p == ' ') 819 p++; 820 ctime -> hours = atoi(p); 821 p = to_delim(pd, ":."); 822 if (p) 823 { 824 p++; 825 ctime -> minutes = atoi(p); 826 p = to_delim(pd, ":."); 827 if (p) 828 { 829 p++; 830 ctime -> seconds = atoi(p); 831 } 832 } 833 } 834 } 835 } 836 break; 837 838 case 5: 839 cdate -> day = atoi(pd); 840 p = to_delim(pd, "-/."); 841 if (p) 842 { 843 p++; 844 cdate -> month = atoi(p); 845 pd = p; 846 p = to_delim(pd, "-/."); 847 if (p) 848 { 849 p++; 850 cdate -> year = atoi(p); 851 if (cdate -> year > 80 && cdate -> year < 1900) 852 cdate -> year += 1900; 853 else if (cdate -> year < 1900) 854 cdate -> year += 2000; 855 ret = TRUE; 856 p = strchr(p, ' '); 857 if (p) 858 { 859 while (*p && *p == ' ') 860 p++; 861 ctime -> hours = atoi(p); 862 p = to_delim(pd, ":."); 863 if (p) 864 { 865 p++; 866 ctime -> minutes = atoi(p); 867 p = to_delim(pd, ":."); 868 if (p) 869 { 870 p++; 871 ctime -> seconds = atoi(p); 872 } 873 } 874 } 875 } 876 } 877 break; 878 879 default: 880 break; 881 } 882 } 883 } 884 return ret; 565 885 } 566 567 568 /*569 02-08-96 23:55 1570 8 Feb 96 23:55:32 2571 8 Feb 96 11:55p 3572 96-02-08 23:55:32 4573 */574 575 #pragma alloc_text(ARCCNRS,ArcDateTime)576 577 BOOL ArcDateTime (CHAR *dt,INT type,CDATE *cdate,CTIME *ctime) {578 579 INT x;580 BOOL ret = FALSE;581 CHAR *p,*pp,*pd;582 583 if(dt && cdate && ctime) {584 memset(cdate,0,sizeof(CDATE));585 memset(ctime,0,sizeof(CTIME));586 if(type) {587 p = dt;588 while(*p && *p == ' ')589 p++;590 pd = dt;591 switch(type) {592 case 1:593 cdate->month = atoi(pd);594 p = to_delim(pd,"-/.");595 if(p) {596 p++;597 cdate->day = atoi(p);598 pd = p;599 p = to_delim(pd,"-/.");600 if(p) {601 p++;602 cdate->year = atoi(p);603 if(cdate->year > 80 && cdate->year < 1900)604 cdate->year += 1900;605 else if(cdate->year < 1900)606 cdate->year += 2000;607 ret = TRUE;608 p = strchr(p,' ');609 if(p) {610 while(*p && *p == ' ')611 p++;612 ctime->hours = atoi(p);613 p = to_delim(pd,":.");614 if(p) {615 p++;616 ctime->minutes = atoi(p);617 p = to_delim(pd,":.");618 if(p) {619 p++;620 ctime->seconds = atoi(p);621 }622 }623 }624 }625 }626 break;627 628 case 2:629 cdate->day = atoi(p);630 p = strchr(p,' ');631 if(p) {632 p++;633 for(x = 0;x < 12;x++) {634 if(!strnicmp(p,GetPString(IDS_JANUARY + x),3))635 break;636 }637 if(x < 12) {638 cdate->month = x;639 p = strchr(p,' ');640 if(p) {641 p++;642 cdate->year = atoi(p);643 if(cdate->year > 80 && cdate->year < 1900)644 cdate->year += 1900;645 else if(cdate->year < 1900)646 cdate->year += 2000;647 ret = TRUE;648 p = strchr(p,' ');649 if(p) {650 while(*p && *p == ' ')651 p++;652 ctime->hours = atoi(p);653 p = to_delim(pd,":.");654 if(p) {655 p++;656 ctime->minutes = atoi(p);657 p = to_delim(pd,":.");658 if(p) {659 p++;660 ctime->seconds = atoi(p);661 }662 }663 }664 }665 }666 }667 break;668 669 case 3:670 cdate->day = atoi(p);671 p = strchr(p,' ');672 if(p) {673 p++;674 for(x = 0;x < 12;x++) {675 if(!strnicmp(p,GetPString(IDS_JANUARY + x),3))676 break;677 }678 if(x < 12) {679 cdate->month = x;680 p = strchr(p,' ');681 if(p) {682 p++;683 cdate->year = atoi(p);684 if(cdate->year > 80 && cdate->year < 1900)685 cdate->year += 1900;686 else if(cdate->year < 1900)687 cdate->year += 2000;688 ret = TRUE;689 p = strchr(p,' ');690 if(p) {691 while(*p && *p == ' ')692 p++;693 ctime->hours = atoi(p);694 p = to_delim(pd,":.");695 if(p) {696 p++;697 pp = p;698 ctime->minutes = atoi(p);699 p = to_delim(pd,":.");700 if(p) {701 p++;702 ctime->seconds = atoi(p);703 p += 2;704 if(toupper(*p) == 'P')705 ctime->hours += 12;706 }707 else {708 p = pp;709 p += 2;710 if(toupper(*p) == 'P')711 ctime->hours += 12;712 }713 }714 }715 }716 }717 }718 break;719 720 case 4:721 cdate->year = atoi(p);722 if(cdate->year > 80 && cdate->year < 1900)723 cdate->year += 1900;724 else if(cdate->year < 1900)725 cdate->year += 2000;726 p = to_delim(pd,"-/.");727 if(p) {728 p++;729 cdate->month = atoi(p);730 pd = p;731 p = to_delim(pd,"-/.");732 if(p) {733 p++;734 cdate->day = atoi(p);735 ret = TRUE;736 p = strchr(p,' ');737 if(p) {738 while(*p && *p == ' ')739 p++;740 ctime->hours = atoi(p);741 p = to_delim(pd,":.");742 if(p) {743 p++;744 ctime->minutes = atoi(p);745 p = to_delim(pd,":.");746 if(p) {747 p++;748 ctime->seconds = atoi(p);749 }750 }751 }752 }753 }754 break;755 756 case 5:757 cdate->day = atoi(pd);758 p = to_delim(pd,"-/.");759 if(p) {760 p++;761 cdate->month = atoi(p);762 pd = p;763 p = to_delim(pd,"-/.");764 if(p) {765 p++;766 cdate->year = atoi(p);767 if(cdate->year > 80 && cdate->year < 1900)768 cdate->year += 1900;769 else if(cdate->year < 1900)770 cdate->year += 2000;771 ret = TRUE;772 p = strchr(p,' ');773 if(p) {774 while(*p && *p == ' ')775 p++;776 ctime->hours = atoi(p);777 p = to_delim(pd,":.");778 if(p) {779 p++;780 ctime->minutes = atoi(p);781 p = to_delim(pd,":.");782 if(p) {783 p++;784 ctime->seconds = atoi(p);785 }786 }787 }788 }789 }790 break;791 792 default:793 break;794 }795 }796 }797 return ret;798 }
Note:
See TracChangeset
for help on using the changeset viewer.
