Click here to Skip to main content
15,884,793 members
Articles / Programming Languages / C

The Windows Access Control Model: Part 2

Rate me:
Please Sign up or sign in to vote.
4.80/5 (28 votes)
27 Jun 2005CPOL43 min read 244.5K   7.2K   113  
This second part of the Access Control series will program with the basic Access Control structures.
/*
 *
 * Copyright (c) 1998-2002
 * Dr John Maddock
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  Dr John Maddock makes no representations
 * about the suitability of this software for any purpose.  
 * It is provided "as is" without express or implied warranty.
 *
 */
 
 /*
  *   LOCATION:    see http://www.boost.org for most recent version.
  *   FILE         regex_cstring.hpp
  *   VERSION      see <boost/version.hpp>
  *   DESCRIPTION: This is an internal header file, do not include directly.
  *                String support and helper functions, for regular
  *                expression library.
  */

#ifndef BOOST_REGEX_CSTRING_HPP
#define BOOST_REGEX_CSTRING_HPP

#ifndef BOOST_REGEX_CONFIG_HPP
#include <boost/regex/config.hpp>
#endif

#include <cstring>

namespace boost{
   namespace re_detail{

#ifdef __BORLANDC__
   #pragma option push -a8 -b -Vx -Ve -pc
#endif

//
// start by defining some template function aliases for C API functions:
//

template <class charT>
std::size_t BOOST_REGEX_CALL re_strlen(const charT *s)
{
   std::size_t len = 0;
   while(*s)
   {
      ++s;
      ++len;
   }
   return len;
}

inline std::size_t BOOST_REGEX_CALL re_strlen(const char *s)
{
   return std::strlen(s);
}

#ifndef BOOST_NO_WREGEX

inline std::size_t BOOST_REGEX_CALL re_strlen(const wchar_t *s)
{
   return std::wcslen(s);
}

#endif

#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL void BOOST_REGEX_CALL re_transform(std::basic_string<wchar_t>& out, const std::basic_string<wchar_t>& in);
#endif
BOOST_REGEX_DECL void BOOST_REGEX_CALL re_transform(std::string& out, const std::string& in);

template <class charT>
void BOOST_REGEX_CALL re_trunc_primary(std::basic_string<charT>& s)
{
   for(unsigned int i = 0; i < s.size(); ++i)
   {
      if(s[i] <= 1)
      {
         s.erase(i);
         break;
      }
   }
}

inline char* BOOST_REGEX_CALL re_strcpy(char *s1, const char *s2)
{
   #if defined(__BORLANDC__) && defined(strcpy)
   return ::strcpy(s1, s2);
   #else
   return std::strcpy(s1, s2);
   #endif
}

#ifndef BOOST_NO_WREGEX

inline wchar_t* BOOST_REGEX_CALL re_strcpy(wchar_t *s1, const wchar_t *s2)
{
   return std::wcscpy(s1, s2);
}

#endif


template <class charT>
charT* BOOST_REGEX_CALL re_strdup(const charT* p)
{
   charT* buf = new charT[re_strlen(p) + 1];
   re_strcpy(buf, p);
   return buf;
}

template <class charT>
inline void BOOST_REGEX_CALL re_strfree(charT* p)
{
   delete[] p;
}

#ifdef __BORLANDC__
  #pragma option pop
#endif

} // namespace re_detail
} // namespace boost

#endif  // BOOST_REGEX_CSTRING_HPP





By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Mr. Shah is a reclusive C++/C# developer lurking somewhere in the depths of the city of London. He learnt physics at Kings' College London and obtained a Master in Science there. Having earned an MCAD, he teeters on the brink of transitioning from C++ to C#, unsure of which language to jump to. Fortunately, he also knows how to use .NET interop to merge code between the two languages (which means he won't have to make the choice anytime soon).

His interests (apart from programming) are walking, football (the real one!), philosophy, history, retro-gaming, strategy gaming, and any good game in general.

He maintains a website / blog / FAQ / junk at shexec32.serveftp.net, where he places the best answers he's written to the questions you've asked. If you can find him, maybe you can hire Mr. Shah to help you with anything C++[/CLI]/C#/.NET related Smile | :) .

Comments and Discussions