| 39 |
char DB_database[50]; |
char DB_database[50]; |
| 40 |
|
|
| 41 |
//Common function |
//Common function |
| 42 |
const char* |
const char * |
| 43 |
str_space (char *string, int length) |
str_space (char *string, int length) |
| 44 |
{ |
{ |
| 45 |
int i; |
int i; |
| 46 |
for (i = 0; i < length; i++) |
for (i = 0; i < length; i++) |
| 47 |
{ |
{ |
| 48 |
string[i] = ' '; |
string[i] = ' '; |
| 49 |
} |
} |
| 50 |
string[length] = '\0'; |
string[length] = '\0'; |
| 51 |
return string; |
return string; |
| 52 |
} |
} |
| 53 |
|
|
| 54 |
const char* |
const char * |
| 55 |
get_time_str (char *string, size_t length) |
get_time_str (char *string, size_t length) |
| 56 |
{ |
{ |
| 57 |
char week[10],buffer[256]; |
char week[10], buffer[256]; |
| 58 |
time_t curtime; |
time_t curtime; |
| 59 |
struct tm *loctime; |
struct tm *loctime; |
| 60 |
|
|
| 61 |
curtime = time (NULL); |
curtime = time (NULL); |
| 62 |
loctime = localtime (&curtime); |
loctime = localtime (&curtime); |
| 63 |
|
|
| 64 |
strftime (buffer, 256, "%Y年%m月%d日%H:%M:%S ", loctime); |
strftime (buffer, 256, "%Y年%m月%d日%H:%M:%S ", loctime); |
| 65 |
|
|
| 66 |
switch (loctime->tm_wday) |
switch (loctime->tm_wday) |
| 67 |
{ |
{ |
| 68 |
case 0: |
case 0: |
| 69 |
strcpy (week, "星期天"); |
strcpy (week, "星期天"); |
| 70 |
break; |
break; |
| 86 |
case 6: |
case 6: |
| 87 |
strcpy (week, "星期六"); |
strcpy (week, "星期六"); |
| 88 |
break; |
break; |
| 89 |
} |
} |
| 90 |
strcat (buffer, week); |
strcat (buffer, week); |
| 91 |
|
|
| 92 |
strncpy (string, buffer, length); |
strncpy (string, buffer, length); |
| 93 |
|
|
| 94 |
return string; |
return string; |
| 95 |
} |
} |