static void Do_work( const char *name, struct line_list *args, WorkerProc *proc, int intern_logger, int intern_status, int intern_mail, int intern_lpd_request, int param_fd ) { Logger_fd = intern_logger; Status_fd = intern_status; Mail_fd = intern_mail; Lpd_request = intern_lpd_request; /* undo the non-blocking IO */ if( Lpd_request > 0 ){ /* undo the non-blocking IO */ Set_block_io( Lpd_request ); } Debug= Find_flag_value( args, DEBUG ); DbgFlag= Find_flag_value( args, DEBUGFV ); #ifdef DMALLOC { extern int dmalloc_outfile_fd; dmalloc_outfile_fd = intern_dmalloc; } #endif DEBUG3("Do_work: '%s', proc 0x%lx ", name, Cast_ptr_to_long(proc) ); (proc)(args, param_fd); cleanup(0); }
void Add_buffer( int n ) { int len = max_in_buffers, count; if(debug)FPRINTF(STDERR, "Add_buffer: start n %d, inbuffers 0x%lx, max_in_buffers %d\n", n, Cast_ptr_to_long(inbuffers), max_in_buffers ); if( max_in_buffers <= n ){ max_in_buffers = n+1; count = sizeof(inbuffers[0])*max_in_buffers; inbuffers = realloc( inbuffers, count ); if( inbuffers == 0 ){ FPRINTF(STDERR,"Add_buffer: realloc %d failed\n", n ); exit(1); } for( count = len; count < max_in_buffers; ++count ){ memset(inbuffers+count,0,sizeof(inbuffers[0])); } } if(debug)FPRINTF(STDERR,"Add_buffer: end n %d, inbuffers 0x%lx, max_in_buffers %d\n", n, Cast_ptr_to_long(inbuffers), max_in_buffers ); }
struct info *Save_outbuf_len( int n, char *str, int len ) { struct info *in; if(debug)FPRINTF(STDERR,"Save_outbuf_len: n %d, len %d\n", n, len ); Add_buffer(n); in = inbuffers+n; if(debug)FPRINTF(STDERR, "Save_outbuf_len: start inbuffers 0x%lx, in 0x%lx, buffer 0x%lx, len %d, max_len %d\n", Cast_ptr_to_long(inbuffers), Cast_ptr_to_long(in), Cast_ptr_to_long(in->buffer), in->len, in->max_len ); if( len + in->len >= in->max_len ){ in->max_len += len; in->buffer = realloc( in->buffer, in->max_len+1 ); if( in->buffer == 0 ){ FPRINTF(STDERR,"Put_oubuf_len: realloc %d failed\n", in->max_len ); exit(1); } } memcpy(in->buffer+in->len, str, len+1 ); in->len += len; if(debug)FPRINTF(STDERR, "Save_outbuf_len: start inbuffers 0x%lx, in 0x%lx, buffer 0x%lx, len %d, max_len %d\n", Cast_ptr_to_long(inbuffers), Cast_ptr_to_long(in), Cast_ptr_to_long(in->buffer), in->len, in->max_len ); return( in ); }