X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=util.c;h=3e8d56eaebbc50855ed2cde7026b5bf5be7c0767;hb=1f4a8ae2a93e1d9abab0fae7bd7d545881cfec60;hp=977e131fbeda106fcaa8fe7964af878ccbe2ebe9;hpb=3a2c5e1f10dc6b3cc86f74c287d8c14be14d7e80;p=secnet.git diff --git a/util.c b/util.c index 977e131..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); \ @@ -723,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)