/* vi: set ts=2: +-------------------+ Christian Schlittchen | | Enno Rehling | Eressea PBEM host | Katja Zedel | (c) 1998 - 2001 | Henning Peters | | Ingo Wilken +-------------------+ Stefan Reich This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ #include #include #include "infocmd.h" #include "command.h" /* kernel includes */ #include #include #include #include /* util includes */ #include #include /* libc includes */ #include #include #include static void info_email(const tnode * tnext, const char * str, void * data, const char * cmd) { unused(str); unused(data); unused(cmd); } static void info_name(const tnode * tnext, const char * str, void * data, const char * cmd) { unused(tnext); unused(str); unused(data); unused(cmd); if (sqlstream!=NULL) { } } static void info_address(const tnode * tnext, const char * str, void * data, const char * cmd) { if (sqlstream!=NULL) { } } static void info_phone(const tnode * tnext, const char * str, void * data, const char * cmd) { if (sqlstream!=NULL) { } } static void info_vacation(const tnode * tnext, const char * str, void * data, const char * cmd) { if (sqlstream!=NULL) { #ifdef SQLOUTPUT unit * u = (unit*)data; faction * f = u->faction; const char * email = sqlquote(igetstrtoken(str)); int duration = atoi(getstrtoken()); time_t start_time = time(NULL); time_t end_time = start_time + 60*60*24*duration; struct tm start = *localtime(&start_time); struct tm end = *localtime(&end_time); fprintf(sqlstream, "UPDATE factions SET vacation = '%s' WHERE id = '%s';\n", email, itoa36(f->no)); fprintf(sqlstream, "UPDATE factions SET vacation_start = '%04d-%02d-%02d' WHERE id = '%s';\n", start.tm_year, start.tm_mon, start.tm_mday, itoa36(f->no)); fprintf(sqlstream, "UPDATE factions SET vacation_end = '%04d-%02d-%02d' WHERE id = '%s';\n", end.tm_year, end.tm_mon, end.tm_mday, itoa36(f->no)); #endif } } static tnode g_keys; static tnode g_info; void infocommands(void) { region ** rp = ®ions; while (*rp) { region * r = *rp; unit **up = &r->units; while (*up) { unit * u = *up; strlist * order; for (order = u->orders; order; order = order->next) if (igetkeyword(order->s, u->faction->locale) == K_INFO) { /* do_command(&g_keys, u, order->s); */ } if (u==*up) up = &u->next; } if (*rp==r) rp = &r->next; } fflush(sqlstream); } void init_info(void) { add_command(&g_keys, &g_info, "info", NULL); add_command(&g_info, NULL, "email", &info_email); add_command(&g_info, NULL, "name", &info_name); add_command(&g_info, NULL, "adresse", &info_address); add_command(&g_info, NULL, "telefon", &info_phone); add_command(&g_info, NULL, "urlaub", &info_vacation); }