| 1 |
/*************************************************************************** |
/*************************************************************************** |
| 2 |
common.c - description |
common.c - description |
| 3 |
------------------- |
------------------- |
| 4 |
begin : Mon Oct 18 2004 |
Copyright : (C) 2004-2025 by Leaflet |
| 5 |
copyright : (C) 2004 by Leaflet |
Email : leaflet@leafok.com |
|
email : leaflet@leafok.com |
|
| 6 |
***************************************************************************/ |
***************************************************************************/ |
| 7 |
|
|
| 8 |
/*************************************************************************** |
/*************************************************************************** |
| 9 |
* * |
* * |
| 10 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
| 11 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
| 12 |
* the Free Software Foundation; either version 2 of the License, or * |
* the Free Software Foundation; either version 3 of the License, or * |
| 13 |
* (at your option) any later version. * |
* (at your option) any later version. * |
| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 25 |
// Version information |
// Version information |
| 26 |
char app_version[256] = "LBBS-devel version 1.0"; |
char app_version[256] = "LBBS-devel version 1.0"; |
| 27 |
|
|
|
// Global declaration for enviroment |
|
|
char app_home_dir[256]; |
|
|
char app_temp_dir[256]; |
|
|
|
|
| 28 |
// Global declaration for sockets |
// Global declaration for sockets |
| 29 |
int socket_server; |
int socket_server; |
| 30 |
int socket_client; |
int socket_client; |
| 33 |
int port_server; |
int port_server; |
| 34 |
int port_client; |
int port_client; |
| 35 |
|
|
|
// Global declaration for database |
|
|
char DB_host[256]; |
|
|
char DB_username[50]; |
|
|
char DB_password[50]; |
|
|
char DB_database[50]; |
|
|
char DB_timezone[50]; |
|
|
|
|
| 36 |
// Global declaration for system |
// Global declaration for system |
| 37 |
int SYS_exit; |
int SYS_exit; |
| 38 |
int SYS_child_process_count; |
int SYS_child_process_count; |
| 49 |
return string; |
return string; |
| 50 |
} |
} |
| 51 |
|
|
| 52 |
const char *get_time_str(char *string, size_t length) |
const char *get_time_str(char *s, size_t len) |
| 53 |
{ |
{ |
| 54 |
char week[10], buffer[256]; |
time_t curtime = time(NULL); |
|
time_t curtime; |
|
| 55 |
struct tm *loctime; |
struct tm *loctime; |
|
|
|
|
curtime = time(NULL); |
|
| 56 |
loctime = localtime(&curtime); |
loctime = localtime(&curtime); |
| 57 |
|
|
| 58 |
strftime(buffer, 256, "%Y年%m月%d日%H:%M:%S ", loctime); |
size_t j = strftime(s, len, "%Y年%m月%d日%H:%M:%S ", loctime); |
| 59 |
|
|
| 60 |
|
if (j == 0) |
| 61 |
|
{ |
| 62 |
|
return NULL; |
| 63 |
|
} |
| 64 |
|
|
| 65 |
switch (loctime->tm_wday) |
switch (loctime->tm_wday) |
| 66 |
{ |
{ |
| 67 |
case 0: |
case 0: |
| 68 |
strcpy(week, "星期天"); |
strncat(s, "星期天", len - j); |
| 69 |
break; |
break; |
| 70 |
case 1: |
case 1: |
| 71 |
strcpy(week, "星期一"); |
strncat(s, "星期一", len - j); |
| 72 |
break; |
break; |
| 73 |
case 2: |
case 2: |
| 74 |
strcpy(week, "星期二"); |
strncat(s, "星期二", len - j); |
| 75 |
break; |
break; |
| 76 |
case 3: |
case 3: |
| 77 |
strcpy(week, "星期三"); |
strncat(s, "星期三", len - j); |
| 78 |
break; |
break; |
| 79 |
case 4: |
case 4: |
| 80 |
strcpy(week, "星期四"); |
strncat(s, "星期四", len - j); |
| 81 |
break; |
break; |
| 82 |
case 5: |
case 5: |
| 83 |
strcpy(week, "星期五"); |
strncat(s, "星期五", len - j); |
| 84 |
break; |
break; |
| 85 |
case 6: |
case 6: |
| 86 |
strcpy(week, "星期六"); |
strncat(s, "星期六", len - j); |
| 87 |
break; |
break; |
| 88 |
} |
} |
|
strcat(buffer, week); |
|
| 89 |
|
|
| 90 |
strncpy(string, buffer, length); |
return s; |
|
|
|
|
return string; |
|
| 91 |
} |
} |
| 92 |
|
|
| 93 |
void reload_bbs_menu(int i) |
void reload_bbs_menu(int i) |