X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2Flang.c;h=7d1532bf424bd7003cca2560c4da19ef26e1f0c2;hp=b56322ce2e4421c7201e6d32732ba1a882d831ed;hb=HEAD;hpb=706e48b1e666054030c491d864f740071e390038 diff --git a/src/lang.c b/src/lang.c index b56322c..7d1532b 100644 --- a/src/lang.c +++ b/src/lang.c @@ -1,4 +1,4 @@ -/* lang.c - NeonServ v5.3 +/* lang.c - NeonServ v5.6 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -18,6 +18,8 @@ #include "UserNode.h" #include "DBHelper.h" #include "mysqlConn.h" +#include "tools.h" +#include "log.h" #define DEFAULT_LANG_TAG "EN" #define DEFAULT_LANG_NAME "English" @@ -53,7 +55,7 @@ static struct language* add_language(char *langtag, char *langname) { if(cindex == MAXLANGUAGES) return NULL; struct language *lang = malloc(sizeof(*lang)); if (!lang) { - perror("malloc() failed"); + printf_log("main", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__); return NULL; } lang->langtag = strdup(langtag); @@ -142,11 +144,14 @@ void register_language_string(struct language *lang, char *ident, char *text) { if(!lang_entry) { lang_entry = malloc(sizeof(*lang_entry)); if (!lang_entry) { - perror("malloc() failed"); + printf_log("main", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__); return; } lang_entry->ident = strdup(ident); - } + lang_entry->next = lang->entrys[cindex]; + lang->entrys[cindex] = lang_entry; + } else + free(lang_entry->text); //free old text (new one will be set below) //replace all: //$b to \002 //$k to \003 @@ -178,8 +183,6 @@ void register_language_string(struct language *lang, char *ident, char *text) { } } while(a); lang_entry->text = strdup(tmp); - lang_entry->next = lang->entrys[cindex]; - lang->entrys[cindex] = lang_entry; } char *get_language_string(struct UserNode *user, const char* msg_ident) { @@ -209,7 +212,7 @@ char *build_language_string(struct UserNode *user, char *buffer, const char *msg if(buffer == NULL) { buffer = (char *)malloc((MAXLEN+1) * sizeof(char)); if (!buffer) { - perror("malloc() failed"); + printf_log("main", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__); return NULL; } }