summaryrefslogtreecommitdiff
path: root/src/ladmin
diff options
context:
space:
mode:
authoramber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-04-07 18:00:13 +0000
committeramber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-04-07 18:00:13 +0000
commit1a348ede4934a1ba78f337ee1dffe11a699f4bef (patch)
tree883d4c1ae282fb67e1720f81c20f564499298ff4 /src/ladmin
parent7cb0d361f1b4260b47ab1da99224332947320553 (diff)
parenta6cd6538e4271ea08dc86803e8b7e8c8f235960b (diff)
downloadhercules-1a348ede4934a1ba78f337ee1dffe11a699f4bef.tar.gz
hercules-1a348ede4934a1ba78f337ee1dffe11a699f4bef.tar.bz2
hercules-1a348ede4934a1ba78f337ee1dffe11a699f4bef.tar.xz
hercules-1a348ede4934a1ba78f337ee1dffe11a699f4bef.zip
branch for major stability breakage
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@1440 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/ladmin')
-rw-r--r--src/ladmin/GNUmakefile14
-rw-r--r--src/ladmin/Makefile6
-rw-r--r--src/ladmin/ladmin.c70
-rw-r--r--src/ladmin/md5calc.c6
4 files changed, 40 insertions, 56 deletions
diff --git a/src/ladmin/GNUmakefile b/src/ladmin/GNUmakefile
deleted file mode 100644
index 879edaeea..000000000
--- a/src/ladmin/GNUmakefile
+++ /dev/null
@@ -1,14 +0,0 @@
-all: ladmin
-txt: ladmin
-sql: ladmin
-
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o
-COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h
-
-ladmin: ladmin.o md5calc.o $(COMMON_OBJ)
- $(CC) -o ../../$@ ladmin.o md5calc.o $(COMMON_OBJ)
-ladmin.o: ladmin.c ladmin.h md5calc.h $(COMMON_H)
-md5calc.o: md5calc.c md5calc.h
-
-clean:
- rm -f *.o ../../ladmin
diff --git a/src/ladmin/Makefile b/src/ladmin/Makefile
index 879edaeea..20722350b 100644
--- a/src/ladmin/Makefile
+++ b/src/ladmin/Makefile
@@ -2,11 +2,11 @@ all: ladmin
txt: ladmin
sql: ladmin
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o
-COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h
+COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o
+COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h
ladmin: ladmin.o md5calc.o $(COMMON_OBJ)
- $(CC) -o ../../$@ ladmin.o md5calc.o $(COMMON_OBJ)
+ $(CC) -o ../../$@ ladmin.o md5calc.o $(COMMON_OBJ) $(LIB_S)
ladmin.o: ladmin.c ladmin.h md5calc.h $(COMMON_H)
md5calc.o: md5calc.c md5calc.h
diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c
index 497f3bdab..432a78a95 100644
--- a/src/ladmin/ladmin.c
+++ b/src/ladmin/ladmin.c
@@ -6,27 +6,42 @@
///////////////////////////////////////////////////////////////////////////
#include <sys/types.h>
+#include <time.h>
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <winsock2.h>
+void Gettimeofday(struct timeval *timenow)
+{
+ time_t t;
+ t = clock();
+ timenow->tv_usec = t;
+ timenow->tv_sec = t / CLK_TCK;
+ return;
+}
+#define gettimeofday(timenow, dummy) Gettimeofday(timenow)
+#else
#include <sys/socket.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <netinet/in.h>
#include <sys/time.h> // gettimeofday
-#include <time.h>
#include <sys/ioctl.h>
#include <unistd.h> // close
+#include <arpa/inet.h> // inet_addr
+#include <netdb.h> // gethostbyname
+#endif
+#include <stdio.h>
+#include <stdlib.h>
#include <signal.h>
#include <fcntl.h>
#include <string.h> // str*
-#include <arpa/inet.h> // inet_addr
-#include <netdb.h> // gethostbyname
#include <stdarg.h> // valist
#include <ctype.h> // tolower
-#include "core.h"
-#include "socket.h"
+#include "../common/strlib.h"
+#include "../common/core.h"
+#include "../common/socket.h"
#include "ladmin.h"
-#include "version.h"
-#include "mmo.h"
+#include "../common/version.h"
+#include "../common/mmo.h"
#ifdef PASSWORDENC
#include "md5calc.h"
@@ -266,7 +281,7 @@ int ladmin_log(char *fmt, ...) {
fprintf(logfp, RETCODE);
else {
gettimeofday(&tv, NULL);
- strftime(tmpstr, 24, date_format, localtime(&(tv.tv_sec)));
+ strftime(tmpstr, 24, date_format, localtime((const time_t*)&(tv.tv_sec)));
sprintf(tmpstr + strlen(tmpstr), ".%03d: %s", (int)tv.tv_usec / 1000, fmt);
vfprintf(logfp, tmpstr, ap);
}
@@ -277,23 +292,6 @@ int ladmin_log(char *fmt, ...) {
return 0;
}
-//-----------------------------------------------------
-// Function to suppress control characters in a string.
-//-----------------------------------------------------
-int remove_control_chars(unsigned char *str) {
- int i;
- int change = 0;
-
- for(i = 0; str[i]; i++) {
- if (str[i] < 32) {
- str[i] = '_';
- change = 1;
- }
- }
-
- return change;
-}
-
//---------------------------------------------
// Function to return ordonal text of a number.
//---------------------------------------------
@@ -367,9 +365,9 @@ int verify_accountname(char* account_name) {
//---------------------------------------------------
// E-mail check: return 0 (not correct) or 1 (valid).
//---------------------------------------------------
-int e_mail_check(unsigned char *email) {
+int e_mail_check(char *email) {
char ch;
- unsigned char* last_arobas;
+ char* last_arobas;
// athena limits
if (strlen(email) < 3 || strlen(email) > 39)
@@ -3252,7 +3250,7 @@ int parse_fromlogin(int fd) {
}
// printf("parse_fromlogin : %d %d %d\n", fd, RFIFOREST(fd), RFIFOW(fd,0));
- sd = session[fd]->session_data;
+ sd = (struct char_session_data*)session[fd]->session_data;
while(RFIFOREST(fd) >= 2) {
switch(RFIFOW(fd,0)) {
@@ -3302,11 +3300,11 @@ int parse_fromlogin(int fd) {
memcpy(md5key, RFIFOP(fd,4), RFIFOW(fd,2) - 4);
md5key[sizeof(md5key)-1] = '0';
if (passenc == 1) {
- strncpy(md5str, RFIFOP(fd,4), RFIFOW(fd,2) - 4);
+ strncpy(md5str, (const char*)RFIFOP(fd,4), RFIFOW(fd,2) - 4);
strcat(md5str, loginserveradminpassword);
} else if (passenc == 2) {
strncpy(md5str, loginserveradminpassword, sizeof(loginserveradminpassword));
- strcat(md5str, RFIFOP(fd,4));
+ strcat(md5str, (const char*)RFIFOP(fd,4));
}
MD5_String2binary(md5str, md5bin);
WFIFOW(login_fd,0) = 0x7918; // Request for administation login (encrypted password)
@@ -3801,7 +3799,7 @@ int parse_fromlogin(int fd) {
case 0x7947: // answer of an account name search
if (RFIFOREST(fd) < 30)
return 0;
- if (strcmp(RFIFOP(fd,6), "") == 0) {
+ if (strcmp((const char*)RFIFOP(fd,6), "") == 0) {
if (defaultlanguage == 'F') {
printf("Impossible de trouver le nom du compte [%d]. Le compte n'existe pas.\n", RFIFOL(fd,2));
ladmin_log("Impossible de trouver le nom du compte [%d]. Le compte n'existe pas." RETCODE, RFIFOL(fd,2));
@@ -4018,7 +4016,7 @@ int parse_fromlogin(int fd) {
connect_until_time = (time_t)RFIFOL(fd,140);
ban_until_time = (time_t)RFIFOL(fd,144);
memset(memo, '\0', sizeof(memo));
- strncpy(memo, RFIFOP(fd,150), RFIFOW(fd,148));
+ strncpy(memo, (const char*)RFIFOP(fd,150), RFIFOW(fd,148));
if (RFIFOL(fd,2) == -1) {
if (defaultlanguage == 'F') {
printf("Impossible de trouver le compte [%s]. Le compte n'existe pas.\n", parameters);
@@ -4258,8 +4256,8 @@ int ladmin_config_read(const char *cfgName) {
line[sizeof(line)-1] = '\0';
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
- remove_control_chars(w1);
- remove_control_chars(w2);
+ remove_control_chars((unsigned char *) w1);
+ remove_control_chars((unsigned char *) w2);
if(strcmpi(w1,"login_ip")==0){
struct hostent *h = gethostbyname (w2);
diff --git a/src/ladmin/md5calc.c b/src/ladmin/md5calc.c
index 7b9a9a2c6..c6c958583 100644
--- a/src/ladmin/md5calc.c
+++ b/src/ladmin/md5calc.c
@@ -96,7 +96,7 @@ static void MD5_Round_Calculate(const unsigned char *block,
//Save A as AA, B as BB, C as CC, and and D as DD (saving of A, B, C, and D)
unsigned int A=*A2, B=*B2, C=*C2, D=*D2;
unsigned int AA = A,BB = B,CC = C,DD = D;
-
+
//It is a large region variable reluctantly because of calculation of a round. . . for Round1...4
pX = X;
@@ -187,7 +187,7 @@ void MD5_String2binary(const char * string, char * output)
memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length.
padding_message[copy_len] |= 0x80; //The next of a message is 1.
- //1-4
+ //1-4
//If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes.
if (56 <= copy_len) {
MD5_Round_Calculate(padding_message, A,B,C,D);
@@ -226,7 +226,7 @@ void MD5_String(const char * string, char * output)
{
unsigned char digest[16];
- MD5_String2binary(string,digest);
+ MD5_String2binary(string,(char*)digest);
sprintf(output,
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
digest[ 0], digest[ 1], digest[ 2], digest[ 3],