1 /*
2  * Copyright 2015 Artem Savkov <artem.savkov@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 #include "discord.h"
18 #include <stdlib.h>
19 #include <glib.h>
20 #include <time.h>
21 
22 typedef enum {
23   SEARCH_UNKNOWN,
24   SEARCH_ID,
25   SEARCH_NAME,
26   SEARCH_NAME_IGNORECASE,
27   SEARCH_FNAME,
28   SEARCH_IRC_USER_NAME,
29   SEARCH_IRC_USER_NAME_IGNORECASE
30 } search_t;
31 
32 channel_info *get_channel(discord_data *dd, const char *channel_id,
33                           const char *server_id, search_t type);
34 user_info *get_user(discord_data *dd, const char *uname,
35                     const char *server_id, search_t type);
36 server_info *get_server_by_id(discord_data *dd, const char *server_id);
37 
38 void free_channel_info(channel_info *cinfo);
39 void free_discord_data(discord_data *dd);
40 void free_server_info(server_info *sinfo);
41 void free_user_info(user_info *uinfo);
42 void free_gw_data(gw_data *gw);
43 char *discord_canonize_name(const char *name);
44 char *discord_escape_string(const char *msg);
45 void discord_debug(char *format, ...);
46 char *discord_utf8_strndup(const char *str, size_t n);
47 
48 /* input: 2018-05-24T19:06:42.190000+00:00 */
49 /* output: 1527188802 (the .19 and timezone are discarded) */
50 time_t parse_iso_8601(const char *timestamp);
51