string_unquote.c (484B)
1 /* ISC license. */ 2 3 #include <string.h> 4 #include <errno.h> 5 #include <skalibs/skamisc.h> 6 7 int string_unquote (char *d, size_t *w, char const *s, size_t len, size_t *r) 8 { 9 if (!len-- || (*s++ != '"')) return (errno = EINVAL, 0) ; 10 { 11 size_t rr, ww ; 12 char tmp[len ? len : 1] ; 13 if (!string_unquote_withdelim(tmp, &ww, s, len, &rr, "\"", 1)) return 0 ; 14 if (rr == len) return (errno = EPIPE, 0) ; 15 memcpy(d, tmp, ww) ; 16 *w = ww ; 17 *r = rr + 2 ; 18 } 19 return 1 ; 20 }