2
* kitchensink.c : When no place else seems to fit...
4
* ====================================================================
5
* Licensed to the Apache Software Foundation (ASF) under one
6
* or more contributor license agreements. See the NOTICE file
7
* distributed with this work for additional information
8
* regarding copyright ownership. The ASF licenses this file
9
* to you under the Apache License, Version 2.0 (the
10
* "License"); you may not use this file except in compliance
11
* with the License. You may obtain a copy of the License at
13
* http://www.apache.org/licenses/LICENSE-2.0
15
* Unless required by applicable law or agreed to in writing,
16
* software distributed under the License is distributed on an
17
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18
* KIND, either express or implied. See the License for the
19
* specific language governing permissions and limitations
21
* ====================================================================
24
#include <apr_pools.h>
27
#include "svn_types.h"
28
#include "svn_error.h"
29
#include "svn_mergeinfo.h"
30
#include "svn_private_config.h"
33
svn_revnum_parse(svn_revnum_t *rev,
39
svn_revnum_t result = strtol(str, &end, 10);
45
return svn_error_createf(SVN_ERR_REVNUM_PARSE_FAILURE, NULL,
46
_("Invalid revision number found parsing '%s'"),
51
/* The end pointer from strtol() is valid, but a negative revision
52
number is invalid, so move the end pointer back to the
53
beginning of the string. */
57
return svn_error_createf(SVN_ERR_REVNUM_PARSE_FAILURE, NULL,
58
_("Negative revision number found parsing '%s'"),
68
svn_uuid_generate(apr_pool_t *pool)
71
char *uuid_str = apr_pcalloc(pool, APR_UUID_FORMATTED_LENGTH + 1);
73
apr_uuid_format(uuid_str, &uuid);
78
svn_depth_to_word(svn_depth_t depth)
82
case svn_depth_exclude:
84
case svn_depth_unknown:
90
case svn_depth_immediates:
92
case svn_depth_infinity:
95
return "INVALID-DEPTH";
101
svn_depth_from_word(const char *word)
103
if (strcmp(word, "exclude") == 0)
104
return svn_depth_exclude;
105
if (strcmp(word, "unknown") == 0)
106
return svn_depth_unknown;
107
if (strcmp(word, "empty") == 0)
108
return svn_depth_empty;
109
if (strcmp(word, "files") == 0)
110
return svn_depth_files;
111
if (strcmp(word, "immediates") == 0)
112
return svn_depth_immediates;
113
if (strcmp(word, "infinity") == 0)
114
return svn_depth_infinity;
115
/* There's no special value for invalid depth, and no convincing
116
reason to make one yet, so just fall back to unknown depth.
117
If you ever change that convention, check callers to make sure
118
they're not depending on it (e.g., option parsing in main() ).
120
return svn_depth_unknown;
124
svn_inheritance_to_word(svn_mergeinfo_inheritance_t inherit)
128
case svn_mergeinfo_inherited:
130
case svn_mergeinfo_nearest_ancestor:
131
return "nearest-ancestor";
138
svn_mergeinfo_inheritance_t
139
svn_inheritance_from_word(const char *word)
141
if (strcmp(word, "inherited") == 0)
142
return svn_mergeinfo_inherited;
143
if (strcmp(word, "nearest-ancestor") == 0)
144
return svn_mergeinfo_nearest_ancestor;
145
return svn_mergeinfo_explicit;
149
svn_node_kind_to_word(svn_node_kind_t kind)
159
case svn_node_unknown:
167
svn_node_kind_from_word(const char *word)
170
return svn_node_unknown;
172
if (strcmp(word, "none") == 0)
173
return svn_node_none;
174
else if (strcmp(word, "file") == 0)
175
return svn_node_file;
176
else if (strcmp(word, "dir") == 0)
179
/* This also handles word == "unknown" */
180
return svn_node_unknown;
184
svn_tristate__to_word(svn_tristate_t tristate)
188
case svn_tristate_false:
190
case svn_tristate_true:
192
case svn_tristate_unknown:
199
svn_tristate__from_word(const char *word)
202
return svn_tristate_unknown;
203
else if (0 == svn_cstring_casecmp(word, "true")
204
|| 0 == svn_cstring_casecmp(word, "yes")
205
|| 0 == svn_cstring_casecmp(word, "on")
206
|| 0 == strcmp(word, "1"))
207
return svn_tristate_true;
208
else if (0 == svn_cstring_casecmp(word, "false")
209
|| 0 == svn_cstring_casecmp(word, "no")
210
|| 0 == svn_cstring_casecmp(word, "off")
211
|| 0 == strcmp(word, "0"))
212
return svn_tristate_false;
214
return svn_tristate_unknown;