Removed unused variables and fixed GCC warnings
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6259 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
c6fdb4436d
commit
2d99d7ad3e
26 changed files with 124 additions and 96 deletions
|
@ -27,7 +27,7 @@ JNL_AsyncDNS::~JNL_AsyncDNS()
|
|||
wait_for_thread_death();
|
||||
}
|
||||
|
||||
unsigned long WINAPI JNL_AsyncDNS::_threadfunc(LPVOID _d)
|
||||
DWORD WINAPI JNL_AsyncDNS::_threadfunc(LPVOID _d)
|
||||
{
|
||||
JNL_AsyncDNS *_this=(JNL_AsyncDNS*)_d;
|
||||
struct hostent *hostentry;
|
||||
|
|
|
@ -30,7 +30,7 @@ JNL_Connection::JNL_Connection(JNL_AsyncDNS *dns, int sendbufsize, int recvbufsi
|
|||
m_send_buffer_len=sendbufsize;
|
||||
m_recv_buffer=(char*)malloc(m_recv_buffer_len);
|
||||
m_send_buffer=(char*)malloc(m_send_buffer_len);
|
||||
m_socket=-1;
|
||||
m_socket=INVALID_SOCKET;
|
||||
m_remote_port=0;
|
||||
m_state=STATE_NOCONNECTION;
|
||||
m_recv_len=m_recv_pos=0;
|
||||
|
@ -39,7 +39,7 @@ JNL_Connection::JNL_Connection(JNL_AsyncDNS *dns, int sendbufsize, int recvbufsi
|
|||
memset(&m_saddr,0,sizeof(m_saddr));
|
||||
}
|
||||
|
||||
void JNL_Connection::connect(int s, struct sockaddr_in *loc)
|
||||
void JNL_Connection::connect(PORTABLE_SOCKET s, struct sockaddr_in *loc)
|
||||
{
|
||||
close(1);
|
||||
m_socket=s;
|
||||
|
@ -47,7 +47,7 @@ void JNL_Connection::connect(int s, struct sockaddr_in *loc)
|
|||
m_dns=NULL;
|
||||
if (loc) m_saddr=*loc;
|
||||
else memset(&m_saddr,0,sizeof(m_saddr));
|
||||
if (m_socket != -1)
|
||||
if (m_socket != INVALID_SOCKET)
|
||||
{
|
||||
SET_SOCK_BLOCK(m_socket,0);
|
||||
m_state=STATE_CONNECTED;
|
||||
|
@ -64,7 +64,7 @@ void JNL_Connection::connect(char *hostname, int port)
|
|||
close(1);
|
||||
m_remote_port=(short)port;
|
||||
m_socket=::socket(AF_INET,SOCK_STREAM,0);
|
||||
if (m_socket==-1)
|
||||
if (m_socket==INVALID_SOCKET)
|
||||
{
|
||||
m_errorstr="creating socket";
|
||||
m_state=STATE_ERROR;
|
||||
|
@ -83,7 +83,7 @@ void JNL_Connection::connect(char *hostname, int port)
|
|||
else
|
||||
{
|
||||
m_state=STATE_RESOLVING;
|
||||
m_saddr.sin_family=AF_INET;
|
||||
m_saddr.sin_family=AF_INET;
|
||||
m_saddr.sin_port=htons((unsigned short)port);
|
||||
m_saddr.sin_addr.s_addr=inet_addr(hostname);
|
||||
}
|
||||
|
@ -92,11 +92,11 @@ void JNL_Connection::connect(char *hostname, int port)
|
|||
|
||||
JNL_Connection::~JNL_Connection()
|
||||
{
|
||||
if (m_socket >= 0)
|
||||
if (m_socket != INVALID_SOCKET)
|
||||
{
|
||||
::shutdown(m_socket, SHUT_RDWR);
|
||||
::closesocket(m_socket);
|
||||
m_socket=-1;
|
||||
m_socket=INVALID_SOCKET;
|
||||
}
|
||||
free(m_recv_buffer);
|
||||
free(m_send_buffer);
|
||||
|
@ -145,7 +145,7 @@ void JNL_Connection::run(int max_send_bytes, int max_recv_bytes, int *bytes_sent
|
|||
else { m_state=STATE_CONNECTING; }
|
||||
break;
|
||||
case STATE_CONNECTING:
|
||||
{
|
||||
{
|
||||
fd_set f[3];
|
||||
FD_ZERO(&f[0]);
|
||||
FD_ZERO(&f[1]);
|
||||
|
@ -278,12 +278,12 @@ void JNL_Connection::close(int quick)
|
|||
if (quick || m_state == STATE_RESOLVING || m_state == STATE_CONNECTING)
|
||||
{
|
||||
m_state=STATE_CLOSED;
|
||||
if (m_socket >= 0)
|
||||
if (m_socket != INVALID_SOCKET)
|
||||
{
|
||||
::shutdown(m_socket, SHUT_RDWR);
|
||||
::closesocket(m_socket);
|
||||
}
|
||||
m_socket=-1;
|
||||
m_socket=INVALID_SOCKET;
|
||||
memset(m_recv_buffer,0,m_recv_buffer_len);
|
||||
memset(m_send_buffer,0,m_send_buffer_len);
|
||||
m_remote_port=0;
|
||||
|
@ -438,7 +438,7 @@ int JNL_Connection::recv_line(char *line, int maxlength)
|
|||
|
||||
unsigned long JNL_Connection::get_interface(void)
|
||||
{
|
||||
if (m_socket==-1) return 0;
|
||||
if (m_socket==INVALID_SOCKET) return 0;
|
||||
struct sockaddr_in sin;
|
||||
memset(&sin,0,sizeof(sin));
|
||||
socklen_t len=16;
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define _CONNECTION_H_
|
||||
|
||||
#include "asyncdns.h"
|
||||
#include "netinc.h"
|
||||
|
||||
#define JNL_CONNECTION_AUTODNS ((JNL_AsyncDNS*)-1)
|
||||
|
||||
|
@ -80,7 +81,7 @@ class JNL_Connection
|
|||
~JNL_Connection();
|
||||
|
||||
void connect(char *hostname, int port);
|
||||
void connect(int sock, struct sockaddr_in *loc=NULL); // used by the listen object, usually not needed by users.
|
||||
void connect(PORTABLE_SOCKET sock, struct sockaddr_in *loc=NULL); // used by the listen object, usually not needed by users.
|
||||
|
||||
void run(int max_send_bytes=-1, int max_recv_bytes=-1, int *bytes_sent=NULL, int *bytes_rcvd=NULL);
|
||||
int get_state() { return m_state; }
|
||||
|
@ -110,7 +111,7 @@ class JNL_Connection
|
|||
short get_remote_port(void) { return m_remote_port; } // this returns the remote port of connection
|
||||
|
||||
protected:
|
||||
int m_socket;
|
||||
PORTABLE_SOCKET m_socket;
|
||||
short m_remote_port;
|
||||
char *m_recv_buffer;
|
||||
char *m_send_buffer;
|
||||
|
|
|
@ -43,4 +43,10 @@ typedef int socklen_t;
|
|||
#define SHUT_RDWR 2
|
||||
#endif
|
||||
|
||||
#ifndef INVALID_SOCKET
|
||||
#define INVALID_SOCKET -1
|
||||
#endif
|
||||
|
||||
#define PORTABLE_SOCKET SOCKET
|
||||
|
||||
#endif //_NETINC_H_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue