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