[793] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: findrec.c 793 2007-08-21 02:53:38Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Copyright (c) 1993-98 M. Kimes
|
---|
| 7 | Copyright (c) 2003, 2007 Steven H.Levine
|
---|
| 8 |
|
---|
| 9 | Find records
|
---|
| 10 |
|
---|
| 11 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
| 12 |
|
---|
| 13 | ***********************************************************************/
|
---|
| 14 |
|
---|
[2] | 15 | #define INCL_WIN
|
---|
| 16 |
|
---|
| 17 | #include <os2.h>
|
---|
| 18 | #include <stdarg.h>
|
---|
| 19 | #include <stdio.h>
|
---|
| 20 | #include <stdlib.h>
|
---|
| 21 | #include <string.h>
|
---|
| 22 | #include "fm3dll.h"
|
---|
| 23 |
|
---|
[551] | 24 | PCNRITEM FindCnrRecord(HWND hwndCnr, CHAR * filename, PCNRITEM pciParent,
|
---|
| 25 | BOOL partial, BOOL partmatch, BOOL noenv)
|
---|
| 26 | {
|
---|
[2] | 27 |
|
---|
[551] | 28 | SEARCHSTRING srch;
|
---|
| 29 | PCNRITEM pci;
|
---|
| 30 | register CHAR *file, *p;
|
---|
[2] | 31 |
|
---|
[551] | 32 | if (partial) {
|
---|
| 33 | if (strlen(filename) > 3) {
|
---|
| 34 | file = strrchr(filename, '\\');
|
---|
| 35 | if (!file) {
|
---|
| 36 | file = strrchr(filename, ':');
|
---|
| 37 | if (file)
|
---|
| 38 | file++;
|
---|
| 39 | else
|
---|
| 40 | file = filename;
|
---|
[2] | 41 | }
|
---|
| 42 | else
|
---|
[551] | 43 | file++;
|
---|
[2] | 44 | }
|
---|
| 45 | else
|
---|
| 46 | file = filename;
|
---|
| 47 | }
|
---|
| 48 | else
|
---|
| 49 | file = filename;
|
---|
[551] | 50 | memset(&srch, 0, sizeof(SEARCHSTRING));
|
---|
| 51 | srch.cb = (ULONG) sizeof(SEARCHSTRING);
|
---|
| 52 | srch.pszSearch = (PSZ) file;
|
---|
[2] | 53 | srch.fsPrefix = FALSE;
|
---|
| 54 | srch.fsCaseSensitive = FALSE;
|
---|
[551] | 55 | srch.usView = CV_TREE; /* | CV_EXACTMATCH; */
|
---|
| 56 | if (!pciParent)
|
---|
| 57 | pciParent = (PCNRITEM) CMA_FIRST;
|
---|
[2] | 58 | pci = WinSendMsg(hwndCnr,
|
---|
[551] | 59 | CM_SEARCHSTRING, MPFROMP(&srch), MPFROMP(pciParent));
|
---|
| 60 | while (pci && (INT) pci != -1) {
|
---|
| 61 | if (!noenv || (pci->flags & (RECFLAGS_ENV | RECFLAGS_UNDERENV)) == 0) {
|
---|
| 62 | if (!partmatch) { /* full name must match full name */
|
---|
[730] | 63 | if (!stricmp(pci->pszFileName, filename))
|
---|
[551] | 64 | return pci; /* success */
|
---|
[2] | 65 | }
|
---|
[551] | 66 | else { /* only root name must match */
|
---|
[730] | 67 | if (strlen(pci->pszFileName) > 3) {
|
---|
| 68 | p = strrchr(pci->pszFileName, '\\');
|
---|
[551] | 69 | if (!p) {
|
---|
[730] | 70 | p = strrchr(pci->pszFileName, ':');
|
---|
[551] | 71 | if (p)
|
---|
| 72 | p++;
|
---|
| 73 | else
|
---|
[730] | 74 | p = pci->pszFileName;
|
---|
[551] | 75 | }
|
---|
| 76 | else
|
---|
| 77 | p++;
|
---|
| 78 | }
|
---|
| 79 | else
|
---|
[730] | 80 | p = pci->pszFileName;
|
---|
[551] | 81 | if (!stricmp(p, file))
|
---|
| 82 | return pci; /* success */
|
---|
[2] | 83 | }
|
---|
| 84 | }
|
---|
[551] | 85 | pci = WinSendMsg(hwndCnr, CM_SEARCHSTRING, MPFROMP(&srch), MPFROMP(pci));
|
---|
[2] | 86 | }
|
---|
[689] | 87 |
|
---|
[551] | 88 | return NULL; /* failure */
|
---|
[2] | 89 | }
|
---|
| 90 |
|
---|
[551] | 91 | PCNRITEM FindParentRecord(HWND hwndCnr, PCNRITEM pciC)
|
---|
| 92 | {
|
---|
[2] | 93 |
|
---|
[551] | 94 | PCNRITEM pciP = (PCNRITEM) NULL, pci = pciC;
|
---|
[2] | 95 |
|
---|
[551] | 96 | if (pci) {
|
---|
| 97 | for (;;) {
|
---|
[2] | 98 | pciP = WinSendMsg(hwndCnr,
|
---|
[551] | 99 | CM_QUERYRECORD,
|
---|
| 100 | MPFROMP(pci),
|
---|
| 101 | MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
|
---|
| 102 | if (pciP && (INT) pciP != -1)
|
---|
| 103 | pci = pciP;
|
---|
[2] | 104 | else
|
---|
[551] | 105 | break;
|
---|
[2] | 106 | }
|
---|
| 107 | }
|
---|
| 108 | return pci;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
[551] | 111 | VOID ShowCnrRecord(HWND hwndCnr, PMINIRECORDCORE pmi)
|
---|
| 112 | {
|
---|
[2] | 113 |
|
---|
[551] | 114 | QUERYRECORDRECT qrecrct;
|
---|
| 115 | RECTL rcl;
|
---|
| 116 | RECTL rclViewport;
|
---|
[2] | 117 |
|
---|
[551] | 118 | memset(&qrecrct, 0, sizeof(QUERYRECORDRECT));
|
---|
[2] | 119 | qrecrct.cb = sizeof(QUERYRECORDRECT);
|
---|
[551] | 120 | qrecrct.pRecord = (PRECORDCORE) pmi;
|
---|
[2] | 121 | qrecrct.fsExtent = (CMA_ICON | CMA_TEXT | CMA_TREEICON);
|
---|
[551] | 122 | if (!WinSendMsg(hwndCnr,
|
---|
| 123 | CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct))) {
|
---|
[2] | 124 | qrecrct.fsExtent = CMA_TEXT | CMA_TREEICON;
|
---|
[551] | 125 | WinSendMsg(hwndCnr, CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct));
|
---|
[2] | 126 | }
|
---|
| 127 | WinSendMsg(hwndCnr,
|
---|
[551] | 128 | CM_QUERYVIEWPORTRECT,
|
---|
| 129 | MPFROMP(&rclViewport), MPFROM2SHORT(CMA_WINDOW, FALSE));
|
---|
[2] | 130 | WinSendMsg(hwndCnr,
|
---|
[551] | 131 | CM_SCROLLWINDOW,
|
---|
| 132 | MPFROMSHORT(CMA_VERTICAL),
|
---|
| 133 | MPFROMLONG((rclViewport.yTop - rcl.yTop) - 4));
|
---|
[2] | 134 | WinSendMsg(hwndCnr,
|
---|
[551] | 135 | CM_SCROLLWINDOW,
|
---|
| 136 | MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(rcl.xLeft - 4));
|
---|
[2] | 137 | }
|
---|
[793] | 138 |
|
---|
| 139 | #pragma alloc_text(FINDREC,FindCnrRecord,FindParentRecord,ShowCnrRecord)
|
---|