Beispiel #1
0
void process_pull_msg(zmq_msg_t * payload_msg) {
	char * type = NULL;

	json_t * payload = json_loadb(zmq_msg_data(payload_msg),
		zmq_msg_size(payload_msg), 0, NULL);
	if(payload == NULL)
		return;

	if(get_values(payload,
		"type", JSON_STRING, 1, &type,
		NULL) != 0) {
		json_decref(payload);
		return;
	}

	if(strcmp(type, "command") == 0)
		process_cmd(payload);
	else if(strcmp(type, "host_check_processed") == 0 ||
		strcmp(type, "service_check_processed") == 0)
		process_status(payload);
	else if(strcmp(type, "acknowledgement") == 0)
		process_acknowledgement(payload);
	else if(strcmp(type, "comment_add") == 0)
		process_comment(payload);
	else if(strcmp(type, "downtime_add") == 0)
		process_downtime(payload);
	else if(strcmp(type, "state_data") == 0)
		process_bulkstate(payload);
	return;
}
Beispiel #2
0
void process_token(char *tok, struct program *prog){
	
	if(check_comment(tok, prog)){
		process_comment(tok);
	}
	else{
		
		// must be a variable
		process_definition(tok, prog);
	}
}
Beispiel #3
0
/**
* Given the first token to an input line, will attempt to parse it and
* process the related instruction.
*
* @param tok 		The first token on the input line, this is expected to be
* 					a clean (non-whitespace) token.
* @param program 	Contains all current program information gathered so far,
* 					primarily used for error reporting.
*/
void process_token(char *tok, struct program *program){

	// check for comments
	if(check_comment(tok, program)){
		process_comment(program);
		return;
	}

	// process constant definitions
	else if(check_const_def(tok, program)){
		process_const_def(tok, program);
		return;
	}

	// Function definitions
	else if(check_func_def(tok, program)){
		process_func_def(tok, program);
		return;
	}
	
	// check if we have a label
	else if(check_label_def(tok, program)){
		process_label_def(tok, program);
		return;
	}

	// the first token should contain our instruction
	else if(!strcmp(tok, "HALT")){
		process_instruction(program, HALT, HALT_F , 0);
	}
	else if(!strcmp(tok, "NOT")){
		process_instruction(program, NOT, NOT_F, 0);
	}
	else if(!strcmp(tok, "SHL")){
		process_instruction(program, SHL, SHL_F, 0);
	}
	else if(!strcmp(tok, "SHR")){
		process_instruction(program, SHR, SHR_F, 0);
	}
	else if(!strcmp(tok, "OR")){
		process_instruction(program, OR, OR_F, 0);
	}
	else if(!strcmp(tok, "AND")){
		process_instruction(program, AND, AND_F, 0);
	}
	else if(!strcmp(tok, "ADD")){
		process_instruction(program, ADD, ADD_F, 0);
	}
	else if(!strcmp(tok, "SW")){
		process_instruction(program, SW, SW_F, 0);
	}
	else if(!strcmp(tok, "SI")){
		process_instruction(program, SI, SI_F, 0);
	}
	else if(!strcmp(tok, "LW")){
		process_instruction(program, LW, LW_F, 0);
	}
	else if(!strcmp(tok, "LI")){
		process_instruction(program, LI, LI_F, 0);
	}
	else if(!strcmp(tok, "BEZ")){
		process_instruction(program, BEZ, BEZ_F, 0);
	}
	else if(!strcmp(tok, "ROT")){
		process_instruction(program, ROT, ROT_F, 0);
	}
	else if(!strcmp(tok, "ROT1")){
		process_instruction(program, ROT1, ROT1_F, 0);
	}
	else if(!strcmp(tok, "JMP")){
		process_instruction(program, JMP, JMP_F, 0);
	}
	else if(!strcmp(tok, "NOP")){
		process_instruction(program, NOP, NOP_F, 0);
	}
	else if(!strcmp(tok, "LFSJ")){
		process_instruction(program, LFSJ, LFSJ_F, 0);
	}
	else if(!strcmp(tok, "STJ")){
		process_instruction(program, STJ, STJ_F, 0);
	}

	// looks like a bad opcode
	else{
		#ifdef DEBUG
			fprintf(stderr, "BAD CODE '%s'\n", tok);
		#endif
		print_unexpected_ident(tok, program);
	}
}