bool MPPS_SCP_EMULATOR_CLASS::processCommandDataset(DCM_COMMAND_CLASS *command_ptr, DCM_DATASET_CLASS *dataset_ptr) // DESCRIPTION : Process the Storage command and dataset. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { bool result; // handle individual commands switch(command_ptr->getCommandId()) { case DIMSE_CMD_NCREATE_RQ: if (dataset_ptr) { // process the CREATE command result = processCreate(dataset_ptr); } else { // missing dataset UINT16 status = DCM_STATUS_PROCESSING_FAILURE; result = sendResponse(DIMSE_CMD_NCREATE_RSP, status); } break; case DIMSE_CMD_NSET_RQ: if (dataset_ptr) { // process the SET command result = processSet(dataset_ptr); } else { // missing dataset UINT16 status = DCM_STATUS_PROCESSING_FAILURE; result = sendResponse(DIMSE_CMD_NSET_RSP, status); } break; default: { // unknown command UINT16 status = DCM_STATUS_UNRECOGNIZED_OPERATION; result = sendResponse(command_ptr->getCommandId(), status); } break; } // return result return result; }
Process* _createProcess(Process *plist, int ppid, int prio) { RRPrioParams *rrp; printf("Criando processo... "); plist = processCreate(plist); rrp = malloc(sizeof (RRPrioParams)); rrp->prio = prio; rrpInitSchedParams(plist, rrp); processSetStatus(plist, PROC_READY); processSetParentPid(plist, ppid); printf(" Criado PID %d!\n", processGetPid(plist)); return plist; }
/** * FUNCTION NAME: checkMessages * * DESCRIPTION: This function is the message handler of this node. * This function does the following: * 1) Pops messages from the queue * 2) Handles the messages according to message types */ void MP2Node::checkMessages() { /* * Implement this. Parts of it are already implemented */ char * data; int size; /* * Declare your local variables here */ // dequeue all messages and handle them while ( !memberNode->mp2q.empty() ) { /* * Pop a message from the queue */ data = (char *)memberNode->mp2q.front().elt; size = memberNode->mp2q.front().size; memberNode->mp2q.pop(); string message(data, data + size); /* * Handle the message types here */ cout << "Got message = " << message << endl; Message incoming_msg(message); //convert the message in string form to Message type //check for message type and call their handlers accordingly. switch(incoming_msg.type) { case CREATE : {processCreate(incoming_msg); break;} case READ : {processRead(incoming_msg); break;} case REPLY : {processNodesReply(incoming_msg); break;} case READREPLY : {processReadReply(incoming_msg);break;} case DELETE : {processDelete(incoming_msg); break;} case UPDATE : {processUpdate(incoming_msg); break;} default : {} } } // At the end check the acks or nacks that this node may have received from the reply messages from the nodes to // whom this node may sent the client CRUD message checkReplyMessages(); /* * This function should also ensure all READ and UPDATE operation * get QUORUM replies */ }
int main(int argc, char *argv[]) { ServerArguments arguments; // Arguments parser. if (serverArgumentsCreate(&arguments, argc, argv) == ERROR) { return ERROR; } File file; if (fileCreate(&file, serverArgumentsFileRoute(&arguments)) == ERROR) { return ERROR; } int sesion_id = ONE; while (!feof(fileAsociatedFile(&file))) { long line_length = fileLineLengthCount(&file); char buffer[line_length + ONE]; fileReadLine(&file, buffer, (int)line_length + ONE); Process process; processCreate(&process, buffer, sesion_id); sesion_id++; } // Create server. Server server; if (serverCreate(&server) == ERROR) { return ERROR; } if (serverOpen(&server, serverArgumentsPort(&arguments)) == ERROR) { return ERROR; } Socket new_sock = serverAccept(&server); if (new_sock.sockfd == ERROR) { return ERROR; } if (socketSend(&new_sock, NULL) == ERROR) { return ERROR; } serverArgumentsDestroy(&arguments); serverDestroy(&server); socketDestroy(&new_sock); fileDestroy(&file); return ZERO; }
JNIEXPORT jlong JNICALL Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored, jstring cmd, jstring envBlock, jstring dir, jlongArray stdHandles, jboolean redirectErrorStream) { jlong ret = 0; if (cmd != NULL && stdHandles != NULL) { const jchar *pcmd = (*env)->GetStringChars(env, cmd, NULL); if (pcmd != NULL) { const jchar *penvBlock = (envBlock != NULL) ? (*env)->GetStringChars(env, envBlock, NULL) : NULL; if (!(*env)->ExceptionCheck(env)) { const jchar *pdir = (dir != NULL) ? (*env)->GetStringChars(env, dir, NULL) : NULL; if (!(*env)->ExceptionCheck(env)) { jlong *handles = (*env)->GetLongArrayElements(env, stdHandles, NULL); if (handles != NULL) { ret = processCreate( env, pcmd, penvBlock, pdir, handles, redirectErrorStream); (*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0); } if (pdir != NULL) (*env)->ReleaseStringChars(env, dir, pdir); } if (penvBlock != NULL) (*env)->ReleaseStringChars(env, envBlock, penvBlock); } (*env)->ReleaseStringChars(env, cmd, pcmd); } } return ret; }
STDMETHODIMP GuestSessionWrap::ProcessCreate(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment), ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, IGuestProcess **aGuestProcess) { LogRelFlow(("{%p} %s:enter aCommand=%ls aArguments=%zu aEnvironment=%zu aFlags=%zu aTimeoutMS=%RU32 aGuestProcess=%p\n", this, "GuestSession::processCreate", aCommand, aArguments, aEnvironment, aFlags, aTimeoutMS, aGuestProcess)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aGuestProcess); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = processCreate(BSTRInConverter(aCommand).str(), ArrayBSTRInConverter(ComSafeArrayInArg(aArguments)).array(), ArrayBSTRInConverter(ComSafeArrayInArg(aEnvironment)).array(), ArrayInConverter<ProcessCreateFlag_T>(ComSafeArrayInArg(aFlags)).array(), aTimeoutMS, ComTypeOutConverter<IGuestProcess>(aGuestProcess).ptr()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave aGuestProcess=%p hrc=%Rhrc\n", this, "GuestSession::processCreate", *aGuestProcess, hrc)); return hrc; }
void SerialPortWorker::processCommand(Command command) { // qDebug() << "Method name"; switch (command.type) { case CT_create: processCreate(command.num); break; case CT_connect: processConnect(command.num); break; case CT_basicPosture: processBasicPosture(command.num); break; case CT_DCOn: processDCOn(command.num); break; case CT_setPose: processSetPose(command.num, command.angles); break; case CT_DCOff: processDCOff(command.num); break; case CT_disconnect: processDisconnect(command.num); break; // default: // break; } }
bool PRINT_SCP_EMULATOR_CLASS::processCommandDataset(DCM_COMMAND_CLASS *command_ptr, DCM_DATASET_CLASS *dataset_ptr) // DESCRIPTION : Process the Print command (and dataset). // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { bool result; // handle individual commands switch(command_ptr->getCommandId()) { case DIMSE_CMD_NACTION_RQ: // process the ACTION command result = processAction(command_ptr->getEncodePresentationContextId()); break; case DIMSE_CMD_NCREATE_RQ: if ((sopClassUidM == FILM_SESSION_SOP_CLASS_UID) || (dataset_ptr)) { // process the CREATE command // - Basic Film Session may not define a dataset - but that is OK result = processCreate(command_ptr->getEncodePresentationContextId(), dataset_ptr); } else { // missing dataset UINT16 status = DCM_STATUS_PROCESSING_FAILURE; result = sendResponse(DIMSE_CMD_NCREATE_RSP, command_ptr->getEncodePresentationContextId(), status); } break; case DIMSE_CMD_NDELETE_RQ: // process the DELETE command result = processDelete(command_ptr->getEncodePresentationContextId()); break; case DIMSE_CMD_NEVENTREPORT_RSP: // nothing to do here result = true; break; case DIMSE_CMD_NGET_RQ: // process the GET command result = processGet(command_ptr); break; case DIMSE_CMD_NSET_RQ: if (dataset_ptr) { // process the SET dataset result = processSet(command_ptr->getEncodePresentationContextId(), dataset_ptr); } else { // missing dataset UINT16 status = DCM_STATUS_PROCESSING_FAILURE; result = sendResponse(DIMSE_CMD_NSET_RSP, command_ptr->getEncodePresentationContextId(), status); } break; default: { // unknown command UINT16 status = DCM_STATUS_UNRECOGNIZED_OPERATION; result = sendResponse(command_ptr->getCommandId(), command_ptr->getEncodePresentationContextId(), status); } break; } // return result return result; }