/[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.4 by sysadm, Sat Mar 19 08:23:05 2005 UTC Revision 1.7 by sysadm, Sat May 7 12:08:28 2005 UTC
# Line 15  Line 15 
15   *                                                                         *   *                                                                         *
16   ***************************************************************************/   ***************************************************************************/
17    
18    #include "menu.h"
19  #include <time.h>  #include <time.h>
20    #include <sys/types.h>
21    #include <sys/wait.h>
22    
23  //Version information  //Version information
24  char app_version[256] = "LBBS-devel version 1.0";  char app_version[256] = "LBBS-devel version 1.0";
# Line 38  char DB_username[50]; Line 41  char DB_username[50];
41  char DB_password[50];  char DB_password[50];
42  char DB_database[50];  char DB_database[50];
43    
44    //Global declaration for system
45    int SYS_exit;
46    int SYS_child_process_count;
47    
48  //Common function  //Common function
49  const char*  const char *
50  str_space (char *string, int length)  str_space (char *string, int length)
51  {  {
52    int i;    int i;
53    for (i = 0; i < length; i++)    for (i = 0; i < length; i++)
54    {      {
55      string[i] = ' ';        string[i] = ' ';
56    }      }
57    string[length] = '\0';    string[length] = '\0';
58    return string;    return string;
59  }  }
60    
61  const char*  const char *
62  get_time_str (char *string, size_t length)  get_time_str (char *string, size_t length)
63  {  {
64    char week[10],buffer[256];    char week[10], buffer[256];
65    time_t curtime;    time_t curtime;
66    struct tm *loctime;    struct tm *loctime;
67        
68    curtime = time (NULL);    curtime = time (NULL);
69    loctime = localtime (&curtime);    loctime = localtime (&curtime);
70    
71    strftime (buffer, 256, "%Y年%m月%d日%H:%M:%S ", loctime);    strftime (buffer, 256, "%Y年%m月%d日%H:%M:%S ", loctime);
72      
73    switch (loctime->tm_wday)    switch (loctime->tm_wday)
74    {      {
75      case 0:      case 0:
76        strcpy (week, "星期天");        strcpy (week, "星期天");
77        break;        break;
# Line 86  get_time_str (char *string, size_t lengt Line 93  get_time_str (char *string, size_t lengt
93      case 6:      case 6:
94        strcpy (week, "星期六");        strcpy (week, "星期六");
95        break;        break;
96    }      }
97    strcat (buffer, week);    strcat (buffer, week);
98      
99    strncpy (string, buffer, length);    strncpy (string, buffer, length);
100      
101    return string;    return string;
102  }  }
103    
104    void
105    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    
114    void
115    system_exit (int i)
116    {
117      SYS_exit = 1;
118      log_std ("Get SIG_BBS_EXIT signal successfully\n");
119    }
120    
121    void
122    child_exit (int i)
123    {
124      int pid;
125      
126      pid = wait (0);
127    
128      if (pid > 0)
129        {
130          SYS_child_process_count --;
131          log_std ("Child process (%d) exited\n", pid);
132        }
133    }


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

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