AmendHub

Download

jcs

/

subtext

/

board.h

 

(View History)

jcs   board: For new FTN messages posted locally, just toss them Latest amendment: 560 on 2023-11-21

1 /*
2 * Copyright (c) 2022 joshua stein <jcs@jcs.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef __BOARD_H__
18 #define __BOARD_H__
19
20 #include <stddef.h>
21 #include "fidopkt.h"
22 #include "session.h"
23 #include "settings.h"
24
25 struct board {
26 unsigned long id;
27 char name[32];
28 char description[100];
29 bool restricted_posting;
30 bool restricted_viewing;
31 unsigned short retention_days;
32 unsigned long last_post_at;
33 unsigned long post_count;
34 char ftn_area[32];
35
36 struct bile *bile;
37 };
38
39 extern const struct struct_field board_fields[];
40 extern const size_t nboard_fields;
41 extern const struct bile_object_field board_object_fields[];
42 extern const size_t nboard_object_fields;
43
44 struct board_post {
45 unsigned long id;
46 unsigned long thread_id;
47 time_t time;
48 unsigned long sender_user_id;
49 size_t body_size;
50 char *body;
51 unsigned long parent_post_id;
52 char via[10];
53 };
54 extern const struct bile_object_field board_post_object_fields[];
55 extern const size_t nboard_post_object_fields;
56
57 struct board_ftn_post {
58 unsigned long id;
59 struct fidopkt_msgid msgid;
60 time_t time;
61 char from[32];
62 char subject[80];
63 char msgid_orig[64];
64 char origin[64];
65 char reply[32];
66 char to[32];
67 size_t body_size;
68 char *body;
69 };
70 extern const struct bile_object_field board_ftn_post_object_fields[];
71 extern const size_t nboard_ftn_post_object_fields;
72
73 struct board_thread {
74 unsigned long thread_id;
75 time_t last_post_at;
76 size_t subject_size;
77 char *subject;
78 unsigned long nposts;
79 unsigned long *post_ids;
80 unsigned long *parent_post_ids;
81 };
82 extern const struct bile_object_field board_thread_object_fields[];
83 extern const size_t nboard_thread_object_fields;
84
85 struct board_id_time_map {
86 unsigned long id;
87 time_t time;
88 };
89
90 void board_list_boards(struct session *s);
91 void board_list_ftn_areas(struct session *s);
92 void board_show(struct session *s, short id, char *prompt_prefix);
93 void board_delete_post(struct board *board, struct board_post *post,
94 struct board_thread *thread);
95 void board_delete_ftn_post(struct board *board,
96 struct board_ftn_post *post);
97 size_t board_index_sorted_post_ids(struct board *board,
98 struct board_id_time_map **sorted_id_map);
99 short board_toss_ftn_message(struct board *board,
100 struct fidopkt_message *fidomsg, bool local);
101 void board_prune_old_posts(struct board *board);
102
103 #endif