Jim Park's Unicode NSIS merging - Step 2 : merge TCHARs changes into trunk

Compiler output is identical before & after this step

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6037 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
wizou 2010-03-26 17:18:17 +00:00
commit cdf7735a77
206 changed files with 8437 additions and 6403 deletions

View file

@ -4,8 +4,12 @@
** Author: Justin Frankel
** File: asyncdns.cpp - JNL portable asynchronous DNS implementation
** License: see License.txt
**
** Unicode support by Jim Park -- 08/24/2007
*/
// Jim Park: For Unicode Support, all string functions must explicitly use
// ANSI versions if UNICODE is defined.
#include "netinc.h"
#include "util.h"
@ -47,7 +51,7 @@ int JNL_AsyncDNS::resolve(char *hostname, unsigned long *addr)
return 0;
}
if (lstrcmpi(m_hostname,hostname)) m_addr=0;
if (lstrcmpiA(m_hostname,hostname)) m_addr=0;
else if (m_addr == INADDR_NONE)
{
wait_for_thread_death();
@ -59,7 +63,7 @@ int JNL_AsyncDNS::resolve(char *hostname, unsigned long *addr)
wait_for_thread_death();
return 0;
}
lstrcpy(m_hostname,hostname);
lstrcpyA(m_hostname,hostname);
if (!m_thread)
{

View file

@ -1,39 +1,43 @@
/*
** JNetLib
** Copyright (C) 2000-2001 Nullsoft, Inc.
** Author: Justin Frankel
** File: asyncdns.h - JNL portable asynchronous DNS interface
** License: see License.txt
**
** Usage:
** 1. Create JNL_AsyncDNS object, optionally with the number of cache entries.
** 2. call resolve() to resolve a hostname into an address. The return value of
** resolve is 0 on success (host successfully resolved), 1 on wait (meaning
** try calling resolve() with the same hostname in a few hundred milliseconds
** or so), or -1 on error (i.e. the host can't resolve).
** 4. enjoy.
*/
#ifndef _ASYNCDNS_H_
#define _ASYNCDNS_H_
class JNL_AsyncDNS
{
public:
JNL_AsyncDNS();
~JNL_AsyncDNS();
int resolve(char *hostname, unsigned long *addr); // return 0 on success, 1 on wait, -1 on unresolvable
private:
void wait_for_thread_death();
char m_hostname[256];
unsigned long m_addr;
HANDLE m_thread;
static unsigned long WINAPI _threadfunc(LPVOID _d);
};
#endif //_ASYNCDNS_H_
/*
** JNetLib
** Copyright (C) 2000-2001 Nullsoft, Inc.
** Author: Justin Frankel
** File: asyncdns.h - JNL portable asynchronous DNS interface
** License: see License.txt
**
** Usage:
** 1. Create JNL_AsyncDNS object, optionally with the number of cache entries.
** 2. call resolve() to resolve a hostname into an address. The return value of
** resolve is 0 on success (host successfully resolved), 1 on wait (meaning
** try calling resolve() with the same hostname in a few hundred milliseconds
** or so), or -1 on error (i.e. the host can't resolve).
** 4. enjoy.
**
** Unicode support by Jim Park -- 08/24/2007
*/
// Jim Park: Inet host name is strictly ANSI, no UNICODE for now.
#ifndef _ASYNCDNS_H_
#define _ASYNCDNS_H_
class JNL_AsyncDNS
{
public:
JNL_AsyncDNS();
~JNL_AsyncDNS();
int resolve(char *hostname, unsigned long *addr); // return 0 on success, 1 on wait, -1 on unresolvable
private:
void wait_for_thread_death();
char m_hostname[256];
unsigned long m_addr;
HANDLE m_thread;
static unsigned long WINAPI _threadfunc(LPVOID _d);
};
#endif //_ASYNCDNS_H_

View file

@ -4,6 +4,8 @@
** Author: Justin Frankel
** File: connection.cpp - JNL TCP connection implementation
** License: see License.txt
**
** Unicode support by Jim Park -- 08/24/2007
*/
#include "netinc.h"

View file

@ -50,6 +50,9 @@
** make the socket close after sending all the data sent.
**
** 8. delete ye' ol' object.
**
** Unicode support by Jim Park -- 08/24/2007
** Keep all the stuff here strictly ANSI.
*/
#ifndef _CONNECTION_H_

View file

@ -4,6 +4,8 @@
** Author: Justin Frankel
** File: httpget.cpp - JNL HTTP GET implementation
** License: see License.txt
**
** Unicode support by Jim Park -- 08/24/2007
*/
#include "netinc.h"
@ -179,14 +181,14 @@ void JNL_HTTPGet::connect(char *url)
if (!m_http_proxyhost || !m_http_proxyhost[0])
{
wsprintf(str,"GET %s HTTP/1.0\r\n",m_http_request);
wsprintfA(str,"GET %s HTTP/1.0\r\n",m_http_request);
}
else
{
wsprintf(str,"GET %s HTTP/1.0\r\n",m_http_url);
wsprintfA(str,"GET %s HTTP/1.0\r\n",m_http_url);
}
wsprintf(str+strlen(str),"Host: %s\r\n",m_http_host);
wsprintfA(str+strlen(str),"Host: %s\r\n",m_http_host);
if (m_http_lpinfo&&m_http_lpinfo[0])
{

View file

@ -1,109 +1,113 @@
/*
** JNetLib
** Copyright (C) 2000-2001 Nullsoft, Inc.
** Author: Justin Frankel
** File: httpget.h - JNL interface for doing HTTP GETs.
** License: see License.txt
**
** Usage:
** 1. Create a JNL_HTTPGet object, optionally specifying a JNL_AsyncDNS
** object to use (or NULL for none, or JNL_CONNECTION_AUTODNS for auto),
** and the receive buffer size, and a string specifying proxy (or NULL
** for none). See note on proxy string below.
** 2. call addheader() to add whatever headers you want. It is recommended to
** add at least the following two:
** addheader("User-Agent:MyApp (Mozilla)");
*/// addheader("Accept:*/*");
/* ( the comment weirdness is there so I Can do the star-slash :)
** 3. Call connect() with the URL you wish to GET (see URL string note below)
** 4. Call run() once in a while, checking to see if it returns -1
** (if it does return -1, call geterrorstr() to see what the error is).
** (if it returns 1, no big deal, the connection has closed).
** 5. While you're at it, you can call bytes_available() to see if any data
** from the http stream is available, or getheader() to see if any headers
** are available, or getreply() to see the HTTP reply, or getallheaders()
** to get a double null terminated, null delimited list of headers returned.
** 6. If you want to read from the stream, call get_bytes (which returns how much
** was actually read).
** 7. content_length() is a helper function that uses getheader() to check the
** content-length header.
** 8. Delete ye' ol' object when done.
**
** Proxy String:
** should be in the format of host:port, or user@host:port, or
** user:password@host:port. if port is not specified, 80 is assumed.
** URL String:
** should be in the format of http://user:pass@host:port/requestwhatever
** note that user, pass, port, and /requestwhatever are all optional :)
** note that also, http:// is really not important. if you do poo://
** or even leave out the http:// altogether, it will still work.
*/
#ifndef _HTTPGET_H_
#define _HTTPGET_H_
#include "connection.h"
class JNL_HTTPGet
{
public:
JNL_HTTPGet(JNL_AsyncDNS *dns=JNL_CONNECTION_AUTODNS, int recvbufsize=16384, char *proxy=NULL);
~JNL_HTTPGet();
void addheader(char *header);
void connect(char *url);
int run(); // returns: 0 if all is OK. -1 if error (call geterrorstr()). 1 if connection closed.
int get_status(); // returns 0 if connecting, 1 if reading headers,
// 2 if reading content, -1 if error.
char *getallheaders(); // double null terminated, null delimited list
char *getheader(char *headername);
char *getreply() { return m_reply; }
int getreplycode(); // returns 0 if none yet, otherwise returns http reply code.
char *geterrorstr() { return m_errstr;}
int bytes_available();
int get_bytes(char *buf, int len);
int peek_bytes(char *buf, int len);
__int64 content_length();
JNL_Connection *get_con() { return m_con; }
public:
void reinit();
void deinit();
void seterrstr(char *str) { if (m_errstr) free(m_errstr); m_errstr=(char*)malloc(strlen(str)+1); strcpy(m_errstr,str); }
void do_parse_url(char *url, char **host, int *port, char **req, char **lp);
void do_encode_mimestr(char *in, char *out);
JNL_AsyncDNS *m_dns;
JNL_Connection *m_con;
int m_recvbufsize;
int m_http_state;
int m_http_port;
char *m_http_url;
char *m_http_host;
char *m_http_lpinfo;
char *m_http_request;
char *m_http_proxylpinfo;
char *m_http_proxyhost;
int m_http_proxyport;
char *m_sendheaders;
char *m_recvheaders;
int m_recvheaders_size;
char *m_reply;
char *m_errstr;
};
#endif // _HTTPGET_H_
/*
** JNetLib
** Copyright (C) 2000-2001 Nullsoft, Inc.
** Author: Justin Frankel
** File: httpget.h - JNL interface for doing HTTP GETs.
** License: see License.txt
**
** Usage:
** 1. Create a JNL_HTTPGet object, optionally specifying a JNL_AsyncDNS
** object to use (or NULL for none, or JNL_CONNECTION_AUTODNS for auto),
** and the receive buffer size, and a string specifying proxy (or NULL
** for none). See note on proxy string below.
** 2. call addheader() to add whatever headers you want. It is recommended to
** add at least the following two:
** addheader("User-Agent:MyApp (Mozilla)");
*/// addheader("Accept:*/*");
/* ( the comment weirdness is there so I Can do the star-slash :)
** 3. Call connect() with the URL you wish to GET (see URL string note below)
** 4. Call run() once in a while, checking to see if it returns -1
** (if it does return -1, call geterrorstr() to see what the error is).
** (if it returns 1, no big deal, the connection has closed).
** 5. While you're at it, you can call bytes_available() to see if any data
** from the http stream is available, or getheader() to see if any headers
** are available, or getreply() to see the HTTP reply, or getallheaders()
** to get a double null terminated, null delimited list of headers returned.
** 6. If you want to read from the stream, call get_bytes (which returns how much
** was actually read).
** 7. content_length() is a helper function that uses getheader() to check the
** content-length header.
** 8. Delete ye' ol' object when done.
**
** Proxy String:
** should be in the format of host:port, or user@host:port, or
** user:password@host:port. if port is not specified, 80 is assumed.
** URL String:
** should be in the format of http://user:pass@host:port/requestwhatever
** note that user, pass, port, and /requestwhatever are all optional :)
** note that also, http:// is really not important. if you do poo://
** or even leave out the http:// altogether, it will still work.
**
** Reviewed for Unicode support by Jim Park -- 08/24/2004
** Everything remains ANSI. Made sure all TCHAR style functions were
** changed to strictly ANSI.
*/
#ifndef _HTTPGET_H_
#define _HTTPGET_H_
#include "connection.h"
class JNL_HTTPGet
{
public:
JNL_HTTPGet(JNL_AsyncDNS *dns=JNL_CONNECTION_AUTODNS, int recvbufsize=16384, char *proxy=NULL);
~JNL_HTTPGet();
void addheader(char *header);
void connect(char *url);
int run(); // returns: 0 if all is OK. -1 if error (call geterrorstr()). 1 if connection closed.
int get_status(); // returns 0 if connecting, 1 if reading headers,
// 2 if reading content, -1 if error.
char *getallheaders(); // double null terminated, null delimited list
char *getheader(char *headername);
char *getreply() { return m_reply; }
int getreplycode(); // returns 0 if none yet, otherwise returns http reply code.
char *geterrorstr() { return m_errstr;}
int bytes_available();
int get_bytes(char *buf, int len);
int peek_bytes(char *buf, int len);
__int64 content_length();
JNL_Connection *get_con() { return m_con; }
public:
void reinit();
void deinit();
void seterrstr(char *str) { if (m_errstr) free(m_errstr); m_errstr=(char*)malloc(strlen(str)+1); strcpy(m_errstr,str); }
void do_parse_url(char *url, char **host, int *port, char **req, char **lp);
void do_encode_mimestr(char *in, char *out);
JNL_AsyncDNS *m_dns;
JNL_Connection *m_con;
int m_recvbufsize;
int m_http_state;
int m_http_port;
char *m_http_url;
char *m_http_host;
char *m_http_lpinfo;
char *m_http_request;
char *m_http_proxylpinfo;
char *m_http_proxyhost;
int m_http_proxyport;
char *m_sendheaders;
char *m_recvheaders;
int m_recvheaders_size;
char *m_reply;
char *m_errstr;
};
#endif // _HTTPGET_H_

View file

@ -1,42 +1,46 @@
/*
** JNetLib
** Copyright (C) 2000-2001 Nullsoft, Inc.
** Author: Justin Frankel
** File: netinc.h - network includes and portability defines (used internally)
** License: see License.txt
*/
#ifndef _NETINC_H_
#define _NETINC_H_
#include <windows.h>
#include "util.h"
#define strcasecmp(x,y) stricmp(x,y)
#define ERRNO (WSAGetLastError())
#define SET_SOCK_BLOCK(s,block) { unsigned long __i=block?0:1; ioctlsocket(s,FIONBIO,&__i); }
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEWOULDBLOCK
#define memset mini_memset
#define memcpy mini_memcpy
#define strcpy lstrcpy
#define strncpy lstrcpyn
#define strcat lstrcat
#define strlen lstrlen
#define malloc(x) (new char[x])
#define free(x) {delete [] x;}
typedef int socklen_t;
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
#ifndef INADDR_ANY
#define INADDR_ANY 0
#endif
#ifndef SHUT_RDWR
#define SHUT_RDWR 2
#endif
#endif //_NETINC_H_
/*
** JNetLib
** Copyright (C) 2000-2001 Nullsoft, Inc.
** Author: Justin Frankel
** File: netinc.h - network includes and portability defines (used internally)
** License: see License.txt
**
** Unicode support by Jim Park -- 08/24/2007
*/
#ifndef _NETINC_H_
#define _NETINC_H_
#include <windows.h>
#include "util.h"
#define strcasecmp(x,y) stricmp(x,y)
#define ERRNO (WSAGetLastError())
#define SET_SOCK_BLOCK(s,block) { unsigned long __i=block?0:1; ioctlsocket(s,FIONBIO,&__i); }
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEWOULDBLOCK
#define memset mini_memset
#define memcpy mini_memcpy
// Jim Park: For Unicode support, we need to distinguish whether we are working on
// Unicode or ANSI.
#define strcpy lstrcpyA
#define strncpy lstrcpynA
#define strcat lstrcatA
#define strlen lstrlenA
#define malloc(x) (new char[x])
#define free(x) {delete [] x;}
typedef int socklen_t;
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
#ifndef INADDR_ANY
#define INADDR_ANY 0
#endif
#ifndef SHUT_RDWR
#define SHUT_RDWR 2
#endif
#endif //_NETINC_H_

File diff suppressed because it is too large Load diff

View file

@ -1,85 +1,88 @@
/*
** JNetLib
** Copyright (C) 2000-2001 Nullsoft, Inc.
** Author: Justin Frankel
** File: util.cpp - JNL implementation of basic network utilities
** License: see License.txt
*/
#include "netinc.h"
#include "util.h"
int my_atoi(char *s)
{
int sign=0;
int v=0;
if (*s == '-') { s++; sign++; }
for (;;)
{
int c=*s++ - '0';
if (c < 0 || c > 9) break;
v*=10;
v+=c;
}
if (sign) return -(int) v;
return (int)v;
}
__int64 myatoi64(char *s)
{
__int64 v=0;
int sign=0;
if (*s == '-')
sign++;
else
s--;
for (;;)
{
int c=*(++s) - '0';
if (c < 0 || c > 9) break;
v*=10;
v+=c;
}
if (sign)
v = -v;
return v;
}
void myitoa64(__int64 i, char *buffer)
{
char buf[128], *b = buf;
if (i < 0)
{
*(buffer++) = '-';
i = -i;
}
if (i == 0) *(buffer++) = '0';
else
{
while (i > 0)
{
*(b++) = '0' + ((char) (i%10));
i /= 10;
}
while (b > buf) *(buffer++) = *(--b);
}
*buffer = 0;
}
void mini_memset(void *o,char i,int l)
{
char *oo=(char*)o;
while (l-- > 0) *oo++=i;
}
void mini_memcpy(void *o,void*i,int l)
{
char *oo=(char*)o;
char *ii=(char*)i;
while (l-- > 0) *oo++=*ii++;
}
/*
** JNetLib
** Copyright (C) 2000-2001 Nullsoft, Inc.
** Author: Justin Frankel
** File: util.cpp - JNL implementation of basic network utilities
** License: see License.txt
**
** Unicode support by Jim Park -- 08/24/2007
** Keep everything here strictly ANSI. No TCHAR style stuff.
*/
#include "netinc.h"
#include "util.h"
int my_atoi(char *s)
{
int sign=0;
int v=0;
if (*s == '-') { s++; sign++; }
for (;;)
{
int c=*s++ - '0';
if (c < 0 || c > 9) break;
v*=10;
v+=c;
}
if (sign) return -(int) v;
return (int)v;
}
__int64 myatoi64(char *s)
{
__int64 v=0;
int sign=0;
if (*s == '-')
sign++;
else
s--;
for (;;)
{
int c=*(++s) - '0';
if (c < 0 || c > 9) break;
v*=10;
v+=c;
}
if (sign)
v = -v;
return v;
}
void myitoa64(__int64 i, char *buffer)
{
char buf[128], *b = buf;
if (i < 0)
{
*(buffer++) = '-';
i = -i;
}
if (i == 0) *(buffer++) = '0';
else
{
while (i > 0)
{
*(b++) = '0' + ((char) (i%10));
i /= 10;
}
while (b > buf) *(buffer++) = *(--b);
}
*buffer = 0;
}
void mini_memset(void *o,char i,int l)
{
char *oo=(char*)o;
while (l-- > 0) *oo++=i;
}
void mini_memcpy(void *o,void*i,int l)
{
char *oo=(char*)o;
char *ii=(char*)i;
while (l-- > 0) *oo++=*ii++;
}

View file

@ -19,9 +19,11 @@
** gives you the integer representation of a ip address in dotted
** decimal form.
**
** JNL::addr_to_ipstr(unsigned long addr, char *host, int maxhostlen);
** JNL::addr_to_ipstr(unsigned long addr, char *host, int maxhostlen);
** gives you the dotted decimal notation of an integer ip address.
**
** Reviewed for Unicode support by Jim Park -- 08/24/2007
** Keep the functions here strictly ANSI.
*/
#ifndef _UTIL_H_