Загрузить файлы в «»

This commit is contained in:
8nlight 2023-08-06 20:16:49 +03:00
parent 7a81db868b
commit 1c4180cc36
2 changed files with 5 additions and 5 deletions

2
cfg.h
View File

@ -10,4 +10,4 @@ char *channels[] = {"#channel"};
#define FORMAT_HTML "[%s] %s<br>\n"
#define FORMAT FORMAT_TXT
#define OUTPUT ".txt"
#define EXT ".txt"

8
main.c
View File

@ -18,12 +18,12 @@ char *GetFilename(void) {
//Get filename + date
struct tm tm = GetTime();
size_t filename_size = strlen(client.channel + 1) + (sizeof(tm.tm_year) * 3) + strlen(OUTPUT) + 3;
size_t filename_size = strlen(client.channel + 1) + (sizeof(tm.tm_year) * 3) + strlen(EXT) + 3;
char *filename = malloc(filename_size + 1);
if (filename == NULL)
die("malloc returned NULL");
snprintf(filename, filename_size, "%s-%d-%d-%d%s", client.channel + 1, tm.tm_year + 1900, tm.tm_mon, tm.tm_mday, OUTPUT);
snprintf(filename, filename_size, "%s-%d-%d-%d%s", client.channel + 1, tm.tm_year + 1900, tm.tm_mon, tm.tm_mday, EXT);
return filename;
}
@ -48,7 +48,7 @@ int main(void) {
if (chdir(DIR))
die("Cant chdir");
//512 - size of raw buffer (max)
//512 - size of raw buffer (max irc)
IRCC_init(&client, 512);
int status = IRCC_connect(&client, HOST, PORT);
if (status == IRCC_ERROR)
@ -57,7 +57,7 @@ int main(void) {
//Register and join in channel
IRCC_register(&client, NICK);
for (size_t i = 0; i < sizeof(channels) / sizeof(char *); i++) {
sleep(1);
sleep(3);
size_t join_size = strlen("JOIN \r\n") + strlen(channels[i]) + 1;
char *tmp = malloc(join_size);
if (tmp == NULL)