~ubuntu-branches/ubuntu/precise/transmission/precise

« back to all changes in this revision

Viewing changes to third-party/miniupnp/minissdpc.c

  • Committer: Bazaar Package Importer
  • Author(s): Leo Costela
  • Date: 2009-05-17 19:39:51 UTC
  • mto: (1.3.4 upstream) (2.2.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: james.westby@ubuntu.com-20090517193951-k8x15sqoxzf7cuyx
ImportĀ upstreamĀ versionĀ 1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: minissdpc.c,v 1.4 2007/12/19 14:56:58 nanard Exp $ */
 
1
/* $Id: minissdpc.c,v 1.7 2008/12/18 17:45:48 nanard Exp $ */
2
2
/* Project : miniupnp
3
3
 * Author : Thomas BERNARD
4
 
 * copyright (c) 2005-2007 Thomas Bernard
 
4
 * copyright (c) 2005-2008 Thomas Bernard
5
5
 * This software is subjet to the conditions detailed in the
6
6
 * provided LICENCE file. */
7
7
/*#include <syslog.h>*/
10
10
#include <stdlib.h>
11
11
#include <unistd.h>
12
12
#include <sys/types.h>
 
13
#ifdef WIN32
 
14
#include <winsock2.h>
 
15
#include <Ws2tcpip.h>
 
16
#include <io.h>
 
17
#else
13
18
#include <sys/socket.h>
14
19
#include <sys/un.h>
 
20
#endif
15
21
 
16
22
#include "minissdpc.h"
17
23
#include "miniupnpc.h"
18
24
 
19
 
#define DECODELENGTH(n, p) n = 0; \
20
 
                           do { n = (n << 7) | (*p & 0x7f); } \
21
 
                           while(*(p++)&0x80);
22
 
#define CODELENGTH(n, p) do { *p = (n & 0x7f) | ((n > 0x7f) ? 0x80 : 0); \
23
 
                              p++; n >>= 7; } while(n);
 
25
#include "codelength.h"
24
26
 
25
27
struct UPNPDev *
26
28
getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath)
52
54
                return NULL;
53
55
        }
54
56
        stsize = strlen(devtype);
55
 
        buffer[0] = 1;
 
57
        buffer[0] = 1; /* request type 1 : request devices/services by type */
56
58
        p = buffer + 1;
57
59
        l = stsize;     CODELENGTH(l, p);
58
60
        memcpy(p, devtype, stsize);