libsrsirc  0.0.14
Lightweight, cross-platform IRC library
irc_track.h
Go to the documentation of this file.
1 /* irc_track.h - (optionally) track users and channels
2  * libsrsirc - a lightweight serious IRC lib - (C) 2012-15, Timo Buhrmester
3  * See README for contact-, COPYING for license information. */
4 
5 #ifndef LIBSRSIRC_IRC_TRACK_H
6 #define LIBSRSIRC_IRC_TRACK_H 1
7 
8 
9 #include <libsrsirc/defs.h>
10 
21 struct chanrep {
22  const char *name;
23  const char *topic;
24  const char *topicnick;
25  uint64_t tscreate;
26  uint64_t tstopic;
27  void *tag;
28 };
29 
34 struct userrep {
45  const char *modepfx;
46  const char *nick;
47  const char *uname; //XXX rly?
48  const char *host;
49  const char *fname;
50  size_t nchans;
51  void *tag;
52 };
53 
55 typedef struct chanrep chanrep;
56 
58 typedef struct userrep userrep;
59 
60 
61 /* the results of these functions (i.e. the strings pointed to by the various
62  * members of the structs above) are only valid until the next time irc_read
63  * is called. if you need persistence, copy the data. */
64 
67 size_t irc_num_chans(irc *ctx);
68 
79 size_t irc_all_chans(irc *ctx, chanrep *chanarr, size_t chanarr_cnt);
80 
88 chanrep *irc_chan(irc *ctx, chanrep *dest, const char *name);
89 
103 bool irc_tag_chan(irc *ctx, const char *chnam, void *tag, bool autofree);
104 
107 size_t irc_num_users(irc *ctx);
108 
119 size_t irc_all_users(irc *ctx, userrep *userarr, size_t userarr_cnt);
120 
129 userrep *irc_user(irc *ctx, userrep *dest, const char *ident);
130 
145 bool irc_tag_user(irc *ctx, const char *ident, void *tag, bool autofree);
146 
147 
151 size_t irc_num_members(irc *ctx, const char *chnam);
152 
164 size_t irc_all_members(irc *ctx, const char *chnam, userrep *userarr,
165  size_t userarr_cnt);
166 
167 
178 userrep *irc_member(irc *ctx, userrep *dest, const char *chnam, const char *ident);
179 
180 /* for debugging */
181 
189 void lsi_trk_dump(irc *ctx, bool full);
190 
193 #endif /* LIBSRSIRC_IRC_TRACK_H */
const char * fname
Full name, or NULL if unknown.
Definition: irc_track.h:49
userrep * irc_user(irc *ctx, userrep *dest, const char *ident)
Retrieve one user representation by nickname.
const char * host
Hostname, or NULL if unknown.
Definition: irc_track.h:48
void * tag
Opaque user (as in, libsrsirc user) data.
Definition: irc_track.h:51
const char * modepfx
Mode prefix - only used when dealing with the user in the context of a channel membership, NULL otherwise.
Definition: irc_track.h:45
bool irc_tag_chan(irc *ctx, const char *chnam, void *tag, bool autofree)
Associate opaque user data with a channel.
size_t irc_all_members(irc *ctx, const char *chnam, userrep *userarr, size_t userarr_cnt)
Retrieve representations of all members of a channel.
void lsi_trk_dump(irc *ctx, bool full)
Dump tracking state for debugging purposes.
Object representation of an IRC channel.
Definition: irc_track.h:21
uint64_t tstopic
Topic timestamp (ms since Epoch)
Definition: irc_track.h:26
size_t irc_num_chans(irc *ctx)
Count the channels we are currently in.
size_t irc_all_users(irc *ctx, userrep *userarr, size_t userarr_cnt)
Retrieve representations of all users we&#39;re currently seeing.
Object representation of an IRC user.
Definition: irc_track.h:34
const char * topicnick
Nick of who set the topic, or NULL.
Definition: irc_track.h:24
const char * name
Name of the channel.
Definition: irc_track.h:22
struct irc_s irc
IRC context; pointers to this are our IRC context handle type.
Definition: defs.h:144
const char * topic
Topic of the channel, or NULL.
Definition: irc_track.h:23
const char * uname
Username, or NULL if unknown.
Definition: irc_track.h:47
size_t irc_all_chans(irc *ctx, chanrep *chanarr, size_t chanarr_cnt)
Retrieve representations of all channels we&#39;re currently in.
void * tag
Opaque user data.
Definition: irc_track.h:27
bool irc_tag_user(irc *ctx, const char *ident, void *tag, bool autofree)
Associate opaque user data with a user.
const char * nick
Nickname of the user.
Definition: irc_track.h:46
size_t nchans
Number of channels we know the user is in.
Definition: irc_track.h:50
size_t irc_num_users(irc *ctx)
Count the users we are currently seeing.
uint64_t tscreate
Channel creation time (ms since Epoch)
Definition: irc_track.h:25
size_t irc_num_members(irc *ctx, const char *chnam)
Count number of users in a given channel.
userrep * irc_member(irc *ctx, userrep *dest, const char *chnam, const char *ident)
Retrieve one member representation by nickname and channel.
chanrep * irc_chan(irc *ctx, chanrep *dest, const char *name)
Retrieve one channel representation by channel name.