comparison flashii.h @ 0:aa723e3948a4 default tip

*: initial commit awesome
author Paper <paper@tflc.us>
date Tue, 09 Sep 2025 00:29:57 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:aa723e3948a4
1 /*
2 * wcc -- a shitty sockchat client
3 *
4 * Copyright (c) 2025 Paper
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25 #ifndef WCC_FLASHII_H_
26 #define WCC_FLASHII_H_
27
28 #include <stdint.h>
29
30 /* opaque type */
31 struct flashii;
32
33 struct flashii_msg {
34 int64_t timestamp; /* UNIX timestamp */
35 char *id; /* user ID of the author */
36 char *body; /* message body; sanitized. this is HTML/BBcode */
37 char *msg_id; /* message ID (lol) */
38
39 #define FLASHII_MSG_FLAG_BOLD (0x01)
40 #define FLASHII_MSG_FLAG_CURSIVE (0x02) /* AKA italics */
41 #define FLASHII_MSG_FLAG_UNDERLINE (0x04)
42 #define FLASHII_MSG_FLAG_COLON (0x08)
43 #define FLASHII_MSG_FLAG_PRIVATE (0x10) /* private message */
44 uint32_t flags;
45 };
46
47 typedef void (*flashii_msg_recv_spec)(struct flashii *fls, struct flashii_msg *msg);
48
49 struct flashii_user {
50 char *id;
51 char *name;
52 /* char *color; -- dont care */
53 /* (?) perms; -- dont care */
54 int32_t visible;
55 };
56
57 typedef void (*flashii_user_recv_spec)(struct flashii *fls, struct flashii_user *user);
58
59 struct flashii *flashii_init(const char *protocol, const char *address,
60 uint16_t port, flashii_msg_recv_spec msg_recv,
61 flashii_user_recv_spec user_recv);
62 void flashii_work(struct flashii *fls, int noblock);
63 int flashii_send_message(struct flashii *fls, const char *msg);
64 /* TODO flashii_quit */
65
66 #endif /* WCC_FLASHII_H_ */