static int richeditfind(HWND hwnd, char *what, int matchcase, int wholeword, int down) { long start, end; CHARRANGE sel; WPARAM w = 0; FINDTEXTEX ft; sendmessage (hwnd, EM_EXGETSEL, 0, &sel) ; start = sel.cpMin; end = sel.cpMax; ft.lpstrText = what; ft.chrgText.cpMin = start; ft.chrgText.cpMax = end; if (down) { w = w | FR_DOWN; ft.chrg.cpMin = end; ft.chrg.cpMax = -1; } else { ft.chrg.cpMin = start; ft.chrg.cpMax = 0; } if (matchcase) w = w | FR_MATCHCASE; if (wholeword) w = w | FR_WHOLEWORD; if (sendmessage(hwnd, EM_FINDTEXTEX, w, &ft) == -1) return 0; else { sendmessage (hwnd, EM_EXSETSEL, 0, &(ft.chrgText)); sendmessage (hwnd, EM_SCROLLCARET, 0, 0) ; } return 1; }
void setlistitem(listbox obj, int index) { int count; if (! obj) return; if (index < 0) index = -1; switch (obj->kind) { case ListboxObject: sendmessage(obj->handle, LB_SETCURSEL, index, 0L); break; case MultilistObject: if (index >= 0) sendmessage(obj->handle, LB_SETSEL, TRUE, MAKELPARAM(index, 0)); else { count = sendmessage(obj->handle, LB_GETCOUNT, 0, 0L); sendmessage(obj->handle, LB_SELITEMRANGE, FALSE, MAKELPARAM(0,count-1)); } case DroplistObject: case DropfieldObject: sendmessage(obj->handle, CB_SETCURSEL, index, 0L); break; default: break; } }
PROTECTED void handle_findreplace(HWND hwnd, LPFINDREPLACE pfr) { CHARRANGE sel; int matchcase=0, wholeword=0, down=0; char buf[100]; if (pfr->Flags & FR_MATCHCASE) matchcase = 1; if (pfr->Flags & FR_WHOLEWORD) wholeword = 1; if (pfr->Flags & FR_DOWN) down = 1; if (pfr->Flags & FR_FINDNEXT) { if (!richeditfind(hwnd, pfr->lpstrFindWhat, matchcase, wholeword, down)) { snprintf(buf, 100, G_("\"%s\" not found"), pfr->lpstrFindWhat); askok(buf); } } else if (pfr->Flags & FR_REPLACE) { if (!richeditreplace(hwnd, pfr->lpstrFindWhat, pfr->lpstrReplaceWith, matchcase, wholeword, down)) { snprintf(buf, 100, G_("\"%s\" not found"), pfr->lpstrFindWhat); askok(buf); } } else if (pfr->Flags & FR_REPLACEALL) { /* replace all in the whole buffer then return to original selection state */ sendmessage (hwnd, EM_EXGETSEL, 0, &sel) ; sendmessage (hwnd, EM_SETSEL, 0, 0) ; while ( richeditreplace(hwnd, pfr->lpstrFindWhat, pfr->lpstrReplaceWith, matchcase, wholeword, down) ) ; sendmessage (hwnd, EM_EXSETSEL, 0, &sel) ; } else if (pfr->Flags & FR_DIALOGTERM) hModelessDlg = NULL; }
static void load_hoststatus() { int res; char msg[1024]; sendreturn_t *sres; sprintf(msg, "xymondboard fields=hostname,testname,color test=%s", conncolumn); sres = newsendreturnbuf(1, NULL); res = sendmessage(msg, NULL, XYMON_TIMEOUT, sres); if (res == XYMONSEND_OK) connstatus = getsendreturnstr(sres, 1); if ((res == XYMONSEND_OK) && testcolumn) { sprintf(msg, "xymondboard fields=hostname,testname,color test=%s", testcolumn); res = sendmessage(msg, NULL, XYMON_TIMEOUT, sres); if (res == XYMONSEND_OK) teststatus = getsendreturnstr(sres, 1); } if (res != XYMONSEND_OK) { errprintf("Cannot fetch Xymon status, ignoring --no-down\n"); connstatus = NULL; teststatus = NULL; } freesendreturnbuf(sres); }
void changelistbox(listbox obj, char **list) { int i; HWND hwnd; UINT reset_msg, add_msg; if (! obj) return; hwnd = obj->handle; switch (obj->kind) { case ListboxObject: case MultilistObject: reset_msg = LB_RESETCONTENT; add_msg = LB_ADDSTRING; break; case DroplistObject: case DropfieldObject: reset_msg = CB_RESETCONTENT; add_msg = CB_ADDSTRING; break; default: return; } sendmessage(hwnd, WM_SETREDRAW, FALSE, 0L); sendmessage(hwnd, reset_msg, 0, 0L); for (i=0; list && list[i]; i++) sendmessage(hwnd, add_msg, 0, (LPSTR) list[i]); sendmessage(hwnd, WM_SETREDRAW, TRUE, 0L); if (obj->kind == ListboxObject) sendmessage(hwnd, LB_SETCURSEL, 0, 0L); }
static int richeditreplace(HWND hwnd, char *what, char *replacewith, int matchcase, int wholeword, int down) { /* If current selection is the find string, replace it and find next */ long start, end; CHARRANGE sel; char *buf; textbox t = find_by_handle(hwnd); if (t) { sendmessage (hwnd, EM_EXGETSEL, 0, &sel) ; start = sel.cpMin; end = sel.cpMax; if (start < end) { buf = (char *) malloc(end - start + 1); sendmessage(hwnd, EM_GETSELTEXT, 0, buf); if (!strcmp(buf, what)) { checklimittext(t, strlen(replacewith) - strlen(what) + 2); sendmessage (hwnd, EM_REPLACESEL, 1, replacewith); } free(buf); } /* else just find next */ if (richeditfind(hwnd, what, matchcase, wholeword, down)) return 1; } return 0; }
/* * Set the layer 2 protocol (X.25, HDLC, Raw) */ static int setl2(int card, unsigned long arg) { int status =0; int protocol,channel; if(!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } protocol = arg >> 8; channel = arg & 0xff; sc_adapter[card]->channel[channel].l2_proto = protocol; /* * check that the adapter is also set to the correct protocol */ pr_debug("%s: Sending GetFrameFormat for channel %d\n", sc_adapter[card]->devicename, channel+1); status = sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetFrameFormat, (unsigned char)channel+1, 1, (unsigned int *) protocol); if(status) return status; return 0; }
static void zvm_mdc_report(char *hostname, char *clientclass, enum ostype_t os, void *hinfo, char *fromline, char *timestr, char *cpuutilstr) { char *p; int mdcreads, mdcwrites, mdchitpct; char mdcresult[100]; char msgline[256]; strbuffer_t *msg; if (!cpuutilstr) return; msg = newstrbuffer(0); /* * Looking for MDC info in 'IND' command response * MDC READS-000001/SEC WRITES-000001/SEC HIT RATIO-098% */ *mdcresult = '\0'; /* Skip past three newlines in message to the PAGING text */ p=strstr(cpuutilstr,"READS-"); if (p) { p += 6; sscanf(p, "%d/SEC", &mdcreads); p=strstr(cpuutilstr,"WRITES-") + 7; sscanf(p, "%d/SEC", &mdcwrites); p=strstr(cpuutilstr,"RATIO-") + 6; sscanf(p, "%d", &mdchitpct); sprintf(msgline, "data %s.mdc\n%s\n%d:%d:%d\n", commafy(hostname), osname(os), mdcreads, mdcwrites, mdchitpct); addtobuffer(msg, msgline); sendmessage(STRBUF(msg), NULL, BBTALK_TIMEOUT, NULL); } freestrbuffer(msg); }
void dumbmover::update() { if(movepath.getsize() == 0) { movepath.calculate(position, position + delta); movepath.pop_front(); } if(movepath.getsize() != 0) { movepoints += speed; if(movepoints > 100) { movepoints -= 100; ivec2 moveposition = movepath.getcurrent(); message msg; msg.set("changeposition",1); msg.set("x",moveposition.getx()); msg.set("y",moveposition.gety()); sendmessage(msg); movepath.pop_front(); if(getregistry()->checkposition(moveposition)) { component::killhost(); } } } }
/* * Dials the number passed in */ static int dial(int card, unsigned long channel, setup_parm setup) { int status; char Phone[48]; if(!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } /*extract ISDN number to dial from eaz/msn string*/ strcpy(Phone,setup.phone); /*send the connection message*/ status = sendmessage(card, CEPID,ceReqTypePhy, ceReqClass1, ceReqPhyConnect, (unsigned char) channel+1, strlen(Phone), (unsigned int *) Phone); pr_debug("%s: Dialing %s on channel %lu\n", sc_adapter[card]->devicename, Phone, channel+1); return status; }
void send_data(void *host, char *beadomain, char *databuf, char **items) { bea_idx_t *idxwalk; strbuffer_t *msgbuf; char *p; int i; msgbuf = newstrbuffer(0); for (idxwalk = bea_idxhead; (idxwalk); idxwalk = idxwalk->next) { sprintf(msgline, "data %s.bea\n\n", commafy(bbh_item(host, BBH_HOSTNAME))); addtobuffer(msgbuf, msgline); if (beadomain && *beadomain) { sprintf(msgline, "DOMAIN:%s\n", beadomain); addtobuffer(msgbuf, msgline); } for (i=0; (items[i]); i++) { p = getstring(databuf, idxwalk->idx, items[i]); sprintf(msgline, "%s\n", p); addtobuffer(msgbuf, msgline); } sendmessage(STRBUF(msgbuf), NULL, BBTALK_TIMEOUT, NULL); clearstrbuffer(msgbuf); } freestrbuffer(msgbuf); }
static void combo_flush(void) { if (!xymonmsgqueued) { dbgprintf("Flush, but xymonmsg is empty\n"); return; } if (debug) { char *p1, *p2; dbgprintf("Flushing combo message\n"); p1 = p2 = STRBUF(xymonmsg); do { p2++; p1 = strstr(p2, "\nstatus "); if (p1) { p1++; /* Skip the newline */ p2 = strchr(p1, '\n'); if (p2) *p2='\0'; printf(" %s\n", p1); if (p2) *p2='\n'; } } while (p1 && p2); } sendmessage(STRBUF(xymonmsg), NULL, XYMON_TIMEOUT, NULL); combo_start(); /* Get ready for the next */ }
int main(int argc, char const **argv) { arg_check(argc); int socket_fd, recv, len; char msg[6] = "hello"; char response[MSG_SIZE_CLIENT], server_port[6], server_ip[40]; struct timeval times[3]; struct sockaddr_storage server_addr; struct addrinfo hints, *res; fd_set read_set; bzero(response, sizeof response); resolve(server_ip, argv[1]); setup(&socket_fd, &hints, res, server_ip, server_port, &server_addr, &len); fd_clear_set(&socket_fd, &read_set); sendmessage(&socket_fd, &msg[0], (struct sockaddr *) &server_addr, len, times); recv = waitresponse(socket_fd, &read_set, times[2]); getresults1(recv, socket_fd, &response[0], times); close(socket_fd); }
static int getboard(int mincolor) { char msg[1024]; int i; sendreturn_t *sres; int xymondresult; if (!boardmaster) { sprintf(msg, "xymondboard acklevel=%d fields=hostname,testname,color,lastchange,logtime,validtime,acklist color=%s", critacklevel,colorname(mincolor)); for (i=mincolor+1; (i < COL_COUNT); i++) sprintf(msg+strlen(msg), ",%s", colorname(i)); sres = newsendreturnbuf(1, NULL); xymondresult = sendmessage(msg, NULL, XYMON_TIMEOUT, sres); if (xymondresult != XYMONSEND_OK) { boardmaster = ""; freesendreturnbuf(sres); errormsg("Unable to fetch current status\n"); return 1; } else { boardmaster = getsendreturnstr(sres, 1); freesendreturnbuf(sres); } } return 0; }
int main(int argc, const char * argv[]) { // insert code here... int matrix[4][4]; sendmessage(); receiver(); return 0; }
int setup_buffers(int card, int c) { unsigned int nBuffers, i, cBase; unsigned int buffer_size; LLData RcvBuffOffset; if(!IS_VALID_CARD(card)) { pr_debug("invalid param: %d is not a valid card id\n", card); return -ENODEV; } /* * Calculate the buffer offsets (send/recv/send/recv) */ pr_debug("%s: setting up channel buffer space in shared RAM\n", sc_adapter[card]->devicename); buffer_size = BUFFER_SIZE; nBuffers = ((sc_adapter[card]->ramsize - BUFFER_BASE) / buffer_size) / 2; nBuffers = nBuffers > BUFFERS_MAX ? BUFFERS_MAX : nBuffers; pr_debug("%s: calculating buffer space: %d buffers, %d big\n", sc_adapter[card]->devicename, nBuffers, buffer_size); if(nBuffers < 2) { pr_debug("%s: not enough buffer space\n", sc_adapter[card]->devicename); return -1; } cBase = (nBuffers * buffer_size) * (c - 1); pr_debug("%s: channel buffer offset from shared RAM: 0x%x\n", sc_adapter[card]->devicename, cBase); sc_adapter[card]->channel[c-1].first_sendbuf = BUFFER_BASE + cBase; sc_adapter[card]->channel[c-1].num_sendbufs = nBuffers / 2; sc_adapter[card]->channel[c-1].free_sendbufs = nBuffers / 2; sc_adapter[card]->channel[c-1].next_sendbuf = 0; pr_debug("%s: send buffer setup complete: first=0x%x n=%d f=%d, nxt=%d\n", sc_adapter[card]->devicename, sc_adapter[card]->channel[c-1].first_sendbuf, sc_adapter[card]->channel[c-1].num_sendbufs, sc_adapter[card]->channel[c-1].free_sendbufs, sc_adapter[card]->channel[c-1].next_sendbuf); /* * Prep the receive buffers */ pr_debug("%s: adding %d RecvBuffers:\n", sc_adapter[card]->devicename, nBuffers /2); for (i = 0 ; i < nBuffers / 2; i++) { RcvBuffOffset.buff_offset = ((sc_adapter[card]->channel[c-1].first_sendbuf + (nBuffers / 2) * buffer_size) + (buffer_size * i)); RcvBuffOffset.msg_len = buffer_size; pr_debug("%s: adding RcvBuffer #%d offset=0x%x sz=%d bufsz:%d\n", sc_adapter[card]->devicename, i + 1, RcvBuffOffset.buff_offset, RcvBuffOffset.msg_len,buffer_size); sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead, c, sizeof(LLData), (unsigned int *)&RcvBuffOffset); } return 0; }
static int prepare_fromnet(void) { static char contentmd5[33] = { '\0', }; sendreturn_t *sres; sendresult_t sendstat; char *fdata, *fhash; sres = newsendreturnbuf(1, NULL); sendstat = sendmessage("config hosts.cfg", NULL, XYMON_TIMEOUT, sres); if (sendstat != XYMONSEND_OK) { freesendreturnbuf(sres); errprintf("Cannot load hosts.cfg from xymond, code %d\n", sendstat); return -1; } fdata = getsendreturnstr(sres, 1); freesendreturnbuf(sres); fhash = md5hash(fdata); if (strcmp(contentmd5, fhash) == 0) { /* No changes */ xfree(fdata); return 1; } if (contentbuffer) freestrbuffer(contentbuffer); contentbuffer = convertstrbuffer(fdata, 0); strcpy(contentmd5, fhash); return 0; }
void cleartext(control obj) { if (! obj) return; if ((obj->kind != FieldObject) && (obj->kind != TextboxObject)) return; sendmessage(obj->handle, WM_CLEAR, 0, 0L); }
int isselected(listbox obj, int index) { if (! obj) return -1; switch (obj->kind) { case ListboxObject: return (index == sendmessage(obj->handle, LB_GETCURSEL, 0, 0L)); case MultilistObject: return sendmessage(obj->handle, LB_GETSEL, index, 0L); case DroplistObject: case DropfieldObject: return (index == sendmessage(obj->handle, CB_GETCURSEL, 0, 0L)); default: return 0; } }
void pastetext(control obj) { if (! obj) return; if ((obj->kind != FieldObject) && (obj->kind != TextboxObject)) return; sendmessage(obj->handle, WM_PASTE, 0, 0L); }
void undotext(control obj) /* Why was this previously commented out? CJ */ { if (! obj) return; if ((obj->kind != FieldObject) && (obj->kind != TextboxObject)) return; sendmessage(obj->handle, EM_UNDO, 0, 0L); }
void selecttext(control obj, long start, long end) { int left, right; long length; if (! obj) return; if ((obj->kind != FieldObject) && (obj->kind != TextboxObject)) return; length = GetWindowTextLength(obj->handle); left = (start < 0) ? length : start; right = (end < 0) ? length : end; #ifdef WIN32 sendmessage(obj->handle, EM_SETSEL, left,right); #else sendmessage(obj->handle, EM_SETSEL, 0, MAKELONG(left,right)); #endif }
static void meta_flush(void) { if (!xymonmetaqueued) { dbgprintf("Flush, but xymonmeta is empty\n"); return; } sendmessage(STRBUF(metamsg), NULL, XYMON_TIMEOUT, NULL); meta_start(); /* Get ready for the next */ }
int type1(int *msgvec, int doign, int page) { int nlines, *ip; struct message *mp; char *cp; FILE *obuf; obuf = stdout; if (setjmp(pipestop)) goto close_pipe; if (value("interactive") != NULL && (page || (cp = value("crt")) != NULL)) { nlines = 0; if (!page) { for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) nlines += message[*ip - 1].m_lines; } if (page || nlines > (*cp ? atoi(cp) : realscreenheight)) { cp = value("PAGER"); if (cp == NULL || *cp == '\0') cp = _PATH_MORE; obuf = Popen(cp, "w"); if (obuf == NULL) { warnx("%s", cp); obuf = stdout; } else (void)signal(SIGPIPE, brokpipe); } } /* * Send messages to the output. * */ for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) { mp = &message[*ip - 1]; touch(mp); dot = mp; if (value("quiet") == NULL) fprintf(obuf, "Message %d:\n", *ip); (void)sendmessage(mp, obuf, doign ? ignore : 0, NULL); } close_pipe: if (obuf != stdout) { /* * Ignore SIGPIPE so it can't cause a duplicate close. */ (void)signal(SIGPIPE, SIG_IGN); (void)Pclose(obuf); (void)signal(SIGPIPE, SIG_DFL); } return (0); }
void send_to_all(t_datas *datas, char *msg, int needLogin, t_users *except) { t_list *elem; t_users *user; elem = datas->users; while (elem) { user = (t_users*)elem->datas; if (user != except) { if (needLogin && user->username[0] != 0) sendmessage(user->state, msg); else if (!needLogin) sendmessage(user->state, msg); } elem = elem->next; } }
void inserttext(control obj, char *text) { if (! obj) return; if ((obj->kind != FieldObject) && (obj->kind != TextboxObject)) return; text = to_dos_string(text); sendmessage(obj->handle, EM_REPLACESEL, 0, (long) text); if (text) discard(text); }
signed evse_cm_slac_match (struct session * session, struct channel * channel, struct message * message) { struct cm_slac_match_request * request = (struct cm_slac_match_request *) (message); struct cm_slac_match_confirm * confirm = (struct cm_slac_match_confirm *) (message); while (readmessage (channel, message, HOMEPLUG_MMV, (CM_SLAC_MATCH | MMTYPE_REQ)) > 0) { if (! memcmp (session->RunID, request->MatchVarField.RunID, sizeof (session->RunID))) { slac_debug (session, 0, __func__, "<-- CM_SLAC_MATCH.REQ"); memcpy (session->PEV_ID, request->MatchVarField.PEV_ID, sizeof (session->PEV_ID)); memcpy (session->PEV_MAC, request->MatchVarField.PEV_MAC, sizeof (session->PEV_MAC)); memcpy (session->RunID, request->MatchVarField.RunID, sizeof (session->RunID)); #if SLAC_DEBUG if (_anyset (session->flags, SLAC_VERBOSE)) { char string [256]; slac_debug (session, 0, __func__, "CM_SLAC_MATCH.REQ.APPLICATION_TYPE %d", request->APPLICATION_TYPE); slac_debug (session, 0, __func__, "CM_SLAC_MATCH.REQ.SECURITY_TYPE %d", request->SECURITY_TYPE); slac_debug (session, 0, __func__, "CM_SLAC_MATCH.REQ.MVFLength %d", LE16TOH (request->MVFLength)); slac_debug (session, 0, __func__, "CM_SLAC_MATCH.REQ.PEV_ID %s", HEXSTRING (string, request->MatchVarField.PEV_ID)); slac_debug (session, 0, __func__, "CM_SLAC_MATCH.REQ.PEV_MAC %s", HEXSTRING (string, request->MatchVarField.PEV_MAC)); slac_debug (session, 0, __func__, "CM_SLAC_MATCH.REQ.EVSE_ID %s", HEXSTRING (string, request->MatchVarField.EVSE_ID)); slac_debug (session, 0, __func__, "CM_SLAC_MATCH.REQ.EVSE_MAC %s", HEXSTRING (string, request->MatchVarField.EVSE_MAC)); slac_debug (session, 0, __func__, "CM_SLAC_MATCH.REQ.RunID %s", HEXSTRING (string, request->MatchVarField.RunID)); } #endif slac_debug (session, 0, __func__, "--> CM_SLAC_MATCH.CNF"); memset (message, 0, sizeof (* message)); EthernetHeader (& confirm->ethernet, session->PEV_MAC, channel->host, channel->type); HomePlugHeader1 (& confirm->homeplug, HOMEPLUG_MMV, (CM_SLAC_MATCH | MMTYPE_CNF)); confirm->APPLICATION_TYPE = session->APPLICATION_TYPE; confirm->SECURITY_TYPE = session->SECURITY_TYPE; confirm->MVFLength = HTOLE16 (sizeof (confirm->MatchVarField)); memcpy (confirm->MatchVarField.PEV_ID, session->PEV_ID, sizeof (confirm->MatchVarField.PEV_ID)); memcpy (confirm->MatchVarField.PEV_MAC, session->PEV_MAC, sizeof (confirm->MatchVarField.PEV_MAC)); memcpy (confirm->MatchVarField.EVSE_ID, session->EVSE_ID, sizeof (confirm->MatchVarField.EVSE_ID)); memcpy (confirm->MatchVarField.EVSE_MAC, session->EVSE_MAC, sizeof (confirm->MatchVarField.EVSE_MAC)); memcpy (confirm->MatchVarField.RunID, session->RunID, sizeof (confirm->MatchVarField.RunID)); memcpy (confirm->MatchVarField.NID, session->NID, sizeof (confirm->MatchVarField.NID)); memcpy (confirm->MatchVarField.NMK, session->NMK, sizeof (confirm->MatchVarField.NMK)); if (sendmessage (channel, message, sizeof (* confirm)) <= 0) { return (slac_debug (session, 1, __func__, CHANNEL_CANTSEND)); } return (0); } } return (slac_debug (session, session->exit, __func__, "<-- CM_SLAC_MATCH.REQ ?")); }
void textselection(control obj, long *start, long *end) { unsigned long sel; if (! obj) return; if ((obj->kind != FieldObject) && (obj->kind != TextboxObject)) return; sel = sendmessage(obj->handle, EM_GETSEL, 0, 0); if (start) *start = LOWORD(sel); if (end) *end = HIWORD(sel); }
char *sendmsg_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr) { char NXTACCTSECRET[512],destNXTaddr[256],msg[1024],*retstr = 0; copy_cJSON(destNXTaddr,objs[1]); copy_cJSON(NXTACCTSECRET,objs[2]); copy_cJSON(msg,objs[3]); //printf("sendmsg_func sender.(%s) valid.%d dest.(%s) (%s)\n",sender,valid,destNXTaddr,origargstr); if ( sender[0] != 0 && valid != 0 && destNXTaddr[0] != 0 ) retstr = sendmessage(sender,NXTACCTSECRET,msg,(int32_t)strlen(msg)+1,destNXTaddr,origargstr); else retstr = clonestr("{\"error\":\"invalid sendmessage request\"}"); return(retstr); }
/* * Save/copy the indicated messages at the end of the passed file name. * If mark is true, mark the message "saved." */ int save1(char str[], int mark, const char *cmd, struct ignoretab *ignore) { struct message *mp; char *file; const char *disp; int f, *msgvec, *ip; FILE *obuf; msgvec = (int *)salloc((msgCount + 2) * sizeof(*msgvec)); if ((file = snarf(str, &f)) == NULL) return (1); if (!f) { *msgvec = first(0, MMNORM); if (*msgvec == 0) { printf("No messages to %s.\n", cmd); return (1); } msgvec[1] = 0; } if (f && getmsglist(str, msgvec, 0) < 0) return (1); if ((file = expand(file)) == NULL) return (1); printf("\"%s\" ", file); (void)fflush(stdout); if (access(file, 0) >= 0) disp = "[Appended]"; else disp = "[New file]"; if ((obuf = Fopen(file, "a")) == NULL) { warn((char *)NULL); return (1); } for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) { mp = &message[*ip - 1]; touch(mp); if (sendmessage(mp, obuf, ignore, NULL) < 0) { warnx("%s", file); (void)Fclose(obuf); return (1); } if (mark) mp->m_flag |= MSAVED; } (void)fflush(obuf); if (ferror(obuf)) warn("%s", file); (void)Fclose(obuf); printf("%s\n", disp); return (0); }