[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1050061 - in /subversion/trunk/subversion: include/svn_io.h libsvn_subr/deprecated.c libsvn_subr/io.c

From: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: Sat, 18 Dec 2010 07:05:51 -0600

On Thu, Dec 16, 2010 at 11:18 AM, <cmpilato_at_apache.org> wrote:
> Author: cmpilato
> Date: Thu Dec 16 17:18:43 2010
> New Revision: 1050061
>
> URL: http://svn.apache.org/viewvc?rev=1050061&view=rev
> Log:
> Rev the svn_io_start_cmd() API, adding pipe support.
>
> * subversion/libsvn_subr/io.c
>  (svn_io_start_cmd2): New revision of svn_io_start_cmd(), adding
>    booleans to indicate where pipes should be used instead of file
>    handles.
>  (svn_io_start_cmd): Moved to deprecated.c.
>
> * subversion/libsvn_subr/deprecated.c
>  (svn_io_start_cmd): Moved here from io.c, and reduced to a mere
>    wrapper around svn_io_start_cmd2().
>
> * subversion/include/svn_io.h
>  (svn_io_start_cmd2): New revision of svn_io_start_cmd2().
>  (svn_io_start_cmd): Deprecate this function.
>
> Patch by:  Martin Furter <mf_at_rola.ch>
>           (Tweaked by cmpilato.)
>
> Modified:
>    subversion/trunk/subversion/include/svn_io.h
>    subversion/trunk/subversion/libsvn_subr/deprecated.c
>    subversion/trunk/subversion/libsvn_subr/io.c
>
> Modified: subversion/trunk/subversion/include/svn_io.h
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_io.h?rev=1050061&r1=1050060&r2=1050061&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/include/svn_io.h (original)
> +++ subversion/trunk/subversion/include/svn_io.h Thu Dec 16 17:18:43 2010
> @@ -1484,9 +1484,17 @@ svn_io_dir_walk(const char *dirname,
>
>  /**
>  * Start @a cmd with @a args, using utf8-encoded @a path as working
> - * directory.  Connect @a cmd's stdin, stdout, and stderr to @a infile,
> - * @a outfile, and @a errfile, except where they are NULL.  Return the
> - * process handle for the invoked program in @a *cmd_proc.
> + * directory.  Return the process handle for the invoked program in @a
> + * *cmd_proc.
> + *
> + * If @a infile_pipe is TRUE, connect @a cmd's stdin to a pipe;
> + * otherwise, connect it to @a infile (which may be NULL).  If
> + * @a outfile_pipe is TRUE, connect @a cmd's stdout to a pipe; otherwise,
> + * connect it to @a outfile (which may be NULL).  If @a errfile_pipe
> + * is TRUE, connect @a cmd's stderr to a pipe; otherwise, connect it
> + * to @a errfile (which may be NULL).  (Callers must pass FALSE for
> + * each of these boolean values for which the corresponding file
> + * handle is non-NULL.)

Innocent bystander question: if the *file_pipe arg is always FALSE
when the *file arg is non-NULL, is it always TRUE if the *file arg is
NULL? If so, can we use the NULL as the use-a-pipe sentinel, rather
than a separate arg?

>  *
>  * @a args is a list of utf8-encoded <tt>const char *</tt> arguments,
>  * terminated by @c NULL.  @a args[0] is the name of the program, though it
> @@ -1501,8 +1509,29 @@ svn_io_dir_walk(const char *dirname,
>  * will result in error output being written to @a errfile, if non-NULL, and
>  * a non-zero exit status being returned to the parent process.
>  *
> + * @since New in 1.7.
> + */
> +svn_error_t *svn_io_start_cmd2(apr_proc_t *cmd_proc,
> +                               const char *path,
> +                               const char *cmd,
> +                               const char *const *args,
> +                               svn_boolean_t inherit,
> +                               svn_boolean_t infile_pipe,
> +                               apr_file_t *infile,
> +                               svn_boolean_t outfile_pipe,
> +                               apr_file_t *outfile,
> +                               svn_boolean_t errfile_pipe,
> +                               apr_file_t *errfile,
> +                               apr_pool_t *pool);
> +
> +/**
> + * Similar to svn_io_start_cmd2() but with @a infile_pipe, @a
> + * outfile_pipe, and @a errfile_pipe always FALSE.
> + *
> + * @deprecated Provided for backward compatibility with the 1.6 API
>  * @since New in 1.3.
>  */
> +SVN_DEPRECATED
>  svn_error_t *
>  svn_io_start_cmd(apr_proc_t *cmd_proc,
>                  const char *path,
>
> Modified: subversion/trunk/subversion/libsvn_subr/deprecated.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/deprecated.c?rev=1050061&r1=1050060&r2=1050061&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_subr/deprecated.c (original)
> +++ subversion/trunk/subversion/libsvn_subr/deprecated.c Thu Dec 16 17:18:43 2010
> @@ -754,6 +754,22 @@ svn_io_get_dirents(apr_hash_t **dirents,
>   return svn_io_get_dirents2(dirents, path, pool);
>  }
>
> +svn_error_t *
> +svn_io_start_cmd(apr_proc_t *cmd_proc,
> +                 const char *path,
> +                 const char *cmd,
> +                 const char *const *args,
> +                 svn_boolean_t inherit,
> +                 apr_file_t *infile,
> +                 apr_file_t *outfile,
> +                 apr_file_t *errfile,
> +                 apr_pool_t *pool)
> +{
> +  return svn_io_start_cmd2(cmd_proc, path, cmd, args, inherit, FALSE,
> +                           infile, FALSE, outfile, FALSE, errfile, pool);
> +}
> +
> +
>  struct walk_func_filter_baton_t
>  {
>   svn_io_walk_func_t walk_func;
>
> Modified: subversion/trunk/subversion/libsvn_subr/io.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1050061&r1=1050060&r2=1050061&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_subr/io.c (original)
> +++ subversion/trunk/subversion/libsvn_subr/io.c Thu Dec 16 17:18:43 2010
> @@ -2188,15 +2188,18 @@ handle_child_process_error(apr_pool_t *p
>
>
>  svn_error_t *
> -svn_io_start_cmd(apr_proc_t *cmd_proc,
> -                 const char *path,
> -                 const char *cmd,
> -                 const char *const *args,
> -                 svn_boolean_t inherit,
> -                 apr_file_t *infile,
> -                 apr_file_t *outfile,
> -                 apr_file_t *errfile,
> -                 apr_pool_t *pool)
> +svn_io_start_cmd2(apr_proc_t *cmd_proc,
> +                  const char *path,
> +                  const char *cmd,
> +                  const char *const *args,
> +                  svn_boolean_t inherit,
> +                  svn_boolean_t infile_pipe,
> +                  apr_file_t *infile,
> +                  svn_boolean_t outfile_pipe,
> +                  apr_file_t *outfile,
> +                  svn_boolean_t errfile_pipe,
> +                  apr_file_t *errfile,
> +                  apr_pool_t *pool)
>  {
>   apr_status_t apr_err;
>   apr_procattr_t *cmdproc_attr;
> @@ -2204,6 +2207,10 @@ svn_io_start_cmd(apr_proc_t *cmd_proc,
>   const char **args_native;
>   const char *cmd_apr;
>
> +  SVN_ERR_ASSERT(!((infile != NULL) && infile_pipe));
> +  SVN_ERR_ASSERT(!((outfile != NULL) && outfile_pipe));
> +  SVN_ERR_ASSERT(!((errfile != NULL) && errfile_pipe));
> +
>   /* Create the process attributes. */
>   apr_err = apr_procattr_create(&cmdproc_attr, pool);
>   if (apr_err)
> @@ -2212,7 +2219,7 @@ svn_io_start_cmd(apr_proc_t *cmd_proc,
>
>   /* Make sure we invoke cmd directly, not through a shell. */
>   apr_err = apr_procattr_cmdtype_set(cmdproc_attr,
> -                                     inherit?APR_PROGRAM_PATH:APR_PROGRAM);
> +                                     inherit ? APR_PROGRAM_PATH : APR_PROGRAM);
>   if (apr_err)
>     return svn_error_wrap_apr(apr_err, _("Can't set process '%s' cmdtype"),
>                               cmd);
> @@ -2256,6 +2263,13 @@ svn_io_start_cmd(apr_proc_t *cmd_proc,
>           (apr_err, _("Can't set process '%s' child errfile"), cmd);
>     }
>
> +  /* Forward request for pipes to APR. */
> +  if (infile_pipe || outfile_pipe || errfile_pipe)
> +    apr_procattr_io_set(cmdproc_attr,
> +                        infile_pipe ? APR_FULL_BLOCK : APR_NO_PIPE,
> +                        outfile_pipe ? APR_FULL_BLOCK : APR_NO_PIPE,
> +                        errfile_pipe ? APR_FULL_BLOCK : APR_NO_PIPE);
> +
>   /* Have the child print any problems executing its program to errfile. */
>   apr_err = apr_pool_userdata_set(errfile, ERRFILE_KEY, NULL, pool);
>   if (apr_err)
>
>
>
Received on 2010-12-18 14:06:31 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.