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