2005-10-09 13:47:20 +02:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* This file is part of the bip project
|
2022-01-09 21:20:49 +01:00
|
|
|
* Copyright (C) 2004,2005 Arnaud Cornet
|
|
|
|
* Copyright (C) 2004,2005,2022 Loïc Gomez
|
2005-10-09 13:47:20 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
* See the file "COPYING" for the exact licensing terms.
|
|
|
|
*/
|
|
|
|
|
2005-04-28 10:26:44 +02:00
|
|
|
#ifndef IRC_LINE_H
|
|
|
|
#define IRC_LINE_H
|
|
|
|
|
|
|
|
#include "connection.h"
|
|
|
|
|
2022-03-10 13:52:03 +01:00
|
|
|
#define WRITE_LINE0(con, org, com) \
|
|
|
|
do { \
|
|
|
|
struct line l; \
|
|
|
|
irc_line_init(&l); \
|
|
|
|
l.origin = org; \
|
|
|
|
_irc_line_append(&l, com); \
|
|
|
|
irc_line_write(&l, con); \
|
|
|
|
_irc_line_deinit(&l); \
|
|
|
|
} while (0)
|
2006-09-18 20:05:17 +02:00
|
|
|
|
2022-03-10 13:52:03 +01:00
|
|
|
#define WRITE_LINE1(con, org, com, a) \
|
|
|
|
do { \
|
|
|
|
struct line l; \
|
|
|
|
irc_line_init(&l); \
|
|
|
|
l.origin = org; \
|
|
|
|
_irc_line_append(&l, com); \
|
|
|
|
_irc_line_append(&l, a); \
|
|
|
|
irc_line_write(&l, con); \
|
|
|
|
_irc_line_deinit(&l); \
|
|
|
|
} while (0)
|
2005-04-28 10:26:44 +02:00
|
|
|
|
2022-03-10 13:52:03 +01:00
|
|
|
#define WRITE_LINE2(con, org, com, a1, a2) \
|
|
|
|
do { \
|
|
|
|
struct line l; \
|
|
|
|
irc_line_init(&l); \
|
|
|
|
l.origin = org; \
|
|
|
|
_irc_line_append(&l, com); \
|
|
|
|
_irc_line_append(&l, a1); \
|
|
|
|
_irc_line_append(&l, a2); \
|
|
|
|
irc_line_write(&l, con); \
|
|
|
|
_irc_line_deinit(&l); \
|
|
|
|
} while (0)
|
2005-04-28 10:26:44 +02:00
|
|
|
|
2022-03-10 13:52:03 +01:00
|
|
|
#define WRITE_LINE3(con, org, com, a1, a2, a3) \
|
|
|
|
do { \
|
|
|
|
struct line l; \
|
|
|
|
irc_line_init(&l); \
|
|
|
|
l.origin = org; \
|
|
|
|
_irc_line_append(&l, com); \
|
|
|
|
_irc_line_append(&l, a1); \
|
|
|
|
_irc_line_append(&l, a2); \
|
|
|
|
_irc_line_append(&l, a3); \
|
|
|
|
irc_line_write(&l, con); \
|
|
|
|
_irc_line_deinit(&l); \
|
|
|
|
} while (0)
|
2005-04-28 10:26:44 +02:00
|
|
|
|
2022-03-10 13:52:03 +01:00
|
|
|
#define WRITE_LINE4(con, org, com, a1, a2, a3, a4) \
|
|
|
|
do { \
|
|
|
|
struct line l; \
|
|
|
|
irc_line_init(&l); \
|
|
|
|
l.origin = org; \
|
|
|
|
_irc_line_append(&l, com); \
|
|
|
|
_irc_line_append(&l, a1); \
|
|
|
|
_irc_line_append(&l, a2); \
|
|
|
|
_irc_line_append(&l, a3); \
|
|
|
|
_irc_line_append(&l, a4); \
|
|
|
|
irc_line_write(&l, con); \
|
|
|
|
_irc_line_deinit(&l); \
|
|
|
|
} while (0)
|
2005-04-28 10:26:44 +02:00
|
|
|
|
|
|
|
struct line {
|
|
|
|
char *origin;
|
2008-12-20 14:20:50 +01:00
|
|
|
array_t words;
|
2005-04-28 10:26:44 +02:00
|
|
|
int colon;
|
|
|
|
};
|
|
|
|
|
|
|
|
void irc_line_init(struct line *l);
|
2008-12-18 14:27:16 +01:00
|
|
|
void _irc_line_deinit(struct line *l);
|
2022-01-09 21:20:49 +01:00
|
|
|
struct line *irc_line_new(void);
|
2005-04-28 10:26:44 +02:00
|
|
|
void irc_line_write(struct line *l, connection_t *c);
|
2008-12-15 19:19:27 +01:00
|
|
|
void irc_line_append(struct line *l, const char *s);
|
2008-12-20 14:20:50 +01:00
|
|
|
struct line *irc_line_new_from_string(char *str);
|
2005-04-28 10:26:44 +02:00
|
|
|
char *irc_line_to_string(struct line *l);
|
2008-12-18 14:27:16 +01:00
|
|
|
char *irc_line_to_string_to(struct line *line, char *nick);
|
2005-04-28 10:26:44 +02:00
|
|
|
void irc_line_free(struct line *l);
|
|
|
|
struct line *irc_line_dup(struct line *line);
|
2008-12-15 19:19:27 +01:00
|
|
|
void _irc_line_append(struct line *l, const char *s);
|
2008-12-20 14:20:50 +01:00
|
|
|
int irc_line_includes(struct line *line, int elem);
|
2008-12-15 19:19:27 +01:00
|
|
|
const char *irc_line_elem(struct line *line, int elem);
|
|
|
|
int irc_line_count(struct line *line);
|
|
|
|
char *irc_line_pop(struct line *l);
|
2022-01-03 09:25:52 +01:00
|
|
|
int irc_line_is_error(struct line *line);
|
2008-12-15 19:19:27 +01:00
|
|
|
int irc_line_elem_equals(struct line *line, int elem, const char *cmp);
|
|
|
|
int irc_line_elem_case_equals(struct line *line, int elem, const char *cmp);
|
2009-02-02 19:47:53 +01:00
|
|
|
void irc_line_drop(struct line *line, int elem);
|
2005-04-28 10:26:44 +02:00
|
|
|
|
|
|
|
#endif
|