/* Given a string like "HTTP/1.1 500 (status)" in BUF, parse out the numeric status code into *STATUS_CODE_OUT. Ignores leading whitespace. */ static svn_error_t * parse_status_line(int *status_code_out, const char **reason, const char *status_line, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { svn_error_t *err; const char *token; char *tok_status; svn_stringbuf_t *temp_buf = svn_stringbuf_create(status_line, scratch_pool); svn_stringbuf_strip_whitespace(temp_buf); token = apr_strtok(temp_buf->data, " \t\r\n", &tok_status); if (token) token = apr_strtok(NULL, " \t\r\n", &tok_status); if (!token) return svn_error_createf(SVN_ERR_RA_DAV_MALFORMED_DATA, NULL, _("Malformed DAV:status '%s'"), status_line); err = svn_cstring_atoi(status_code_out, token); if (err) return svn_error_createf(SVN_ERR_RA_DAV_MALFORMED_DATA, err, _("Malformed DAV:status '%s'"), status_line); token = apr_strtok(NULL, " \t\r\n", &tok_status); *reason = apr_pstrdup(result_pool, token); return SVN_NO_ERROR; }
void svn_cl__check_boolean_prop_val(const char *propname, const char *propval, apr_pool_t *pool) { svn_stringbuf_t *propbuf; if (!svn_prop_is_boolean(propname)) return; propbuf = svn_stringbuf_create(propval, pool); svn_stringbuf_strip_whitespace(propbuf); if (propbuf->data[0] == '\0' || svn_cstring_casecmp(propbuf->data, "0") == 0 || svn_cstring_casecmp(propbuf->data, "no") == 0 || svn_cstring_casecmp(propbuf->data, "off") == 0 || svn_cstring_casecmp(propbuf->data, "false") == 0) { svn_error_t *err = svn_error_createf (SVN_ERR_BAD_PROPERTY_VALUE, NULL, _("To turn off the %s property, use 'svn propdel';\n" "setting the property to '%s' will not turn it off."), propname, propval); svn_handle_warning2(stderr, err, "svn: "); svn_error_clear(err); } }
/* Parse *PROP_NAME from HEADER as the part after the INDICATOR line. * Allocate *PROP_NAME in RESULT_POOL. * Set *PROP_NAME to NULL if no valid property name was found. */ static svn_error_t * parse_prop_name(const char **prop_name, const char *header, const char *indicator, apr_pool_t *result_pool) { SVN_ERR(svn_utf_cstring_to_utf8(prop_name, header + strlen(indicator), result_pool)); if (**prop_name == '\0') *prop_name = NULL; else if (! svn_prop_name_is_valid(*prop_name)) { svn_stringbuf_t *buf = svn_stringbuf_create(*prop_name, result_pool); svn_stringbuf_strip_whitespace(buf); *prop_name = (svn_prop_name_is_valid(buf->data) ? buf->data : NULL); } return SVN_NO_ERROR; }
static svn_error_t * test21(const char **msg, svn_boolean_t msg_only, svn_test_opts_t *opts, apr_pool_t *pool) { *msg = "check that whitespace will be stripped correctly"; if (msg_only) return SVN_NO_ERROR; a = svn_stringbuf_create(" \ttest\t\t \t ", pool); b = svn_stringbuf_create("test", pool); svn_stringbuf_strip_whitespace(a); if (svn_stringbuf_compare(a, b) == TRUE) return SVN_NO_ERROR; else return fail(pool, "test failed"); }