2 * kitchensink.c : When no place else seems to fit...
4 * ====================================================================
5 * Copyright (c) 2006-2007 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 #include <apr_pools.h>
22 #include "svn_types.h"
23 #include "svn_error.h"
24 #include "svn_mergeinfo.h"
25 #include "svn_private_config.h"
28 svn_revnum_parse(svn_revnum_t
*rev
,
34 svn_revnum_t result
= strtol(str
, &end
, 10);
40 return svn_error_createf(SVN_ERR_REVNUM_PARSE_FAILURE
, NULL
,
41 _("Invalid revision number found parsing '%s'"),
46 /* The end pointer from strtol() is valid, but a negative revision
47 number is invalid, so move the end pointer back to the
48 beginning of the string. */
52 return svn_error_createf(SVN_ERR_REVNUM_PARSE_FAILURE
, NULL
,
53 _("Negative revision number found parsing '%s'"),
63 svn_uuid_generate(apr_pool_t
*pool
)
66 char *uuid_str
= apr_pcalloc(pool
, APR_UUID_FORMATTED_LENGTH
+ 1);
68 apr_uuid_format(uuid_str
, &uuid
);
73 svn_depth_to_word(svn_depth_t depth
)
77 case svn_depth_exclude
:
79 case svn_depth_unknown
:
85 case svn_depth_immediates
:
87 case svn_depth_infinity
:
90 return "INVALID-DEPTH";
96 svn_depth_from_word(const char *word
)
98 if (strcmp(word
, "exclude") == 0)
99 return svn_depth_exclude
;
100 if (strcmp(word
, "unknown") == 0)
101 return svn_depth_unknown
;
102 if (strcmp(word
, "empty") == 0)
103 return svn_depth_empty
;
104 if (strcmp(word
, "files") == 0)
105 return svn_depth_files
;
106 if (strcmp(word
, "immediates") == 0)
107 return svn_depth_immediates
;
108 if (strcmp(word
, "infinity") == 0)
109 return svn_depth_infinity
;
110 /* There's no special value for invalid depth, and no convincing
111 reason to make one yet, so just fall back to unknown depth.
112 If you ever change that convention, check callers to make sure
113 they're not depending on it (e.g., option parsing in main() ).
115 return svn_depth_unknown
;
119 svn_inheritance_to_word(svn_mergeinfo_inheritance_t inherit
)
123 case svn_mergeinfo_inherited
:
125 case svn_mergeinfo_nearest_ancestor
:
126 return "nearest-ancestor";
133 svn_mergeinfo_inheritance_t
134 svn_inheritance_from_word(const char *word
)
136 if (strcmp(word
, "inherited") == 0)
137 return svn_mergeinfo_inherited
;
138 if (strcmp(word
, "nearest-ancestor") == 0)
139 return svn_mergeinfo_nearest_ancestor
;
140 return svn_mergeinfo_explicit
;