| 778 | ************************************************************************/ |
| 779 | |
| 780 | static int |
| 781 | ng_fixedstring_parse(const struct ng_parse_type *type, |
| 782 | const char *s, int *off, const u_char *const start, |
| 783 | u_char *const buf, int *buflen) |
| 784 | { |
| 785 | const struct ng_parse_fixedstring_info *const fi = type->info; |
| 786 | char *sval; |
| 787 | int len; |
| 788 | int slen; |
| 789 | |
| 790 | if ((sval = ng_get_string_token(s, off, &len, &slen)) == NULL) |
| 791 | return (EINVAL); |
| 792 | if (slen + 1 > fi->bufSize) { |
| 793 | free(sval, M_NETGRAPH_PARSE); |
| 794 | return (E2BIG); |
| 795 | } |
| 796 | *off += len; |
| 797 | bcopy(sval, buf, slen); |
| 798 | free(sval, M_NETGRAPH_PARSE); |
| 799 | bzero(buf + slen, fi->bufSize - slen); |
| 800 | *buflen = fi->bufSize; |
| 801 | return (0); |
| 802 | } |
| 803 | |
| 804 | static int |
| 805 | ng_fixedstring_unparse(const struct ng_parse_type *type, |
nothing calls this directly
no test coverage detected