Changeset 105 for trunk/src/helpers
- Timestamp:
- Sep 27, 2001, 10:29:02 PM (24 years ago)
- Location:
- trunk/src/helpers
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/apmh.c
r93 r105 158 158 * After this, the status fields in APM 159 159 * are valid (if NO_ERROR is returned). 160 */ 161 162 APIRET apmhReadStatus(PAPM pApm) // in: APM structure created by apmhOpen 163 { 164 APIRET arc = NO_ERROR; 160 * If the values changed since the previous 161 * call, *pfChanged is set to TRUE; FALSE 162 * otherwise. 163 */ 164 165 APIRET apmhReadStatus(PAPM pApm, // in: APM structure created by apmhOpen 166 PBOOL pfChanged) // out: values changed (ptr can be NULL) 167 { 168 APIRET arc = NO_ERROR; 169 BOOL fChanged = FALSE; 165 170 166 171 if ((pApm) && (pApm->hfAPMSys)) … … 174 179 PowerStatus.ParmLength))) 175 180 { 176 pApm->ulBatteryStatus = PowerStatus.BatteryStatus; 177 pApm->ulBatteryLife = PowerStatus.BatteryLife; 181 if ( (pApm->fAlreadyRead) 182 || (pApm->ulBatteryStatus != PowerStatus.BatteryStatus) 183 || (pApm->ulBatteryLife != PowerStatus.BatteryLife) 184 ) 185 { 186 pApm->ulBatteryStatus = PowerStatus.BatteryStatus; 187 pApm->ulBatteryLife = PowerStatus.BatteryLife; 188 189 pApm->fAlreadyRead = FALSE; 190 fChanged = TRUE; 191 } 178 192 } 193 194 if (pfChanged) 195 *pfChanged = fChanged; 179 196 } 180 197 else -
trunk/src/helpers/apps.c
r101 r105 744 744 * this uses the default Win-OS/2 environment. 745 745 * See appQueryDefaultWin31Environment. 746 * 747 * -- WARNING: Since this uses WinStartApp internally, 748 * and WinStartApp completely hangs PM if a Win-OS/2 749 * full-screen session is started from a thread that 750 * is NOT thread1, THIS SHOULD ONLY BE CALLED ON 751 * THREAD 1 of your application. 746 752 * 747 753 * Even though this isn't clearly said in PMREF, -
trunk/src/helpers/dialog.c
r103 r105 48 48 #define INCL_WINDIALOGS 49 49 #define INCL_WININPUT 50 #define INCL_WINSTATICS 50 51 #define INCL_WINBUTTONS 51 #define INCL_WIN STATICS52 #define INCL_WINENTRYFIELDS 52 53 #define INCL_WINSYS 53 54 … … 70 71 #include "helpers\stringh.h" 71 72 #include "helpers\winh.h" 73 #include "helpers\xstring.h" 72 74 73 75 /* … … 2131 2133 2132 2134 /* 2135 *@@ cmnTextEntryBox: 2136 * common dialog for entering a text string. 2137 * The dialog has a descriptive text on top 2138 * with an entry field below and "OK" and "Cancel" 2139 * buttons. 2140 * 2141 * The string from the user is returned in a 2142 * new buffer, which must be free'd by the caller. 2143 * Returns NULL if the user pressed "Cancel". 2144 * 2145 * fl can be any combination of the following 2146 * flags: 2147 * 2148 * -- TEBF_REMOVETILDE: tilde ("~") characters 2149 * are removed from pcszTitle before setting 2150 * the title. Useful for reusing menu item 2151 * texts. 2152 * 2153 * -- TEBF_REMOVEELLIPSE: ellipse ("...") strings 2154 * are removed from pcszTitle before setting 2155 * the title. Useful for reusing menu item 2156 * texts. 2157 * 2158 * -- TEBF_SELECTALL: the default text in the 2159 * entry field is initially highlighted. 2160 * 2161 *@@added V0.9.15 (2001-09-14) [umoeller] 2162 */ 2163 2164 PSZ dlghTextEntryBox(HWND hwndOwner, 2165 const char *pcszTitle, // in: dlg title 2166 const char *pcszDescription, // in: descriptive text above entry field 2167 const char *pcszDefault, // in: default text for entry field or NULL 2168 const char *pcszOK, // in: "OK" string 2169 const char *pcszCancel, // in: "Cancel" string 2170 ULONG ulMaxLen, // in: maximum length for entry 2171 ULONG fl, // in: TEBF_* flags 2172 const char *pcszFont) // in: font (e.g. "9.WarpSans") 2173 { 2174 CONTROLDEF 2175 Static = { 2176 WC_STATIC, 2177 NULL, 2178 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_WORDBREAK, 2179 -1, 2180 CTL_COMMON_FONT, 2181 0, 2182 { 300, SZL_AUTOSIZE }, // size 2183 5 // spacing 2184 }, 2185 Entry = { 2186 WC_ENTRYFIELD, 2187 NULL, 2188 WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_MARGIN | ES_AUTOSCROLL, 2189 999, 2190 CTL_COMMON_FONT, 2191 0, 2192 { 300, 20 }, // size 2193 5 // spacing 2194 }, 2195 OKButton = { 2196 WC_BUTTON, 2197 NULL, 2198 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_DEFAULT, 2199 DID_OK, 2200 CTL_COMMON_FONT, 2201 0, 2202 { 100, 30 }, // size 2203 5 // spacing 2204 }, 2205 CancelButton = { 2206 WC_BUTTON, 2207 NULL, 2208 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, 2209 DID_CANCEL, 2210 CTL_COMMON_FONT, 2211 0, 2212 { 100, 30 }, // size 2213 5 // spacing 2214 }; 2215 DLGHITEM DlgTemplate[] = 2216 { 2217 START_TABLE, 2218 START_ROW(0), 2219 CONTROL_DEF(&Static), 2220 START_ROW(0), 2221 CONTROL_DEF(&Entry), 2222 START_ROW(0), 2223 CONTROL_DEF(&OKButton), 2224 CONTROL_DEF(&CancelButton), 2225 END_TABLE 2226 }; 2227 2228 HWND hwndDlg = NULLHANDLE; 2229 PSZ pszReturn = NULL; 2230 XSTRING strTitle; 2231 2232 xstrInitCopy(&strTitle, pcszTitle, 0); 2233 2234 if (fl & (TEBF_REMOVEELLIPSE | TEBF_REMOVETILDE)) 2235 { 2236 ULONG ulOfs; 2237 if (fl & TEBF_REMOVEELLIPSE) 2238 { 2239 ulOfs = 0; 2240 while (xstrFindReplaceC(&strTitle, 2241 &ulOfs, 2242 "...", 2243 "")) 2244 ; 2245 } 2246 2247 if (fl & TEBF_REMOVETILDE) 2248 { 2249 ulOfs = 0; 2250 while (xstrFindReplaceC(&strTitle, 2251 &ulOfs, 2252 "~", 2253 "")) 2254 ; 2255 } 2256 } 2257 2258 Static.pcszText = pcszDescription; 2259 2260 OKButton.pcszText = pcszOK; 2261 CancelButton.pcszText = pcszCancel; 2262 2263 if (NO_ERROR == dlghCreateDlg(&hwndDlg, 2264 hwndOwner, 2265 FCF_TITLEBAR | FCF_SYSMENU | FCF_DLGBORDER | FCF_NOBYTEALIGN, 2266 WinDefDlgProc, 2267 strTitle.psz, 2268 DlgTemplate, // DLGHITEM array 2269 ARRAYITEMCOUNT(DlgTemplate), 2270 NULL, 2271 pcszFont)) 2272 { 2273 HWND hwndEF = WinWindowFromID(hwndDlg, 999); 2274 winhCenterWindow(hwndDlg); 2275 winhSetEntryFieldLimit(hwndEF, ulMaxLen); 2276 if (pcszDefault) 2277 { 2278 WinSetWindowText(hwndEF, (PSZ)pcszDefault); 2279 if (fl & TEBF_SELECTALL) 2280 winhEntryFieldSelectAll(hwndEF); 2281 } 2282 WinSetFocus(HWND_DESKTOP, hwndEF); 2283 if (DID_OK == WinProcessDlg(hwndDlg)) 2284 pszReturn = winhQueryWindowText(hwndEF); 2285 2286 WinDestroyWindow(hwndDlg); 2287 } 2288 2289 xstrClear(&strTitle); 2290 2291 return (pszReturn); 2292 } 2293 2294 /* 2133 2295 *@@ dlghSetPrevFocus: 2134 2296 * "backward" function for rotating the focus … … 2246 2408 } 2247 2409 } 2248 2249 /*2250 *@@ MatchMnemonic:2251 * returns TRUE if the specified control matches2252 *2253 *2254 *@@added V0.9.9 (2001-03-17) [umoeller]2255 */2256 2410 2257 2411 /* -
trunk/src/helpers/dosh.c
r94 r105 814 814 &fFixed); // V0.9.13 (2001-06-14) [umoeller] 815 815 816 _Pmpf((__FUNCTION__ ": doshIsFixedDisk returned %d for disk %d", arc, ulLogicalDrive));817 _Pmpf((" fFixed is %d", fFixed));816 // _Pmpf((__FUNCTION__ ": doshIsFixedDisk returned %d for disk %d", arc, ulLogicalDrive)); 817 // _Pmpf((" fFixed is %d", fFixed)); 818 818 819 819 if (!arc) … … 825 825 arc = doshQueryDiskParams(ulLogicalDrive, 826 826 &bpb); 827 _Pmpf((" doshQueryDiskParams returned %d", arc));827 // _Pmpf((" doshQueryDiskParams returned %d", arc)); 828 828 829 829 if ( (!arc) … … 831 831 ) 832 832 { 833 _Pmpf((" --> is CD-ROM"));833 // _Pmpf((" --> is CD-ROM")); 834 834 fCDROM = TRUE; 835 835 } -
trunk/src/helpers/stringh.c
r94 r105 1914 1914 /* 1915 1915 * match_comp_os2: 1916 * Compare a single component (directory name or file name) of the 1917 * paths, for OS/2 and DOS styles. MASK and NAME point into a 1918 * component of the wildcard and the name to be checked, respectively. 1919 * Comparing stops at the next separator. The FLAGS argument is the 1920 * same as that of fnmatch(). HAS_DOT is true if a dot is in the 1921 * current component of NAME. The number of dots is not restricted, 1922 * even in DOS style. Return FNM_MATCH iff MASK and NAME match. 1916 * compares a single component (directory name or file name) 1917 * of the paths, for OS/2 and DOS styles. MASK and NAME point 1918 * into a component of the wildcard and the name to be checked, 1919 * respectively. Comparing stops at the next separator. 1920 * The FLAGS argument is the same as that of fnmatch(). 1921 * 1922 * HAS_DOT is true if a dot is in the current component of NAME. 1923 * The number of dots is not restricted, even in DOS style. 1924 * 1925 * Returns FNM_MATCH iff MASK and NAME match. 1926 * 1923 1927 * Note that this function is recursive. 1924 1928 * … … 1944 1948 if (*name == 0) 1945 1949 return FNM_MATCH; 1946 if ((flags & _FNM_PATHPREFIX) && IS_OS2_COMP_SEP(*name))1950 if ((flags & FNM_PATHPREFIX) && IS_OS2_COMP_SEP(*name)) 1947 1951 return FNM_MATCH; 1948 1952 return FNM_NOMATCH; … … 1959 1963 * is ignored at the end of NAME. */ 1960 1964 1961 if ((flags & _FNM_PATHPREFIX) && mask[1] == 0 && *name == 0)1965 if ((flags & FNM_PATHPREFIX) && mask[1] == 0 && *name == 0) 1962 1966 return FNM_MATCH; 1963 1967 … … 1994 1998 if (IS_OS2_COMP_END(*name)) 1995 1999 return FNM_NOMATCH; 1996 if (*name == '.' && (flags & _FNM_STYLE_MASK) == _FNM_DOS)2000 if (*name == '.' && (flags & FNM_STYLE_MASK) == FNM_DOS) 1997 2001 return FNM_NOMATCH; 1998 2002 ++name; … … 2015 2019 /* All other characters match themselves. */ 2016 2020 2017 if (flags & _FNM_IGNORECASE)2021 if (flags & FNM_IGNORECASE) 2018 2022 { 2019 2023 if (tolower(*mask) != tolower(*name)) … … 2033 2037 /* 2034 2038 * match_comp: 2035 * compare a single component (directory name or file name) of the 2036 * paths, for all styles which need component-by-component matching. 2037 * MASK and NAME point to the start of a component of the wildcard and 2038 * the name to be checked, respectively. Comparing stops at the next 2039 * separator. The FLAGS argument is the same as that of fnmatch(). 2039 * compares a single component (directory name or file 2040 * name) of the paths, for all styles which need 2041 * component-by-component matching. MASK and NAME point 2042 * to the start of a component of the wildcard and the 2043 * name to be checked, respectively. Comparing stops at 2044 * the next separator. The FLAGS argument is the same as 2045 * that of fnmatch(). 2046 * 2040 2047 * Return FNM_MATCH iff MASK and NAME match. 2041 2048 * … … 2049 2056 const unsigned char *s; 2050 2057 2051 switch (flags & _FNM_STYLE_MASK)2052 { 2053 case _FNM_OS2:2054 case _FNM_DOS:2058 switch (flags & FNM_STYLE_MASK) 2059 { 2060 case FNM_OS2: 2061 case FNM_DOS: 2055 2062 2056 2063 /* For OS/2 and DOS styles, we add an implicit dot at the end of … … 2080 2087 /* 2081 2088 * match_unix: 2082 * match complete paths for Unix styles. The FLAGS argument is the 2083 * same as that of fnmatch(). COMP points to the start of the current 2084 * component in NAME. Return FNM_MATCH iff MASK and NAME match. The 2089 * matches complete paths for Unix styles. 2090 * 2091 * The FLAGS argument is the same as that of fnmatch(). 2092 * COMP points to the start of the current component in 2093 * NAME. Return FNM_MATCH iff MASK and NAME match. The 2085 2094 * backslash character is used for escaping ? and * unless 2086 2095 * FNM_NOESCAPE is set. … … 2110 2119 if (*name == 0) 2111 2120 return FNM_MATCH; 2112 if ((flags & _FNM_PATHPREFIX) && IS_UNIX_COMP_SEP(*name))2121 if ((flags & FNM_PATHPREFIX) && IS_UNIX_COMP_SEP(*name)) 2113 2122 return FNM_MATCH; 2114 2123 return FNM_NOMATCH; … … 2164 2173 2165 2174 if (!(IS_UNIX_COMP_SEP(*name) 2166 || ((flags & _FNM_PATHPREFIX) && *name == 02175 || ((flags & FNM_PATHPREFIX) && *name == 0 2167 2176 && (mask[1] == 0 2168 2177 || (!(flags & FNM_NOESCAPE) && mask[1] == '\\' … … 2292 2301 /* All other characters match themselves. */ 2293 2302 2294 if (flags & _FNM_IGNORECASE)2303 if (flags & FNM_IGNORECASE) 2295 2304 { 2296 2305 if (tolower(*mask) != tolower(*name)) … … 2327 2336 unsigned flags) 2328 2337 { 2329 int m_drive, n_drive, 2330 rc; 2338 int m_drive, 2339 n_drive, 2340 rc; 2331 2341 2332 2342 /* Match and skip the drive name if present. */ … … 2339 2349 if (m_drive == -1 || n_drive == -1) 2340 2350 return FNM_NOMATCH; 2341 if (!(flags & _FNM_IGNORECASE))2351 if (!(flags & FNM_IGNORECASE)) 2342 2352 return FNM_NOMATCH; 2343 2353 if (tolower(m_drive) != tolower(n_drive)) … … 2359 2369 * "\*\server\path". Ditto for /. */ 2360 2370 2361 switch (flags & _FNM_STYLE_MASK)2362 { 2363 case _FNM_OS2:2364 case _FNM_DOS:2371 switch (flags & FNM_STYLE_MASK) 2372 { 2373 case FNM_OS2: 2374 case FNM_DOS: 2365 2375 2366 2376 if (IS_OS2_COMP_SEP(name[0]) && IS_OS2_COMP_SEP(name[1])) … … 2373 2383 break; 2374 2384 2375 case _FNM_POSIX:2385 case FNM_POSIX: 2376 2386 2377 2387 if (name[0] == '/' && name[1] == '/') … … 2404 2414 * is reached even if there are components left in NAME. */ 2405 2415 2406 if (*mask == 0 && (flags & _FNM_PATHPREFIX))2416 if (*mask == 0 && (flags & FNM_PATHPREFIX)) 2407 2417 return FNM_MATCH; 2408 2418 … … 2436 2446 */ 2437 2447 2438 BOOL strhMatchOS2(const unsigned char* pcszMask, // in: mask (e.g. "*.txt") 2439 const unsigned char* pcszName) // in: string to check (e.g. "test.txt") 2440 { 2441 return ((BOOL)(_fnmatch_unsigned(pcszMask, 2442 pcszName, 2443 _FNM_OS2 | _FNM_IGNORECASE) 2448 BOOL strhMatchOS2(const char *pcszMask, // in: mask (e.g. "*.txt") 2449 const char *pcszName) // in: string to check (e.g. "test.txt") 2450 { 2451 return ((BOOL)(_fnmatch_unsigned((const unsigned char *)pcszMask, 2452 (const unsigned char *)pcszName, 2453 FNM_OS2 | FNM_IGNORECASE) 2454 == FNM_MATCH) 2455 ); 2456 } 2457 2458 /* 2459 *@@ strhMatchExt: 2460 * like strhMatchOS2, but this takes all the flags 2461 * for input. 2462 * 2463 *@@added V0.9.15 (2001-09-14) [umoeller] 2464 */ 2465 2466 BOOL strhMatchExt(const char *pcszMask, // in: mask (e.g. "*.txt") 2467 const char *pcszName, // in: string to check (e.g. "test.txt") 2468 unsigned flags) // in: FNM_* flags 2469 { 2470 return ((BOOL)(_fnmatch_unsigned((const unsigned char *)pcszMask, 2471 (const unsigned char *)pcszName, 2472 flags) 2444 2473 == FNM_MATCH) 2445 2474 );
Note:
See TracChangeset
for help on using the changeset viewer.