FS-9924: Removed extra space in source files

This commit is contained in:
Sergey Safarov committed 2017-02-09 23:59:49 -05:00
1 parent 60d4e87487
commit df1ab07ca4
455 files changed
+9699 -9698

No files matched your search

+18 -18
View File
@@ -1,23 +1,23 @@
/*
* Copyright (c) 2011, Anthony Minessale II
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -63,11 +63,11 @@ int mcast_socket_create(const char *host, int16_t port, mcast_handle_t *handle,
int family = AF_INET;
memset(handle, 0, sizeof(*handle));
if (strchr(host, ':')) {
if (strchr(host, ':')) {
family = AF_INET6;
}
if ((!(flags & MCAST_SEND) && !(flags & MCAST_RECV)) || (handle->sock = (mcast_socket_t)socket(family, SOCK_DGRAM, 0)) == mcast_sock_invalid ) {
return -1;
}
@@ -83,17 +83,17 @@ int mcast_socket_create(const char *host, int16_t port, mcast_handle_t *handle,
handle->send_addr.sin_port = htons(port);
handle->family = AF_INET;
}
if ( setsockopt(handle->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one)) != 0 ) {
mcast_socket_close(handle);
return -1;
}
if ((flags & MCAST_RECV)) {
if (handle->family == AF_INET) {
struct ip_mreq mreq;
handle->recv_addr.sin_family = AF_INET;
handle->recv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
handle->recv_addr.sin_port = htons(port);
@@ -116,24 +116,24 @@ int mcast_socket_create(const char *host, int16_t port, mcast_handle_t *handle,
struct addrinfo addr_criteria;
struct addrinfo *mcast_addr;
char service[80] = "";
memset(&addr_criteria, 0, sizeof(addr_criteria));
addr_criteria.ai_family = AF_UNSPEC;
addr_criteria.ai_socktype = SOCK_DGRAM;
addr_criteria.ai_protocol = IPPROTO_UDP;
addr_criteria.ai_flags |= AI_NUMERICHOST;
snprintf(service, sizeof(service), "%d", port);
getaddrinfo(host, service, &addr_criteria, &mcast_addr);
memset(&handle->recv_addr6, 0, sizeof(handle->recv_addr6));
handle->recv_addr6.sin6_family = AF_INET6;
handle->recv_addr6.sin6_port = htons(port);
inet_pton(AF_INET6, "::0", &(handle->recv_addr6.sin6_addr));
memcpy(&mreq.ipv6mr_multiaddr, &((struct sockaddr_in6 *)mcast_addr->ai_addr)->sin6_addr, sizeof(struct in6_addr));
mreq.ipv6mr_interface = 0;
setsockopt(handle->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, (const char *)&mreq, sizeof(mreq));
@@ -165,7 +165,7 @@ int mcast_socket_create(const char *host, int16_t port, mcast_handle_t *handle,
if ((flags & MCAST_TTL_CONTINENT)) {
handle->ttl = 128;
}
if ((flags & MCAST_TTL_UNIVERSE)) {
handle->ttl = 255;
}
@@ -175,7 +175,7 @@ int mcast_socket_create(const char *host, int16_t port, mcast_handle_t *handle,
}
handle->ready = 1;
return 0;
}
+6 -6
View File
@@ -1,23 +1,23 @@
/*
* Copyright (c) 2011, Anthony Minessale II
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -1,23 +1,23 @@
/*
* Copyright (c) 2011, Anthony Minessale II
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -61,7 +61,7 @@ char *McastHandle::recv(int ms)
*((char *)handle.buffer + r) = '\0';
return (char *) handle.buffer;
}
return NULL;
}
@@ -1,23 +1,23 @@
/*
* Copyright (c) 2011, Anthony Minessale II
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+160 -160
View File
@@ -1,11 +1,11 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
#define SWIGPERL
@@ -18,7 +18,7 @@ public:
SwigValueWrapper() : tt(0) { }
SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { }
SwigValueWrapper(const T& t) : tt(new T(t)) { }
~SwigValueWrapper() { delete tt; }
~SwigValueWrapper() { delete tt; }
SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; }
operator T&() const { return *tt; }
T *operator&() { return tt; }
@@ -62,14 +62,14 @@ template <typename T> T SwigValueInit() {
#ifndef SWIGUNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define SWIGUNUSED __attribute__ ((__unused__))
# define SWIGUNUSED __attribute__ ((__unused__))
# else
# define SWIGUNUSED
# endif
# elif defined(__ICC)
# define SWIGUNUSED __attribute__ ((__unused__))
# define SWIGUNUSED __attribute__ ((__unused__))
# else
# define SWIGUNUSED
# define SWIGUNUSED
# endif
#endif
@@ -77,7 +77,7 @@ template <typename T> T SwigValueInit() {
# ifdef __cplusplus
# define SWIGUNUSEDPARM(p)
# else
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
# endif
#endif
@@ -120,7 +120,7 @@ template <typename T> T SwigValueInit() {
# define SWIGSTDCALL __stdcall
# else
# define SWIGSTDCALL
# endif
# endif
#endif
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
@@ -158,7 +158,7 @@ template <typename T> T SwigValueInit() {
You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
creating a static or dynamic library from the swig runtime code.
In 99.9% of the cases, swig just needs to declare them as 'static'.
But only do this if is strictly necessary, ie, if you have problems
with your compiler or so.
*/
@@ -184,16 +184,16 @@ template <typename T> T SwigValueInit() {
#define SWIG_POINTER_OWN 0x1
/*
/*
Flags/methods for returning states.
The swig conversion methods, as ConvertPtr, return and integer
The swig conversion methods, as ConvertPtr, return and integer
that tells if the conversion was successful or not. And if not,
an error code can be returned (see swigerrors.swg for the codes).
Use the following macros/flags to set or process the returning
states.
In old swig versions, you usually write code as:
if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
@@ -226,23 +226,23 @@ template <typename T> T SwigValueInit() {
} else {
// fail code
}
I.e., now SWIG_ConvertPtr can return new objects and you can
identify the case and take care of the deallocation. Of course that
requires also to SWIG_ConvertPtr to return new result values, as
int SWIG_ConvertPtr(obj, ptr,...) {
if (<obj is ok>) {
if (<need new object>) {
*ptr = <ptr to new allocated object>;
return SWIG_NEWOBJ;
} else {
*ptr = <ptr to old object>;
return SWIG_OLDOBJ;
}
} else {
return SWIG_BADOBJ;
}
int SWIG_ConvertPtr(obj, ptr,...) {
if (<obj is ok>) {
if (<need new object>) {
*ptr = <ptr to new allocated object>;
return SWIG_NEWOBJ;
} else {
*ptr = <ptr to old object>;
return SWIG_OLDOBJ;
}
} else {
return SWIG_BADOBJ;
}
}
Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
@@ -256,7 +256,7 @@ template <typename T> T SwigValueInit() {
int fooi(int);
and you call
food(1) // cast rank '1' (1 -> 1.0)
fooi(1) // cast rank '0'
@@ -264,10 +264,10 @@ template <typename T> T SwigValueInit() {
*/
#define SWIG_OK (0)
#define SWIG_OK (0)
#define SWIG_ERROR (-1)
#define SWIG_IsOK(r) (r >= 0)
#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
/* The CastRankLimit says how many bits are used for the cast rank */
#define SWIG_CASTRANKLIMIT (1 << 8)
@@ -299,11 +299,11 @@ template <typename T> T SwigValueInit() {
# endif
# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
SWIGINTERNINLINE int SWIG_AddCast(int r) {
SWIGINTERNINLINE int SWIG_AddCast(int r) {
return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
}
SWIGINTERNINLINE int SWIG_CheckState(int r) {
return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
SWIGINTERNINLINE int SWIG_CheckState(int r) {
return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
}
#else /* no cast-rank mode */
# define SWIG_AddCast
@@ -352,7 +352,7 @@ typedef struct swig_module_info {
void *clientdata; /* Language specific module data */
} swig_module_info;
/*
/*
Compare two type names skipping the space characters, therefore
"char*" == "char *" and "Class<int>" == "Class<int >", etc.
@@ -453,7 +453,7 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
/*
Dynamic pointer casting. Down an inheritance hierarchy
*/
SWIGRUNTIME swig_type_info *
@@ -497,7 +497,7 @@ SWIG_TypePrettyName(const swig_type_info *type) {
return type->name;
}
/*
/*
Set the clientdata field for a type
*/
SWIGRUNTIME void
@@ -505,14 +505,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
swig_cast_info *cast = ti->cast;
/* if (ti->clientdata == clientdata) return; */
ti->clientdata = clientdata;
while (cast) {
if (!cast->converter) {
swig_type_info *tc = cast->type;
if (!tc->clientdata) {
SWIG_TypeClientData(tc, clientdata);
}
}
}
cast = cast->next;
}
}
@@ -521,18 +521,18 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
SWIG_TypeClientData(ti, clientdata);
ti->owndata = 1;
}
/*
Search for a swig_type_info structure only by mangled name
Search is a O(log #types)
We start searching at module start, and finish searching when start == end.
We start searching at module start, and finish searching when start == end.
Note: if start == end at the beginning of the function, we go all the way around
the circular list.
*/
SWIGRUNTIME swig_type_info *
SWIG_MangledTypeQueryModule(swig_module_info *start,
swig_module_info *end,
SWIG_MangledTypeQueryModule(swig_module_info *start,
swig_module_info *end,
const char *name) {
swig_module_info *iter = start;
do {
@@ -541,11 +541,11 @@ SWIG_MangledTypeQueryModule(swig_module_info *start,
register size_t r = iter->size - 1;
do {
/* since l+r >= 0, we can (>> 1) instead (/ 2) */
register size_t i = (l + r) >> 1;
register size_t i = (l + r) >> 1;
const char *iname = iter->types[i]->name;
if (iname) {
register int compare = strcmp(name, iname);
if (compare == 0) {
if (compare == 0) {
return iter->types[i];
} else if (compare < 0) {
if (i) {
@@ -570,14 +570,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start,
Search for a swig_type_info structure for either a mangled name or a human readable name.
It first searches the mangled names of the types, which is a O(log #types)
If a type is not found it then searches the human readable names, which is O(#types).
We start searching at module start, and finish searching when start == end.
We start searching at module start, and finish searching when start == end.
Note: if start == end at the beginning of the function, we go all the way around
the circular list.
*/
SWIGRUNTIME swig_type_info *
SWIG_TypeQueryModule(swig_module_info *start,
swig_module_info *end,
SWIG_TypeQueryModule(swig_module_info *start,
swig_module_info *end,
const char *name) {
/* STEP 1: Search the name field using binary search */
swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
@@ -596,12 +596,12 @@ SWIG_TypeQueryModule(swig_module_info *start,
iter = iter->next;
} while (iter != end);
}
/* neither found a match */
return 0;
}
/*
/*
Pack binary data into a string
*/
SWIGRUNTIME char *
@@ -617,7 +617,7 @@ SWIG_PackData(char *c, void *ptr, size_t sz) {
return c;
}
/*
/*
Unpack binary data from a string
*/
SWIGRUNTIME const char *
@@ -631,21 +631,21 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
uu = ((d - ('a'-10)) << 4);
else
else
return (char *) 0;
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu |= (d - '0');
else if ((d >= 'a') && (d <= 'f'))
uu |= (d - ('a'-10));
else
else
return (char *) 0;
*u = uu;
}
return c;
}
/*
/*
Pack 'void *' into a string buffer.
*/
SWIGRUNTIME char *
@@ -705,18 +705,18 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
#endif
/* Errors in SWIG */
#define SWIG_UnknownError -1
#define SWIG_IOError -2
#define SWIG_RuntimeError -3
#define SWIG_IndexError -4
#define SWIG_TypeError -5
#define SWIG_DivisionByZero -6
#define SWIG_OverflowError -7
#define SWIG_SyntaxError -8
#define SWIG_ValueError -9
#define SWIG_UnknownError -1
#define SWIG_IOError -2
#define SWIG_RuntimeError -3
#define SWIG_IndexError -4
#define SWIG_TypeError -5
#define SWIG_DivisionByZero -6
#define SWIG_OverflowError -7
#define SWIG_SyntaxError -8
#define SWIG_ValueError -9
#define SWIG_SystemError -10
#define SWIG_AttributeError -11
#define SWIG_MemoryError -12
#define SWIG_MemoryError -12
#define SWIG_NullReferenceError -13
@@ -817,7 +817,7 @@ extern "C" {
#ifndef pTHX_
#define pTHX_
#endif
#endif
#include <string.h>
#ifdef __cplusplus
@@ -921,9 +921,9 @@ SWIG_Perl_ErrorType(int code) {
/* Error manipulation */
#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code)
#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code)
#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg)
#define SWIG_fail goto fail
#define SWIG_fail goto fail
/* Perl-specific SWIG API */
@@ -961,15 +961,15 @@ extern "C" {
#endif
/* Macro to call an XS function */
#ifdef PERL_OBJECT
# define SWIG_CALLXS(_name) _name(cv,pPerl)
#else
# ifndef MULTIPLICITY
# define SWIG_CALLXS(_name) _name(cv)
# else
# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
# endif
#endif
#ifdef PERL_OBJECT
# define SWIG_CALLXS(_name) _name(cv,pPerl)
#else
# ifndef MULTIPLICITY
# define SWIG_CALLXS(_name) _name(cv)
# else
# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
# endif
#endif
#ifdef PERL_OBJECT
#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this;
@@ -1038,13 +1038,13 @@ static void SWIG_croak_null()
#endif
/*
/*
Define how strict is the cast between strings and integers/doubles
when overloading between these types occurs.
The default is making it as strict as possible by using SWIG_AddCast
when needed.
You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to
disable the SWIG_AddCast, making the casting between string and
numbers less strict.
@@ -1060,7 +1060,7 @@ static void SWIG_croak_null()
#endif
#ifdef SWIG_PERL_STRICT_STR2NUM
/* string takes precedence */
#define SWIG_Str2NumCast(x) SWIG_AddCast(x)
#define SWIG_Str2NumCast(x) SWIG_AddCast(x)
#else
/* number takes precedence */
#define SWIG_Str2NumCast(x) x
@@ -1075,7 +1075,7 @@ SWIG_Perl_TypeProxyName(const swig_type_info *type) {
if (!type) return NULL;
if (type->clientdata != NULL) {
return (const char*) type->clientdata;
}
}
else {
return type->name;
}
@@ -1083,7 +1083,7 @@ SWIG_Perl_TypeProxyName(const swig_type_info *type) {
SWIGRUNTIME swig_cast_info *
SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0))
SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0))
|| (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty);
}
@@ -1150,11 +1150,11 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *
*ptr = voidptr;
}
/*
/*
* DISOWN implementation: we need a perl guru to check this one.
*/
if (tsv && (flags & SWIG_POINTER_DISOWN)) {
/*
/*
* almost copy paste code from below SWIG_POINTER_OWN setting
*/
SV *obj = sv;
@@ -1163,7 +1163,7 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *
if (isGV(gv)) {
HV *hv = GvHVn(gv);
/*
* To set ownership (see below), a newSViv(1) entry is added.
* To set ownership (see below), a newSViv(1) entry is added.
* Hence, to remove ownership, we delete the entry.
*/
if (hv_exists_ent(hv, obj, 0)) {
@@ -1292,13 +1292,13 @@ typedef struct {
#ifndef PERL_OBJECT
#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
#ifndef MULTIPLICITY
SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *))
SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *))
#else
SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *))
SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *))
#endif
#else
# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *))
SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *))
#endif
{
MAGIC *mg;
@@ -1438,9 +1438,9 @@ SWIG_Perl_SetModule(swig_module_info *module) {
#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
@@ -1460,12 +1460,12 @@ static swig_module_info swig_module = {swig_types, 2, 0, 0, 0, 0};
#define SWIG_name "MCASTc::boot_MCAST"
#define SWIG_prefix "MCASTc::"
#define SWIGVERSION 0x010335
#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a))
#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a))
#include <stdexcept>
@@ -1507,7 +1507,7 @@ SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
{
if (SvPOK(obj)) {
STRLEN len = 0;
char *cstr = SvPV(obj, len);
char *cstr = SvPV(obj, len);
size_t size = len + 1;
if (cptr) {
if (alloc) {
@@ -1524,7 +1524,7 @@ SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
} else {
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
if (pchar_descriptor) {
char* vptr = 0;
char* vptr = 0;
if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) {
if (cptr) *cptr = vptr;
if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
@@ -1663,14 +1663,14 @@ SWIG_AsVal_int SWIG_PERL_DECL_ARGS_2(SV * obj, int *val)
} else {
if (val) *val = static_cast< int >(v);
}
}
}
return res;
}
SWIGINTERNINLINE SV *
SWIG_From_long SWIG_PERL_DECL_ARGS_1(long value)
{
{
SV *obj = sv_newmortal();
sv_setiv(obj, (IV) value);
return obj;
@@ -1679,7 +1679,7 @@ SWIG_From_long SWIG_PERL_DECL_ARGS_1(long value)
SWIGINTERNINLINE SV *
SWIG_From_int SWIG_PERL_DECL_ARGS_1(int value)
{
{
return SWIG_From_long SWIG_PERL_CALL_ARGS_1(value);
}
@@ -1697,9 +1697,9 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
}
SWIGINTERNINLINE SV *
SWIGINTERNINLINE SV *
SWIG_FromCharPtr(const char *cptr)
{
{
return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
}
@@ -1747,7 +1747,7 @@ XS(_wrap_new_McastHandle) {
int ecode3 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 3) || (items > 3)) {
SWIG_croak("Usage: new_McastHandle(host,port,flags);");
}
@@ -1759,23 +1759,23 @@ XS(_wrap_new_McastHandle) {
ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_McastHandle" "', argument " "2"" of type '" "int""'");
}
}
arg2 = static_cast< int >(val2);
ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3);
if (!SWIG_IsOK(ecode3)) {
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_McastHandle" "', argument " "3"" of type '" "int""'");
}
}
arg3 = static_cast< int >(val3);
result = (McastHandle *)new McastHandle((char const *)arg1,arg2,arg3);
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_McastHandle, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
XSRETURN(argvi);
fail:
if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
SWIG_croak_null();
}
}
@@ -1788,22 +1788,22 @@ XS(_wrap_delete_McastHandle) {
int res1 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: delete_McastHandle(self);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_McastHandle, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_McastHandle" "', argument " "1"" of type '" "McastHandle *""'");
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_McastHandle" "', argument " "1"" of type '" "McastHandle *""'");
}
arg1 = reinterpret_cast< McastHandle * >(argp1);
delete arg1;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
@@ -1821,13 +1821,13 @@ XS(_wrap_McastHandle_send) {
int alloc2 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: McastHandle_send(self,data);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_McastHandle, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_send" "', argument " "1"" of type '" "McastHandle *""'");
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_send" "', argument " "1"" of type '" "McastHandle *""'");
}
arg1 = reinterpret_cast< McastHandle * >(argp1);
res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
@@ -1837,11 +1837,11 @@ XS(_wrap_McastHandle_send) {
arg2 = reinterpret_cast< char * >(buf2);
result = (int)(arg1)->send((char const *)arg2);
ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
XSRETURN(argvi);
fail:
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
SWIG_croak_null();
}
@@ -1859,30 +1859,30 @@ XS(_wrap_McastHandle_recv) {
int ecode2 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 1) || (items > 2)) {
SWIG_croak("Usage: McastHandle_recv(self,ms);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_McastHandle, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_recv" "', argument " "1"" of type '" "McastHandle *""'");
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_recv" "', argument " "1"" of type '" "McastHandle *""'");
}
arg1 = reinterpret_cast< McastHandle * >(argp1);
if (items > 1) {
ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "McastHandle_recv" "', argument " "2"" of type '" "int""'");
}
}
arg2 = static_cast< int >(val2);
}
result = (char *)(arg1)->recv(arg2);
ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
@@ -1896,21 +1896,21 @@ XS(_wrap_McastHandle_filenum) {
int res1 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: McastHandle_filenum(self);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_McastHandle, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_filenum" "', argument " "1"" of type '" "McastHandle *""'");
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_filenum" "', argument " "1"" of type '" "McastHandle *""'");
}
arg1 = reinterpret_cast< McastHandle * >(argp1);
result = (int)(arg1)->filenum();
ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
@@ -1957,18 +1957,18 @@ static swig_command_info swig_commands[] = {
};
/* -----------------------------------------------------------------------------
* Type initialization:
* This problem is tough by the requirement that no dynamic
* memory is used. Also, since swig_type_info structures store pointers to
* This problem is tough by the requirement that no dynamic
* memory is used. Also, since swig_type_info structures store pointers to
* swig_cast_info structures and swig_cast_info structures store pointers back
* to swig_type_info structures, we need some lookup code at initialization.
* The idea is that swig generates all the structures that are needed.
* The runtime then collects these partially filled structures.
* The SWIG_InitializeModule function takes these initial arrays out of
* to swig_type_info structures, we need some lookup code at initialization.
* The idea is that swig generates all the structures that are needed.
* The runtime then collects these partially filled structures.
* The SWIG_InitializeModule function takes these initial arrays out of
* swig_module, and does all the lookup, filling in the swig_module.types
* array with the correct data and linking the correct swig_cast_info
* structures together.
*
* The generated swig_type_info structures are assigned staticly to an initial
* The generated swig_type_info structures are assigned staticly to an initial
* array. We just loop through that array, and handle each type individually.
* First we lookup if this type has been already loaded, and if so, use the
* loaded structure instead of the generated one. Then we have to fill in the
@@ -1978,17 +1978,17 @@ static swig_command_info swig_commands[] = {
* a column is one of the swig_cast_info structures for that type.
* The cast_initial array is actually an array of arrays, because each row has
* a variable number of columns. So to actually build the cast linked list,
* we find the array of casts associated with the type, and loop through it
* we find the array of casts associated with the type, and loop through it
* adding the casts to the list. The one last trick we need to do is making
* sure the type pointer in the swig_cast_info struct is correct.
*
* First off, we lookup the cast->type name to see if it is already loaded.
* First off, we lookup the cast->type name to see if it is already loaded.
* There are three cases to handle:
* 1) If the cast->type has already been loaded AND the type we are adding
* casting info to has not been loaded (it is in this module), THEN we
* replace the cast->type pointer with the type pointer that has already
* been loaded.
* 2) If BOTH types (the one we are adding casting info to, and the
* 2) If BOTH types (the one we are adding casting info to, and the
* cast->type) are loaded, THEN the cast info has already been loaded by
* the previous module so we just ignore it.
* 3) Finally, if cast->type has not already been loaded, then we add that
@@ -2013,9 +2013,9 @@ SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
int found, init;
clientdata = clientdata;
/* check to see if the circular list has been setup, if not, set it up */
if (swig_module.next==0) {
/* Initialize the swig_module */
@@ -2026,7 +2026,7 @@ SWIG_InitializeModule(void *clientdata) {
} else {
init = 0;
}
/* Try and load any already created modules */
module_head = SWIG_GetModule(clientdata);
if (!module_head) {
@@ -2045,20 +2045,20 @@ SWIG_InitializeModule(void *clientdata) {
}
iter=iter->next;
} while (iter!= module_head);
/* if the is found in the list, then all is done and we may leave */
if (found) return;
/* otherwise we must add out module into the list */
swig_module.next = module_head->next;
module_head->next = &swig_module;
}
/* When multiple interpeters are used, a module could have already been initialized in
a different interpreter, but not yet have a pointer in this interpreter.
In this case, we do not want to continue adding types... everything should be
set up already */
if (init == 0) return;
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
@@ -2067,11 +2067,11 @@ SWIG_InitializeModule(void *clientdata) {
swig_type_info *type = 0;
swig_type_info *ret;
swig_cast_info *cast;
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
#endif
/* if there is another module already loaded */
if (swig_module.next != &swig_module) {
type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
@@ -2090,7 +2090,7 @@ SWIG_InitializeModule(void *clientdata) {
} else {
type = swig_module.type_initial[i];
}
/* Insert casting types */
cast = swig_module.cast_initial[i];
while (cast->type) {
@@ -2121,7 +2121,7 @@ SWIG_InitializeModule(void *clientdata) {
if (!ocast) ret = 0;
}
}
if (!ret) {
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
@@ -2138,7 +2138,7 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.types[i] = type;
}
swig_module.types[i] = 0;
#ifdef SWIGRUNTIME_DEBUG
printf("**** SWIG_InitializeModule: Cast List ******\n");
for (i = 0; i < swig_module.size; ++i) {
@@ -2166,10 +2166,10 @@ SWIG_PropagateClientData(void) {
size_t i;
swig_cast_info *equiv;
static int init_run = 0;
if (init_run) return;
init_run = 1;
for (i = 0; i < swig_module.size; i++) {
if (swig_module.types[i]->clientdata) {
equiv = swig_module.types[i]->cast;
@@ -2201,14 +2201,14 @@ extern "C"
XS(SWIG_init) {
dXSARGS;
int i;
SWIG_InitializeModule(0);
/* Install commands */
for (i = 0; swig_commands[i].name; i++) {
newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__);
}
/* Install variables */
for (i = 0; swig_variables[i].name; i++) {
SV *sv;
@@ -2218,9 +2218,9 @@ XS(SWIG_init) {
} else {
sv_setiv(sv,(IV) 0);
}
swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get);
swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get);
}
/* Install constant */
for (i = 0; swig_constants[i].type; i++) {
SV *sv;
@@ -2246,7 +2246,7 @@ XS(SWIG_init) {
}
SvREADONLY_on(sv);
}
SWIG_TypeClientData(SWIGTYPE_p_McastHandle, (void*) "MCAST::McastHandle");
ST(0) = &PL_sv_yes;
XSRETURN(1);
+1 -1
View File
@@ -15,7 +15,7 @@ int main(int argc, char *argv[])
mcast_socket_create("231.3.3.7", 1337, &handle, MCAST_SEND | MCAST_RECV | MCAST_TTL_HOST);
perror("create");
if (!strcmp(argv[1], "send")) {
mcast_socket_send(&handle, argv[2], strlen(argv[2]));
exit(0);
File diff suppressed because it is too large. Load diff
+13 -13
View File
@@ -1,4 +1,4 @@
/*
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
*
@@ -22,7 +22,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Anthony Minessale II <anthm@freeswitch.org>
* Seven Du <dujinfang@gmail.com>
*
@@ -41,7 +41,7 @@
#else
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <sys/wait.h>
#endif
#include <string.h>
#ifndef WIN32
@@ -70,8 +70,8 @@
#define VERTO_CHAT_PROTO "verto"
#define copy_string(x,y,z) strncpy(x, y, z - 1)
#define set_string(x,y) strncpy(x, y, sizeof(x)-1)
#define copy_string(x,y,z) strncpy(x, y, z - 1)
#define set_string(x,y) strncpy(x, y, sizeof(x)-1)
#define CODE_INVALID -32600
#define CODE_AUTH_REQUIRED -32000
@@ -131,7 +131,7 @@ struct jsock_s {
char *uid;
char *dialplan;
char *context;
char remote_host[256];
int remote_port;
@@ -139,7 +139,7 @@ struct jsock_s {
struct verto_profile_s *profile;
switch_thread_rwlock_t *rwlock;
switch_mutex_t *write_mutex;
switch_mutex_t *filter_mutex;
@@ -189,9 +189,9 @@ typedef struct verto_pvt_s {
switch_frame_t text_read_frame;
switch_thread_cond_t *text_cond;
switch_mutex_t *text_cond_mutex;
switch_mutex_t *text_read_mutex;
switch_mutex_t *text_write_mutex;
switch_mutex_t *text_cond_mutex;
switch_mutex_t *text_read_mutex;
switch_mutex_t *text_write_mutex;
switch_buffer_t *text_read_buffer;
switch_buffer_t *text_write_buffer;
@@ -235,7 +235,7 @@ struct verto_profile_s {
int ssl_ready;
int ready;
int debug;
int in_thread;
int blind_reg;
@@ -310,8 +310,8 @@ struct globals_s {
switch_thread_rwlock_t *tech_rwlock;
switch_thread_cond_t *detach_cond;
switch_mutex_t *detach_mutex;
switch_mutex_t *detach2_mutex;
switch_mutex_t *detach_mutex;
switch_mutex_t *detach2_mutex;
uint32_t detached;
uint32_t detach_timeout;
+47 -47
View File
@@ -14,7 +14,7 @@
#define ms_sleep(x) usleep( x * 1000);
#else
#define ms_sleep(x) Sleep( x );
#endif
#endif
#ifdef _MSC_VER
/* warning C4706: assignment within conditional expression*/
@@ -32,11 +32,11 @@ static struct ws_globals_s ws_globals;
#ifndef WSS_STANDALONE
void init_ssl(void)
void init_ssl(void)
{
// SSL_library_init();
}
void deinit_ssl(void)
void deinit_ssl(void)
{
return;
}
@@ -169,28 +169,28 @@ static int cheezy_get_var(char *data, char *name, char *buf, size_t buflen)
e = strchr(v, '\n');
}
}
if (v && e) {
int cplen;
size_t len = e - v;
if (len > buflen - 1) {
cplen = buflen -1;
} else {
cplen = len;
}
strncpy(buf, v, cplen);
*(buf+cplen) = '\0';
return 1;
}
}
}
return 0;
}
static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen)
static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen)
{
int y=0,bytes=0;
size_t x=0;
@@ -234,7 +234,7 @@ static void sha1_digest(char *digest, unsigned char *in)
SHA1Update(&sha, in, strlen(in));
SHA1Final(&sha, digest);
}
#else
#else
static void sha1_digest(unsigned char *digest, char *in)
{
@@ -277,13 +277,13 @@ int ws_handshake(wsh_t *wsh)
}
*(wsh->buffer + wsh->datalen) = '\0';
if (strncasecmp(wsh->buffer, "GET ", 4)) {
goto err;
}
p = wsh->buffer + 4;
e = strchr(p, ' ');
if (!e) {
goto err;
@@ -296,11 +296,11 @@ int ws_handshake(wsh_t *wsh)
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Key", key, sizeof(key));
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Version", version, sizeof(version));
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Protocol", proto, sizeof(proto));
if (!*key) {
goto err;
}
snprintf(input, sizeof(input), "%s%s", key, WEBSOCKET_GUID);
sha1_digest(output, input);
b64encode((unsigned char *)output, SHA1_HASH_SIZE, (unsigned char *)b64, sizeof(b64));
@@ -309,7 +309,7 @@ int ws_handshake(wsh_t *wsh)
snprintf(proto_buf, sizeof(proto_buf), "Sec-WebSocket-Protocol: %s\r\n", proto);
}
snprintf(respond, sizeof(respond),
snprintf(respond, sizeof(respond),
"HTTP/1.1 101 Switching Protocols\r\n"
"Upgrade: websocket\r\n"
"Connection: Upgrade\r\n"
@@ -358,7 +358,7 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
if (r == -1) {
err = SSL_get_error(wsh->ssl, r);
if (err == SSL_ERROR_WANT_READ) {
if (!block) {
r = -2;
@@ -393,7 +393,7 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
}
}
} while (r == -1 && xp_is_blocking(xp_errno()) && wsh->x < 1000);
end:
if (wsh->x >= 10000 || (block && wsh->x >= 1000)) {
@@ -407,7 +407,7 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
if (r >= 0) {
wsh->x = 0;
}
return r;
}
@@ -448,13 +448,13 @@ ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
if (ssl_err) {
r = ssl_err * -1;
}
return r;
}
do {
r = send(wsh->sock, (void *)((unsigned char *)data + wrote), bytes - wrote, 0);
if (r > 0) {
wrote += r;
}
@@ -471,9 +471,9 @@ ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
}
ms_sleep(ms);
}
} while (--sanity > 0 && ((r == -1 && xp_is_blocking(xp_errno())) || (wsh->block && wrote < bytes)));
//if (r<0) {
//printf("wRITE FAIL: %s\n", strerror(errno));
//}
@@ -559,7 +559,7 @@ int establish_logical_layer(wsh_t *wsh)
if (code == 0) {
return -1;
}
if (code < 0) {
if (code == -1 && SSL_get_error(wsh->ssl, code) != SSL_ERROR_WANT_READ) {
return -1;
@@ -579,11 +579,11 @@ int establish_logical_layer(wsh_t *wsh)
}
} while (wsh->sanity > 0);
if (!wsh->sanity) {
return -1;
}
}
while (!wsh->down && !wsh->handshake) {
@@ -601,7 +601,7 @@ int establish_logical_layer(wsh_t *wsh)
}
wsh->logical_established = 1;
return 0;
}
@@ -662,7 +662,7 @@ void ws_destroy(wsh_t *wsh)
if (wsh->down > 1) {
return;
}
wsh->down = 2;
if (wsh->write_buffer) {
@@ -688,15 +688,15 @@ void ws_destroy(wsh_t *wsh)
}
ssize_t ws_close(wsh_t *wsh, int16_t reason)
ssize_t ws_close(wsh_t *wsh, int16_t reason)
{
if (wsh->down) {
return -1;
}
wsh->down = 1;
if (wsh->uri) {
free(wsh->uri);
wsh->uri = NULL;
@@ -724,7 +724,7 @@ ssize_t ws_close(wsh_t *wsh, int16_t reason)
wsh->sock = ws_sock_invalid;
return reason * -1;
}
@@ -743,7 +743,7 @@ uint64_t ntoh64(uint64_t val)
ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
{
ssize_t need = 2;
char *maskp;
int ll = 0;
@@ -778,7 +778,7 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
}
return ws_close(wsh, WS_PROTO_ERR);
}
if (wsh->datalen < need) {
if ((wsh->datalen += ws_raw_read(wsh, wsh->buffer + wsh->datalen, 9 - wsh->datalen, WS_BLOCK)) < need) {
/* too small - protocol err */
@@ -804,7 +804,7 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
{
int fin = (wsh->buffer[0] >> 7) & 1;
int mask = (wsh->buffer[1] >> 7) & 1;
if (!fin && *oc != WSOC_CONTINUATION) {
frag = 1;
@@ -814,7 +814,7 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
if (mask) {
need += 4;
if (need > wsh->datalen) {
/* too small - protocol err */
*oc = WSOC_CLOSE;
@@ -824,7 +824,7 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
wsh->plen = wsh->buffer[1] & 0x7f;
wsh->payload = &wsh->buffer[2];
if (wsh->plen == 127) {
uint64_t *u64;
int more = 0;
@@ -847,7 +847,7 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
}
u64 = (uint64_t *) wsh->payload;
wsh->payload += 8;
wsh->plen = ntoh64(*u64);
@@ -884,7 +884,7 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
if (need + blen > (ssize_t)wsh->bbuflen) {
void *tmp;
wsh->bbuflen = need + blen + wsh->rplen;
if ((tmp = realloc(wsh->bbuffer, wsh->bbuflen))) {
@@ -897,11 +897,11 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
}
wsh->rplen = wsh->plen - need;
if (wsh->rplen) {
memcpy(wsh->body, wsh->payload, wsh->rplen);
}
while(need) {
ssize_t r = ws_raw_read(wsh, wsh->body + wsh->rplen, need, WS_BLOCK);
@@ -915,7 +915,7 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
wsh->rplen += r;
need -= r;
}
if (mask && maskp) {
ssize_t i;
@@ -923,7 +923,7 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
wsh->body[i] ^= maskp[i % 4];
}
}
if (*oc == WSOC_PING) {
ws_write_frame(wsh, WSOC_PONG, wsh->body, wsh->rplen);
@@ -939,7 +939,7 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
}
*data = (uint8_t *)wsh->bbuffer;
//printf("READ[%ld][%d]-----------------------------:\n[%s]\n-------------------------------\n", wsh->packetlen, *oc, (char *)*data);
@@ -987,7 +987,7 @@ ssize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes)
hdr[1] = 127;
hlen += 8;
u64 = (uint64_t *) &hdr[2];
*u64 = hton64(bytes);
}
@@ -1002,17 +1002,17 @@ ssize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes)
abort();
}
}
bp = (uint8_t *) wsh->write_buffer;
memcpy(bp, (void *) &hdr[0], hlen);
memcpy(bp + hlen, data, bytes);
raw_ret = ws_raw_write(wsh, bp, (hlen + bytes));
if (raw_ret != (ssize_t) (hlen + bytes)) {
return raw_ret;
}
return bytes;
}
+3 -3
View File
@@ -9,7 +9,7 @@
#include <sys/types.h>
#ifndef _MSC_VER
#include <arpa/inet.h>
#include <sys/wait.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <unistd.h>
#else
@@ -25,7 +25,7 @@
//#include "sha1.h"
#include <openssl/ssl.h>
#if defined(_MSC_VER) || defined(__APPLE__) || defined(__FreeBSD__) || (defined(__SVR4) && defined(__sun))
#if defined(_MSC_VER) || defined(__APPLE__) || defined(__FreeBSD__) || (defined(__SVR4) && defined(__sun))
#define __bswap_64(x) \
x = (x>>56) | \
((x<<40) & 0x00FF000000000000) | \
@@ -137,7 +137,7 @@ int xp_is_blocking(int errcode);
#ifndef _MSC_VER
static inline uint64_t get_unaligned_uint64(const void *p)
{
{
const struct { uint64_t d; } __attribute__((packed)) *pp = p;
return pp->d;
}