39 lines
991 B
C
39 lines
991 B
C
#include "common.h"
|
|
|
|
char* mIRC_COLORS[16] = {"97", "30", "34", "32", "91", "31", "35", "33", "93", "92", "96", "36", "94", "95", "90", "37"};
|
|
|
|
ssize_t get_buffer_line(char* buf, IRC_Message* parsed)
|
|
{
|
|
if (buf == NULL || parsed == NULL) return -1;
|
|
char* ppoi;
|
|
if ((ppoi = strchr(buf, '\n')) != NULL) {
|
|
*ppoi = '\0';
|
|
if (ppoi > buf && *(ppoi - 1) == '\r') *(ppoi - 1) = '\0';
|
|
if (Tok_mesg(buf, parsed) == 1) return ++ppoi - buf;
|
|
fprintf(stderr, "warning: received invalid message.\n");
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void print_local_time(const char* irc_time)
|
|
{
|
|
if (irc_time != NULL) {
|
|
struct tm time;
|
|
char* tz;
|
|
char buffer[32];
|
|
strptime(irc_time, "%Y-%m-%dT%H:%M:%S", &time);
|
|
tz = getenv("TZ");
|
|
setenv("TZ", "", 1);
|
|
tzset();
|
|
time_t ctime = mktime(&time);
|
|
if (tz != NULL)
|
|
setenv("TZ", tz, 1);
|
|
else
|
|
unsetenv("TZ");
|
|
tzset();
|
|
strftime(buffer, sizeof(buffer), "%c", localtime(&ctime));
|
|
printf(" " ANSI_COLOR_BLUE "(%s)" ANSI_COLOR_RESET, buffer);
|
|
}
|
|
}
|