Main Page   Modules   Data Structures   File List   Data Fields   Globals  

svn_types.h

Go to the documentation of this file.
00001 /**
00002  * @copyright
00003  * ====================================================================
00004  * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
00005  *
00006  * This software is licensed as described in the file COPYING, which
00007  * you should have received as part of this distribution.  The terms
00008  * are also available at http://subversion.tigris.org/license-1.html.
00009  * If newer versions of this license are posted there, you may use a
00010  * newer version instead, at your option.
00011  *
00012  * This software consists of voluntary contributions made by many
00013  * individuals.  For exact contribution history, see the revision
00014  * history and logs, available at http://subversion.tigris.org/.
00015  * ====================================================================
00016  * @endcopyright
00017  *
00018  * @file svn_types.h
00019  * @brief Subversion's data types
00020  */
00021 
00022 #ifndef SVN_TYPES_H
00023 #define SVN_TYPES_H
00024 
00025 /* ### this should go away, but it causes too much breakage right now */
00026 #include <stdlib.h>
00027 
00028 #include <apr.h>        /* for apr_size_t */
00029 #include <apr_pools.h>
00030 #include <apr_hash.h>
00031 #include <apr_tables.h>
00032 #include <apr_time.h>
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif /* __cplusplus */
00037 
00038 
00039 
00040 /** Subversion error object.
00041  *
00042  * Defined here, rather than in svn_error.h, to avoid a recursive #include 
00043  * situation.
00044  */
00045 typedef struct svn_error_t
00046 {
00047   /** APR error value, possibly SVN_ custom err */
00048   apr_status_t apr_err;
00049 
00050   /** details from producer of error */
00051   const char *message;
00052 
00053   /** ptr to the error we "wrap" */
00054   struct svn_error_t *child;
00055 
00056   /** The pool holding this error and any child errors it wraps */
00057   apr_pool_t *pool;
00058 
00059   /** Source file where the error originated.  Only used iff @c SVN_DEBUG. */
00060   const char *file;
00061 
00062   /** Source line where the error originated.  Only used iff @c SVN_DEBUG. */
00063   long line;
00064 
00065 } svn_error_t;
00066 
00067 
00068 
00069 /** index into an apr_array_header_t */
00070 #define APR_ARRAY_IDX(ary,i,type) (((type *)(ary)->elts)[i])
00071 
00072 /** easier array-pushing syntax */
00073 #define APR_ARRAY_PUSH(ary,type) (*((type *)apr_array_push (ary)))
00074 
00075 
00076 /** The various types of nodes in the Subversion filesystem. */
00077 typedef enum
00078 {
00079   /* absent */
00080   svn_node_none,
00081 
00082   /* regular file */
00083   svn_node_file,
00084 
00085   /* directory */
00086   svn_node_dir,
00087 
00088   /* something's here, but we don't know what */
00089   svn_node_unknown
00090 
00091 } svn_node_kind_t;
00092 
00093 
00094 /** A revision number. */
00095 typedef long int svn_revnum_t;
00096 
00097 /** Valid revision numbers begin at 0 */
00098 #define SVN_IS_VALID_REVNUM(n) ((n) >= 0)
00099 
00100 /** The 'official' invalid revision num */
00101 #define SVN_INVALID_REVNUM ((svn_revnum_t) -1)
00102 
00103 /** Not really invalid...just unimportant -- one day, this can be its
00104  * own unique value, for now, just make it the same as
00105  * @c SVN_INVALID_REVNUM.
00106  */
00107 #define SVN_IGNORED_REVNUM ((svn_revnum_t) -1) 
00108 
00109 /** Convert null-terminated C string @a str to a revision number. */
00110 #define SVN_STR_TO_REV(str) ((svn_revnum_t) atol(str))
00111 
00112 /** In @c printf()-style functions, format revision numbers using this. */
00113 #define SVN_REVNUM_T_FMT "ld"
00114 
00115 
00116 /** The size of a file in the Subversion FS. */
00117 typedef apr_int64_t svn_filesize_t;
00118 
00119 /** The 'official' invalid file size constant. */
00120 #define SVN_INVALID_FILESIZE ((svn_filesize_t) -1)
00121 
00122 /** In @c printf()-style functions, format file sizes using this. */
00123 #define SVN_FILESIZE_T_FMT APR_INT64_T_FMT
00124 
00125 /* Parse a base-10 numeric string into a 64-bit unsigned numeric value. */
00126 /* NOTE: Private. For use by Subversion's own code only. See issue #1644. */
00127 /* FIXME: APR should supply a function to do this, such as "apr_atoui64". */
00128 #define svn__atoui64(X) ((apr_uint64_t) apr_atoi64(X))
00129 
00130 
00131 /** YABT:  Yet Another Boolean Type */
00132 typedef int svn_boolean_t;
00133 
00134 #ifndef TRUE
00135 /** uhh... true */
00136 #define TRUE 1
00137 #endif /* TRUE */
00138 
00139 #ifndef FALSE
00140 /** uhh... false */
00141 #define FALSE 0
00142 #endif /* FALSE */
00143 
00144 
00145 /** An enum to indicate whether recursion is needed. */
00146 enum svn_recurse_kind
00147 {
00148   svn_nonrecursive = 1,
00149   svn_recursive
00150 };
00151 
00152 
00153 /** A general subversion directory entry. */
00154 typedef struct svn_dirent_t
00155 {
00156   /** node kind */
00157   svn_node_kind_t kind;
00158 
00159   /** length of file text, or 0 for directories */
00160   svn_filesize_t size;
00161 
00162   /** does the node have props? */
00163   svn_boolean_t has_props;
00164 
00165   /** last rev in which this node changed */
00166   svn_revnum_t created_rev;
00167 
00168   /** time of created_rev (mod-time) */
00169   apr_time_t time;
00170 
00171   /** author of created_rev */
00172   const char *last_author;
00173 
00174 } svn_dirent_t;
00175 
00176 
00177 
00178 
00179 /** Keyword substitution.
00180  *
00181  * All the keywords Subversion recognizes.
00182  * 
00183  * Note that there is a better, more general proposal out there, which
00184  * would take care of both internationalization issues and custom
00185  * keywords (e.g., $NetBSD$).  See
00186  * 
00187  *<pre>    http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=8921
00188  *    =====
00189  *    From: "Jonathan M. Manning" <jmanning@alisa-jon.net>
00190  *    To: dev@subversion.tigris.org
00191  *    Date: Fri, 14 Dec 2001 11:56:54 -0500
00192  *    Message-ID: <87970000.1008349014@bdldevel.bl.bdx.com>
00193  *    Subject: Re: keywords</pre>
00194  *
00195  * and Eric Gillespie's support of same:
00196  *
00197  *<pre>    http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=8757
00198  *    =====
00199  *    From: "Eric Gillespie, Jr." <epg@pretzelnet.org>
00200  *    To: dev@subversion.tigris.org
00201  *    Date: Wed, 12 Dec 2001 09:48:42 -0500
00202  *    Message-ID: <87k7vsebp1.fsf@vger.pretzelnet.org>
00203  *    Subject: Re: Customizable Keywords</pre>
00204  *
00205  * However, it is considerably more complex than the scheme below.
00206  * For now we're going with simplicity, hopefully the more general
00207  * solution can be done post-1.0.
00208  *
00209  * @defgroup svn_types_keywords keywords
00210  * @{
00211  */
00212 
00213 /** The maximum size of an expanded or un-expanded keyword. */
00214 #define SVN_KEYWORD_MAX_LEN    255
00215 
00216 /** The most recent revision in which this file was changed. */
00217 #define SVN_KEYWORD_REVISION_LONG    "LastChangedRevision"
00218 
00219 /** Short version of LastChangedRevision */
00220 #define SVN_KEYWORD_REVISION_SHORT   "Rev"
00221 
00222 /** The most recent date (repository time) when this file was changed. */
00223 #define SVN_KEYWORD_DATE_LONG        "LastChangedDate"
00224 
00225 /** Short version of LastChangedDate */
00226 #define SVN_KEYWORD_DATE_SHORT       "Date"
00227 
00228 /** Who most recently committed to this file. */
00229 #define SVN_KEYWORD_AUTHOR_LONG      "LastChangedBy"
00230 
00231 /** Short version of LastChangedBy */
00232 #define SVN_KEYWORD_AUTHOR_SHORT     "Author"
00233 
00234 /** The URL for the head revision of this file. */
00235 #define SVN_KEYWORD_URL_LONG         "HeadURL"
00236 
00237 /** Short version of HeadURL */
00238 #define SVN_KEYWORD_URL_SHORT        "URL"
00239 
00240 /** A compressed combination of the other four keywords.
00241  *
00242  * (But see comments above about a more general solution to keyword
00243  * combinations.)
00244  */
00245 #define SVN_KEYWORD_ID               "Id"
00246 
00247 /** @} */
00248 
00249 
00250 /** A structure to represent a path that changed for a log entry. */
00251 typedef struct svn_log_changed_path_t
00252 {
00253   /** 'A'dd, 'D'elete, 'R'eplace, 'M'odify */
00254   char action;
00255 
00256   /** Source path of copy (if any). */
00257   const char *copyfrom_path;
00258 
00259   /** Source revision of copy (if any). */
00260   svn_revnum_t copyfrom_rev;
00261 
00262 } svn_log_changed_path_t;
00263 
00264 
00265 /** The callback invoked by log message loopers, such as
00266  * @c svn_ra_plugin_t.get_log() and @c svn_repos_get_logs().
00267  *
00268  * This function is invoked once on each log message, in the order
00269  * determined by the caller (see above-mentioned functions).
00270  *
00271  * @a baton, @a revision, @a author, @a date, and @a message are what you 
00272  * think they are.  Any of @a author, @a date, or @a message may be @c NULL.
00273  *
00274  * If @a date is neither null nor the empty string, it was generated by
00275  * @c svn_time_to_string() and can be converted to @c apr_time_t with
00276  * @c svn_time_from_string().
00277  *
00278  * If @a changed_paths is non-@c NULL, then it contains as keys every path
00279  * committed in @a revision; the values are (@c svn_log_changed_path_t *) 
00280  * structures (see above).
00281  *
00282  * ### The only reason @a changed_paths is not qualified with `const' is
00283  * that we usually want to loop over it, and @c apr_hash_first() doesn't
00284  * take a const hash, for various reasons.  I'm not sure that those
00285  * "various reasons" are actually even relevant anymore, and if
00286  * they're not, it might be nice to change @c apr_hash_first() so
00287  * read-only uses of hashes can be protected via the type system.
00288  *
00289  * Use @a pool for all allocation.  (If the caller is iterating over log
00290  * messages, invoking this receiver on each, we recommend the standard
00291  * pool loop recipe: create a subpool, pass it as @a pool to each call,
00292  * clear it after each iteration, destroy it after the loop is done.)
00293  */
00294 typedef svn_error_t *(*svn_log_message_receiver_t)
00295      (void *baton,
00296       apr_hash_t *changed_paths,
00297       svn_revnum_t revision,
00298       const char *author,
00299       const char *date,  /* use svn_time_from_string() if need apr_time_t */
00300       const char *message,
00301       apr_pool_t *pool);
00302 
00303 
00304 /** Callback function type for commits.
00305  *
00306  * When a commit succeeds, an instance of this is invoked on the @a
00307  * new_revision, @a date, and @a author of the commit, along with the
00308  * @a baton closure.
00309  */
00310 typedef svn_error_t * (*svn_commit_callback_t) (
00311     svn_revnum_t new_revision,
00312     const char *date,
00313     const char *author,
00314     void *baton);
00315 
00316 
00317 /** The maximum amount we (ideally) hold in memory at a time when
00318  * processing a stream of data.
00319  *
00320  * For example, when copying data from one stream to another, do it in
00321  * blocks of this size; also, the standard size of one svndiff window;
00322  * etc.
00323  */
00324 #define SVN_STREAM_CHUNK_SIZE 102400
00325 
00326 /** The maximum amount we can ever hold in memory. */
00327 /* FIXME: Should this be the same as SVN_STREAM_CHUNK_SIZE? */
00328 #define SVN_MAX_OBJECT_SIZE (((apr_size_t) -1) / 2)
00329 
00330 
00331 
00332 /* ### Note: despite being about mime-TYPES, these probably don't
00333  * ### belong in svn_types.h.  However, no other header is more
00334  * ### appropriate, and didn't feel like creating svn_validate.h for
00335  * ### so little.
00336  */
00337 
00338 /** Validate @a mime_type.
00339  *
00340  * If @a mime_type does not contain a "/", or ends with non-alphanumeric
00341  * data, return @c SVN_ERR_BAD_MIME_TYPE, else return success.
00342  * 
00343  * Use @a pool only to find error allocation.
00344  *
00345  * Goal: to match both "foo/bar" and "foo/bar; charset=blah", without
00346  * being too strict about it, but to disallow mime types that have
00347  * quotes, newlines, or other garbage on the end, such as might be
00348  * unsafe in an HTTP header.
00349  */
00350 svn_error_t *svn_mime_type_validate (const char *mime_type,
00351                                      apr_pool_t *pool);
00352 
00353 
00354 /** Return false iff @a mime_type is a textual type.
00355  *
00356  * All mime types that start with "text/" are textual, plus some special 
00357  * cases (for example, "image/x-xbitmap").
00358  */
00359 svn_boolean_t svn_mime_type_is_binary (const char *mime_type);
00360 
00361 
00362 
00363 /** A user defined callback that subversion will call with a user defined 
00364  * baton to see if the current operation should be continued.  If the operation 
00365  * should continue, the function should return @c SVN_NO_ERROR, if not, it 
00366  * should return @c SVN_ERR_CANCELLED.
00367  */
00368 typedef svn_error_t *(*svn_cancel_func_t) (void *cancel_baton);
00369 
00370 #ifdef __cplusplus
00371 }
00372 #endif /* __cplusplus */
00373 
00374 #endif /* SVN_TYPES_H */

Generated on Wed Oct 20 01:47:45 2004 for Subversion by doxygen1.2.18