| 1 |
|
|---|
| 2 | /***********************************************************************
|
|---|
| 3 |
|
|---|
| 4 | $Id: avl.c 123 2004-12-05 00:20:19Z root $
|
|---|
| 5 |
|
|---|
| 6 | archiver.bb2 loader and utilities
|
|---|
| 7 |
|
|---|
| 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
|
|---|
| 12 |
|
|---|
| 13 | ***********************************************************************/
|
|---|
| 14 |
|
|---|
| 15 | #define INCL_WIN
|
|---|
| 16 | #define INCL_DOS
|
|---|
| 17 |
|
|---|
| 18 | #include <os2.h>
|
|---|
| 19 | #include <stdlib.h>
|
|---|
| 20 | #include <stdio.h>
|
|---|
| 21 | #include <string.h>
|
|---|
| 22 | #include <share.h>
|
|---|
| 23 | #include <ctype.h>
|
|---|
| 24 | #include "fm3dll.h"
|
|---|
| 25 | #include "fm3dlg.h"
|
|---|
| 26 | #include "fm3str.h"
|
|---|
| 27 |
|
|---|
| 28 | BOOL loadedarcs = FALSE;
|
|---|
| 29 |
|
|---|
| 30 | #pragma alloc_text(MISC9,quick_find_type,find_type)
|
|---|
| 31 |
|
|---|
| 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;
|
|---|
| 52 | }
|
|---|
| 53 | }
|
|---|
| 54 | return found;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 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 | }
|
|---|
| 96 | }
|
|---|
| 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 | }
|
|---|
| 115 | }
|
|---|
| 116 | info = info->next;
|
|---|
| 117 | }
|
|---|
| 118 | DosClose(handle); /* Either way, we're done for now */
|
|---|
| 119 | return info; /* return signature, if any */
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 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 | }
|
|---|
| 377 | }
|
|---|
| 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;
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 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);
|
|---|
| 565 | }
|
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 | /*
|
|---|
| 569 | 02-08-96 23:55 1
|
|---|
| 570 | 8 Feb 96 23:55:32 2
|
|---|
| 571 | 8 Feb 96 11:55p 3
|
|---|
| 572 | 96-02-08 23:55:32 4
|
|---|
| 573 | */
|
|---|
| 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 | }
|
|---|