summary history branches tags files
commit:2dacd7d53aba27df15082c06d57d49286cd91f6e
author:mrmekon
committer:mrmekon
date:Mon Nov 14 01:13:45 2011 -0500
parents:6b023ebf15db769e06c7df0f4eedd1600dbd2107
Added function to return literal data
diff --git a/simplepgp.xcodeproj/trevor.pbxuser b/simplepgp.xcodeproj/trevor.pbxuser
line changes: +6/-6
index dbd97c2..2adf291
--- a/simplepgp.xcodeproj/trevor.pbxuser
+++ b/simplepgp.xcodeproj/trevor.pbxuser
@@ -94,9 +94,9 @@
 	};
 	69269F2314620D0F00F69705 /* packet.c */ = {
 		uiCtxt = {
-			sepNavIntBoundsRect = "{{0, 0}, {905, 21840}}";
-			sepNavSelRange = "{7998, 0}";
-			sepNavVisRange = "{6413, 1690}";
+			sepNavIntBoundsRect = "{{0, 0}, {905, 22152}}";
+			sepNavSelRange = "{8104, 120}";
+			sepNavVisRange = "{8101, 1269}";
 			sepNavWindowFrame = "{{139, 11}, {1136, 746}}";
 		};
 	};
@@ -213,9 +213,9 @@
 	};
 	6926AD2B146DDA1900F69705 /* simplepgp.h */ = {
 		uiCtxt = {
-			sepNavIntBoundsRect = "{{0, 0}, {1077, 1222}}";
-			sepNavSelRange = "{1265, 0}";
-			sepNavVisRange = "{753, 1477}";
+			sepNavIntBoundsRect = "{{0, 0}, {905, 1742}}";
+			sepNavSelRange = "{3330, 67}";
+			sepNavVisRange = "{2500, 1469}";
 			sepNavWindowFrame = "{{107, 43}, {1136, 746}}";
 		};
 	};

diff --git a/src/packet.c b/src/packet.c
line changes: +27/-0
index 4bd5f50..be11fd8
--- a/src/packet.c
+++ b/src/packet.c
@@ -250,6 +250,33 @@ spgp_packet_t *spgp_decode_message(uint8_t *message, uint32_t length) {
   return head;
 }
 
+char *spgp_get_literal_data(spgp_packet_t *msg, uint32_t *datalen,
+														char **filename, uint32_t *filenamelen) {
+	spgp_packet_t *cur = msg;
+  
+	if (setjmp(exception)) {
+    	LOG_PRINT("Exception (0x%x)\n",_spgp_err);
+  	  goto end;
+  }
+  
+  if (NULL == msg || NULL == datalen || 
+  		NULL == filename || NULL == filenamelen) 
+  	RAISE(INVALID_ARGS);
+  
+  while (cur) {
+  	if (cur->header->type == PKT_TYPE_LITERAL_DATA) {
+    	*datalen = cur->c.literal->dataLen;
+      *filenamelen = cur->c.literal->filenameLen;
+      *filename = cur->c.literal->filename;
+      return cur->c.literal->data;
+    }
+  	cur = cur->next;
+  }
+  
+	end:
+	return NULL;
+}
+
 uint8_t spgp_decrypt_all_secret_keys(spgp_packet_t *msg, 
                                 		 uint8_t *passphrase, uint32_t length) {
 	spgp_packet_t *cur = msg;

diff --git a/src/simplepgp.h b/src/simplepgp.h
line changes: +12/-0
index bf26df0..207dd81
--- a/src/simplepgp.h
+++ b/src/simplepgp.h
@@ -86,6 +86,18 @@ spgp_packet_t *spgp_decode_message(uint8_t *message, uint32_t length);
  */
 uint8_t spgp_decrypt_all_secret_keys(spgp_packet_t *msg, 
                                 		 uint8_t *passphrase, uint32_t length);
+                                     
+/**
+ * Gets the literal data buffer from a decrypted message
+ *
+ * @param Linked-list of packets to search for data
+ * @param datalen Set to size of returned data (in bytes)
+ * @param filename Set to buffer containing filename
+ * @param filenamelen Set to size of filename (in bytes)
+ * @return Buffer with literal data, or NULL if none available
+ */
+char *spgp_get_literal_data(spgp_packet_t *msg, uint32_t *datalen,
+														char **filename, uint32_t *filenamelen);
 
 /**
  * Frees all dynamic resources associated with |pkt|.