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 } svn_node_kind_t; 00091 00092 /** About Special Files in Subversion 00093 * 00094 * Subversion denotes files that cannot be portably created or 00095 * modified as special files (svn_node_special). It stores these 00096 * files in the repository as a plain text file with the svn:special 00097 * property set. The file contents contain: a platform-specific type 00098 * string, a space character, then any information necessary to create 00099 * the file on a supported platform. For example, if a symbolic link 00100 * were being represented, the repository file would have the 00101 * following contents: 00102 * 00103 * "link /path/to/link/target" 00104 * 00105 * Where 'link' is the identifier string showing that this special 00106 * file should be a symbolic link and '/path/to/link/target' is the 00107 * destination of the symbolic link. 00108 * 00109 * Special files are stored in the text-base exactly as they are 00110 * stored in the repository. The platform specific files are created 00111 * in the working copy at EOL/keyword translation time using 00112 * svn_subst_copy_and_translate2. If the current platform does not 00113 * support a specific special file type, the file is copied into the 00114 * working copy as it is seen in the repository. Because of this, 00115 * users of other platforms can still view and modify the special 00116 * files, even if they do not have their unique properties. 00117 * 00118 * New types of special files can be added by: 00119 * 1. Implementing a platform-dependent routine to create a uniquely 00120 * named special file and one to read the special file in 00121 * libsvn_subr/io.c. 00122 * 2. Creating a new textual name similar to 00123 * SVN_SUBST__SPECIAL_LINK_STR in libsvn_subr/subst.c. 00124 * 3. Handling the translation/detranslation case for the new type in 00125 * create_special_file and detranslate_special_file, using the 00126 * routines from 1. 00127 */ 00128 00129 /** A revision number. */ 00130 typedef long int svn_revnum_t; 00131 00132 /** Valid revision numbers begin at 0 */ 00133 #define SVN_IS_VALID_REVNUM(n) ((n) >= 0) 00134 00135 /** The 'official' invalid revision num */ 00136 #define SVN_INVALID_REVNUM ((svn_revnum_t) -1) 00137 00138 /** Not really invalid...just unimportant -- one day, this can be its 00139 * own unique value, for now, just make it the same as 00140 * @c SVN_INVALID_REVNUM. 00141 */ 00142 #define SVN_IGNORED_REVNUM ((svn_revnum_t) -1) 00143 00144 /** Convert null-terminated C string @a str to a revision number. */ 00145 #define SVN_STR_TO_REV(str) ((svn_revnum_t) atol(str)) 00146 00147 /** In @c printf()-style functions, format revision numbers using this. */ 00148 #define SVN_REVNUM_T_FMT "ld" 00149 00150 00151 /** The size of a file in the Subversion FS. */ 00152 typedef apr_int64_t svn_filesize_t; 00153 00154 /** The 'official' invalid file size constant. */ 00155 #define SVN_INVALID_FILESIZE ((svn_filesize_t) -1) 00156 00157 /** In @c printf()-style functions, format file sizes using this. */ 00158 #define SVN_FILESIZE_T_FMT APR_INT64_T_FMT 00159 00160 /* Parse a base-10 numeric string into a 64-bit unsigned numeric value. */ 00161 /* NOTE: Private. For use by Subversion's own code only. See issue #1644. */ 00162 /* FIXME: APR should supply a function to do this, such as "apr_atoui64". */ 00163 #define svn__atoui64(X) ((apr_uint64_t) apr_atoi64(X)) 00164 00165 00166 /** YABT: Yet Another Boolean Type */ 00167 typedef int svn_boolean_t; 00168 00169 #ifndef TRUE 00170 /** uhh... true */ 00171 #define TRUE 1 00172 #endif /* TRUE */ 00173 00174 #ifndef FALSE 00175 /** uhh... false */ 00176 #define FALSE 0 00177 #endif /* FALSE */ 00178 00179 00180 /** An enum to indicate whether recursion is needed. */ 00181 enum svn_recurse_kind 00182 { 00183 svn_nonrecursive = 1, 00184 svn_recursive 00185 }; 00186 00187 00188 /** A general subversion directory entry. */ 00189 typedef struct svn_dirent_t 00190 { 00191 /** node kind */ 00192 svn_node_kind_t kind; 00193 00194 /** length of file text, or 0 for directories */ 00195 svn_filesize_t size; 00196 00197 /** does the node have props? */ 00198 svn_boolean_t has_props; 00199 00200 /** last rev in which this node changed */ 00201 svn_revnum_t created_rev; 00202 00203 /** time of created_rev (mod-time) */ 00204 apr_time_t time; 00205 00206 /** author of created_rev */ 00207 const char *last_author; 00208 00209 } svn_dirent_t; 00210 00211 00212 00213 00214 /** Keyword substitution. 00215 * 00216 * All the keywords Subversion recognizes. 00217 * 00218 * Note that there is a better, more general proposal out there, which 00219 * would take care of both internationalization issues and custom 00220 * keywords (e.g., $NetBSD$). See 00221 * 00222 *<pre> http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=8921 00223 * ===== 00224 * From: "Jonathan M. Manning" <jmanning@alisa-jon.net> 00225 * To: dev@subversion.tigris.org 00226 * Date: Fri, 14 Dec 2001 11:56:54 -0500 00227 * Message-ID: <87970000.1008349014@bdldevel.bl.bdx.com> 00228 * Subject: Re: keywords</pre> 00229 * 00230 * and Eric Gillespie's support of same: 00231 * 00232 *<pre> http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=8757 00233 * ===== 00234 * From: "Eric Gillespie, Jr." <epg@pretzelnet.org> 00235 * To: dev@subversion.tigris.org 00236 * Date: Wed, 12 Dec 2001 09:48:42 -0500 00237 * Message-ID: <87k7vsebp1.fsf@vger.pretzelnet.org> 00238 * Subject: Re: Customizable Keywords</pre> 00239 * 00240 * However, it is considerably more complex than the scheme below. 00241 * For now we're going with simplicity, hopefully the more general 00242 * solution can be done post-1.0. 00243 * 00244 * @defgroup svn_types_keywords keywords 00245 * @{ 00246 */ 00247 00248 /** The maximum size of an expanded or un-expanded keyword. */ 00249 #define SVN_KEYWORD_MAX_LEN 255 00250 00251 /** The most recent revision in which this file was changed. */ 00252 #define SVN_KEYWORD_REVISION_LONG "LastChangedRevision" 00253 00254 /** Short version of LastChangedRevision */ 00255 #define SVN_KEYWORD_REVISION_SHORT "Rev" 00256 00257 /** Medium version of LastChangedRevision, matching the one CVS uses */ 00258 #define SVN_KEYWORD_REVISION_MEDIUM "Revision" 00259 00260 /** The most recent date (repository time) when this file was changed. */ 00261 #define SVN_KEYWORD_DATE_LONG "LastChangedDate" 00262 00263 /** Short version of LastChangedDate */ 00264 #define SVN_KEYWORD_DATE_SHORT "Date" 00265 00266 /** Who most recently committed to this file. */ 00267 #define SVN_KEYWORD_AUTHOR_LONG "LastChangedBy" 00268 00269 /** Short version of LastChangedBy */ 00270 #define SVN_KEYWORD_AUTHOR_SHORT "Author" 00271 00272 /** The URL for the head revision of this file. */ 00273 #define SVN_KEYWORD_URL_LONG "HeadURL" 00274 00275 /** Short version of HeadURL */ 00276 #define SVN_KEYWORD_URL_SHORT "URL" 00277 00278 /** A compressed combination of the other four keywords. 00279 * 00280 * (But see comments above about a more general solution to keyword 00281 * combinations.) 00282 */ 00283 #define SVN_KEYWORD_ID "Id" 00284 00285 /** @} */ 00286 00287 00288 /** A structure to represent a path that changed for a log entry. */ 00289 typedef struct svn_log_changed_path_t 00290 { 00291 /** 'A'dd, 'D'elete, 'R'eplace, 'M'odify */ 00292 char action; 00293 00294 /** Source path of copy (if any). */ 00295 const char *copyfrom_path; 00296 00297 /** Source revision of copy (if any). */ 00298 svn_revnum_t copyfrom_rev; 00299 00300 } svn_log_changed_path_t; 00301 00302 00303 /** The callback invoked by log message loopers, such as 00304 * @c svn_ra_plugin_t.get_log() and @c svn_repos_get_logs(). 00305 * 00306 * This function is invoked once on each log message, in the order 00307 * determined by the caller (see above-mentioned functions). 00308 * 00309 * @a baton, @a revision, @a author, @a date, and @a message are what you 00310 * think they are. Any of @a author, @a date, or @a message may be @c NULL. 00311 * 00312 * If @a date is neither null nor the empty string, it was generated by 00313 * @c svn_time_to_string() and can be converted to @c apr_time_t with 00314 * @c svn_time_from_string(). 00315 * 00316 * If @a changed_paths is non-@c NULL, then it contains as keys every path 00317 * committed in @a revision; the values are (@c svn_log_changed_path_t *) 00318 * structures (see above). 00319 * 00320 * ### The only reason @a changed_paths is not qualified with `const' is 00321 * that we usually want to loop over it, and @c apr_hash_first() doesn't 00322 * take a const hash, for various reasons. I'm not sure that those 00323 * "various reasons" are actually even relevant anymore, and if 00324 * they're not, it might be nice to change @c apr_hash_first() so 00325 * read-only uses of hashes can be protected via the type system. 00326 * 00327 * Use @a pool for all allocation. (If the caller is iterating over log 00328 * messages, invoking this receiver on each, we recommend the standard 00329 * pool loop recipe: create a subpool, pass it as @a pool to each call, 00330 * clear it after each iteration, destroy it after the loop is done.) 00331 */ 00332 typedef svn_error_t *(*svn_log_message_receiver_t) 00333 (void *baton, 00334 apr_hash_t *changed_paths, 00335 svn_revnum_t revision, 00336 const char *author, 00337 const char *date, /* use svn_time_from_string() if need apr_time_t */ 00338 const char *message, 00339 apr_pool_t *pool); 00340 00341 00342 /** Callback function type for commits. 00343 * 00344 * When a commit succeeds, an instance of this is invoked on the @a 00345 * new_revision, @a date, and @a author of the commit, along with the 00346 * @a baton closure. 00347 */ 00348 typedef svn_error_t * (*svn_commit_callback_t) ( 00349 svn_revnum_t new_revision, 00350 const char *date, 00351 const char *author, 00352 void *baton); 00353 00354 00355 /** The maximum amount we (ideally) hold in memory at a time when 00356 * processing a stream of data. 00357 * 00358 * For example, when copying data from one stream to another, do it in 00359 * blocks of this size. 00360 */ 00361 #define SVN_STREAM_CHUNK_SIZE 102400 00362 00363 /** The maximum amount we can ever hold in memory. */ 00364 /* FIXME: Should this be the same as SVN_STREAM_CHUNK_SIZE? */ 00365 #define SVN_MAX_OBJECT_SIZE (((apr_size_t) -1) / 2) 00366 00367 00368 00369 /* ### Note: despite being about mime-TYPES, these probably don't 00370 * ### belong in svn_types.h. However, no other header is more 00371 * ### appropriate, and didn't feel like creating svn_validate.h for 00372 * ### so little. 00373 */ 00374 00375 /** Validate @a mime_type. 00376 * 00377 * If @a mime_type does not contain a "/", or ends with non-alphanumeric 00378 * data, return @c SVN_ERR_BAD_MIME_TYPE, else return success. 00379 * 00380 * Use @a pool only to find error allocation. 00381 * 00382 * Goal: to match both "foo/bar" and "foo/bar; charset=blah", without 00383 * being too strict about it, but to disallow mime types that have 00384 * quotes, newlines, or other garbage on the end, such as might be 00385 * unsafe in an HTTP header. 00386 */ 00387 svn_error_t *svn_mime_type_validate (const char *mime_type, 00388 apr_pool_t *pool); 00389 00390 00391 /** Return false iff @a mime_type is a textual type. 00392 * 00393 * All mime types that start with "text/" are textual, plus some special 00394 * cases (for example, "image/x-xbitmap"). 00395 */ 00396 svn_boolean_t svn_mime_type_is_binary (const char *mime_type); 00397 00398 00399 00400 /** A user defined callback that subversion will call with a user defined 00401 * baton to see if the current operation should be continued. If the operation 00402 * should continue, the function should return @c SVN_NO_ERROR, if not, it 00403 * should return @c SVN_ERR_CANCELLED. 00404 */ 00405 typedef svn_error_t *(*svn_cancel_func_t) (void *cancel_baton); 00406 00407 #ifdef __cplusplus 00408 } 00409 #endif /* __cplusplus */ 00410 00411 #endif /* SVN_TYPES_H */
1.3.5