/[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.9 by sysadm, Sat Mar 19 13:34:20 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 349  display_file_ex (const char *filename, i Line 352  display_file_ex (const char *filename, i
352  }  }
353    
354  int  int
355  show_top ()  show_top (char *status)
356  {  {
357      char buffer[256];
358    
359      str_space (buffer, 20 - strlen (BBS_current_section_name));
360    
361      moveto (1, 0);
362      prints ("\033[1;44;33m%-20s \033[37m%20s"
363              "         %s\033[33mÌÖÂÛÇø [%s]\033[m",
364              status, BBS_name, buffer, BBS_current_section_name);
365      iflush ();
366    
367      return 0;
368    }
369    
370    int
371    show_bottom (char *msg)
372    {
373      char str_time[256], str_time_onine[20], buffer[256];
374      time_t time_online;
375      struct tm *tm_online;
376    
377      get_time_str (str_time, 256);
378      str_space (buffer, 33 - strlen (BBS_username));
379    
380      time_online = time (0) - BBS_login_tm;
381      tm_online = gmtime (&time_online);
382    
383      moveto (screen_lines, 0);
384      prints ("\033[1;44;33m[\033[36m%s\033[33m]"
385              "%sÕʺÅ[\033[36m%s\033[33m]"
386              "[\033[36m%1d\033[33m:\033[36m%2d\033[33m:\033[36m%2d\033[33m]\033[m",
387              str_time, buffer, BBS_username, tm_online->tm_mday - 1,
388              tm_online->tm_hour, tm_online->tm_min);
389      iflush ();
390    
391    return 0;    return 0;
392  }  }
393    
394  int  int
395  show_bottom ()  show_active_board ()
396  {  {
397      char filename[256], buffer[260];
398      FILE *fin;
399      int i, j;
400      static long int line;
401    
402      sprintf (filename, "%sdata/active_board.txt", app_home_dir);
403    
404      clrline (3, 2 + ACTIVE_BOARD_HEIGHT);
405    
406      moveto (3, 0);
407    
408      if ((fin = fopen (filename, "r")) != NULL)
409        {
410          for (j = 0; j < line; j++)
411            {
412              if (fgets (buffer, 255, fin) == NULL)
413                {
414                  line = 0;
415                  rewind (fin);
416                  break;
417                }
418            }
419    
420          for (j = 0; j < ACTIVE_BOARD_HEIGHT; j++)
421            {
422              if (fgets (buffer, 255, fin) == NULL)
423                {
424                  line = 0;
425                  if (j == 0)
426                    {
427                      rewind (fin);
428                      if (fgets (buffer, 255, fin) == NULL)
429                        {
430                          break;
431                        }
432                    }
433                  else
434                    {
435                      break;
436                    }
437                }
438              line++;
439              i = strlen (buffer);
440              if (buffer[i - 1] == '\n' && buffer[i - 2] != '\r')
441                {
442                  buffer[i - 1] = '\r';
443                  buffer[i] = '\n';
444                  buffer[i + 1] = '\0';
445                }
446              prints (buffer);
447              iflush ();
448            }
449          fclose (fin);
450        }
451    
452    return 0;    return 0;
453  }  }


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

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