mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Change signature of strn_fromprint()
The 'dst' parameter is now (char *) instead of (unsigned char *) because in general it is used to produce human-readable (ASCII) strings, not binary data.
This commit is contained in:
parent
c8bf8a7733
commit
43e76ec7b5
@ -121,9 +121,9 @@ static int app_echo(const struct cli_parsed *parsed, struct cli_context *context
|
||||
const char *arg = parsed->args[i];
|
||||
DEBUGF(verbose, "echo:argv[%d]=\"%s\"", i, arg);
|
||||
if (escapes) {
|
||||
unsigned char buf[strlen(arg)];
|
||||
char buf[strlen(arg)];
|
||||
size_t len = strn_fromprint(buf, sizeof buf, arg, 0, '\0', NULL);
|
||||
cli_write(context, (char *)buf, len);
|
||||
cli_write(context, buf, len);
|
||||
} else
|
||||
cli_puts(context, arg);
|
||||
cli_delim(context, NULL);
|
||||
|
@ -744,7 +744,7 @@ static int load_did_name(keypair *kp, const char *text)
|
||||
return WHY("duplicate DID");
|
||||
const char *e = NULL;
|
||||
bzero(kp->private_key, kp->private_key_len);
|
||||
strn_fromprint(kp->private_key, kp->private_key_len, t, 0, '"', &e);
|
||||
strn_fromprint((char *)kp->private_key, kp->private_key_len, t, 0, '"', &e);
|
||||
if (*e != '"')
|
||||
return WHY("malformed DID quoted string");
|
||||
t = e + 1;
|
||||
@ -754,7 +754,7 @@ static int load_did_name(keypair *kp, const char *text)
|
||||
return WHY("duplicate Name");
|
||||
const char *e = NULL;
|
||||
bzero(kp->public_key, kp->public_key_len);
|
||||
strn_fromprint(kp->public_key, kp->public_key_len, t, 0, '"', &e);
|
||||
strn_fromprint((char *)kp->public_key, kp->public_key_len, t, 0, '"', &e);
|
||||
if (*e != '"')
|
||||
return WHY("malformed Name quoted string");
|
||||
t = e + 1;
|
||||
|
6
str.c
6
str.c
@ -521,10 +521,10 @@ size_t toprint_str_len(const char *srcStr, const char quotes[2])
|
||||
return srcStr ? strbuf_count(strbuf_toprint_quoted(strbuf_local(NULL, 0), quotes, srcStr)) : 4;
|
||||
}
|
||||
|
||||
size_t strn_fromprint(unsigned char *dst, size_t dstsiz, const char *src, size_t srclen, char endquote, const char **afterp)
|
||||
size_t strn_fromprint(char *dst, size_t dstsiz, const char *src, size_t srclen, char endquote, const char **afterp)
|
||||
{
|
||||
unsigned char *const odst = dst;
|
||||
unsigned char *const edst = dst + dstsiz;
|
||||
char *const odst = dst;
|
||||
char *const edst = dst + dstsiz;
|
||||
const char *const esrc = srclen ? src + srclen : NULL;
|
||||
while ((src < esrc || !esrc) && *src && *src != endquote && dst < edst) {
|
||||
switch (*src) {
|
||||
|
2
str.h
2
str.h
@ -235,7 +235,7 @@ char *toprint(char *dstStr, ssize_t dstBufSiz, const char *srcBuf, size_t srcByt
|
||||
char *toprint_str(char *dstStr, ssize_t dstBufSiz, const char *srcStr, const char quotes[2]);
|
||||
size_t toprint_len(const char *srcBuf, size_t srcBytes, const char quotes[2]);
|
||||
size_t toprint_str_len(const char *srcStr, const char quotes[2]);
|
||||
size_t strn_fromprint(unsigned char *dst, size_t dstsiz, const char *src, size_t srclen, char endquote, const char **afterp);
|
||||
size_t strn_fromprint(char *dst, size_t dstsiz, const char *src, size_t srclen, char endquote, const char **afterp);
|
||||
|
||||
#define alloca_toprint_quoted(dstsiz,buf,len,quotes) toprint((char *)alloca((dstsiz) == -1 ? toprint_len((const char *)(buf),(len), (quotes)) + 1 : (size_t)(dstsiz)), (size_t)(dstsiz), (const char *)(buf), (len), (quotes))
|
||||
#define alloca_toprint(dstsiz,buf,len) alloca_toprint_quoted(dstsiz,buf,len,"``")
|
||||
|
Loading…
Reference in New Issue
Block a user