
Compiler output is identical before & after this step git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/branches/wizou@6036 212acab6-be3b-0410-9dea-997c60f758d6
70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
/*
|
|
** JNetLib
|
|
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
|
** Author: Justin Frankel
|
|
** File: util.cpp - JNL implementation of basic network utilities
|
|
** License: see jnetlib.h
|
|
**
|
|
** Reviewed for Unicode Support by Jim Park -- 08/17/2007
|
|
** Note: The functions that work on char's should be explicitely set to use the
|
|
** ANSI versions. Some of the functions like wprintf() are #defined to be
|
|
** the wide-char versions when _UNICODE is defined. So these must be explictly
|
|
** set to use the ANSI versions.
|
|
*/
|
|
|
|
#include "netinc.h"
|
|
|
|
#include "util.h"
|
|
|
|
int JNL::open_socketlib()
|
|
{
|
|
#ifdef _WIN32
|
|
WSADATA wsaData;
|
|
if (WSAStartup(MAKEWORD(1, 1), &wsaData)) return 1;
|
|
#endif
|
|
return 0;
|
|
}
|
|
void JNL::close_socketlib()
|
|
{
|
|
#ifdef _WIN32
|
|
WSACleanup();
|
|
#endif
|
|
}
|
|
unsigned long JNL::ipstr_to_addr(const char *cp)
|
|
{
|
|
return ::inet_addr(cp);
|
|
}
|
|
|
|
void JNL::addr_to_ipstr(unsigned long addr, char *host, int maxhostlen)
|
|
{
|
|
struct in_addr a; a.s_addr=addr;
|
|
char *p=::inet_ntoa(a); strncpy(host,p?p:"",maxhostlen);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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++;
|
|
}
|