本文整理汇总了C++中IONIL函数的典型用法代码示例。如果您正苦于以下问题:C++ IONIL函数的具体用法?C++ IONIL怎么用?C++ IONIL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IONIL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: IoDate_newWithTime_
IoObject *IoCertificate_asnTimeToDate(IoCertificate *self, ASN1_TIME *tm)
{
char *v;
int gmt=0;
int i;
int y=0,M=0,d=0,h=0,m=0,s=0;
i=tm->length;
v=(char *)tm->data;
if (i < 10) return IONIL(self);
if (v[i-1] == 'Z') gmt=1;
for (i=0; i<10; i++)
if ((v[i] > '9') || (v[i] < '0')) return IONIL(self);
y= (v[0]-'0')*10+(v[1]-'0');
if (y < 50) y+=100;
M= (v[2]-'0')*10+(v[3]-'0');
if ((M > 12) || (M < 1)) return IONIL(self);
d= (v[4]-'0')*10+(v[5]-'0');
h= (v[6]-'0')*10+(v[7]-'0');
m= (v[8]-'0')*10+(v[9]-'0');
if ( (v[10] >= '0') && (v[10] <= '9') &&
(v[11] >= '0') && (v[11] <= '9'))
s= (v[10]-'0')*10+(v[11]-'0');
struct tm ctm;
ctm.tm_sec = s;
ctm.tm_min = m;
ctm.tm_hour = h;
ctm.tm_mday = d;
ctm.tm_mon = M-1;
ctm.tm_year = y;
ctm.tm_gmtoff = 0;
return IoDate_newWithTime_(IoObject_state(self), timegm(&ctm));
}
开发者ID:anthem,项目名称:io,代码行数:35,代码来源:IoCertificate.c
示例2: IoMessage_locals_valueArgAt_
IoObject *IoDBI_with(IoDBI *self, IoObject *locals, IoMessage *m)
{
//doc DBI with(driverName) Get a new connection with the given driver.
IoObject *name = IoMessage_locals_valueArgAt_(m, locals, 0);
if (!ISSYMBOL(name))
{
IoState_error_(IOSTATE, m, "argument 0 to method '%s' must be a Symbol, not a '%s'\n",
CSTRING(IoMessage_name(m)), IoObject_name(name));
return IONIL(self);
}
if (DATA(self)->didInit != 1)
{
IoDBI_init(self, locals, m);
}
dbi_conn c = dbi_conn_new(CSTRING(name));
if (c == NULL)
{
IoState_error_(IOSTATE, m, "libdbi error during dbi_conn_new\n");
return IONIL(self);
}
return IoDBIConn_new(IOSTATE, c);
}
开发者ID:BMeph,项目名称:io,代码行数:26,代码来源:IoDBI.c
示例3: OCTX
IoSecureServer *IoSecureServer_setCRLFile(IoSecureServer *self, IoObject *locals, IoMessage *msg)
{
SSL_CTX *ctx = OCTX(self);
IoSeq *pathSeq = IoMessage_locals_seqArgAt_(msg, locals, 0);
char *path = IoSeq_asCString(pathSeq);
if(ctx == NULL)
{
IoState_error_(IOSTATE, msg, "SecureServer has no SSL_CTX");
return IONIL(self);
}
X509_STORE *store = SSL_CTX_get_cert_store(ctx);
X509_STORE_set_verify_cb_func(store, IoSecureSockets_Verify_CRL_Callback);
X509_STORE_set_flags (store, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
X509_LOOKUP *lookup;
if (!(lookup = X509_STORE_add_lookup (store, X509_LOOKUP_file ())))
{
ERR_print_errors_fp(stderr);
IoState_error_(IOSTATE, msg, "Error creating X509_LOOKUP object.");
return IONIL(self);
}
if (X509_load_crl_file(lookup, path, X509_FILETYPE_PEM) != 1)
{
ERR_print_errors_fp(stderr);
IoState_error_(IOSTATE, msg, "Error loading CRL from file %s\n", path);
return IONIL(self);
}
return self;
}
开发者ID:ADTSH,项目名称:io,代码行数:29,代码来源:IoSecureServer.c
示例4: DynLib_pointerForSymbolName_
IoDynLib *IoDynLib_callPluginInitFunc(IoDynLib *self, IoObject *locals, IoMessage *m)
{
/*doc DynLib callPluginInit(functionName)
Call's the dll function of the specified name.
Returns the result as a Number or raises an exception on error.
*/
intptr_t rc = 0;
intptr_t *params = NULL;
void *f = DynLib_pointerForSymbolName_(DATA(self),
CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 0)));
if (f == NULL)
{
IoState_error_(IOSTATE, m, "Error resolving call '%s'.",
CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 0)));
return IONIL(self);
}
if (IoMessage_argCount(m) < 1)
{
IoState_error_(IOSTATE, m, "Error, you must give an init function name to check for.");
return IONIL(self);
}
params = io_calloc(1, sizeof(intptr_t) * 2);
params[0] = (intptr_t)IOSTATE;
params[1] = (intptr_t)IOSTATE->lobby;
rc = ((intptr_t (*)(intptr_t, intptr_t))f)(params[0], params[1]);
io_free(params);
return IONUMBER(rc);
}
开发者ID:Habaut,项目名称:GameBindings,代码行数:33,代码来源:IoDynLib.c
示例5: IoRegex_rawRegex
static IoRegexMatch *IoRegexMatches_searchFrom_withOptions_(IoRegexMatches *self, IoMessage *m, int position, int options)
{
Regex *regex = IoRegex_rawRegex(DATA(self)->regex);
int *captures = 0;
int *capture = 0;
IoList *rangeList = 0;
int i = 0;
int captureCount = Regex_search_from_to_withOptions_captureArray_(
regex,
CSTRING(DATA(self)->string),
position,
DATA(self)->endPosition,
options,
DATA(self)->captureArray
);
if (Regex_error(regex))
IoState_error_(IOSTATE, m, Regex_error(regex));
if (captureCount == 0)
return IONIL(self);
/* The search function puts information about captured substrings in captureArray.
There's a pair of integers for each capture. The first element of the pair is the
start index of the substring, and the second element is the end index.
The first pair represents the entire match. */
captures = (int *)UArray_data(DATA(self)->captureArray);
DATA(self)->position = captures[1];
DATA(self)->currentMatchIsEmpty = (captures[0] == captures[1]);
capture = captures;
rangeList = IoList_new(IOSTATE);
for (i = 0; i < captureCount; i++) {
IoObject *element = 0;
// unsure about this locals initialization ...
IoObject *locals = NULL;
IoMessage *message = IoMessage_new(IOSTATE);
if (capture[0] == -1 && capture[1] == -1) {
/* This capture was not matched. */
element = IONIL(self);
} else {
element = IoRange_new(IOSTATE);
IoMessage_setCachedArg_to_(message, 0, IONUMBER(capture[0]));
IoMessage_setCachedArg_to_(message, 1, IONUMBER(capture[1]));
IoRange_setRange(element, locals, message);
IoRange_setFirst(element, IONUMBER(capture[0]));
IoRange_setLast(element, IONUMBER(capture[1]));
}
IoList_rawAppend_(rangeList, element);
capture += 2;
}
return IoRegexMatch_newWithRegex_subject_captureRanges_(IOSTATE, DATA(self)->regex, DATA(self)->string, rangeList);
}
开发者ID:ADTSH,项目名称:io,代码行数:57,代码来源:IoRegexMatches.c
示例6: IO_METHOD
IO_METHOD(IoNumber, asCharacter)
{
/*doc Number asCharacter
Returns a String containing a single character whose
value is the value of the first byte of the receiver.
Returns nil if the number has no valid UCS mapping.
*/
double d =DATA(self);
long ld = d;
if (d < 0 || d != ld)
{
return IONIL(self);
}
else
{
uint32_t i = io_uint32InBigEndian((uint32_t)d);
int bytes = countBytes(ld);
IoSeq *s;
if (bytes == 0)
{
bytes = 1;
}
if (bytes == 3)
{
bytes = 4;
}
if (bytes > 4)
{
// no valid UCS encoding for this value
return IONIL(self);
}
s = IoSeq_newWithData_length_(IOSTATE, (unsigned char *)&i, bytes);
{
UArray *u = IoSeq_rawUArray(s);
int e = CENCODING_ASCII;
switch (bytes)
{
case 1: e = CENCODING_ASCII; break;
case 2: e = CENCODING_UCS2; break;
case 4: e = CENCODING_UCS4; break;
}
UArray_setEncoding_(u, e);
}
return s;
}
}
开发者ID:Akiyah,项目名称:io,代码行数:56,代码来源:IoNumber.c
示例7: Output
IoObject *IoAVCodec_decode(IoAVCodec *self, IoObject *locals, IoMessage *m)
{
/*doc AVCodec decode
Decodes the next chunk of input data.
Output (if any) is placed in the outputBuffers.
Returns self.
*/
AVFormatContext *formatContext = DATA(self)->formatContext;
int audioStreamIndex = DATA(self)->audioStreamIndex;
int videoStreamIndex = DATA(self)->videoStreamIndex;
AVPacket *packet = DATA(self)->packet;
int ret;
if(DATA(self)->audioContext == NULL && DATA(self)->videoContext == NULL)
{
//printf("not open\n");
return IONIL(self);
}
ret = av_read_frame(formatContext, packet);
if (ret < 0)
{
//printf("av_read_frame ret = %i\n", ret);
if(ret == AVERROR_IO)
{
DATA(self)->isAtEnd = 1;
}
return IONIL(self);
}
if (packet->stream_index == audioStreamIndex && DATA(self)->audioContext)
{
IoAVCodec_decodeAudioPacket(self,
formatContext->streams[audioStreamIndex]->codec,
packet->data, packet->size);
}
else if (packet->stream_index == videoStreamIndex && DATA(self)->videoContext)
{
IoAVCodec_decodeVideoPacket(self,
formatContext->streams[videoStreamIndex]->codec,
packet->data, packet->size);
}
else
{
av_free_packet(packet);
}
return self;
}
开发者ID:BMeph,项目名称:io,代码行数:54,代码来源:IoAVCodec.c
示例8: IO_METHOD
IO_METHOD(IoMessage, previous)
{
/*doc Message previous
Returns the previous message in the message chain or Nil if there is no previous message.
*/
#ifdef IOMESSAGE_HASPREV
return DATA(self)->previous ? (IoObject *)DATA(self)->previous : IONIL(self);
#else
return IONIL(self);
#endif
}
开发者ID:mikedouglas,项目名称:io,代码行数:12,代码来源:IoMessage.c
示例9: IoMessage_locals_intArgAt_
IoObject *IoCairoPathElement_pointAt(IoCairoPathElement *self, IoObject *locals, IoMessage *m)
{
cairo_path_data_t *data = 0;
int pointCount = 0;
int i = 0;
if (!DATA(self)) return IONIL(self);
i = IoMessage_locals_intArgAt_(m, locals, 0);
pointCount = IoCairoPathElement_pointCount(self);
if (i < 0 || i >= pointCount) return IONIL(self);
data = PATH_DATA(self) + i + 1;
return IoSeq_newWithX_y_(IOSTATE, data->point.x, data->point.y);
}
开发者ID:cdcarter,项目名称:io,代码行数:15,代码来源:IoCairoPathElement.c
示例10: IoMessage_locals_addressArgAt_
IoObject *IoSocket_asyncUdpRead(IoSocket *self, IoObject *locals, IoMessage *m)
{
/*doc Socket asyncUdpRead(ipAddress, aSeq, readSize)
Reads up to readSize number of bytes from ipAddress into aSeq if data is available.
Returns self immediately if successful. Returns an error object on Error. Returns nil if the socket is disconnected.
*/
IoObject *address = IoMessage_locals_addressArgAt_(m, locals, 0);
UArray *buffer = IoSeq_rawUArray(IoMessage_locals_mutableSeqArgAt_(m, locals, 1));
size_t readSize = IoMessage_locals_sizetArgAt_(m, locals, 2);
if (Socket_udpRead(SOCKET(self), IoSocket_rawAddressFrom_(address), buffer, readSize))
{
return self;
}
else
{
if (Socket_asyncFailed())
{
return SOCKETERROR("Socket udp read failed");
}
else
{
return IONIL(self);
}
}
}
开发者ID:BMeph,项目名称:io,代码行数:27,代码来源:IoSocket.c
示例11: IO_METHOD
IO_METHOD(IoFile, contents)
{
/*doc File contents
Returns contents of the file as a mutable Sequence of bytes.
*/
UArray *ba = UArray_new();
long result = -1;
if (DATA(self)->stream == stdin)
{
result = UArray_readFromCStream_(ba, DATA(self)->stream);
}
else
{
result = UArray_readFromFilePath_(ba, IoSeq_rawUArray(DATA(self)->path));
}
if (result != -1)
{
return IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
}
else
{
UArray_free(ba);
IoState_error_(IOSTATE, m, "unable to read file '%s'", UTF8CSTRING(DATA(self)->path));
}
return IONIL(self);
}
开发者ID:achoy,项目名称:io,代码行数:30,代码来源:IoFile.c
示例12: IO_METHOD
IO_METHOD(IoSeq, asBinarySignedInteger)
{
/*doc Sequence asBinarySignedInteger
Returns a Number with the bytes of the receiver interpreted as a binary signed integer. Endian is same as machine.
*/
const void *bytes = UArray_bytes(DATA(self));
size_t byteCount = UArray_size(DATA(self));
if(byteCount == 1)
{
return IONUMBER(*((const int8_t *)bytes));
}
else if(byteCount == 2)
{
return IONUMBER(*((const int16_t *)bytes));
}
else if(byteCount == 4)
{
return IONUMBER(*((const int32_t *)bytes));
}
else
{
IoState_error_(IOSTATE, m, "Sequence is %i bytes but only conversion of 1, 2, or 4 bytes is supported", byteCount);
}
return IONIL(self);
}
开发者ID:doublec,项目名称:io,代码行数:28,代码来源:IoSeq_immutable.c
示例13: IoMessage_locals_valueArgAt_
IoObject *IoMessage_locals_addressArgAt_(IoMessage *self, IoObject *locals, int n)
{
IoObject *v = IoMessage_locals_valueArgAt_(self, locals, n);
if(ISIPADDRESS(v))
{
return v;
}
#if !defined(_WIN32) || defined(__CYGWIN__)
else if(ISUNIXPATH(v))
{
return v;
}
#endif
else
{
#if !defined(_WIN32) || defined(__CYGWIN__)
char *type = "IPAddress or UnixPath";
#else
char *type = "IPAddress";
#endif
IoMessage_locals_numberArgAt_errorForType_(self, locals, n, type);
}
return IONIL(self);
}
开发者ID:BMeph,项目名称:io,代码行数:26,代码来源:IoSocket.c
示例14: CNUMBER
IoCFFIArray *IoCFFIArray_atPut(IoCFFIArray *self, IoObject *locals, IoMessage *m)
{
int pos;
IoObject *value, *arrayType, *d;
char *ptr;
pos = CNUMBER(IoMessage_locals_numberArgAt_(m, locals, 0));
value = IoMessage_locals_valueArgAt_(m, locals, 1);
if ( pos >= DATA(self)->arraySize ) {
IoState_error_(IOSTATE, m, "index out of bounds");
return IONIL(self);
}
arrayType = IoObject_getSlot_(self, IOSYMBOL("arrayType"));
ptr = ((char *)DATA(self)->buffer) + (DATA(self)->itemSize * pos);
d = IOCLONE(arrayType);
IoCFFIDataType_rawSetValue(d, value);
memcpy(ptr, (void *)IoCFFIDataType_ValuePointerFromObject_(self, d), DATA(self)->itemSize);
if ( DATA(self)->keepValuesRefs ) {
DATA(self)->keepValuesRefs[pos] = IOREF(d);
}
return self;
}
开发者ID:bomma,项目名称:io,代码行数:27,代码来源:IoCFFIArray.c
示例15: IONIL
IoObject *IoRegexMatches_next(IoRegexMatches *self, IoObject *locals, IoMessage *m)
{
/*doc RegexMatches next
Returns the next match, or nil if there is none.
*/
IoRegexMatch *match = 0;
if (DATA(self)->position >= DATA(self)->endPosition)
/* We've passed the end position, so we're done. */
return IONIL(self);
if (!DATA(self)->currentMatchIsEmpty)
/* The previous match was not a zero length match, so we can just continue searching
from the end of that match. */
return IoRegexMatches_search(self, m);
/* The last match was a zero length match. If we just continue searching as normal,
we'll get the same empty match again, and we'll end up in an infinite loop when trying
to iterate through all matches. Instead we try to find an alternative match by performing
a search using the options PCRE_NOTEMPTY and PCRE_ANCHORED: */
match = IoRegexMatches_searchWithOptions_(self, m, PCRE_NOTEMPTY | PCRE_ANCHORED);
if (!ISNIL(match))
return match;
/* No alternative match was found, so we do what Perl does: we advance our position
by one character, and continue searching from there: */
++DATA(self)->position;
return IoRegexMatches_search(self, m);
}
开发者ID:ADTSH,项目名称:io,代码行数:29,代码来源:IoRegexMatches.c
示例16: IOCB
IoObject *IoAsyncRequest_write(IoAsyncRequest *self, IoObject *locals, IoMessage *m)
{
/*doc AsyncRequest write(fileOffset, aSeq, bufferOffset, numberOfBytesToWrite)
Submits an async write request. Returns nil on error, self otherwise.
*/
int r;
IoSeq *data;
UArray *ba;
int bufferOffset;
int bytesToWrite;
IOCB(self)->aio_offset = (size_t)CNUMBER(IoMessage_locals_numberArgAt_(m, locals, 0));
data = IoMessage_locals_seqArgAt_(m, locals, 1);
ba = IoSeq_rawUArray(data);
bufferOffset = IoMessage_locals_intArgAt_(m, locals, 2);
bytesToWrite = IoMessage_locals_intArgAt_(m, locals, 3);
if (bytesToWrite > UArray_size(ba) - bufferOffset)
{
bytesToWrite = UArray_size(ba) - bufferOffset;
}
IOCB(self)->aio_nbytes = bytesToWrite;
IOCB(self)->aio_buf = realloc(IOCB_BUFFER(self), bytesToWrite);
memcpy(IOCB_BUFFER(self), UArray_bytes(ba), bytesToWrite);
r = aio_write(IOCB(self));
return r == 0 ? self : IONIL(self);
}
开发者ID:Akiyah,项目名称:io,代码行数:33,代码来源:IoAsyncRequest.c
示例17: IoObject_getSlot_
IoObject *IoTokyoCabinetPrefixCursor_key(IoObject *self, IoObject *locals, IoMessage *m)
{
/*doc TokyoCabinetPrefixCursor key
Returns current cursor key or nil.
*/
int size;
char *ks;
IoSeq *prefix = IoObject_getSlot_(self, IOSYMBOL("prefix"));
IOASSERT(ISSEQ(prefix), "prefix must be a sequence");
IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
ks = tcbdbcurkey(TokyoCabinetPrefixCursor(self), &size);
if (ks)
{
UArray *k = UArray_newWithData_type_size_copy_(ks, CTYPE_uint8_t, size, 1);
if (UArray_beginsWith_(k, IoSeq_rawUArray(prefix)))
{
//printf("prefix '%s'\n", UArray_bytes(IoSeq_rawUArray(prefix)));
//printf("before clip '%s'\n", UArray_bytes(k));
UArray_clipBeforeEndOf_(k, IoSeq_rawUArray(prefix));
UArray_removeFirst(k); // remove separator
//printf("after clip '%s'\n", UArray_bytes(k));
return IoSeq_newWithUArray_copy_(IOSTATE, k, 0);
}
UArray_free(k);
}
return IONIL(self);
}
开发者ID:ADTSH,项目名称:io,代码行数:33,代码来源:IoTokyoCabinetPrefixCursor.c
示例18: IO_METHOD
IO_METHOD(IoSandbox, doSandboxString)
{
/*doc Sandbox doSandboxString(aString)
Evaluate aString inside the Sandbox.
*/
IoState *boxState = IoSandbox_boxState(self);
char *s = IoMessage_locals_cStringArgAt_(m, locals, 0);
IoObject *result = IoState_doSandboxCString_(boxState, s);
if (ISSYMBOL(result))
{
return IOSYMBOL(CSTRING(result));
}
if (ISSEQ(result))
{
return IOSEQ(IOSEQ_BYTES(result), IOSEQ_LENGTH(result));
}
if (ISNUMBER(result))
{
return IONUMBER(CNUMBER(result));
}
return IONIL(self);
}
开发者ID:Habaut,项目名称:GameBindings,代码行数:28,代码来源:IoSandbox.c
示例19: IO_METHOD
IO_METHOD(IoObject, errorNumberDescription)
{
/*doc System errorNumber
Returns the C errno string.
*/
return errno ? IOSYMBOL(strerror(errno)) : IONIL(self);
}
开发者ID:Habaut,项目名称:GameBindings,代码行数:7,代码来源:IoSystem.c
示例20: IoAVCodec_registerIfNeeded
IoObject *IoAVCodec_open(IoAVCodec *self, IoObject *locals, IoMessage *m)
{
/*doc AVCodec open
Opens the input file. Return self on success or raises an exception on error.
*/
int err;
IoAVCodec_registerIfNeeded(self);
IoAVCodec_freeContextIfNeeded(self);
IoAVCodec_createContextIfNeeded(self);
DATA(self)->isAtEnd = 0;
err = IoAVCodec_openFile(self);
if (err != 0)
{
IoObject *fileName = IoObject_symbolGetSlot_(self, IOSYMBOL("path"));
IoState_error_(IOSTATE, m, "error %i opening file %s\n", err, CSTRING(fileName));
return IONIL(self);
}
IoAVCodec_findStreams(self);
av_read_play(DATA(self)->formatContext);
return self;
}
开发者ID:BMeph,项目名称:io,代码行数:28,代码来源:IoAVCodec.c
注:本文中的IONIL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论