tools.c
来自「一个ftp服务器程序」· C语言 代码 · 共 50 行
C
50 行
# include "ftpdaemon.h"extern char ftplog_file[_POSIX_PATH_MAX];extern char curr_time[80];void FTPLOG( char *fmt, ... ){ FILE *fp; struct tm *tm; time_t tloc; va_list ap;#ifdef NOFTPLOG return ;#endif va_start( ap, fmt ); time( &tloc ); tm = localtime( &tloc ); if ( (fp=fopen(ftplog_file, "a+")) != NULL ) { fprintf( fp, "%02d/%02d/%02d %02d:%02d:%02d ", \ tm->tm_year, tm->tm_mon+1, tm->tm_mday, \ tm->tm_hour, tm->tm_min, tm->tm_sec ); vfprintf( fp, fmt, ap ); fprintf( fp, "\n" ); fsync( fileno(fp) ); fclose( fp ); } va_end( ap );}char *currtime( ){ struct tm *tm; time_t tloc; memset(curr_time, 0, sizeof(curr_time)); time( &tloc ); tm = localtime( &tloc ); sprintf(curr_time, "%02d%02d%02d-%02d%02d%02d", \ tm->tm_year, tm->tm_mon+1, tm->tm_mday, \ tm->tm_hour, tm->tm_min, tm->tm_sec ); return (char *)curr_time;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?