Ignore:
Timestamp:
26/07/06 11:18:55 (14 years ago)
Author:
spascoe
Message:

I've created a bbftpd log facility to replace syslog.
At present it allows you to log messages to a file in addition
to syslog. This should help testing on other machines.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/storeafile.c

    r773 r1328  
    5656              v 2.0.1  2001/04/23   - Correct indentation 
    5757              v 2.0.2  2001/05/04   - Correct return code treatment 
    58               v 2.1.0  2001/05/30   - Correct syslog level 
     58              v 2.1.0  2001/05/30   - Correct bbftpd_log level 
    5959                                       
    6060 *****************************************************************************/ 
     
    6565#include <signal.h> 
    6666#include <stdio.h> 
    67 #include <syslog.h> 
     67#include <bbftpd_log.h> 
    6868#include <sys/stat.h> 
    6969#include <sys/time.h> 
     
    174174#endif 
    175175    if ( code == MSG_STORE ) { 
    176         syslog(BBFTPD_DEBUG,"Storing file %s of size %" LONG_LONG_FORMAT " with %d children",currentfilename,msg_store->filesize,msg_store->nbport) ; 
     176        bbftpd_log(BBFTPD_DEBUG,"Storing file %s of size %" LONG_LONG_FORMAT " with %d children",currentfilename,msg_store->filesize,msg_store->nbport) ; 
    177177    } else { 
    178         syslog(BBFTPD_DEBUG,"Storing file %s of size %" LONG_LONG_FORMAT " with %d children in compressed mode",currentfilename,msg_store->filesize,msg_store->nbport) ; 
     178        bbftpd_log(BBFTPD_DEBUG,"Storing file %s of size %" LONG_LONG_FORMAT " with %d children in compressed mode",currentfilename,msg_store->filesize,msg_store->nbport) ; 
    179179    } 
    180180    /* 
     
    201201            savederrno == ENOTDIR ) { 
    202202            sprintf(logmessage,"Error stating file %s : %s ",currentfilename,strerror(savederrno)) ; 
    203             syslog(BBFTPD_ERR,"Error stating file %s : %s ",currentfilename,strerror(savederrno)) ; 
     203            bbftpd_log(BBFTPD_ERR,"Error stating file %s : %s ",currentfilename,strerror(savederrno)) ; 
    204204            reply(MSG_BAD_NO_RETRY,logmessage) ; 
    205205            return 0 ; 
     
    210210        } else { 
    211211            sprintf(logmessage,"Error stating file %s : %s ",currentfilename,strerror(savederrno)) ; 
    212             syslog(BBFTPD_ERR,"Error stating file %s : %s ",currentfilename,strerror(savederrno)) ; 
     212            bbftpd_log(BBFTPD_ERR,"Error stating file %s : %s ",currentfilename,strerror(savederrno)) ; 
    213213            reply(MSG_BAD,logmessage) ; 
    214214            return 0 ; 
     
    219219        */ 
    220220        if ( (statbuf.st_mode & S_IFDIR) == S_IFDIR) { 
    221             syslog(BBFTPD_ERR,"file %s is a directory",currentfilename) ; 
     221            bbftpd_log(BBFTPD_ERR,"file %s is a directory",currentfilename) ; 
    222222            sprintf(logmessage,"File %s is a directory",currentfilename) ; 
    223223            reply(MSG_BAD_NO_RETRY,logmessage) ; 
     
    239239        savederrno = errno ; 
    240240        sprintf(logmessage,"Error creation file %s : %s ",currentfilename,strerror(errno)) ; 
    241         syslog(BBFTPD_ERR,"Error creation file %s : %s ",currentfilename,strerror(errno)) ; 
     241        bbftpd_log(BBFTPD_ERR,"Error creation file %s : %s ",currentfilename,strerror(errno)) ; 
    242242        /* 
    243243        ** We tell the client not to retry in the following case (even in waiting 
     
    283283        close(fd) ; 
    284284        unlink(currentfilename) ; 
    285         syslog(BBFTPD_ERR,"Error seeking file %s : %s ",currentfilename,strerror(errno)) ; 
     285        bbftpd_log(BBFTPD_ERR,"Error seeking file %s : %s ",currentfilename,strerror(errno)) ; 
    286286        reply(MSG_BAD,logmessage) ; 
    287287        return 0 ; 
     
    295295        close(fd) ; 
    296296        unlink(currentfilename) ; 
    297         syslog(BBFTPD_ERR,"Error writing file %s : %s ",currentfilename,strerror(errno)) ; 
     297        bbftpd_log(BBFTPD_ERR,"Error writing file %s : %s ",currentfilename,strerror(errno)) ; 
    298298        /* 
    299299        ** We tell the client not to retry in the following case (even in waiting 
     
    316316        savederrno = errno ; 
    317317        unlink(currentfilename) ; 
    318         syslog(BBFTPD_ERR,"Error closing file %s : %s ",currentfilename,strerror(savederrno)) ; 
     318        bbftpd_log(BBFTPD_ERR,"Error closing file %s : %s ",currentfilename,strerror(savederrno)) ; 
    319319        sprintf(logmessage,"Error closing file %s : %s ",currentfilename,strerror(savederrno)) ; 
    320320        if ( savederrno == ENOSPC ) { 
     
    384384                select(nfds,0,0,0,&wait_timer) ; 
    385385            } 
    386             syslog(BBFTPD_DEBUG,"Child Starting") ; 
     386            bbftpd_log(BBFTPD_DEBUG,"Child Starting") ; 
    387387            /* 
    388388            ** Close all unnecessary stuff 
     
    402402                */  
    403403                i = errno ; 
    404                 syslog(BBFTPD_ERR,"Error stating file %s : %s ",currentfilename,strerror(errno)) ; 
     404                bbftpd_log(BBFTPD_ERR,"Error stating file %s : %s ",currentfilename,strerror(errno)) ; 
    405405                close(recsock) ; 
    406406                exit(i) ; 
     
    416416                i = errno ; 
    417417                unlink(currentfilename) ; 
    418                 syslog(BBFTPD_ERR,"Error opening file %s : %s ",currentfilename,strerror(errno)) ; 
     418                bbftpd_log(BBFTPD_ERR,"Error opening file %s : %s ",currentfilename,strerror(errno)) ; 
    419419                /* 
    420420                ** At this point a non recoverable error is  
     
    439439                close(fd) ; 
    440440                unlink(currentfilename) ; 
    441                 syslog(BBFTPD_ERR,"error seeking file : %s",strerror(errno)) ; 
     441                bbftpd_log(BBFTPD_ERR,"error seeking file : %s",strerror(errno)) ; 
    442442                close(recsock) ; 
    443443                exit(i)  ; 
     
    454454                    */ 
    455455                    if (readmessage(recsock,receive_buffer,COMPMESSLEN,datato) < 0 ) { 
    456                         syslog(BBFTPD_ERR,"Error reading compression header") ; 
     456                        bbftpd_log(BBFTPD_ERR,"Error reading compression header") ; 
    457457                        close(fd) ; 
    458458                        unlink(currentfilename) ; 
     
    502502                        */ 
    503503                        i = errno ; 
    504                         syslog(BBFTPD_ERR,"Error select while receiving : %s",strerror(errno)) ; 
     504                        bbftpd_log(BBFTPD_ERR,"Error select while receiving : %s",strerror(errno)) ; 
    505505                        close(fd) ; 
    506506                        unlink(currentfilename) ; 
     
    508508                        exit(i) ; 
    509509                    } else if ( retcode == 0 ) { 
    510                         syslog(BBFTPD_ERR,"Time out while receiving") ; 
     510                        bbftpd_log(BBFTPD_ERR,"Time out while receiving") ; 
    511511                        close(fd) ; 
    512512                        unlink(currentfilename) ; 
     
    518518                        if ( retcode < 0 ) { 
    519519                            i = errno ; 
    520                             syslog(BBFTPD_ERR,"Error while receiving : %s",strerror(errno)) ; 
     520                            bbftpd_log(BBFTPD_ERR,"Error while receiving : %s",strerror(errno)) ; 
    521521                            close(fd) ; 
    522522                            unlink(currentfilename) ; 
     
    525525                        } else if ( retcode == 0 ) { 
    526526                            i = ECONNRESET ; 
    527                             syslog(BBFTPD_ERR,"Connexion breaks") ; 
     527                            bbftpd_log(BBFTPD_ERR,"Connexion breaks") ; 
    528528                            close(fd) ; 
    529529                            unlink(currentfilename) ; 
     
    546546                        if ( retcode != 0 ) { 
    547547                            i = EILSEQ ; 
    548                             syslog(BBFTPD_ERR,"Error while decompressing %d ",retcode) ; 
     548                            bbftpd_log(BBFTPD_ERR,"Error while decompressing %d ",retcode) ; 
    549549                            close(fd) ; 
    550550                            unlink(currentfilename) ; 
     
    570570                    if ( (retcode = write(fd,&data_buffer[lenwrited],lentowrite-lenwrited)) < 0 ) { 
    571571                        i = errno ; 
    572                         syslog(BBFTPD_ERR,"error writing file : %s",strerror(errno)) ; 
     572                        bbftpd_log(BBFTPD_ERR,"error writing file : %s",strerror(errno)) ; 
    573573                        close(fd) ; 
    574574                        unlink(currentfilename) ; 
     
    595595                close(fd) ; 
    596596                unlink(currentfilename) ; 
    597                 syslog(BBFTPD_ERR,"Error sending ACK ") ; 
     597                bbftpd_log(BBFTPD_ERR,"Error sending ACK ") ; 
    598598                close(recsock) ; 
    599599                exit(ETIMEDOUT) ; 
    600600            } 
    601601            toprint64 = nbget ; 
    602             syslog(BBFTPD_DEBUG,"Child received %" LONG_LONG_FORMAT " bytes ; end correct ",toprint64) ; 
     602            bbftpd_log(BBFTPD_DEBUG,"Child received %" LONG_LONG_FORMAT " bytes ; end correct ",toprint64) ; 
    603603            close(recsock) ; 
    604604            exit(0) ; 
     
    611611                ** Fork failed ... 
    612612                */ 
    613                 syslog(BBFTPD_ERR,"fork failed : %s",strerror(errno)) ; 
     613                bbftpd_log(BBFTPD_ERR,"fork failed : %s",strerror(errno)) ; 
    614614                unlink(currentfilename) ; 
    615615                sprintf(logmessage,"fork failed : %s ",strerror(errno)) ; 
     
    625625                ** in case of error  
    626626                */ 
    627                 syslog(BBFTPD_DEBUG,"Started child pid %d",retcode) ; 
     627                bbftpd_log(BBFTPD_DEBUG,"Started child pid %d",retcode) ; 
    628628                pid_child[i-1] = retcode ; 
    629629                close(recsock) ; 
Note: See TracChangeset for help on using the changeset viewer.