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

Contents of /lbbs/src/user_info_display.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu Oct 23 09:55:15 2025 UTC (4 months, 3 weeks ago) by sysadm
Branch: MAIN
Content type: text/x-csrc
Add user_info_display

1 /***************************************************************************
2 user_list_display.c - description
3 -------------------
4 Copyright : (C) 2004-2025 by Leaflet
5 Email : leaflet@leafok.com
6 ***************************************************************************/
7
8 /***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 3 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17 #include "lml.h"
18 #include "log.h"
19 #include "screen.h"
20 #include "str_process.h"
21 #include "user_list.h"
22 #include "user_info_display.h"
23 #include <string.h>
24 #include <sys/param.h>
25
26 #define BBS_max_sessions_per_user 10
27
28 static int display_user_intro_key_handler(int *p_key, DISPLAY_CTX *p_ctx)
29 {
30 return 0;
31 }
32
33 int user_info_display(USER_INFO *p_user_info)
34 {
35 USER_ONLINE_INFO sessions[BBS_max_sessions_per_user];
36 int session_cnt = BBS_max_sessions_per_user;
37 char action_str[LINE_BUFFER_LEN];
38 char *p;
39 int ret;
40 int i;
41
42 action_str[0] = '\0';
43
44 ret = query_user_online_info_by_uid(p_user_info->uid, sessions, &session_cnt, 0);
45 if (ret < 0)
46 {
47 log_error("query_user_online_info_by_uid(uid=%d, cnt=%d) error: %d\n",
48 p_user_info->uid, session_cnt, ret);
49 }
50 else
51 {
52 p = action_str;
53 for (i = 0; i < session_cnt; i++)
54 {
55 if (p + strlen(sessions[i].current_action_title) + 3 >= action_str + sizeof(action_str)) // buffer overflow
56 {
57 log_error("action_str of user(uid=%d) truncated at i=%d\n", p_user_info->uid, i);
58 break;
59 }
60 *p++ = '[';
61 p = stpncpy(p, sessions[i].current_action_title, strlen(sessions[i].current_action_title));
62 *p++ = ']';
63 *p++ = ' ';
64 }
65 *p = '\0';
66 }
67
68 char intro_f[BBS_user_intro_max_len];
69 char profile_f[BUFSIZ];
70 long line_offsets[BBS_user_intro_max_line + 1];
71 long lines;
72
73 lml_render(p_user_info->intro, intro_f, sizeof(intro_f), 0);
74
75 snprintf(profile_f, sizeof(profile_f),
76 "已选中用户 [%s]\n发帖数:%d\n%s\n%s\n",
77 p_user_info->username,
78 get_user_article_cnt(p_user_info->uid),
79 action_str,
80 intro_f);
81
82 lines = split_data_lines(profile_f, SCREEN_COLS, line_offsets, MIN(SCREEN_ROWS - 1, BBS_user_intro_max_line + 4), 1, NULL);
83
84 clearscr();
85 display_data(profile_f, lines, line_offsets, 2, display_user_intro_key_handler, DATA_READ_HELP);
86 press_any_key();
87
88 return 0;
89 }

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