Commits

Anonymous committed 265bc74

建立初始化库,里面包含:
* ATL/WTL
* PCRE
* GetOptX

Comments (0)

Files changed (58)

bin/bison.exe

Binary file added.
+/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
+#line 3 "bison.simple"
+
+/* Skeleton output parser for bison,
+   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+/* As a special exception, when this file is copied by Bison into a
+   Bison output file, you may use that output file without restriction.
+   This special exception was added by the Free Software Foundation
+   in version 1.24 of Bison.  */
+
+#ifndef alloca
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#else /* not GNU C.  */
+#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
+#include <alloca.h>
+#else /* not sparc */
+#if defined (MSDOS) && !defined (__TURBOC__)
+#include <malloc.h>
+#else /* not MSDOS, or __TURBOC__ */
+#if defined(_AIX)
+#include <malloc.h>
+ #pragma alloca
+#else /* not MSDOS, __TURBOC__, or _AIX */
+#ifdef __hpux
+#ifdef __cplusplus
+extern "C" {
+void *alloca (unsigned int);
+};
+#else /* not __cplusplus */
+void *alloca ();
+#endif /* not __cplusplus */
+#endif /* __hpux */
+#endif /* not _AIX */
+#endif /* not MSDOS, or __TURBOC__ */
+#endif /* not sparc.  */
+#endif /* not GNU C.  */
+#endif /* alloca not defined.  */
+
+/* This is the parser code that is written into each bison parser
+  when the %semantic_parser declaration is not specified in the grammar.
+  It was written by Richard Stallman by simplifying the hairy parser
+  used when %semantic_parser is specified.  */
+
+/* Note: there must be only one dollar sign in this file.
+   It is replaced by the list of actions, each action
+   as one case of the switch.  */
+
+#define yyerrok		(yyerrstatus = 0)
+#define yyclearin	(yychar = YYEMPTY)
+#define YYEMPTY		-2
+#define YYEOF		0
+#define YYACCEPT	return(0)
+#define YYABORT 	return(1)
+#define YYERROR		goto yyerrlab1
+/* Like YYERROR except do call yyerror.
+   This remains here temporarily to ease the
+   transition to the new meaning of YYERROR, for GCC.
+   Once GCC version 2 has supplanted version 1, this can go.  */
+#define YYFAIL		goto yyerrlab
+#define YYRECOVERING()  (!!yyerrstatus)
+#define YYBACKUP(token, value) \
+do								\
+  if (yychar == YYEMPTY && yylen == 1)				\
+    { yychar = (token), yylval = (value);			\
+      yychar1 = YYTRANSLATE (yychar);				\
+      YYPOPSTACK;						\
+      goto yybackup;						\
+    }								\
+  else								\
+    { yyerror ("syntax error: cannot back up"); YYERROR; }	\
+while (0)
+
+#define YYTERROR	1
+#define YYERRCODE	256
+
+#ifndef YYPURE
+#define YYLEX		yylex()
+#endif
+
+#ifdef YYPURE
+#ifdef YYLSP_NEEDED
+#ifdef YYLEX_PARAM
+#define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
+#else
+#define YYLEX		yylex(&yylval, &yylloc)
+#endif
+#else /* not YYLSP_NEEDED */
+#ifdef YYLEX_PARAM
+#define YYLEX		yylex(&yylval, YYLEX_PARAM)
+#else
+#define YYLEX		yylex(&yylval)
+#endif
+#endif /* not YYLSP_NEEDED */
+#endif
+
+/* If nonreentrant, generate the variables here */
+
+#ifndef YYPURE
+
+int	yychar;			/*  the lookahead symbol		*/
+YYSTYPE	yylval;			/*  the semantic value of the		*/
+				/*  lookahead symbol			*/
+
+#ifdef YYLSP_NEEDED
+YYLTYPE yylloc;			/*  location data for the lookahead	*/
+				/*  symbol				*/
+#endif
+
+int yynerrs;			/*  number of parse errors so far       */
+#endif  /* not YYPURE */
+
+#if YYDEBUG != 0
+int yydebug;			/*  nonzero means print parse trace	*/
+/* Since this is uninitialized, it does not stop multiple parsers
+   from coexisting.  */
+#endif
+
+/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/
+
+#ifndef	YYINITDEPTH
+#define YYINITDEPTH 200
+#endif
+
+/*  YYMAXDEPTH is the maximum size the stacks can grow to
+    (effective only if the built-in stack extension method is used).  */
+
+#if YYMAXDEPTH == 0
+#undef YYMAXDEPTH
+#endif
+
+#ifndef YYMAXDEPTH
+#define YYMAXDEPTH 10000
+#endif
+
+/* Prevent warning if -Wstrict-prototypes.  */
+#ifdef __GNUC__
+int yyparse (void);
+#endif
+
+#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
+#define __yy_memcpy(FROM,TO,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
+#else				/* not GNU C or C++ */
+#ifndef __cplusplus
+
+/* This is the most reliable way to avoid incompatibilities
+   in available built-in functions on various systems.  */
+static void
+__yy_memcpy (from, to, count)
+     char *from;
+     char *to;
+     int count;
+{
+  register char *f = from;
+  register char *t = to;
+  register int i = count;
+
+  while (i-- > 0)
+    *t++ = *f++;
+}
+
+#else /* __cplusplus */
+
+/* This is the most reliable way to avoid incompatibilities
+   in available built-in functions on various systems.  */
+static void
+__yy_memcpy (char *from, char *to, int count)
+{
+  register char *f = from;
+  register char *t = to;
+  register int i = count;
+
+  while (i-- > 0)
+    *t++ = *f++;
+}
+
+#endif
+#endif
+
+#line 192 "bison.simple"
+
+/* The user can define YYPARSE_PARAM as the name of an argument to be passed
+   into yyparse.  The argument should have type void *.
+   It should actually point to an object.
+   Grammar actions can access the variable by casting it
+   to the proper pointer type.  */
+
+#ifdef YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
+#else
+#define YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL
+#endif
+
+int
+yyparse(YYPARSE_PARAM)
+     YYPARSE_PARAM_DECL
+{
+  register int yystate;
+  register int yyn;
+  register short *yyssp;
+  register YYSTYPE *yyvsp;
+  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
+  int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */
+
+  short	yyssa[YYINITDEPTH];	/*  the state stack			*/
+  YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/
+
+  short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
+  YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */
+
+#ifdef YYLSP_NEEDED
+  YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
+  YYLTYPE *yyls = yylsa;
+  YYLTYPE *yylsp;
+
+#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
+#else
+#define YYPOPSTACK   (yyvsp--, yyssp--)
+#endif
+
+  int yystacksize = YYINITDEPTH;
+
+#ifdef YYPURE
+  int yychar;
+  YYSTYPE yylval;
+  int yynerrs;
+#ifdef YYLSP_NEEDED
+  YYLTYPE yylloc;
+#endif
+#endif
+
+  YYSTYPE yyval;		/*  the variable used to return		*/
+				/*  semantic values from the action	*/
+				/*  routines				*/
+
+  int yylen;
+
+#if YYDEBUG != 0
+  if (yydebug)
+    fprintf(stderr, "Starting parse\n");
+#endif
+
+  yystate = 0;
+  yyerrstatus = 0;
+  yynerrs = 0;
+  yychar = YYEMPTY;		/* Cause a token to be read.  */
+
+  /* Initialize stack pointers.
+     Waste one element of value and location stack
+     so that they stay on the same level as the state stack.
+     The wasted elements are never initialized.  */
+
+  yyssp = yyss - 1;
+  yyvsp = yyvs;
+#ifdef YYLSP_NEEDED
+  yylsp = yyls;
+#endif
+
+/* Push a new state, which is found in  yystate  .  */
+/* In all cases, when you get here, the value and location stacks
+   have just been pushed. so pushing a state here evens the stacks.  */
+yynewstate:
+
+  *++yyssp = yystate;
+
+  if (yyssp >= yyss + yystacksize - 1)
+    {
+      /* Give user a chance to reallocate the stack */
+      /* Use copies of these so that the &'s don't force the real ones into memory. */
+      YYSTYPE *yyvs1 = yyvs;
+      short *yyss1 = yyss;
+#ifdef YYLSP_NEEDED
+      YYLTYPE *yyls1 = yyls;
+#endif
+
+      /* Get the current used size of the three stacks, in elements.  */
+      int size = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+      /* Each stack pointer address is followed by the size of
+	 the data in use in that stack, in bytes.  */
+#ifdef YYLSP_NEEDED
+      /* This used to be a conditional around just the two extra args,
+	 but that might be undefined if yyoverflow is a macro.  */
+      yyoverflow("parser stack overflow",
+		 &yyss1, size * sizeof (*yyssp),
+		 &yyvs1, size * sizeof (*yyvsp),
+		 &yyls1, size * sizeof (*yylsp),
+		 &yystacksize);
+#else
+      yyoverflow("parser stack overflow",
+		 &yyss1, size * sizeof (*yyssp),
+		 &yyvs1, size * sizeof (*yyvsp),
+		 &yystacksize);
+#endif
+
+      yyss = yyss1; yyvs = yyvs1;
+#ifdef YYLSP_NEEDED
+      yyls = yyls1;
+#endif
+#else /* no yyoverflow */
+      /* Extend the stack our own way.  */
+      if (yystacksize >= YYMAXDEPTH)
+	{
+	  yyerror("parser stack overflow");
+	  return 2;
+	}
+      yystacksize *= 2;
+      if (yystacksize > YYMAXDEPTH)
+	yystacksize = YYMAXDEPTH;
+      yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
+      __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
+      yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
+      __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
+#ifdef YYLSP_NEEDED
+      yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
+      __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
+#endif
+#endif /* no yyoverflow */
+
+      yyssp = yyss + size - 1;
+      yyvsp = yyvs + size - 1;
+#ifdef YYLSP_NEEDED
+      yylsp = yyls + size - 1;
+#endif
+
+#if YYDEBUG != 0
+      if (yydebug)
+	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
+#endif
+
+      if (yyssp >= yyss + yystacksize - 1)
+	YYABORT;
+    }
+
+#if YYDEBUG != 0
+  if (yydebug)
+    fprintf(stderr, "Entering state %d\n", yystate);
+#endif
+
+  goto yybackup;
+ yybackup:
+
+/* Do appropriate processing given the current state.  */
+/* Read a lookahead token if we need one and don't already have one.  */
+/* yyresume: */
+
+  /* First try to decide what to do without reference to lookahead token.  */
+
+  yyn = yypact[yystate];
+  if (yyn == YYFLAG)
+    goto yydefault;
+
+  /* Not known => get a lookahead token if don't already have one.  */
+
+  /* yychar is either YYEMPTY or YYEOF
+     or a valid token in external form.  */
+
+  if (yychar == YYEMPTY)
+    {
+#if YYDEBUG != 0
+      if (yydebug)
+	fprintf(stderr, "Reading a token: ");
+#endif
+      yychar = YYLEX;
+    }
+
+  /* Convert token to internal form (in yychar1) for indexing tables with */
+
+  if (yychar <= 0)		/* This means end of input. */
+    {
+      yychar1 = 0;
+      yychar = YYEOF;		/* Don't call YYLEX any more */
+
+#if YYDEBUG != 0
+      if (yydebug)
+	fprintf(stderr, "Now at end of input.\n");
+#endif
+    }
+  else
+    {
+      yychar1 = YYTRANSLATE(yychar);
+
+#if YYDEBUG != 0
+      if (yydebug)
+	{
+	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
+	  /* Give the individual parser a way to print the precise meaning
+	     of a token, for further debugging info.  */
+#ifdef YYPRINT
+	  YYPRINT (stderr, yychar, yylval);
+#endif
+	  fprintf (stderr, ")\n");
+	}
+#endif
+    }
+
+  yyn += yychar1;
+  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
+    goto yydefault;
+
+  yyn = yytable[yyn];
+
+  /* yyn is what to do for this token type in this state.
+     Negative => reduce, -yyn is rule number.
+     Positive => shift, yyn is new state.
+       New state is final state => don't bother to shift,
+       just return success.
+     0, or most negative number => error.  */
+
+  if (yyn < 0)
+    {
+      if (yyn == YYFLAG)
+	goto yyerrlab;
+      yyn = -yyn;
+      goto yyreduce;
+    }
+  else if (yyn == 0)
+    goto yyerrlab;
+
+  if (yyn == YYFINAL)
+    YYACCEPT;
+
+  /* Shift the lookahead token.  */
+
+#if YYDEBUG != 0
+  if (yydebug)
+    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
+#endif
+
+  /* Discard the token being shifted unless it is eof.  */
+  if (yychar != YYEOF)
+    yychar = YYEMPTY;
+
+  *++yyvsp = yylval;
+#ifdef YYLSP_NEEDED
+  *++yylsp = yylloc;
+#endif
+
+  /* count tokens shifted since error; after three, turn off error status.  */
+  if (yyerrstatus) yyerrstatus--;
+
+  yystate = yyn;
+  goto yynewstate;
+
+/* Do the default action for the current state.  */
+yydefault:
+
+  yyn = yydefact[yystate];
+  if (yyn == 0)
+    goto yyerrlab;
+
+/* Do a reduction.  yyn is the number of a rule to reduce with.  */
+yyreduce:
+  yylen = yyr2[yyn];
+  if (yylen > 0)
+    yyval = yyvsp[1-yylen]; /* implement default value of the action */
+
+#if YYDEBUG != 0
+  if (yydebug)
+    {
+      int i;
+
+      fprintf (stderr, "Reducing via rule %d (line %d), ",
+	       yyn, yyrline[yyn]);
+
+      /* Print the symbols being reduced, and their result.  */
+      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
+	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
+      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
+    }
+#endif
+
+$   /* the action file gets copied in in place of this dollarsign */
+#line 487 "bison.simple"
+
+  yyvsp -= yylen;
+  yyssp -= yylen;
+#ifdef YYLSP_NEEDED
+  yylsp -= yylen;
+#endif
+
+#if YYDEBUG != 0
+  if (yydebug)
+    {
+      short *ssp1 = yyss - 1;
+      fprintf (stderr, "state stack now");
+      while (ssp1 != yyssp)
+	fprintf (stderr, " %d", *++ssp1);
+      fprintf (stderr, "\n");
+    }
+#endif
+
+  *++yyvsp = yyval;
+
+#ifdef YYLSP_NEEDED
+  yylsp++;
+  if (yylen == 0)
+    {
+      yylsp->first_line = yylloc.first_line;
+      yylsp->first_column = yylloc.first_column;
+      yylsp->last_line = (yylsp-1)->last_line;
+      yylsp->last_column = (yylsp-1)->last_column;
+      yylsp->text = 0;
+    }
+  else
+    {
+      yylsp->last_line = (yylsp+yylen-1)->last_line;
+      yylsp->last_column = (yylsp+yylen-1)->last_column;
+    }
+#endif
+
+  /* Now "shift" the result of the reduction.
+     Determine what state that goes to,
+     based on the state we popped back to
+     and the rule number reduced by.  */
+
+  yyn = yyr1[yyn];
+
+  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
+  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+    yystate = yytable[yystate];
+  else
+    yystate = yydefgoto[yyn - YYNTBASE];
+
+  goto yynewstate;
+
+yyerrlab:   /* here on detecting error */
+
+  if (! yyerrstatus)
+    /* If not already recovering from an error, report this error.  */
+    {
+      ++yynerrs;
+
+#ifdef YYERROR_VERBOSE
+      yyn = yypact[yystate];
+
+      if (yyn > YYFLAG && yyn < YYLAST)
+	{
+	  int size = 0;
+	  char *msg;
+	  int x, count;
+
+	  count = 0;
+	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
+	  for (x = (yyn < 0 ? -yyn : 0);
+	       x < (sizeof(yytname) / sizeof(char *)); x++)
+	    if (yycheck[x + yyn] == x)
+	      size += strlen(yytname[x]) + 15, count++;
+	  msg = (char *) malloc(size + 15);
+	  if (msg != 0)
+	    {
+	      strcpy(msg, "parse error");
+
+	      if (count < 5)
+		{
+		  count = 0;
+		  for (x = (yyn < 0 ? -yyn : 0);
+		       x < (sizeof(yytname) / sizeof(char *)); x++)
+		    if (yycheck[x + yyn] == x)
+		      {
+			strcat(msg, count == 0 ? ", expecting `" : " or `");
+			strcat(msg, yytname[x]);
+			strcat(msg, "'");
+			count++;
+		      }
+		}
+	      yyerror(msg);
+	      free(msg);
+	    }
+	  else
+	    yyerror ("parse error; also virtual memory exceeded");
+	}
+      else
+#endif /* YYERROR_VERBOSE */
+	yyerror("parse error");
+    }
+
+  goto yyerrlab1;
+yyerrlab1:   /* here on error raised explicitly by an action */
+
+  if (yyerrstatus == 3)
+    {
+      /* if just tried and failed to reuse lookahead token after an error, discard it.  */
+
+      /* return failure if at end of input */
+      if (yychar == YYEOF)
+	YYABORT;
+
+#if YYDEBUG != 0
+      if (yydebug)
+	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
+#endif
+
+      yychar = YYEMPTY;
+    }
+
+  /* Else will try to reuse lookahead token
+     after shifting the error token.  */
+
+  yyerrstatus = 3;		/* Each real token shifted decrements this */
+
+  goto yyerrhandle;
+
+yyerrdefault:  /* current state does not do anything special for the error token. */
+
+#if 0
+  /* This is wrong; only states that explicitly want error tokens
+     should shift them.  */
+  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
+  if (yyn) goto yydefault;
+#endif
+
+yyerrpop:   /* pop the current state because it cannot handle the error token */
+
+  if (yyssp == yyss) YYABORT;
+  yyvsp--;
+  yystate = *--yyssp;
+#ifdef YYLSP_NEEDED
+  yylsp--;
+#endif
+
+#if YYDEBUG != 0
+  if (yydebug)
+    {
+      short *ssp1 = yyss - 1;
+      fprintf (stderr, "Error: state stack now");
+      while (ssp1 != yyssp)
+	fprintf (stderr, " %d", *++ssp1);
+      fprintf (stderr, "\n");
+    }
+#endif
+
+yyerrhandle:
+
+  yyn = yypact[yystate];
+  if (yyn == YYFLAG)
+    goto yyerrdefault;
+
+  yyn += YYTERROR;
+  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
+    goto yyerrdefault;
+
+  yyn = yytable[yyn];
+  if (yyn < 0)
+    {
+      if (yyn == YYFLAG)
+	goto yyerrpop;
+      yyn = -yyn;
+      goto yyreduce;
+    }
+  else if (yyn == 0)
+    goto yyerrpop;
+
+  if (yyn == YYFINAL)
+    YYACCEPT;
+
+#if YYDEBUG != 0
+  if (yydebug)
+    fprintf(stderr, "Shifting error token, ");
+#endif
+
+  *++yyvsp = yylval;
+#ifdef YYLSP_NEEDED
+  *++yylsp = yylloc;
+#endif
+
+  yystate = yyn;
+  goto yynewstate;
+}
Binary file added.

bin/premake4.exe

Binary file added.

cfg/common.inc.lua

+--
+
+configuration { }
+    flags
+    {
+        'Unicode',
+        -- ���뻹�Dz�Ҫ��̬����crt���Ͼ�����ϵͳ���Ķ���
+        --'StaticRuntime',
+        'ExtraWarnings',
+        'FatalWarnings',
+    }
+    defines { '_UNICODE', 'UNICODE', }
+    includedirs { '../include', '..', }
+    files
+    {
+        -- for reference
+        '../../README.txt',
+    }
+
+configuration 'Debug'
+    targetsuffix 'd'
+    flags { 'Symbols' }
+    defines { '_DEBUG', 'DEBUG' }
+
+configuration 'Release'
+    flags { 'Optimize' }
+    defines { 'NDEBUG' }
+
+configuration 'windows'
+    defines { '_WIN32', 'WIN32', 'WINDOWS' }
+
+configuration 'x32'
+    defines { 'X86' }
+    flags { 'No64BitChecks' }
+
+configuration 'x64'
+    defines { 'X64' }
+
+configuration 'vs*'
+    defines { '_CRT_SECURE_NO_WARNINGS', '_CRT_NON_CONFORMING_SWPRINTFS' }
+    buildoptions { '/wd4512', '/wd4100', '/wd4565', '/wd4273' }
+
+configuration { 'windows', 'WindowedApp' }
+    flags { 'WinMain' }
+--
+
+configuration { }
+    files
+    {
+        '../stdafx.*', '../xconfig.h',
+    }
+
+configuration 'vs*'
+    pchheader 'stdafx.h'
+    pchsource '../stdafx.cpp'
+--
+
+configuration { }
+    includedirs { '../include/pcre' }
+    libdirs { '../lib' }
+
+-- ����tccʱʹ�þ�̬����
+configuration 'not gmake'
+    defines { 'PCRE_STATIC' }
+
+configuration { 'sharedlib or consoleapp or windowedapp', 'windows', 'Release' }
+    links { 'pcre' }
+
+configuration { 'sharedlib or consoleapp or windowedapp', 'windows', 'Debug', 'not gmake' }
+    links { 'pcred' }
+
+configuration { 'sharedlib or consoleapp or windowedapp', 'gmake' }
+    links { 'pcre' }

cfg/share.inc.lua

+--
+
+configuration { }
+    includedirs { '../include' }
+    libdirs { '../lib' }
+
+
+configuration 'sharedlib or consoleapp or windowedapp'
+    links { 'share' }
+--
+
+configuration { }
+    includedirs { '../include/atl', '../include/wtl', }
+    files
+    {
+        '../include/atl/*.h',
+        '../include/wtl/*.h',
+    }
+    defines { '_USE_WTL', '_WTL_SUPPORT_SDK_ATL3', '_WTL_USE_CSTRING' }

include/atl/atl.h

+
+
+/* this ALWAYS GENERATED file contains the definitions for the interfaces */
+
+
+ /* File created by MIDL compiler version 6.00.0366 */
+/* at Fri May 21 10:49:57 2010
+ */
+/* Compiler settings for atl.idl:
+    Oicf, W1, Zp8, env=Win32 (32b run)
+    protocol : dce , ms_ext, c_ext, robust
+    error checks: allocation ref bounds_check enum stub_data 
+    VC __declspec() decoration level: 
+         __declspec(uuid()), __declspec(selectany), __declspec(novtable)
+         DECLSPEC_UUID(), MIDL_INTERFACE()
+*/
+//@@MIDL_FILE_HEADING(  )
+
+#pragma warning( disable: 4049 )  /* more than 64k source lines */
+
+
+/* verify that the <rpcndr.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCNDR_H_VERSION__
+#define __REQUIRED_RPCNDR_H_VERSION__ 475
+#endif
+
+#include "rpc.h"
+#include "rpcndr.h"
+
+#ifndef __RPCNDR_H_VERSION__
+#error this stub requires an updated version of <rpcndr.h>
+#endif // __RPCNDR_H_VERSION__
+
+
+#ifndef __atl_h__
+#define __atl_h__
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+#ifndef ATL_H
+#define ATL_H
+#endif
+
+/* Forward Declarations */ 
+
+/* header files for imported files */
+#include "oaidl.h"
+#include "atliface.h"
+
+#ifdef __cplusplus
+extern "C"{
+#endif 
+
+void * __RPC_USER MIDL_user_allocate(size_t);
+void __RPC_USER MIDL_user_free( void * ); 
+
+
+#ifndef __ATLLib_LIBRARY_DEFINED__
+#define __ATLLib_LIBRARY_DEFINED__
+
+/* library ATLLib */
+/* [helpstring][version][uuid] */ 
+
+
+
+
+EXTERN_C const IID LIBID_ATLLib;
+#endif /* __ATLLib_LIBRARY_DEFINED__ */
+
+/* Additional Prototypes for ALL interfaces */
+
+/* end of Additional Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
+
+#endif // ATL_H

include/atl/atlbase.h

+// This is a part of the Active Template Library.
+// Copyright (C) 1996-1998 Microsoft Corporation
+// All rights reserved.
+//
+// This source code is only intended as a supplement to the
+// Active Template Library Reference and related
+// electronic documentation provided with the library.
+// See these sources for detailed information regarding the
+// Active Template Library product.
+
+#ifndef __ATLBASE_H__
+#define __ATLBASE_H__
+
+#ifndef __cplusplus
+        #error ATL requires C++ compilation (use a .cpp suffix)
+#endif
+
+#ifndef _ATL_NO_PRAGMA_WARNINGS
+#pragma warning(disable: 4201) // nameless unions are part of C++
+#pragma warning(disable: 4127) // constant expression
+#pragma warning(disable: 4505) // unreferenced local function has been removed
+#pragma warning(disable: 4512) // can't generate assignment operator (so what?)
+#pragma warning(disable: 4514) // unreferenced inlines are common
+#pragma warning(disable: 4103) // pragma pack
+#pragma warning(disable: 4702) // unreachable code
+#pragma warning(disable: 4237) // bool
+#pragma warning(disable: 4710) // function couldn't be inlined
+#pragma warning(disable: 4355) // 'this' : used in base member initializer list
+#pragma warning(disable: 4097) // typedef name used as synonym for class-name
+#pragma warning(disable: 4786) // identifier was truncated in the debug information
+#pragma warning(disable: 4268) // const static/global data initialized to zeros
+#pragma warning(disable: 4291) // allow placement new
+#endif //!_ATL_NO_PRAGMA_WARNINGS
+
+#include <atldef.h>
+
+#include <windows.h>
+#include <winnls.h>
+#include <ole2.h>
+
+#include <comcat.h>
+#include <stddef.h>
+
+#ifdef new
+#pragma push_macro("new")
+#define _ATL_REDEF_NEW
+#undef new
+#endif
+
+#include <tchar.h>
+#include <malloc.h>
+
+#ifndef _ATL_NO_DEBUG_CRT
+// Warning: if you define the above symbol, you will have
+// to provide your own definition of the ATLASSERT(x) macro
+// in order to compile ATL
+        #include <crtdbg.h>
+#endif
+
+#include <olectl.h>
+#include <winreg.h>
+#include <atliface.h>
+
+#ifdef _DEBUG
+#include <stdio.h>
+#include <stdarg.h>
+#endif
+
+#include <atlconv.h>
+
+#include <shlwapi.h>
+
+#define _ATL_TYPELIB_INDEX_LENGTH 10
+#define _ATL_QUOTES_SPACE 2
+
+#pragma pack(push, _ATL_PACKING)
+
+#if defined(_ATL_DLL)
+        #pragma comment(lib, "atl.lib")
+#endif
+
+extern "C" const __declspec(selectany) GUID LIBID_ATLLib = {0x44EC0535,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
+extern "C" const __declspec(selectany) CLSID CLSID_Registrar = {0x44EC053A,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
+extern "C" const __declspec(selectany) IID IID_IRegistrar = {0x44EC053B,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
+extern "C" const __declspec(selectany) IID IID_IAxWinHostWindow = {0xb6ea2050,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
+extern "C" const __declspec(selectany) IID IID_IAxWinAmbientDispatch = {0xb6ea2051,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
+extern "C" const __declspec(selectany) IID IID_IInternalConnection = {0x72AD0770,0x6A9F,0x11d1,{0xBC,0xEC,0x00,0x60,0x08,0x8F,0x44,0x4E}};
+extern "C" const __declspec(selectany) IID IID_IDocHostUIHandlerDispatch = {0x425B5AF0,0x65F1,0x11d1,{0x96,0x11,0x00,0x00,0xF8,0x1E,0x0D,0x0D}};
+
+#ifndef _ATL_DLL_IMPL
+namespace ATL
+{
+#endif
+
+struct _ATL_CATMAP_ENTRY
+{
+   int iType;
+   const CATID* pcatid;
+};
+
+#define _ATL_CATMAP_ENTRY_END 0
+#define _ATL_CATMAP_ENTRY_IMPLEMENTED 1
+#define _ATL_CATMAP_ENTRY_REQUIRED 2
+
+typedef HRESULT (WINAPI _ATL_CREATORFUNC)(void* pv, REFIID riid, LPVOID* ppv);
+typedef HRESULT (WINAPI _ATL_CREATORARGFUNC)(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw);
+typedef HRESULT (WINAPI _ATL_MODULEFUNC)(DWORD_PTR dw);
+typedef LPCTSTR (WINAPI _ATL_DESCRIPTIONFUNC)();
+typedef const struct _ATL_CATMAP_ENTRY* (_ATL_CATMAPFUNC)();
+typedef void (__stdcall _ATL_TERMFUNC)(DWORD_PTR dw);
+
+struct _ATL_TERMFUNC_ELEM
+{
+        _ATL_TERMFUNC* pFunc;
+        DWORD_PTR dw;
+        _ATL_TERMFUNC_ELEM* pNext;
+};
+
+struct _ATL_OBJMAP_ENTRY
+{
+        const CLSID* pclsid;
+        HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister);
+        _ATL_CREATORFUNC* pfnGetClassObject;
+        _ATL_CREATORFUNC* pfnCreateInstance;
+        IUnknown* pCF;
+        DWORD dwRegister;
+        _ATL_DESCRIPTIONFUNC* pfnGetObjectDescription;
+        _ATL_CATMAPFUNC* pfnGetCategoryMap;
+        HRESULT WINAPI RevokeClassObject()
+        {
+                return CoRevokeClassObject(dwRegister);
+        }
+        HRESULT WINAPI RegisterClassObject(DWORD dwClsContext, DWORD dwFlags)
+        {
+                IUnknown* p = NULL;
+                if (pfnGetClassObject == NULL)
+                        return S_OK;
+                HRESULT hRes = pfnGetClassObject(pfnCreateInstance, IID_IUnknown, (LPVOID*) &p);
+                if (SUCCEEDED(hRes))
+                        hRes = CoRegisterClassObject(*pclsid, p, dwClsContext, dwFlags, &dwRegister);
+                if (p != NULL)
+                        p->Release();
+                return hRes;
+        }
+// Added in ATL 3.0
+        void (WINAPI *pfnObjectMain)(bool bStarting);
+};
+
+struct _ATL_REGMAP_ENTRY
+{
+        LPCOLESTR     szKey;
+        LPCOLESTR     szData;
+};
+
+struct _AtlCreateWndData
+{
+        void* m_pThis;
+        DWORD m_dwThreadID;
+        _AtlCreateWndData* m_pNext;
+};
+
+struct _ATL_MODULE_21
+{
+// Attributes
+public:
+        UINT cbSize;
+        HINSTANCE m_hInst;
+        HINSTANCE m_hInstResource;
+        HINSTANCE m_hInstTypeLib;
+        _ATL_OBJMAP_ENTRY* m_pObjMap;
+        LONG m_nLockCnt;
+        HANDLE m_hHeap;
+        union
+        {
+                CRITICAL_SECTION m_csTypeInfoHolder;
+                CRITICAL_SECTION m_csStaticDataInit;
+        };
+        CRITICAL_SECTION m_csWindowCreate;
+        CRITICAL_SECTION m_csObjMap;
+};
+
+struct _ATL_MODULE_30
+{
+// Attributes
+public:
+        UINT cbSize;
+        HINSTANCE m_hInst;
+        HINSTANCE m_hInstResource;
+        HINSTANCE m_hInstTypeLib;
+        _ATL_OBJMAP_ENTRY* m_pObjMap;
+        LONG m_nLockCnt;
+        HANDLE m_hHeap;
+        union
+        {
+                CRITICAL_SECTION m_csTypeInfoHolder;
+                CRITICAL_SECTION m_csStaticDataInit;
+        };
+        CRITICAL_SECTION m_csWindowCreate;
+        CRITICAL_SECTION m_csObjMap;
+// Original Size = 100
+// Stuff added in ATL 3.0
+        DWORD dwAtlBuildVer;
+        _AtlCreateWndData* m_pCreateWndList;
+        bool m_bDestroyHeap;
+        GUID* pguidVer;
+        DWORD m_dwHeaps;    // Number of heaps we have (-1)
+        HANDLE* m_phHeaps;
+        int m_nHeap;        // Which heap to choose from
+        _ATL_TERMFUNC_ELEM* m_pTermFuncs;
+};
+
+#if _ATL_VER == 0x0300
+typedef _ATL_MODULE_30 _ATL_MODULE;
+#else
+struct _ATL_MODULE
+{
+// Attributes
+public:
+        UINT cbSize;
+        HINSTANCE m_hInst;
+        HINSTANCE m_hInstResource;
+        HINSTANCE m_hInstTypeLib;
+        _ATL_OBJMAP_ENTRY* m_pObjMap;
+        LONG m_nLockCnt;
+        HANDLE m_hHeap;
+        union
+        {
+                CRITICAL_SECTION m_csTypeInfoHolder;
+                CRITICAL_SECTION m_csStaticDataInit;
+        };
+        CRITICAL_SECTION m_csWindowCreate;
+        CRITICAL_SECTION m_csObjMap;
+// Original Size = 100
+// Stuff added in ATL 3.0
+        DWORD dwAtlBuildVer;
+        _AtlCreateWndData* m_pCreateWndList;
+        bool m_bDestroyHeap;
+        GUID* pguidVer;
+        DWORD m_dwHeaps;    // Number of heaps we have (-1)
+        HANDLE* m_phHeaps;
+        int m_nHeap;        // Which heap to choose from
+        _ATL_TERMFUNC_ELEM* m_pTermFuncs;
+// Stuff added in ATL 6.1
+        LONG m_nNextWindowID;
+};
+#endif
+
+const int _nAtlModuleVer21Size = sizeof( _ATL_MODULE_21 );
+const int _nAtlModuleVer30Size = sizeof( _ATL_MODULE_30 );
+
+//This define makes debugging asserts easier.
+#define _ATL_SIMPLEMAPENTRY ((_ATL_CREATORARGFUNC*)1)
+
+struct _ATL_INTMAP_ENTRY
+{
+        const IID* piid;       // the interface id (IID)
+        DWORD_PTR dw;
+        _ATL_CREATORARGFUNC* pFunc; //NULL:end, 1:offset, n:ptr
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Thunks for __stdcall member functions
+
+
+#if defined(_M_IX86)
+#pragma pack(push,1)
+struct _stdcallthunk
+{
+        DWORD   m_mov;          // mov dword ptr [esp+0x4], pThis (esp+0x4 is hWnd)
+        DWORD   m_this;         //
+        BYTE    m_jmp;          // jmp WndProc
+        DWORD   m_relproc;      // relative jmp
+        BOOL Init(DWORD_PTR proc, void* pThis)
+        {
+                m_mov = 0x042444C7;  //C7 44 24 0C
+                m_this = PtrToUlong(pThis);
+                m_jmp = 0xe9;
+                m_relproc = DWORD((INT_PTR)proc - ((INT_PTR)this+sizeof(_stdcallthunk)));
+                // write block from data cache and
+                //  flush from instruction cache
+                FlushInstructionCache(GetCurrentProcess(), this, sizeof(_stdcallthunk));
+                return TRUE;
+        }
+};
+#pragma pack(pop)
+
+PVOID __stdcall __AllocStdCallThunk(VOID);
+VOID  __stdcall __FreeStdCallThunk(PVOID);
+
+#define AllocStdCallThunk() __AllocStdCallThunk()
+#define FreeStdCallThunk(p) __FreeStdCallThunk(p)
+
+#pragma comment(lib, "atlthunk.lib")
+
+#elif defined (_M_AMD64)
+#pragma pack(push,2)
+struct _stdcallthunk
+{
+    USHORT  RcxMov;         // mov rcx, pThis
+    ULONG64 RcxImm;         // 
+    USHORT  RaxMov;         // mov rax, target
+    ULONG64 RaxImm;         //
+    USHORT  RaxJmp;         // jmp target
+    BOOL Init(DWORD_PTR proc, void *pThis)
+    {
+        RcxMov = 0xb948;          // mov rcx, pThis
+        RcxImm = (ULONG64)pThis;  // 
+        RaxMov = 0xb848;          // mov rax, target
+        RaxImm = (ULONG64)proc;   //
+        RaxJmp = 0xe0ff;          // jmp rax
+        FlushInstructionCache(GetCurrentProcess(), this, sizeof(_stdcallthunk));
+        return TRUE;
+    }
+};
+#pragma pack(pop)
+
+PVOID __AllocStdCallThunk(VOID);
+VOID  __FreeStdCallThunk(PVOID);
+
+#define AllocStdCallThunk() __AllocStdCallThunk()
+#define FreeStdCallThunk(p) __FreeStdCallThunk(p)
+
+#elif defined(_M_IA64)
+#pragma comment(lib, "atl21asm.lib")
+#pragma pack(push,8)
+extern "C" LRESULT CALLBACK _WndProcThunkProc( HWND, UINT, WPARAM, LPARAM );
+struct _FuncDesc
+{
+        void* pfn;
+        void* gp;
+};
+struct _stdcallthunk
+{
+        _FuncDesc m_funcdesc;
+        void* m_pFunc;
+        void* m_pThis;
+        BOOL Init(DWORD_PTR proc, void* pThis)
+        {
+                const _FuncDesc* pThunkProc;
+
+                pThunkProc = reinterpret_cast< const _FuncDesc* >( _WndProcThunkProc );
+                m_funcdesc.pfn = pThunkProc->pfn;
+                m_funcdesc.gp = &m_pFunc;
+                m_pFunc = reinterpret_cast< void* >( proc );
+                m_pThis = pThis;
+                ::FlushInstructionCache( GetCurrentProcess(), this, sizeof( _stdcallthunk ) );
+                return TRUE;
+        }
+};
+#pragma pack(pop)
+#define AllocStdCallThunk() HeapAlloc(GetProcessHeap(),0,sizeof(_stdcallthunk))
+#define FreeStdCallThunk(p) HeapFree(GetProcessHeap(), 0, p)
+#else
+#error Only AMD64, IA64, and X86 supported
+#endif
+
+class CDynamicStdCallThunk
+{
+public:
+        _stdcallthunk *pThunk;
+
+        CDynamicStdCallThunk()
+        {
+                pThunk = NULL;
+        }
+
+        ~CDynamicStdCallThunk()
+        {
+                if (pThunk)
+                        FreeStdCallThunk(pThunk);
+        }
+
+        BOOL Init(DWORD_PTR proc, void *pThis)
+        {
+                if (!pThunk) {
+                    pThunk = static_cast<_stdcallthunk *>(AllocStdCallThunk());
+                    if (pThunk == NULL) {
+                        return FALSE;
+                    }
+                }
+
+                if ((proc == 0) && (pThis == NULL)) {
+                    return TRUE;
+                }
+
+                return pThunk->Init(proc, pThis);
+        }
+};
+typedef CDynamicStdCallThunk CStdCallThunk;
+
+/////////////////////////////////////////////////////////////////////////////
+// QI Support
+
+ATLAPI AtlInternalQueryInterface(void* pThis,
+        const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, void** ppvObject);
+
+/////////////////////////////////////////////////////////////////////////////
+// Smart Pointer helpers
+
+ATLAPI_(IUnknown*) AtlComPtrAssign(IUnknown** pp, IUnknown* lp);
+ATLAPI_(IUnknown*) AtlComQIPtrAssign(IUnknown** pp, IUnknown* lp, REFIID riid);
+
+/////////////////////////////////////////////////////////////////////////////
+// Inproc Marshaling helpers
+
+ATLAPI AtlFreeMarshalStream(IStream* pStream);
+ATLAPI AtlMarshalPtrInProc(IUnknown* pUnk, const IID& iid, IStream** ppStream);
+ATLAPI AtlUnmarshalPtr(IStream* pStream, const IID& iid, IUnknown** ppUnk);
+
+ATLAPI_(BOOL) AtlWaitWithMessageLoop(HANDLE hEvent);
+
+/////////////////////////////////////////////////////////////////////////////
+// Connection Point Helpers
+
+ATLAPI AtlAdvise(IUnknown* pUnkCP, IUnknown* pUnk, const IID& iid, LPDWORD pdw);
+ATLAPI AtlUnadvise(IUnknown* pUnkCP, const IID& iid, DWORD dw);
+
+/////////////////////////////////////////////////////////////////////////////
+// IDispatch Error handling
+
+ATLAPI AtlSetErrorInfo(const CLSID& clsid, LPCOLESTR lpszDesc,
+        DWORD dwHelpID, LPCOLESTR lpszHelpFile, const IID& iid, HRESULT hRes,
+        HINSTANCE hInst);
+
+/////////////////////////////////////////////////////////////////////////////
+// Module
+
+ATLAPI AtlModuleRegisterClassObjects(_ATL_MODULE* pM, DWORD dwClsContext, DWORD dwFlags);
+ATLAPI AtlModuleRevokeClassObjects(_ATL_MODULE* pM);
+ATLAPI AtlModuleGetClassObject(_ATL_MODULE* pM, REFCLSID rclsid, REFIID riid, LPVOID* ppv);
+ATLAPI AtlModuleRegisterServer(_ATL_MODULE* pM, BOOL bRegTypeLib, const CLSID* pCLSID = NULL);
+ATLAPI AtlModuleUnregisterServer(_ATL_MODULE* pM, const CLSID* pCLSID = NULL);
+ATLAPI AtlModuleUnregisterServerEx(_ATL_MODULE* pM, BOOL bUnRegTypeLib, const CLSID* pCLSID = NULL);
+ATLAPI AtlModuleUpdateRegistryFromResourceD(_ATL_MODULE*pM, LPCOLESTR lpszRes,
+        BOOL bRegister, struct _ATL_REGMAP_ENTRY* pMapEntries, IRegistrar* pReg = NULL);
+ATLAPI AtlModuleRegisterTypeLib(_ATL_MODULE* pM, LPCOLESTR lpszIndex);
+ATLAPI AtlModuleUnRegisterTypeLib(_ATL_MODULE* pM, LPCOLESTR lpszIndex);
+ATLAPI AtlModuleLoadTypeLib(_ATL_MODULE* pM, LPCOLESTR lpszIndex, BSTR* pbstrPath, ITypeLib** ppTypeLib);
+
+ATLAPI AtlModuleInit(_ATL_MODULE* pM, _ATL_OBJMAP_ENTRY* p, HINSTANCE h);
+ATLAPI AtlModuleTerm(_ATL_MODULE* pM);
+ATLAPI_(DWORD) AtlGetVersion(void* pReserved);
+ATLAPI_(void) AtlModuleAddCreateWndData(_ATL_MODULE* pM, _AtlCreateWndData* pData, void* pObject);
+ATLAPI_(void*) AtlModuleExtractCreateWndData(_ATL_MODULE* pM);
+ATLAPI AtlModuleAddTermFunc(_ATL_MODULE* pM, _ATL_TERMFUNC* pFunc, DWORD_PTR dw);
+
+#ifndef _ATL_DLL_IMPL
+}; //namespace ATL
+#endif
+
+namespace ATL
+{
+
+/////////////////////////////////////////////////////////////////////////////
+// Error to HRESULT helpers
+
+inline HRESULT AtlHresultFromLastError()
+{
+        DWORD dwErr = ::GetLastError();
+        return HRESULT_FROM_WIN32(dwErr);
+}
+
+inline HRESULT AtlHresultFromWin32(DWORD nError)
+{
+        return( HRESULT_FROM_WIN32( nError ) );
+}
+
+inline void __declspec(noreturn) _AtlRaiseException( DWORD dwExceptionCode, DWORD dwExceptionFlags = EXCEPTION_NONCONTINUABLE )
+{
+        RaiseException( dwExceptionCode, dwExceptionFlags, 0, NULL );
+}
+
+enum atlTraceFlags
+{
+        // Application defined categories
+        atlTraceUser        = 0x00000001,
+        atlTraceUser2       = 0x00000002,
+        atlTraceUser3       = 0x00000004,
+        atlTraceUser4       = 0x00000008,
+        // ATL defined categories
+        atlTraceGeneral     = 0x00000020,
+        atlTraceCOM         = 0x00000040,
+        atlTraceQI      = 0x00000080,
+        atlTraceRegistrar   = 0x00000100,
+        atlTraceRefcount    = 0x00000200,
+        atlTraceWindowing   = 0x00000400,
+        atlTraceControls    = 0x00000800,
+        atlTraceHosting     = 0x00001000,
+        atlTraceDBClient    = 0x00002000,
+        atlTraceDBProvider  = 0x00004000,
+        atlTraceSnapin      = 0x00008000,
+        atlTraceNotImpl     = 0x00010000,
+};
+
+#ifndef ATL_TRACE_CATEGORY
+#define ATL_TRACE_CATEGORY 0xFFFFFFFF
+#endif
+
+#ifdef _DEBUG
+
+#ifndef ATL_TRACE_LEVEL
+#define ATL_TRACE_LEVEL 0
+#endif
+
+inline void _cdecl AtlTrace(LPCSTR lpszFormat, ...)
+{
+        va_list args;
+        va_start(args, lpszFormat);
+
+        int nBuf;
+        char szBuffer[512];
+
+        nBuf = _vsnprintf(szBuffer, sizeof(szBuffer), lpszFormat, args);
+        szBuffer[sizeof(szBuffer)-1] = 0;
+        
+        if(nBuf == -1 || nBuf >= sizeof(szBuffer))
+        {
+                char szContinued[] = "...";
+                
+                lstrcpyA(szBuffer + sizeof(szBuffer) - sizeof(szContinued), szContinued);
+        }                
+        
+        OutputDebugStringA(szBuffer);
+                
+        va_end(args);
+}
+inline void _cdecl AtlTrace2(DWORD category, UINT level, LPCSTR lpszFormat, ...)
+{
+        if (category & ATL_TRACE_CATEGORY && level <= ATL_TRACE_LEVEL)
+        {
+                va_list args;
+                va_start(args, lpszFormat);
+
+                int nBuf;
+                char szBuffer[512];
+
+                nBuf = _vsnprintf(szBuffer, sizeof(szBuffer), lpszFormat, args);
+                szBuffer[sizeof(szBuffer)-1] = 0;
+
+                if(nBuf == -1 || nBuf >= sizeof(szBuffer))
+                {
+                        char szContinued[] = "...";
+                        
+                        lstrcpyA(szBuffer + sizeof(szBuffer) - sizeof(szContinued), szContinued);
+                }                
+
+                OutputDebugStringA("ATL: ");
+                OutputDebugStringA(szBuffer);
+                va_end(args);
+        }
+}
+#ifndef OLE2ANSI
+inline void _cdecl AtlTrace(LPCWSTR lpszFormat, ...)
+{
+        va_list args;
+        va_start(args, lpszFormat);
+
+        int nBuf;
+        WCHAR szBuffer[512];
+
+        nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer) / sizeof(WCHAR), lpszFormat, args);
+        szBuffer[sizeof(szBuffer)/sizeof(WCHAR)-1] = 0;
+
+        if(nBuf == -1 || nBuf >= sizeof(szBuffer)/sizeof(WCHAR))
+        {
+                WCHAR szContinued[] = L"...";
+                
+                ocscpy(szBuffer + sizeof(szBuffer)/sizeof(WCHAR) - sizeof(szContinued)/sizeof(WCHAR), szContinued);
+        }                
+
+        OutputDebugStringW(szBuffer);
+        va_end(args);
+}
+inline void _cdecl AtlTrace2(DWORD category, UINT level, LPCWSTR lpszFormat, ...)
+{
+        if (category & ATL_TRACE_CATEGORY && level <= ATL_TRACE_LEVEL)
+        {
+                va_list args;
+                va_start(args, lpszFormat);
+
+                int nBuf;
+                WCHAR szBuffer[512];
+
+                nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer) / sizeof(WCHAR), lpszFormat, args);
+                szBuffer[sizeof(szBuffer)/sizeof(WCHAR)-1] = 0;
+
+                if(nBuf == -1 || nBuf >= sizeof(szBuffer)/sizeof(WCHAR))
+                {
+                        WCHAR szContinued[] = L"...";
+                        
+                        ocscpy(szBuffer + sizeof(szBuffer)/sizeof(WCHAR) - sizeof(szContinued)/sizeof(WCHAR), szContinued);
+                }                
+
+                OutputDebugStringW(L"ATL: ");
+                OutputDebugStringW(szBuffer);
+                va_end(args);
+        }
+}
+#endif //!OLE2ANSI
+
+
+#ifndef ATLTRACE
+#define ATLTRACE            AtlTrace
+#define ATLTRACE2           AtlTrace2
+#endif
+#define ATLTRACENOTIMPL(funcname)   ATLTRACE2(atlTraceNotImpl, 2, _T("ATL: %s not implemented.\n"), funcname); return E_NOTIMPL
+#else // !DEBUG
+inline void _cdecl AtlTrace(LPCSTR , ...){}
+inline void _cdecl AtlTrace2(DWORD, UINT, LPCSTR , ...){}
+#ifndef OLE2ANSI
+inline void _cdecl AtlTrace(LPCWSTR , ...){}
+inline void _cdecl AtlTrace2(DWORD, UINT, LPCWSTR , ...){}
+#endif //OLE2ANSI
+#ifndef ATLTRACE
+#define ATLTRACE            1 ? (void)0 : AtlTrace
+#define ATLTRACE2           1 ? (void)0 : AtlTrace2
+#endif //ATLTRACE
+#define ATLTRACENOTIMPL(funcname)   return E_NOTIMPL
+#endif //_DEBUG
+
+// Validation macro for OUT pointer
+// Used in QI and CreateInstance
+#define _ATL_VALIDATE_OUT_POINTER(x)        ATLASSERT(x != NULL);        \
+        if (x == NULL)        \
+                return E_POINTER;        \
+        *x = NULL
+
+/////////////////////////////////////////////////////////////////////////////
+// Win32 libraries
+
+#pragma comment(lib, "kernel32.lib")
+#pragma comment(lib, "user32.lib")
+#ifndef _WIN64
+#pragma comment(lib, "olepro32.lib")
+#endif
+#pragma comment(lib, "advapi32.lib")
+#pragma comment(lib, "ole32.lib")
+#pragma comment(lib, "oleaut32.lib")
+#pragma comment(lib, "uuid.lib")
+
+static HRESULT AtlSetChildSite(IUnknown* punkChild, IUnknown* punkParent)
+{
+        if (punkChild == NULL)
+                return E_POINTER;
+
+        HRESULT hr;
+        IObjectWithSite* pChildSite = NULL;
+        hr = punkChild->QueryInterface(IID_IObjectWithSite, (void**)&pChildSite);
+        if (SUCCEEDED(hr) && pChildSite != NULL)
+        {
+                hr = pChildSite->SetSite(punkParent);
+                pChildSite->Release();
+        }
+        return hr;
+}
+
+template <class T>
+class _NoAddRefReleaseOnCComPtr : public T
+{
+        private:
+                STDMETHOD_(ULONG, AddRef)()=0;
+                STDMETHOD_(ULONG, Release)()=0;
+};
+
+template <class T>
+class CComPtr
+{
+public:
+        typedef T _PtrClass;
+        CComPtr()
+        {
+                p=NULL;
+        }
+        CComPtr(T* lp)
+        {
+                if ((p = lp) != NULL)
+                        p->AddRef();
+        }
+        CComPtr(const CComPtr<T>& lp)
+        {
+                if ((p = lp.p) != NULL)
+                        p->AddRef();
+        }
+        ~CComPtr()
+        {
+                if (p)
+                        p->Release();
+        }
+        void Release()
+        {
+                IUnknown* pTemp = p;
+                if (pTemp)
+                {
+                        p = NULL;
+                        pTemp->Release();
+                }
+        }
+        operator T*() const
+        {
+                return (T*)p;
+        }
+        T& operator*() const
+        {
+                ATLASSERT(p!=NULL);
+                return *p;
+        }
+        //The assert on operator& usually indicates a bug.  If this is really
+        //what is needed, however, take the address of the p member explicitly.
+        T** operator&()
+        {
+                ATLASSERT(p==NULL);
+                return &p;
+        }
+        _NoAddRefReleaseOnCComPtr<T>* operator->() const
+        {
+                ATLASSERT(p!=NULL);
+                return (_NoAddRefReleaseOnCComPtr<T>*)p;
+        }
+        T* operator=(T* lp)
+        {
+                return (T*)AtlComPtrAssign((IUnknown**)&p, lp);
+        }
+        T* operator=(const CComPtr<T>& lp)
+        {
+                return (T*)AtlComPtrAssign((IUnknown**)&p, lp.p);
+        }
+        bool operator!() const
+        {
+                return (p == NULL);
+        }
+        bool operator<(T* pT) const
+        {
+                return p < pT;
+        }
+        bool operator==(T* pT) const
+        {
+                return p == pT;
+        }
+        // Compare two objects for equivalence
+        bool IsEqualObject(IUnknown* pOther)
+        {
+                if (p == NULL && pOther == NULL)
+                        return true; // They are both NULL objects
+
+                if (p == NULL || pOther == NULL)
+                        return false; // One is NULL the other is not
+
+                CComPtr<IUnknown> punk1;
+                CComPtr<IUnknown> punk2;
+                p->QueryInterface(IID_IUnknown, (void**)&punk1);
+                pOther->QueryInterface(IID_IUnknown, (void**)&punk2);
+                return punk1 == punk2;
+        }
+        void Attach(T* p2)
+        {
+                if (p)
+                        p->Release();
+                p = p2;
+        }
+        T* Detach()
+        {
+                T* pt = p;
+                p = NULL;
+                return pt;
+        }
+        HRESULT CopyTo(T** ppT)
+        {
+                ATLASSERT(ppT != NULL);
+                if (ppT == NULL)
+                        return E_POINTER;
+                *ppT = p;
+                if (p)
+                        p->AddRef();
+                return S_OK;
+        }
+        HRESULT SetSite(IUnknown* punkParent)
+        {
+                return AtlSetChildSite(p, punkParent);
+        }
+        HRESULT Advise(IUnknown* pUnk, const IID& iid, LPDWORD pdw)
+        {
+                return AtlAdvise(p, pUnk, iid, pdw);
+        }
+        HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+        {
+                ATLASSERT(p == NULL);
+                return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
+        }
+        HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+        {
+                CLSID clsid;
+                HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
+                ATLASSERT(p == NULL);
+                if (SUCCEEDED(hr))
+                        hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
+                return hr;
+        }
+        template <class Q>
+        HRESULT QueryInterface(Q** pp) const
+        {
+                ATLASSERT(pp != NULL && *pp == NULL);
+                return p->QueryInterface(__uuidof(Q), (void**)pp);
+        }
+        T* p;
+};
+
+
+template <class T, const IID* piid = &__uuidof(T)>
+class CComQIPtr
+{
+public:
+        typedef T _PtrClass;
+        CComQIPtr()
+        {
+                p=NULL;
+        }
+        CComQIPtr(T* lp)
+        {
+                if ((p = lp) != NULL)
+                        p->AddRef();
+        }
+        CComQIPtr(const CComQIPtr<T,piid>& lp)
+        {
+                if ((p = lp.p) != NULL)
+                        p->AddRef();
+        }
+        CComQIPtr(IUnknown* lp)
+        {
+                p=NULL;
+                if (lp != NULL)
+                        lp->QueryInterface(*piid, (void **)&p);
+        }
+        ~CComQIPtr()
+        {
+                if (p)
+                        p->Release();
+        }
+        void Release()
+        {
+                IUnknown* pTemp = p;
+                if (pTemp)
+                {
+                        p = NULL;
+                        pTemp->Release();
+                }
+        }
+        operator T*() const
+        {
+                return p;
+        }
+        T& operator*() const
+        {
+                ATLASSERT(p!=NULL); return *p;
+        }
+        //The assert on operator& usually indicates a bug.  If this is really
+        //what is needed, however, take the address of the p member explicitly.
+        T** operator&()
+        {
+                ATLASSERT(p==NULL);
+                return &p;
+        }
+        _NoAddRefReleaseOnCComPtr<T>* operator->() const
+        {
+                ATLASSERT(p!=NULL);
+                return (_NoAddRefReleaseOnCComPtr<T>*)p;
+        }
+        T* operator=(T* lp)
+        {
+                return (T*)AtlComPtrAssign((IUnknown**)&p, lp);
+        }
+        T* operator=(const CComQIPtr<T,piid>& lp)
+        {
+                return (T*)AtlComPtrAssign((IUnknown**)&p, lp.p);
+        }
+        T* operator=(IUnknown* lp)
+        {
+                return (T*)AtlComQIPtrAssign((IUnknown**)&p, lp, *piid);
+        }
+        bool operator!() const
+        {
+                return (p == NULL);
+        }
+        bool operator<(T* pT) const
+        {
+                return p < pT;
+        }
+        bool operator==(T* pT) const
+        {
+                return p == pT;
+        }
+        // Compare two objects for equivalence
+        bool IsEqualObject(IUnknown* pOther)
+        {
+                if (p == NULL && pOther == NULL)
+                        return true; // They are both NULL objects
+
+                if (p == NULL || pOther == NULL)
+                        return false; // One is NULL the other is not
+
+                CComPtr<IUnknown> punk1;
+                CComPtr<IUnknown> punk2;
+                p->QueryInterface(IID_IUnknown, (void**)&punk1);
+                pOther->QueryInterface(IID_IUnknown, (void**)&punk2);
+                return punk1 == punk2;
+        }
+        void Attach(T* p2)
+        {
+                if (p)
+                        p->Release();
+                p = p2;
+        }
+        T* Detach()
+        {
+                T* pt = p;
+                p = NULL;
+                return pt;
+        }
+        HRESULT CopyTo(T** ppT)
+        {
+                ATLASSERT(ppT != NULL);
+                if (ppT == NULL)
+                        return E_POINTER;
+                *ppT = p;
+                if (p)
+                        p->AddRef();
+                return S_OK;
+        }
+        HRESULT SetSite(IUnknown* punkParent)
+        {
+                return AtlSetChildSite(p, punkParent);
+        }
+        HRESULT Advise(IUnknown* pUnk, const IID& iid, LPDWORD pdw)
+        {
+                return AtlAdvise(p, pUnk, iid, pdw);
+        }
+        HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+        {
+                ATLASSERT(p == NULL);
+                return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
+        }
+        HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+        {
+                CLSID clsid;
+                HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
+                ATLASSERT(p == NULL);
+                if (SUCCEEDED(hr))
+                        hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
+                return hr;
+        }
+        template <class Q>
+        HRESULT QueryInterface(Q** pp)
+        {
+                ATLASSERT(pp != NULL && *pp == NULL);
+                return p->QueryInterface(__uuidof(Q), (void**)pp);
+        }
+        T* p;
+};
+
+//Specialization to make it work
+template<>
+class CComQIPtr<IUnknown, &IID_IUnknown>
+{
+public:
+        typedef IUnknown _PtrClass;
+        CComQIPtr()
+        {
+                p=NULL;
+        }
+        CComQIPtr(IUnknown* lp)
+        {
+                //Actually do a QI to get identity
+                p=NULL;
+                if (lp != NULL)
+                        lp->QueryInterface(IID_IUnknown, (void **)&p);
+        }
+        CComQIPtr(const CComQIPtr<IUnknown,&IID_IUnknown>& lp)
+        {
+                if ((p = lp.p) != NULL)
+                        p->AddRef();
+        }
+        ~CComQIPtr()
+        {
+                if (p)
+                        p->Release();
+        }
+        void Release()
+        {
+                IUnknown* pTemp = p;
+                if (pTemp)
+                {
+                        p = NULL;
+                        pTemp->Release();
+                }
+        }
+        operator IUnknown*() const
+        {
+                return p;
+        }
+        IUnknown& operator*() const
+        {
+                ATLASSERT(p!=NULL);
+                return *p;
+        }
+        //The assert on operator& usually indicates a bug.  If this is really
+        //what is needed, however, take the address of the p member explicitly.
+        IUnknown** operator&()
+        {
+                ATLASSERT(p==NULL);
+                return &p;
+        }
+        _NoAddRefReleaseOnCComPtr<IUnknown>* operator->() const
+        {
+                ATLASSERT(p!=NULL);
+                return (_NoAddRefReleaseOnCComPtr<IUnknown>*)p;
+        }
+        IUnknown* operator=(IUnknown* lp)
+        {
+                //Actually do a QI to get identity
+                return (IUnknown*)AtlComQIPtrAssign((IUnknown**)&p, lp, IID_IUnknown);
+        }
+        IUnknown* operator=(const CComQIPtr<IUnknown,&IID_IUnknown>& lp)
+        {
+                return (IUnknown*)AtlComPtrAssign((IUnknown**)&p, lp.p);
+        }
+        bool operator!() const
+        {
+                return (p == NULL);
+        }
+        bool operator<(IUnknown* pT) const
+        {
+                return p < pT;
+        }
+        bool operator==(IUnknown* pT) const
+        {
+                return p == pT;
+        }
+        // Compare two objects for equivalence
+        bool IsEqualObject(IUnknown* pOther)
+        {
+                if (p == NULL && pOther == NULL)
+                        return true; // They are both NULL objects
+
+                if (p == NULL || pOther == NULL)
+                        return false; // One is NULL the other is not
+
+                CComPtr<IUnknown> punk1;
+                CComPtr<IUnknown> punk2;
+                p->QueryInterface(IID_IUnknown, (void**)&punk1);
+                pOther->QueryInterface(IID_IUnknown, (void**)&punk2);
+                return punk1 == punk2;
+        }
+        IUnknown* Detach()
+        {
+                IUnknown* pt = p;
+                p = NULL;
+                return pt;
+        }
+        HRESULT CopyTo(IUnknown** ppT)
+        {
+                ATLASSERT(ppT != NULL);
+                if (ppT == NULL)
+                        return E_POINTER;
+                *ppT = p;
+                if (p)
+                        p->AddRef();
+                return S_OK;
+        }
+        HRESULT SetSite(IUnknown* punkParent)
+        {
+                return AtlSetChildSite(p, punkParent);
+        }
+        HRESULT Advise(IUnknown* pUnk, const IID& iid, LPDWORD pdw)
+        {
+                return AtlAdvise(p, pUnk, iid, pdw);
+        }
+        HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+        {
+                ATLASSERT(p == NULL);
+                return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(IUnknown), (void**)&p);
+        }
+        HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+        {
+                CLSID clsid;
+                HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
+                ATLASSERT(p == NULL);
+                if (SUCCEEDED(hr))
+                        hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(IUnknown), (void**)&p);
+                return hr;
+        }
+        template <class Q>
+        HRESULT QueryInterface(Q** pp)
+        {
+                ATLASSERT(pp != NULL && *pp == NULL);
+                return p->QueryInterface(__uuidof(Q), (void**)pp);
+        }
+        IUnknown* p;
+};
+
+#define com_cast CComQIPtr
+
+/////////////////////////////////////////////////////////////
+// Class to Adapt CComBSTR and CComPtr for use with STL containers
+// the syntax to use it is
+// std::vector< CAdapt <CComBSTR> > vect;
+
+template <class T>
+class CAdapt
+{
+public:
+        CAdapt()
+        {
+        }
+        CAdapt(const T& rSrc)
+        {
+                m_T = rSrc;
+        }
+
+        CAdapt(const CAdapt& rSrCA)
+        {
+                m_T = rSrCA.m_T;
+        }
+
+        CAdapt& operator=(const T& rSrc)
+        {
+                m_T = rSrc;
+                return *this;
+        }
+        bool operator<(const T& rSrc) const
+        {
+                return m_T < rSrc;
+        }
+        bool operator==(const T& rSrc) const
+        {
+                return m_T == rSrc;
+        }
+        operator T&()
+        {
+                return m_T;
+        }
+
+        operator const T&() const
+        {
+                return m_T;
+        }
+
+        T m_T;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// GUID comparison
+
+inline BOOL InlineIsEqualUnknown(REFGUID rguid1)
+{
+   return (
+          ((PLONG) &rguid1)[0] == 0 &&
+          ((PLONG) &rguid1)[1] == 0 &&
+#ifdef _ATL_BYTESWAP
+          ((PLONG) &rguid1)[2] == 0xC0000000 &&
+          ((PLONG) &rguid1)[3] == 0x00000046);
+#else
+          ((PLONG) &rguid1)[2] == 0x000000C0 &&
+          ((PLONG) &rguid1)[3] == 0x46000000);
+#endif
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Threading Model Support
+
+#ifdef OLD_ATL_CRITSEC_CODE
+
+class CComCriticalSection
+{
+public:
+        void Lock() {EnterCriticalSection(&m_sec);}
+        void Unlock() {LeaveCriticalSection(&m_sec);}
+        void Init() {InitializeCriticalSection(&m_sec);}
+        void Term() {DeleteCriticalSection(&m_sec);}
+        CRITICAL_SECTION m_sec;
+};
+
+class CComAutoCriticalSection
+{
+public:
+        void Lock() {EnterCriticalSection(&m_sec);}
+        void Unlock() {LeaveCriticalSection(&m_sec);}
+        CComAutoCriticalSection() {InitializeCriticalSection(&m_sec);}
+        ~CComAutoCriticalSection() {DeleteCriticalSection(&m_sec);}
+        CRITICAL_SECTION m_sec;
+};
+
+class CComFakeCriticalSection
+{
+public:
+        void Lock() {}
+        void Unlock() {}
+        void Init() {}
+        void Term() {}
+};
+
+class CComMultiThreadModelNoCS
+{
+public:
+        static ULONG WINAPI Increment(LPLONG p) {return InterlockedIncrement(p);}
+        static ULONG WINAPI Decrement(LPLONG p) {return InterlockedDecrement(p);}
+        typedef CComFakeCriticalSection AutoCriticalSection;
+        typedef CComFakeCriticalSection CriticalSection;
+        typedef CComMultiThreadModelNoCS ThreadModelNoCS;
+};
+
+class CComMultiThreadModel
+{
+public:
+        static ULONG WINAPI Increment(LPLONG p) {return InterlockedIncrement(p);}
+        static ULONG WINAPI Decrement(LPLONG p) {return InterlockedDecrement(p);}
+        typedef CComAutoCriticalSection AutoCriticalSection;
+        typedef CComCriticalSection CriticalSection;
+        typedef CComMultiThreadModelNoCS ThreadModelNoCS;
+};
+
+class CComSingleThreadModel
+{
+public:
+        static ULONG WINAPI Increment(LPLONG p) {return ++(*p);}
+        static ULONG WINAPI Decrement(LPLONG p) {return --(*p);}
+        typedef CComFakeCriticalSection AutoCriticalSection;
+        typedef CComFakeCriticalSection CriticalSection;
+        typedef CComSingleThreadModel ThreadModelNoCS;
+};
+
+#if defined(_ATL_SINGLE_THREADED)
+        typedef CComSingleThreadModel CComObjectThreadModel;
+        typedef CComSingleThreadModel CComGlobalsThreadModel;
+#elif defined(_ATL_APARTMENT_THREADED)
+        typedef CComSingleThreadModel CComObjectThreadModel;
+        typedef CComMultiThreadModel CComGlobalsThreadModel;
+#else
+        typedef CComMultiThreadModel CComObjectThreadModel;
+        typedef CComMultiThreadModel CComGlobalsThreadModel;
+#endif
+#else  /* OLD_ATL_CRITSEC_CODE */
+
+class CComCriticalSection
+{
+public:
+
+	CComCriticalSection() throw()
+	{
+		memset(&m_sec, 0, sizeof(CRITICAL_SECTION));
+	}
+	HRESULT Lock() throw()
+	{
+		EnterCriticalSection(&m_sec);
+		return S_OK;
+	}
+	HRESULT Unlock() throw()
+	{
+		LeaveCriticalSection(&m_sec);
+		return S_OK;
+	}
+	HRESULT Init() throw()
+	{
+		HRESULT hRes = S_OK;
+		__try
+		{
+			InitializeCriticalSection(&m_sec);
+		}
+		// structured exception may be raised in low memory situations
+		__except(EXCEPTION_EXECUTE_HANDLER)
+		{
+			if (STATUS_NO_MEMORY == GetExceptionCode())
+				hRes = E_OUTOFMEMORY;
+			else
+				hRes = E_FAIL;
+		}
+		return hRes;
+	}
+
+	HRESULT Term() throw()
+	{
+		DeleteCriticalSection(&m_sec);
+		return S_OK;
+	}	
+	CRITICAL_SECTION m_sec;
+};
+
+class CComAutoCriticalSection : public CComCriticalSection
+{
+public:
+	CComAutoCriticalSection()
+	{
+		CComCriticalSection::Init();
+	}
+	~CComAutoCriticalSection() throw()
+	{
+		CComCriticalSection::Term();
+	}
+private :
+	HRESULT Init();	// Not implemented. CComAutoCriticalSection::Init should never be called
+	HRESULT Term(); // Not implemented. CComAutoCriticalSection::Term should never be called
+};
+
+class CComAutoDeleteCriticalSection : public CComCriticalSection
+{
+public:
+	CComAutoDeleteCriticalSection(): m_bInitialized(false) 
+	{
+	}
+
+	~CComAutoDeleteCriticalSection() throw()
+	{
+		if (!m_bInitialized)
+		{