void Rename_PUT_TOK ( int _tok, int _toksize ) { int * _rep; /*** perform realloc if necessary ***/ if ( _out_buf_ptr + _toksize >= _out_buf_size ) { #ifdef TEST_FLAG printf ( "Rename_PUT_TOK: _out_buf realloc (%d -> %d)\n", _out_buf_size, _out_buf_ptr + _toksize + Rename_SocketServerP3 ); #endif doOutRealloc ( _out_buf_ptr + _toksize + Rename_SocketServerP3, "Rename_PUT_TOK" ); } if ( _out_buf_ptr + _toksize < _out_buf_size ) { switch ( _toksize ) { case 1: Put1byteNum ( _tok ); break; case 2: Put2byteNum ( _tok ); break; case 3: Put3byteNum ( _tok ); break; case 4: Put4byteNum ( _tok ); break; } _out_buf_ptr += _toksize; } }
void Rename_WRITE ( int * _rep ) { int write_len; int out_buf_ptr0 = _out_buf_ptr - 4; #ifdef SERVER_STATS_FLAG Rename_clock_e = times ( &Rename_tms_buf_e ); gettimeofday ( &Rename_timeval_buf_e, ( void * ) &Rename_tz ); #endif _out_buf_ptr = 0; Put4byteNum(out_buf_ptr0); write_len = write ( slave_sock, _out_buf, out_buf_ptr0 + 4 ); #ifdef SERVER_STATS_FLAG Rename_cycleReadWriteLenThis += write_len; #endif if ( write_len != out_buf_ptr0 + 4 ) { printf ( "\n Rename_WRITE :write error\n `write' returned %d not %d\n", write_len, out_buf_ptr0 ); * _rep = FALSE; } else { * _rep = TRUE; } _out_buf_ptr = 4; #ifdef TEST_FLAG { int n; printf ( "Rename_WRITE (%d including 1st four length bytes):\n `", write_len ); for ( n = 0 ; n < write_len ; n++ ) { printf ( "%3d ", ( unsigned char ) _out_buf [ n ] ); } printf ( "'\n" ); } #endif /*** check _in_buf_size/_out_buf_size are default ***/ if ( _in_buf_size != Rename_SharedSocketServerP2 ) { #ifdef TEST_FLAG printf ( "Rename_WRITE: _in_buf realloc (%d -> %d)\n", _in_buf_size, Rename_SharedSocketServerP2 ); #endif doInRealloc ( Rename_SharedSocketServerP2, "Rename_WRITE" ); } if ( _out_buf_size != Rename_SharedSocketServerP3 ) { #ifdef TEST_FLAG printf ( "Rename_WRITE: _out_buf realloc (%d -> %d)\n", _out_buf_size, Rename_SharedSocketServerP3 ); #endif doOutRealloc ( Rename_SharedSocketServerP3, "Rename_WRITE" ); } }
void Rename_PUT_FILE ( int * _rep, void * _filename ) { struct stat stat_buf; FILE * filename_ptr; int c; * _rep = FALSE; if ( stat ( ( char * ) _filename, & stat_buf ) != 0 ) { printf ( "\n Rename_PUT_FILE: %s does not exist\"r\" - errno %d\n", ( char * ) _filename, errno ); return; } if ( ( filename_ptr = fopen ( ( char * ) _filename, "r" ) ) == NULL ) { printf ( "\n Rename_PUT_FILE: unable to fopen %s \"r\" - errno %d\n", ( char * ) _filename, errno ); return; } /*** perform realloc if necessary ***/ if ( _out_buf_ptr + stat_buf.st_size + 4 >= _out_buf_size ) { #ifdef TEST_FLAG printf ( "Rename_PUT_FILE: _out_buf realloc (%d -> %d)\n", _out_buf_size, _out_buf_ptr + stat_buf.st_size + 4 + 100 ); #endif doOutRealloc ( _out_buf_ptr + stat_buf.st_size + 4 + 100, "Rename_PUT_FILE" ); } Put4byteNum ( stat_buf.st_size ); _out_buf_ptr += 4; c = getc ( filename_ptr ); while ( c != EOF ) { _out_buf [ _out_buf_ptr++ ] = ( unsigned char ) c; c = getc ( filename_ptr ); } if ( ( fclose ( filename_ptr ) ) ) { printf ( "\n Rename_PUT_FILE: fclose failed - errno %d\n", errno ); return; } * _rep = TRUE; }
void Rename_WRITE ( int * _rep ) { int write_len; int out_buf_ptr0 = _out_buf_ptr - 4; _out_buf_ptr = 0; Put4byteNum(out_buf_ptr0); write_len = write ( slave_sock, _out_buf, out_buf_ptr0 + 4 ); if ( write_len != out_buf_ptr0 + 4 ) { printf ( "\n Rename_WRITE: write error\n `write' returned %d not %d\n", write_len, out_buf_ptr0 ); * _rep = FALSE; } else { * _rep = TRUE; } _out_buf_ptr = 4; #ifdef TEST_FLAG { int n; printf ( "Rename_WRITE (%d including 1st four length bytes):\n `", write_len ); for ( n = 0 ; n < write_len ; n++ ) { printf ( "%3d ", ( unsigned char ) _out_buf [ n ] ); } printf ( "'\n `" ); } #endif /*** check _in_buf_size/_out_buf_size are default ***/ if ( _in_buf_size != Rename_SocketClientP2 ) { #ifdef TEST_FLAG printf ( "Rename_WRITE: _in_buf realloc (%d -> %d)\n", _in_buf_size, Rename_SocketClientP2 ); #endif doInRealloc ( Rename_SocketClientP2, "Rename_WRITE" ); } if ( _out_buf_size != Rename_SocketClientP3 ) { #ifdef TEST_FLAG printf ( "Rename_WRITE: _out_buf realloc (%d -> %d)\n", _out_buf_size, Rename_SocketClientP3 ); #endif doOutRealloc ( Rename_SocketClientP3, "Rename_WRITE" ); } }
void Rename_PUT_TOK ( int _tok, int _toksize ) { if ( ( _out_buf_ptr + _toksize ) <= Rename_SocketClientP3 ) { switch ( _toksize ) { case 1: Put1byteNum ( _tok ); break; case 2: Put2byteNum ( _tok ); break; case 3: Put3byteNum ( _tok ); break; case 4: Put4byteNum ( _tok ); break; } _out_buf_ptr += _toksize; } }