/[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.2 by sysadm, Wed Oct 20 07:46:32 2004 UTC Revision 1.10 by sysadm, Mon Apr 28 12:45:57 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                            common.c  -  description                                                    common.c  -  description
3                               -------------------                                                           -------------------
4      begin                : Mon Oct 18 2004          begin                : Mon Oct 18 2004
5      copyright            : (C) 2004 by Leaflet          copyright            : (C) 2004 by Leaflet
6      email                : leaflet@leafok.com          email                : leaflet@leafok.com
7   ***************************************************************************/   ***************************************************************************/
8    
9  /***************************************************************************  /***************************************************************************
# Line 15  Line 15 
15   *                                                                         *   *                                                                         *
16   ***************************************************************************/   ***************************************************************************/
17    
18  //Version information  #include "menu.h"
19    #include <time.h>
20    #include <sys/types.h>
21    #include <sys/wait.h>
22    
23    // Version information
24  char app_version[256] = "LBBS-devel version 1.0";  char app_version[256] = "LBBS-devel version 1.0";
25    
26  //Global declaration for enviroment  // Global declaration for enviroment
27  char app_home_dir[256];  char app_home_dir[256];
28    char app_temp_dir[256];
29    
30  //Global declaration for sockets  // Global declaration for sockets
31  int socket_server;  int socket_server;
32  int socket_client;  int socket_client;
33  char hostaddr_server[50];  char hostaddr_server[50];
# Line 29  char hostaddr_client[50]; Line 35  char hostaddr_client[50];
35  int port_server;  int port_server;
36  int port_client;  int port_client;
37    
38  //Global declaration for database  // Global declaration for database
39  char DB_host[256];  char DB_host[256];
40  char DB_username[50];  char DB_username[50];
41  char DB_password[50];  char DB_password[50];
42  char DB_database[50];  char DB_database[50];
43    char DB_timezone[50];
44    
45    // Global declaration for system
46    int SYS_exit;
47    int SYS_child_process_count;
48    
49    // Common function
50    const char *
51    str_space(char *string, int length)
52    {
53            int i;
54            for (i = 0; i < length; i++)
55            {
56                    string[i] = ' ';
57            }
58            string[length] = '\0';
59            return string;
60    }
61    
62    const char *
63    get_time_str(char *string, size_t length)
64    {
65            char week[10], buffer[256];
66            time_t curtime;
67            struct tm *loctime;
68    
69            curtime = time(NULL);
70            loctime = localtime(&curtime);
71    
72            strftime(buffer, 256, "%Y年%m月%d日%H:%M:%S ", loctime);
73    
74            switch (loctime->tm_wday)
75            {
76            case 0:
77                    strcpy(week, "星期天");
78                    break;
79            case 1:
80                    strcpy(week, "星期一");
81                    break;
82            case 2:
83                    strcpy(week, "星期二");
84                    break;
85            case 3:
86                    strcpy(week, "星期三");
87                    break;
88            case 4:
89                    strcpy(week, "星期四");
90                    break;
91            case 5:
92                    strcpy(week, "星期五");
93                    break;
94            case 6:
95                    strcpy(week, "星期六");
96                    break;
97            }
98            strcat(buffer, week);
99    
100            strncpy(string, buffer, length);
101    
102            return string;
103    }
104    
105    void reload_bbs_menu(int i)
106    {
107            if (reload_menu(&bbs_menu) < 0)
108                    log_error("Reload menu failed\n");
109            else
110                    log_std("Reload menu successfully\n");
111    }
112    
113    void system_exit(int i)
114    {
115            SYS_exit = 1;
116    }
117    
118    void child_exit(int i)
119    {
120            int pid;
121    
122            pid = wait(0);
123    
124            if (pid > 0)
125            {
126                    SYS_child_process_count--;
127                    log_std("Child process (%d) exited\n", pid);
128            }
129    }


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

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