Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 92 lines (75 sloc) 2.451 kb
29252b6 More refactoring; chopping up quirc.c. '#pragma once'-ing headers
Sound and Fury authored
1 #pragma once
2
9f0cff1 Initial commit.
Sound and Fury authored
3 /*
3fcb080 Enable many warnings & fix them
ec429 authored
4 quIRC - simple terminal-based IRC client
3c98009 Nudge the (C)opyright message to '2010-11'
ec429 authored
5 Copyright (C) 2010-11 Edward Cree
3fcb080 Enable many warnings & fix them
ec429 authored
6
9f0cff1 Initial commit.
Sound and Fury authored
7 See quirc.c for license information
8 irc: networking functions
9 */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <stdbool.h>
14 #include <string.h>
15 #include <unistd.h>
8844d52 Fix various compile errors in prev. commit
Sound and Fury authored
16 #include <fcntl.h>
556a521 Functions for irc-style casemapping
Sound and Fury authored
17 #include <ctype.h>
9f0cff1 Initial commit.
Sound and Fury authored
18 #include <sys/socket.h>
19 #include <sys/utsname.h>
20 #include <netdb.h>
21 #include <arpa/inet.h>
22 #include <netinet/in.h>
5bd9397 Asynchronous connect(), fixes, and liveness (unfinished)
Sound and Fury authored
23 #include <errno.h>
417d27e Handle SIGPIPE
Sound and Fury authored
24 #include <signal.h>
29252b6 More refactoring; chopping up quirc.c. '#pragma once'-ing headers
Sound and Fury authored
25
bdca1e0 More correct casemapping handling (doesn't yet detect from RPL_ISUPPORT)
Sound and Fury authored
26 typedef enum
27 {
28 RFC1459,
29 STRICT_RFC1459,
30 ASCII
31 }
32 cmap;
33
61b2658 irc_breakdown() function, parses :prefix cmd args...
Sound and Fury authored
34 typedef struct
35 {
36 char *prefix;
37 char *cmd;
38 int nargs;
39 char *args[15]; // RFC specifies maximum of 15 args
40 }
41 message;
42
a9c16e9 Things generally are now buffer-aware
Sound and Fury authored
43 #include "bits.h"
29252b6 More refactoring; chopping up quirc.c. '#pragma once'-ing headers
Sound and Fury authored
44 #include "buffer.h"
45 #include "colour.h"
46 #include "config.h"
83af8c1 Move handling of numeric responses out to irc.c
Sound and Fury authored
47 #include "numeric.h"
bdca1e0 More correct casemapping handling (doesn't yet detect from RPL_ISUPPORT)
Sound and Fury authored
48 #include "names.h"
9f0cff1 Initial commit.
Sound and Fury authored
49
bfdcd84 Handle Low-Level Quoting
Sound and Fury authored
50 #define MQUOTE '\020'
51
ca84446 React to SIGWINCH (unless option 'winch' is set false)
ec429 authored
52 volatile sig_atomic_t sigpipe, sigwinch;
417d27e Handle SIGPIPE
Sound and Fury authored
53
ca84446 React to SIGWINCH (unless option 'winch' is set false)
ec429 authored
54 void handle_sigpipe(int); // handles both sigpipe and sigwinch
417d27e Handle SIGPIPE
Sound and Fury authored
55
5bd9397 Asynchronous connect(), fixes, and liveness (unfinished)
Sound and Fury authored
56 int irc_connect(char *server, char *portno, fd_set *master, int *fdmax); // non-blocking
b5829d6 PASS (--pass) and related stuff, also call termsize() at startup
ec429 authored
57 int irc_conn_rest(int b, char *nick, char *username, char *passwd, char *fullname); // call this when the non-blocking connect() has finished
e515989 Allow multiple automatic connects and joins in .quirc
Sound and Fury authored
58 int autoconnect(fd_set *master, int *fdmax, servlist *serv);
9f0cff1 Initial commit.
Sound and Fury authored
59 int irc_tx(int fd, char * packet);
60 int irc_rx(int fd, char ** data);
61b2658 irc_breakdown() function, parses :prefix cmd args...
Sound and Fury authored
61
62 message irc_breakdown(char *packet);
7c3fe55 More work on parsing and protocol correctness etc.
Sound and Fury authored
63 void message_free(message pkt);
9add456 Improve PREFIX handling (RPL_ISUPPORT) and :prefix handling
Sound and Fury authored
64 void prefix_split(char * prefix, char **src, char **user, char **host);
65
bfdcd84 Handle Low-Level Quoting
Sound and Fury authored
66 void low_quote(char *from, char to[512]);
67 char * low_dequote(char *buf);
e928ecf Refactor PING, MODE and KILL handling
Sound and Fury authored
68
bdca1e0 More correct casemapping handling (doesn't yet detect from RPL_ISUPPORT)
Sound and Fury authored
69 char irc_to_upper(char c, cmap casemapping);
70 char irc_to_lower(char c, cmap casemapping);
f048496 Some const-correctness
ec429 authored
71 int irc_strcasecmp(const char *c1, const char *c2, cmap casemapping);
72 int irc_strncasecmp(const char *c1, const char *c2, int n, cmap casemapping);
556a521 Functions for irc-style casemapping
Sound and Fury authored
73
d88f242 //text sends message /text (then /// sends //, etc.)
ec429 authored
74 // Send an IRC PRIVMSG (ie. ordinary talking)
75 int talk(char *iinput);
76
6fee724 Some work on the new RX parsing
Sound and Fury authored
77 // Received-IRC message handlers
78 int irc_numeric(message pkt, int b);
8acd80f More work on the new parsing code
Sound and Fury authored
79 int rx_ping(message pkt, int b);
cdd4d11 Implemented MODEs, except that nick-prefixes are never displayed
ec429 authored
80 int rx_mode(message pkt, int b); // the first MODE triggers auto-join
8acd80f More work on the new parsing code
Sound and Fury authored
81 int rx_kill(message pkt, int b, fd_set *master);
82 int rx_kick(message pkt, int b);
83 int rx_error(message pkt, int b, fd_set *master);
bf8886f Much more parsing work
Sound and Fury authored
84 int rx_privmsg(message pkt, int b, bool notice);
8acd80f More work on the new parsing code
Sound and Fury authored
85 int rx_topic(message pkt, int b);
86 int rx_join(message pkt, int b);
87 int rx_part(message pkt, int b);
88 int rx_quit(message pkt, int b);
89 int rx_nick(message pkt, int b);
097f13b Refactoring (CTCP handling from rx_privmsg() to ctcp())
Sound and Fury authored
90
834778f Better handling of NOTICE CTCP
Sound and Fury authored
91 int ctcp(char *msg, char *from, char *src, int b2, bool ha, bool notice, bool priv); // Handle CTCP (Client-To-Client Protocol) messages (from is crushed-src)
Something went wrong with that request. Please try again.