/[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.1 by sysadm, Tue Oct 19 17:10:39 2004 UTC Revision 1.9 by sysadm, Mon Apr 28 03:30:59 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  //Global declaration for enviroment  #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";
25    
26    // 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 26  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];
43    
44    // Global declaration for system
45    int SYS_exit;
46    int SYS_child_process_count;
47    
48    // Common function
49    const char *
50    str_space(char *string, int length)
51    {
52            int i;
53            for (i = 0; i < length; i++)
54            {
55                    string[i] = ' ';
56            }
57            string[length] = '\0';
58            return string;
59    }
60    
61    const char *
62    get_time_str(char *string, size_t length)
63    {
64            char week[10], buffer[256];
65            time_t curtime;
66            struct tm *loctime;
67    
68            curtime = time(NULL);
69            loctime = localtime(&curtime);
70    
71            strftime(buffer, 256, "%Y年%m月%d日%H:%M:%S ", loctime);
72    
73            switch (loctime->tm_wday)
74            {
75            case 0:
76                    strcpy(week, "星期天");
77                    break;
78            case 1:
79                    strcpy(week, "星期一");
80                    break;
81            case 2:
82                    strcpy(week, "星期二");
83                    break;
84            case 3:
85                    strcpy(week, "星期三");
86                    break;
87            case 4:
88                    strcpy(week, "星期四");
89                    break;
90            case 5:
91                    strcpy(week, "星期五");
92                    break;
93            case 6:
94                    strcpy(week, "星期六");
95                    break;
96            }
97            strcat(buffer, week);
98    
99            strncpy(string, buffer, length);
100    
101            return string;
102    }
103    
104    void reload_bbs_menu(int i)
105    {
106            if (reload_menu(&bbs_menu) < 0)
107                    log_error("Reload menu failed\n");
108            else
109                    log_std("Reload menu successfully\n");
110    }
111    
112    void system_exit(int i)
113    {
114            SYS_exit = 1;
115    }
116    
117    void child_exit(int i)
118    {
119            int pid;
120    
121            pid = wait(0);
122    
123            if (pid > 0)
124            {
125                    SYS_child_process_count--;
126                    log_std("Child process (%d) exited\n", pid);
127            }
128    }


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

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