static t_stat ipc_set_node (UNIT UNUSED *uptr, int32 UNUSED val, char *cval, void UNUSED *desc) { if (cval == NULL || *cval == 0) { strcpy(fnpName, IPC_NODE); #ifdef VM_FNP set_prompt (0, "sim>"); // reset prompt to default #endif } else { stripquotes(cval); if (!startsWith(cval, "cpu")) sim_printf("WARNING: Node name <%s> does not begin with 'cpu'\n", cval); strcpy(fnpName, cval); #ifdef VM_FNP char temp[132]; sprintf(temp, "%s>", fnpName); set_prompt(0, temp); #endif } // if IPC is already running, resrart it with new node if (actor) { ipc(ipcStop, 0, 0, 0, 0); // ki;; IPC ipc(ipcStart, fnpName, 0, 0, 0); } return SCPE_OK; }
static void process_line(char *line) { char *p; static char *msgid; BUG_ON(!line); p = strrchr(line, '\n'); if (p) *p = '\0'; if (!strncmp(line, "msgid", 5)) { if (msgid) warn("last msgid had no corresponding msgstr"); msgid = strdup(stripquotes(line + 5)); } else if (!strncmp(line, "msgstr", 6)) { if (!msgid) warn("msgstr without msgid"); hashput(msgid, stripquotes(line + 6)); xfree(msgid); } }
static t_stat ipc_set_grp (UNIT UNUSED *uptr, int32 UNUSED val, char UNUSED *cval, void UNUSED *desc) { stripquotes(cval); strcpy(fnpGroup, cval); if (actor) { ipc(ipcStop, 0, 0, 0, 0); // kill IPC ipc(ipcStart, fnpName, 0, 0, 0); } return SCPE_OK; }
// the following written by jl777 void copy_cJSON(char *dest,cJSON *obj) { char *str; long offset; dest[0] = 0; if ( obj != 0 ) { str = cJSON_Print(obj); if ( str != 0 ) { offset = stripquotes(str); strcpy(dest,str+offset); free(str); } } }
int32_t extract_cJSON_str(char *dest,int32_t max,cJSON *json,char *field) { int32_t safecopy(char *dest,char *src,long len); char *str; cJSON *obj; int32_t len; long offset; dest[0] = 0; obj = cJSON_GetObjectItem(json,field); if ( obj != 0 ) { str = cJSON_Print(obj); offset = stripquotes(str); len = safecopy(dest,str+offset,max); free(str); return(len); } return(0); }
// the following written by jl777 void copy_cJSON(char *dest,cJSON *obj) { char *str; int i; long offset; dest[0] = 0; if ( obj != 0 ) { str = cJSON_Print(obj); if ( str != 0 ) { offset = stripquotes(str); //strcpy(dest,str+offset); for (i=0; i<MAX_JSON_FIELD-1; i++) if ( (dest[i]= str[offset+i]) == 0 ) break; dest[i] = 0; free(str); } } }
/* * Sanitize and enhance an HTML message for display. * Also convert weird character sets to UTF-8 if necessary. * Also fixup img src="cid:..." type inline images to fetch the image * */ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, StrBuf *Source, StrBuf *Target) { char buf[SIZ]; char *msg; char *ptr; char *msgstart; char *msgend; StrBuf *converted_msg; int buffer_length = 1; int line_length = 0; int content_length = 0; char new_window[SIZ]; int brak = 0; int alevel = 0; int scriptlevel = 0; int script_start_pos = (-1); int i; int linklen; char charset[128]; StrBuf *BodyArea = NULL; #ifdef HAVE_ICONV iconv_t ic = (iconv_t)(-1) ; char *ibuf; /* Buffer of characters to be converted */ char *obuf; /* Buffer for converted characters */ size_t ibuflen; /* Length of input buffer */ size_t obuflen; /* Length of output buffer */ char *osav; /* Saved pointer to output buffer */ #endif if (Target == NULL) Target = WC->WBuf; safestrncpy(charset, supplied_charset, sizeof charset); msg = strdup(""); sprintf(new_window, "<a target=\"%s\" href=", TARGET); if (Source == NULL) while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { line_length = strlen(buf); buffer_length = content_length + line_length + 2; ptr = realloc(msg, buffer_length); if (ptr == NULL) { StrBufAppendPrintf(Target, "<b>"); StrBufAppendPrintf(Target, _("realloc() error! couldn't get %d bytes: %s"), buffer_length + 1, strerror(errno)); StrBufAppendPrintf(Target, "</b><br><br>\n"); while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { /** flush */ } free(msg); return; } msg = ptr; strcpy(&msg[content_length], buf); content_length += line_length; strcpy(&msg[content_length], "\n"); content_length += 1; } else { content_length = StrLength(Source); free(msg); msg = (char*) ChrPtr(Source);/* TODO: remove cast */ buffer_length = content_length; } /** Do a first pass to isolate the message body */ ptr = msg + 1; msgstart = msg; msgend = &msg[content_length]; while (ptr < msgend) { /** Advance to next tag */ ptr = strchr(ptr, '<'); if ((ptr == NULL) || (ptr >= msgend)) break; ++ptr; if ((ptr == NULL) || (ptr >= msgend)) break; /* * Look for META tags. Some messages (particularly in * Asian locales) illegally declare a message's character * set in the HTML instead of in the MIME headers. This * is wrong but we have to work around it anyway. */ if (!strncasecmp(ptr, "META", 4)) { char *meta_start; char *meta_end; int meta_length; char *meta; char *meta_http_equiv; char *meta_content; char *spaceptr; meta_start = &ptr[4]; meta_end = strchr(ptr, '>'); if ((meta_end != NULL) && (meta_end <= msgend)) { meta_length = meta_end - meta_start + 1; meta = malloc(meta_length + 1); safestrncpy(meta, meta_start, meta_length); meta[meta_length] = 0; striplt(meta); if (!strncasecmp(meta, "HTTP-EQUIV=", 11)) { meta_http_equiv = strdup(&meta[11]); spaceptr = strchr(meta_http_equiv, ' '); if (spaceptr != NULL) { *spaceptr = 0; meta_content = strdup(++spaceptr); if (!strncasecmp(meta_content, "content=", 8)) { strcpy(meta_content, &meta_content[8]); stripquotes(meta_http_equiv); stripquotes(meta_content); extract_charset_from_meta(charset, meta_http_equiv, meta_content); } free(meta_content); } free(meta_http_equiv); } free(meta); } } /* * Any of these tags cause everything up to and including * the tag to be removed. */ if ( (!strncasecmp(ptr, "HTML", 4)) ||(!strncasecmp(ptr, "HEAD", 4)) ||(!strncasecmp(ptr, "/HEAD", 5)) ||(!strncasecmp(ptr, "BODY", 4)) ) { char *pBody = NULL; if (!strncasecmp(ptr, "BODY", 4)) { pBody = ptr; } ptr = strchr(ptr, '>'); if ((ptr == NULL) || (ptr >= msgend)) break; if ((pBody != NULL) && (ptr - pBody > 4)) { char* src; char *cid_start, *cid_end; *ptr = '\0'; pBody += 4; while ((isspace(*pBody)) && (pBody < ptr)) pBody ++; BodyArea = NewStrBufPlain(NULL, ptr - pBody); if (pBody < ptr) { src = strstr(pBody, "cid:"); if (src) { cid_start = src + 4; cid_end = cid_start; while ((*cid_end != '"') && !isspace(*cid_end) && (cid_end < ptr)) cid_end ++; /* copy tag and attributes up to src="cid: */ StrBufAppendBufPlain(BodyArea, pBody, src - pBody, 0); /* add in /webcit/mimepart/<msgno>/CID/ trailing / stops dumb URL filters getting excited */ StrBufAppendPrintf(BodyArea, "/webcit/mimepart/%d/",msgnum); StrBufAppendBufPlain(BodyArea, cid_start, cid_end - cid_start, 0); if (ptr - cid_end > 0) StrBufAppendBufPlain(BodyArea, cid_end + 1, ptr - cid_end, 0); } else StrBufAppendBufPlain(BodyArea, pBody, ptr - pBody, 0); } *ptr = '>'; } ++ptr; if ((ptr == NULL) || (ptr >= msgend)) break; msgstart = ptr; } /* * Any of these tags cause everything including and following * the tag to be removed. */ if ( (!strncasecmp(ptr, "/HTML", 5)) ||(!strncasecmp(ptr, "/BODY", 5)) ) { --ptr; msgend = ptr; strcpy(ptr, ""); } ++ptr; } if (msgstart > msg) { strcpy(msg, msgstart); } /* Now go through the message, parsing tags as necessary. */ converted_msg = NewStrBufPlain(NULL, content_length + 8192); /** Convert foreign character sets to UTF-8 if necessary. */ #ifdef HAVE_ICONV if ( (strcasecmp(charset, "us-ascii")) && (strcasecmp(charset, "UTF-8")) && (strcasecmp(charset, "")) ) { syslog(LOG_DEBUG, "Converting %s to UTF-8\n", charset); ctdl_iconv_open("UTF-8", charset, &ic); if (ic == (iconv_t)(-1) ) { syslog(LOG_WARNING, "%s:%d iconv_open() failed: %s\n", __FILE__, __LINE__, strerror(errno)); } } if (Source == NULL) { if (ic != (iconv_t)(-1) ) { ibuf = msg; ibuflen = content_length; obuflen = content_length + (content_length / 2) ; obuf = (char *) malloc(obuflen); osav = obuf; iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen); content_length = content_length + (content_length / 2) - obuflen; osav[content_length] = 0; free(msg); msg = osav; iconv_close(ic); } } else { if (ic != (iconv_t)(-1) ) { StrBuf *Buf = NewStrBufPlain(NULL, StrLength(Source) + 8096);; StrBufConvert(Source, Buf, &ic); FreeStrBuf(&Buf); iconv_close(ic); msg = (char*)ChrPtr(Source); /* TODO: get rid of this. */ } } #endif /* * At this point, the message has been stripped down to * only the content inside the <BODY></BODY> tags, and has * been converted to UTF-8 if it was originally in a foreign * character set. The text is also guaranteed to be null * terminated now. */ if (converted_msg == NULL) { StrBufAppendPrintf(Target, "Error %d: %s<br>%s:%d", errno, strerror(errno), __FILE__, __LINE__); goto BAIL; } if (BodyArea != NULL) { StrBufAppendBufPlain(converted_msg, HKEY("<table "), 0); StrBufAppendBuf(converted_msg, BodyArea, 0); StrBufAppendBufPlain(converted_msg, HKEY(" width=\"100%\"><tr><td>"), 0); } ptr = msg; msgend = strchr(msg, 0); while (ptr < msgend) { /** Try to sanitize the html of any rogue scripts */ if (!strncasecmp(ptr, "<script", 7)) { if (scriptlevel == 0) { script_start_pos = StrLength(converted_msg); } ++scriptlevel; } if (!strncasecmp(ptr, "</script", 8)) { --scriptlevel; } /** * Change mailto: links to WebCit mail, by replacing the * link with one that points back to our mail room. Due to * the way we parse URL's, it'll even handle mailto: links * that have "?subject=" in them. */ if (!strncasecmp(ptr, "<a href=\"mailto:", 16)) { content_length += 64; StrBufAppendPrintf(converted_msg, "<a href=\"display_enter?force_room=_MAIL_?recp="); ptr = &ptr[16]; ++alevel; ++brak; } /** Make external links open in a separate window */ else if (!strncasecmp(ptr, "<a href=\"", 9)) { ++alevel; ++brak; if ( ((strchr(ptr, ':') < strchr(ptr, '/'))) && ((strchr(ptr, '/') < strchr(ptr, '>'))) ) { /* open external links to new window */ StrBufAppendPrintf(converted_msg, new_window); ptr = &ptr[8]; } else if ( (treat_as_wiki) && (strncasecmp(ptr, "<a href=\"wiki?", 14)) && (strncasecmp(ptr, "<a href=\"dotgoto?", 17)) && (strncasecmp(ptr, "<a href=\"knrooms?", 17)) ) { content_length += 64; StrBufAppendPrintf(converted_msg, "<a href=\"wiki?go="); StrBufUrlescAppend(converted_msg, WC->CurRoom.name, NULL); StrBufAppendPrintf(converted_msg, "?page="); ptr = &ptr[9]; } else { StrBufAppendPrintf(converted_msg, "<a href=\""); ptr = &ptr[9]; } } /** Fixup <img src="cid:... ...> to fetch the mime part */ else if (!strncasecmp(ptr, "<img ", 5)) { char *cid_start, *cid_end; char* tag_end=strchr(ptr,'>'); char* src; /* FIXME - handle this situation (maybe someone opened an <img cid... * and then ended the message) */ if (!tag_end) { syslog(LOG_DEBUG, "tag_end is null and ptr is:\n"); syslog(LOG_DEBUG, "%s\n", ptr); syslog(LOG_DEBUG, "Theoretical bytes remaining: %d\n", (int)(msgend - ptr)); } src=strstr(ptr, "src=\"cid:"); ++brak; if (src && isspace(*(src-1)) && tag_end && (cid_start=strchr(src,':')) && (cid_end=strchr(cid_start,'"')) && (cid_end < tag_end) ) { /* copy tag and attributes up to src="cid: */ StrBufAppendBufPlain(converted_msg, ptr, src - ptr, 0); cid_start++; /* add in /webcit/mimepart/<msgno>/CID/ trailing / stops dumb URL filters getting excited */ StrBufAppendPrintf(converted_msg, " src=\"/webcit/mimepart/%d/",msgnum); StrBufAppendBufPlain(converted_msg, cid_start, cid_end - cid_start, 0); StrBufAppendBufPlain(converted_msg, "/\"", -1, 0); ptr = cid_end+1; } StrBufAppendBufPlain(converted_msg, ptr, tag_end - ptr, 0); ptr = tag_end; } /** * Turn anything that looks like a URL into a real link, as long * as it's not inside a tag already */ else if ( (brak == 0) && (alevel == 0) && ( (!strncasecmp(ptr, "http://", 7)) || (!strncasecmp(ptr, "https://", 8)))) { /** Find the end of the link */ int strlenptr; linklen = 0; strlenptr = strlen(ptr); for (i=0; i<=strlenptr; ++i) { if ((ptr[i]==0) ||(isspace(ptr[i])) ||(ptr[i]==10) ||(ptr[i]==13) ||(ptr[i]=='(') ||(ptr[i]==')') ||(ptr[i]=='<') ||(ptr[i]=='>') ||(ptr[i]=='[') ||(ptr[i]==']') ||(ptr[i]=='"') ||(ptr[i]=='\'') ) linklen = i; /* did s.b. send us an entity? */ if (ptr[i] == '&') { if ((ptr[i+2] ==';') || (ptr[i+3] ==';') || (ptr[i+5] ==';') || (ptr[i+6] ==';') || (ptr[i+7] ==';')) linklen = i; } if (linklen > 0) break; } if (linklen > 0) { char *ltreviewptr; char *nbspreviewptr; char linkedchar; int len; len = linklen; linkedchar = ptr[len]; ptr[len] = '\0'; /* spot for some subject strings tinymce tends to give us. */ ltreviewptr = strchr(ptr, '<'); if (ltreviewptr != NULL) { *ltreviewptr = '\0'; linklen = ltreviewptr - ptr; } nbspreviewptr = strstr(ptr, " "); if (nbspreviewptr != NULL) { /* nbspreviewptr = '\0'; */ linklen = nbspreviewptr - ptr; } if (ltreviewptr != 0) *ltreviewptr = '<'; ptr[len] = linkedchar; content_length += (32 + linklen); StrBufAppendPrintf(converted_msg, "%s\"", new_window); StrBufAppendBufPlain(converted_msg, ptr, linklen, 0); StrBufAppendPrintf(converted_msg, "\">"); StrBufAppendBufPlain(converted_msg, ptr, linklen, 0); ptr += linklen; StrBufAppendPrintf(converted_msg, "</A>"); } } else { StrBufAppendBufPlain(converted_msg, ptr, 1, 0); ptr++; } if ((ptr >= msg) && (ptr <= msgend)) { /* * We need to know when we're inside a tag, * so we don't turn things that look like URL's into * links, when they're already links - or image sources. */ if ((ptr > msg) && (*(ptr-1) == '<')) { ++brak; } if ((ptr > msg) && (*(ptr-1) == '>')) { --brak; if ((scriptlevel == 0) && (script_start_pos >= 0)) { StrBufCutRight(converted_msg, StrLength(converted_msg) - script_start_pos); script_start_pos = (-1); } } if (!strncasecmp(ptr, "</A>", 3)) --alevel; } } if (BodyArea != NULL) { StrBufAppendBufPlain(converted_msg, HKEY("</td></tr></table>"), 0); FreeStrBuf(&BodyArea); } /** uncomment these two lines to override conversion */ /** memcpy(converted_msg, msg, content_length); */ /** output_length = content_length; */ /** Output our big pile of markup */ StrBufAppendBuf(Target, converted_msg, 0); BAIL: /** A little trailing vertical whitespace... */ StrBufAppendPrintf(Target, "<br><br>\n"); /** Now give back the memory */ FreeStrBuf(&converted_msg); if ((msg != NULL) && (Source == NULL)) free(msg); }
void Node_Value_Parser::handle_append_command(Command_Value& cv, Moldable* bc) { if (tm.current_token() != Mogu_Syntax::append) return; Node_Value tmp {}; std::string str {}; uint8_t flags {cv.get_flags()}; int token {tm.current_token()}; bool preposition_found {false}; // This is used for checking unexpected input to see if it's actually // supposed to be represented as an integer used as a list index. bool check_if_list {false}; tm.next(); token = tm.current_token(); // Cycle through the input, testing flag combinations and setting // things where appropriate, until we're out of tokens. while (token != Mogu_Syntax::OUT_OF_RANGE_END) { // A string will either be a value or an identifier. if (!preposition_found && Mogu_Syntax::location == token) { tm.next(); std::stringstream buf; // append location user foo bar to self while (token != Mogu_Syntax::preposition) { if (Mogu_Syntax::TOKEN_DELIM == token) buf << tm.fetch_string(); else buf << tm.current_token(); buf << " "; tm.next(); token = tm.current_token(); } std::string in {buf.str()}; //user foo bar Node_Value_Parser p {}; Command_Value c {*bc}; Node_Value v {}; p.set_user_id(user_id); p.set_group_id(group_id); p.give_input(in,v); //"widget baz bop" in = stripquotes(v.get_string()); // widget baz bop buf.str(std::string{}); buf << Mogu_Syntax::append.str << " " << in << " "; while (token != Mogu_Syntax::OUT_OF_RANGE_END) { if (Mogu_Syntax::TOKEN_DELIM == token) buf << tm.fetch_string(); else buf << tm.current_token(); buf << " "; tm.next(); token = tm.current_token(); } p.give_input(buf.str(),c,bc); cv = c; return; } if (Mogu_Syntax::TOKEN_DELIM == token) { str = tm.fetch_string(); tmp.set_string(str); // If the only thing that has been set is the action, // then the token delimiter will be a quoted string. if ((flags == (uint8_t)Command_Flags::action) && is_quoted_string(str)) { flags = cv.set(Command_Flags::value, tmp); } // If the r_object has been set, but there's no identifier, // the next string encountered must be the identifier. else if (cv.test(Command_Flags::r_object) && !cv.test(Command_Flags::r_identifier)) { flags = cv.set(Command_Flags::r_identifier, tmp); } // Same as above, but for standard objects. else if (cv.test(Command_Flags::object) && !cv.test(Command_Flags::identifier)) { flags = cv.set(Command_Flags::identifier, tmp); } // In all other cases, this is unexpected input, but it might // be a list index. 'continue' not present here because we want to // keep moving through the decision tree. else check_if_list = true; } // Object tokens will either be the object or r_object, depending // on if it was reached before the preposition or not. else if (is_object_token(token)) { if (!preposition_found && !cv.test(Command_Flags::r_object)) { flags = cv.set(Command_Flags::r_object, token); if (token == Mogu_Syntax::user) { // The only instance where we have // "append user to ..." is when we are // appending a user to a group. tm.next(); if (tm.current_token()==Mogu_Syntax::preposition) { handle_user_to_group(cv,bc); break; } else tm.prev(); } } else if (preposition_found && !cv.test(Command_Flags::object)) { flags = cv.set(Command_Flags::object, token); } else check_if_list = true; // Do not continue. } else if (is_state_token(token)) { tmp.set_int(token); if (!preposition_found && !cv.test(Command_Flags::r_arg)) { flags = cv.set(Command_Flags::r_arg, tmp); } else if (preposition_found && !cv.test(Command_Flags::arg)) { flags = cv.set(Command_Flags::arg, token); } else check_if_list = true; } else if (is_preposition_token(token)) { preposition_found = true; } // This would be reached in the event of unexpected input. // If the check_if_list flag is turned on, we're going to give the // input the benefit of the doubt and see whether or not the previous // token was a list token. If so, that's what this is. Otherwise, // we're going to return without doing anything. else if (check_if_list) { tm.prev(); if (Mogu_Syntax::list != tm.current_token()) return; tm.next(); // Make sure to go back where we were in the input. tmp.set_int((int) token); if (!preposition_found && !cv.test(Command_Flags::r_arg)) { cv.set(Command_Flags::r_arg, tmp); } else if (preposition_found && !cv.test(Command_Flags::arg)) { cv.set(Command_Flags::arg, tmp); } // We have no clue what the hell this is. else return; } tm.next(); token = tm.current_token(); } // end while loop // After this, there is the possibility that we'll have a reduceable value // with r_OBJ/r_ID/r_arg. If so, we'll go ahead and reduce that now: if (cv.object_is_reduceable(true)) { cv.reduce_object(true, bc); } }
void set (Moldable& broadcaster, Command_Value& v) { mApp; const Syntax_Def& o {Mogu_Syntax::get(v.get(Command_Flags::object))}; int i {-1}; const uint8_t f {logic_flags(v)}; switch(o) { case Mogu_Syntax::own:{ const Syntax_Def& a {Mogu_Syntax::get(v.get(Command_Flags::arg))}; broadcaster.set_attribute(a, v.get(Command_Flags::value)); break;} case Mogu_Syntax::path:{ // set application URL app->set_path(stripquotes(v.get(Command_Flags::value))); break;} case Mogu_Syntax::user: { if (user_is_set(f,v, broadcaster)) break; else // Cascade to node editor case { i = app->get_user(); } } //NO BREAK case Mogu_Syntax::group: // Don't do if i already set. { if (o==Mogu_Syntax::group) { if (group_is_set(f,v)) break; else i = i>=0 ? i : app->get_group(); } } // NO BREAK case Mogu_Syntax::data: case Mogu_Syntax::meta: { Node_Value arg {}; bool has_arg {v.test(Command_Flags::arg)}; if (has_arg) arg = v.get(Command_Flags::arg); Prefix p {syntax_to_prefix(o)}; std::string id {v.get_identifier()}; Redis::Node_Editor e {p, id, has_arg ? &arg : nullptr}; if (i>=0) e.set_id(i); e.write(v.get(Command_Flags::value)); break; } case Mogu_Syntax::slot:{ // set application slot std::string s {v.get_identifier()}; Node_Value n {v.get(Command_Flags::value)}; if (s.empty()) { Application::log.log(Log_Level::critical, "Attempting to set a slot that no name. ", "Something has gone terribly wrong!"); } app->get_slot_manager().set_slot(s,n); break;} case Mogu_Syntax::widget:{ // set arbitrary widget attribute Moldable* w {app->get_widget(v.get_identifier())}; if (!w) break; const Syntax_Def& a {Mogu_Syntax::get(v.get(Command_Flags::arg))}; w->set_attribute(a, v.get(Command_Flags::value)); break;} default: break; // If bad input, stop immediately } }
t_stat ipc (ipc_funcs fn, char *arg1, char *arg2, char *arg3, int32 UNUSED arg4) { // if (!checkIPC()) // return SCPE_UDIS; switch (fn) { case ipcStart: if (actor) killIPC(); actor = zactor_new (ipc_actor, arg1); assert (actor); deletePeers(); // remove all peers break; case ipcStop: ipc_printf("Stopping IPC ... "); killIPC(); ipc_printf("deleted %d peers ... ", deletePeers()); ipc_printf("done\n"); break; case ipcRestart: ipc(ipcStop, 0, 0, 0, 0); // kill IPC deletePeers(); ipc(ipcStart, fnpName, 0, 0, 0); // start IPC break; case ipcEnter: //sim_debug (DBG_VERBOSE, &ipc_dev, "%s/%s has entered " STR(IPC_GROUP) "\n", arg1, arg2); if (ipc_verbose) ipc_printf("(ENTER) %s/%s has entered %s from %s\n", arg1, arg2, fnpGroup, arg3); savePeer(arg1, arg2); break; case ipcExit: //sim_debug (DBG_VERBOSE, &ipc_dev, "%s has left " STR(IPC_GROUP) "\n", arg1); if (ipc_verbose) ipc_printf("(EXIT) %s/%s has left %s\n", arg1, arg2, fnpGroup); removePeer(arg1); break; case ipcShoutTx: zstr_sendx (actor, "SHOUT", arg1, NULL); break; case ipcWhisperTx: #if 1 if (arg1) // WHISPER msg (use last whisper peer) { IPC_Peer *p1 = findPeer(stripquotes(trim(arg1))); // f**k for peer named 'name' if (p1) strcpy(lastPeer, p1->peerID); // save Peer id else { bool bGuid = isGUID(stripquotes(trim(arg1))); if (!bGuid) { sim_printf("Error: '%s' is not a GUID or a known peer\n", arg1); return SCPE_ARG; } strcpy(lastPeer, arg1); // Peer name not found, assume arg1 is a peerID then... } } #endif zstr_sendx (actor, "WHISPER", arg2, NULL); break; case ipcShoutRx: // when we receive a broadcast message //sim_debug (DBG_VERBOSE, &ipc_dev, "%s: %s\n", arg1, arg2); if (ipc_verbose) ipc_printf("(RX SHOUT) %s/%s:<%s>\n", arg1, arg2, arg3); break; case ipcWhisperRx: // when we receive a peer-to-peer (whisper) message //sim_debug (DBG_VERBOSE, &ipc_dev, "%s: %s\n", arg1, arg2); if (ipc_verbose) ipc_printf("(RX WHISPER) %s/%s:<%s>\n", arg1, arg2, arg3); if (strncmp (arg1, "fnp-", 4) == 0) diaCommand (arg1, arg2, arg3); else if (strncmp (arg1, "scp", 3) == 0) scpCommand (arg1, arg2, arg3); else ipc_printf ("dropping whisper from unknown source %s/%s:<%s>\n", arg1, arg2, arg3); break; case ipcTest: zyre_test(true); break; default: break; } return SCPE_OK; }