/* * This file is part of blabouncer (https://www.blatech.co.uk/l_bratch/blabouncer). * Copyright (C) 2019 Luke Bratch . * * Blabouncer 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, version 3. * * Blabouncer 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 blabouncer. If not, see . */ #ifndef FUNCTIONS_H_INCLUDED #define FUNCTIONS_H_INCLUDED #include #include #include #include #include #include #include #include #include #include #include #include #include #define MAXDATASIZE 513 // max number of bytes we can get at once (RFC2812 says 512, plus one for null terminator) // getstdin() return codes #define OK 0 #define NO_INPUT 1 #define TOO_LONG 2 #define DEBUG_CRIT 0 #define DEBUG_SOME 1 #define DEBUG_FULL 2 // Write debug string to file. // Debug level is provided by level, set to one of DEBUG_CRIT, DEBUG_SOME or DEBUG_FULL. // Debug is only written if the global int "debug" is greater than or equal to the level. void debugprint(int level, char *format, ...); // Get stdin line with buffer overrun protection int getstdin(char *prompt, char *buff, size_t sz); // Append CR-LF to the end of a string (after cleaning up any existing trailing CR or LF) void appendcrlf(char *string); // Remove leading colon ':' which is the starting character of a prefix in an IRC message void stripprefix(char *string); // Extract final parameter from IRC message, removing the leading colon ':' void extractfinalparameter(char *string); // Extract the IRC nick from a prefix void extractnickfromprefix(char *string); // Update an existing nickuserhost string with a new nick void updatenickuserhost(char *nickuserhost, char *nick); // Update an existing 001 greeting with a new nickuserhost void updategreetings(char *greeting001, char *greeting002, char *greeting003, char *greeting004, char *greeting005a, char *greeting005b, char *greeting005c, char *newnickuserhost, char *oldnickuserhost, char *newnick, char *oldnick); #endif