source: branches/ticket_150/dll/findrec.c@ 1036

Last change on this file since 1036 was 793, checked in by Gregg Young, 18 years ago

Move #pragma alloc_text to end for OpenWatcom compat

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
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
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
24PCNRITEM FindCnrRecord(HWND hwndCnr, CHAR * filename, PCNRITEM pciParent,
25 BOOL partial, BOOL partmatch, BOOL noenv)
26{
27
28 SEARCHSTRING srch;
29 PCNRITEM pci;
30 register CHAR *file, *p;
31
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;
41 }
42 else
43 file++;
44 }
45 else
46 file = filename;
47 }
48 else
49 file = filename;
50 memset(&srch, 0, sizeof(SEARCHSTRING));
51 srch.cb = (ULONG) sizeof(SEARCHSTRING);
52 srch.pszSearch = (PSZ) file;
53 srch.fsPrefix = FALSE;
54 srch.fsCaseSensitive = FALSE;
55 srch.usView = CV_TREE; /* | CV_EXACTMATCH; */
56 if (!pciParent)
57 pciParent = (PCNRITEM) CMA_FIRST;
58 pci = WinSendMsg(hwndCnr,
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 */
63 if (!stricmp(pci->pszFileName, filename))
64 return pci; /* success */
65 }
66 else { /* only root name must match */
67 if (strlen(pci->pszFileName) > 3) {
68 p = strrchr(pci->pszFileName, '\\');
69 if (!p) {
70 p = strrchr(pci->pszFileName, ':');
71 if (p)
72 p++;
73 else
74 p = pci->pszFileName;
75 }
76 else
77 p++;
78 }
79 else
80 p = pci->pszFileName;
81 if (!stricmp(p, file))
82 return pci; /* success */
83 }
84 }
85 pci = WinSendMsg(hwndCnr, CM_SEARCHSTRING, MPFROMP(&srch), MPFROMP(pci));
86 }
87
88 return NULL; /* failure */
89}
90
91PCNRITEM FindParentRecord(HWND hwndCnr, PCNRITEM pciC)
92{
93
94 PCNRITEM pciP = (PCNRITEM) NULL, pci = pciC;
95
96 if (pci) {
97 for (;;) {
98 pciP = WinSendMsg(hwndCnr,
99 CM_QUERYRECORD,
100 MPFROMP(pci),
101 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
102 if (pciP && (INT) pciP != -1)
103 pci = pciP;
104 else
105 break;
106 }
107 }
108 return pci;
109}
110
111VOID ShowCnrRecord(HWND hwndCnr, PMINIRECORDCORE pmi)
112{
113
114 QUERYRECORDRECT qrecrct;
115 RECTL rcl;
116 RECTL rclViewport;
117
118 memset(&qrecrct, 0, sizeof(QUERYRECORDRECT));
119 qrecrct.cb = sizeof(QUERYRECORDRECT);
120 qrecrct.pRecord = (PRECORDCORE) pmi;
121 qrecrct.fsExtent = (CMA_ICON | CMA_TEXT | CMA_TREEICON);
122 if (!WinSendMsg(hwndCnr,
123 CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct))) {
124 qrecrct.fsExtent = CMA_TEXT | CMA_TREEICON;
125 WinSendMsg(hwndCnr, CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct));
126 }
127 WinSendMsg(hwndCnr,
128 CM_QUERYVIEWPORTRECT,
129 MPFROMP(&rclViewport), MPFROM2SHORT(CMA_WINDOW, FALSE));
130 WinSendMsg(hwndCnr,
131 CM_SCROLLWINDOW,
132 MPFROMSHORT(CMA_VERTICAL),
133 MPFROMLONG((rclViewport.yTop - rcl.yTop) - 4));
134 WinSendMsg(hwndCnr,
135 CM_SCROLLWINDOW,
136 MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(rcl.xLeft - 4));
137}
138
139#pragma alloc_text(FINDREC,FindCnrRecord,FindParentRecord,ShowCnrRecord)
Note: See TracBrowser for help on using the repository browser.