2 * Author: Jochen Tucht 2003/12/09
3 * Copyright (C) Jochen Tucht
5 * Purpose: supplementary classes and functions for Merge7z
9 * *** SECURITY ALERT ***
10 * Be aware of 2. a) of the GNU General Public License. Please log your changes
11 * at the end of this comment.
13 * License: This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 DATE: BY: DESCRIPTION:
29 ========== ================== ================================================
35 #ifndef StrIsIntlEqual
37 #define StrIsIntlEqual StrIsIntlEqualW
39 #define StrIsIntlEqual StrIsIntlEqualA
46 * @brief Construct and throw a Complain object containing an error message.
48 Complain::Complain(LPCTSTR format, ...)
50 wvsprintf(msg, format, (va_list)(&format + 1));
55 * @brief Report error to user. To be called from within catch block.
57 int Complain::Alert(HWND hwndParent, UINT flags)
59 return MessageBox(hwndParent, msg, 0, flags);
63 * @brief Complain that some DLL failed to CreateObject() something.
65 void ComplainCreateObject(HMODULE handle, LPCTSTR name)
67 TCHAR module[MAX_PATH];
68 ::GetModuleFileName(handle, module, sizeof module);
69 Complain(_T("%.300s Failed to create %.300s"), module, name);
73 * @brief Complain that something could not be found.
75 void ComplainNotFound(LPCTSTR name)
77 Complain(_T("Not found: %.300s"), name);
81 * @brief Complain that something could not be opened.
83 void ComplainCantOpen(LPCTSTR name)
85 Complain(_T("Can't open: %.300s"), name);
89 * @brief Release interface until ref count reaches 0.
91 * Very bad practice in general, but helps avoiding resource leaks
92 * due to inaccurate ref counting.
94 void NTAPI Release(IUnknown *punk)
98 ULONG Release = punk->Release();
107 * @brief Find a keyword within an EnumList, and return its numeric value.
109 EnumList::Find(LPCTSTR r, BOOL fCaseSens) const
111 static const TCHAR trim[] = _T(".;:() ");
112 int cch = StrCSpn(r += StrSpn(r, trim), trim);
115 while (LPCTSTR p = StrChr(q, '('))
117 q = StrChr(++p, ')');
118 if (StrIsIntlEqual(fCaseSens, p, r, cch) && q - p == cch)