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

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_HTML "[%s] %s<br>\n"
#define FORMAT FORMAT_TXT #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 //Get filename + date
struct tm tm = GetTime(); 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); char *filename = malloc(filename_size + 1);
if (filename == NULL) if (filename == NULL)
die("malloc returned 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; return filename;
} }
@ -48,7 +48,7 @@ int main(void) {
if (chdir(DIR)) if (chdir(DIR))
die("Cant chdir"); die("Cant chdir");
//512 - size of raw buffer (max) //512 - size of raw buffer (max irc)
IRCC_init(&client, 512); IRCC_init(&client, 512);
int status = IRCC_connect(&client, HOST, PORT); int status = IRCC_connect(&client, HOST, PORT);
if (status == IRCC_ERROR) if (status == IRCC_ERROR)
@ -57,7 +57,7 @@ int main(void) {
//Register and join in channel //Register and join in channel
IRCC_register(&client, NICK); IRCC_register(&client, NICK);
for (size_t i = 0; i < sizeof(channels) / sizeof(char *); i++) { 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; size_t join_size = strlen("JOIN \r\n") + strlen(channels[i]) + 1;
char *tmp = malloc(join_size); char *tmp = malloc(join_size);
if (tmp == NULL) if (tmp == NULL)