53 lines
1.8 KiB
C
53 lines
1.8 KiB
C
|
/*
|
||
|
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
||
|
* Copyright (c) 2019, 2020 Alex-David Denes
|
||
|
*
|
||
|
* uIRC 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 3 of the License, or
|
||
|
* any later version.
|
||
|
*
|
||
|
* uIRC is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
#include "../../assemblers/assemblers.h" // Assm_mesg()
|
||
|
#include "../../tokenizers/tokenizers.h" // Tok_mesg()
|
||
|
#include "../../types.h" // IRC_User
|
||
|
#include "../common.h" // expect()
|
||
|
|
||
|
#include <assert.h> // assert()
|
||
|
#include <stdlib.h> // EXIT_SUCCESS
|
||
|
|
||
|
int
|
||
|
main(void)
|
||
|
{
|
||
|
const char* str[] = { ":buddy@hostnet.com PRIVMSG #general :login hunter12",
|
||
|
"NOTICE * :nice cock bro",
|
||
|
"@day=13;willtolive=0 PRIVMSG you :helo",
|
||
|
":mom!mother@localhost NOTICE #netadmin :johnny, your pizza is done" };
|
||
|
|
||
|
for (unsigned long i = 0; i < sizeof(str) / sizeof(*str); i++) {
|
||
|
IRC_Message* m = NULL;
|
||
|
if ((m = uirc_tokenizer_message(str[i])) == NULL) {
|
||
|
printf("Failed to convert string to IRC_Message struct.\n");
|
||
|
return EXIT_FAILURE;
|
||
|
}
|
||
|
signed long ret;
|
||
|
char buf[513];
|
||
|
if ((ret = uirc_assembler_message(buf, m, sizeof(buf) / sizeof(char))) <= 0) {
|
||
|
printf("Failed to convert IRC_Message struct to a string. (%li)\n", ret);
|
||
|
return EXIT_FAILURE;
|
||
|
}
|
||
|
expect(buf, str[i]);
|
||
|
print_irc_message(m);
|
||
|
}
|
||
|
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|