/[LeafOK_CVS]/lbbs/src/common.c
ViewVC logotype

Diff of /lbbs/src/common.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.9 by sysadm, Mon Apr 28 03:30:59 2025 UTC Revision 1.14 by sysadm, Mon May 5 11:11:06 2025 UTC
# Line 15  Line 15 
15   *                                                                         *   *                                                                         *
16   ***************************************************************************/   ***************************************************************************/
17    
18    #include "common.h"
19    #include "log.h"
20  #include "menu.h"  #include "menu.h"
21    #include <string.h>
22  #include <time.h>  #include <time.h>
23  #include <sys/types.h>  #include <sys/types.h>
24  #include <sys/wait.h>  #include <sys/wait.h>
# Line 23  Line 26 
26  // Version information  // Version information
27  char app_version[256] = "LBBS-devel version 1.0";  char app_version[256] = "LBBS-devel version 1.0";
28    
 // Global declaration for enviroment  
 char app_home_dir[256];  
 char app_temp_dir[256];  
   
29  // Global declaration for sockets  // Global declaration for sockets
30  int socket_server;  int socket_server;
31  int socket_client;  int socket_client;
# Line 35  char hostaddr_client[50]; Line 34  char hostaddr_client[50];
34  int port_server;  int port_server;
35  int port_client;  int port_client;
36    
 // Global declaration for database  
 char DB_host[256];  
 char DB_username[50];  
 char DB_password[50];  
 char DB_database[50];  
   
37  // Global declaration for system  // Global declaration for system
38  int SYS_exit;  int SYS_exit;
39  int SYS_child_process_count;  int SYS_child_process_count;
40    
41  // Common function  // Common function
42  const char *  const char *str_space(char *string, int length)
 str_space(char *string, int length)  
43  {  {
44          int i;          int i;
45          for (i = 0; i < length; i++)          for (i = 0; i < length; i++)
# Line 58  str_space(char *string, int length) Line 50  str_space(char *string, int length)
50          return string;          return string;
51  }  }
52    
53  const char *  const char *get_time_str(char *s, size_t len)
 get_time_str(char *string, size_t length)  
54  {  {
55          char week[10], buffer[256];          time_t curtime = time(NULL);
         time_t curtime;  
56          struct tm *loctime;          struct tm *loctime;
   
         curtime = time(NULL);  
57          loctime = localtime(&curtime);          loctime = localtime(&curtime);
58    
59          strftime(buffer, 256, "%Y年%m月%d日%H:%M:%S ", loctime);          size_t j = strftime(s, len, "%Y年%m月%d日%H:%M:%S ", loctime);
60    
61            if (j == 0)
62            {
63                    return NULL;
64            }
65    
66          switch (loctime->tm_wday)          switch (loctime->tm_wday)
67          {          {
68          case 0:          case 0:
69                  strcpy(week, "星期天");                  strncat(s, "星期天", len - j);
70                  break;                  break;
71          case 1:          case 1:
72                  strcpy(week, "星期一");                  strncat(s, "星期一", len - j);
73                  break;                  break;
74          case 2:          case 2:
75                  strcpy(week, "星期二");                  strncat(s, "星期二", len - j);
76                  break;                  break;
77          case 3:          case 3:
78                  strcpy(week, "星期三");                  strncat(s, "星期三", len - j);
79                  break;                  break;
80          case 4:          case 4:
81                  strcpy(week, "星期四");                  strncat(s, "星期四", len - j);
82                  break;                  break;
83          case 5:          case 5:
84                  strcpy(week, "星期五");                  strncat(s, "星期五", len - j);
85                  break;                  break;
86          case 6:          case 6:
87                  strcpy(week, "星期六");                  strncat(s, "星期六", len - j);
88                  break;                  break;
89          }          }
         strcat(buffer, week);  
90    
91          strncpy(string, buffer, length);          return s;
   
         return string;  
92  }  }
93    
94  void reload_bbs_menu(int i)  void reload_bbs_menu(int i)


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1