Project: miniupnp
Project web page: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
+github: https://github.com/miniupnp/miniupnp
+freecode: http://freecode.com/projects/miniupnp
Author: Thomas Bernard
-Copyright (c) 2005-2011 Thomas Bernard
+Copyright (c) 2005-2012 Thomas Bernard
This software is subject to the conditions detailed in the
LICENSE file provided within this distribution.
+
For the comfort of Win32 users, bsdqueue.h is included in the distribution.
Its licence is included in the header of the file.
bsdqueue.h is a copy of the sys/queue.h of an OpenBSD system.
-* miniupnp Client *
+
+* miniUPnP Client - miniUPnPc *
To compile, simply run 'gmake' (could be 'make' on your system).
Under win32, to compile with MinGW, type "mingw32make.bat".
+MS Visual C solution and project files are supplied in the msvc/ subdirectory.
+
The compilation is known to work under linux, FreeBSD,
OpenBSD, MacOS X, AmigaOS and cygwin.
The official AmigaOS4.1 SDK was used for AmigaOS4 and GeekGadgets for AmigaOS3.
> make install
> exit
-alternatively, to install in a specific location, use :
+alternatively, to install into a specific location, use :
> INSTALLPREFIX=/usr/local make install
upnpc.c is a sample client using the libminiupnpc.
Discovery process is speeded up when MiniSSDPd is running on the machine.
+
* Python module *
you can build a python module with 'make pythonmodule'
-/* $Id: miniwget.c,v 1.55 2012/03/05 19:42:47 nanard Exp $ */
+/* $Id: miniwget.c,v 1.56 2012/05/01 16:16:08 nanard Exp $ */
/* Project : miniupnp
* Website : http://miniupnp.free.fr/
* Author : Thomas Bernard
unsigned int bytestocopy = 0;
/* buffers : */
char * header_buf;
- int header_buf_len = 2048;
- int header_buf_used = 0;
+ unsigned int header_buf_len = 2048;
+ unsigned int header_buf_used = 0;
char * content_buf;
- int content_buf_len = 2048;
- int content_buf_used = 0;
+ unsigned int content_buf_len = 2048;
+ unsigned int content_buf_used = 0;
char chunksize_buf[32];
- int chunksize_buf_index;
+ unsigned int chunksize_buf_index;
header_buf = malloc(header_buf_len);
content_buf = malloc(content_buf_len);
/* search for CR LF CR LF (end of headers)
* recognize also LF LF */
i = 0;
- while(i < (header_buf_used-1) && (endofheaders == 0)) {
+ while(i < ((int)header_buf_used-1) && (endofheaders == 0)) {
if(header_buf[i] == '\r') {
i++;
if(header_buf[i] == '\n') {
i++;
- if(i < header_buf_used && header_buf[i] == '\r') {
+ if(i < (int)header_buf_used && header_buf[i] == '\r') {
i++;
- if(i < header_buf_used && header_buf[i] == '\n') {
+ if(i < (int)header_buf_used && header_buf[i] == '\n') {
endofheaders = i+1;
}
}
i++; /* discarding chunk-extension */
if(i<n && buf[i] == '\r') i++;
if(i<n && buf[i] == '\n') {
- int j;
+ unsigned int j;
for(j = 0; j < chunksize_buf_index; j++) {
if(chunksize_buf[j] >= '0'
&& chunksize_buf[j] <= '9')
goto end_of_stream;
}
}
- bytestocopy = ((int)chunksize < n - i)?chunksize:(n - i);
- if((int)(content_buf_used + bytestocopy) > content_buf_len)
+ bytestocopy = ((int)chunksize < (n - i))?chunksize:(unsigned int)(n - i);
+ if((content_buf_used + bytestocopy) > content_buf_len)
{
- if(content_length >= content_buf_used + (int)bytestocopy) {
+ if(content_length >= (int)(content_buf_used + bytestocopy)) {
content_buf_len = content_length;
} else {
- content_buf_len = content_buf_used + (int)bytestocopy;
+ content_buf_len = content_buf_used + bytestocopy;
}
content_buf = (char *)realloc((void *)content_buf,
content_buf_len);
{
/* not chunked */
if(content_length > 0
- && (content_buf_used + n) > content_length) {
+ && (int)(content_buf_used + n) > content_length) {
/* skipping additional bytes */
n = content_length - content_buf_used;
}
if(content_buf_used + n > content_buf_len)
{
- if(content_length >= content_buf_used + n) {
+ if(content_length >= (int)(content_buf_used + n)) {
content_buf_len = content_length;
} else {
content_buf_len = content_buf_used + n;
}
}
/* use the Content-Length header value if available */
- if(content_length > 0 && content_buf_used >= content_length)
+ if(content_length > 0 && (int)content_buf_used >= content_length)
{
#ifdef DEBUG
printf("End of HTTP content\n");
* do all the work.
* Return NULL if something failed. */
static void *
-miniwget3(const char * url, const char * host,
+miniwget3(const char * host,
unsigned short port, const char * path,
int * size, char * addr_str, int addr_str_len,
const char * httpversion)
/* miniwget2() :
* Call miniwget3(); retry with HTTP/1.1 if 1.0 fails. */
static void *
-miniwget2(const char * url, const char * host,
+miniwget2(const char * host,
unsigned short port, const char * path,
int * size, char * addr_str, int addr_str_len)
{
char * respbuffer;
- respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.1");
+ respbuffer = miniwget3(host, port, path, size, addr_str, addr_str_len, "1.1");
/*
- respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.0");
+ respbuffer = miniwget3(host, port, path, size, addr_str, addr_str_len, "1.0");
if (*size == 0)
{
#ifdef DEBUG
printf("Retrying with HTTP/1.1\n");
#endif
free(respbuffer);
- respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.1");
+ respbuffer = miniwget3(host, port, path, size, addr_str, addr_str_len, "1.1");
}
*/
return respbuffer;
#ifdef DEBUG
printf("parsed url : hostname='%s' port=%hu path='%s'\n", hostname, port, path);
#endif
- return miniwget2(url, hostname, port, path, size, 0, 0);
+ return miniwget2(hostname, port, path, size, 0, 0);
}
void * miniwget_getaddr(const char * url, int * size, char * addr, int addrlen)
#ifdef DEBUG
printf("parsed url : hostname='%s' port=%hu path='%s'\n", hostname, port, path);
#endif
- return miniwget2(url, hostname, port, path, size, addr, addrlen);
+ return miniwget2(hostname, port, path, size, addr, addrlen);
}
#! /bin/sh
-# $Id: updateminiupnpcstrings.sh,v 1.4 2009/07/29 08:34:01 nanard Exp $
+# $Id: updateminiupnpcstrings.sh,v 1.7 2011/01/04 11:41:53 nanard Exp $
+# project miniupnp : http://miniupnp.free.fr/
+# (c) 2009 Thomas Bernard
-TEMPLATE_FILE=$1
-OUTPUT_FILE=$2
+FILE=miniupnpcstrings.h
+TMPFILE=miniupnpcstrings.h.tmp
+TEMPLATE_FILE=${FILE}.in
# detecting the OS name and version
OS_NAME=`uname -s`
OS_VERSION=`cat /etc/debian_version`
fi
# use lsb_release (Linux Standard Base) when available
-if os_name=`lsb_release -i -s 2>/dev/null`; then
- OS_NAME=$os_name
- OS_VERSION=`lsb_release -r -s`
+LSB_RELEASE=`which lsb_release`
+if [ 0 -eq $? -a -x "${LSB_RELEASE}" ]; then
+ OS_NAME=`${LSB_RELEASE} -i -s`
+ OS_VERSION=`${LSB_RELEASE} -r -s`
+ case $OS_NAME in
+ Debian)
+ #OS_VERSION=`${LSB_RELEASE} -c -s`
+ ;;
+ Ubuntu)
+ #OS_VERSION=`${LSB_RELEASE} -c -s`
+ ;;
+ esac
+fi
+
+# on AmigaOS 3, uname -r returns "unknown", so we use uname -v
+if [ "$OS_NAME" = "AmigaOS" ]; then
+ if [ "$OS_VERSION" = "unknown" ]; then
+ OS_VERSION=`uname -v`
+ fi
fi
echo "Detected OS [$OS_NAME] version [$OS_VERSION]"
+MINIUPNPC_VERSION=`cat VERSION`
+echo "MiniUPnPc version [${MINIUPNPC_VERSION}]"
EXPR="s|OS_STRING \".*\"|OS_STRING \"${OS_NAME}/${OS_VERSION}\"|"
#echo $EXPR
-#echo "Backing up $OUTPUT_FILE to $OUTPUT_FILE.bak."
-#cp $OUTPUT_FILE $OUTPUT_FILE.bak
-test -f ${TEMPLATE_FILE}
-echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $OUTPUT_FILE."
-sed -e "$EXPR" < $TEMPLATE_FILE > $OUTPUT_FILE
+test -f ${FILE}.in
+echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $FILE."
+sed -e "$EXPR" < $TEMPLATE_FILE > $TMPFILE
+
+EXPR="s|MINIUPNPC_VERSION_STRING \".*\"|MINIUPNPC_VERSION_STRING \"${MINIUPNPC_VERSION}\"|"
+echo "setting MINIUPNPC_VERSION_STRING macro value to ${MINIUPNPC_VERSION} in $FILE."
+sed -e "$EXPR" < $TMPFILE > $FILE
+rm $TMPFILE