Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit ca614def authored by deuce's avatar deuce

Add *_TO_ASTRING() which uses alloca() but takes a max buf size argument

and trucates there.
parent 7fd1d2c1
......@@ -128,7 +128,7 @@ extern int thread_suid_broken; /* NPTL is no longer broken */
(ret)[JSSTSpos]=(char)JSSTSstrval[JSSTSpos]; \
(ret)[*JSSTSlenptr]=0; \
} \
else JS_ReportError(cx, "Error alocating %lu bytes at %s:%d", (*JSSTSlenptr)+1, getfname(__FILE__), __LINE__); \
else JS_ReportError(cx, "Error allocating %lu bytes at %s:%d", (*JSSTSlenptr)+1, getfname(__FILE__), __LINE__); \
} \
} \
}
......@@ -173,6 +173,36 @@ extern int thread_suid_broken; /* NPTL is no longer broken */
if(JS_IsExceptionPending(cx)) \
return JS_FALSE;
#define JSSTRING_TO_ASTRING(cx, str, ret, maxsize, lenptr) \
{ \
size_t *JSSTSlenptr=lenptr; \
size_t JSSTSlen; \
size_t JSSTSpos; \
const jschar *JSSTSstrval; \
\
if(JSSTSlenptr==NULL) \
JSSTSlenptr=&JSSTSlen; \
(ret)=NULL; \
if((str) != NULL) { \
if((JSSTSstrval=JS_GetStringCharsAndLength((cx), (str), JSSTSlenptr))) { \
if(*JSSTSlenptr >= maxsize) \
*JSSTSlenptr = maxsize-1; \
if(((ret)=(char *)alloca(*JSSTSlenptr+1))) { \
for(JSSTSpos=0; JSSTSpos<*JSSTSlenptr; JSSTSpos++) \
(ret)[JSSTSpos]=(char)JSSTSstrval[JSSTSpos]; \
(ret)[*JSSTSlenptr]=0; \
} \
else JS_ReportError(cx, "Error allocating %lu bytes on stack at %s:%d", (*JSSTSlenptr)+1, getfname(__FILE__), __LINE__); \
} \
} \
}
#define JSVALUE_TO_ASTRING(cx, val, ret, maxsize, lenptr) \
{ \
JSString *JSVTSstr=JS_ValueToString((cx), (val)); \
JSSTRING_TO_ASTRING((cx), JSVTSstr, (ret), (maxsize), (lenptr)); \
}
#define JSSTRING_TO_STRING(cx, str, ret, lenptr) \
{ \
size_t *JSSTSlenptr=lenptr; \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment