/*
	WARNING: This file was generated by dkct.
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: testsid.ctr
*/

/*
Copyright (C) 2011-2013, Dirk Krause

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above opyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used
  to endorse or promote products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**	@file testsid.c The testsid module.
*/


#line 10 "testsid.ctr"

#include "dk3all.h"
#include "dkt-version.h"
#include "dkt.h"
#include "dkwt.h"





#line 19 "testsid.ctr"



/**	Text SIDS to show.
*/
static dkChar const * const sidstext[] = {
dkT("S-1-1-0"),
dkT("S-1-5-18"),
NULL


#line 29 "testsid.ctr"
};



/**	The main function.
	@param	argc	Number of command line arguments.
	@param	argv	Command line arguments array.
	@return	0 on success, any other value indicates an error.
*/
DK3_MAIN
{
  dkChar	bu[DK3_MAX_PATH];
  dkChar	b2[DK3_MAX_PATH];
  int exval = 0;
  dkChar const * const	*sidtextptr;
  PSID		psid;
  DWORD		dwSize;
  DWORD		dwSzB2;
  SID_NAME_USE	sidNameUse;

  

#line 50 "testsid.ctr"
  

#line 51 "testsid.ctr"
  sidtextptr = sidstext;
  dk3sf_initialize_stdout();
  while(*sidtextptr) {
    dk3sf_fputs(*sidtextptr, stdout);
    dk3sf_fputc(dkT('\n'), stdout);
    if(ConvertStringSidToSid(*sidtextptr, &psid)) {
      if(psid) {
        dwSize = DK3_SIZEOF(bu,dkChar);
	dwSzB2 = DK3_SIZEOF(bu,dkChar);
        if(LookupAccountSid(
	    NULL,
	    psid,
	    bu,
	    &dwSize,
	    b2,
	    &dwSzB2,
	    &sidNameUse
	  )
	)
	{
	  if(dwSize > 0) {
	    if(dwSize < DK3_SIZEOF(bu,dkChar)) {
	      bu[dwSize] = dkT('\0');
	    } else {
	      bu[DK3_SIZEOF(bu,dkChar)-1] = dkT('\0');
	    }
	    dk3sf_fputs(bu, stdout);
	    dk3sf_fputc(dkT('\n'), stdout);
	  } else {		

#line 80 "testsid.ctr"
	  }
	} else {	

#line 82 "testsid.ctr"
	}
        LocalFree(psid);
      } else {	

#line 85 "testsid.ctr"
      }
    } else {	

#line 87 "testsid.ctr"
    }
    sidtextptr++;
  }
  

#line 91 "testsid.ctr"
  

#line 92 "testsid.ctr"
  exit(exval); return exval;
}

