int main(int argc, char** argv) { std::string filename = "scene.lua"; if (argc >= 2) { filename = argv[1]; } if (!run_lua(filename)) { std::cerr << "Could not open " << filename << std::endl; return 1; } }
int main(int argc, char** argv) { char * run_type = getenv("RUN_TYPE"); string runType; if (run_type == NULL) { runType = "NORMAL"; } else { runType = string(run_type); } bool firstRun = false; while (true) { if (firstRun) { cerr << "RUN TYPE: " << runType << endl; } if (runType == "WORKER") { worker.accept(); } std::string filename = "scene.lua"; if (argc >= 2) { filename = argv[1]; } if (!run_lua(filename)) { std::cerr << "Could not open " << filename << std::endl; return 1; } if (runType != "WORKER") { break; } firstRun = false; } return 0; }
static void received_im_msg_cb(PurpleAccount *account, char *who, char *buffer, PurpleConversation *conv, PurpleMessageFlags flags, void *data) { // A workaround to avoid skipping of the first message as a result on NULL-conv: if (conv == NULL) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, who); PurpleBuddy *buddy = purple_find_buddy(account, who); PurplePresence *presence = purple_buddy_get_presence(buddy); msg_metadata_t msg; //Get message msg.text = purple_markup_strip_html(buffer); msg.remote_username = who; //LOCAL USER: msg.local_alias = purple_account_get_alias(account); msg.local_username = (char *) purple_account_get_name_for_display(account); //REMOTE USER (Buddy): //Get buddy alias msg.remote_alias = purple_buddy_get_alias(buddy); if(msg.remote_alias == NULL) msg.remote_alias = ""; //Get buddy group PurpleGroup *group = purple_buddy_get_group(buddy); //return empty string if not in group msg.remote_from_group = group != NULL ? purple_group_get_name(group) : ""; //Get protocol ID msg.protocol_id = purple_account_get_protocol_id(account); //trim out PROTOCOL_PREFIX (eg.: "prpl-irc" => "irc") if(!strncmp(msg.protocol_id,PROTOCOL_PREFIX,strlen(PROTOCOL_PREFIX))) msg.protocol_id += strlen(PROTOCOL_PREFIX); //Get status PurpleStatus *status = purple_account_get_active_status(account); PurpleStatusType *type = purple_status_get_type(status); //remote PurpleStatus *r_status = purple_presence_get_active_status(presence); PurpleStatusType *r_status_type = purple_status_get_type(r_status); //Get status id msg.local_status_id = NULL; msg.local_status_id = purple_primitive_get_id_from_type( purple_status_type_get_primitive(type)); //remote msg.remote_status_id = NULL; msg.remote_status_id = purple_primitive_get_id_from_type( purple_status_type_get_primitive(r_status_type)); //Get status message msg.local_status_msg = NULL; if (purple_status_type_get_attr(type, "message") != NULL) { msg.local_status_msg = purple_status_get_attr_string(status, "message"); } else { PurpleSavedStatus *savedstatus = purple_savedstatus_get_current(); if(savedstatus) msg.local_status_msg = purple_savedstatus_get_message(savedstatus); } //remote msg.remote_status_msg = NULL; if (purple_status_type_get_attr(r_status_type, "message") != NULL) { msg.remote_status_msg = purple_status_get_attr_string(r_status, "message"); } else { msg.remote_status_msg = ""; } run_lua(conv, msg); }