/[cvs]/ccvs/src/sign.c
ViewVC logotype

Diff of /ccvs/src/sign.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.2 by dprice, Sat Oct 15 01:39:25 2005 UTC revision 1.1.2.3 by dprice, Sun Oct 16 20:45:19 2005 UTC
# Line 35  Line 35 
35  #include "xalloc.h"  #include "xalloc.h"
36    
37  /* CVS headers.  */  /* CVS headers.  */
38    #include "filesubr.h"
39  #include "root.h"  #include "root.h"
40  #include "run.h"  #include "run.h"
41  #include "stack.h"  #include "stack.h"
# Line 110  add_sign_arg (const char *arg) Line 111  add_sign_arg (const char *arg)
111   *   server_support     Whether the server supports signed files.   *   server_support     Whether the server supports signed files.
112   */   */
113  bool  bool
114  get_sign_commits (bool server_support)  get_sign_commits (bool server_active, bool server_support)
115  {  {
116      sign_state tmp;      sign_state tmp;
117    
118        /* Only sign commits from the client (and in local mode).  */
119        if (server_active) return false;
120    
121      if (sign_commits == SIGN_DEFAULT)      if (sign_commits == SIGN_DEFAULT)
122          tmp = current_parsed_root->sign;          tmp = current_parsed_root->sign;
123      else      else
# Line 226  sign_args_list_to_args_proc (Node *p, vo Line 230  sign_args_list_to_args_proc (Node *p, vo
230    
231    
232    
233    char *
234    get_sigfile_name (const char *fn)
235    {
236        return Xasprintf ("%s%s%s", BAKPREFIX, fn, ".sig");
237    }
238    
239    
240    
241    bool
242    have_sigfile (bool server_active, const char *fn)
243    {
244        char *sfn;
245        bool retval;
246    
247        /* Sig files are only created on the server.  Optimize.  */
248        if (!server_active) return false;
249    
250        sfn = get_sigfile_name (fn);
251        if (isreadable (sfn)) retval = true;
252        else retval = false;
253    
254        free (sfn);
255        return retval;
256    }
257    
258    
259    
260  /* Generate a signature and return it in allocated memory.  */  /* Generate a signature and return it in allocated memory.  */
261  char *  char *
262  get_signature (const char *srepos, const char *filename, bool bin, size_t *len)  gen_signature (const char *srepos, const char *filename, bool bin, size_t *len)
263  {  {
264      char *cmdline;      char *cmdline;
265      FILE *pipefp;      FILE *pipefp;
# Line 256  get_signature (const char *srepos, const Line 287  get_signature (const char *srepos, const
287                                get_sign_template (),                                get_sign_template (),
288                                "a", ",", get_sign_args (),                                "a", ",", get_sign_args (),
289                                sign_args_list_to_args_proc, (void *) NULL,                                sign_args_list_to_args_proc, (void *) NULL,
                               "p", "s", srepos,  
290                                "r", "s", current_parsed_root->directory,                                "r", "s", current_parsed_root->directory,
291                                  "p", "s", srepos,
292                                "t", "s", bin ? NULL : get_sign_textmode (),                                "t", "s", bin ? NULL : get_sign_textmode (),
293                                "s", "s", filename,                                "s", "s", filename,
294                                (char *) NULL);                                (char *) NULL);
# Line 302  get_signature (const char *srepos, const Line 333  get_signature (const char *srepos, const
333      *len = sigoff;      *len = sigoff;
334      return sigbuf;      return sigbuf;
335  }  }
336    
337    
338    
339    /* Read a signature from a file and return it in allocated memory.  */
340    static char *
341    read_signature (const char *fn, bool bin, size_t *len)
342    {
343        char *sfn = get_sigfile_name (fn);
344        char *data = NULL;
345        size_t datasize;
346    
347        get_file (sfn, sfn, bin ? "rb" : "r", &data, &datasize, len);
348    
349        free (sfn);
350        return data;
351    }
352    
353    
354    
355    /* Generate a signature or read one from the sigfile and return it in
356     * allocated memory.
357     */
358    char *
359    get_signature (bool server_active, const char *srepos, const char *filename,
360                   bool bin, size_t *len)
361    {
362        if (server_active) return read_signature (filename, bin, len);
363        /* else */ return gen_signature (srepos, filename, bin, len);
364    }

Legend:
Removed from v.1.1.2.2  
changed lines
  Added in v.1.1.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26