Changeset 1266:75da91412f7f in roaraudio


Ignore:
Timestamp:
02/27/09 04:07:18 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added simple API to decrypt OpenPGP files (using GnuPG), will do mor work here tomorrow

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/vio_cmd.h

    r1264 r1266  
    8989int roar_vio_open_gzip(struct roar_vio_calls * calls, struct roar_vio_calls * dst, int level); 
    9090 
     91int roar_vio_open_gpg(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int wronly, char * opts); 
     92int roar_vio_open_pgp_decrypt(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw); 
     93 
    9194#endif 
    9295 
  • libroar/vio_cmd.c

    r1264 r1266  
    374374} 
    375375 
     376int roar_vio_open_gpg(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int wronly, char * opts) { 
     377#ifdef ROAR_HAVE_BIN_GPG 
     378 char command[1024]; 
     379 int pwpipe[2]; 
     380 int ret; 
     381 
     382 if ( pw != NULL ) { 
     383  if ( pipe(pwpipe) == -1 ) 
     384   return -1; 
     385 
     386  snprintf(command, 1024, "%s --no-verbose --quiet --passphrase-repeat 0 --passphrase-fd %i %s", ROAR_HAVE_BIN_GPG, pwpipe[0], opts); 
     387 
     388  write(pwpipe[1], pw, strlen(pw)); 
     389 
     390  close(pwpipe[1]); 
     391 } else { 
     392  snprintf(command, 1024, "%s --no-verbose --quiet %s", ROAR_HAVE_BIN_GPG, opts); 
     393 } 
     394 
     395 if ( wronly ) { 
     396  ret = roar_vio_open_cmd(calls, dst, NULL, command, 0); 
     397 } else { 
     398  ret = roar_vio_open_cmd(calls, dst, command, NULL, 0); 
     399 } 
     400 
     401 if ( pw != NULL ) 
     402  close(pwpipe[0]); 
     403 
     404 return ret; 
     405#else 
     406 return -1; 
     407#endif 
     408} 
     409 
     410int roar_vio_open_pgp_decrypt(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw) { 
     411 return roar_vio_open_gpg(calls, dst, pw, 0, "-d"); 
     412} 
     413 
     414 
    376415//ll 
Note: See TracChangeset for help on using the changeset viewer.