/[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.95 by sysadm, Thu Jun 12 03:14:23 2025 UTC Revision 1.102 by sysadm, Sat Jun 21 02:15:18 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
 #include "screen.h"  
17  #include "bbs.h"  #include "bbs.h"
18  #include "common.h"  #include "common.h"
 #include "str_process.h"  
 #include "log.h"  
 #include "io.h"  
19  #include "editor.h"  #include "editor.h"
20  #include "file_loader.h"  #include "file_loader.h"
21  #include <fcntl.h>  #include "io.h"
22    #include "log.h"
23    #include "login.h"
24    #include "screen.h"
25    #include "str_process.h"
26  #include <ctype.h>  #include <ctype.h>
 #include <unistd.h>  
 #include <stdlib.h>  
27  #include <errno.h>  #include <errno.h>
28  #include <sys/types.h>  #include <fcntl.h>
29  #include <sys/stat.h>  #include <string.h>
30    #include <stdlib.h>
31    #include <unistd.h>
32  #include <sys/param.h>  #include <sys/param.h>
33    #include <sys/stat.h>
34  #include <sys/shm.h>  #include <sys/shm.h>
35    #include <sys/types.h>
 #define _POSIX_C_SOURCE 200809L  
 #include <string.h>  
36    
37  #define ACTIVE_BOARD_HEIGHT 8  #define ACTIVE_BOARD_HEIGHT 8
38    
# Line 301  int display_data(const void *p_data, lon Line 300  int display_data(const void *p_data, lon
300                                           percentile,                                           percentile,
301                                           ctx.msg);                                           ctx.msg);
302    
303                          len = split_line(buffer, SCREEN_COLS, &eol, &display_len);                          len = split_line(buffer, SCREEN_COLS, &eol, &display_len, 1);
304                          for (; display_len < SCREEN_COLS; display_len++)                          for (; display_len < SCREEN_COLS; display_len++)
305                          {                          {
306                                  buffer[len++] = ' ';                                  buffer[len++] = ' ';
# Line 424  int display_data(const void *p_data, lon Line 423  int display_data(const void *p_data, lon
423                                          output_end_row = SCREEN_ROWS - 1;                                          output_end_row = SCREEN_ROWS - 1;
424                                          clrline(output_current_row, SCREEN_ROWS);                                          clrline(output_current_row, SCREEN_ROWS);
425                                          break;                                          break;
                                 case KEY_F2: // For test only  
                                         EDITOR_DATA *p_editor_data;  
                                         size_t data_new_len = strlen(p_data) + LINE_BUFFER_LEN;  
   
                                         char *p_data_new = malloc(data_new_len);  
                                         if (p_data_new == NULL)  
                                         {  
                                                 break;  
                                         }  
                                         p_editor_data = editor_data_load(p_data);  
                                         if (p_editor_data == NULL)  
                                         {  
                                                 free(p_data_new);  
                                                 break;  
                                         }  
   
                                         editor_display(p_editor_data);  
                                         editor_data_save(p_editor_data, p_data_new, data_new_len);  
                                         editor_data_cleanup(p_editor_data);  
                                         p_editor_data = NULL;  
                                         free(p_data_new);  
                                         p_data_new = NULL;  
   
                                         // Refresh after display editor  
                                         line_current -= (output_current_row - screen_begin_row);  
                                         output_current_row = screen_begin_row;  
                                         output_end_row = SCREEN_ROWS - 1;  
                                         clrline(output_current_row, SCREEN_ROWS);  
                                         break;  
426                                  case 0: // Refresh bottom line                                  case 0: // Refresh bottom line
427                                          break;                                          break;
428                                  default:                                  default:
# Line 460  int display_data(const void *p_data, lon Line 430  int display_data(const void *p_data, lon
430                                          break;                                          break;
431                                  }                                  }
432    
433                                  BBS_last_access_tm = time(0);                                  BBS_last_access_tm = time(NULL);
434                          }                          }
435    
436                          continue;                          continue;
# Line 524  int display_file(const char *filename, i Line 494  int display_file(const char *filename, i
494                  return KEY_NULL;                  return KEY_NULL;
495          }          }
496    
497            if (user_online_update("VIEW_FILE") < 0)
498            {
499                    log_error("user_online_update(VIEW_FILE) error\n");
500            }
501    
502          ret = display_data(p_data, line_total, p_line_offsets, eof_exit, display_file_key_handler, DATA_READ_HELP);          ret = display_data(p_data, line_total, p_line_offsets, eof_exit, display_file_key_handler, DATA_READ_HELP);
503    
504          if (detach_file_shm(p_shm) < 0)          if (detach_file_shm(p_shm) < 0)
# Line 547  int show_top(const char *str_left, const Line 522  int show_top(const char *str_left, const
522    
523          strncpy(str_left_f, str_left, sizeof(str_left_f) - 1);          strncpy(str_left_f, str_left, sizeof(str_left_f) - 1);
524          str_left_f[sizeof(str_left_f) - 1] = '\0';          str_left_f[sizeof(str_left_f) - 1] = '\0';
525          len = split_line(str_left_f, STR_TOP_LEFT_MAX_LEN, &eol, &str_left_len);          len = split_line(str_left_f, STR_TOP_LEFT_MAX_LEN, &eol, &str_left_len, 1);
526          str_left_f[len] = '\0';          str_left_f[len] = '\0';
527    
528          strncpy(str_middle_f, str_middle, sizeof(str_middle_f) - 1);          strncpy(str_middle_f, str_middle, sizeof(str_middle_f) - 1);
529          str_middle_f[sizeof(str_middle_f) - 1] = '\0';          str_middle_f[sizeof(str_middle_f) - 1] = '\0';
530          len = split_line(str_middle, STR_TOP_MIDDLE_MAX_LEN, &eol, &str_middle_len);          len = split_line(str_middle, STR_TOP_MIDDLE_MAX_LEN, &eol, &str_middle_len, 1);
531          str_middle_f[len] = '\0';          str_middle_f[len] = '\0';
532    
533          strncpy(str_right_f, str_right, sizeof(str_right_f) - 1);          strncpy(str_right_f, str_right, sizeof(str_right_f) - 1);
534          str_right_f[sizeof(str_right_f) - 1] = '\0';          str_right_f[sizeof(str_right_f) - 1] = '\0';
535          len = split_line(str_right, STR_TOP_RIGHT_MAX_LEN, &eol, &str_right_len);          len = split_line(str_right, STR_TOP_RIGHT_MAX_LEN, &eol, &str_right_len, 1);
536          str_right_f[len] = '\0';          str_right_f[len] = '\0';
537    
538          moveto(1, 0);          moveto(1, 0);
# Line 588  int show_bottom(const char *msg) Line 563  int show_bottom(const char *msg)
563          {          {
564                  strncpy(msg_f, msg, sizeof(msg_f) - 1);                  strncpy(msg_f, msg, sizeof(msg_f) - 1);
565                  msg_f[sizeof(msg_f) - 1] = '\0';                  msg_f[sizeof(msg_f) - 1] = '\0';
566                  len = split_line(msg_f, 23, &eol, &msg_len);                  len = split_line(msg_f, 23, &eol, &msg_len, 1);
567                  msg_f[len] = '\0';                  msg_f[len] = '\0';
568          }          }
569    
570          len_username = (int)strnlen(BBS_username, sizeof(BBS_username));          len_username = (int)strnlen(BBS_username, sizeof(BBS_username));
571    
572          time_online = time(0) - BBS_login_tm;          time_online = time(NULL) - BBS_login_tm;
573          tm_online = gmtime(&time_online);          tm_online = gmtime(&time_online);
574          if (tm_online->tm_mday > 1)          if (tm_online->tm_mday > 1)
575          {          {
# Line 641  int show_active_board() Line 616  int show_active_board()
616                  }                  }
617          }          }
618    
619          if (time(0) - t_last_show >= 10)          if (time(NULL) - t_last_show >= 10)
620          {          {
621                  line_last = line_current;                  line_last = line_current;
622                  t_last_show = time(0);                  t_last_show = time(NULL);
623          }          }
624          else          else
625          {          {


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

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