From e46d0247d01daf5f1dde49446f5632a6fcafefef Mon Sep 17 00:00:00 2001 From: Martin Passing Date: Sun, 23 May 2021 22:24:45 +0200 Subject: [PATCH] revert clang-format style changes on 3rd party code --- windows/nsProcess/ConvFunc.h | 855 ++++++++++++++++----------------- windows/nsProcess/api.h | 67 ++- windows/nsProcess/nsis_tchar.h | 270 +++++------ windows/nsProcess/pluginapi.h | 152 +++--- 4 files changed, 651 insertions(+), 693 deletions(-) diff --git a/windows/nsProcess/ConvFunc.h b/windows/nsProcess/ConvFunc.h index 513cd16f0e..739737b084 100644 --- a/windows/nsProcess/ConvFunc.h +++ b/windows/nsProcess/ConvFunc.h @@ -15,27 +15,27 @@ *****************************************************************/ #ifndef _CONVFUNC_ -# define _CONVFUNC_ - -int xatoi ( char* str ); -int xatoiW ( wchar_t* wstr ); -char* xitoa ( int number, char* str, int width ); -wchar_t* xitoaW ( int number, wchar_t* wstr, int width ); -unsigned int xatoui ( char* str ); -unsigned int xatouiW ( wchar_t* wstr ); -char* xuitoa ( unsigned int number, char* str, int width ); -wchar_t* xuitoaW ( unsigned int number, wchar_t* wstr, int width ); -__int64 xatoi64 ( char* str ); -__int64 xatoi64W ( wchar_t* wstr ); -char* xi64toa ( __int64 number, char* str, int width ); -wchar_t* xi64toaW ( __int64 number, wchar_t* wstr, int width ); -int hex2dec ( char* hex ); -int hex2decW ( wchar_t* whex ); -void dec2hex ( unsigned int dec, char* hex, BOOL lowercase, unsigned int width ); -void dec2hexW ( unsigned int dec, wchar_t* whex, BOOL lowercase, unsigned int width ); - -void str2hex ( unsigned char* str, char* hex, BOOL lowercase, unsigned int bytes ); -void hex2str ( char* hex, char* str ); +#define _CONVFUNC_ + +int xatoi(char *str); +int xatoiW(wchar_t *wstr); +char* xitoa(int number, char *str, int width); +wchar_t* xitoaW(int number, wchar_t *wstr, int width); +unsigned int xatoui(char *str); +unsigned int xatouiW(wchar_t *wstr); +char* xuitoa(unsigned int number, char *str, int width); +wchar_t* xuitoaW(unsigned int number, wchar_t *wstr, int width); +__int64 xatoi64(char *str); +__int64 xatoi64W(wchar_t *wstr); +char* xi64toa(__int64 number, char *str, int width); +wchar_t* xi64toaW(__int64 number, wchar_t *wstr, int width); +int hex2dec(char *hex); +int hex2decW(wchar_t *whex); +void dec2hex(unsigned int dec, char *hex, BOOL lowercase, unsigned int width); +void dec2hexW(unsigned int dec, wchar_t *whex, BOOL lowercase, unsigned int width); + +void str2hex(unsigned char *str, char *hex, BOOL lowercase, unsigned int bytes); +void hex2str(char *hex, char *str); #endif @@ -54,27 +54,27 @@ void hex2str ( char* hex, char* str ); * xatoi(" -0045:value") == -45; ********************************************************************/ #if defined xatoi || defined ALLCONVFUNC -# define xatoi_INCLUDED -# undef xatoi -int xatoi ( char* str ) +#define xatoi_INCLUDED +#undef xatoi +int xatoi(char *str) { - int nNumber = 0; - BOOL bMinus = FALSE; - - while ( *str == ' ' ) - ++str; - if ( *str == '+' ) - ++str; - else if ( *str == '-' ) - { - bMinus = TRUE; - ++str; - } - for ( ; *str != '\0' && *str >= '0' && *str <= '9'; ++str ) - nNumber = ( nNumber * 10 ) + ( *str - '0' ); - if ( bMinus == TRUE ) - nNumber = 0 - nNumber; - return nNumber; + int nNumber=0; + BOOL bMinus=FALSE; + + while (*str == ' ') + ++str; + if (*str == '+') + ++str; + else if (*str == '-') + { + bMinus=TRUE; + ++str; + } + for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str) + nNumber=(nNumber * 10) + (*str - '0'); + if (bMinus == TRUE) + nNumber=0 - nNumber; + return nNumber; } #endif @@ -93,27 +93,27 @@ int xatoi ( char* str ) * xatoiW(L" -0045:value") == -45; ********************************************************************/ #if defined xatoiW || defined ALLCONVFUNC -# define xatoiW_INCLUDED -# undef xatoiW -int xatoiW ( wchar_t* wstr ) +#define xatoiW_INCLUDED +#undef xatoiW +int xatoiW(wchar_t *wstr) { - int nNumber = 0; - BOOL bMinus = FALSE; - - while ( *wstr == ' ' ) - ++wstr; - if ( *wstr == '+' ) - ++wstr; - else if ( *wstr == '-' ) - { - bMinus = TRUE; - ++wstr; - } - for ( ; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr ) - nNumber = ( nNumber * 10 ) + ( *wstr - '0' ); - if ( bMinus == TRUE ) - nNumber = 0 - nNumber; - return nNumber; + int nNumber=0; + BOOL bMinus=FALSE; + + while (*wstr == ' ') + ++wstr; + if (*wstr == '+') + ++wstr; + else if (*wstr == '-') + { + bMinus=TRUE; + ++wstr; + } + for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr) + nNumber=(nNumber * 10) + (*wstr - '0'); + if (bMinus == TRUE) + nNumber=0 - nNumber; + return nNumber; } #endif @@ -135,43 +135,42 @@ int xatoiW ( wchar_t* wstr ) * xitoa(45, szResult, 4); //szResult == "0045" ********************************************************************/ #if defined xitoa || defined ALLCONVFUNC -# define xitoa_INCLUDED -# undef xitoa -char* xitoa ( int number, char* str, int width ) +#define xitoa_INCLUDED +#undef xitoa +char* xitoa(int number, char *str, int width) { - char tmp[128]; - int a = 0; - int b = 0; - *tmp = 0; - - if ( number == 0 ) - { - str[0] = '0'; - --width; - b = 1; - } - else if ( number < 0 ) - { - str[0] = '-'; - number = 0 - number; - --width; - b = 1; - } - for ( tmp[a] = '\0'; number != 0; ++a ) - { - tmp[a] = ( number % 10 ) + '0'; - number = number / 10; - } - if ( a < width ) - do - { - tmp[a] = '0'; - } while ( ++a < width ); - for ( --a; a >= 0; --a, ++b ) - str[b] = tmp[a]; - - str[b] = '\0'; - return str; + char tmp[128]; + int a=0; + int b=0; + *tmp = 0; + + if (number == 0) + { + str[0]='0'; + --width; + b=1; + } + else if (number < 0) + { + str[0]='-'; + number=0 - number; + --width; + b=1; + } + for (tmp[a]='\0'; number != 0; ++a) + { + tmp[a]=(number % 10) + '0'; + number=number / 10; + } + if (a < width) + do + { + tmp[a]='0'; + } while (++a= 0; --a, ++b) str[b]=tmp[a]; + + str[b]='\0'; + return str; } #endif @@ -193,39 +192,37 @@ char* xitoa ( int number, char* str, int width ) * xitoaW(45, wszResult, 4); //wszResult == L"0045" ********************************************************************/ #if defined xitoaW || defined ALLCONVFUNC -# define xitoaW_INCLUDED -# undef xitoaW -wchar_t* xitoaW ( int number, wchar_t* wstr, int width ) +#define xitoaW_INCLUDED +#undef xitoaW +wchar_t* xitoaW(int number, wchar_t *wstr, int width) { - wchar_t wtmp[128] = L""; - int a = 0; - int b = 0; - - if ( number == 0 ) - { - wstr[0] = '0'; - --width; - b = 1; - } - else if ( number < 0 ) - { - wstr[0] = '-'; - number = 0 - number; - --width; - b = 1; - } - for ( wtmp[a] = '\0'; number != 0; ++a ) - { - wtmp[a] = ( number % 10 ) + '0'; - number = number / 10; - } - for ( ; width > a; ++a ) - wtmp[a] = '0'; - for ( --a; a >= 0; --a, ++b ) - wstr[b] = wtmp[a]; - - wstr[b] = '\0'; - return wstr; + wchar_t wtmp[128]=L""; + int a=0; + int b=0; + + if (number == 0) + { + wstr[0]='0'; + --width; + b=1; + } + else if (number < 0) + { + wstr[0]='-'; + number=0 - number; + --width; + b=1; + } + for (wtmp[a]='\0'; number != 0; ++a) + { + wtmp[a]=(number % 10) + '0'; + number=number / 10; + } + for (; width > a; ++a) wtmp[a]='0'; + for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a]; + + wstr[b]='\0'; + return wstr; } #endif @@ -244,21 +241,21 @@ wchar_t* xitoaW ( int number, wchar_t* wstr, int width ) * xatoui(" -0045:value") == 0; ********************************************************************/ #if defined xatoui || defined ALLCONVFUNC -# define xatoui_INCLUDED -# undef xatoui -unsigned int xatoui ( char* str ) +#define xatoui_INCLUDED +#undef xatoui +unsigned int xatoui(char *str) { - unsigned int nNumber = 0; - - while ( *str == ' ' ) - ++str; - if ( *str == '+' ) - ++str; - else if ( *str == '-' ) - return 0; - for ( ; *str != '\0' && *str >= '0' && *str <= '9'; ++str ) - nNumber = ( nNumber * 10 ) + ( *str - '0' ); - return nNumber; + unsigned int nNumber=0; + + while (*str == ' ') + ++str; + if (*str == '+') + ++str; + else if (*str == '-') + return 0; + for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str) + nNumber=(nNumber * 10) + (*str - '0'); + return nNumber; } #endif @@ -277,21 +274,21 @@ unsigned int xatoui ( char* str ) * xatouiW(L" -0045:value") == 0; ********************************************************************/ #if defined xatouiW || defined ALLCONVFUNC -# define xatouiW_INCLUDED -# undef xatouiW -unsigned int xatouiW ( wchar_t* wstr ) +#define xatouiW_INCLUDED +#undef xatouiW +unsigned int xatouiW(wchar_t *wstr) { - unsigned int nNumber = 0; - - while ( *wstr == ' ' ) - ++wstr; - if ( *wstr == '+' ) - ++wstr; - else if ( *wstr == '-' ) - return 0; - for ( ; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr ) - nNumber = ( nNumber * 10 ) + ( *wstr - '0' ); - return nNumber; + unsigned int nNumber=0; + + while (*wstr == ' ') + ++wstr; + if (*wstr == '+') + ++wstr; + else if (*wstr == '-') + return 0; + for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr) + nNumber=(nNumber * 10) + (*wstr - '0'); + return nNumber; } #endif @@ -312,32 +309,30 @@ unsigned int xatouiW ( wchar_t* wstr ) * xuitoa(45, szResult, 4); //szResult == "0045" ********************************************************************/ #if defined xuitoa || defined ALLCONVFUNC -# define xuitoa_INCLUDED -# undef xuitoa -char* xuitoa ( unsigned int number, char* str, int width ) +#define xuitoa_INCLUDED +#undef xuitoa +char* xuitoa(unsigned int number, char *str, int width) { - char tmp[128] = ""; - int a = 0; - int b = 0; - - if ( number == 0 ) - { - str[0] = '0'; - --width; - b = 1; - } - for ( tmp[a] = '\0'; number != 0; ++a ) - { - tmp[a] = ( number % 10 ) + '0'; - number = number / 10; - } - for ( ; width > a; ++a ) - tmp[a] = '0'; - for ( --a; a >= 0; --a, ++b ) - str[b] = tmp[a]; - - str[b] = '\0'; - return str; + char tmp[128]=""; + int a=0; + int b=0; + + if (number == 0) + { + str[0]='0'; + --width; + b=1; + } + for (tmp[a]='\0'; number != 0; ++a) + { + tmp[a]=(number % 10) + '0'; + number=number / 10; + } + for (; width > a; ++a) tmp[a]='0'; + for (--a; a >= 0; --a, ++b) str[b]=tmp[a]; + + str[b]='\0'; + return str; } #endif @@ -358,32 +353,30 @@ char* xuitoa ( unsigned int number, char* str, int width ) * xuitoaW(45, wszResult, 4); //wszResult == L"0045" ********************************************************************/ #if defined xuitoaW || defined ALLCONVFUNC -# define xuitoaW_INCLUDED -# undef xuitoaW -wchar_t* xuitoaW ( unsigned int number, wchar_t* wstr, int width ) +#define xuitoaW_INCLUDED +#undef xuitoaW +wchar_t* xuitoaW(unsigned int number, wchar_t *wstr, int width) { - wchar_t wtmp[128] = L""; - int a = 0; - int b = 0; - - if ( number == 0 ) - { - wstr[0] = '0'; - --width; - b = 1; - } - for ( wtmp[a] = '\0'; number != 0; ++a ) - { - wtmp[a] = ( number % 10 ) + '0'; - number = number / 10; - } - for ( ; width > a; ++a ) - wtmp[a] = '0'; - for ( --a; a >= 0; --a, ++b ) - wstr[b] = wtmp[a]; - - wstr[b] = '\0'; - return wstr; + wchar_t wtmp[128]=L""; + int a=0; + int b=0; + + if (number == 0) + { + wstr[0]='0'; + --width; + b=1; + } + for (wtmp[a]='\0'; number != 0; ++a) + { + wtmp[a]=(number % 10) + '0'; + number=number / 10; + } + for (; width > a; ++a) wtmp[a]='0'; + for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a]; + + wstr[b]='\0'; + return wstr; } #endif @@ -402,27 +395,27 @@ wchar_t* xuitoaW ( unsigned int number, wchar_t* wstr, int width ) * xatoi64(" -0045:value") == -45; ********************************************************************/ #if defined xatoi64 || defined ALLCONVFUNC -# define xatoi64_INCLUDED -# undef xatoi64 -__int64 xatoi64 ( char* str ) +#define xatoi64_INCLUDED +#undef xatoi64 +__int64 xatoi64(char *str) { - __int64 nNumber = 0; - BOOL bMinus = FALSE; - - while ( *str == ' ' ) - ++str; - if ( *str == '+' ) - ++str; - else if ( *str == '-' ) - { - bMinus = TRUE; - ++str; - } - for ( ; *str != '\0' && *str >= '0' && *str <= '9'; ++str ) - nNumber = ( nNumber * 10 ) + ( *str - '0' ); - if ( bMinus == TRUE ) - nNumber = 0 - nNumber; - return nNumber; + __int64 nNumber=0; + BOOL bMinus=FALSE; + + while (*str == ' ') + ++str; + if (*str == '+') + ++str; + else if (*str == '-') + { + bMinus=TRUE; + ++str; + } + for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str) + nNumber=(nNumber * 10) + (*str - '0'); + if (bMinus == TRUE) + nNumber=0 - nNumber; + return nNumber; } #endif @@ -441,27 +434,27 @@ __int64 xatoi64 ( char* str ) * xatoi64W(L" -0045:value") == -45; ********************************************************************/ #if defined xatoi64W || defined ALLCONVFUNC -# define xatoi64W_INCLUDED -# undef xatoi64W -__int64 xatoi64W ( wchar_t* wstr ) +#define xatoi64W_INCLUDED +#undef xatoi64W +__int64 xatoi64W(wchar_t *wstr) { - __int64 nNumber = 0; - BOOL bMinus = FALSE; - - while ( *wstr == ' ' ) - ++wstr; - if ( *wstr == '+' ) - ++wstr; - else if ( *wstr == '-' ) - { - bMinus = TRUE; - ++wstr; - } - for ( ; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr ) - nNumber = ( nNumber * 10 ) + ( *wstr - '0' ); - if ( bMinus == TRUE ) - nNumber = 0 - nNumber; - return nNumber; + __int64 nNumber=0; + BOOL bMinus=FALSE; + + while (*wstr == ' ') + ++wstr; + if (*wstr == '+') + ++wstr; + else if (*wstr == '-') + { + bMinus=TRUE; + ++wstr; + } + for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr) + nNumber=(nNumber * 10) + (*wstr - '0'); + if (bMinus == TRUE) + nNumber=0 - nNumber; + return nNumber; } #endif @@ -483,39 +476,37 @@ __int64 xatoi64W ( wchar_t* wstr ) * xi64toa(45, szResult, 4); //szResult == "0045" ********************************************************************/ #if defined xi64toa || defined ALLCONVFUNC -# define xi64toa_INCLUDED -# undef xi64toa -char* xi64toa ( __int64 number, char* str, int width ) +#define xi64toa_INCLUDED +#undef xi64toa +char* xi64toa(__int64 number, char *str, int width) { - char tmp[128] = ""; - int a = 0; - int b = 0; - - if ( number == 0 ) - { - str[0] = '0'; - --width; - b = 1; - } - else if ( number < 0 ) - { - str[0] = '-'; - number = 0 - number; - --width; - b = 1; - } - for ( tmp[a] = '\0'; number != 0; ++a ) - { - tmp[a] = (char) ( ( number % 10 ) + '0' ); - number = number / 10; - } - for ( ; width > a; ++a ) - tmp[a] = '0'; - for ( --a; a >= 0; --a, ++b ) - str[b] = tmp[a]; - - str[b] = '\0'; - return str; + char tmp[128]=""; + int a=0; + int b=0; + + if (number == 0) + { + str[0]='0'; + --width; + b=1; + } + else if (number < 0) + { + str[0]='-'; + number=0 - number; + --width; + b=1; + } + for (tmp[a]='\0'; number != 0; ++a) + { + tmp[a]=(char)((number % 10) + '0'); + number=number / 10; + } + for (; width > a; ++a) tmp[a]='0'; + for (--a; a >= 0; --a, ++b) str[b]=tmp[a]; + + str[b]='\0'; + return str; } #endif @@ -537,39 +528,37 @@ char* xi64toa ( __int64 number, char* str, int width ) * xi64toaW(45, wszResult, 4); //wszResult == L"0045" ********************************************************************/ #if defined xi64toaW || defined ALLCONVFUNC -# define xi64toaW_INCLUDED -# undef xi64toaW -wchar_t* xi64toaW ( __int64 number, wchar_t* wstr, int width ) +#define xi64toaW_INCLUDED +#undef xi64toaW +wchar_t* xi64toaW(__int64 number, wchar_t *wstr, int width) { - wchar_t wtmp[128] = L""; - int a = 0; - int b = 0; - - if ( number == 0 ) - { - wstr[0] = '0'; - --width; - b = 1; - } - else if ( number < 0 ) - { - wstr[0] = '-'; - number = 0 - number; - --width; - b = 1; - } - for ( wtmp[a] = '\0'; number != 0; ++a ) - { - wtmp[a] = (char) ( ( number % 10 ) + '0' ); - number = number / 10; - } - for ( ; width > a; ++a ) - wtmp[a] = '0'; - for ( --a; a >= 0; --a, ++b ) - wstr[b] = wtmp[a]; - - wstr[b] = '\0'; - return wstr; + wchar_t wtmp[128]=L""; + int a=0; + int b=0; + + if (number == 0) + { + wstr[0]='0'; + --width; + b=1; + } + else if (number < 0) + { + wstr[0]='-'; + number=0 - number; + --width; + b=1; + } + for (wtmp[a]='\0'; number != 0; ++a) + { + wtmp[a]=(char)((number % 10) + '0'); + number=number / 10; + } + for (; width > a; ++a) wtmp[a]='0'; + for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a]; + + wstr[b]='\0'; + return wstr; } #endif @@ -588,30 +577,24 @@ wchar_t* xi64toaW ( __int64 number, wchar_t* wstr, int width ) * hex2dec("A1F") == 2591; ********************************************************************/ #if defined hex2dec || defined ALLCONVFUNC -# define hex2dec_INCLUDED -# undef hex2dec -int hex2dec ( char* hex ) +#define hex2dec_INCLUDED +#undef hex2dec +int hex2dec(char *hex) { - int a; - int b = 0; - - while ( 1 ) - { - a = *hex++; - if ( a >= '0' && a <= '9' ) - a -= '0'; - else if ( a >= 'a' && a <= 'f' ) - a -= 'a' - 10; - else if ( a >= 'A' && a <= 'F' ) - a -= 'A' - 10; - else - return -1; - - if ( *hex ) - b = ( b + a ) * 16; - else - return ( b + a ); - } + int a; + int b=0; + + while (1) + { + a=*hex++; + if (a >= '0' && a <= '9') a-='0'; + else if (a >= 'a' && a <= 'f') a-='a'-10; + else if (a >= 'A' && a <= 'F') a-='A'-10; + else return -1; + + if (*hex) b=(b + a) * 16; + else return (b + a); + } } #endif @@ -630,30 +613,24 @@ int hex2dec ( char* hex ) * hex2decW(L"A1F") == 2591; ********************************************************************/ #if defined hex2decW || defined ALLCONVFUNC -# define hex2decW_INCLUDED -# undef hex2decW -int hex2decW ( wchar_t* whex ) +#define hex2decW_INCLUDED +#undef hex2decW +int hex2decW(wchar_t *whex) { - int a; - int b = 0; - - while ( 1 ) - { - a = *whex++; - if ( a >= '0' && a <= '9' ) - a -= '0'; - else if ( a >= 'a' && a <= 'f' ) - a -= 'a' - 10; - else if ( a >= 'A' && a <= 'F' ) - a -= 'A' - 10; - else - return -1; - - if ( *whex ) - b = ( b + a ) * 16; - else - return ( b + a ); - } + int a; + int b=0; + + while (1) + { + a=*whex++; + if (a >= '0' && a <= '9') a-='0'; + else if (a >= 'a' && a <= 'f') a-='a'-10; + else if (a >= 'A' && a <= 'F') a-='A'-10; + else return -1; + + if (*whex) b=(b + a) * 16; + else return (b + a); + } } #endif @@ -674,35 +651,29 @@ int hex2decW ( wchar_t* whex ) * dec2hex(10, szResult, TRUE, 2); //szResult == "0a" ********************************************************************/ #if defined dec2hex || defined ALLCONVFUNC -# define dec2hex_INCLUDED -# undef dec2hex -void dec2hex ( unsigned int dec, char* hex, BOOL lowercase, unsigned int width ) +#define dec2hex_INCLUDED +#undef dec2hex +void dec2hex(unsigned int dec, char *hex, BOOL lowercase, unsigned int width) { - unsigned int a = dec; - unsigned int b = 0; - unsigned int c = 0; - char d = '1'; - if ( a == 0 ) - d = '0'; - - while ( a ) - { - b = a % 16; - a = a / 16; - if ( b < 10 ) - hex[c++] = b + '0'; - else if ( lowercase == TRUE ) - hex[c++] = b + 'a' - 10; - else - hex[c++] = b + 'A' - 10; - } - while ( width > c ) - hex[c++] = '0'; - hex[c] = '\0'; - - if ( d == '1' ) - for ( b = 0, --c; b < c; d = hex[b], hex[b++] = hex[c], hex[c--] = d ) - ; + unsigned int a=dec; + unsigned int b=0; + unsigned int c=0; + char d='1'; + if (a == 0) d='0'; + + while (a) + { + b=a % 16; + a=a / 16; + if (b < 10) hex[c++]=b + '0'; + else if (lowercase == TRUE) hex[c++]=b + 'a' - 10; + else hex[c++]=b + 'A' - 10; + } + while (width > c) hex[c++]='0'; + hex[c]='\0'; + + if (d == '1') + for (b=0, --c; b < c; d=hex[b], hex[b++]=hex[c], hex[c--]=d); } #endif @@ -723,35 +694,29 @@ void dec2hex ( unsigned int dec, char* hex, BOOL lowercase, unsigned int width ) * dec2hexW(10, wszResult, TRUE, 2); //wszResult == L"0a" ********************************************************************/ #if defined dec2hexW || defined ALLCONVFUNC -# define dec2hexW_INCLUDED -# undef dec2hexW -void dec2hexW ( unsigned int dec, wchar_t* whex, BOOL lowercase, unsigned int width ) +#define dec2hexW_INCLUDED +#undef dec2hexW +void dec2hexW(unsigned int dec, wchar_t *whex, BOOL lowercase, unsigned int width) { - unsigned int a = dec; - unsigned int b = 0; - unsigned int c = 0; - wchar_t d = '1'; - if ( a == 0 ) - d = '0'; - - while ( a ) - { - b = a % 16; - a = a / 16; - if ( b < 10 ) - whex[c++] = b + '0'; - else if ( lowercase == TRUE ) - whex[c++] = b + 'a' - 10; - else - whex[c++] = b + 'A' - 10; - } - while ( width > c ) - whex[c++] = '0'; - whex[c] = '\0'; - - if ( d == '1' ) - for ( b = 0, --c; b < c; d = whex[b], whex[b++] = whex[c], whex[c--] = d ) - ; + unsigned int a=dec; + unsigned int b=0; + unsigned int c=0; + wchar_t d='1'; + if (a == 0) d='0'; + + while (a) + { + b=a % 16; + a=a / 16; + if (b < 10) whex[c++]=b + '0'; + else if (lowercase == TRUE) whex[c++]=b + 'a' - 10; + else whex[c++]=b + 'A' - 10; + } + while (width > c) whex[c++]='0'; + whex[c]='\0'; + + if (d == '1') + for (b=0, --c; b < c; d=whex[b], whex[b++]=whex[c], whex[c--]=d); } #endif @@ -774,19 +739,19 @@ void dec2hexW ( unsigned int dec, wchar_t* whex, BOOL lowercase, unsigned int wi * str2hex((unsigned char *)"Some Text", szResult, TRUE, lstrlen("Some Text")); //szResult == "536f6d652054657874" ********************************************************************/ #if defined str2hex || defined ALLCONVFUNCS -# define str2hex_INCLUDED -# undef str2hex -void str2hex ( unsigned char* str, char* hex, BOOL lowercase, unsigned int bytes ) +#define str2hex_INCLUDED +#undef str2hex +void str2hex(unsigned char *str, char *hex, BOOL lowercase, unsigned int bytes) { - char a[16]; - unsigned int b = 0; - - for ( hex[0] = '\0'; b < bytes; ++b ) - { - // wsprintf(a, "%02x", (unsigned int)str[b]); - dec2hex ( (unsigned int) str[b], a, lowercase, 2 ); - lstrcat ( hex, a ); - } + char a[16]; + unsigned int b=0; + + for (hex[0]='\0'; b < bytes; ++b) + { + //wsprintf(a, "%02x", (unsigned int)str[b]); + dec2hex((unsigned int)str[b], a, lowercase, 2); + lstrcat(hex, a); + } } #endif @@ -803,33 +768,31 @@ void str2hex ( unsigned char* str, char* hex, BOOL lowercase, unsigned int bytes * hex2str("536f6d652054657874", szResult); //szResult == "Some Text" ********************************************************************/ #if defined hex2str || defined ALLCONVFUNCS -# define hex2str_INCLUDED -# undef hex2str -void hex2str ( char* hex, char* str ) +#define hex2str_INCLUDED +#undef hex2str +void hex2str(char *hex, char *str) { - char a[4]; - int b; + char a[4]; + int b; - while ( *hex ) + while (*hex) + { + a[0]=*hex; + a[1]=*++hex; + a[2]='\0'; + + if (*hex++) { - a[0] = *hex; - a[1] = *++hex; - a[2] = '\0'; - - if ( *hex++ ) - { - if ( ( b = hex2dec ( a ) ) > 0 ) - *str++ = b; - else - break; - } - else - break; - } - *str = '\0'; + if ((b=hex2dec(a)) > 0) *str++=b; + else break; + } + else break; + } + *str='\0'; } #endif + /******************************************************************** * * * Example * diff --git a/windows/nsProcess/api.h b/windows/nsProcess/api.h index 200881dd18..ed014b2df2 100644 --- a/windows/nsProcess/api.h +++ b/windows/nsProcess/api.h @@ -1,15 +1,15 @@ /* * apih - * + * * This file is a part of NSIS. - * + * * Copyright (C) 1999-2008 Nullsoft and Contributors - * + * * Licensed under the zlib/libpng license (the "License"); * you may not use this file except in compliance with the License. - * + * * Licence details can be found in the file COPYING. - * + * * This software is provided 'as-is', without any express or implied * warranty. */ @@ -21,62 +21,61 @@ // The format is 0xXXXXYYYY where X is the major version and Y is the minor version (MAKELONG(y,x)) // When doing version checks, always remember to use >=, ex: if (pX->exec_flags->plugin_api_version >= NSISPIAPIVER_1_0) {} -#define NSISPIAPIVER_1_0 0x00010000 +#define NSISPIAPIVER_1_0 0x00010000 #define NSISPIAPIVER_CURR NSISPIAPIVER_1_0 // NSIS Plug-In Callback Messages -enum NSPIM +enum NSPIM { - NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup - NSPIM_GUIUNLOAD, // Called after .onGUIEnd + NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup + NSPIM_GUIUNLOAD, // Called after .onGUIEnd }; // Prototype for callbacks registered with extra_parameters->RegisterPluginCallback() // Return NULL for unknown messages // Should always be __cdecl for future expansion possibilities -typedef UINT_PTR ( *NSISPLUGINCALLBACK ) ( enum NSPIM ); +typedef UINT_PTR (*NSISPLUGINCALLBACK)(enum NSPIM); // extra_parameters data structures containing other interesting stuff // but the stack, variables and HWND passed on to plug-ins. typedef struct { - int autoclose; - int all_user_var; - int exec_error; - int abort; - int exec_reboot; // NSIS_SUPPORT_REBOOT - int reboot_called; // NSIS_SUPPORT_REBOOT - int XXX_cur_insttype; // depreacted - int plugin_api_version; // see NSISPIAPIVER_CURR - // used to be XXX_insttype_changed - int silent; // NSIS_CONFIG_SILENT_SUPPORT - int instdir_error; - int rtl; - int errlvl; - int alter_reg_view; - int status_update; + int autoclose; + int all_user_var; + int exec_error; + int abort; + int exec_reboot; // NSIS_SUPPORT_REBOOT + int reboot_called; // NSIS_SUPPORT_REBOOT + int XXX_cur_insttype; // depreacted + int plugin_api_version; // see NSISPIAPIVER_CURR + // used to be XXX_insttype_changed + int silent; // NSIS_CONFIG_SILENT_SUPPORT + int instdir_error; + int rtl; + int errlvl; + int alter_reg_view; + int status_update; } exec_flags_t; #ifndef NSISCALL -# define NSISCALL __stdcall +# define NSISCALL __stdcall #endif -typedef struct -{ - exec_flags_t* exec_flags; - int ( NSISCALL* ExecuteCodeSegment ) ( int, HWND ); - void ( NSISCALL* validate_filename ) ( TCHAR* ); - BOOL ( NSISCALL* RegisterPluginCallback ) ( HMODULE, NSISPLUGINCALLBACK ); +typedef struct { + exec_flags_t *exec_flags; + int (NSISCALL *ExecuteCodeSegment)(int, HWND); + void (NSISCALL *validate_filename)(TCHAR *); + BOOL (NSISCALL *RegisterPluginCallback)(HMODULE, NSISPLUGINCALLBACK); } extra_parameters; // Definitions for page showing plug-ins // See Ui.c to understand better how they're used // sent to the outer window to tell it to go to the next inner window -#define WM_NOTIFY_OUTER_NEXT ( WM_USER + 0x8 ) +#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8) // custom pages should send this message to let NSIS know they're ready -#define WM_NOTIFY_CUSTOM_READY ( WM_USER + 0xd ) +#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd) // sent as wParam with WM_NOTIFY_OUTER_NEXT when user cancels - heed its warning #define NOTIFY_BYE_BYE 'x' diff --git a/windows/nsProcess/nsis_tchar.h b/windows/nsProcess/nsis_tchar.h index 9ba80d5f6d..92025ccc5e 100644 --- a/windows/nsProcess/nsis_tchar.h +++ b/windows/nsProcess/nsis_tchar.h @@ -1,10 +1,10 @@ /* * nsis_tchar.h - * + * * This file is a part of NSIS. - * + * * Copyright (C) 1999-2007 Nullsoft and Contributors - * + * * This software is provided 'as-is', without any express or implied * warranty. * @@ -17,198 +17,198 @@ #ifdef _UNICODE -# ifndef _T -# define __T( x ) L##x -# define _T( x ) __T ( x ) -# define _TEXT( x ) __T ( x ) -# endif +#ifndef _T +#define __T(x) L ## x +#define _T(x) __T(x) +#define _TEXT(x) __T(x) +#endif typedef wchar_t TCHAR; typedef wchar_t _TUCHAR; // program -# define _tmain wmain -# define _tWinMain wWinMain -# define _tenviron _wenviron -# define __targv __wargv +#define _tmain wmain +#define _tWinMain wWinMain +#define _tenviron _wenviron +#define __targv __wargv // printfs -# define _ftprintf fwprintf -# define _sntprintf _snwprintf -# define _stprintf _swprintf -# define _tprintf wprintf -# define _vftprintf vfwprintf -# define _vsntprintf _vsnwprintf -# define _vstprintf _vswprintf +#define _ftprintf fwprintf +#define _sntprintf _snwprintf +#define _stprintf _swprintf +#define _tprintf wprintf +#define _vftprintf vfwprintf +#define _vsntprintf _vsnwprintf +#define _vstprintf _vswprintf // scanfs -# define _tscanf wscanf -# define _stscanf swscanf +#define _tscanf wscanf +#define _stscanf swscanf // string manipulations -# define _tcscat wcscat -# define _tcschr wcschr -# define _tcsclen wcslen -# define _tcscpy wcscpy -# define _tcsdup _wcsdup -# define _tcslen wcslen -# define _tcsnccpy wcsncpy -# define _tcsncpy wcsncpy -# define _tcsrchr wcsrchr -# define _tcsstr wcsstr -# define _tcstok wcstok +#define _tcscat wcscat +#define _tcschr wcschr +#define _tcsclen wcslen +#define _tcscpy wcscpy +#define _tcsdup _wcsdup +#define _tcslen wcslen +#define _tcsnccpy wcsncpy +#define _tcsncpy wcsncpy +#define _tcsrchr wcsrchr +#define _tcsstr wcsstr +#define _tcstok wcstok // string comparisons -# define _tcscmp wcscmp -# define _tcsicmp _wcsicmp -# define _tcsncicmp _wcsnicmp -# define _tcsncmp wcsncmp -# define _tcsnicmp _wcsnicmp +#define _tcscmp wcscmp +#define _tcsicmp _wcsicmp +#define _tcsncicmp _wcsnicmp +#define _tcsncmp wcsncmp +#define _tcsnicmp _wcsnicmp // upper / lower -# define _tcslwr _wcslwr -# define _tcsupr _wcsupr -# define _totlower towlower -# define _totupper towupper +#define _tcslwr _wcslwr +#define _tcsupr _wcsupr +#define _totlower towlower +#define _totupper towupper // conversions to numbers -# define _tcstoi64 _wcstoi64 -# define _tcstol wcstol -# define _tcstoul wcstoul -# define _tstof _wtof -# define _tstoi _wtoi -# define _tstoi64 _wtoi64 -# define _ttoi _wtoi -# define _ttoi64 _wtoi64 -# define _ttol _wtol +#define _tcstoi64 _wcstoi64 +#define _tcstol wcstol +#define _tcstoul wcstoul +#define _tstof _wtof +#define _tstoi _wtoi +#define _tstoi64 _wtoi64 +#define _ttoi _wtoi +#define _ttoi64 _wtoi64 +#define _ttol _wtol // conversion from numbers to strings -# define _itot _itow -# define _ltot _ltow -# define _i64tot _i64tow -# define _ui64tot _ui64tow +#define _itot _itow +#define _ltot _ltow +#define _i64tot _i64tow +#define _ui64tot _ui64tow // file manipulations -# define _tfopen _wfopen -# define _topen _wopen -# define _tremove _wremove -# define _tunlink _wunlink +#define _tfopen _wfopen +#define _topen _wopen +#define _tremove _wremove +#define _tunlink _wunlink // reading and writing to i/o -# define _fgettc fgetwc -# define _fgetts fgetws -# define _fputts fputws -# define _gettchar getwchar +#define _fgettc fgetwc +#define _fgetts fgetws +#define _fputts fputws +#define _gettchar getwchar // directory -# define _tchdir _wchdir +#define _tchdir _wchdir // environment -# define _tgetenv _wgetenv -# define _tsystem _wsystem +#define _tgetenv _wgetenv +#define _tsystem _wsystem // time -# define _tcsftime wcsftime +#define _tcsftime wcsftime #else // ANSI -# ifndef _T -# define _T( x ) x -# define _TEXT( x ) x -# endif -typedef char TCHAR; -typedef unsigned char _TUCHAR; +#ifndef _T +#define _T(x) x +#define _TEXT(x) x +#endif +typedef char TCHAR; +typedef unsigned char _TUCHAR; // program -# define _tmain main -# define _tWinMain WinMain -# define _tenviron environ -# define __targv __argv +#define _tmain main +#define _tWinMain WinMain +#define _tenviron environ +#define __targv __argv // printfs -# define _ftprintf fprintf -# define _sntprintf _snprintf -# define _stprintf sprintf -# define _tprintf printf -# define _vftprintf vfprintf -# define _vsntprintf _vsnprintf -# define _vstprintf vsprintf +#define _ftprintf fprintf +#define _sntprintf _snprintf +#define _stprintf sprintf +#define _tprintf printf +#define _vftprintf vfprintf +#define _vsntprintf _vsnprintf +#define _vstprintf vsprintf // scanfs -# define _tscanf scanf -# define _stscanf sscanf +#define _tscanf scanf +#define _stscanf sscanf // string manipulations -# define _tcscat strcat -# define _tcschr strchr -# define _tcsclen strlen -# define _tcscnlen strnlen -# define _tcscpy strcpy -# define _tcsdup _strdup -# define _tcslen strlen -# define _tcsnccpy strncpy -# define _tcsrchr strrchr -# define _tcsstr strstr -# define _tcstok strtok +#define _tcscat strcat +#define _tcschr strchr +#define _tcsclen strlen +#define _tcscnlen strnlen +#define _tcscpy strcpy +#define _tcsdup _strdup +#define _tcslen strlen +#define _tcsnccpy strncpy +#define _tcsrchr strrchr +#define _tcsstr strstr +#define _tcstok strtok // string comparisons -# define _tcscmp strcmp -# define _tcsicmp _stricmp -# define _tcsncmp strncmp -# define _tcsncicmp _strnicmp -# define _tcsnicmp _strnicmp +#define _tcscmp strcmp +#define _tcsicmp _stricmp +#define _tcsncmp strncmp +#define _tcsncicmp _strnicmp +#define _tcsnicmp _strnicmp // upper / lower -# define _tcslwr _strlwr -# define _tcsupr _strupr +#define _tcslwr _strlwr +#define _tcsupr _strupr -# define _totupper toupper -# define _totlower tolower +#define _totupper toupper +#define _totlower tolower // conversions to numbers -# define _tcstol strtol -# define _tcstoul strtoul -# define _tstof atof -# define _tstoi atoi -# define _tstoi64 _atoi64 -# define _tstoi64 _atoi64 -# define _ttoi atoi -# define _ttoi64 _atoi64 -# define _ttol atol +#define _tcstol strtol +#define _tcstoul strtoul +#define _tstof atof +#define _tstoi atoi +#define _tstoi64 _atoi64 +#define _tstoi64 _atoi64 +#define _ttoi atoi +#define _ttoi64 _atoi64 +#define _ttol atol // conversion from numbers to strings -# define _i64tot _i64toa -# define _itot _itoa -# define _ltot _ltoa -# define _ui64tot _ui64toa +#define _i64tot _i64toa +#define _itot _itoa +#define _ltot _ltoa +#define _ui64tot _ui64toa // file manipulations -# define _tfopen fopen -# define _topen _open -# define _tremove remove -# define _tunlink _unlink +#define _tfopen fopen +#define _topen _open +#define _tremove remove +#define _tunlink _unlink // reading and writing to i/o -# define _fgettc fgetc -# define _fgetts fgets -# define _fputts fputs -# define _gettchar getchar +#define _fgettc fgetc +#define _fgetts fgets +#define _fputts fputs +#define _gettchar getchar // directory -# define _tchdir _chdir +#define _tchdir _chdir // environment -# define _tgetenv getenv -# define _tsystem system +#define _tgetenv getenv +#define _tsystem system // time -# define _tcsftime strftime +#define _tcsftime strftime #endif // is functions (the same in Unicode / ANSI) -#define _istgraph isgraph -#define _istascii __isascii +#define _istgraph isgraph +#define _istascii __isascii -#define __TFILE__ _T ( __FILE__ ) -#define __TDATE__ _T ( __DATE__ ) -#define __TTIME__ _T ( __TIME__ ) +#define __TFILE__ _T(__FILE__) +#define __TDATE__ _T(__DATE__) +#define __TTIME__ _T(__TIME__) diff --git a/windows/nsProcess/pluginapi.h b/windows/nsProcess/pluginapi.h index fed8c16f07..b9bfee91c9 100644 --- a/windows/nsProcess/pluginapi.h +++ b/windows/nsProcess/pluginapi.h @@ -2,99 +2,95 @@ #define ___NSIS_PLUGIN__H___ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #include "api.h" #include "nsis_tchar.h" #ifndef NSISCALL -# define NSISCALL __stdcall +# define NSISCALL __stdcall #endif -#define EXDLL_INIT() \ - { \ - g_stringsize = string_size; \ - g_stacktop = stacktop; \ - g_variables = variables; \ - } - - typedef struct _stack_t - { - struct _stack_t* next; - TCHAR text[1]; // this should be the length of string_size - } stack_t; - - enum - { - INST_0, // $0 - INST_1, // $1 - INST_2, // $2 - INST_3, // $3 - INST_4, // $4 - INST_5, // $5 - INST_6, // $6 - INST_7, // $7 - INST_8, // $8 - INST_9, // $9 - INST_R0, // $R0 - INST_R1, // $R1 - INST_R2, // $R2 - INST_R3, // $R3 - INST_R4, // $R4 - INST_R5, // $R5 - INST_R6, // $R6 - INST_R7, // $R7 - INST_R8, // $R8 - INST_R9, // $R9 - INST_CMDLINE, // $CMDLINE - INST_INSTDIR, // $INSTDIR - INST_OUTDIR, // $OUTDIR - INST_EXEDIR, // $EXEDIR - INST_LANG, // $LANGUAGE - __INST_LAST - }; - - extern unsigned int g_stringsize; - extern stack_t** g_stacktop; - extern TCHAR* g_variables; - - int NSISCALL popstring ( TCHAR* str ); // 0 on success, 1 on empty stack - int NSISCALL popstringn ( TCHAR* str, int maxlen ); // with length limit, pass 0 for g_stringsize - int NSISCALL popint(); // pops an integer - int NSISCALL popint_or(); // with support for or'ing (2|4|8) - int NSISCALL myatoi ( const TCHAR* s ); // converts a string to an integer - unsigned NSISCALL myatou ( const TCHAR* s ); // converts a string to an unsigned integer, decimal only - int NSISCALL myatoi_or ( const TCHAR* s ); // with support for or'ing (2|4|8) - void NSISCALL pushstring ( const TCHAR* str ); - void NSISCALL pushint ( int value ); - TCHAR* NSISCALL getuservariable ( const int varnum ); - void NSISCALL setuservariable ( const int varnum, const TCHAR* var ); +#define EXDLL_INIT() { \ + g_stringsize=string_size; \ + g_stacktop=stacktop; \ + g_variables=variables; } + +typedef struct _stack_t { + struct _stack_t *next; + TCHAR text[1]; // this should be the length of string_size +} stack_t; + +enum +{ +INST_0, // $0 +INST_1, // $1 +INST_2, // $2 +INST_3, // $3 +INST_4, // $4 +INST_5, // $5 +INST_6, // $6 +INST_7, // $7 +INST_8, // $8 +INST_9, // $9 +INST_R0, // $R0 +INST_R1, // $R1 +INST_R2, // $R2 +INST_R3, // $R3 +INST_R4, // $R4 +INST_R5, // $R5 +INST_R6, // $R6 +INST_R7, // $R7 +INST_R8, // $R8 +INST_R9, // $R9 +INST_CMDLINE, // $CMDLINE +INST_INSTDIR, // $INSTDIR +INST_OUTDIR, // $OUTDIR +INST_EXEDIR, // $EXEDIR +INST_LANG, // $LANGUAGE +__INST_LAST +}; + +extern unsigned int g_stringsize; +extern stack_t **g_stacktop; +extern TCHAR *g_variables; + +int NSISCALL popstring(TCHAR *str); // 0 on success, 1 on empty stack +int NSISCALL popstringn(TCHAR *str, int maxlen); // with length limit, pass 0 for g_stringsize +int NSISCALL popint(); // pops an integer +int NSISCALL popint_or(); // with support for or'ing (2|4|8) +int NSISCALL myatoi(const TCHAR *s); // converts a string to an integer +unsigned NSISCALL myatou(const TCHAR *s); // converts a string to an unsigned integer, decimal only +int NSISCALL myatoi_or(const TCHAR *s); // with support for or'ing (2|4|8) +void NSISCALL pushstring(const TCHAR *str); +void NSISCALL pushint(int value); +TCHAR * NSISCALL getuservariable(const int varnum); +void NSISCALL setuservariable(const int varnum, const TCHAR *var); #ifdef _UNICODE -# define PopStringW( x ) popstring ( x ) -# define PushStringW( x ) pushstring ( x ) -# define SetUserVariableW( x, y ) setuservariable ( x, y ) +#define PopStringW(x) popstring(x) +#define PushStringW(x) pushstring(x) +#define SetUserVariableW(x,y) setuservariable(x,y) - int NSISCALL PopStringA ( char* ansiStr ); - void NSISCALL PushStringA ( const char* ansiStr ); - void NSISCALL GetUserVariableW ( const int varnum, wchar_t* wideStr ); - void NSISCALL GetUserVariableA ( const int varnum, char* ansiStr ); - void NSISCALL SetUserVariableA ( const int varnum, const char* ansiStr ); +int NSISCALL PopStringA(char* ansiStr); +void NSISCALL PushStringA(const char* ansiStr); +void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr); +void NSISCALL GetUserVariableA(const int varnum, char* ansiStr); +void NSISCALL SetUserVariableA(const int varnum, const char* ansiStr); #else // ANSI defs -# define PopStringA( x ) popstring ( x ) -# define PushStringA( x ) pushstring ( x ) -# define SetUserVariableA( x, y ) setuservariable ( x, y ) +#define PopStringA(x) popstring(x) +#define PushStringA(x) pushstring(x) +#define SetUserVariableA(x,y) setuservariable(x,y) -int NSISCALL PopStringW ( wchar_t* wideStr ); -void NSISCALL PushStringW ( wchar_t* wideStr ); -void NSISCALL GetUserVariableW ( const int varnum, wchar_t* wideStr ); -void NSISCALL GetUserVariableA ( const int varnum, char* ansiStr ); -void NSISCALL SetUserVariableW ( const int varnum, const wchar_t* wideStr ); +int NSISCALL PopStringW(wchar_t* wideStr); +void NSISCALL PushStringW(wchar_t* wideStr); +void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr); +void NSISCALL GetUserVariableA(const int varnum, char* ansiStr); +void NSISCALL SetUserVariableW(const int varnum, const wchar_t* wideStr); #endif @@ -102,4 +98,4 @@ void NSISCALL SetUserVariableW ( const int varnum, const wchar_t* wideStr ); } #endif -#endif //!___NSIS_PLUGIN__H___ +#endif//!___NSIS_PLUGIN__H___