]>
jfr.im git - solanum.git/blob - ircd/msgbuf.c
2 * charybdis - an advanced ircd.
3 * Copyright (c) 2016 William Pitcock <nenolod@dereferenced.org>.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice is present in all copies.
9 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
10 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
12 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
13 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
14 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
15 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
16 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
17 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
18 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
19 * POSSIBILITY OF SUCH DAMAGE.
23 #include "ircd_defs.h"
27 * parse a message into a MsgBuf.
28 * returns 0 on success, 1 on error.
31 msgbuf_parse(struct MsgBuf
*msgbuf
, char *line
)
38 /* skip any leading spaces */
39 for (ch
= line
; *ch
&& *ch
== ' '; ch
++)
53 char *next
= strchr(t
, ';');
54 char *eq
= strchr(t
, '=');
65 msgbuf_append_tag(msgbuf
, t
, eq
);
75 /* skip any whitespace between tags and origin */
76 for (; *ch
&& *ch
== ' '; ch
++)
84 char *end
= strchr(ch
, ' ');
90 for (ch
= end
+ 1; *ch
&& *ch
== ' '; ch
++)
97 n_para
= rb_string_to_array(ch
, parv
, MAXPARA
);
101 msgbuf
->cmd
= parv
[0];
102 for (i
= 0; i
< n_para
; i
++)
103 msgbuf_append_para(msgbuf
, parv
[i
]);