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_private_config.h"
27 svn_revnum_parse(svn_revnum_t
*rev
,
33 svn_revnum_t result
= strtol(str
, &end
, 10);
39 return svn_error_createf(SVN_ERR_REVNUM_PARSE_FAILURE
, NULL
,
40 _("Invalid revision number found parsing '%s'"),
45 /* The end pointer from strtol() is valid, but a negative revision
46 number is invalid, so move the end pointer back to the
47 beginning of the string. */
51 return svn_error_createf(SVN_ERR_REVNUM_PARSE_FAILURE
, NULL
,
52 _("Negative revision number found parsing '%s'"),
62 svn_uuid_generate(apr_pool_t
*pool
)
65 char *uuid_str
= apr_pcalloc(pool
, APR_UUID_FORMATTED_LENGTH
+ 1);
67 apr_uuid_format(uuid_str
, &uuid
);
72 svn_depth_to_word(svn_depth_t depth
)
76 case svn_depth_exclude
:
78 case svn_depth_unknown
:
84 case svn_depth_immediates
:
86 case svn_depth_infinity
:
89 return "INVALID-DEPTH";
95 svn_depth_from_word(const char *word
)
97 if (strcmp(word
, "exclude") == 0)
98 return svn_depth_exclude
;
99 if (strcmp(word
, "unknown") == 0)
100 return svn_depth_unknown
;
101 if (strcmp(word
, "empty") == 0)
102 return svn_depth_empty
;
103 if (strcmp(word
, "files") == 0)
104 return svn_depth_files
;
105 if (strcmp(word
, "immediates") == 0)
106 return svn_depth_immediates
;
107 if (strcmp(word
, "infinity") == 0)
108 return svn_depth_infinity
;
109 /* There's no special value for invalid depth, and no convincing
110 reason to make one yet, so just fall back to unknown depth.
111 If you ever change that convention, check callers to make sure
112 they're not depending on it (e.g., option parsing in main() ).
114 return svn_depth_unknown
;
118 svn_inheritance_to_word(svn_mergeinfo_inheritance_t inherit
)
122 case svn_mergeinfo_inherited
:
124 case svn_mergeinfo_nearest_ancestor
:
125 return "nearest-ancestor";
132 svn_mergeinfo_inheritance_t
133 svn_inheritance_from_word(const char *word
)
135 if (strcmp(word
, "inherited") == 0)
136 return svn_mergeinfo_inherited
;
137 if (strcmp(word
, "nearest-ancestor") == 0)
138 return svn_mergeinfo_nearest_ancestor
;
139 return svn_mergeinfo_explicit
;