Update Session Manager

This commit is contained in:
belliash 2013-08-12 19:23:09 +02:00
parent 27b78ae986
commit 8d93137639

View File

@ -43,71 +43,11 @@ char* get_admin_hash(const char* username) {
char* get_cookie_time(time_t t) {
struct tm* utc = gmtime(&t);
char wday[4];
char month[4];
switch(utc->tm_wday) {
case 0:
sprintf(wday, "Sun");
break;
case 1:
sprintf(wday, "Mon");
break;
case 2:
sprintf(wday, "Tue");
break;
case 3:
sprintf(wday, "Wed");
break;
case 4:
sprintf(wday, "Thu");
break;
case 5:
sprintf(wday, "Fri");
break;
case 6:
sprintf(wday, "Sat");
break;
}
switch(utc->tm_mon) {
case 0:
sprintf(month, "Jan");
break;
case 1:
sprintf(month, "Feb");
break;
case 2:
sprintf(month, "Mar");
break;
case 3:
sprintf(month, "Apr");
break;
case 4:
sprintf(month, "May");
break;
case 5:
sprintf(month, "Jun");
break;
case 6:
sprintf(month, "Jul");
break;
case 7:
sprintf(month, "Aug");
break;
case 8:
sprintf(month, "Sep");
break;
case 9:
sprintf(month, "Oct");
break;
case 10:
sprintf(month, "Nov");
break;
case 11:
sprintf(month, "Dec");
break;
}
char *wdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
char utc_str[200];
sprintf(utc_str, "%s, %d %s %d %02d:%02d:%02d UTC", wday, utc->tm_mday, month, (utc->tm_year + 1900), utc->tm_hour, utc->tm_min, utc->tm_sec);
sprintf(utc_str, "%s, %d %s %d %02d:%02d:%02d UTC", wdays[utc->tm_wday], utc->tm_mday, months[utc->tm_mon], (utc->tm_year + 1900), utc->tm_hour, utc->tm_min, utc->tm_sec);
return safe_strdup(utc_str);
}
@ -252,6 +192,7 @@ int main(int argc, char **argv) {
void* safe_malloc(size_t size) {
void* val = malloc(size);
if(val == NULL) {
fprintf(stderr, "ERROR: MALLOC FAILURE!\n");
exit(1);
@ -291,6 +232,7 @@ char* safe_strcat(int num_strs, ...) {
char* safe_strdup(const char* str) {
char* new_str = NULL;
if(str != NULL) {
new_str = strdup(str);
if(new_str == NULL) {