[OpenPGP:SDK svn] r331 - openpgpsdk/trunk/examples

Subversion ben at algroup.co.uk
Tue Jan 10 17:24:13 GMT 2006


Author: ben
Date: 2006-01-10 17:24:13 +0000 (Tue, 10 Jan 2006)
New Revision: 331

Modified:
   openpgpsdk/trunk/examples/packet-dump.c
Log:
Actually read the file.


Modified: openpgpsdk/trunk/examples/packet-dump.c
===================================================================
--- openpgpsdk/trunk/examples/packet-dump.c	2006-01-10 16:09:38 UTC (rev 330)
+++ openpgpsdk/trunk/examples/packet-dump.c	2006-01-10 17:24:13 UTC (rev 331)
@@ -12,6 +12,7 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#include <fcntl.h>
 
 static int indent=0;
 static const char *pname;
@@ -867,7 +868,9 @@
 
 static void usage()
     {
-    fprintf(stderr,"%s [-a]\n",pname);
+    fprintf(stderr,"%s [-a] [-b] <file name>\n\n",pname);
+    fprintf(stderr,"-a\tRead armoured data\n"
+	    "-b\tDon't buffer stdout/stderr\n");
     exit(1);
     }
 
@@ -877,6 +880,7 @@
     ops_boolean_t armour=ops_false;
     int ret;
     int ch;
+    int fd;
 
     pname=argv[0];
 
@@ -895,15 +899,26 @@
 	default:
 	    usage();
 	    }
+    argc-=optind;
+    argv+=optind;
 
+    if(argc != 1)
+	usage();
 
+    fd=open(argv[0],O_RDONLY);
+    if(fd < 0)
+	{
+	perror(argv[0]);
+	exit(2);
+	}
+
     pinfo=ops_parse_info_new();
     //    ops_parse_packet_options(&opt,OPS_PTAG_SS_ALL,OPS_PARSE_RAW);
     ops_parse_options(pinfo,OPS_PTAG_SS_ALL,OPS_PARSE_PARSED);
 
     ops_parse_cb_set(pinfo,callback,NULL);
 
-    ops_reader_set_fd(pinfo,0);
+    ops_reader_set_fd(pinfo,fd);
 
     if(armour)
 	ops_reader_push_dearmour(pinfo,ops_true,ops_true,ops_true);



More information about the OpenPGPsdk-svn mailing list