MCPcopy Create free account
hub / github.com/F-Stack/f-stack / getenv_quad

Function getenv_quad

freebsd/kern/kern_environment.c:900–939  ·  view source on GitHub ↗

* Return a quad_t value from an environment variable. */

Source from the content-addressed store, hash-verified

898 * Return a quad_t value from an environment variable.
899 */
900int
901getenv_quad(const char *name, quad_t *data)
902{
903 const char *value;
904 char suffix, *vtp;
905 quad_t iv;
906
907 value = kenv_acquire(name);
908 if (value == NULL) {
909 goto error;
910 }
911 iv = strtoq(value, &vtp, 0);
912 if (vtp == value || (vtp[0] != '\0' && vtp[1] != '\0')) {
913 goto error;
914 }
915 suffix = vtp[0];
916 kenv_release(value);
917 switch (suffix) {
918 case 't': case 'T':
919 iv *= 1024;
920 /* FALLTHROUGH */
921 case 'g': case 'G':
922 iv *= 1024;
923 /* FALLTHROUGH */
924 case 'm': case 'M':
925 iv *= 1024;
926 /* FALLTHROUGH */
927 case 'k': case 'K':
928 iv *= 1024;
929 case '\0':
930 break;
931 default:
932 return (0);
933 }
934 *data = iv;
935 return (1);
936error:
937 kenv_release(value);
938 return (0);
939}
940
941/*
942 * Return a boolean value from an environment variable. This can be in

Callers 8

getenv_intFunction · 0.70
getenv_uintFunction · 0.70
getenv_int64Function · 0.70
getenv_uint64Function · 0.70
getenv_longFunction · 0.70
getenv_ulongFunction · 0.70
getmemsizeFunction · 0.50
getmemsizeFunction · 0.50

Calls 3

strtoqFunction · 0.85
kenv_acquireFunction · 0.70
kenv_releaseFunction · 0.70

Tested by

no test coverage detected