primitiveGSMNewState(void) { sqInt state; state = instantiateClassindexableSize(classByteArray(), gsmStateBytes()); gsmInitState(state + BaseHeaderSize); popthenPush(1, state); return 0; }
int dropRequestFileHandle(int dropIndex) { int fileHandle, wasBrowserMode; char *dropName = dropRequestFileName(dropIndex); if(!dropName) return interpreterProxy->nilObject(); fileHandle = instantiateClassindexableSize(classByteArray(), fileRecordSize()); wasBrowserMode = fBrowserMode; fBrowserMode = false; sqFileOpen(fileValueOf(fileHandle),(int)dropName, strlen(dropName), 0); fBrowserMode = wasBrowserMode; return fileHandle; }
int dropRequestFileHandle(int dropIndex) { char *path= dropRequestFileName(dropIndex); if (path) { // you cannot be serious? int handle= instantiateClassindexableSize(classByteArray(), fileRecordSize()); sqFileOpen((SQFile *)fileValueOf(handle), path, strlen(path), 0); return handle; } return interpreterProxy->nilObject(); }
/* RePlugin>>#allocateByteArrayAndSetRcvrPCREPtrFromPCRE: */ static sqInt allocateByteArrayAndSetRcvrPCREPtrFromPCRE(sqInt aPCREPtr) { void *patByteArrayPtr; sqInt patObject; /* Allocate a Smalltalk ByteArray -- lastAlloc contains the length */ patObject = instantiateClassindexableSize(classByteArray(), lastAlloc); /* begin loadRcvrFromStackAt: */ rcvr = stackObjectValue(0); patByteArrayPtr = arrayValueOf(patObject); memcpy(patByteArrayPtr, (void *) aPCREPtr, lastAlloc); /* begin rcvrPCREBufferFrom: */ storePointerofObjectwithValue(2, rcvr, patObject); return patObject; }
primitiveFileStdioHandles(void) { // FilePlugin>>#primitiveFileStdioHandles SQFile fileRecords[3]; sqInt index; sqInt result; sqInt validMask; if (sHFAfn != 0) { if (!( ((sqInt (*)(void))sHFAfn)())) { return primitiveFailFor(PrimErrUnsupported); } } validMask = sqFileStdioHandlesInto(fileRecords); if (validMask == 0) { return primitiveFailFor(PrimErrUnsupported); } result = instantiateClassindexableSize(classArray(), 3); if (result == null) { return primitiveFailFor(PrimErrNoMemory); } pushRemappableOop(result); for (index = 0; index <= 2; index += 1) { if ((validMask & (1 << index)) != 0) { result = instantiateClassindexableSize(classByteArray(), sizeof(SQFile)); if (result == null) { popRemappableOop(); return primitiveFailFor(PrimErrNoMemory); } storePointerofObjectwithValue(index, topRemappableOop(), result); memcpy(firstIndexableField(result), (&(fileRecords[index])), sizeof(SQFile)); } } # if COGMTVM fullGC(); # endif /* COGMTVM */ result = popRemappableOop(); popthenPush(1, result); }
primitiveAsyncFileOpen(void) { // AsynchFilePlugin>>#primitiveAsyncFileOpen AsyncFile *f; char *fileName; sqInt fileNameSize; sqInt fOop; sqInt okToOpen; sqInt semaIndex; sqInt writeFlag; success(isBytes(stackValue(2))); fileName = ((char *) (firstIndexableField(stackValue(2)))); writeFlag = booleanValueOf(stackValue(1)); semaIndex = stackIntegerValue(0); if (failed()) { return null; } /* If the security plugin can be loaded, use it to check for permission. If not, assume it's ok */ fileNameSize = slotSizeOf(((int) fileName) - 4); if (sCOAFfn != 0) { okToOpen = ((sqInt (*) (char *, sqInt, sqInt)) sCOAFfn)(fileName, fileNameSize, writeFlag); if (!okToOpen) { primitiveFail(); return null; } } fOop = instantiateClassindexableSize(classByteArray(), sizeof(AsyncFile)); f = asyncFileValueOf(fOop); if (!(failed())) { asyncFileOpen(f, (int)fileName, fileNameSize, writeFlag, semaIndex); } if (failed()) { return null; } popthenPush(4, fOop); return null; }
fileOpenNamesizewritesecure(char *nameIndex, sqInt nameSize, sqInt writeFlag, sqInt secureFlag) { // FilePlugin>>#fileOpenName:size:write:secure: SQFile *file; sqInt fileOop; sqInt okToOpen; fileOop = instantiateClassindexableSize(classByteArray(), sizeof(SQFile)); /* begin fileValueOf: */ if (!((isBytes(fileOop)) && ((byteSizeOf(fileOop)) == (sizeof(SQFile))))) { primitiveFail(); file = null; goto l1; } file = firstIndexableField(fileOop); l1: /* end fileValueOf: */; if (!(failed())) { if (secureFlag) { /* If the security plugin can be loaded, use it to check for permission. If not, assume it's ok */ if (sCOFfn != 0) { /* If the security plugin can be loaded, use it to check for permission. If not, assume it's ok */ okToOpen = ((sqInt (*) (char *, sqInt, sqInt)) sCOFfn)(nameIndex, nameSize, writeFlag); if (!okToOpen) { primitiveFail(); } } } } if (!(failed())) { sqFileOpen(file, nameIndex, nameSize, writeFlag); } return fileOop; }
/* RePlugin>>#allocateByteArrayAndSetRcvrExtraPtrFrom: */ static sqInt allocateByteArrayAndSetRcvrExtraPtrFrom(sqInt anExtraPtr) { void *extraByteArrayPtr; sqInt extraObject; extraByteArrayPtr = 0; if (anExtraPtr) { /* Allocate a Smalltalk ByteArray -- lastAlloc contains the length */ extraObject = instantiateClassindexableSize(classByteArray(), sizeof(real_pcre_extra)); /* begin loadRcvrFromStackAt: */ rcvr = stackObjectValue(0); extraByteArrayPtr = arrayValueOf(extraObject); memcpy(extraByteArrayPtr, (void *) anExtraPtr, sizeof(real_pcre_extra)); } else { extraObject = nilObject(); } /* begin rcvrExtraPtrFrom: */ storePointerofObjectwithValue(3, rcvr, extraObject); return extraObject; }