Fix compiler warning due to missing function prototype.
[svn.git] / subversion / svn / cat-cmd.c
blob708c2d661f7abd8ee206ed816e57625cb19d4bb6
1 /*
2 * cat-cmd.c -- Print the content of a file or URL.
4 * ====================================================================
5 * Copyright (c) 2000-2004 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 /* ==================================================================== */
23 /*** Includes. ***/
25 #include "svn_pools.h"
26 #include "svn_client.h"
27 #include "svn_error.h"
28 #include "cl.h"
31 /*** Code. ***/
33 /* This implements the `svn_opt_subcommand_t' interface. */
34 svn_error_t *
35 svn_cl__cat(apr_getopt_t *os,
36 void *baton,
37 apr_pool_t *pool)
39 svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
40 svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
41 apr_array_header_t *targets;
42 int i;
43 svn_stream_t *out;
44 apr_pool_t *subpool = svn_pool_create(pool);
46 SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
47 opt_state->targets,
48 ctx, pool));
50 /* Cat cannot operate on an implicit '.' so a filename is required */
51 if (! targets->nelts)
52 return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
54 SVN_ERR(svn_stream_for_stdout(&out, pool));
56 for (i = 0; i < targets->nelts; i++)
58 const char *target = APR_ARRAY_IDX(targets, i, const char *);
59 const char *truepath;
60 svn_opt_revision_t peg_revision;
62 svn_pool_clear(subpool);
63 SVN_ERR(svn_cl__check_cancel(ctx->cancel_baton));
65 /* Get peg revisions. */
66 SVN_ERR(svn_opt_parse_path(&peg_revision, &truepath, target,
67 subpool));
69 SVN_ERR(svn_cl__try(svn_client_cat2(out, truepath, &peg_revision,
70 &(opt_state->start_revision),
71 ctx, subpool),
72 NULL, opt_state->quiet,
73 SVN_ERR_UNVERSIONED_RESOURCE,
74 SVN_ERR_ENTRY_NOT_FOUND,
75 SVN_ERR_CLIENT_IS_DIRECTORY,
76 SVN_NO_ERROR));
78 svn_pool_destroy(subpool);
80 return SVN_NO_ERROR;