/*============================================================================== Copyright (C) 2007 Martin Furter This file is part of svntar svntar is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. svntar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with svntar; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ==============================================================================*/ #ifndef SVN_TAR_H #define SVN_TAR_H #include "svn_io.h" #include "svn_pools.h" #ifndef _ #define _(x) x #endif #define SVN_TAR_LINKDEST_LENGTH 100 /** * Callback for reporting nodes added to the tar. * * @param baton Baton. * @param type Node type added. * @param name Name of the node added. * @param pool The APR pool to use for allocations. * @return An @a svn_error_t on error, else @c NULL. */ typedef svn_error_t* (*svn_tar_add_fn_t)( void* baton, char type, const char* name, apr_pool_t* pool ); /** * Opaque tar structure. */ typedef struct svn_tar_t svn_tar_t; /** * Creates a new tar structure. * * @param tar Pointer for returning the tar structure. * @param pool The APR pool to use for allocations. * @return An @a svn_error_t on error, else @c NULL. */ svn_error_t* svn_tar_create( svn_tar_t** tar, apr_pool_t* pool ); /** * Close the tar file. * * @param tar A tar structure. * @return An @a svn_error_t on error, else @c NULL. */ svn_error_t* svn_tar_close( svn_tar_t* tar ); /** * Set the 'add' callback. * * @param tar A tar structure. * @param add_fn * @param add_baton */ void svn_tar_set_add_callback( svn_tar_t* tar, svn_tar_add_fn_t add_fn, void* add_baton ); /** * Set the tar output stream. * * @param tar A tar structure. * @param output */ void svn_tar_set_output( svn_tar_t* tar, svn_stream_t* output ); /** * Set prefix for filenames added. * * @param tar A tar structure. * @param prefix Filename prefix. * @param pool The APR pool to use for allocations. */ void svn_tar_set_prefix( svn_tar_t* tar, const char* prefix, apr_pool_t* pool ); /** * Set the user id to use. * * @param tar A tar structure. * @param user_id ID of the user. */ void svn_tar_set_user_id( svn_tar_t* tar, unsigned short user_id ); /** * Set the user name to use. * * @param tar A tar structure. * @param user_name Name of the user. * @return An @a svn_error_t on error, else @c NULL. */ svn_error_t* svn_tar_set_user_name( svn_tar_t* tar, const char* user_name ); /** * Set the group id to use. * * @param tar A tar structure. * @param group_id ID of the group. */ void svn_tar_set_group_id( svn_tar_t* tar, unsigned short group_id ); /** * Set the group name to use. * * @param tar A tar structure. * @param group_name Name of the group. * @return An @a svn_error_t on error, else @c NULL. */ svn_error_t* svn_tar_set_group_name( svn_tar_t* tar, const char* group_name ); /** * Set the modification time for the files. * * @param tar A tar structure. * @param mtime The mtime. */ void svn_tar_set_mtime( svn_tar_t* tar, int mtime ); /** * Add a directory. * * @param name Name of the directory to add. * @param tar A tar structure. * @param pool The APR pool to use for allocations. * @return An @a svn_error_t on error, else @c NULL. */ svn_error_t* svn_tar_add_dir( const char* name, svn_tar_t* tar, apr_pool_t* pool ); #if 0 /* unused functions */ /** * Add a file. * * @param filestream Pointer to return a stream. * @param name Name of the file to add. * @param size Size of the file. * @param executable @a TRUE if the file is executable. * @param tar A tar structure. * @param pool The APR pool to use for allocations. * @return An @a svn_error_t on error, else @c NULL. */ svn_error_t* svn_tar_add_file_stream( svn_stream_t** filestream, const char* name, unsigned int size, svn_boolean_t executable, svn_tar_t* tar, apr_pool_t* pool ); /** * Add a file from the filesystem to the tar. * * @param name Name of the file or link to add. * @param filename Path to the file. * @param ignore_missing If @a TRUE ignore the file if it is missing. * @param tar A tar structure. * @param pool The APR pool to use for allocations. * @return An @a svn_error_t on error, else @c NULL. */ svn_error_t* svn_tar_add_file( const char* name, const char* filename, svn_boolean_t ignore_missing, svn_tar_t* tar, apr_pool_t* pool ); /** * Add a link to the tar. * * @param name Name of the link to add. * @param link_target Target of the link. * @param tar A tar structure. * @param pool The APR pool to use for allocations. * @return An @a svn_error_t on error, else @c NULL. */ svn_error_t* svn_tar_add_link( const char* name, const char* link_target, svn_tar_t* tar, apr_pool_t* pool ); #ifndef WIN32 /** * Add a file or link from the filesystem to the tar. * * @param name Name of the file or link to add. * @param filename Path to the file. * @param ignore_missing If @a TRUE ignore the file if it is missing. * @param tar A tar structure. * @param pool The APR pool to use for allocations. * @return An @a svn_error_t on error, else @c NULL. */ svn_error_t* svn_tar_add_file_or_link( const char* name, const char* filename, svn_boolean_t ignore_missing, svn_tar_t* tar, apr_pool_t* pool ); #endif /* !WIN32 */ #endif /* unused functions */ /** * Called by @a svn_tar_add to get properties for the node to add. * * @param name Name of the property. * @param value Pointer to return the value of the property. * @param baton Property callback baton given to @a svn_tar_add. * @param pool The APR pool to use for allocations. * @return An @a svn_error_t on error, else @c NULL. */ typedef svn_error_t* (*svn_tar_propget_callback_t)( const char* name, const char** value, void* baton, apr_pool_t* pool ); /** * Called by @a svn_tar_add to provide a file stream. * * @param filestream Stream to write the file to. * @param baton Filestream callback baton given to @a svn_tar_add. * @param pool The APR pool to use for allocations. * @return An @a svn_error_t on error, else @c NULL. */ typedef svn_error_t* (*svn_tar_file_stream_callback_t)( svn_stream_t* filestream, void* baton, apr_pool_t* pool ); /** * Add a node to the tar file. * * @param name Name of the node to add. * @param kind Kind of the node to add. * @param size Size of the file. * @param propget_cb Property callback. * @param propget_baton Property callback baton. * @param filestream_cb Filestream callback. * @param filestream_baton Filestream callback baton. * @param tar A tar structure. * @param pool The APR pool to use for allocations. * @return An @a svn_error_t on error, else @c NULL. */ svn_error_t* svn_tar_add( const char* name, svn_node_kind_t kind, int size, svn_tar_propget_callback_t propget_cb, void* propget_baton, svn_tar_file_stream_callback_t filestream_cb, void* filestream_baton, svn_tar_t* tar, apr_pool_t* pool ); #endif /* SVN_TAR_H */