Lines Matching +full:mem +full:- +full:base

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
46 #include "un-namespace.h"
71 * virtual database. 0 is returned on success, -1 on failure.
86 return (-1); in cgetset()
114 * Skip past the current capability field - it's either the in cgetcap()
152 * -1 if the requested record couldn't be found, -2 if a system error was
153 * encountered (couldn't open/read a file, etc.), and -3 if a potential
161 return (getent(buf, &dummy, db_array, -1, name, 0, NULL)); in cgetent()
165 * Getent implements the functions of cgetent. If fd is non-negative,
198 return (-3); in getent()
206 return (-2); in getent()
220 return (-2); in getent()
246 (void)capdbp->close(capdbp); in getent()
251 if (capdbp->close(capdbp) < 0) { in getent()
253 return (-2); in getent()
257 return (-2); in getent()
304 return (-2); in getent()
306 fd = -1; in getent()
317 if (rp > record && *(rp-1) == '\\') { in getent()
318 rp--; in getent()
334 pos = rp - record; in getent()
335 newsize = r_end - record + BFRAG; in getent()
341 return (-2); in getent()
379 return (-1); in getent()
417 *(s - 1) = '\0'; in getent()
420 tcstart = tc - 3; in getent()
421 tclen = s - tcstart; in getent()
430 if (iret < -1) { in getent()
439 if (iret == -1) { in getent()
440 *(s - 1) = ':'; in getent()
441 scan = s - 1; in getent()
455 newilen -= s - newicap; in getent()
458 /* make sure interpolated record is `:'-terminated */ in getent()
460 if (*(s-1) != ':') { in getent()
469 diff = newilen - tclen; in getent()
470 if (diff >= r_end - rp) { in getent()
474 pos = rp - record; in getent()
475 newsize = r_end - record + diff + BFRAG; in getent()
476 tcpos = tcstart - record; in getent()
477 tcposend = tcend - record; in getent()
484 return (-2); in getent()
496 bcopy(tcend, s, rp - tcend); in getent()
505 scan = s-1; in getent()
515 *len = rp - record - 1; /* don't count NUL */ in getent()
518 reallocf(record, (size_t)(rp - record))) == NULL) { in getent()
520 return (-2); in getent()
537 return (-2); in cdbget()
543 switch(capdbp->get(capdbp, &key, &data, 0)) { in cdbget()
544 case -1: in cdbget()
546 return (-2); in cdbget()
549 return (-1); in cdbget()
557 key.size = data.size - 1; in cdbget()
567 * record buf, -1 if not.
575 return -1; in cgetmatch()
599 bp--; /* a '|' or ':' may have stopped the match */ in cgetmatch()
602 return (-1); /* match failed totally */ in cgetmatch()
640 * upon returning an entry with more remaining, and -1 if an error occurs.
655 return (-1); in cgetnext()
672 return (-1); in cgetnext()
680 return (-1); in cgetnext()
685 line[len - 1] = '\0'; in cgetnext()
692 if (line[len - 2] == '\\') in cgetnext()
698 if (line[len - 2] == '\\') in cgetnext()
736 return (-1); in cgetnext()
739 return (-1); in cgetnext()
742 line[len - 1] = '\0'; in cgetnext()
761 status = getent(bp, &dummy, db_array, -1, buf, 0, NULL); in cgetnext()
762 if (status == -2 || status == -3) in cgetnext()
775 * NUL is returned on success, -1 if the requested string capability
776 * couldn't be found, -2 if a system error was encountered (storage
785 char *mem; in cgetstr() local
792 return (-1); in cgetstr()
798 if ((mem = malloc(SFRAG)) == NULL) { in cgetstr()
800 return (-2); /* couldn't even allocate the first fragment */ in cgetstr()
803 mp = mem; in cgetstr()
808 * There is always room for one more character in mem. in cgetstr()
809 * Mp always points just past last character in mem. in cgetstr()
831 n = n * 8 + (*bp++ - '0'); in cgetstr()
832 } while (--i && '0' <= *bp && *bp <= '7'); in cgetstr()
862 *mp++ = *(bp-1); in cgetstr()
867 m_room--; in cgetstr()
874 size_t size = mp - mem; in cgetstr()
876 if ((mem = reallocf(mem, size + SFRAG)) == NULL) in cgetstr()
877 return (-2); in cgetstr()
879 mp = mem + size; in cgetstr()
883 m_room--; in cgetstr()
884 len = mp - mem - 1; in cgetstr()
890 if ((mem = reallocf(mem, (size_t)(mp - mem))) == NULL) in cgetstr()
891 return (-2); in cgetstr()
892 *str = mem; in cgetstr()
903 * -1 if the requested string capability couldn't be found, -2 if a system
912 char *mem; in cgetustr() local
918 return (-1); in cgetustr()
924 if ((mem = malloc(SFRAG)) == NULL) { in cgetustr()
926 return (-2); /* couldn't even allocate the first fragment */ in cgetustr()
929 mp = mem; in cgetustr()
934 * There is always room for one more character in mem. in cgetustr()
935 * Mp always points just past last character in mem. in cgetustr()
939 m_room--; in cgetustr()
946 size_t size = mp - mem; in cgetustr()
948 if ((mem = reallocf(mem, size + SFRAG)) == NULL) in cgetustr()
949 return (-2); in cgetustr()
951 mp = mem + size; in cgetustr()
955 m_room--; in cgetustr()
956 len = mp - mem - 1; in cgetustr()
962 if ((mem = reallocf(mem, (size_t)(mp - mem))) == NULL) in cgetustr()
963 return (-2); in cgetustr()
964 *str = mem; in cgetustr()
971 * the long pointed to by num. 0 is returned on success, -1 if the requested
978 int base, digit; in cgetnum() local
986 return (-1); in cgetnum()
989 * Look at value and determine numeric base: in cgetnum()
998 base = 16; in cgetnum()
1000 base = 8; in cgetnum()
1002 base = 10; in cgetnum()
1010 digit = *bp - '0'; in cgetnum()
1012 digit = 10 + *bp - 'a'; in cgetnum()
1014 digit = 10 + *bp - 'A'; in cgetnum()
1018 if (digit >= base) in cgetnum()
1021 n = n * base + digit; in cgetnum()