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