X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=util.c;h=3e8d56eaebbc50855ed2cde7026b5bf5be7c0767;hb=fa02f7fc18d19b7c9e930c8471fcda949794f764;hp=241196227a80cd71e655daea6d5368fabadf37dd;hpb=7dae56bc17f51e875b436ec63e035be12c4a6fcf;p=secnet.git diff --git a/util.c b/util.c index 2411962..3e8d56e 100644 --- a/util.c +++ b/util.c @@ -183,15 +183,6 @@ char *write_mpstring(MP_INT *a) return buff; } -int32_t write_mpbin(MP_INT *a, uint8_t *buffer, int32_t buflen) -{ - char *hb = write_mpstring(a); - int32_t len; - hex_decode(buffer, buflen, &len, hb, True); - free(hb); - return len; -} - #define DEFINE_SETFDFLAG(fn,FL,FLAG) \ void fn(int fd) { \ int r=fcntl(fd, F_GET##FL); \ @@ -427,6 +418,11 @@ const char *priomsg_getmessage(const struct priomsg *pm, const char *defmsg) return defmsg; } +bool_t priomsg_update_fixed(struct priomsg *pm, int prio, const char *m) { + if (!priomsg_update_p(pm, prio)) return False; + truncmsg_add_string(&pm->m, m); + return True; +} void buffer_new(struct buffer_if *buf, int32_t len) { @@ -526,10 +522,11 @@ void send_nak(const struct comm_addr *dest, uint32_t our_index, buf_append_uint32(buf,our_index); buf_append_uint32(buf,LABEL_NAK); if (logwhy) - Message(M_INFO,"%s: %08"PRIx32"<-%08"PRIx32": %08"PRIx32":" - " %s; sending NAK\n", + Message(M_INFO,"%s: sending NAK for" + " %08"PRIx32" %08"PRIx32"<-%08"PRIx32":" + " %s\n", comm_addr_to_string(dest), - our_index, their_index, msgtype, logwhy); + msgtype, our_index, their_index, logwhy); dest->comm->sendmsg(dest->comm->st, buf, dest, 0); } @@ -717,6 +714,15 @@ const char *pollbadbit(int revents) return 0; } +void pathprefix_template_init(struct pathprefix_template *out, + const char *prefix, int maxsuffix) +{ + size_t l=strlen(prefix); + NEW_ARY(out->buffer,l+maxsuffix+1); + strcpy(out->buffer,prefix); + out->write_here=out->buffer+l; +} + enum async_linebuf_result async_linebuf_read(struct pollfd *pfd, struct buffer_if *buf, const char **emsg_out)