Changeset 249
- Timestamp:
- Feb 8, 2003, 9:57:38 PM (23 years ago)
- Location:
- trunk
- Files:
-
- 18 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/helpers/dosh.h
r243 r249 703 703 PSZ pszFileOut, 704 704 ULONG cbFileOut); 705 706 typedef APIRET XWPENTRY FNCBFORALLFILES(const FILEFINDBUF3 *pfb3, 707 PVOID pvCallback); 708 709 APIRET doshForAllFiles(PCSZ pcszSearchMask, 710 ULONG flFile, 711 FNCBFORALLFILES *pfncb, 712 PVOID pvCallback); 705 713 706 714 /* ****************************************************************** -
trunk/include/helpers/nls.h
r242 r249 44 44 #define TYPE_DBCS_1ST 0x0001 45 45 #define TYPE_DBCS_2ND 0x0002 46 47 ULONG XWPENTRY nlsQueryCodepage(VOID); 46 48 47 49 BOOL XWPENTRY nlsDBCS(VOID); -
trunk/include/helpers/xml.h
r187 r249 359 359 const char *pcszName, 360 360 const char *pcszValue, 361 ULONG lenValue, 361 362 PDOMNODE *ppNew); 362 363 363 364 APIRET xmlCreateTextNode(PDOMNODE pParent, 364 365 const char *pcszText, 365 ULONG ulLength,366 ULONG lenText, 366 367 PDOMNODE *ppNew); 367 368 -
trunk/include/helpers/xstring.h
r171 r249 225 225 typedef XSTRENCODE *PXSTRENCODE; 226 226 227 ULONG XWPENTRY xstrEncodeASCII(PXSTRING pxstr); 228 227 229 ULONG XWPENTRY xstrDecode2(PXSTRING pxstr, 228 230 CHAR cKey); -
trunk/make/_sub_compile.in
r243 r249 45 45 !endif 46 46 47 .asm.{$(OUTPUTDIR)}.obj: 48 @echo ### [$@]: Assembling $(@B).asm 49 alp -Sv:ALP -Fdo:$(OUTPUTDIR) $(@B).asm 50 51 52 -
trunk/make/compile_dll_mt.in
r243 r249 13 13 # 14 14 15 !ifndef CC_DLL_MT 16 !error CC_DLL_MT is not defined. 17 !endif 18 15 19 CC = $(CC_DLL_MT) 16 20 17 OUTPUTDIR = $(PROJECT_OUTPUT_DIR) 21 OUTPUTDIR = $(PROJECT_OUTPUT_DIR)\dll_mt 18 22 19 23 !include $(MAKE_INCLUDE_DIR)\_sub_compile.in -
trunk/make/helpers.in
r243 r249 9 9 !endif 10 10 11 !if [@echo $(MAKEDIR)\makefile: PROJECT_BASE_DIR is: $(PROJECT_BASE_DIR)]12 !endif11 # !if [@echo $(MAKEDIR)\makefile: PROJECT_BASE_DIR is: $(PROJECT_BASE_DIR)] 12 # !endif 13 13 14 14 # include setup (compiler options etc.) … … 30 30 OUTPUTDIR = $(HELPERS_OUTPUT_DIR) 31 31 32 !if [@echo $(MAKEDIR)\makefile: helpers OBJs will be written to $(OUTPUTDIR)]33 !endif32 # !if [@echo $(MAKEDIR)\makefile: helpers OBJs will be written to $(OUTPUTDIR)] 33 # !endif 34 34 35 35 !if [@md $(OUTPUTDIR) 2> NUL] … … 69 69 !endif 70 70 71 .asm.{$(OUTPUTDIR)}.obj:72 @echo $(MAKEDIR)\makefile: Assembling $(@B).asm73 alp -Sv:ALP -Fdo:$(OUTPUTDIR) $(@B).asm74 71 75 76 -
trunk/make/link_exe.in
r245 r249 63 63 !endif 64 64 65 !ifndef LINKCMD 66 LINKCMD = $(LINK) 67 !endif 68 65 69 $(MODULESDIR)\$(MODULESTEM).exe: $(LINKOBJS) $(MODULEDEF) $(DEPEND_RES) 66 70 @echo ### [$@]: Linking $(@F) 67 $(LINK ) @<<71 $(LINKCMD) @<< 68 72 /OUT:$@ $(MODULEDEF) $(LINKOBJS) $(PMPRINTF_LIB) 69 73 <<KEEP … … 76 80 !endif 77 81 @cd $(MODULESDIR) 78 $(RUN_MAPSYM) $( @B).map82 $(RUN_MAPSYM) $(MAPDIR)\$(@B).map 79 83 !ifdef CVS_WORK_ROOT_DRIVE 80 84 @$(CVS_WORK_ROOT_DRIVE) -
trunk/src/helpers/dosh.c
r244 r249 3893 3893 } 3894 3894 3895 #define FINDBUFSIZE 0x10000 // 64K 3896 #define FINDCOUNT 500 3897 3898 /* 3899 *@@ doshForAllFiles: 3900 * this calles pfncb for all files in a directory matching 3901 * the given file mask. 3902 * 3903 * This is to avoid having to recode the typical but 3904 * easy-to-get-wrong DosFindFirst/Next loop. 3905 * 3906 * pfncb must be prototyped as follows: 3907 * 3908 + APIRET XWPENTRY fnMyCallback(const FILEFINDBUF3 *pfb3, 3909 + PVOID pvCallback) 3910 * 3911 * On each iteration, it receives the current file-find 3912 * buffer in pfb3. pvCallback is constantly set to what 3913 * was passed in to this function. 3914 * 3915 * The callback will get called for every file returned 3916 * from the loop. This function will automatically 3917 * filter out the stupid "." and ".." directory entries 3918 * that DosFindFirst/Next always return, so the callback 3919 * will never see those. 3920 * 3921 * If the callback returns any value other than NO_ERROR, 3922 * this function aborts and returns that error. The 3923 * exception is that if the callback returns 3924 * ERROR_NO_MORE_FILES, this function will abort also, 3925 * but return NO_ERROR still. This is useful if you are 3926 * looking for a specific file and want to cancel the 3927 * search early without provoking an error. 3928 * 3929 *@@added V1.0.2 (2003-02-03) [umoeller] 3930 */ 3931 3932 APIRET doshForAllFiles(PCSZ pcszSearchMask, // in: search mask (e.g. "C:\dir\*.txt") 3933 ULONG flFile, // in: any of FILE_ARCHIVED | FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_DIRECTORY 3934 FNCBFORALLFILES *pfncb, // in: address of callback function 3935 PVOID pvCallback) // in: parameter passed to callback 3936 { 3937 APIRET arc = NO_ERROR; 3938 HDIR hdirFindHandle = HDIR_CREATE; 3939 ULONG ulFindCount = FINDCOUNT; 3940 3941 PBYTE pbFindBuf; 3942 3943 if (arc = DosAllocMem((PVOID*)&pbFindBuf, 3944 FINDBUFSIZE, 3945 PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE)) 3946 return arc; 3947 3948 arc = DosFindFirst((PSZ)pcszSearchMask, 3949 &hdirFindHandle, 3950 flFile, 3951 pbFindBuf, 3952 FINDBUFSIZE, 3953 &ulFindCount, 3954 FIL_STANDARD); 3955 3956 while ( (arc == NO_ERROR) 3957 || (arc == ERROR_BUFFER_OVERFLOW) 3958 ) 3959 { 3960 ULONG ul; 3961 PFILEFINDBUF3 pfb3 = (PFILEFINDBUF3)pbFindBuf; 3962 3963 for (ul = 0; 3964 ul < ulFindCount; 3965 ul++) 3966 { 3967 // filter out the "." and ".." entries 3968 if (!( (pfb3->attrFile & FILE_DIRECTORY) 3969 && (pfb3->achName[0] == '.') 3970 && ( (pfb3->achName[1] == '\0') 3971 || ( (pfb3->achName[1] == '.') 3972 && (pfb3->achName[2] == '\0') 3973 ) 3974 ) 3975 )) 3976 { 3977 // call callback 3978 if (arc = pfncb(pfb3, pvCallback)) 3979 // callback returned error: 3980 break; 3981 } 3982 3983 // next item in buffer 3984 if (pfb3->oNextEntryOffset) 3985 pfb3 = (PFILEFINDBUF3)( (PBYTE)pfb3 3986 + pfb3->oNextEntryOffset 3987 ); 3988 } 3989 3990 if (!arc) 3991 { 3992 ulFindCount = FINDCOUNT; 3993 arc = DosFindNext(hdirFindHandle, 3994 pbFindBuf, 3995 FINDBUFSIZE, 3996 &ulFindCount); 3997 } 3998 } 3999 4000 // no more files is not an error 4001 if (arc == ERROR_NO_MORE_FILES) 4002 arc = NO_ERROR; 4003 4004 DosFindClose(hdirFindHandle); 4005 4006 DosFreeMem(pbFindBuf); 4007 4008 return arc; 4009 } 4010 3895 4011 /* 3896 4012 *@@category: Helpers\Control program helpers\Module handling -
trunk/src/helpers/helpers_pre.in
r243 r249 10 10 # These will be put into BIN\. 11 11 12 PLAINCOBJS = \ 13 $(OUTPUTDIR)\encodings.obj\ 12 PLAINCOBJS = $(OUTPUTDIR)\encodings.obj\ 14 13 $(OUTPUTDIR)\linklist.obj\ 15 14 $(OUTPUTDIR)\math.obj\ … … 18 17 $(OUTPUTDIR)\xml.obj\ 19 18 20 XMLOBJS = \ 21 $(OUTPUTDIR)\xmlparse.obj\ 19 XMLOBJS = $(OUTPUTDIR)\xmlparse.obj\ 22 20 $(OUTPUTDIR)\xmlrole.obj\ 23 21 $(OUTPUTDIR)\xmltok.obj\ -
trunk/src/helpers/makefile
r245 r249 1 1 # 2 # makefile: 3 # makefile for src/helpers directory. 4 # For use with IBM NMAKE, which comes with the IBM compilers, 5 # the Developer's Toolkit, and the DDK. 2 # See make\readme.txt about an introduction to the make system introduced 3 # in the CVS trunk on 2003-01-28. 6 4 # 7 # This makefile is even more complicated than the other makefiles 8 # because the helpers code has been designed to be independent 9 # of any single project. Presently the helpers code is used in 10 # XWorkplace and WarpIN. As a result, I had to design a way so that 11 # this makefile can produce output in a variable directory, with 12 # variable compiler flags, and so on. This is done via environment 13 # variables passed in from the "parent" makefile of a specific 14 # project. 15 # 16 # Even worse, with V0.9.5, I chose to create a shared runtime DLL 17 # for the various WarpIN executables. For that, I chose to use 18 # a separate makefile (makefile_dll). In order to share make 19 # definitions, these have been put into separate .in files in 20 # this directory, which are included via nmake !include. 21 # 22 # Called from: main makefile 23 # 24 # Required environment variables: 25 # 26 # -- PROJECT_BASE_DIR: where to find setup.in; this should 27 # be the root directory of the project, e.g. "C:\cvs\warpin" 28 # or "C:\cvs\xworkplace" 29 # 30 # -- HELPERS_OUTPUT_DIR: where to create output files (*.obj, helpers.lib) 31 # this should be a "bin" directory (e.g. "C:\cvs\warpin\bin" 32 # 33 # -- CC_HELPERS: compiler command line for compiling C files. 34 # With VAC++, this should include the /Ge+ (compile to EXE) 35 # option to allow linking the library to both EXE and DLL 36 # files. 37 # If you're using the "dll" target, specify /Ge- instead. 38 # 39 # -- MAINMAKERUNNING: if this is NOT defined, this makefile 40 # will recurse to the makefile in $(PROJECT_BASE_DIR). 41 # So to have this makefile run successfully, define this 42 # variable to something. 43 # 44 # This variable was introduced to be able to start a build 45 # process from src\helpers as well. However, when your own 46 # project makefile calls src\helpers\makefile, you must set 47 # this to something. 48 # 49 # Input: ./*.c 50 # 51 # Targets: specify the target(s) to be made, which can be: 52 # 53 # -- "all" (default): create helpers.lib in addition 54 # to all the output .obj files in $(HELPERS_OUTPUT_DIR). 55 # 56 # This contains all helpers (plain C, control program, 57 # and PM). 58 # 59 # This makes linking a bit easier since you don't have to 60 # keep in mind the millions of object files. Still, you 61 # should be sure to include the proper headers in your 62 # code. 63 # 64 # Alternatively, you can call this makefile with certain 65 # targets explicitly specified. However, you must then 66 # make sure that the resulted object files are linked 67 # properly, because some of the more advanced helpers 68 # require other helpers. 69 # 70 # -- "plainc": create "plainc.lib", which contains 71 # platform-independent helpers code only (no control 72 # program helpers, no PM helpers). 73 # 74 # This is included if you specify "all". Use this if 75 # you want a subset of the helpers only. 76 # 77 # -- "cp": create "cp.lib", which contains "plainc" plus 78 # control program helpers. 79 # 80 # This is included if you specify "all". Use this if 81 # you want a subset of the helpers only. 82 # 83 # Edit "setup.in" to set up the make process. 5 # Copyright (C) 1998-2003 Ulrich Mller. 6 # This file is part of the XWorkplace source package. 7 # XWorkplace is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published 9 # by the Free Software Foundation, in version 2 as it comes in the 10 # "COPYING" file of the XWorkplace main distribution. 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 84 15 # 85 16 86 # set up shared environment variables 87 !include ..\..\make\helpers.in 88 # define $(OBJ), which contains all object targets 17 # *************************************************************************** 18 # * 19 # * 1) include generic setup definitions (compiler options etc.) 20 # * 21 # *************************************************************************** 22 23 !include $(PROJECT_BASE_DIR)\config.in 24 !include $(PROJECT_BASE_DIR)\make\setup.in 25 26 # *************************************************************************** 27 # * 28 # * 2) include mode-specific compiler inference rules 29 # * 30 # *************************************************************************** 31 32 !ifndef CC_HELPERS 33 CC_HELPERS = error! 34 !endif 35 36 !ifndef NOINCLUDEDEPEND 37 !ifndef OUTPUTDIR_HELPERS 38 !error OUTPUTDIR_HELPERS is not defined. 39 !endif 40 !endif 41 42 CC = $(CC_HELPERS) 43 OUTPUTDIR = $(OUTPUTDIR_HELPERS) 44 45 !include $(MAKE_INCLUDE_DIR)\_sub_compile.in 46 47 # *************************************************************************** 48 # * 49 # * 3) list objects to be built 50 # * 51 # *************************************************************************** 52 89 53 !include helpers_pre.in 90 54 91 plainc: \ 92 !ifndef MAINMAKERUNNING 93 callmainmake 94 @echo ----- Leaving $(MAKEDIR) 95 !else 96 $(OUTPUTDIR)\plainc.lib 97 #$(OBJS) 98 @echo ----- Leaving $(MAKEDIR) 99 !endif 55 # *************************************************************************** 56 # * 57 # * 4) define specific stuff for linker include 58 # * 59 # *************************************************************************** 100 60 101 cp: \ 102 !ifndef MAINMAKERUNNING 103 callmainmake 104 @echo ----- Leaving $(MAKEDIR) 105 !else 106 $(OUTPUTDIR)\cp.lib 107 #$(OBJS) 108 @echo ----- Leaving $(MAKEDIR) 109 !endif 61 # *************************************************************************** 62 # * 63 # * 5) link executable 64 # * 65 # *************************************************************************** 110 66 111 # Define the main dependency between the output HELPERS.LIB and 112 # all the object files. 113 # $? represents the names of all dependent files that are 114 # out-of-date with respect to the target file. 115 # The exclamation point ( ! ) preceding the LIB command causes NMAKE 116 # to execute the LIB command once for each dependent file in the list. 67 ALLTARGET = $(OUTPUTDIR)\helpers.lib 117 68 118 $(OUTPUTDIR)\helpers.lib: $(OBJS) makefile 119 !ifdef EMX 120 !emxomfar cr $* $? 121 !else 69 # *************************************************************************** 70 # * 71 # * 6) define main target 72 # * 73 # *************************************************************************** 74 75 !include $(MAKE_INCLUDE_DIR)\targets.in 76 77 $(OUTPUTDIR)\helpers.lib: $(OBJS) 122 78 - del $@ 123 79 ilib /nol /nob $@ @<<$(TEMP)\ilib.lnk … … 125 81 ); 126 82 <<KEEP 127 !endif128 83 129 # same thing for cp.lib 130 $(OUTPUTDIR)\cp.lib: $(CPOBJS) makefile 131 !ifdef EMX 132 !emxomfar cr $* $? 133 !else 84 # *************************************************************************** 85 # * 86 # * explicit targets 87 # * 88 # *************************************************************************** 89 90 cp: $(OUTPUTDIR)\helpers_cp.lib 91 92 $(OUTPUTDIR)\helpers_cp.lib: $(CPOBJS) 134 93 - del $@ 135 ilib /nol /nob $@ @<< 94 ilib /nol /nob $@ @<<$(TEMP)\ilib.lnk 136 95 +$(CPOBJS: =&^ 137 96 ); 138 97 <<KEEP 139 !endif140 141 # same thing for plainc.lib142 $(OUTPUTDIR)\plainc.lib: $(PLAINCOBJS) makefile143 !ifdef EMX144 !emxomfar cr $* $?145 !else146 - del $@147 ilib /nol /nob $@ @<<148 +$(PLAINCOBJS: =&^149 );150 <<KEEP151 !endif152 153 !include helpers_post.in154 155 ALLTARGET = $(OUTPUTDIR)\helpers.lib156 157 !include ..\..\make\targets.in158 159 ###################################################160 #161 # "test" target: for test cases162 #163 ###################################################164 165 TESTCASE_DIR = testcase166 167 !undef DEBUGDIALOG168 !ifdef DBGDLG169 DEBUGDIALOG = /DDEBUG_DIALOG_WINDOWS=1170 !endif171 172 TESTCASE_CC_BASE = icc /c /ti+ /w2 /ss /se /D__DEBUG__=1 $(DEBUGDIALOG) /i..\..\include173 174 TESTCASE_CC = $(TESTCASE_CC_BASE) /Fo$(TESTCASE_DIR)\$(@B).obj $(@B).c175 176 .c.{$(TESTCASE_DIR)}.obj:177 @echo $(MAKEDIR)\makefile: Compiling $(@B).c178 @echo INCLUDE is $(INCLUDE)179 $(TESTCASE_CC)180 181 # testcase executables182 TESTCASE_TARGETS = \183 dosh.exe \184 dialog.exe \185 exeh.exe \186 fdlg.exe \187 fdlg_pm.exe \188 xmap.exe \189 vcard.exe190 191 # dialog.exe192 DIALOG_TEST_OBJS = \193 $(TESTCASE_DIR)\dialog.obj \194 $(TESTCASE_DIR)\_test_dialog.obj \195 $(TESTCASE_DIR)\winh.obj \196 $(TESTCASE_DIR)\xstring.obj \197 $(TESTCASE_DIR)\linklist.obj \198 $(TESTCASE_DIR)\cctl_checkcnr.obj \199 $(TESTCASE_DIR)\cnrh.obj \200 $(TESTCASE_DIR)\comctl.obj \201 $(TESTCASE_DIR)\stringh.obj \202 $(TESTCASE_DIR)\dosh.obj \203 $(TESTCASE_DIR)\except.obj \204 $(TESTCASE_DIR)\debug.obj \205 $(TESTCASE_DIR)\textview.obj \206 $(TESTCASE_DIR)\textv_html.obj \207 $(TESTCASE_DIR)\tmsgfile.obj \208 $(TESTCASE_DIR)\datetime.obj \209 $(TESTCASE_DIR)\tree.obj \210 $(TESTCASE_DIR)\gpih.obj \211 $(TESTCASE_DIR)\prfh.obj \212 $(TESTCASE_DIR)\nls.obj \213 $(TESTCASE_DIR)\nlscache.obj214 215 $(TESTCASE_DIR)\dialog.obj: ..\..\include\helpers\dialog.h216 $(TESTCASE_DIR)\_test_dialog.obj: ..\..\include\helpers\dialog.h217 218 dialog.exe: $(DIALOG_TEST_OBJS)219 ilink /debug /optfunc /pmtype:pm $(DIALOG_TEST_OBJS) pmprintf.lib /o:$@220 221 # dosh.exe222 DOSH_TEST_OBJS = \223 $(TESTCASE_DIR)\dosh.obj \224 $(TESTCASE_DIR)\_test_dosh.obj225 226 dosh.exe: $(DOSH_TEST_OBJS)227 ilink /debug /optfunc /pmtype:vio $(DOSH_TEST_OBJS) pmprintf.lib /o:$@228 229 # exeh.exe230 EXEH_TEST_OBJS = \231 $(TESTCASE_DIR)\dosh.obj \232 $(TESTCASE_DIR)\exeh.obj \233 $(TESTCASE_DIR)\stringh.obj \234 $(TESTCASE_DIR)\xstring.obj \235 $(TESTCASE_DIR)\_test_exeh.obj236 237 exeh.exe: $(EXEH_TEST_OBJS)238 ilink /debug /optfunc /pmtype:vio $(EXEH_TEST_OBJS) pmprintf.lib /o:$@239 240 # fdlg.exe241 FDLG_TEST_OBJS_SHARED = \242 $(TESTCASE_DIR)\comctl.obj \243 $(TESTCASE_DIR)\cctl_cnr.obj \244 $(TESTCASE_DIR)\cctl_cnr_dtls.obj \245 $(TESTCASE_DIR)\cctl_toolbar.obj \246 $(TESTCASE_DIR)\cctl_tooltip.obj \247 $(TESTCASE_DIR)\cctl_xframe.obj \248 $(TESTCASE_DIR)\cnrh.obj \249 $(TESTCASE_DIR)\dosh.obj \250 $(TESTCASE_DIR)\gpih.obj \251 $(TESTCASE_DIR)\linklist.obj \252 $(TESTCASE_DIR)\winh.obj \253 $(TESTCASE_DIR)\stringh.obj \254 $(TESTCASE_DIR)\xstring.obj \255 $(TESTCASE_DIR)\prfh.obj \256 $(TESTCASE_DIR)\tree.obj \257 $(TESTCASE_DIR)\nls.obj \258 $(TESTCASE_DIR)\nlscache.obj259 260 FDLG_TEST_OBJS = \261 $(FDLG_TEST_OBJS_SHARED) \262 $(TESTCASE_DIR)\_call_filedlg.obj263 264 $(TESTCASE_DIR)\_call_filedlg_pm.obj: _call_filedlg.c265 @echo $(MAKEDIR)\makefile: Compiling $(@B).c (PM version)266 @echo INCLUDE is $(INCLUDE)267 $(TESTCASE_CC_BASE) /D__USE_PM_CNR__=1 /Fo$(TESTCASE_DIR)\_call_filedlg_pm.obj _call_filedlg.c268 269 FDLG_TEST_OBJS_PM = \270 $(FDLG_TEST_OBJS_SHARED) \271 $(TESTCASE_DIR)\_call_filedlg_pm.obj272 273 fdlg.exe: $(FDLG_TEST_OBJS) makefile274 @echo $(MAKEDIR)\makefile: Linking $@275 ilink /nologo /debug /pmtype:pm $(FDLG_TEST_OBJS) pmprintf.lib /o:$@276 277 fdlg_pm.exe: $(FDLG_TEST_OBJS_PM) makefile278 @echo $(MAKEDIR)\makefile: Linking $@ (PM version)279 ilink /nologo /debug /pmtype:pm $(FDLG_TEST_OBJS_PM) pmprintf.lib /o:$@280 281 # xmap.exe282 MAP_TEST_OBJS = \283 $(TESTCASE_DIR)\map_vac.obj \284 $(TESTCASE_DIR)\linklist.obj \285 $(TESTCASE_DIR)\stringh.obj \286 $(TESTCASE_DIR)\xstring.obj \287 $(TESTCASE_DIR)\_test_map.obj288 289 xmap.exe: $(MAP_TEST_OBJS)290 ilink /debug /optfunc /pmtype:vio $(MAP_TEST_OBJS) pmprintf.lib /o:$@291 292 # vcard.exe293 VCARD_TEST_OBJS = \294 $(TESTCASE_DIR)\vcard.obj \295 $(TESTCASE_DIR)\_test_vcard.obj \296 $(TESTCASE_DIR)\xstring.obj \297 $(TESTCASE_DIR)\stringh.obj \298 $(TESTCASE_DIR)\linklist.obj \299 $(TESTCASE_DIR)\dosh.obj \300 $(TESTCASE_DIR)\prfh.obj \301 $(TESTCASE_DIR)\nls.obj \302 $(TESTCASE_DIR)\except.obj \303 $(TESTCASE_DIR)\debug.obj \304 $(TESTCASE_DIR)\tree.obj305 306 vcard.exe: $(VCARD_TEST_OBJS)307 ilink /debug /pmtype:vio $(VCARD_TEST_OBJS) /o:$@308 309 test: $(TESTCASE_TARGETS)310 98 311 99 -
trunk/src/helpers/nls.c
r243 r249 88 88 COUNTRYCODE G_cc = { 0, 0 }; 89 89 DBCSVECTOR G_aDBCSVector[8]; 90 91 /* 92 *@@ nlsQueryCodepage: 93 * returns the current process codepage as a ULONG. 94 * 95 *@@added V1.0.2 (2003-02-07) [umoeller] 96 */ 97 98 ULONG nlsQueryCodepage(VOID) 99 { 100 ULONG acp[8]; 101 ULONG cb = 0; 102 if (DosQueryCp(sizeof(acp), 103 acp, 104 &cb)) 105 return 437; // I think this is still the system default 106 107 return acp[0]; 108 } 90 109 91 110 /* -
trunk/src/helpers/xml.c
r238 r249 714 714 * 715 715 *@@added V0.9.9 (2001-02-14) [umoeller] 716 *@@changed V1.0.2 (2003-02-07) [umoeller]: added lenValue param 716 717 */ 717 718 … … 719 720 const char *pcszName, // in: attribute name (null-terminated) 720 721 const char *pcszValue, // in: attribute value (null-terminated) 722 ULONG lenValue, // in: length of value (must be specified) 721 723 PDOMNODE *ppNew) 722 724 { 723 APIRET arc = NO_ERROR; 725 APIRET arc; 726 PDOMNODE pNew = NULL; 724 727 725 728 if ( (!pElement) 726 729 || (pElement->NodeBase.ulNodeType != DOMNODE_ELEMENT) 727 730 ) 728 arc = ERROR_DOM_NO_ELEMENT; 729 else 730 { 731 PDOMNODE pNew = NULL; 732 if (!(arc = xmlCreateDomNode(pElement, // this takes care of adding to the list 733 DOMNODE_ATTRIBUTE, 734 pcszName, 735 0, 736 &pNew))) 737 { 738 pNew->pstrNodeValue = xstrCreate(0); 739 xstrcpy(pNew->pstrNodeValue, pcszValue, 0); 740 741 *ppNew = pNew; 742 } 731 return ERROR_DOM_NO_ELEMENT; 732 733 if (!(arc = xmlCreateDomNode(pElement, // this takes care of adding to the list 734 DOMNODE_ATTRIBUTE, 735 pcszName, 736 0, 737 &pNew))) 738 { 739 pNew->pstrNodeValue = xstrCreate(lenValue + 1); 740 xstrcpy(pNew->pstrNodeValue, pcszValue, lenValue); 741 742 *ppNew = pNew; 743 743 } 744 744 … … 759 759 APIRET xmlCreateTextNode(PDOMNODE pParent, // in: parent element node 760 760 const char *pcszText, // in: ptr to start of text 761 ULONG ulLength,// in: length of *pcszText761 ULONG lenText, // in: length of *pcszText 762 762 PDOMNODE *ppNew) 763 763 { … … 772 772 { 773 773 PSZ pszNodeValue; 774 if (pszNodeValue = (PSZ)malloc( ulLength+ 1))774 if (pszNodeValue = (PSZ)malloc(lenText + 1)) 775 775 { 776 memcpy(pszNodeValue, pcszText, ulLength);777 pszNodeValue[ ulLength] = '\0';776 memcpy(pszNodeValue, pcszText, lenText); 777 pszNodeValue[lenText] = '\0'; 778 778 pNew->pstrNodeValue = xstrCreate(0); 779 779 xstrset(pNew->pstrNodeValue, pszNodeValue); … … 1552 1552 { 1553 1553 PDOMNODE pAttrib; 1554 PCSZ pcszValue = papcszAttribs[i + 1]; // attr value 1554 1555 if (!(pDom->arcDOM = xmlCreateAttributeNode(pNew, // element, 1555 1556 papcszAttribs[i], // attr name 1556 papcszAttribs[i + 1], // attr value 1557 pcszValue, 1558 strlen(pcszValue), 1557 1559 &pAttrib))) 1558 1560 { … … 2428 2430 * the int at index 0x94 to 0x00f6. 2429 2431 * 2432 * -- pfnExternalHandler should be specified if you want the 2433 * parser to be able to handle @external_entities. Since 2434 * the parser has no concept of storage whatsoever, it is 2435 * the responsibility of this callback to supply the parser 2436 * with additional XML data when an external entity reference 2437 * is encountered. 2438 * 2439 * This callback must have the following prototype: 2440 * 2441 + APIRET APIENTRY ParseExternal(PXMLDOM pDom, 2442 + XML_Parser pSubParser, 2443 + const char *pcszSystemID, 2444 + const char *pcszPublicID) 2445 + 2446 * 2447 * The callback will be called for each reference that refers 2448 * to an external entity. pSubParser is a sub-parser created 2449 * by the DOM engine, and pcszSystemID and pcszPublicID 2450 * reference the external entity by means of a URI. As always 2451 * with XML, the system ID is required, while the public ID is 2452 * optional. 2453 * 2454 * In the simplest case, this code could look as follows: 2455 * 2456 + APIRET arc = ERROR_FILE_NOT_FOUND; 2457 + 2458 + if (pcszSystemID) 2459 + { 2460 + PSZ pszContents = NULL; 2461 + if (!(arc = doshLoadTextFile(pcszSystemID, 2462 + &pszContents, 2463 + NULL))) 2464 + { 2465 + if (!XML_Parse(pSubParser, 2466 + pszContents, 2467 + strlen(pszContents), 2468 + TRUE)) 2469 + arc = -1; 2470 + 2471 + free(pszContents); 2472 + } 2473 + } 2474 + 2475 + return arc; 2476 * 2430 2477 * -- pvCallbackUser is a user parameter which is simply stored 2431 2478 * in the XMLDOM struct which is returned. Since the XMLDOM … … 2435 2482 *@@added V0.9.9 (2001-02-14) [umoeller] 2436 2483 *@@changed V0.9.14 (2001-08-09) [umoeller]: added DF_DROP_WHITESPACE support 2484 *@@changed V0.9.20 (2002-07-06) [umoeller]: added static system IDs 2437 2485 */ 2438 2486 … … 2445 2493 PXMLDOM *ppDom) // out: XMLDOM struct created 2446 2494 { 2447 APIRET arc = NO_ERROR; 2448 2449 PXMLDOM pDom = (PXMLDOM)malloc(sizeof(*pDom)); 2450 if (!pDom) 2451 arc = ERROR_NOT_ENOUGH_MEMORY; 2452 else 2453 { 2454 PDOMNODE pDocument = NULL; 2455 2456 memset(pDom, 0, sizeof(XMLDOM)); 2457 2458 pDom->flParserFlags = flParserFlags; 2459 pDom->pfnGetCPData = pfnGetCPData; 2460 pDom->pfnExternalHandler = pfnExternalHandler; 2461 pDom->pvCallbackUser = pvCallbackUser; 2462 2463 // these added with V0.9.20 (2002-07-06) [umoeller] 2464 pDom->paSystemIds = paSystemIds; 2465 pDom->cSystemIds = cSystemIds; 2466 2467 lstInit(&pDom->llElementStack, 2468 TRUE); // auto-free 2469 2470 // create the document node 2471 if (!(arc = xmlCreateDomNode(NULL, // no parent 2472 DOMNODE_DOCUMENT, 2473 NULL, 2474 0, 2475 &pDocument))) 2495 APIRET arc = NO_ERROR; 2496 PXMLDOM pDom; 2497 PDOMNODE pDocument = NULL; 2498 2499 if (!(pDom = (PXMLDOM)malloc(sizeof(*pDom)))) 2500 return ERROR_NOT_ENOUGH_MEMORY; 2501 2502 memset(pDom, 0, sizeof(XMLDOM)); 2503 2504 pDom->flParserFlags = flParserFlags; 2505 pDom->pfnGetCPData = pfnGetCPData; 2506 pDom->pfnExternalHandler = pfnExternalHandler; 2507 pDom->pvCallbackUser = pvCallbackUser; 2508 2509 // these added with V0.9.20 (2002-07-06) [umoeller] 2510 pDom->paSystemIds = paSystemIds; 2511 pDom->cSystemIds = cSystemIds; 2512 2513 lstInit(&pDom->llElementStack, 2514 TRUE); // auto-free 2515 2516 // create the document node 2517 if (!(arc = xmlCreateDomNode(NULL, // no parent 2518 DOMNODE_DOCUMENT, 2519 NULL, 2520 0, 2521 &pDocument))) 2522 { 2523 // store the document in the DOM 2524 pDom->pDocumentNode = (PDOMDOCUMENTNODE)pDocument; 2525 2526 // push the document on the stack so the handlers 2527 // will append to that 2528 PushElementStack(pDom, 2529 pDocument); 2530 2531 pDom->pParser = XML_ParserCreate(NULL); 2532 2533 if (!pDom->pParser) 2534 arc = ERROR_NOT_ENOUGH_MEMORY; 2535 else 2476 2536 { 2477 // store the document in the DOM 2478 pDom->pDocumentNode = (PDOMDOCUMENTNODE)pDocument; 2479 2480 // push the document on the stack so the handlers 2481 // will append to that 2482 PushElementStack(pDom, 2483 pDocument); 2484 2485 pDom->pParser = XML_ParserCreate(NULL); 2486 2487 if (!pDom->pParser) 2488 arc = ERROR_NOT_ENOUGH_MEMORY; 2489 else 2537 if (pfnGetCPData) 2538 XML_SetUnknownEncodingHandler(pDom->pParser, 2539 UnknownEncodingHandler, 2540 pDom); // user data 2541 2542 XML_SetParamEntityParsing(pDom->pParser, 2543 XML_PARAM_ENTITY_PARSING_ALWAYS); 2544 2545 XML_SetElementHandler(pDom->pParser, 2546 StartElementHandler, 2547 EndElementHandler); 2548 2549 XML_SetCharacterDataHandler(pDom->pParser, 2550 CharacterDataHandler); 2551 2552 // XML_SetProcessingInstructionHandler(XML_Parser parser, 2553 // XML_ProcessingInstructionHandler handler); 2554 2555 2556 if (flParserFlags & DF_PARSECOMMENTS) 2557 XML_SetCommentHandler(pDom->pParser, 2558 CommentHandler); 2559 2560 if ( (pfnExternalHandler) 2561 || (cSystemIds) // V0.9.20 (2002-07-06) [umoeller] 2562 ) 2563 XML_SetExternalEntityRefHandler(pDom->pParser, 2564 ExternalEntityRefHandler); 2565 2566 if (flParserFlags & DF_PARSEDTD) 2490 2567 { 2491 if (pfnGetCPData) 2492 XML_SetUnknownEncodingHandler(pDom->pParser, 2493 UnknownEncodingHandler, 2494 pDom); // user data 2568 XML_SetDoctypeDeclHandler(pDom->pParser, 2569 StartDoctypeDeclHandler, 2570 EndDoctypeDeclHandler); 2571 2572 XML_SetNotationDeclHandler(pDom->pParser, 2573 NotationDeclHandler); 2574 2575 XML_SetElementDeclHandler(pDom->pParser, 2576 ElementDeclHandler); 2577 2578 XML_SetAttlistDeclHandler(pDom->pParser, 2579 AttlistDeclHandler); 2580 2581 XML_SetEntityDeclHandler(pDom->pParser, 2582 EntityDeclHandler); 2495 2583 2496 2584 XML_SetParamEntityParsing(pDom->pParser, 2497 2585 XML_PARAM_ENTITY_PARSING_ALWAYS); 2498 2499 XML_SetElementHandler(pDom->pParser,2500 StartElementHandler,2501 EndElementHandler);2502 2503 XML_SetCharacterDataHandler(pDom->pParser,2504 CharacterDataHandler);2505 2506 // XML_SetProcessingInstructionHandler(XML_Parser parser,2507 // XML_ProcessingInstructionHandler handler);2508 2509 2510 if (flParserFlags & DF_PARSECOMMENTS)2511 XML_SetCommentHandler(pDom->pParser,2512 CommentHandler);2513 2514 if ( (pfnExternalHandler)2515 || (cSystemIds) // V0.9.20 (2002-07-06) [umoeller]2516 )2517 XML_SetExternalEntityRefHandler(pDom->pParser,2518 ExternalEntityRefHandler);2519 2520 if (flParserFlags & DF_PARSEDTD)2521 {2522 XML_SetDoctypeDeclHandler(pDom->pParser,2523 StartDoctypeDeclHandler,2524 EndDoctypeDeclHandler);2525 2526 XML_SetNotationDeclHandler(pDom->pParser,2527 NotationDeclHandler);2528 2529 XML_SetElementDeclHandler(pDom->pParser,2530 ElementDeclHandler);2531 2532 XML_SetAttlistDeclHandler(pDom->pParser,2533 AttlistDeclHandler);2534 2535 XML_SetEntityDeclHandler(pDom->pParser,2536 EntityDeclHandler);2537 2538 XML_SetParamEntityParsing(pDom->pParser,2539 XML_PARAM_ENTITY_PARSING_ALWAYS);2540 }2541 2542 // XML_SetXmlDeclHandler ... do we care for this? I guess not2543 2544 // pass the XMLDOM as user data to the handlers2545 XML_SetUserData(pDom->pParser,2546 pDom);2547 2586 } 2587 2588 // XML_SetXmlDeclHandler ... do we care for this? I guess not 2589 2590 // pass the XMLDOM as user data to the handlers 2591 XML_SetUserData(pDom->pParser, 2592 pDom); 2548 2593 } 2549 2594 } -
trunk/src/helpers/xmldefs.c
r97 r249 222 222 * use a different encoding for its characters. 223 223 * 224 * In the document entity, the encoding declaration is part of the XML225 * @text_declaration.224 * In the document entity, the encoding declaration is part of the 225 * XML @text_declaration. 226 226 * 227 227 * Also see @entities. -
trunk/src/helpers/xstring.c
r245 r249 1258 1258 1259 1259 // static encoding table for xstrEncode 1260 STATICPSZ apszEncoding[] =1260 static PSZ apszEncoding[] = 1261 1261 { 1262 1262 "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", … … 1365 1365 // use the static encoding table for speed 1366 1366 memcpy(pszDestCurr, 1367 apszEncoding[( unsigned char)pcszEncode[ulEncode]],1367 apszEncoding[(UCHAR)pcszEncode[ulEncode]], 1368 1368 3); 1369 1369 pszDestCurr += 3; … … 1385 1385 *pszDestCurr = 0; 1386 1386 1387 xstrcpy(pxstr, pszDest, pszDestCurr-pszDest); 1387 xstrcpy(pxstr, pszDest, pszDestCurr - pszDest); 1388 } 1389 1390 free(pszDest); 1391 } 1392 1393 return ulrc; 1394 } 1395 1396 /* 1397 *@@ xstrEncodeASCII: 1398 * like xstrEncode, but instead of encoding characters 1399 * from an array given by the caller, this encodes all 1400 * non-ASCII characters (i.e. >= 128) plus the '%' char. 1401 * 1402 *@@added V1.0.2 (2003-02-07) [umoeller] 1403 */ 1404 1405 ULONG xstrEncodeASCII(PXSTRING pxstr) // in/out: string to convert 1406 { 1407 ULONG ulrc = 0, 1408 ul, 1409 ulEncodeLength; 1410 1411 if ( (pxstr) 1412 && (pxstr->ulLength) 1413 ) 1414 { 1415 PSZ pszDest = (PSZ)malloc(pxstr->ulLength * 3 1416 + 1), 1417 pszDestCurr = pszDest; 1418 1419 if (pszDest) 1420 { 1421 for (ul = 0; 1422 ul < pxstr->ulLength; 1423 ul++) 1424 { 1425 if ( ((UCHAR)pxstr->psz[ul] >= 128) 1426 || (pxstr->psz[ul] == '%') 1427 ) 1428 { 1429 memcpy(pszDestCurr, 1430 apszEncoding[(UCHAR)pxstr->psz[ul]], 1431 3); 1432 pszDestCurr += 3; 1433 ulrc++; 1434 goto iterate; 1435 } 1436 1437 *pszDestCurr++ = pxstr->psz[ul]; 1438 1439 iterate: 1440 ; 1441 } 1442 } 1443 1444 // something was encoded; update pxstr 1445 if (ulrc) 1446 { 1447 *pszDestCurr = 0; 1448 1449 xstrcpy(pxstr, pszDest, pszDestCurr - pszDest); 1388 1450 } 1389 1451
Note:
See TracChangeset
for help on using the changeset viewer.