
#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<pthread.h>
#include<stdlib.h>

#include"zither.h"
#include<almemsys/almemsys.h>


/*
int log_out(char *, char *, char *);
*/

// V6 対応

int log_out(int fd, char * user, char * com, char * data1, char * data2, unsigned char * chIpadd)
{
static int ret;
int a;
char * outlog_data = (char *)calloc(BUF_DEFLEN, sizeof(char));
char * time_data = (char *)calloc(BUF_DEFLEN, sizeof(char));

ret = 0;

swap_mem(data1, '\n', ' ');
swap_mem(data2, '\n', ' ');

time_data = time_getr(time_data);

outlog_data = safe_sprintf(outlog_data, BUF_MAX, "%s [%s] user:%s com:%s in:%s out:%s\n",
   chIpadd, time_data, user, com, data1, data2);

#ifdef DEBUG
fprintf(stderr,"DEBUG: log_out(): %s\n", outlog_data);
#endif

a = strlen(outlog_data);
ret = write(fd, outlog_data, a);

free(outlog_data);
free(time_data);

return(ret);
}







