HTTP_Request *parse_HTTP_Request(HTTP_Request *request) { String *line; File *socket = open_File_from_file_descriptor(request->client.socket); /* parse startline */ line = read_File_next_line(socket); line->length --; /* remove \r */ parse_HTTP_Request_startline(request, line); if (request->target == NULL) { puts("Null target!"); } free_String(line); free_File(socket); return request; }
int File_copyTo( const IFile* self, const IPath* targetPath, int force ) { bool status = 0; char* target = NULL; IFile* target_file = NULL; IDirectory* target_dir = new_Directory_path( targetPath ); if ( Directory_exists( target_dir ) ) { target = CharString_cat3( Path_getCommon( targetPath ), "/", Path_getBasename( self->path ) ); } else { target = CharString_copy( Path_getCommon( targetPath ) ); } target_file = new_File( target ); if ( !File_exists( target_file ) || force ) { if ( File_open( target_file, "w" ) ) { byte buffer[256]; int read; while ( (read = File_read( self, buffer, 256 )) ) { File_write( target_file, buffer, read ); status = 1; } if ( !status ) { fprintf( stdout, "File.c::copyTo: could not copy data\n" ); } } File_close( target_file ); } free_Directory( target_dir ); free_File( target_file ); free_CharString( target ); return status; }