/** * Initializes a DataInputStream. * * @param dis the DataInputStream to initialize * @param file the name of the file to initialize the stream from */ void DataInputStream_open(DataInputStream *dis, const char *file) { (*dis).size = getFileSize(file); if ((*dis).size == -1) { fprintf(stderr, "No such file '%s'\n", file); stopVM(-1); } // Note: the default way to allocate memory written by zeni (*dis).in = newBuffer((*dis).size, "DataInputStream_open", true); // Note: modified way to allocate memory written by zeni //(*dis).in = memget(sizeof(char)*(*dis).size); if (readFile(file, (*dis).in, (*dis).size) != (*dis).size) { printf("Error reading '%s'\n", file); stopVM(-1); } (*dis).pos = 0; }
void new_DataInputStream_open(DataInputStream *dis, unsigned char * fileArray, unsigned int size) { (*dis).size = size; if ((*dis).size == -1) { // fprintf(stderr, "No such file '%s'\n", fileArray); stopVM(-1); } //(*dis).in = newBuffer((*dis).size, "DataInputStream_open", true); //strcpy(fileArray, (*dis).in); //strncpy((*dis).in, fileArray, size); (*dis).in = (ByteAddress)fileArray; //snprintf((*dis).in, size, "%s", fileArray); (*dis).pos = 0; }
void ProxygenServer::doShutdown() { switch(m_shutdownState) { case ShutdownState::SHUTDOWN_NONE: // Transition from SHUTDOWN_NONE to DRAINING_READS needs to happen // explicitly through `stopListening`, not here. not_reached(); break; case ShutdownState::DRAINING_READS: // Even though connections may be open for reading, they will not be // executed in the VM stopVM(); break; case ShutdownState::STOPPING_VM: // this is a no-op, and can happen when we triggered VM shutdown from // the timeout code path, but the connections drain while waiting for // shutdown. We let the VM shutdown continue and it will advance us // to the next state. break; case ShutdownState::DRAINING_WRITES: forceStop(); break; } }