示例#1
0
int main()
{
    
    char **cgivars;
    int i;
    char *action_event;
    int pid;
    char *action_name;
    char *process_filename;

    /** First, get the CGI variables into a list of strings **/
    cgivars = getcgivars();
 
    action_event = (char *) getvalue("action_event", cgivars);
    pid = atoi((char *) getvalue("pid", cgivars));
    action_name = (char *) getvalue("act_name", cgivars);
    process_filename = get_process_filename();
    peos_set_process_table_file(process_filename);
    peos_set_loginname(process_filename);
  

    if(strcmp(action_event, "Abort") == 0) {
        peos_notify(pid, action_name, PEOS_EVENT_ABORT);
	printf("Location: active_processes.cgi?action=continue\r\n\r\n");
    }
    

    if(strcmp(action_event, "Suspend") == 0) {
        peos_notify(pid, action_name, PEOS_EVENT_SUSPEND);
	printf("Location: active_processes.cgi?action=continue\r\n\r\n");
    }


    if(strcmp(action_event, "Run") == 0) {
	printf("Location: action_page.cgi?resource_type=requires&pid=%d&action_name=%s\r\n\r\n", pid, action_name);
    }
    
    
    if(strcmp(action_event, "Finish") == 0) {
	printf("Location: action_page.cgi?resource_type=provides&pid=%d&action_name=%s\r\n\r\n", pid, action_name);
    }
    
    
    /** Free anything that needs to be freed **/
    for (i=0; cgivars[i]; i++) free(cgivars[i]) ;
    free(cgivars) ;

    exit(0) ;    
}
示例#2
0
文件: shell.c 项目: jimiszm/peos
void run_action(int argc, char *argv[])
{
    char *action, *script;
    int pid; 
    vm_exit_code status;

    if (argc < 3) {
	printf("usage: %s pid action\n", argv[0]);
	return;
    }

    pid = atoi(argv[1]);
    action = argv[2];
    printf("Performing action %s\n", action);
    if ((status = peos_notify(pid, action, PEOS_EVENT_START)) == VM_ERROR 
	|| status == VM_INTERNAL_ERROR) {
	printf("process executed an illegal instruction and has been terminated\n");
    } 
    else {
	script = (char *) peos_get_script(pid, action);
	if (script) {
	    printf("%s\n", script);
	} 
	else {
	    printf("Error : Script Not Found");	
	}
    }
            
}
示例#3
0
文件: shell.c 项目: jimiszm/peos
void abort_action(int argc, char *argv[])
{
    char *action;
    int pid;
    vm_exit_code status;

    if (argc < 3) {
        printf("usage: %s pid action\n", argv[0]);
	return;
    }
    pid = atoi(argv[1]);
    action = argv[2];
    if ((status = peos_notify(pid, action,PEOS_EVENT_ABORT)) == VM_ERROR 
	|| status == VM_INTERNAL_ERROR) {
	printf("process encountered an illegal event and has been terminated\n");
    }
}
示例#4
0
文件: shell.c 项目: jimiszm/peos
void finish_action(int argc, char *argv[])
{
    char *action;
    int pid; 
    vm_exit_code status;

    if (argc < 3) {
	printf("usage: %s pid action\n", argv[0]);
	return;
    }
    pid = atoi(argv[1]);
    action = argv[2];
    printf("Performing action %s\n", action);
    if ((status = peos_notify(pid, action,PEOS_EVENT_FINISH)) == VM_ERROR 
	|| status == VM_INTERNAL_ERROR) {
	printf("process executed an illegal instruction and has been terminated\n");
    }
}
示例#5
0
文件: demo.c 项目: padraigoleary/PEOS
int
main (int argc, char **argv) {
    int status;
    char *pid;
    char *action;
    char *patientId;
	char *symptoms;
	char *bloodtest;
	
    //char *login = "******"; /* default login name */
    //char *request_method= getenv("REQUEST_METHOD") ;
    char **cgivars = getcgivars();

    setenv("COMPILER_DIR", ".", 1);

    //if (strcmp(request_method, "POST") == 0) {
	//set_login_name(login);
	action = getvalue("action", cgivars);
	patientId = getvalue("patientid", cgivars);

	if (strcmp(action, "sbmt_symptoms") == 0) {
	    symptoms = getvalue("symptoms", cgivars);

	    if (add_symptoms(symptoms) != 1) {
		fprintf(stderr, "Could not add symptoms\n");
		return -1;
	    }

	} else if (strcmp(action, "req_bloodtest") == 0) {
	    bloodtest = getvalue("bloodtest", cgivars);

	    if (peos_delete_process_instance(atoi(pid)) < 0) {
		fprintf(stderr, "Could not delete process instance\n");
		return -1;
	    }
	} else if (strcmp(action, "start") == 0) {
	    pid = getvalue("pid", cgivars);
	    action  = getvalue("action", cgivars);

	    if ((status = peos_notify(atoi(pid), action, PEOS_EVENT_START)) == VM_ERROR 
		|| (status == VM_INTERNAL_ERROR)) {
		fprintf(stderr, "unable to start action '%s' in process instance '%d'\n", action, atoi(pid));
		return -1;
	    }

	} else if (strcmp(action, "finish") == 0) {
	    pid = getvalue("pid", cgivars);
	    action  = getvalue("action", cgivars);

	    if ((status = peos_notify(atoi(pid), action,PEOS_EVENT_FINISH)) == VM_ERROR 
		|| status == VM_INTERNAL_ERROR) {
		fprintf(stderr, "process executed an illegal instruction and has been terminated\n");
		return -1;
	    }

	} else if (strcmp(action, "abort") == 0) {
	    pid = getvalue("pid", cgivars);
	    action  = getvalue("action", cgivars);

	    if ((status = peos_notify(atoi(pid), action,PEOS_EVENT_ABORT)) == VM_ERROR 
		|| status == VM_INTERNAL_ERROR) {
		fprintf(stderr, "process encountered an illegal event and has been terminated\n");
		return -1;
	    }

	} else if (strcmp(action, "suspend") == 0) {
	    pid = getvalue("pid", cgivars);
	    action  = getvalue("action", cgivars);

	    if ((status = peos_notify(atoi(pid), action,PEOS_EVENT_SUSPEND)) == VM_ERROR 
		|| status == VM_INTERNAL_ERROR) {
		fprintf(stderr, "process encountered an illegal event and has been terminated\n");
		return -1;
	    }
	}
    //}

    return_patient_record(patientId);
    return (0);
}