[123] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: avl.c 247 2005-08-13 23:03:52Z root $
|
---|
| 5 |
|
---|
| 6 | archiver.bb2 loader and utilities
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[247] | 9 | Copyright (c) 2004, 2005 Steven H.Levine
|
---|
[123] | 10 |
|
---|
[247] | 11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 12 | 13 Aug 05 SHL Beautify with indent
|
---|
[123] | 13 |
|
---|
| 14 | ***********************************************************************/
|
---|
| 15 |
|
---|
[2] | 16 | #define INCL_WIN
|
---|
| 17 | #define INCL_DOS
|
---|
| 18 |
|
---|
| 19 | #include <os2.h>
|
---|
| 20 | #include <stdlib.h>
|
---|
| 21 | #include <stdio.h>
|
---|
| 22 | #include <string.h>
|
---|
| 23 | #include <share.h>
|
---|
| 24 | #include <ctype.h>
|
---|
| 25 | #include "fm3dll.h"
|
---|
| 26 | #include "fm3dlg.h"
|
---|
| 27 | #include "fm3str.h"
|
---|
| 28 |
|
---|
| 29 | BOOL loadedarcs = FALSE;
|
---|
| 30 |
|
---|
| 31 | #pragma alloc_text(MISC9,quick_find_type,find_type)
|
---|
| 32 |
|
---|
[247] | 33 | ARC_TYPE *quick_find_type(CHAR * filespec, ARC_TYPE * topsig)
|
---|
| 34 | {
|
---|
| 35 | ARC_TYPE *info, *found = NULL;
|
---|
| 36 | CHAR *p;
|
---|
[2] | 37 |
|
---|
[247] | 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 | }
|
---|
[2] | 56 | }
|
---|
[247] | 57 | return found;
|
---|
[2] | 58 | }
|
---|
| 59 |
|
---|
[247] | 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. */
|
---|
[2] | 66 |
|
---|
[247] | 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;
|
---|
[2] | 124 | }
|
---|
[247] | 125 | DosClose(handle); /* Either way, we're done for now */
|
---|
| 126 | return info; /* return signature, if any */
|
---|
[2] | 127 | }
|
---|
| 128 |
|
---|
| 129 | #pragma alloc_text(AVL,load_archivers)
|
---|
| 130 |
|
---|
[247] | 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;
|
---|
[2] | 137 |
|
---|
[247] | 138 | loadedarcs = TRUE;
|
---|
| 139 | DosEnterCritSec();
|
---|
| 140 | p = searchpath(GetPString(IDS_ARCHIVERBB2));
|
---|
| 141 | if (!p || !*p)
|
---|
| 142 | {
|
---|
| 143 | DosExitCritSec();
|
---|
| 144 | return -1;
|
---|
| 145 | }
|
---|
| 146 | handle = _fsopen(p, "r", SH_DENYWR);
|
---|
[2] | 147 | DosExitCritSec();
|
---|
[247] | 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;
|
---|
[123] | 159 | bstripcr(s);
|
---|
[247] | 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;
|
---|
[2] | 401 | }
|
---|
[247] | 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;
|
---|
[2] | 439 | }
|
---|
| 440 |
|
---|
| 441 | #pragma alloc_text(FMARCHIVE,SBoxDlgProc)
|
---|
| 442 |
|
---|
[247] | 443 | MRESULT EXPENTRY SBoxDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 444 | {
|
---|
| 445 | /* dlg proc that allows selecting an archiver entry */
|
---|
[2] | 446 |
|
---|
[247] | 447 | ARC_TYPE **info, *temp, *test;
|
---|
| 448 | SHORT sSelect, x;
|
---|
| 449 | CHAR text[256];
|
---|
[2] | 450 |
|
---|
[247] | 451 | switch (msg)
|
---|
| 452 | {
|
---|
[2] | 453 | case WM_INITDLG:
|
---|
[247] | 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;
|
---|
[2] | 471 |
|
---|
[247] | 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 | }
|
---|
[2] | 489 |
|
---|
[247] | 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];
|
---|
[2] | 512 |
|
---|
[247] | 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 | }
|
---|
[2] | 521 |
|
---|
[247] | 522 | ContinueHere:
|
---|
[2] | 523 |
|
---|
[247] | 524 | temp = temp -> next;
|
---|
| 525 | }
|
---|
| 526 | if (found)
|
---|
| 527 | PosOverOkay(hwnd);
|
---|
| 528 | }
|
---|
| 529 | break;
|
---|
[2] | 530 |
|
---|
| 531 | case WM_COMMAND:
|
---|
[247] | 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;
|
---|
[2] | 596 |
|
---|
[247] | 597 | case DID_CANCEL:
|
---|
| 598 | *info = NULL;
|
---|
| 599 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 600 | break;
|
---|
[2] | 601 |
|
---|
[247] | 602 | default:
|
---|
| 603 | break;
|
---|
| 604 | }
|
---|
| 605 | return 0;
|
---|
[2] | 606 |
|
---|
| 607 | case WM_CONTROL:
|
---|
[247] | 608 | if (SHORT1FROMMP(mp1) == ASEL_LISTBOX && SHORT2FROMMP(mp1) == LN_ENTER)
|
---|
| 609 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
---|
| 610 | return 0;
|
---|
[2] | 611 |
|
---|
| 612 | case WM_CLOSE:
|
---|
[247] | 613 | WinDismissDlg(hwnd, FALSE);
|
---|
| 614 | return 0;
|
---|
[2] | 615 |
|
---|
| 616 | default:
|
---|
[247] | 617 | break;
|
---|
| 618 | }
|
---|
| 619 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 620 | }
|
---|
| 621 |
|
---|
| 622 | /*
|
---|
[247] | 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 | */
|
---|
[2] | 628 |
|
---|
| 629 | #pragma alloc_text(ARCCNRS,ArcDateTime)
|
---|
| 630 |
|
---|
[247] | 631 | BOOL ArcDateTime(CHAR * dt, INT type, CDATE * cdate, CTIME * ctime)
|
---|
| 632 | {
|
---|
| 633 | INT x;
|
---|
| 634 | BOOL ret = FALSE;
|
---|
| 635 | CHAR *p, *pp, *pd;
|
---|
[2] | 636 |
|
---|
[247] | 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;
|
---|
[2] | 689 |
|
---|
[247] | 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;
|
---|
[2] | 737 |
|
---|
[247] | 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;
|
---|
[2] | 796 |
|
---|
[247] | 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;
|
---|
[2] | 837 |
|
---|
[247] | 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;
|
---|
[2] | 878 |
|
---|
[247] | 879 | default:
|
---|
| 880 | break;
|
---|
| 881 | }
|
---|
| 882 | }
|
---|
[2] | 883 | }
|
---|
[247] | 884 | return ret;
|
---|
[2] | 885 | }
|
---|