aboutsummaryrefslogtreecommitdiff
path: root/external/miniupnpc/testminiwget.c
diff options
context:
space:
mode:
authorAntonio Juarez <antonio.maria.juarez@live.com>2014-04-09 13:14:35 +0100
committerAntonio Juarez <antonio.maria.juarez@live.com>2014-04-09 13:14:35 +0100
commit9682a15400495ae490543e7e5af242ff5c4c9fa0 (patch)
tree63ba7287d8f679742a244413291d4334fc26b6e6 /external/miniupnpc/testminiwget.c
parentImprovements in JSON RPC (diff)
downloadmonero-9682a15400495ae490543e7e5af242ff5c4c9fa0.tar.xz
Port mapping with UPnP
Diffstat (limited to 'external/miniupnpc/testminiwget.c')
-rwxr-xr-xexternal/miniupnpc/testminiwget.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/external/miniupnpc/testminiwget.c b/external/miniupnpc/testminiwget.c
new file mode 100755
index 000000000..8ae90320e
--- /dev/null
+++ b/external/miniupnpc/testminiwget.c
@@ -0,0 +1,53 @@
+/* $Id: testminiwget.c,v 1.4 2012/06/23 22:35:59 nanard Exp $ */
+/* Project : miniupnp
+ * Author : Thomas Bernard
+ * Copyright (c) 2005-2012 Thomas Bernard
+ * This software is subject to the conditions detailed in the
+ * LICENCE file provided in this distribution.
+ * */
+#include <stdio.h>
+#include <stdlib.h>
+#include "miniwget.h"
+
+/**
+ * This program uses the miniwget / miniwget_getaddr function
+ * from miniwget.c in order to retreive a web ressource using
+ * a GET HTTP method, and store it in a file.
+ */
+int main(int argc, char * * argv)
+{
+ void * data;
+ int size, writtensize;
+ FILE *f;
+ char addr[64];
+
+ if(argc < 3) {
+ fprintf(stderr, "Usage:\t%s url file\n", argv[0]);
+ fprintf(stderr, "Example:\t%s http://www.google.com/ out.html\n", argv[0]);
+ return 1;
+ }
+ data = miniwget_getaddr(argv[1], &size, addr, sizeof(addr), 0);
+ if(!data) {
+ fprintf(stderr, "Error fetching %s\n", argv[1]);
+ return 1;
+ }
+ printf("local address : %s\n", addr);
+ printf("got %d bytes\n", size);
+ f = fopen(argv[2], "wb");
+ if(!f) {
+ fprintf(stderr, "Cannot open file %s for writing\n", argv[2]);
+ free(data);
+ return 1;
+ }
+ writtensize = fwrite(data, 1, size, f);
+ if(writtensize != size) {
+ fprintf(stderr, "Could only write %d bytes out of %d to %s\n",
+ writtensize, size, argv[2]);
+ } else {
+ printf("%d bytes written to %s\n", writtensize, argv[2]);
+ }
+ fclose(f);
+ free(data);
+ return 0;
+}
+