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

Diff of /lbbs/src/screen.c

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

Revision 1.7 by sysadm, Tue Nov 30 07:10:32 2004 UTC Revision 1.10 by sysadm, Sun Mar 20 17:23:17 2005 UTC
# Line 15  Line 15 
15   *                                                                         *   *                                                                         *
16   ***************************************************************************/   ***************************************************************************/
17    
18    #include "bbs.h"
19  #include "common.h"  #include "common.h"
20  #include "io.h"  #include "io.h"
21  #include <sys/types.h>  #include <sys/types.h>
22  #include <sys/stat.h>  #include <sys/stat.h>
23  #include <unistd.h>  #include <unistd.h>
24    
25    #define ACTIVE_BOARD_HEIGHT     8
26    
27  int screen_lines = 24;  int screen_lines = 24;
28    
29  void  void
# Line 166  display_file (const char *filename) Line 169  display_file (const char *filename)
169    FILE *fin;    FILE *fin;
170    int i;    int i;
171    
172    if ((fin = fopen (filename, "r")) != NULL)    if ((fin = fopen (filename, "r")) == NULL)
173    {    {
174      while (fgets (buffer, 255, fin))      return -1;
       {  
         i = strlen (buffer);  
         if (buffer[i - 1] == '\n' && buffer[i - 2] != '\r')  
           {  
             buffer[i - 1] = '\r';  
             buffer[i] = '\n';  
             buffer[i + 1] = '\0';  
           }  
         prints (buffer);  
         iflush ();  
       }  
     fclose(fin);  
     return 0;  
175    }    }
176      
177    return -1;    while (fgets (buffer, 255, fin))
178        {
179          i = strlen (buffer);
180          if (buffer[i - 1] == '\n' && buffer[i - 2] != '\r')
181            {
182              buffer[i - 1] = '\r';
183              buffer[i] = '\n';
184              buffer[i + 1] = '\0';
185            }
186          prints (buffer);
187          iflush ();
188        }
189      fclose(fin);
190    
191      return 0;
192  }  }
193    
194  int  int
# Line 349  display_file_ex (const char *filename, i Line 353  display_file_ex (const char *filename, i
353  }  }
354    
355  int  int
356  show_top ()  show_top (char *status)
357    {
358      char buffer[256];
359    
360      str_space (buffer, 20 - strlen (BBS_current_section_name));
361    
362      moveto (1, 0);
363      prints ("\033[1;44;33m%-20s \033[37m%20s"
364              "         %s\033[33mÌÖÂÛÇø [%s]\033[m",
365              status, BBS_name, buffer, BBS_current_section_name);
366      iflush ();
367    
368      return 0;
369    }
370    
371    int
372    show_bottom (char *msg)
373  {  {
374      char str_time[256], str_time_onine[20], buffer[256];
375      time_t time_online;
376      struct tm *tm_online;
377    
378      get_time_str (str_time, 256);
379      str_space (buffer, 33 - strlen (BBS_username));
380    
381      time_online = time (0) - BBS_login_tm;
382      tm_online = gmtime (&time_online);
383    
384      moveto (screen_lines, 0);
385      prints ("\033[1;44;33m[\033[36m%s\033[33m]"
386              "%sÕʺÅ[\033[36m%s\033[33m]"
387              "[\033[36m%1d\033[33m:\033[36m%2d\033[33m:\033[36m%2d\033[33m]\033[m",
388              str_time, buffer, BBS_username, tm_online->tm_mday - 1,
389              tm_online->tm_hour, tm_online->tm_min);
390      iflush ();
391    
392    return 0;    return 0;
393  }  }
394    
395  int  int
396  show_bottom ()  show_active_board ()
397  {  {
398      char filename[256], buffer[260];
399      FILE *fin;
400      int i, j;
401      static long int line;
402    
403      sprintf (filename, "%sdata/active_board.txt", app_home_dir);
404    
405      clrline (3, 2 + ACTIVE_BOARD_HEIGHT);
406    
407      moveto (3, 0);
408    
409      if ((fin = fopen (filename, "r")) != NULL)
410        {
411          for (j = 0; j < line; j++)
412            {
413              if (fgets (buffer, 255, fin) == NULL)
414                {
415                  line = 0;
416                  rewind (fin);
417                  break;
418                }
419            }
420    
421          for (j = 0; j < ACTIVE_BOARD_HEIGHT; j++)
422            {
423              if (fgets (buffer, 255, fin) == NULL)
424                {
425                  line = 0;
426                  if (j == 0)
427                    {
428                      rewind (fin);
429                      if (fgets (buffer, 255, fin) == NULL)
430                        {
431                          break;
432                        }
433                    }
434                  else
435                    {
436                      break;
437                    }
438                }
439              line++;
440              i = strlen (buffer);
441              if (buffer[i - 1] == '\n' && buffer[i - 2] != '\r')
442                {
443                  buffer[i - 1] = '\r';
444                  buffer[i] = '\n';
445                  buffer[i + 1] = '\0';
446                }
447              prints (buffer);
448              iflush ();
449            }
450          fclose (fin);
451        }
452    
453    return 0;    return 0;
454  }  }


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

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