Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/wince/wince.cpp  view on Meta::CPAN

//-- Called from intrface.cpp, extract.c, fileio.c, list.c, process.c
int __cdecl sprintf(char *buffer, const char *format, ...) {

   WCHAR wszBuffer[512], wszFormat[512];

   MBSTOTSTR(wszFormat, format, countof(wszFormat));
   BOOL fPercent = FALSE;
   for (WCHAR *pwsz = wszFormat; *pwsz; pwsz++) {
      if (*pwsz == L'%') {
         fPercent = !fPercent;
      } else if (fPercent && (((*pwsz >= L'a') && (*pwsz <= L'z')) ||
                              ((*pwsz >= L'A') && (*pwsz <= L'Z'))))
      {
         if (*pwsz == L's') {
            *pwsz = L'S';
         } else if (*pwsz == L'S') {
            *pwsz = L's';
         }
         fPercent = FALSE;
      }
   }

   va_list pArgs;
   va_start(pArgs, format);
   _vsntprintf(wszBuffer, countof(wszBuffer), wszFormat, pArgs);
   va_end(pArgs);

   TSTRTOMBS(buffer, wszBuffer, countof(wszBuffer));

   return 0;
}
#endif /* _WIN32_WCE < 211 */

#ifndef POCKET_UNZIP
//******************************************************************************
//-- Called from unzip.c
void __cdecl perror(const char* errorText)
{
    OutputDebugString((LPCTSTR)errorText);
}
#endif // !POCKET_UNZIP

#ifdef USE_FWRITE
//******************************************************************************
//-- Called from fileio.c
void __cdecl setbuf(FILE *, char *)
{
    // We are using fwrite and the call to setbuf was to set the stream
    // unbuffered which is the default behaviour, we have nothing to do.
}
#endif // USE_FWRITE

//******************************************************************************
//***** STDLIB.H functions
//******************************************************************************

#ifdef _MBCS
int __cdecl mblen(const char *mbc, size_t mbszmax)
{
    // very simple cooked-down version of mblen() without any error handling
    // (Windows CE does not support multibyte charsets with a maximum char
    // length > 2 bytes)
    return (IsDBCSLeadByte((BYTE)*mbc) ? 2 : 1);
}
#endif /* _MBCS */

//******************************************************************************
//***** STRING.H functions
//******************************************************************************

//-- Called from winmain.cpp
int __cdecl _stricmp(const char *string1, const char *string2) {
   while (*string1 && ((*string1 | 0x20) == (*string2 | 0x20))) {
      string1++;
      string2++;
   }
   return (*string1 - *string2);
}

//******************************************************************************
//-- Called from intrface.cpp and winmain.cpp
char* __cdecl _strupr(char *string) {
   while (*string) {
      if ((*string >= 'a') && (*string <= 'z')) {
         *string -= 'a' - 'A';
      }
      string++;
   }
   return string;
}

//******************************************************************************
//-- Called from fileio.c ("open_input_file()")
char* __cdecl strerror(int errnum) {
   return "[errmsg not available]";
}

#ifndef _MBCS
//******************************************************************************
//-- Called from winmain.cpp
char* __cdecl strrchr(const char *string, int c) {

   // Walk to end of string.
   for (char *p = (char*)string; *p; p++) {
   }

   // Walk backwards looking for character.
   for (p--; p >= string; p--) {
      if ((int)*p == c) {
         return p;
      }
   }

   return NULL;
}
#endif /* !_MBCS */

//******************************************************************************
//***** CTYPE.H functions
//******************************************************************************



( run in 1.702 second using v1.01-cache-2.11-cpan-437f7b0c052 )