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