repo
stringlengths
6
47
file_url
stringlengths
77
269
file_path
stringlengths
5
186
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-07 08:35:43
2026-01-07 08:55:24
truncated
bool
2 classes
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_freebsd_386.go
vendor/modernc.org/libc/netdb/capi_freebsd_386.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_freebsd_386.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_netbsd_arm.go
vendor/modernc.org/libc/netdb/netdb_netbsd_arm.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_netbsd_arm.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AI_ADDRCONFIG = 0x00000400 // netdb.h:269:1: AI_CANONNAME = 0x00000002 // netdb.h:266:1: AI_MASK = 3087 // netdb.h:273:1: AI_NUMERICHOST = 0x00000004 // netdb.h:267:1: AI_NUMERICSERV = 0x00000008 // netdb.h:268:1: AI_PASSIVE = 0x00000001 // netdb.h:265:1: AI_SRV = 0x00000800 // netdb.h:272:1: EAI_ADDRFAMILY = 1 // netdb.h:243:1: EAI_AGAIN = 2 // netdb.h:244:1: EAI_BADFLAGS = 3 // netdb.h:245:1: EAI_BADHINTS = 12 // netdb.h:254:1: EAI_FAIL = 4 // netdb.h:246:1: EAI_FAMILY = 5 // netdb.h:247:1: EAI_MAX = 15 // netdb.h:257:1: EAI_MEMORY = 6 // netdb.h:248:1: EAI_NODATA = 7 // netdb.h:249:1: EAI_NONAME = 8 // netdb.h:250:1: EAI_OVERFLOW = 14 // netdb.h:256:1: EAI_PROTOCOL = 13 // netdb.h:255:1: EAI_SERVICE = 9 // netdb.h:251:1: EAI_SOCKTYPE = 10 // netdb.h:252:1: EAI_SYSTEM = 11 // netdb.h:253:1: HOST_NOT_FOUND = 1 // netdb.h:230:1: INT16_MAX = 32767 // common_int_limits.h:53:1: INT16_MIN = -32768 // common_int_limits.h:47:1: INT32_MAX = 2147483647 // common_int_limits.h:54:1: INT32_MIN = -2147483648 // common_int_limits.h:48:1: INT64_MAX = 9223372036854775807 // common_int_limits.h:55:1: INT64_MIN = -9223372036854775808 // common_int_limits.h:49:1: INT8_MAX = 127 // common_int_limits.h:52:1: INT8_MIN = -128 // common_int_limits.h:46:1: INTMAX_MAX = 9223372036854775807 // common_int_limits.h:111:1: INTMAX_MIN = -9223372036854775808 // common_int_limits.h:110:1: INTPTR_MAX = 2147483647 // common_int_limits.h:105:1: INTPTR_MIN = -2147483648 // common_int_limits.h:104:1: INT_FAST16_MAX = 2147483647 // common_int_limits.h:93:1: INT_FAST16_MIN = -2147483648 // common_int_limits.h:87:1: INT_FAST32_MAX = 2147483647 // common_int_limits.h:94:1: INT_FAST32_MIN = -2147483648 // common_int_limits.h:88:1: INT_FAST64_MAX = 9223372036854775807 // common_int_limits.h:95:1: INT_FAST64_MIN = -9223372036854775808 // common_int_limits.h:89:1: INT_FAST8_MAX = 2147483647 // common_int_limits.h:92:1: INT_FAST8_MIN = -2147483648 // common_int_limits.h:86:1: INT_LEAST16_MAX = 32767 // common_int_limits.h:73:1: INT_LEAST16_MIN = -32768 // common_int_limits.h:67:1: INT_LEAST32_MAX = 2147483647 // common_int_limits.h:74:1: INT_LEAST32_MIN = -2147483648 // common_int_limits.h:68:1: INT_LEAST64_MAX = 9223372036854775807 // common_int_limits.h:75:1: INT_LEAST64_MIN = -9223372036854775808 // common_int_limits.h:69:1: INT_LEAST8_MAX = 127 // common_int_limits.h:72:1: INT_LEAST8_MIN = -128 // common_int_limits.h:66:1: NETDB_INTERNAL = -1 // netdb.h:226:1: NETDB_SUCCESS = 0 // netdb.h:227:1: NI_DGRAM = 0x00000010 // netdb.h:300:1: NI_MAXHOST = 1025 // netdb.h:289:1: NI_MAXSERV = 32 // netdb.h:290:1: NI_NAMEREQD = 0x00000004 // netdb.h:298:1: NI_NOFQDN = 0x00000001 // netdb.h:296:1: NI_NUMERICHOST = 0x00000002 // netdb.h:297:1: NI_NUMERICSCOPE = 0x00000040 // netdb.h:302:1: NI_NUMERICSERV = 0x00000008 // netdb.h:299:1: NI_WITHSCOPEID = 0x00000020 // netdb.h:301:1: NO_ADDRESS = 4 // netdb.h:235:1: NO_DATA = 4 // netdb.h:233:1: NO_RECOVERY = 3 // netdb.h:232:1: PRIX16 = "X" // int_fmtio.h:186:1: PRIX32 = "X" // int_fmtio.h:187:1: PRIX64 = "llX" // int_fmtio.h:189:1: PRIX8 = "X" // int_fmtio.h:185:1: PRIXFAST16 = "X" // int_fmtio.h:202:1: PRIXFAST32 = "X" // int_fmtio.h:203:1: PRIXFAST64 = "llX" // int_fmtio.h:205:1: PRIXFAST8 = "X" // int_fmtio.h:201:1: PRIXLEAST16 = "X" // int_fmtio.h:194:1: PRIXLEAST32 = "X" // int_fmtio.h:195:1: PRIXLEAST64 = "llX" // int_fmtio.h:197:1: PRIXLEAST8 = "X" // int_fmtio.h:193:1: PRIXMAX = "llX" // int_fmtio.h:206:1: PRIXPTR = "lX" // int_fmtio.h:211:1: PRId16 = "d" // int_fmtio.h:44:1: PRId32 = "d" // int_fmtio.h:45:1: PRId64 = "lld" // int_fmtio.h:47:1: PRId8 = "d" // int_fmtio.h:43:1: PRIdFAST16 = "d" // int_fmtio.h:60:1: PRIdFAST32 = "d" // int_fmtio.h:61:1: PRIdFAST64 = "lld" // int_fmtio.h:63:1: PRIdFAST8 = "d" // int_fmtio.h:59:1: PRIdLEAST16 = "d" // int_fmtio.h:52:1: PRIdLEAST32 = "d" // int_fmtio.h:53:1: PRIdLEAST64 = "lld" // int_fmtio.h:55:1: PRIdLEAST8 = "d" // int_fmtio.h:51:1: PRIdMAX = "lld" // int_fmtio.h:64:1: PRIdPTR = "ld" // int_fmtio.h:69:1: PRIi16 = "i" // int_fmtio.h:72:1: PRIi32 = "i" // int_fmtio.h:73:1: PRIi64 = "lli" // int_fmtio.h:75:1: PRIi8 = "i" // int_fmtio.h:71:1: PRIiFAST16 = "i" // int_fmtio.h:88:1: PRIiFAST32 = "i" // int_fmtio.h:89:1: PRIiFAST64 = "lli" // int_fmtio.h:91:1: PRIiFAST8 = "i" // int_fmtio.h:87:1: PRIiLEAST16 = "i" // int_fmtio.h:80:1: PRIiLEAST32 = "i" // int_fmtio.h:81:1: PRIiLEAST64 = "lli" // int_fmtio.h:83:1: PRIiLEAST8 = "i" // int_fmtio.h:79:1: PRIiMAX = "lli" // int_fmtio.h:92:1: PRIiPTR = "li" // int_fmtio.h:97:1: PRIo16 = "o" // int_fmtio.h:102:1: PRIo32 = "o" // int_fmtio.h:103:1: PRIo64 = "llo" // int_fmtio.h:105:1: PRIo8 = "o" // int_fmtio.h:101:1: PRIoFAST16 = "o" // int_fmtio.h:118:1: PRIoFAST32 = "o" // int_fmtio.h:119:1: PRIoFAST64 = "llo" // int_fmtio.h:121:1: PRIoFAST8 = "o" // int_fmtio.h:117:1: PRIoLEAST16 = "o" // int_fmtio.h:110:1: PRIoLEAST32 = "o" // int_fmtio.h:111:1: PRIoLEAST64 = "llo" // int_fmtio.h:113:1: PRIoLEAST8 = "o" // int_fmtio.h:109:1: PRIoMAX = "llo" // int_fmtio.h:122:1: PRIoPTR = "lo" // int_fmtio.h:127:1: PRIu16 = "u" // int_fmtio.h:130:1: PRIu32 = "u" // int_fmtio.h:131:1: PRIu64 = "llu" // int_fmtio.h:133:1: PRIu8 = "u" // int_fmtio.h:129:1: PRIuFAST16 = "u" // int_fmtio.h:146:1: PRIuFAST32 = "u" // int_fmtio.h:147:1: PRIuFAST64 = "llu" // int_fmtio.h:149:1: PRIuFAST8 = "u" // int_fmtio.h:145:1: PRIuLEAST16 = "u" // int_fmtio.h:138:1: PRIuLEAST32 = "u" // int_fmtio.h:139:1: PRIuLEAST64 = "llu" // int_fmtio.h:141:1: PRIuLEAST8 = "u" // int_fmtio.h:137:1: PRIuMAX = "llu" // int_fmtio.h:150:1: PRIuPTR = "lu" // int_fmtio.h:155:1: PRIx16 = "x" // int_fmtio.h:158:1: PRIx32 = "x" // int_fmtio.h:159:1: PRIx64 = "llx" // int_fmtio.h:161:1: PRIx8 = "x" // int_fmtio.h:157:1: PRIxFAST16 = "x" // int_fmtio.h:174:1: PRIxFAST32 = "x" // int_fmtio.h:175:1: PRIxFAST64 = "llx" // int_fmtio.h:177:1: PRIxFAST8 = "x" // int_fmtio.h:173:1: PRIxLEAST16 = "x" // int_fmtio.h:166:1: PRIxLEAST32 = "x" // int_fmtio.h:167:1: PRIxLEAST64 = "llx" // int_fmtio.h:169:1: PRIxLEAST8 = "x" // int_fmtio.h:165:1: PRIxMAX = "llx" // int_fmtio.h:178:1: PRIxPTR = "lx" // int_fmtio.h:183:1: PTRDIFF_MAX = 2147483647 // common_int_limits.h:121:1: PTRDIFF_MIN = -2147483648 // common_int_limits.h:120:1: SCNd16 = "hd" // int_fmtio.h:216:1: SCNd32 = "d" // int_fmtio.h:217:1: SCNd64 = "lld" // int_fmtio.h:219:1: SCNd8 = "hhd" // int_fmtio.h:215:1: SCNdFAST16 = "d" // int_fmtio.h:232:1: SCNdFAST32 = "d" // int_fmtio.h:233:1: SCNdFAST64 = "lld" // int_fmtio.h:235:1: SCNdFAST8 = "d" // int_fmtio.h:231:1: SCNdLEAST16 = "hd" // int_fmtio.h:224:1: SCNdLEAST32 = "d" // int_fmtio.h:225:1: SCNdLEAST64 = "lld" // int_fmtio.h:227:1: SCNdLEAST8 = "hhd" // int_fmtio.h:223:1: SCNdMAX = "lld" // int_fmtio.h:236:1: SCNdPTR = "ld" // int_fmtio.h:241:1: SCNi16 = "hi" // int_fmtio.h:244:1: SCNi32 = "i" // int_fmtio.h:245:1: SCNi64 = "lli" // int_fmtio.h:247:1: SCNi8 = "hhi" // int_fmtio.h:243:1: SCNiFAST16 = "i" // int_fmtio.h:260:1: SCNiFAST32 = "i" // int_fmtio.h:261:1: SCNiFAST64 = "lli" // int_fmtio.h:263:1: SCNiFAST8 = "i" // int_fmtio.h:259:1: SCNiLEAST16 = "hi" // int_fmtio.h:252:1: SCNiLEAST32 = "i" // int_fmtio.h:253:1: SCNiLEAST64 = "lli" // int_fmtio.h:255:1: SCNiLEAST8 = "hhi" // int_fmtio.h:251:1: SCNiMAX = "lli" // int_fmtio.h:264:1: SCNiPTR = "li" // int_fmtio.h:269:1: SCNo16 = "ho" // int_fmtio.h:274:1: SCNo32 = "o" // int_fmtio.h:275:1: SCNo64 = "llo" // int_fmtio.h:277:1: SCNo8 = "hho" // int_fmtio.h:273:1: SCNoFAST16 = "o" // int_fmtio.h:290:1: SCNoFAST32 = "o" // int_fmtio.h:291:1: SCNoFAST64 = "llo" // int_fmtio.h:293:1: SCNoFAST8 = "o" // int_fmtio.h:289:1: SCNoLEAST16 = "ho" // int_fmtio.h:282:1: SCNoLEAST32 = "o" // int_fmtio.h:283:1: SCNoLEAST64 = "llo" // int_fmtio.h:285:1: SCNoLEAST8 = "hho" // int_fmtio.h:281:1: SCNoMAX = "llo" // int_fmtio.h:294:1: SCNoPTR = "lo" // int_fmtio.h:299:1: SCNu16 = "hu" // int_fmtio.h:302:1: SCNu32 = "u" // int_fmtio.h:303:1: SCNu64 = "llu" // int_fmtio.h:305:1: SCNu8 = "hhu" // int_fmtio.h:301:1: SCNuFAST16 = "u" // int_fmtio.h:318:1: SCNuFAST32 = "u" // int_fmtio.h:319:1: SCNuFAST64 = "llu" // int_fmtio.h:321:1: SCNuFAST8 = "u" // int_fmtio.h:317:1: SCNuLEAST16 = "hu" // int_fmtio.h:310:1: SCNuLEAST32 = "u" // int_fmtio.h:311:1: SCNuLEAST64 = "llu" // int_fmtio.h:313:1: SCNuLEAST8 = "hhu" // int_fmtio.h:309:1: SCNuMAX = "llu" // int_fmtio.h:322:1: SCNuPTR = "lu" // int_fmtio.h:327:1: SCNx16 = "hx" // int_fmtio.h:330:1: SCNx32 = "x" // int_fmtio.h:331:1: SCNx64 = "llx" // int_fmtio.h:333:1: SCNx8 = "hhx" // int_fmtio.h:329:1: SCNxFAST16 = "x" // int_fmtio.h:346:1: SCNxFAST32 = "x" // int_fmtio.h:347:1: SCNxFAST64 = "llx" // int_fmtio.h:349:1: SCNxFAST8 = "x" // int_fmtio.h:345:1: SCNxLEAST16 = "hx" // int_fmtio.h:338:1: SCNxLEAST32 = "x" // int_fmtio.h:339:1: SCNxLEAST64 = "llx" // int_fmtio.h:341:1: SCNxLEAST8 = "hhx" // int_fmtio.h:337:1: SCNxMAX = "llx" // int_fmtio.h:350:1: SCNxPTR = "lx" // int_fmtio.h:355:1: SCOPE_DELIMITER = 37 // netdb.h:308:1: SIG_ATOMIC_MAX = 2147483647 // common_int_limits.h:125:1: SIG_ATOMIC_MIN = -2147483648 // common_int_limits.h:124:1: SIZE_MAX = 4294967295 // common_int_limits.h:128:1: TRY_AGAIN = 2 // netdb.h:231:1: UINT16_MAX = 65535 // common_int_limits.h:59:1: UINT32_MAX = 4294967295 // common_int_limits.h:60:1: UINT64_MAX = 18446744073709551615 // common_int_limits.h:61:1: UINT8_MAX = 255 // common_int_limits.h:58:1: UINTMAX_MAX = 18446744073709551615 // common_int_limits.h:112:1: UINTPTR_MAX = 4294967295 // common_int_limits.h:106:1: UINT_FAST16_MAX = 4294967295 // common_int_limits.h:99:1: UINT_FAST32_MAX = 4294967295 // common_int_limits.h:100:1: UINT_FAST64_MAX = 18446744073709551615 // common_int_limits.h:101:1: UINT_FAST8_MAX = 4294967295 // common_int_limits.h:98:1: UINT_LEAST16_MAX = 65535 // common_int_limits.h:79:1: UINT_LEAST32_MAX = 4294967295 // common_int_limits.h:80:1: UINT_LEAST64_MAX = 18446744073709551615 // common_int_limits.h:81:1: UINT_LEAST8_MAX = 255 // common_int_limits.h:78:1: WCHAR_MAX = 2147483647 // wchar_limits.h:50:1: WCHAR_MIN = -2147483648 // wchar_limits.h:42:1: WINT_MAX = 2147483647 // wchar_limits.h:68:1: WINT_MIN = -2147483648 // wchar_limits.h:60:1: X_ARM_ARCH_4T = 0 // cdefs.h:44:1: X_ARM_ARCH_5 = 0 // cdefs.h:40:1: X_ARM_ARCH_5T = 0 // cdefs.h:36:1: X_ARM_ARCH_6 = 0 // cdefs.h:31:1: X_ARM_ARCH_7 = 0 // cdefs.h:20:1: X_ARM_ARCH_DWORD_OK = 0 // cdefs.h:51:1: X_ARM_ARCH_T2 = 0 // cdefs.h:24:1: X_ARM_CDEFS_H_ = 0 // cdefs.h:4:1: X_ARM_INT_CONST_H_ = 0 // int_const.h:33:1: X_ARM_INT_FMTIO_H_ = 0 // int_fmtio.h:33:1: X_ARM_INT_LIMITS_H_ = 0 // int_limits.h:33:1: X_ARM_INT_MWGWTYPES_H_ = 0 // int_mwgwtypes.h:33:1: X_ARM_INT_TYPES_H_ = 0 // int_types.h:33:1: X_ARM_WCHAR_LIMITS_H_ = 0 // wchar_limits.h:33:1: X_BSD_INT16_T_ = 0 // stdint.h:50:1: X_BSD_INT32_T_ = 0 // stdint.h:60:1: X_BSD_INT64_T_ = 0 // stdint.h:70:1: X_BSD_INT8_T_ = 0 // stdint.h:40:1: X_BSD_INTPTR_T_ = 0 // stdint.h:80:1: X_BSD_UINT16_T_ = 0 // stdint.h:55:1: X_BSD_UINT32_T_ = 0 // stdint.h:65:1: X_BSD_UINT64_T_ = 0 // stdint.h:75:1: X_BSD_UINT8_T_ = 0 // stdint.h:45:1: X_BSD_UINTPTR_T_ = 0 // stdint.h:85:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_INTTYPES_H_ = 0 // inttypes.h:33:1: X_NETBSD_SOURCE = 1 // featuretest.h:70:1: X_NETDB_H_ = 0 // netdb.h:91:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:113:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:116:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:119:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:122:1: X_PATH_SERVICES = "/etc/services" // netdb.h:125:1: X_PATH_SERVICES_CDB = "/var/db/services.cdb" // netdb.h:128:1: X_PATH_SERVICES_DB = "/var/db/services.db" // netdb.h:131:1: X_SYS_ANSI_H_ = 0 // ansi.h:33:1: X_SYS_CDEFS_ELF_H_ = 0 // cdefs_elf.h:31:1: X_SYS_CDEFS_H_ = 0 // cdefs.h:37:1: X_SYS_COMMON_ANSI_H_ = 0 // common_ansi.h:33:1: X_SYS_COMMON_INT_LIMITS_H_ = 0 // common_int_limits.h:33:1: X_SYS_COMMON_INT_MWGWTYPES_H_ = 0 // common_int_mwgwtypes.h:33:1: X_SYS_COMMON_INT_TYPES_H_ = 0 // common_int_types.h:33:1: X_SYS_INTTYPES_H_ = 0 // inttypes.h:33:1: X_SYS_STDINT_H_ = 0 // stdint.h:33:1: ) type Ptrdiff_t = int32 /* <builtin>:3:26 */ type Size_t = uint32 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // return true if value 'a' fits in type 't' // $NetBSD: endian_machdep.h,v 1.9 2014/01/29 01:03:13 matt Exp $ // __ARMEB__ or __AARCH64EB__ is predefined when building big-endian ARM. // $NetBSD: ansi.h,v 1.14 2011/07/17 20:54:54 joerg Exp $ // - // Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc. // All rights reserved. // // This code is derived from software contributed to The NetBSD Foundation // by Jun-ichiro itojun Hagino and by Klaus Klein. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS // ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // $NetBSD: ansi.h,v 1.18 2019/05/07 03:49:26 kamil Exp $ // $NetBSD: common_ansi.h,v 1.1 2014/08/19 07:27:31 matt Exp $ // - // Copyright (c) 2014 The NetBSD Foundation, Inc. // All rights reserved. // // This code is derived from software contributed to The NetBSD Foundation // by Matt Thomas of 3am Software Foundry. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS // ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // $NetBSD: cdefs.h,v 1.141 2019/02/21 21:34:05 christos Exp $ // * Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 // $NetBSD: int_types.h,v 1.17 2014/07/25 21:43:13 joerg Exp $ // - // Copyright (c) 2014 The NetBSD Foundation, Inc. // All rights reserved. // // This code is derived from software contributed to The NetBSD Foundation // by Matt Thomas of 3am Software Foundry. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS // ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // $NetBSD: common_int_types.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ // - // Copyright (c) 2014 The NetBSD Foundation, Inc. // All rights reserved. // // This code is derived from software contributed to The NetBSD Foundation // by Joerg Sonnenberger. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS // ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // 7.18.1 Integer types // 7.18.1.1 Exact-width integer types type X__int8_t = int8 /* common_int_types.h:45:27 */ type X__uint8_t = uint8 /* common_int_types.h:46:27 */ type X__int16_t = int16 /* common_int_types.h:47:27 */ type X__uint16_t = uint16 /* common_int_types.h:48:27 */ type X__int32_t = int32 /* common_int_types.h:49:27 */ type X__uint32_t = uint32 /* common_int_types.h:50:27 */ type X__int64_t = int64 /* common_int_types.h:51:27 */ type X__uint64_t = uint64 /* common_int_types.h:52:27 */ // 7.18.1.4 Integer types capable of holding object pointers type X__intptr_t = int32 /* common_int_types.h:58:27 */ type X__uintptr_t = uint32 /* common_int_types.h:59:26 */ // Types which are fundamental to the implementation and may appear in // more than one standard header are defined here. Standard headers // then use: // #ifdef _BSD_SIZE_T_ // typedef _BSD_SIZE_T_ size_t; // #undef _BSD_SIZE_T_ // #endif type X__caddr_t = uintptr /* ansi.h:37:14 */ // core address type X__gid_t = X__uint32_t /* ansi.h:38:20 */ // group id type X__in_addr_t = X__uint32_t /* ansi.h:39:20 */ // IP(v4) address
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_freebsd_arm.go
vendor/modernc.org/libc/netdb/netdb_freebsd_arm.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_freebsd_arm.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AI_ADDRCONFIG = 0x00000400 // netdb.h:200:1: AI_ALL = 0x00000100 // netdb.h:198:1: AI_CANONNAME = 0x00000002 // netdb.h:190:1: AI_DEFAULT = 1536 // netdb.h:203:1: AI_MASK = 3343 // netdb.h:194:1: AI_NUMERICHOST = 0x00000004 // netdb.h:191:1: AI_NUMERICSERV = 0x00000008 // netdb.h:192:1: AI_PASSIVE = 0x00000001 // netdb.h:189:1: AI_V4MAPPED = 0x00000800 // netdb.h:201:1: AI_V4MAPPED_CFG = 0x00000200 // netdb.h:199:1: EAI_AGAIN = 2 // netdb.h:168:1: EAI_BADFLAGS = 3 // netdb.h:169:1: EAI_BADHINTS = 12 // netdb.h:181:1: EAI_FAIL = 4 // netdb.h:170:1: EAI_FAMILY = 5 // netdb.h:171:1: EAI_MAX = 15 // netdb.h:184:1: EAI_MEMORY = 6 // netdb.h:172:1: EAI_NONAME = 8 // netdb.h:177:1: EAI_OVERFLOW = 14 // netdb.h:183:1: EAI_PROTOCOL = 13 // netdb.h:182:1: EAI_SERVICE = 9 // netdb.h:178:1: EAI_SOCKTYPE = 10 // netdb.h:179:1: EAI_SYSTEM = 11 // netdb.h:180:1: HOST_NOT_FOUND = 1 // netdb.h:155:1: IPPORT_RESERVED = 1024 // netdb.h:146:1: NETDB_INTERNAL = -1 // netdb.h:153:1: NETDB_SUCCESS = 0 // netdb.h:154:1: NI_DGRAM = 0x00000010 // netdb.h:218:1: NI_MAXHOST = 1025 // netdb.h:208:1: NI_MAXSERV = 32 // netdb.h:209:1: NI_NAMEREQD = 0x00000004 // netdb.h:216:1: NI_NOFQDN = 0x00000001 // netdb.h:214:1: NI_NUMERICHOST = 0x00000002 // netdb.h:215:1: NI_NUMERICSCOPE = 0x00000020 // netdb.h:219:1: NI_NUMERICSERV = 0x00000008 // netdb.h:217:1: NO_ADDRESS = 4 // netdb.h:159:1: NO_DATA = 4 // netdb.h:158:1: NO_RECOVERY = 3 // netdb.h:157:1: SCOPE_DELIMITER = 37 // netdb.h:224:1: TRY_AGAIN = 2 // netdb.h:156:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_ILP32 = 1 // <predefined>:1:1: X_IN_ADDR_T_DECLARED = 0 // netdb.h:67:1: X_IN_PORT_T_DECLARED = 0 // netdb.h:72:1: X_MACHINE__TYPES_H_ = 0 // _types.h:42:1: X_NETDB_H_ = 0 // netdb.h:60:1: X_Nonnull = 0 // cdefs.h:790:1: X_Null_unspecified = 0 // cdefs.h:792:1: X_Nullable = 0 // cdefs.h:791:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:91:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:93:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:94:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:95:1: X_PATH_SERVICES = "/etc/services" // netdb.h:96:1: X_PATH_SERVICES_DB = "/var/db/services.db" // netdb.h:97:1: X_SIZE_T_DECLARED = 0 // netdb.h:77:1: X_SOCKLEN_T_DECLARED = 0 // netdb.h:82:1: X_SYS_CDEFS_H_ = 0 // cdefs.h:39:1: X_SYS__TYPES_H_ = 0 // _types.h:32:1: X_UINT32_T_DECLARED = 0 // netdb.h:87:1: Unix = 1 // <predefined>:367:1: ) type Ptrdiff_t = int32 /* <builtin>:3:26 */ type Size_t = uint32 /* <builtin>:9:23 */ type Wchar_t = uint32 /* <builtin>:15:24 */ type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // - // SPDX-License-Identifier: (BSD-3-Clause AND ISC) // // Copyright (c) 1980, 1983, 1988, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // - // Portions Copyright (c) 1993 by Digital Equipment Corporation. // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies, and that // the name of Digital Equipment Corporation not be used in advertising or // publicity pertaining to distribution of the document or software without // specific, written prior permission. // // THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL // WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT // CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL // DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR // PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS // ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS // SOFTWARE. // - // --Copyright-- // @(#)netdb.h 8.1 (Berkeley) 6/2/93 // From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $ // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 // $FreeBSD$ // Testing against Clang-specific extensions. // This code has been put in place to help reduce the addition of // compiler specific defines in FreeBSD code. It helps to aid in // having a compiler-agnostic source tree. // Compiler memory barriers, specific to gcc and clang. // XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced // Macro to test if we're using a specific version of gcc or later. // The __CONCAT macro is used to concatenate parts of symbol names, e.g. // with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. // The __CONCAT macro is a bit tricky to use if it must work in non-ANSI // mode -- there must be no spaces between its arguments, and for nested // __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also // concatenate double-quoted strings produced by the __STRING macro, but // this only works with ANSI C. // // __XSTRING is like __STRING, but it expands any macros in its argument // first. It is only available with ANSI C. // Compiler-dependent macros to help declare dead (non-returning) and // pure (no side effects) functions, and unused variables. They are // null except for versions of gcc that are known to support the features // properly (old versions of gcc-2 supported the dead and pure features // in a different (wrong) way). If we do not provide an implementation // for a given compiler, let the compile fail if it is told to use // a feature that we cannot live without. // Keywords added in C11. // Emulation of C11 _Generic(). Unlike the previously defined C11 // keywords, it is not possible to implement this using exactly the same // syntax. Therefore implement something similar under the name // __generic(). Unlike _Generic(), this macro can only distinguish // between a single type, so it requires nested invocations to // distinguish multiple cases. // C99 Static array indices in function parameter declarations. Syntax such as: // void bar(int myArray[static 10]); // is allowed in C99 but not in C++. Define __min_size appropriately so // headers using it can be compiled in either language. Use like this: // void bar(int myArray[__min_size(10)]); // XXX: should use `#if __STDC_VERSION__ < 199901'. // C++11 exposes a load of C99 stuff // GCC 2.95 provides `__restrict' as an extension to C90 to support the // C99-specific `restrict' type qualifier. We happen to use `__restrict' as // a way to define the `restrict' type qualifier without disturbing older // software that is unaware of C99 keywords. // GNU C version 2.96 adds explicit branch prediction so that // the CPU back-end can hint the processor and also so that // code blocks can be reordered such that the predicted path // sees a more linear flow, thus improving cache behavior, etc. // // The following two macros provide us with a way to utilize this // compiler feature. Use __predict_true() if you expect the expression // to evaluate to true, and __predict_false() if you expect the // expression to evaluate to false. // // A few notes about usage: // // * Generally, __predict_false() error condition checks (unless // you have some _strong_ reason to do otherwise, in which case // document it), and/or __predict_true() `no-error' condition // checks, assuming you want to optimize for the no-error case. // // * Other than that, if you don't know the likelihood of a test // succeeding from empirical or other `hard' evidence, don't // make predictions. // // * These are meant to be used in places that are run `a lot'. // It is wasteful to make predictions in code that is run // seldomly (e.g. at subsystem initialization time) as the // basic block reordering that this affects can often generate // larger code. // We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h> // require it. // Given the pointer x to the member m of the struct s, return // a pointer to the containing structure. When using GCC, we first // assign pointer x to a local variable, to check that its type is // compatible with member m. // Compiler-dependent macros to declare that functions take printf-like // or scanf-like arguments. They are null except for versions of gcc // that are known to support the features properly (old versions of gcc-2 // didn't permit keeping the keywords out of the application namespace). // Compiler-dependent macros that rely on FreeBSD-specific extensions. // Embed the rcs id of a source file in the resulting library. Note that in // more recent ELF binutils, we use .ident allowing the ID to be stripped. // Usage: // __FBSDID("$FreeBSD$"); // - // The following definitions are an extension of the behavior originally // implemented in <sys/_posix.h>, but with a different level of granularity. // POSIX.1 requires that the macros we test be defined before any standard // header file is included. // // Here's a quick run-down of the versions: // defined(_POSIX_SOURCE) 1003.1-1988 // _POSIX_C_SOURCE == 1 1003.1-1990 // _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option // _POSIX_C_SOURCE == 199309 1003.1b-1993 // _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, // and the omnibus ISO/IEC 9945-1: 1996 // _POSIX_C_SOURCE == 200112 1003.1-2001 // _POSIX_C_SOURCE == 200809 1003.1-2008 // // In addition, the X/Open Portability Guide, which is now the Single UNIX // Specification, defines a feature-test macro which indicates the version of // that specification, and which subsumes _POSIX_C_SOURCE. // // Our macros begin with two underscores to avoid namespace screwage. // Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. // Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. // Deal with various X/Open Portability Guides and Single UNIX Spec. // Deal with all versions of POSIX. The ordering relative to the tests above is // important. // - // Deal with _ANSI_SOURCE: // If it is defined, and no other compilation environment is explicitly // requested, then define our internal feature-test macros to zero. This // makes no difference to the preprocessor (undefined symbols in preprocessing // expressions are defined to have value zero), but makes it more convenient for // a test program to print out the values. // // If a program mistakenly defines _ANSI_SOURCE and some other macro such as // _POSIX_C_SOURCE, we will assume that it wants the broader compilation // environment (and in fact we will never get here). // User override __EXT1_VISIBLE // Old versions of GCC use non-standard ARM arch symbols; acle-compat.h // translates them to __ARM_ARCH and the modern feature symbols defined by ARM. // Nullability qualifiers: currently only supported by Clang. // Type Safety Checking // // Clang provides additional attributes to enable checking type safety // properties that cannot be enforced by the C type system. // Lock annotations. // // Clang provides support for doing basic thread-safety tests at // compile-time, by marking which locks will/should be held when // entering/leaving a functions. // // Furthermore, it is also possible to annotate variables and structure // members to enforce that they are only accessed when certain locks are // held. // Structure implements a lock. // Function acquires an exclusive or shared lock. // Function attempts to acquire an exclusive or shared lock. // Function releases a lock. // Function asserts that an exclusive or shared lock is held. // Function requires that an exclusive or shared lock is or is not held. // Function should not be analyzed. // Function or variable should not be sanitized, e.g., by AddressSanitizer. // GCC has the nosanitize attribute, but as a function attribute only, and // warns on use as a variable attribute. // Guard variables and structure members by lock. // Alignment builtins for better type checking and improved code generation. // Provide fallback versions for other compilers (GCC/Clang < 10): // - // SPDX-License-Identifier: BSD-2-Clause-FreeBSD // // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 // $FreeBSD$ // - // SPDX-License-Identifier: BSD-4-Clause // // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> // Copyright (c) 1990, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. All advertising materials mentioning features or use of this software // must display the following acknowledgement: // This product includes software developed by the University of // California, Berkeley and its contributors. // 4. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 // From: @(#)types.h 8.3 (Berkeley) 1/5/94 // $FreeBSD$ // Basic types upon which most other types are built. type X__int8_t = int8 /* _types.h:51:22 */ type X__uint8_t = uint8 /* _types.h:52:24 */ type X__int16_t = int16 /* _types.h:53:17 */ type X__uint16_t = uint16 /* _types.h:54:25 */ type X__int32_t = int32 /* _types.h:55:15 */ type X__uint32_t = uint32 /* _types.h:56:23 */ // LONGLONG type X__int64_t = int64 /* _types.h:61:20 */ // LONGLONG type X__uint64_t = uint64 /* _types.h:66:28 */ // Standard type definitions. type X__clock_t = X__uint32_t /* _types.h:71:20 */ // clock()... type X__critical_t = X__int32_t /* _types.h:72:19 */ type X__double_t = float64 /* _types.h:74:17 */ type X__float_t = float32 /* _types.h:75:16 */ type X__intfptr_t = X__int32_t /* _types.h:77:19 */ type X__intmax_t = X__int64_t /* _types.h:78:19 */ type X__intptr_t = X__int32_t /* _types.h:79:19 */ type X__int_fast8_t = X__int32_t /* _types.h:80:19 */ type X__int_fast16_t = X__int32_t /* _types.h:81:19 */ type X__int_fast32_t = X__int32_t /* _types.h:82:19 */ type X__int_fast64_t = X__int64_t /* _types.h:83:19 */ type X__int_least8_t = X__int8_t /* _types.h:84:18 */ type X__int_least16_t = X__int16_t /* _types.h:85:19 */ type X__int_least32_t = X__int32_t /* _types.h:86:19 */ type X__int_least64_t = X__int64_t /* _types.h:87:19 */ type X__ptrdiff_t = X__int32_t /* _types.h:88:19 */ // ptr1 - ptr2 type X__register_t = X__int32_t /* _types.h:89:19 */ type X__segsz_t = X__int32_t /* _types.h:90:19 */ // segment size (in pages) type X__size_t = X__uint32_t /* _types.h:91:20 */ // sizeof() type X__ssize_t = X__int32_t /* _types.h:92:19 */ // byte count or error type X__time_t = X__int64_t /* _types.h:93:19 */ // time()... type X__uintfptr_t = X__uint32_t /* _types.h:94:20 */ type X__uintmax_t = X__uint64_t /* _types.h:95:20 */ type X__uintptr_t = X__uint32_t /* _types.h:96:20 */ type X__uint_fast8_t = X__uint32_t /* _types.h:97:20 */ type X__uint_fast16_t = X__uint32_t /* _types.h:98:20 */ type X__uint_fast32_t = X__uint32_t /* _types.h:99:20 */ type X__uint_fast64_t = X__uint64_t /* _types.h:100:20 */ type X__uint_least8_t = X__uint8_t /* _types.h:101:19 */ type X__uint_least16_t = X__uint16_t /* _types.h:102:20 */ type X__uint_least32_t = X__uint32_t /* _types.h:103:20 */ type X__uint_least64_t = X__uint64_t /* _types.h:104:20 */ type X__u_register_t = X__uint32_t /* _types.h:105:20 */ type X__vm_offset_t = X__uint32_t /* _types.h:106:20 */ type X__vm_paddr_t = X__uint32_t /* _types.h:107:20 */ type X__vm_size_t = X__uint32_t /* _types.h:108:20 */ type X___wchar_t = uint32 /* _types.h:110:22 */ // Standard type definitions. type X__blksize_t = X__int32_t /* _types.h:40:19 */ // file block size type X__blkcnt_t = X__int64_t /* _types.h:41:19 */ // file block count type X__clockid_t = X__int32_t /* _types.h:42:19 */ // clock_gettime()... type X__fflags_t = X__uint32_t /* _types.h:43:20 */ // file flags type X__fsblkcnt_t = X__uint64_t /* _types.h:44:20 */ type X__fsfilcnt_t = X__uint64_t /* _types.h:45:20 */ type X__gid_t = X__uint32_t /* _types.h:46:20 */ type X__id_t = X__int64_t /* _types.h:47:19 */ // can hold a gid_t, pid_t, or uid_t type X__ino_t = X__uint64_t /* _types.h:48:20 */ // inode number type X__key_t = int32 /* _types.h:49:15 */ // IPC key (for Sys V IPC) type X__lwpid_t = X__int32_t /* _types.h:50:19 */ // Thread ID (a.k.a. LWP) type X__mode_t = X__uint16_t /* _types.h:51:20 */ // permissions type X__accmode_t = int32 /* _types.h:52:14 */ // access permissions type X__nl_item = int32 /* _types.h:53:14 */ type X__nlink_t = X__uint64_t /* _types.h:54:20 */ // link count type X__off_t = X__int64_t /* _types.h:55:19 */ // file offset type X__off64_t = X__int64_t /* _types.h:56:19 */ // file offset (alias) type X__pid_t = X__int32_t /* _types.h:57:19 */ // process [group] type X__rlim_t = X__int64_t /* _types.h:58:19 */ // resource limit - intentionally // signed, because of legacy code // that uses -1 for RLIM_INFINITY type X__sa_family_t = X__uint8_t /* _types.h:61:19 */ type X__socklen_t = X__uint32_t /* _types.h:62:20 */ type X__suseconds_t = int32 /* _types.h:63:15 */ // microseconds (signed) type X__timer_t = uintptr /* _types.h:64:24 */ // timer_gettime()... type X__mqd_t = uintptr /* _types.h:65:21 */ // mq_open()... type X__uid_t = X__uint32_t /* _types.h:66:20 */ type X__useconds_t = uint32 /* _types.h:67:22 */ // microseconds (unsigned) type X__cpuwhich_t = int32 /* _types.h:68:14 */ // which parameter for cpuset. type X__cpulevel_t = int32 /* _types.h:69:14 */ // level parameter for cpuset. type X__cpusetid_t = int32 /* _types.h:70:14 */ // cpuset identifier. type X__daddr_t = X__int64_t /* _types.h:71:19 */ // bwrite(3), FIOBMAP2, etc // Unusual type definitions. // rune_t is declared to be an “int” instead of the more natural // “unsigned long” or “long”. Two things are happening here. It is not // unsigned so that EOF (-1) can be naturally assigned to it and used. Also, // it looks like 10646 will be a 31 bit standard. This means that if your // ints cannot hold 32 bits, you will be in trouble. The reason an int was // chosen over a long is that the is*() and to*() routines take ints (says // ANSI C), but they use __ct_rune_t instead of int. // // NOTE: rune_t is not covered by ANSI nor other standards, and should not // be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and // rune_t must be the same type. Also, wint_t should be able to hold all // members of the largest character set plus one extra value (WEOF), and // must be at least 16 bits. type X__ct_rune_t = int32 /* _types.h:91:14 */ // arg type for ctype funcs type X__rune_t = X__ct_rune_t /* _types.h:92:21 */ // rune_t (see above) type X__wint_t = X__ct_rune_t /* _types.h:93:21 */ // wint_t (see above) // Clang already provides these types as built-ins, but only in C++ mode. type X__char16_t = X__uint_least16_t /* _types.h:97:26 */ type X__char32_t = X__uint_least32_t /* _types.h:98:26 */ // In C++11, char16_t and char32_t are built-in types. type X__max_align_t = struct { F__max_align1 int64 F__max_align2 float64 } /* _types.h:111:3 */ type X__dev_t = X__uint64_t /* _types.h:113:20 */ // device number type X__fixpt_t = X__uint32_t /* _types.h:115:20 */ // fixed point number // mbstate_t is an opaque object to keep conversion state during multibyte // stream conversions. type X__mbstate_t = struct { F__ccgo_pad1 [0]uint64 F__mbstate8 [128]uint8 } /* _types.h:124:3 */ type X__rman_res_t = X__uintmax_t /* _types.h:126:25 */ // Types for varargs. These are all provided by builtin types these // days, so centralize their definition. type X__va_list = X__builtin_va_list /* _types.h:133:27 */ // internally known to gcc type X__gnuc_va_list = X__va_list /* _types.h:140:20 */ // compatibility w/GNU headers // When the following macro is defined, the system uses 64-bit inode numbers. // Programs can use this to avoid including <sys/param.h>, with its associated // namespace pollution. type In_addr_t = X__uint32_t /* netdb.h:66:20 */ type In_port_t = X__uint16_t /* netdb.h:71:20 */ type Socklen_t = X__socklen_t /* netdb.h:81:21 */ type Uint32_t = X__uint32_t /* netdb.h:86:20 */ // Structures returned by network data base library. All addresses are // supplied in host order, and returned in network order (suitable for // use in system calls). type Hostent = struct { Fh_name uintptr Fh_aliases uintptr Fh_addrtype int32 Fh_length int32 Fh_addr_list uintptr } /* netdb.h:106:1 */ type Netent = struct { Fn_name uintptr Fn_aliases uintptr Fn_addrtype int32 Fn_net Uint32_t } /* netdb.h:115:1 */ type Servent = struct { Fs_name uintptr Fs_aliases uintptr Fs_port int32 Fs_proto uintptr } /* netdb.h:122:1 */ type Protoent = struct { Fp_name uintptr Fp_aliases uintptr Fp_proto int32 } /* netdb.h:129:1 */ type Addrinfo = struct { Fai_flags int32 Fai_family int32 Fai_socktype int32 Fai_protocol int32 Fai_addrlen Socklen_t Fai_canonname uintptr Fai_addr uintptr Fai_next uintptr } /* netdb.h:135:1 */ var _ uint8 /* gen.c:2:13: */
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_darwin_amd64.go
vendor/modernc.org/libc/netdb/netdb_darwin_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_darwin_amd64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_APPLETALK = 16 // socket.h:375:1: AF_CCITT = 10 // socket.h:369:1: AF_CHAOS = 5 // socket.h:363:1: AF_CNT = 21 // socket.h:380:1: AF_COIP = 20 // socket.h:379:1: AF_DATAKIT = 9 // socket.h:368:1: AF_DECnet = 12 // socket.h:371:1: AF_DLI = 13 // socket.h:372:1: AF_E164 = 28 // socket.h:387:1: AF_ECMA = 8 // socket.h:367:1: AF_HYLINK = 15 // socket.h:374:1: AF_IEEE80211 = 37 // socket.h:399:1: AF_IMPLINK = 3 // socket.h:361:1: AF_INET = 2 // socket.h:359:1: AF_INET6 = 30 // socket.h:390:1: AF_IPX = 23 // socket.h:382:1: AF_ISDN = 28 // socket.h:386:1: AF_ISO = 7 // socket.h:365:1: AF_LAT = 14 // socket.h:373:1: AF_LINK = 18 // socket.h:377:1: AF_LOCAL = 1 // socket.h:357:1: AF_MAX = 40 // socket.h:401:1: AF_NATM = 31 // socket.h:392:1: AF_NDRV = 27 // socket.h:385:1: AF_NETBIOS = 33 // socket.h:394:1: AF_NS = 6 // socket.h:364:1: AF_OSI = 7 // socket.h:366:1: AF_PPP = 34 // socket.h:395:1: AF_PUP = 4 // socket.h:362:1: AF_RESERVED_36 = 36 // socket.h:398:1: AF_ROUTE = 17 // socket.h:376:1: AF_SIP = 24 // socket.h:383:1: AF_SNA = 11 // socket.h:370:1: AF_SYSTEM = 32 // socket.h:393:1: AF_UNIX = 1 // socket.h:355:1: AF_UNSPEC = 0 // socket.h:354:1: AF_UTUN = 38 // socket.h:400:1: AI_ADDRCONFIG = 0x00000400 // netdb.h:226:1: AI_ALL = 0x00000100 // netdb.h:222:1: AI_CANONNAME = 0x00000002 // netdb.h:212:1: AI_DEFAULT = 1536 // netdb.h:230:1: AI_MASK = 5127 // netdb.h:217:1: AI_NUMERICHOST = 0x00000004 // netdb.h:213:1: AI_NUMERICSERV = 0x00001000 // netdb.h:214:1: AI_PASSIVE = 0x00000001 // netdb.h:211:1: AI_UNUSABLE = 0x10000000 // netdb.h:234:1: AI_V4MAPPED = 0x00000800 // netdb.h:227:1: AI_V4MAPPED_CFG = 0x00000200 // netdb.h:224:1: BIG_ENDIAN = 4321 // endian.h:94:1: BYTE_ORDER = 1234 // endian.h:97:1: CONNECT_DATA_AUTHENTICATED = 0x4 // socket.h:300:1: CONNECT_DATA_IDEMPOTENT = 0x2 // socket.h:299:1: CONNECT_RESUME_ON_READ_WRITE = 0x1 // socket.h:298:1: EAI_ADDRFAMILY = 1 // netdb.h:185:1: EAI_AGAIN = 2 // netdb.h:187:1: EAI_BADFLAGS = 3 // netdb.h:188:1: EAI_BADHINTS = 12 // netdb.h:200:1: EAI_FAIL = 4 // netdb.h:189:1: EAI_FAMILY = 5 // netdb.h:190:1: EAI_MAX = 15 // netdb.h:205:1: EAI_MEMORY = 6 // netdb.h:191:1: EAI_NODATA = 7 // netdb.h:193:1: EAI_NONAME = 8 // netdb.h:195:1: EAI_OVERFLOW = 14 // netdb.h:203:1: EAI_PROTOCOL = 13 // netdb.h:201:1: EAI_SERVICE = 9 // netdb.h:196:1: EAI_SOCKTYPE = 10 // netdb.h:197:1: EAI_SYSTEM = 11 // netdb.h:198:1: FD_SETSIZE = 1024 // _fd_setsize.h:29:1: HOST_NOT_FOUND = 1 // netdb.h:174:1: ICMP6_FILTER = 18 // in6.h:380:1: ICMPV6CTL_ND6_ONLINKNSRFC4861 = 50 // in6.h:615:1: INADDR_NONE = 0xffffffff // in.h:342:1: INET6_ADDRSTRLEN = 46 // in6.h:161:1: INET_ADDRSTRLEN = 16 // in.h:388:1: INT16_MAX = 32767 // stdint.h:599:1: INT16_MIN = -32768 // stdint.h:600:1: INT32_MAX = 2147483647 // stdint.h:555:1: INT32_MIN = -2147483648 // stdint.h:556:1: INT64_MAX = 9223372036854775807 // stdint.h:461:1: INT64_MIN = -9223372036854775808 // stdint.h:462:1: INT8_MAX = 127 // stdint.h:621:1: INT8_MIN = -128 // stdint.h:622:1: INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: INT_FAST16_MAX = 32767 // stdint.h:615:1: INT_FAST16_MIN = -32768 // stdint.h:614:1: INT_FAST32_MAX = 2147483647 // stdint.h:574:1: INT_FAST32_MIN = -2147483648 // stdint.h:573:1: INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: INT_FAST8_MAX = 127 // stdint.h:634:1: INT_FAST8_MIN = -128 // stdint.h:633:1: INT_LEAST16_MAX = 32767 // stdint.h:612:1: INT_LEAST16_MIN = -32768 // stdint.h:611:1: INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: INT_LEAST8_MAX = 127 // stdint.h:631:1: INT_LEAST8_MIN = -128 // stdint.h:630:1: IN_CLASSA_HOST = 0x00ffffff // in.h:317:1: IN_CLASSA_MAX = 128 // in.h:318:1: IN_CLASSA_NET = 0xff000000 // in.h:315:1: IN_CLASSA_NSHIFT = 24 // in.h:316:1: IN_CLASSB_HOST = 0x0000ffff // in.h:323:1: IN_CLASSB_MAX = 65536 // in.h:324:1: IN_CLASSB_NET = 0xffff0000 // in.h:321:1: IN_CLASSB_NSHIFT = 16 // in.h:322:1: IN_CLASSC_HOST = 0x000000ff // in.h:329:1: IN_CLASSC_NET = 0xffffff00 // in.h:327:1: IN_CLASSC_NSHIFT = 8 // in.h:328:1: IN_CLASSD_HOST = 0x0fffffff // in.h:334:1: IN_CLASSD_NET = 0xf0000000 // in.h:332:1: IN_CLASSD_NSHIFT = 28 // in.h:333:1: IN_LOOPBACKNET = 127 // in.h:369:1: IPCTL_ACCEPTSOURCEROUTE = 13 // in.h:649:1: IPCTL_DEFTTL = 3 // in.h:637:1: IPCTL_DIRECTEDBROADCAST = 9 // in.h:645:1: IPCTL_FASTFORWARDING = 14 // in.h:650:1: IPCTL_FORWARDING = 1 // in.h:635:1: IPCTL_GIF_TTL = 16 // in.h:652:1: IPCTL_INTRQDROPS = 11 // in.h:647:1: IPCTL_INTRQMAXLEN = 10 // in.h:646:1: IPCTL_KEEPFAITH = 15 // in.h:651:1: IPCTL_MAXID = 17 // in.h:653:1: IPCTL_RTEXPIRE = 5 // in.h:641:1: IPCTL_RTMAXCACHE = 7 // in.h:643:1: IPCTL_RTMINEXPIRE = 6 // in.h:642:1: IPCTL_SENDREDIRECTS = 2 // in.h:636:1: IPCTL_SOURCEROUTE = 8 // in.h:644:1: IPCTL_STATS = 12 // in.h:648:1: IPPORT_HIFIRSTAUTO = 49152 // in.h:286:1: IPPORT_HILASTAUTO = 65535 // in.h:287:1: IPPORT_RESERVED = 1024 // in.h:279:1: IPPORT_RESERVEDSTART = 600 // in.h:295:1: IPPORT_USERRESERVED = 5000 // in.h:281:1: IPPROTO_3PC = 34 // in.h:139:1: IPPROTO_ADFS = 68 // in.h:173:1: IPPROTO_AH = 51 // in.h:158:1: IPPROTO_AHIP = 61 // in.h:166:1: IPPROTO_APES = 99 // in.h:204:1: IPPROTO_ARGUS = 13 // in.h:116:1: IPPROTO_AX25 = 93 // in.h:198:1: IPPROTO_BHA = 49 // in.h:156:1: IPPROTO_BLT = 30 // in.h:135:1: IPPROTO_BRSATMON = 76 // in.h:181:1: IPPROTO_CFTP = 62 // in.h:167:1: IPPROTO_CHAOS = 16 // in.h:119:1: IPPROTO_CMTP = 38 // in.h:143:1: IPPROTO_CPHB = 73 // in.h:178:1: IPPROTO_CPNX = 72 // in.h:177:1: IPPROTO_DDP = 37 // in.h:142:1: IPPROTO_DGP = 86 // in.h:191:1: IPPROTO_DIVERT = 254 // in.h:213:1: IPPROTO_DONE = 257 // in.h:221:1: IPPROTO_DSTOPTS = 60 // in.h:165:1: IPPROTO_EGP = 8 // in.h:111:1: IPPROTO_EMCON = 14 // in.h:117:1: IPPROTO_ENCAP = 98 // in.h:203:1: IPPROTO_EON = 80 // in.h:185:1: IPPROTO_ESP = 50 // in.h:157:1: IPPROTO_ETHERIP = 97 // in.h:202:1: IPPROTO_FRAGMENT = 44 // in.h:151:1: IPPROTO_GGP = 3 // in.h:104:1: IPPROTO_GMTP = 100 // in.h:205:1: IPPROTO_GRE = 47 // in.h:154:1: IPPROTO_HELLO = 63 // in.h:168:1: IPPROTO_HMP = 20 // in.h:125:1: IPPROTO_HOPOPTS = 0 // in.h:99:1: IPPROTO_ICMP = 1 // in.h:101:1: IPPROTO_ICMPV6 = 58 // in.h:163:1: IPPROTO_IDP = 22 // in.h:127:1: IPPROTO_IDPR = 35 // in.h:140:1: IPPROTO_IDRP = 45 // in.h:152:1: IPPROTO_IGMP = 2 // in.h:103:1: IPPROTO_IGP = 85 // in.h:190:1: IPPROTO_IGRP = 88 // in.h:193:1: IPPROTO_IL = 40 // in.h:145:1: IPPROTO_INLSP = 52 // in.h:159:1: IPPROTO_INP = 32 // in.h:137:1: IPPROTO_IP = 0 // in.h:97:1: IPPROTO_IPCOMP = 108 // in.h:208:1: IPPROTO_IPCV = 71 // in.h:176:1: IPPROTO_IPEIP = 94 // in.h:199:1: IPPROTO_IPIP = 4 // in.h:106:1: IPPROTO_IPPC = 67 // in.h:172:1: IPPROTO_IPV4 = 4 // in.h:105:1: IPPROTO_IPV6 = 41 // in.h:147:1: IPPROTO_IRTP = 28 // in.h:133:1: IPPROTO_KRYPTOLAN = 65 // in.h:170:1: IPPROTO_LARP = 91 // in.h:196:1: IPPROTO_LEAF1 = 25 // in.h:130:1: IPPROTO_LEAF2 = 26 // in.h:131:1: IPPROTO_MAX = 256 // in.h:218:1: IPPROTO_MAXID = 52 // in.h:629:1: IPPROTO_MEAS = 19 // in.h:124:1: IPPROTO_MHRP = 48 // in.h:155:1: IPPROTO_MICP = 95 // in.h:200:1: IPPROTO_MTP = 92 // in.h:197:1: IPPROTO_MUX = 18 // in.h:123:1: IPPROTO_ND = 77 // in.h:182:1: IPPROTO_NHRP = 54 // in.h:161:1: IPPROTO_NONE = 59 // in.h:164:1: IPPROTO_NSP = 31 // in.h:136:1: IPPROTO_NVPII = 11 // in.h:114:1: IPPROTO_OSPFIGP = 89 // in.h:194:1: IPPROTO_PGM = 113 // in.h:209:1: IPPROTO_PIGP = 9 // in.h:112:1: IPPROTO_PIM = 103 // in.h:207:1: IPPROTO_PRM = 21 // in.h:126:1: IPPROTO_PUP = 12 // in.h:115:1: IPPROTO_PVP = 75 // in.h:180:1: IPPROTO_RAW = 255 // in.h:215:1: IPPROTO_RCCMON = 10 // in.h:113:1: IPPROTO_RDP = 27 // in.h:132:1: IPPROTO_ROUTING = 43 // in.h:150:1: IPPROTO_RSVP = 46 // in.h:153:1: IPPROTO_RVD = 66 // in.h:171:1: IPPROTO_SATEXPAK = 64 // in.h:169:1: IPPROTO_SATMON = 69 // in.h:174:1: IPPROTO_SCCSP = 96 // in.h:201:1: IPPROTO_SCTP = 132 // in.h:210:1: IPPROTO_SDRP = 42 // in.h:149:1: IPPROTO_SEP = 33 // in.h:138:1: IPPROTO_SRPC = 90 // in.h:195:1: IPPROTO_ST = 7 // in.h:110:1: IPPROTO_SVMTP = 82 // in.h:187:1: IPPROTO_SWIPE = 53 // in.h:160:1: IPPROTO_TCF = 87 // in.h:192:1: IPPROTO_TCP = 6 // in.h:108:1: IPPROTO_TP = 29 // in.h:134:1: IPPROTO_TPXX = 39 // in.h:144:1: IPPROTO_TRUNK1 = 23 // in.h:128:1: IPPROTO_TRUNK2 = 24 // in.h:129:1: IPPROTO_TTP = 84 // in.h:189:1: IPPROTO_UDP = 17 // in.h:121:1: IPPROTO_VINES = 83 // in.h:188:1: IPPROTO_VISA = 70 // in.h:175:1: IPPROTO_VMTP = 81 // in.h:186:1: IPPROTO_WBEXPAK = 79 // in.h:184:1: IPPROTO_WBMON = 78 // in.h:183:1: IPPROTO_WSN = 74 // in.h:179:1: IPPROTO_XNET = 15 // in.h:118:1: IPPROTO_XTP = 36 // in.h:141:1: IPV6CTL_ACCEPT_RTADV = 12 // in6.h:580:1: IPV6CTL_ADDRCTLPOLICY = 38 // in6.h:605:1: IPV6CTL_AUTO_FLOWLABEL = 17 // in6.h:585:1: IPV6CTL_AUTO_LINKLOCAL = 35 // in6.h:602:1: IPV6CTL_DAD_COUNT = 16 // in6.h:584:1: IPV6CTL_DEFHLIM = 3 // in6.h:569:1: IPV6CTL_DEFMCASTHLIM = 18 // in6.h:586:1: IPV6CTL_FORWARDING = 1 // in6.h:567:1: IPV6CTL_FORWSRCRT = 5 // in6.h:573:1: IPV6CTL_GIF_HLIM = 19 // in6.h:587:1: IPV6CTL_HDRNESTLIMIT = 15 // in6.h:583:1: IPV6CTL_KAME_VERSION = 20 // in6.h:588:1: IPV6CTL_KEEPFAITH = 13 // in6.h:581:1: IPV6CTL_LOG_INTERVAL = 14 // in6.h:582:1: IPV6CTL_MAXDYNROUTES = 49 // in6.h:614:1: IPV6CTL_MAXFRAGPACKETS = 9 // in6.h:577:1: IPV6CTL_MAXFRAGS = 41 // in6.h:608:1: IPV6CTL_MAXID = 51 // in6.h:619:1: IPV6CTL_MAXIFDEFROUTERS = 48 // in6.h:613:1: IPV6CTL_MAXIFPREFIXES = 47 // in6.h:612:1: IPV6CTL_MCAST_PMTU = 44 // in6.h:609:1: IPV6CTL_MRTPROTO = 8 // in6.h:576:1: IPV6CTL_MRTSTATS = 7 // in6.h:575:1: IPV6CTL_NEIGHBORGCTHRESH = 46 // in6.h:611:1: IPV6CTL_PREFER_TEMPADDR = 37 // in6.h:604:1: IPV6CTL_RIP6STATS = 36 // in6.h:603:1: IPV6CTL_RR_PRUNE = 22 // in6.h:590:1: IPV6CTL_RTEXPIRE = 25 // in6.h:595:1: IPV6CTL_RTMAXCACHE = 27 // in6.h:597:1: IPV6CTL_RTMINEXPIRE = 26 // in6.h:596:1: IPV6CTL_SENDREDIRECTS = 2 // in6.h:568:1: IPV6CTL_SOURCECHECK = 10 // in6.h:578:1: IPV6CTL_SOURCECHECK_LOGINT = 11 // in6.h:579:1: IPV6CTL_STATS = 6 // in6.h:574:1: IPV6CTL_TEMPPLTIME = 33 // in6.h:600:1: IPV6CTL_TEMPVLTIME = 34 // in6.h:601:1: IPV6CTL_USETEMPADDR = 32 // in6.h:599:1: IPV6CTL_USE_DEFAULTZONE = 39 // in6.h:606:1: IPV6CTL_USE_DEPRECATED = 21 // in6.h:589:1: IPV6CTL_V6ONLY = 24 // in6.h:594:1: IPV6PORT_ANONMAX = 65535 // in6.h:143:1: IPV6PORT_ANONMIN = 49152 // in6.h:142:1: IPV6PORT_RESERVED = 1024 // in6.h:141:1: IPV6PORT_RESERVEDMAX = 1023 // in6.h:145:1: IPV6PORT_RESERVEDMIN = 600 // in6.h:144:1: IPV6PROTO_MAXID = 104 // in6.h:562:1: IPV6_2292DSTOPTS = 23 // in6.h:385:1: IPV6_2292HOPLIMIT = 20 // in6.h:382:1: IPV6_2292HOPOPTS = 22 // in6.h:384:1: IPV6_2292NEXTHOP = 21 // in6.h:383:1: IPV6_2292PKTINFO = 19 // in6.h:381:1: IPV6_2292PKTOPTIONS = 25 // in6.h:389:1: IPV6_2292RTHDR = 24 // in6.h:386:1: IPV6_BINDV6ONLY = 27 // in6.h:405:1: IPV6_BOUND_IF = 125 // in6.h:494:1: IPV6_CHECKSUM = 26 // in6.h:401:1: IPV6_DEFAULT_MULTICAST_HOPS = 1 // in6.h:506:1: IPV6_DEFAULT_MULTICAST_LOOP = 1 // in6.h:507:1: IPV6_FAITH = 29 // in6.h:411:1: IPV6_FW_ADD = 30 // in6.h:414:1: IPV6_FW_DEL = 31 // in6.h:415:1: IPV6_FW_FLUSH = 32 // in6.h:416:1: IPV6_FW_GET = 34 // in6.h:418:1: IPV6_FW_ZERO = 33 // in6.h:417:1: IPV6_IPSEC_POLICY = 28 // in6.h:409:1: IPV6_JOIN_GROUP = 12 // in6.h:375:1: IPV6_LEAVE_GROUP = 13 // in6.h:376:1: IPV6_MAX_GROUP_SRC_FILTER = 512 // in6.h:521:1: IPV6_MAX_MEMBERSHIPS = 4095 // in6.h:515:1: IPV6_MAX_SOCK_SRC_FILTER = 128 // in6.h:522:1: IPV6_MIN_MEMBERSHIPS = 31 // in6.h:514:1: IPV6_MULTICAST_HOPS = 10 // in6.h:373:1: IPV6_MULTICAST_IF = 9 // in6.h:372:1: IPV6_MULTICAST_LOOP = 11 // in6.h:374:1: IPV6_PORTRANGE = 14 // in6.h:379:1: IPV6_PORTRANGE_DEFAULT = 0 // in6.h:552:1: IPV6_PORTRANGE_HIGH = 1 // in6.h:553:1: IPV6_PORTRANGE_LOW = 2 // in6.h:554:1: IPV6_RECVTCLASS = 35 // in6.h:426:1: IPV6_RTHDR_LOOSE = 0 // in6.h:499:1: IPV6_RTHDR_STRICT = 1 // in6.h:500:1: IPV6_RTHDR_TYPE_0 = 0 // in6.h:501:1: IPV6_SOCKOPT_RESERVED1 = 3 // in6.h:369:1: IPV6_TCLASS = 36 // in6.h:427:1: IPV6_UNICAST_HOPS = 4 // in6.h:371:1: IPV6_V6ONLY = 27 // in6.h:403:1: IP_ADD_MEMBERSHIP = 12 // in.h:418:1: IP_ADD_SOURCE_MEMBERSHIP = 70 // in.h:464:1: IP_BLOCK_SOURCE = 72 // in.h:466:1: IP_BOUND_IF = 25 // in.h:434:1: IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:485:1: IP_DEFAULT_MULTICAST_TTL = 1 // in.h:484:1: IP_DROP_MEMBERSHIP = 13 // in.h:419:1: IP_DROP_SOURCE_MEMBERSHIP = 71 // in.h:465:1: IP_DUMMYNET_CONFIGURE = 60 // in.h:455:1: IP_DUMMYNET_DEL = 61 // in.h:456:1: IP_DUMMYNET_FLUSH = 62 // in.h:457:1: IP_DUMMYNET_GET = 64 // in.h:458:1: IP_FAITH = 22 // in.h:429:1: IP_FW_ADD = 40 // in.h:439:1: IP_FW_DEL = 41 // in.h:440:1: IP_FW_FLUSH = 42 // in.h:441:1: IP_FW_GET = 44 // in.h:443:1: IP_FW_RESETLOG = 45 // in.h:444:1: IP_FW_ZERO = 43 // in.h:442:1: IP_HDRINCL = 2 // in.h:408:1: IP_IPSEC_POLICY = 21 // in.h:428:1: IP_MAX_GROUP_SRC_FILTER = 512 // in.h:499:1: IP_MAX_MEMBERSHIPS = 4095 // in.h:493:1: IP_MAX_SOCK_MUTE_FILTER = 128 // in.h:501:1: IP_MAX_SOCK_SRC_FILTER = 128 // in.h:500:1: IP_MIN_MEMBERSHIPS = 31 // in.h:492:1: IP_MSFILTER = 74 // in.h:470:1: IP_MULTICAST_IF = 9 // in.h:415:1: IP_MULTICAST_IFINDEX = 66 // in.h:461:1: IP_MULTICAST_LOOP = 11 // in.h:417:1: IP_MULTICAST_TTL = 10 // in.h:416:1: IP_MULTICAST_VIF = 14 // in.h:420:1: IP_NAT__XXX = 55 // in.h:452:1: IP_OLD_FW_ADD = 50 // in.h:447:1: IP_OLD_FW_DEL = 51 // in.h:448:1: IP_OLD_FW_FLUSH = 52 // in.h:449:1: IP_OLD_FW_GET = 54 // in.h:451:1: IP_OLD_FW_RESETLOG = 56 // in.h:453:1: IP_OLD_FW_ZERO = 53 // in.h:450:1: IP_OPTIONS = 1 // in.h:407:1: IP_PKTINFO = 26 // in.h:435:1: IP_PORTRANGE = 19 // in.h:425:1: IP_PORTRANGE_DEFAULT = 0 // in.h:593:1: IP_PORTRANGE_HIGH = 1 // in.h:594:1: IP_PORTRANGE_LOW = 2 // in.h:595:1: IP_RECVDSTADDR = 7 // in.h:413:1: IP_RECVIF = 20 // in.h:426:1: IP_RECVOPTS = 5 // in.h:411:1: IP_RECVPKTINFO = 26 // in.h:436:1: IP_RECVRETOPTS = 6 // in.h:412:1: IP_RECVTOS = 27 // in.h:437:1: IP_RECVTTL = 24 // in.h:433:1: IP_RETOPTS = 8 // in.h:414:1: IP_RSVP_OFF = 16 // in.h:422:1: IP_RSVP_ON = 15 // in.h:421:1: IP_RSVP_VIF_OFF = 18 // in.h:424:1: IP_RSVP_VIF_ON = 17 // in.h:423:1: IP_STRIPHDR = 23 // in.h:431:1: IP_TOS = 3 // in.h:409:1: IP_TRAFFIC_MGT_BACKGROUND = 65 // in.h:460:1: IP_TTL = 4 // in.h:410:1: IP_UNBLOCK_SOURCE = 73 // in.h:467:1: KEV_DL_ADDMULTI = 7 // net_kev.h:61:1: KEV_DL_AWDL_RESTRICTED = 26 // net_kev.h:80:1: KEV_DL_AWDL_UNRESTRICTED = 27 // net_kev.h:81:1: KEV_DL_DELMULTI = 8 // net_kev.h:62:1: KEV_DL_IFCAP_CHANGED = 19 // net_kev.h:73:1: KEV_DL_IFDELEGATE_CHANGED = 25 // net_kev.h:79:1: KEV_DL_IF_ATTACHED = 9 // net_kev.h:63:1: KEV_DL_IF_DETACHED = 11 // net_kev.h:65:1: KEV_DL_IF_DETACHING = 10 // net_kev.h:64:1: KEV_DL_IF_IDLE_ROUTE_REFCNT = 18 // net_kev.h:72:1: KEV_DL_ISSUES = 24 // net_kev.h:78:1: KEV_DL_LINK_ADDRESS_CHANGED = 16 // net_kev.h:70:1:
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_openbsd_arm64.go
vendor/modernc.org/libc/netdb/capi_openbsd_arm64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_openbsd_arm64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_linux_amd64.go
vendor/modernc.org/libc/netdb/capi_linux_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_linux_amd64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_netbsd_amd64.go
vendor/modernc.org/libc/netdb/netdb_netbsd_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_netbsd_amd64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AI_ADDRCONFIG = 0x00000400 // netdb.h:269:1: AI_CANONNAME = 0x00000002 // netdb.h:266:1: AI_MASK = 3087 // netdb.h:273:1: AI_NUMERICHOST = 0x00000004 // netdb.h:267:1: AI_NUMERICSERV = 0x00000008 // netdb.h:268:1: AI_PASSIVE = 0x00000001 // netdb.h:265:1: AI_SRV = 0x00000800 // netdb.h:272:1: EAI_ADDRFAMILY = 1 // netdb.h:243:1: EAI_AGAIN = 2 // netdb.h:244:1: EAI_BADFLAGS = 3 // netdb.h:245:1: EAI_BADHINTS = 12 // netdb.h:254:1: EAI_FAIL = 4 // netdb.h:246:1: EAI_FAMILY = 5 // netdb.h:247:1: EAI_MAX = 15 // netdb.h:257:1: EAI_MEMORY = 6 // netdb.h:248:1: EAI_NODATA = 7 // netdb.h:249:1: EAI_NONAME = 8 // netdb.h:250:1: EAI_OVERFLOW = 14 // netdb.h:256:1: EAI_PROTOCOL = 13 // netdb.h:255:1: EAI_SERVICE = 9 // netdb.h:251:1: EAI_SOCKTYPE = 10 // netdb.h:252:1: EAI_SYSTEM = 11 // netdb.h:253:1: HOST_NOT_FOUND = 1 // netdb.h:230:1: INT16_MAX = 32767 // common_int_limits.h:53:1: INT16_MIN = -32768 // common_int_limits.h:47:1: INT32_MAX = 2147483647 // common_int_limits.h:54:1: INT32_MIN = -2147483648 // common_int_limits.h:48:1: INT64_MAX = 9223372036854775807 // common_int_limits.h:55:1: INT64_MIN = -9223372036854775808 // common_int_limits.h:49:1: INT8_MAX = 127 // common_int_limits.h:52:1: INT8_MIN = -128 // common_int_limits.h:46:1: INTMAX_MAX = 9223372036854775807 // common_int_limits.h:111:1: INTMAX_MIN = -9223372036854775808 // common_int_limits.h:110:1: INTPTR_MAX = 9223372036854775807 // common_int_limits.h:105:1: INTPTR_MIN = -9223372036854775808 // common_int_limits.h:104:1: INT_FAST16_MAX = 2147483647 // common_int_limits.h:93:1: INT_FAST16_MIN = -2147483648 // common_int_limits.h:87:1: INT_FAST32_MAX = 2147483647 // common_int_limits.h:94:1: INT_FAST32_MIN = -2147483648 // common_int_limits.h:88:1: INT_FAST64_MAX = 9223372036854775807 // common_int_limits.h:95:1: INT_FAST64_MIN = -9223372036854775808 // common_int_limits.h:89:1: INT_FAST8_MAX = 2147483647 // common_int_limits.h:92:1: INT_FAST8_MIN = -2147483648 // common_int_limits.h:86:1: INT_LEAST16_MAX = 32767 // common_int_limits.h:73:1: INT_LEAST16_MIN = -32768 // common_int_limits.h:67:1: INT_LEAST32_MAX = 2147483647 // common_int_limits.h:74:1: INT_LEAST32_MIN = -2147483648 // common_int_limits.h:68:1: INT_LEAST64_MAX = 9223372036854775807 // common_int_limits.h:75:1: INT_LEAST64_MIN = -9223372036854775808 // common_int_limits.h:69:1: INT_LEAST8_MAX = 127 // common_int_limits.h:72:1: INT_LEAST8_MIN = -128 // common_int_limits.h:66:1: NETDB_INTERNAL = -1 // netdb.h:226:1: NETDB_SUCCESS = 0 // netdb.h:227:1: NI_DGRAM = 0x00000010 // netdb.h:300:1: NI_MAXHOST = 1025 // netdb.h:289:1: NI_MAXSERV = 32 // netdb.h:290:1: NI_NAMEREQD = 0x00000004 // netdb.h:298:1: NI_NOFQDN = 0x00000001 // netdb.h:296:1: NI_NUMERICHOST = 0x00000002 // netdb.h:297:1: NI_NUMERICSCOPE = 0x00000040 // netdb.h:302:1: NI_NUMERICSERV = 0x00000008 // netdb.h:299:1: NI_WITHSCOPEID = 0x00000020 // netdb.h:301:1: NO_ADDRESS = 4 // netdb.h:235:1: NO_DATA = 4 // netdb.h:233:1: NO_RECOVERY = 3 // netdb.h:232:1: PRIX16 = "X" // int_fmtio.h:125:1: PRIX32 = "X" // int_fmtio.h:126:1: PRIX64 = "lX" // int_fmtio.h:127:1: PRIX8 = "X" // int_fmtio.h:124:1: PRIXFAST16 = "X" // int_fmtio.h:133:1: PRIXFAST32 = "X" // int_fmtio.h:134:1: PRIXFAST64 = "lX" // int_fmtio.h:135:1: PRIXFAST8 = "X" // int_fmtio.h:132:1: PRIXLEAST16 = "X" // int_fmtio.h:129:1: PRIXLEAST32 = "X" // int_fmtio.h:130:1: PRIXLEAST64 = "lX" // int_fmtio.h:131:1: PRIXLEAST8 = "X" // int_fmtio.h:128:1: PRIXMAX = "lX" // int_fmtio.h:136:1: PRIXPTR = "lX" // int_fmtio.h:137:1: PRId16 = "d" // int_fmtio.h:48:1: PRId32 = "d" // int_fmtio.h:49:1: PRId64 = "ld" // int_fmtio.h:50:1: PRId8 = "d" // int_fmtio.h:47:1: PRIdFAST16 = "d" // int_fmtio.h:56:1: PRIdFAST32 = "d" // int_fmtio.h:57:1: PRIdFAST64 = "ld" // int_fmtio.h:58:1: PRIdFAST8 = "d" // int_fmtio.h:55:1: PRIdLEAST16 = "d" // int_fmtio.h:52:1: PRIdLEAST32 = "d" // int_fmtio.h:53:1: PRIdLEAST64 = "ld" // int_fmtio.h:54:1: PRIdLEAST8 = "d" // int_fmtio.h:51:1: PRIdMAX = "ld" // int_fmtio.h:59:1: PRIdPTR = "ld" // int_fmtio.h:60:1: PRIi16 = "i" // int_fmtio.h:63:1: PRIi32 = "i" // int_fmtio.h:64:1: PRIi64 = "li" // int_fmtio.h:65:1: PRIi8 = "i" // int_fmtio.h:62:1: PRIiFAST16 = "i" // int_fmtio.h:71:1: PRIiFAST32 = "i" // int_fmtio.h:72:1: PRIiFAST64 = "li" // int_fmtio.h:73:1: PRIiFAST8 = "i" // int_fmtio.h:70:1: PRIiLEAST16 = "i" // int_fmtio.h:67:1: PRIiLEAST32 = "i" // int_fmtio.h:68:1: PRIiLEAST64 = "li" // int_fmtio.h:69:1: PRIiLEAST8 = "i" // int_fmtio.h:66:1: PRIiMAX = "li" // int_fmtio.h:74:1: PRIiPTR = "li" // int_fmtio.h:75:1: PRIo16 = "o" // int_fmtio.h:80:1: PRIo32 = "o" // int_fmtio.h:81:1: PRIo64 = "lo" // int_fmtio.h:82:1: PRIo8 = "o" // int_fmtio.h:79:1: PRIoFAST16 = "o" // int_fmtio.h:88:1: PRIoFAST32 = "o" // int_fmtio.h:89:1: PRIoFAST64 = "lo" // int_fmtio.h:90:1: PRIoFAST8 = "o" // int_fmtio.h:87:1: PRIoLEAST16 = "o" // int_fmtio.h:84:1: PRIoLEAST32 = "o" // int_fmtio.h:85:1: PRIoLEAST64 = "lo" // int_fmtio.h:86:1: PRIoLEAST8 = "o" // int_fmtio.h:83:1: PRIoMAX = "lo" // int_fmtio.h:91:1: PRIoPTR = "lo" // int_fmtio.h:92:1: PRIu16 = "u" // int_fmtio.h:95:1: PRIu32 = "u" // int_fmtio.h:96:1: PRIu64 = "lu" // int_fmtio.h:97:1: PRIu8 = "u" // int_fmtio.h:94:1: PRIuFAST16 = "u" // int_fmtio.h:103:1: PRIuFAST32 = "u" // int_fmtio.h:104:1: PRIuFAST64 = "lu" // int_fmtio.h:105:1: PRIuFAST8 = "u" // int_fmtio.h:102:1: PRIuLEAST16 = "u" // int_fmtio.h:99:1: PRIuLEAST32 = "u" // int_fmtio.h:100:1: PRIuLEAST64 = "lu" // int_fmtio.h:101:1: PRIuLEAST8 = "u" // int_fmtio.h:98:1: PRIuMAX = "lu" // int_fmtio.h:106:1: PRIuPTR = "lu" // int_fmtio.h:107:1: PRIx16 = "x" // int_fmtio.h:110:1: PRIx32 = "x" // int_fmtio.h:111:1: PRIx64 = "lx" // int_fmtio.h:112:1: PRIx8 = "x" // int_fmtio.h:109:1: PRIxFAST16 = "x" // int_fmtio.h:118:1: PRIxFAST32 = "x" // int_fmtio.h:119:1: PRIxFAST64 = "lx" // int_fmtio.h:120:1: PRIxFAST8 = "x" // int_fmtio.h:117:1: PRIxLEAST16 = "x" // int_fmtio.h:114:1: PRIxLEAST32 = "x" // int_fmtio.h:115:1: PRIxLEAST64 = "lx" // int_fmtio.h:116:1: PRIxLEAST8 = "x" // int_fmtio.h:113:1: PRIxMAX = "lx" // int_fmtio.h:121:1: PRIxPTR = "lx" // int_fmtio.h:122:1: PTRDIFF_MAX = 9223372036854775807 // common_int_limits.h:121:1: PTRDIFF_MIN = -9223372036854775808 // common_int_limits.h:120:1: SCNd16 = "hd" // int_fmtio.h:142:1: SCNd32 = "d" // int_fmtio.h:143:1: SCNd64 = "ld" // int_fmtio.h:144:1: SCNd8 = "hhd" // int_fmtio.h:141:1: SCNdFAST16 = "d" // int_fmtio.h:150:1: SCNdFAST32 = "d" // int_fmtio.h:151:1: SCNdFAST64 = "ld" // int_fmtio.h:152:1: SCNdFAST8 = "d" // int_fmtio.h:149:1: SCNdLEAST16 = "hd" // int_fmtio.h:146:1: SCNdLEAST32 = "d" // int_fmtio.h:147:1: SCNdLEAST64 = "ld" // int_fmtio.h:148:1: SCNdLEAST8 = "hhd" // int_fmtio.h:145:1: SCNdMAX = "ld" // int_fmtio.h:153:1: SCNdPTR = "ld" // int_fmtio.h:154:1: SCNi16 = "hi" // int_fmtio.h:157:1: SCNi32 = "i" // int_fmtio.h:158:1: SCNi64 = "li" // int_fmtio.h:159:1: SCNi8 = "hhi" // int_fmtio.h:156:1: SCNiFAST16 = "i" // int_fmtio.h:165:1: SCNiFAST32 = "i" // int_fmtio.h:166:1: SCNiFAST64 = "li" // int_fmtio.h:167:1: SCNiFAST8 = "i" // int_fmtio.h:164:1: SCNiLEAST16 = "hi" // int_fmtio.h:161:1: SCNiLEAST32 = "i" // int_fmtio.h:162:1: SCNiLEAST64 = "li" // int_fmtio.h:163:1: SCNiLEAST8 = "hhi" // int_fmtio.h:160:1: SCNiMAX = "li" // int_fmtio.h:168:1: SCNiPTR = "li" // int_fmtio.h:169:1: SCNo16 = "ho" // int_fmtio.h:174:1: SCNo32 = "o" // int_fmtio.h:175:1: SCNo64 = "lo" // int_fmtio.h:176:1: SCNo8 = "hho" // int_fmtio.h:173:1: SCNoFAST16 = "o" // int_fmtio.h:182:1: SCNoFAST32 = "o" // int_fmtio.h:183:1: SCNoFAST64 = "lo" // int_fmtio.h:184:1: SCNoFAST8 = "o" // int_fmtio.h:181:1: SCNoLEAST16 = "ho" // int_fmtio.h:178:1: SCNoLEAST32 = "o" // int_fmtio.h:179:1: SCNoLEAST64 = "lo" // int_fmtio.h:180:1: SCNoLEAST8 = "hho" // int_fmtio.h:177:1: SCNoMAX = "lo" // int_fmtio.h:185:1: SCNoPTR = "lo" // int_fmtio.h:186:1: SCNu16 = "hu" // int_fmtio.h:189:1: SCNu32 = "u" // int_fmtio.h:190:1: SCNu64 = "lu" // int_fmtio.h:191:1: SCNu8 = "hhu" // int_fmtio.h:188:1: SCNuFAST16 = "u" // int_fmtio.h:197:1: SCNuFAST32 = "u" // int_fmtio.h:198:1: SCNuFAST64 = "lu" // int_fmtio.h:199:1: SCNuFAST8 = "u" // int_fmtio.h:196:1: SCNuLEAST16 = "hu" // int_fmtio.h:193:1: SCNuLEAST32 = "u" // int_fmtio.h:194:1: SCNuLEAST64 = "lu" // int_fmtio.h:195:1: SCNuLEAST8 = "hhu" // int_fmtio.h:192:1: SCNuMAX = "lu" // int_fmtio.h:200:1: SCNuPTR = "lu" // int_fmtio.h:201:1: SCNx16 = "hx" // int_fmtio.h:204:1: SCNx32 = "x" // int_fmtio.h:205:1: SCNx64 = "lx" // int_fmtio.h:206:1: SCNx8 = "hhx" // int_fmtio.h:203:1: SCNxFAST16 = "x" // int_fmtio.h:212:1: SCNxFAST32 = "x" // int_fmtio.h:213:1: SCNxFAST64 = "lx" // int_fmtio.h:214:1: SCNxFAST8 = "x" // int_fmtio.h:211:1: SCNxLEAST16 = "hx" // int_fmtio.h:208:1: SCNxLEAST32 = "x" // int_fmtio.h:209:1: SCNxLEAST64 = "lx" // int_fmtio.h:210:1: SCNxLEAST8 = "hhx" // int_fmtio.h:207:1: SCNxMAX = "lx" // int_fmtio.h:215:1: SCNxPTR = "lx" // int_fmtio.h:216:1: SCOPE_DELIMITER = 37 // netdb.h:308:1: SIG_ATOMIC_MAX = 2147483647 // common_int_limits.h:125:1: SIG_ATOMIC_MIN = -2147483648 // common_int_limits.h:124:1: SIZE_MAX = 18446744073709551615 // common_int_limits.h:128:1: TRY_AGAIN = 2 // netdb.h:231:1: UINT16_MAX = 65535 // common_int_limits.h:59:1: UINT32_MAX = 4294967295 // common_int_limits.h:60:1: UINT64_MAX = 18446744073709551615 // common_int_limits.h:61:1: UINT8_MAX = 255 // common_int_limits.h:58:1: UINTMAX_MAX = 18446744073709551615 // common_int_limits.h:112:1: UINTPTR_MAX = 18446744073709551615 // common_int_limits.h:106:1: UINT_FAST16_MAX = 4294967295 // common_int_limits.h:99:1: UINT_FAST32_MAX = 4294967295 // common_int_limits.h:100:1: UINT_FAST64_MAX = 18446744073709551615 // common_int_limits.h:101:1: UINT_FAST8_MAX = 4294967295 // common_int_limits.h:98:1: UINT_LEAST16_MAX = 65535 // common_int_limits.h:79:1: UINT_LEAST32_MAX = 4294967295 // common_int_limits.h:80:1: UINT_LEAST64_MAX = 18446744073709551615 // common_int_limits.h:81:1: UINT_LEAST8_MAX = 255 // common_int_limits.h:78:1: WCHAR_MAX = 0x7fffffff // wchar_limits.h:41:1: WCHAR_MIN = -2147483648 // wchar_limits.h:40:1: WINT_MAX = 0x7fffffff // wchar_limits.h:45:1: WINT_MIN = -2147483648 // wchar_limits.h:44:1: X_AMD64_INT_CONST_H_ = 0 // int_const.h:33:1: X_AMD64_INT_FMTIO_H_ = 0 // int_fmtio.h:33:1: X_AMD64_INT_LIMITS_H_ = 0 // int_limits.h:33:1: X_AMD64_INT_MWGWTYPES_H_ = 0 // int_mwgwtypes.h:33:1: X_AMD64_INT_TYPES_H_ = 0 // int_types.h:35:1: X_AMD64_WCHAR_LIMITS_H_ = 0 // wchar_limits.h:33:1: X_BSD_INT16_T_ = 0 // stdint.h:50:1: X_BSD_INT32_T_ = 0 // stdint.h:60:1: X_BSD_INT64_T_ = 0 // stdint.h:70:1: X_BSD_INT8_T_ = 0 // stdint.h:40:1: X_BSD_INTPTR_T_ = 0 // stdint.h:80:1: X_BSD_UINT16_T_ = 0 // stdint.h:55:1: X_BSD_UINT32_T_ = 0 // stdint.h:65:1: X_BSD_UINT64_T_ = 0 // stdint.h:75:1: X_BSD_UINT8_T_ = 0 // stdint.h:45:1: X_BSD_UINTPTR_T_ = 0 // stdint.h:85:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_INTTYPES_H_ = 0 // inttypes.h:33:1: X_LP64 = 1 // <predefined>:268:1: X_NETBSD_SOURCE = 1 // featuretest.h:70:1: X_NETDB_H_ = 0 // netdb.h:91:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:113:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:116:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:119:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:122:1: X_PATH_SERVICES = "/etc/services" // netdb.h:125:1: X_PATH_SERVICES_CDB = "/var/db/services.cdb" // netdb.h:128:1: X_PATH_SERVICES_DB = "/var/db/services.db" // netdb.h:131:1: X_SYS_ANSI_H_ = 0 // ansi.h:33:1: X_SYS_CDEFS_ELF_H_ = 0 // cdefs_elf.h:31:1: X_SYS_CDEFS_H_ = 0 // cdefs.h:37:1: X_SYS_COMMON_ANSI_H_ = 0 // common_ansi.h:33:1: X_SYS_COMMON_INT_LIMITS_H_ = 0 // common_int_limits.h:33:1: X_SYS_COMMON_INT_MWGWTYPES_H_ = 0 // common_int_mwgwtypes.h:33:1: X_SYS_COMMON_INT_TYPES_H_ = 0 // common_int_types.h:33:1: X_SYS_INTTYPES_H_ = 0 // inttypes.h:33:1: X_SYS_STDINT_H_ = 0 // stdint.h:33:1: X_X86_64_CDEFS_H_ = 0 // cdefs.h:4:1: ) type Ptrdiff_t = int64 /* <builtin>:3:26 */ type Size_t = uint64 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__int128_t = struct { Flo int64 Fhi int64 } /* <builtin>:21:43 */ // must match modernc.org/mathutil.Int128 type X__uint128_t = struct { Flo uint64 Fhi uint64 } /* <builtin>:22:44 */ // must match modernc.org/mathutil.Int128 type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // return true if value 'a' fits in type 't' // $NetBSD: endian_machdep.h,v 1.4 2006/01/30 21:52:38 dsl Exp $ // $NetBSD: ansi.h,v 1.14 2011/07/17 20:54:54 joerg Exp $ // - // Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc. // All rights reserved. // // This code is derived from software contributed to The NetBSD Foundation // by Jun-ichiro itojun Hagino and by Klaus Klein. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS // ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // $NetBSD: ansi.h,v 1.11 2019/05/07 03:49:26 kamil Exp $ // $NetBSD: common_ansi.h,v 1.1 2014/08/19 07:27:31 matt Exp $ // - // Copyright (c) 2014 The NetBSD Foundation, Inc. // All rights reserved. // // This code is derived from software contributed to The NetBSD Foundation // by Matt Thomas of 3am Software Foundry. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS // ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // $NetBSD: cdefs.h,v 1.141 2019/02/21 21:34:05 christos Exp $ // * Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 // $NetBSD: int_types.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ // - // Copyright (c) 1990 The Regents of the University of California. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // from: @(#)types.h 7.5 (Berkeley) 3/9/91 // $NetBSD: common_int_types.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ // - // Copyright (c) 2014 The NetBSD Foundation, Inc. // All rights reserved. // // This code is derived from software contributed to The NetBSD Foundation // by Joerg Sonnenberger. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS // ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // 7.18.1 Integer types // 7.18.1.1 Exact-width integer types type X__int8_t = int8 /* common_int_types.h:45:27 */ type X__uint8_t = uint8 /* common_int_types.h:46:27 */ type X__int16_t = int16 /* common_int_types.h:47:27 */ type X__uint16_t = uint16 /* common_int_types.h:48:27 */ type X__int32_t = int32 /* common_int_types.h:49:27 */ type X__uint32_t = uint32 /* common_int_types.h:50:27 */ type X__int64_t = int64 /* common_int_types.h:51:27 */ type X__uint64_t = uint64 /* common_int_types.h:52:27 */ // 7.18.1.4 Integer types capable of holding object pointers type X__intptr_t = int64 /* common_int_types.h:58:27 */ type X__uintptr_t = uint64 /* common_int_types.h:59:26 */ // Types which are fundamental to the implementation and may appear in // more than one standard header are defined here. Standard headers // then use: // #ifdef _BSD_SIZE_T_ // typedef _BSD_SIZE_T_ size_t; // #undef _BSD_SIZE_T_ // #endif type X__caddr_t = uintptr /* ansi.h:37:14 */ // core address type X__gid_t = X__uint32_t /* ansi.h:38:20 */ // group id type X__in_addr_t = X__uint32_t /* ansi.h:39:20 */ // IP(v4) address type X__in_port_t = X__uint16_t /* ansi.h:40:20 */ // "Internet" port number type X__mode_t = X__uint32_t /* ansi.h:41:20 */ // file permissions type X__off_t = X__int64_t /* ansi.h:42:19 */ // file offset
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_netbsd_arm.go
vendor/modernc.org/libc/netdb/capi_netbsd_arm.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_netbsd_arm.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_linux_386.go
vendor/modernc.org/libc/netdb/capi_linux_386.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_386.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_openbsd_amd64.go
vendor/modernc.org/libc/netdb/netdb_openbsd_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_openbsd_amd64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AI_ADDRCONFIG = 64 // netdb.h:165:1: AI_CANONNAME = 2 // netdb.h:160:1: AI_EXT = 8 // netdb.h:162:1: AI_FQDN = 32 // netdb.h:164:1: AI_MASK = 119 // netdb.h:167:1: AI_NUMERICHOST = 4 // netdb.h:161:1: AI_NUMERICSERV = 16 // netdb.h:163:1: AI_PASSIVE = 1 // netdb.h:159:1: BIG_ENDIAN = 4321 // endian.h:45:1: BYTE_ORDER = 1234 // endian.h:47:1: EAI_ADDRFAMILY = -9 // netdb.h:196:1: EAI_AGAIN = -3 // netdb.h:190:1: EAI_BADFLAGS = -1 // netdb.h:188:1: EAI_BADHINTS = -12 // netdb.h:199:1: EAI_FAIL = -4 // netdb.h:191:1: EAI_FAMILY = -6 // netdb.h:193:1: EAI_MEMORY = -10 // netdb.h:197:1: EAI_NODATA = -5 // netdb.h:192:1: EAI_NONAME = -2 // netdb.h:189:1: EAI_OVERFLOW = -14 // netdb.h:201:1: EAI_PROTOCOL = -13 // netdb.h:200:1: EAI_SERVICE = -8 // netdb.h:195:1: EAI_SOCKTYPE = -7 // netdb.h:194:1: EAI_SYSTEM = -11 // netdb.h:198:1: ERRSET_FAIL = 2 // netdb.h:225:1: ERRSET_INVAL = 3 // netdb.h:226:1: ERRSET_NODATA = 5 // netdb.h:228:1: ERRSET_NOMEMORY = 1 // netdb.h:224:1: ERRSET_NONAME = 4 // netdb.h:227:1: ERRSET_SUCCESS = 0 // netdb.h:223:1: HOST_NOT_FOUND = 1 // netdb.h:151:1: ICMP6_FILTER = 18 // in6.h:304:1: INET6_ADDRSTRLEN = 46 // in6.h:97:1: INET_ADDRSTRLEN = 16 // in.h:382:1: IN_CLASSA_MAX = 128 // in.h:195:1: IN_CLASSA_NSHIFT = 24 // in.h:193:1: IN_CLASSB_MAX = 65536 // in.h:202:1: IN_CLASSB_NSHIFT = 16 // in.h:200:1: IN_CLASSC_NSHIFT = 8 // in.h:207:1: IN_CLASSD_NSHIFT = 28 // in.h:214:1: IN_LOOPBACKNET = 127 // in.h:253:1: IN_RFC3021_NSHIFT = 31 // in.h:219:1: IPCTL_ARPDOWN = 40 // in.h:698:1: IPCTL_ARPQUEUE = 41 // in.h:699:1: IPCTL_ARPQUEUED = 36 // in.h:694:1: IPCTL_ARPTIMEOUT = 39 // in.h:697:1: IPCTL_DEFTTL = 3 // in.h:662:1: IPCTL_DIRECTEDBCAST = 6 // in.h:664:1: IPCTL_ENCDEBUG = 12 // in.h:670:1: IPCTL_FORWARDING = 1 // in.h:660:1: IPCTL_IFQUEUE = 30 // in.h:688:1: IPCTL_IPPORT_FIRSTAUTO = 7 // in.h:665:1: IPCTL_IPPORT_HIFIRSTAUTO = 9 // in.h:667:1: IPCTL_IPPORT_HILASTAUTO = 10 // in.h:668:1: IPCTL_IPPORT_LASTAUTO = 8 // in.h:666:1: IPCTL_IPPORT_MAXQUEUE = 11 // in.h:669:1: IPCTL_IPSEC_ALLOCATIONS = 18 // in.h:676:1: IPCTL_IPSEC_AUTH_ALGORITHM = 26 // in.h:684:1: IPCTL_IPSEC_BYTES = 20 // in.h:678:1: IPCTL_IPSEC_EMBRYONIC_SA_TIMEOUT = 15 // in.h:673:1: IPCTL_IPSEC_ENC_ALGORITHM = 25 // in.h:683:1: IPCTL_IPSEC_EXPIRE_ACQUIRE = 14 // in.h:672:1: IPCTL_IPSEC_FIRSTUSE = 24 // in.h:682:1: IPCTL_IPSEC_IPCOMP_ALGORITHM = 29 // in.h:687:1: IPCTL_IPSEC_REQUIRE_PFS = 16 // in.h:674:1: IPCTL_IPSEC_SOFT_ALLOCATIONS = 17 // in.h:675:1: IPCTL_IPSEC_SOFT_BYTES = 19 // in.h:677:1: IPCTL_IPSEC_SOFT_FIRSTUSE = 23 // in.h:681:1: IPCTL_IPSEC_SOFT_TIMEOUT = 22 // in.h:680:1: IPCTL_IPSEC_STATS = 13 // in.h:671:1: IPCTL_IPSEC_TIMEOUT = 21 // in.h:679:1: IPCTL_MAXID = 42 // in.h:700:1: IPCTL_MFORWARDING = 31 // in.h:689:1: IPCTL_MRTMFC = 37 // in.h:695:1: IPCTL_MRTPROTO = 34 // in.h:692:1: IPCTL_MRTSTATS = 35 // in.h:693:1: IPCTL_MRTVIF = 38 // in.h:696:1: IPCTL_MTUDISC = 27 // in.h:685:1: IPCTL_MTUDISCTIMEOUT = 28 // in.h:686:1: IPCTL_MULTIPATH = 32 // in.h:690:1: IPCTL_SENDREDIRECTS = 2 // in.h:661:1: IPCTL_SOURCEROUTE = 5 // in.h:663:1: IPCTL_STATS = 33 // in.h:691:1: IPPORT_HIFIRSTAUTO = 49152 // in.h:159:1: IPPORT_HILASTAUTO = 65535 // in.h:160:1: IPPORT_RESERVED = 1024 // in.h:153:1: IPPORT_USERRESERVED = 49151 // in.h:154:1: IPPROTO_AH = 51 // in.h:89:1: IPPROTO_CARP = 112 // in.h:99:1: IPPROTO_DIVERT = 258 // in.h:109:1: IPPROTO_DONE = 257 // in.h:173:1: IPPROTO_DSTOPTS = 60 // in.h:93:1: IPPROTO_EGP = 8 // in.h:78:1: IPPROTO_ENCAP = 98 // in.h:96:1: IPPROTO_EON = 80 // in.h:94:1: IPPROTO_ESP = 50 // in.h:88:1: IPPROTO_ETHERIP = 97 // in.h:95:1: IPPROTO_FRAGMENT = 44 // in.h:85:1: IPPROTO_GGP = 3 // in.h:74:1: IPPROTO_GRE = 47 // in.h:87:1: IPPROTO_HOPOPTS = 0 // in.h:71:1: IPPROTO_ICMP = 1 // in.h:72:1: IPPROTO_ICMPV6 = 58 // in.h:91:1: IPPROTO_IDP = 22 // in.h:81:1: IPPROTO_IGMP = 2 // in.h:73:1: IPPROTO_IP = 0 // in.h:70:1: IPPROTO_IPCOMP = 108 // in.h:98:1: IPPROTO_IPIP = 4 // in.h:75:1: IPPROTO_IPV4 = 4 // in.h:76:1: IPPROTO_IPV6 = 41 // in.h:83:1: IPPROTO_MAX = 256 // in.h:106:1: IPPROTO_MAXID = 259 // in.h:393:1: IPPROTO_MOBILE = 55 // in.h:90:1: IPPROTO_MPLS = 137 // in.h:102:1: IPPROTO_NONE = 59 // in.h:92:1: IPPROTO_PFSYNC = 240 // in.h:103:1: IPPROTO_PIM = 103 // in.h:97:1: IPPROTO_PUP = 12 // in.h:79:1: IPPROTO_RAW = 255 // in.h:104:1: IPPROTO_ROUTING = 43 // in.h:84:1: IPPROTO_RSVP = 46 // in.h:86:1: IPPROTO_SCTP = 132 // in.h:100:1: IPPROTO_TCP = 6 // in.h:77:1: IPPROTO_TP = 29 // in.h:82:1: IPPROTO_UDP = 17 // in.h:80:1: IPPROTO_UDPLITE = 136 // in.h:101:1: IPSEC6_OUTSA = 56 // in6.h:337:1: IPSEC_AUTH_LEVEL_DEFAULT = 1 // in.h:336:1: IPSEC_ESP_NETWORK_LEVEL_DEFAULT = 1 // in.h:338:1: IPSEC_ESP_TRANS_LEVEL_DEFAULT = 1 // in.h:337:1: IPSEC_IPCOMP_LEVEL_DEFAULT = 1 // in.h:339:1: IPSEC_LEVEL_AVAIL = 0x01 // in.h:330:1: IPSEC_LEVEL_BYPASS = 0x00 // in.h:328:1: IPSEC_LEVEL_DEFAULT = 1 // in.h:334:1: IPSEC_LEVEL_NONE = 0x00 // in.h:329:1: IPSEC_LEVEL_REQUIRE = 0x03 // in.h:332:1: IPSEC_LEVEL_UNIQUE = 0x04 // in.h:333:1: IPSEC_LEVEL_USE = 0x02 // in.h:331:1: IPV6CTL_ACCEPT_RTADV = 12 // in6.h:575:1: IPV6CTL_AUTO_FLOWLABEL = 17 // in6.h:579:1: IPV6CTL_DAD_COUNT = 16 // in6.h:578:1: IPV6CTL_DAD_PENDING = 49 // in6.h:589:1: IPV6CTL_DEFHLIM = 3 // in6.h:567:1: IPV6CTL_DEFMCASTHLIM = 18 // in6.h:580:1: IPV6CTL_FORWARDING = 1 // in6.h:565:1: IPV6CTL_FORWSRCRT = 5 // in6.h:568:1: IPV6CTL_HDRNESTLIMIT = 15 // in6.h:577:1: IPV6CTL_IFQUEUE = 51 // in6.h:591:1: IPV6CTL_LOG_INTERVAL = 14 // in6.h:576:1: IPV6CTL_MAXDYNROUTES = 48 // in6.h:588:1: IPV6CTL_MAXFRAGPACKETS = 9 // in6.h:572:1: IPV6CTL_MAXFRAGS = 41 // in6.h:583:1: IPV6CTL_MAXID = 55 // in6.h:595:1: IPV6CTL_MCAST_PMTU = 44 // in6.h:586:1: IPV6CTL_MFORWARDING = 42 // in6.h:584:1: IPV6CTL_MRTMFC = 53 // in6.h:593:1: IPV6CTL_MRTMIF = 52 // in6.h:592:1: IPV6CTL_MRTPROTO = 8 // in6.h:571:1: IPV6CTL_MRTSTATS = 7 // in6.h:570:1: IPV6CTL_MTUDISCTIMEOUT = 50 // in6.h:590:1: IPV6CTL_MULTIPATH = 43 // in6.h:585:1: IPV6CTL_NEIGHBORGCTHRESH = 45 // in6.h:587:1: IPV6CTL_SENDREDIRECTS = 2 // in6.h:566:1: IPV6CTL_SOIIKEY = 54 // in6.h:594:1: IPV6CTL_SOURCECHECK = 10 // in6.h:573:1: IPV6CTL_SOURCECHECK_LOGINT = 11 // in6.h:574:1: IPV6CTL_STATS = 6 // in6.h:569:1: IPV6CTL_USE_DEPRECATED = 21 // in6.h:581:1: IPV6PROTO_MAXID = 259 // in6.h:470:1: IPV6_AUTH_LEVEL = 53 // in6.h:333:1: IPV6_AUTOFLOWLABEL = 59 // in6.h:341:1: IPV6_CHECKSUM = 26 // in6.h:307:1: IPV6_DEFAULT_MULTICAST_HOPS = 1 // in6.h:360:1: IPV6_DEFAULT_MULTICAST_LOOP = 1 // in6.h:361:1: IPV6_DONTFRAG = 62 // in6.h:345:1: IPV6_DSTOPTS = 50 // in6.h:330:1: IPV6_ESP_NETWORK_LEVEL = 55 // in6.h:335:1: IPV6_ESP_TRANS_LEVEL = 54 // in6.h:334:1: IPV6_HOPLIMIT = 47 // in6.h:327:1: IPV6_HOPOPTS = 49 // in6.h:329:1: IPV6_IPCOMP_LEVEL = 60 // in6.h:342:1: IPV6_JOIN_GROUP = 12 // in6.h:300:1: IPV6_LEAVE_GROUP = 13 // in6.h:301:1: IPV6_MINHOPCOUNT = 65 // in6.h:349:1: IPV6_MULTICAST_HOPS = 10 // in6.h:298:1: IPV6_MULTICAST_IF = 9 // in6.h:297:1: IPV6_MULTICAST_LOOP = 11 // in6.h:299:1: IPV6_NEXTHOP = 48 // in6.h:328:1: IPV6_PATHMTU = 44 // in6.h:322:1: IPV6_PIPEX = 63 // in6.h:346:1: IPV6_PKTINFO = 46 // in6.h:326:1: IPV6_PORTRANGE = 14 // in6.h:302:1: IPV6_PORTRANGE_DEFAULT = 0 // in6.h:393:1: IPV6_PORTRANGE_HIGH = 1 // in6.h:394:1: IPV6_PORTRANGE_LOW = 2 // in6.h:395:1: IPV6_RECVDSTOPTS = 40 // in6.h:317:1: IPV6_RECVDSTPORT = 64 // in6.h:348:1: IPV6_RECVHOPLIMIT = 37 // in6.h:314:1: IPV6_RECVHOPOPTS = 39 // in6.h:316:1: IPV6_RECVPATHMTU = 43 // in6.h:320:1: IPV6_RECVPKTINFO = 36 // in6.h:313:1: IPV6_RECVRTHDR = 38 // in6.h:315:1: IPV6_RECVTCLASS = 57 // in6.h:339:1: IPV6_RTABLE = 0x1021 // in6.h:351:1: IPV6_RTHDR = 51 // in6.h:331:1: IPV6_RTHDRDSTOPTS = 35 // in6.h:311:1: IPV6_RTHDR_LOOSE = 0 // in6.h:354:1: IPV6_RTHDR_TYPE_0 = 0 // in6.h:355:1: IPV6_TCLASS = 61 // in6.h:344:1: IPV6_UNICAST_HOPS = 4 // in6.h:296:1: IPV6_USE_MIN_MTU = 42 // in6.h:319:1: IPV6_V6ONLY = 27 // in6.h:308:1: IP_ADD_MEMBERSHIP = 12 // in.h:297:1: IP_AUTH_LEVEL = 20 // in.h:300:1: IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:347:1: IP_DEFAULT_MULTICAST_TTL = 1 // in.h:346:1: IP_DROP_MEMBERSHIP = 13 // in.h:298:1: IP_ESP_NETWORK_LEVEL = 22 // in.h:302:1: IP_ESP_TRANS_LEVEL = 21 // in.h:301:1: IP_HDRINCL = 2 // in.h:287:1: IP_IPCOMP_LEVEL = 29 // in.h:309:1: IP_IPDEFTTL = 37 // in.h:317:1: IP_IPSECFLOWINFO = 36 // in.h:316:1: IP_IPSEC_LOCAL_AUTH = 27 // in.h:307:1: IP_IPSEC_LOCAL_CRED = 25 // in.h:305:1: IP_IPSEC_LOCAL_ID = 23 // in.h:303:1: IP_IPSEC_REMOTE_AUTH = 28 // in.h:308:1: IP_IPSEC_REMOTE_CRED = 26 // in.h:306:1: IP_IPSEC_REMOTE_ID = 24 // in.h:304:1: IP_MAX_MEMBERSHIPS = 4095 // in.h:354:1: IP_MINTTL = 32 // in.h:312:1: IP_MIN_MEMBERSHIPS = 15 // in.h:353:1: IP_MULTICAST_IF = 9 // in.h:294:1: IP_MULTICAST_LOOP = 11 // in.h:296:1: IP_MULTICAST_TTL = 10 // in.h:295:1: IP_OPTIONS = 1 // in.h:286:1: IP_PIPEX = 34 // in.h:314:1: IP_PORTRANGE = 19 // in.h:299:1: IP_PORTRANGE_DEFAULT = 0 // in.h:374:1: IP_PORTRANGE_HIGH = 1 // in.h:375:1: IP_PORTRANGE_LOW = 2 // in.h:376:1: IP_RECVDSTADDR = 7 // in.h:292:1: IP_RECVDSTPORT = 33 // in.h:313:1: IP_RECVIF = 30 // in.h:310:1: IP_RECVOPTS = 5 // in.h:290:1: IP_RECVRETOPTS = 6 // in.h:291:1: IP_RECVRTABLE = 35 // in.h:315:1: IP_RECVTTL = 31 // in.h:311:1: IP_RETOPTS = 8 // in.h:293:1: IP_RTABLE = 0x1021 // in.h:321:1: IP_SENDSRCADDR = 7 // in.h:318:1: IP_TOS = 3 // in.h:288:1: IP_TTL = 4 // in.h:289:1: LITTLE_ENDIAN = 1234 // endian.h:44:1: NETDB_INTERNAL = -1 // netdb.h:149:1: NETDB_SUCCESS = 0 // netdb.h:150:1: NI_DGRAM = 16 // netdb.h:175:1: NI_MAXHOST = 256 // netdb.h:179:1: NI_MAXSERV = 32 // netdb.h:180:1: NI_NAMEREQD = 8 // netdb.h:174:1: NI_NOFQDN = 4 // netdb.h:173:1: NI_NUMERICHOST = 1 // netdb.h:171:1: NI_NUMERICSERV = 2 // netdb.h:172:1: NO_ADDRESS = 4 // netdb.h:155:1: NO_DATA = 4 // netdb.h:154:1: NO_RECOVERY = 3 // netdb.h:153:1: PDP_ENDIAN = 3412 // endian.h:46:1: RRSET_VALIDATED = 1 // netdb.h:218:1: SCOPE_DELIMITER = 37 // netdb.h:185:1: SIN6_LEN = 0 // in6.h:104:1: TRY_AGAIN = 2 // netdb.h:152:1: X_BIG_ENDIAN = 4321 // _endian.h:43:1: X_BYTE_ORDER = 1234 // endian.h:58:1: X_CLOCKID_T_DEFINED_ = 0 // types.h:162:1: X_CLOCK_T_DEFINED_ = 0 // types.h:157:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_INT16_T_DEFINED_ = 0 // types.h:84:1: X_INT32_T_DEFINED_ = 0 // types.h:94:1: X_INT64_T_DEFINED_ = 0 // types.h:104:1: X_INT8_T_DEFINED_ = 0 // types.h:74:1: X_IN_ADDR_DECLARED = 0 // in.h:163:1: X_IN_TYPES_DEFINED_ = 0 // in.h:62:1: X_LITTLE_ENDIAN = 1234 // _endian.h:42:1: X_LP64 = 1 // <predefined>:1:1: X_MACHINE_CDEFS_H_ = 0 // cdefs.h:9:1: X_MACHINE_ENDIAN_H_ = 0 // endian.h:28:1: X_MACHINE__TYPES_H_ = 0 // _types.h:36:1: X_MAX_PAGE_SHIFT = 12 // _types.h:52:1: X_NETDB_H_ = 0 // netdb.h:88:1: X_NETINET6_IN6_H_ = 0 // in6.h:69:1: X_NETINET_IN_H_ = 0 // in.h:39:1: X_OFF_T_DEFINED_ = 0 // types.h:192:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:97:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:98:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:99:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:100:1: X_PATH_SERVICES = "/etc/services" // netdb.h:101:1: X_PDP_ENDIAN = 3412 // _endian.h:44:1: X_PID_T_DEFINED_ = 0 // types.h:167:1: X_QUAD_HIGHWORD = 1 // _endian.h:95:1: X_QUAD_LOWWORD = 0 // _endian.h:96:1: X_RET_PROTECTOR = 1 // <predefined>:2:1: X_SA_FAMILY_T_DEFINED_ = 0 // in.h:57:1: X_SIZE_T_DEFINED_ = 0 // types.h:172:1: X_SOCKLEN_T_DEFINED_ = 0 // in6.h:400:1: X_SSIZE_T_DEFINED_ = 0 // types.h:177:1: X_STACKALIGNBYTES = 15 // _types.h:49:1: X_SYS_CDEFS_H_ = 0 // cdefs.h:39:1: X_SYS_ENDIAN_H_ = 0 // endian.h:38:1: X_SYS_TYPES_H_ = 0 // types.h:41:1: X_SYS__ENDIAN_H_ = 0 // _endian.h:34:1: X_SYS__TYPES_H_ = 0 // _types.h:35:1: X_TIMER_T_DEFINED_ = 0 // types.h:187:1: X_TIME_T_DEFINED_ = 0 // types.h:182:1: X_UINT16_T_DEFINED_ = 0 // types.h:89:1: X_UINT32_T_DEFINED_ = 0 // types.h:99:1: X_UINT64_T_DEFINED_ = 0 // types.h:109:1: X_UINT8_T_DEFINED_ = 0 // types.h:79:1: Unix = 1 // <predefined>:344:1: ) type Ptrdiff_t = int64 /* <builtin>:3:26 */ type Size_t = uint64 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__int128_t = struct { Flo int64 Fhi int64 } /* <builtin>:21:43 */ // must match modernc.org/mathutil.Int128 type X__uint128_t = struct { Flo uint64 Fhi uint64 } /* <builtin>:22:44 */ // must match modernc.org/mathutil.Int128 type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // $OpenBSD: netdb.h,v 1.33 2015/01/18 20:29:31 deraadt Exp $ // ++Copyright++ 1980, 1983, 1988, 1993 // - // Copyright (c) 1980, 1983, 1988, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // - // Portions Copyright (c) 1993 by Digital Equipment Corporation. // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies, and that // the name of Digital Equipment Corporation not be used in advertising or // publicity pertaining to distribution of the document or software without // specific, written prior permission. // // THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL // WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT // CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL // DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR // PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS // ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS // SOFTWARE. // - // --Copyright-- // Copyright (c) 1995, 1996, 1997, 1998, 1999 Craig Metz. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the author nor the names of any contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // @(#)netdb.h 8.1 (Berkeley) 6/2/93 // $From: netdb.h,v 8.7 1996/05/09 05:59:09 vixie Exp $ // $OpenBSD: in.h,v 1.141 2021/06/02 00:09:57 dlg Exp $ // $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ // Copyright (c) 1982, 1986, 1990, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // Constants and structures defined by the internet system, // Per RFC 790, September 1981, and numerous additions. // $OpenBSD: cdefs.h,v 1.43 2018/10/29 17:10:40 guenther Exp $ // $NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $ // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.7 (Berkeley) 1/21/94 // $OpenBSD: cdefs.h,v 1.3 2013/03/28 17:30:45 martynas Exp $ // Written by J.T. Conklin <jtc@wimsey.com> 01/17/95. // Public domain. // Macro to test if we're using a specific version of gcc or later. // The __CONCAT macro is used to concatenate parts of symbol names, e.g. // with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. // The __CONCAT macro is a bit tricky -- make sure you don't put spaces // in between its arguments. Do not use __CONCAT on double-quoted strings, // such as those from the __STRING macro: to concatenate strings just put // them next to each other. // GCC1 and some versions of GCC2 declare dead (non-returning) and // pure (no side effects) functions using "volatile" and "const"; // unfortunately, these then cause warnings under "-ansi -pedantic". // GCC >= 2.5 uses the __attribute__((attrs)) style. All of these // work for GNU C++ (modulo a slight glitch in the C++ grammar in // the distribution version of 2.5.5). // __returns_twice makes the compiler not assume the function
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_linux_s390x.go
vendor/modernc.org/libc/netdb/netdb_linux_s390x.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_s390x.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_ALG = 38 AF_APPLETALK = 5 AF_ASH = 18 AF_ATMPVC = 8 AF_ATMSVC = 20 AF_AX25 = 3 AF_BLUETOOTH = 31 AF_BRIDGE = 7 AF_CAIF = 37 AF_CAN = 29 AF_DECnet = 12 AF_ECONET = 19 AF_FILE = 1 AF_IB = 27 AF_IEEE802154 = 36 AF_INET = 2 AF_INET6 = 10 AF_IPX = 4 AF_IRDA = 23 AF_ISDN = 34 AF_IUCV = 32 AF_KCM = 41 AF_KEY = 15 AF_LLC = 26 AF_LOCAL = 1 AF_MAX = 45 AF_MPLS = 28 AF_NETBEUI = 13 AF_NETLINK = 16 AF_NETROM = 6 AF_NFC = 39 AF_PACKET = 17 AF_PHONET = 35 AF_PPPOX = 24 AF_QIPCRTR = 42 AF_RDS = 21 AF_ROSE = 11 AF_ROUTE = 16 AF_RXRPC = 33 AF_SECURITY = 14 AF_SMC = 43 AF_SNA = 22 AF_TIPC = 30 AF_UNIX = 1 AF_UNSPEC = 0 AF_VSOCK = 40 AF_WANPIPE = 25 AF_X25 = 9 AF_XDP = 44 AI_ADDRCONFIG = 0x0020 AI_ALL = 0x0010 AI_CANONNAME = 0x0002 AI_NUMERICHOST = 0x0004 AI_NUMERICSERV = 0x0400 AI_PASSIVE = 0x0001 AI_V4MAPPED = 0x0008 BIG_ENDIAN = 4321 BYTE_ORDER = 4321 EAI_AGAIN = -3 EAI_BADFLAGS = -1 EAI_FAIL = -4 EAI_FAMILY = -6 EAI_MEMORY = -10 EAI_NONAME = -2 EAI_OVERFLOW = -12 EAI_SERVICE = -8 EAI_SOCKTYPE = -7 EAI_SYSTEM = -11 FD_SETSIZE = 1024 FIOGETOWN = 0x8903 FIOSETOWN = 0x8901 HOST_NOT_FOUND = 1 INET6_ADDRSTRLEN = 46 INET_ADDRSTRLEN = 16 IN_CLASSA_HOST = 16777215 IN_CLASSA_MAX = 128 IN_CLASSA_NET = 0xff000000 IN_CLASSA_NSHIFT = 24 IN_CLASSB_HOST = 65535 IN_CLASSB_MAX = 65536 IN_CLASSB_NET = 0xffff0000 IN_CLASSB_NSHIFT = 16 IN_CLASSC_HOST = 255 IN_CLASSC_NET = 0xffffff00 IN_CLASSC_NSHIFT = 8 IN_LOOPBACKNET = 127 IPPORT_RESERVED1 = 1024 IPV6_2292DSTOPTS = 4 IPV6_2292HOPLIMIT = 8 IPV6_2292HOPOPTS = 3 IPV6_2292PKTINFO = 2 IPV6_2292PKTOPTIONS = 6 IPV6_2292RTHDR = 5 IPV6_ADDRFORM = 1 IPV6_ADDR_PREFERENCES = 72 IPV6_ADD_MEMBERSHIP = 20 IPV6_AUTHHDR = 10 IPV6_AUTOFLOWLABEL = 70 IPV6_CHECKSUM = 7 IPV6_DONTFRAG = 62 IPV6_DROP_MEMBERSHIP = 21 IPV6_DSTOPTS = 59 IPV6_FREEBIND = 78 IPV6_HDRINCL = 36 IPV6_HOPLIMIT = 52 IPV6_HOPOPTS = 54 IPV6_IPSEC_POLICY = 34 IPV6_JOIN_ANYCAST = 27 IPV6_JOIN_GROUP = 20 IPV6_LEAVE_ANYCAST = 28 IPV6_LEAVE_GROUP = 21 IPV6_MINHOPCOUNT = 73 IPV6_MTU = 24 IPV6_MTU_DISCOVER = 23 IPV6_MULTICAST_ALL = 29 IPV6_MULTICAST_HOPS = 18 IPV6_MULTICAST_IF = 17 IPV6_MULTICAST_LOOP = 19 IPV6_NEXTHOP = 9 IPV6_ORIGDSTADDR = 74 IPV6_PATHMTU = 61 IPV6_PKTINFO = 50 IPV6_PMTUDISC_DO = 2 IPV6_PMTUDISC_DONT = 0 IPV6_PMTUDISC_INTERFACE = 4 IPV6_PMTUDISC_OMIT = 5 IPV6_PMTUDISC_PROBE = 3 IPV6_PMTUDISC_WANT = 1 IPV6_RECVDSTOPTS = 58 IPV6_RECVERR = 25 IPV6_RECVFRAGSIZE = 77 IPV6_RECVHOPLIMIT = 51 IPV6_RECVHOPOPTS = 53 IPV6_RECVORIGDSTADDR = 74 IPV6_RECVPATHMTU = 60 IPV6_RECVPKTINFO = 49 IPV6_RECVRTHDR = 56 IPV6_RECVTCLASS = 66 IPV6_ROUTER_ALERT = 22 IPV6_ROUTER_ALERT_ISOLATE = 30 IPV6_RTHDR = 57 IPV6_RTHDRDSTOPTS = 55 IPV6_RTHDR_LOOSE = 0 IPV6_RTHDR_STRICT = 1 IPV6_RTHDR_TYPE_0 = 0 IPV6_RXDSTOPTS = 59 IPV6_RXHOPOPTS = 54 IPV6_TCLASS = 67 IPV6_TRANSPARENT = 75 IPV6_UNICAST_HOPS = 16 IPV6_UNICAST_IF = 76 IPV6_V6ONLY = 26 IPV6_XFRM_POLICY = 35 IP_ADD_MEMBERSHIP = 35 IP_ADD_SOURCE_MEMBERSHIP = 39 IP_BIND_ADDRESS_NO_PORT = 24 IP_BLOCK_SOURCE = 38 IP_CHECKSUM = 23 IP_DEFAULT_MULTICAST_LOOP = 1 IP_DEFAULT_MULTICAST_TTL = 1 IP_DROP_MEMBERSHIP = 36 IP_DROP_SOURCE_MEMBERSHIP = 40 IP_FREEBIND = 15 IP_HDRINCL = 3 IP_IPSEC_POLICY = 16 IP_MAX_MEMBERSHIPS = 20 IP_MINTTL = 21 IP_MSFILTER = 41 IP_MTU = 14 IP_MTU_DISCOVER = 10 IP_MULTICAST_ALL = 49 IP_MULTICAST_IF = 32 IP_MULTICAST_LOOP = 34 IP_MULTICAST_TTL = 33 IP_NODEFRAG = 22 IP_OPTIONS = 4 IP_ORIGDSTADDR = 20 IP_PASSSEC = 18 IP_PKTINFO = 8 IP_PKTOPTIONS = 9 IP_PMTUDISC = 10 IP_PMTUDISC_DO = 2 IP_PMTUDISC_DONT = 0 IP_PMTUDISC_INTERFACE = 4 IP_PMTUDISC_OMIT = 5 IP_PMTUDISC_PROBE = 3 IP_PMTUDISC_WANT = 1 IP_RECVERR = 11 IP_RECVFRAGSIZE = 25 IP_RECVOPTS = 6 IP_RECVORIGDSTADDR = 20 IP_RECVRETOPTS = 7 IP_RECVTOS = 13 IP_RECVTTL = 12 IP_RETOPTS = 7 IP_ROUTER_ALERT = 5 IP_TOS = 1 IP_TRANSPARENT = 19 IP_TTL = 2 IP_UNBLOCK_SOURCE = 37 IP_UNICAST_IF = 50 IP_XFRM_POLICY = 17 LITTLE_ENDIAN = 1234 MCAST_BLOCK_SOURCE = 43 MCAST_EXCLUDE = 0 MCAST_INCLUDE = 1 MCAST_JOIN_GROUP = 42 MCAST_JOIN_SOURCE_GROUP = 46 MCAST_LEAVE_GROUP = 45 MCAST_LEAVE_SOURCE_GROUP = 47 MCAST_MSFILTER = 48 MCAST_UNBLOCK_SOURCE = 44 NETDB_INTERNAL = -1 NETDB_SUCCESS = 0 NI_DGRAM = 16 NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 8 NI_NOFQDN = 4 NI_NUMERICHOST = 1 NI_NUMERICSERV = 2 NO_ADDRESS = 4 NO_DATA = 4 NO_RECOVERY = 3 PDP_ENDIAN = 3412 PF_ALG = 38 PF_APPLETALK = 5 PF_ASH = 18 PF_ATMPVC = 8 PF_ATMSVC = 20 PF_AX25 = 3 PF_BLUETOOTH = 31 PF_BRIDGE = 7 PF_CAIF = 37 PF_CAN = 29 PF_DECnet = 12 PF_ECONET = 19 PF_FILE = 1 PF_IB = 27 PF_IEEE802154 = 36 PF_INET = 2 PF_INET6 = 10 PF_IPX = 4 PF_IRDA = 23 PF_ISDN = 34 PF_IUCV = 32 PF_KCM = 41 PF_KEY = 15 PF_LLC = 26 PF_LOCAL = 1 PF_MAX = 45 PF_MPLS = 28 PF_NETBEUI = 13 PF_NETLINK = 16 PF_NETROM = 6 PF_NFC = 39 PF_PACKET = 17 PF_PHONET = 35 PF_PPPOX = 24 PF_QIPCRTR = 42 PF_RDS = 21 PF_ROSE = 11 PF_ROUTE = 16 PF_RXRPC = 33 PF_SECURITY = 14 PF_SMC = 43 PF_SNA = 22 PF_TIPC = 30 PF_UNIX = 1 PF_UNSPEC = 0 PF_VSOCK = 40 PF_WANPIPE = 25 PF_X25 = 9 PF_XDP = 44 SCM_TIMESTAMP = 29 SCM_TIMESTAMPING = 37 SCM_TIMESTAMPING_OPT_STATS = 54 SCM_TIMESTAMPING_PKTINFO = 58 SCM_TIMESTAMPNS = 35 SCM_TXTIME = 61 SCM_WIFI_STATUS = 41 SIOCATMARK = 0x8905 SIOCGPGRP = 0x8904 SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 SIOCSPGRP = 0x8902 SOL_AAL = 265 SOL_ALG = 279 SOL_ATM = 264 SOL_BLUETOOTH = 274 SOL_CAIF = 278 SOL_DCCP = 269 SOL_DECNET = 261 SOL_ICMPV6 = 58 SOL_IP = 0 SOL_IPV6 = 41 SOL_IRDA = 266 SOL_IUCV = 277 SOL_KCM = 281 SOL_LLC = 268 SOL_NETBEUI = 267 SOL_NETLINK = 270 SOL_NFC = 280 SOL_PACKET = 263 SOL_PNPIPE = 275 SOL_PPPOL2TP = 273 SOL_RAW = 255 SOL_RDS = 276 SOL_RXRPC = 272 SOL_SOCKET = 1 SOL_TIPC = 271 SOL_TLS = 282 SOL_X25 = 262 SOL_XDP = 283 SOMAXCONN = 4096 SO_ACCEPTCONN = 30 SO_ATTACH_BPF = 50 SO_ATTACH_FILTER = 26 SO_ATTACH_REUSEPORT_CBPF = 51 SO_ATTACH_REUSEPORT_EBPF = 52 SO_BINDTODEVICE = 25 SO_BINDTOIFINDEX = 62 SO_BPF_EXTENSIONS = 48 SO_BROADCAST = 6 SO_BSDCOMPAT = 14 SO_BUSY_POLL = 46 SO_CNX_ADVICE = 53 SO_COOKIE = 57 SO_DEBUG = 1 SO_DETACH_BPF = 27 SO_DETACH_FILTER = 27 SO_DETACH_REUSEPORT_BPF = 68 SO_DOMAIN = 39 SO_DONTROUTE = 5 SO_ERROR = 4 SO_GET_FILTER = 26 SO_INCOMING_CPU = 49 SO_INCOMING_NAPI_ID = 56 SO_KEEPALIVE = 9 SO_LINGER = 13 SO_LOCK_FILTER = 44 SO_MARK = 36 SO_MAX_PACING_RATE = 47 SO_MEMINFO = 55 SO_NOFCS = 43 SO_NO_CHECK = 11 SO_OOBINLINE = 10 SO_PASSCRED = 16 SO_PASSSEC = 34 SO_PEEK_OFF = 42 SO_PEERCRED = 17 SO_PEERGROUPS = 59 SO_PEERNAME = 28 SO_PEERSEC = 31 SO_PRIORITY = 12 SO_PROTOCOL = 38 SO_RCVBUF = 8 SO_RCVBUFFORCE = 33 SO_RCVLOWAT = 18 SO_RCVTIMEO = 20 SO_RCVTIMEO_NEW = 66 SO_RCVTIMEO_OLD = 20 SO_REUSEADDR = 2 SO_REUSEPORT = 15 SO_RXQ_OVFL = 40 SO_SECURITY_AUTHENTICATION = 22 SO_SECURITY_ENCRYPTION_NETWORK = 24 SO_SECURITY_ENCRYPTION_TRANSPORT = 23 SO_SELECT_ERR_QUEUE = 45 SO_SNDBUF = 7 SO_SNDBUFFORCE = 32 SO_SNDLOWAT = 19 SO_SNDTIMEO = 21 SO_SNDTIMEO_NEW = 67 SO_SNDTIMEO_OLD = 21 SO_TIMESTAMP = 29 SO_TIMESTAMPING = 37 SO_TIMESTAMPING_NEW = 65 SO_TIMESTAMPING_OLD = 37 SO_TIMESTAMPNS = 35 SO_TIMESTAMPNS_NEW = 64 SO_TIMESTAMPNS_OLD = 35 SO_TIMESTAMP_NEW = 63 SO_TIMESTAMP_OLD = 29 SO_TXTIME = 61 SO_TYPE = 3 SO_WIFI_STATUS = 41 SO_ZEROCOPY = 60 TRY_AGAIN = 2 X_ATFILE_SOURCE = 1 X_BITS_BYTESWAP_H = 1 X_BITS_ENDIANNESS_H = 1 X_BITS_ENDIAN_H = 1 X_BITS_PTHREADTYPES_ARCH_H = 1 X_BITS_PTHREADTYPES_COMMON_H = 1 X_BITS_SOCKADDR_H = 1 X_BITS_STDINT_INTN_H = 1 X_BITS_STDINT_UINTN_H = 1 X_BITS_TIME64_H = 1 X_BITS_TYPESIZES_H = 1 X_BITS_TYPES_H = 1 X_BITS_UINTN_IDENTITY_H = 1 X_BSD_SIZE_T_ = 0 X_BSD_SIZE_T_DEFINED_ = 0 X_DEFAULT_SOURCE = 1 X_ENDIAN_H = 1 X_FEATURES_H = 1 X_FILE_OFFSET_BITS = 64 X_GCC_SIZE_T = 0 X_LINUX_POSIX_TYPES_H = 0 X_LP64 = 1 X_NETDB_H = 1 X_NETINET_IN_H = 1 X_PATH_HEQUIV = "/etc/hosts.equiv" X_PATH_HOSTS = "/etc/hosts" X_PATH_NETWORKS = "/etc/networks" X_PATH_NSSWITCH_CONF = "/etc/nsswitch.conf" X_PATH_PROTOCOLS = "/etc/protocols" X_PATH_SERVICES = "/etc/services" X_POSIX_C_SOURCE = 200809 X_POSIX_SOURCE = 1 X_RPC_NETDB_H = 1 X_RWLOCK_INTERNAL_H = 0 X_SIZET_ = 0 X_SIZE_T = 0 X_SIZE_T_ = 0 X_SIZE_T_DECLARED = 0 X_SIZE_T_DEFINED = 0 X_SIZE_T_DEFINED_ = 0 X_SS_SIZE = 128 X_STDC_PREDEF_H = 1 X_STRUCT_TIMESPEC = 1 X_SYS_CDEFS_H = 1 X_SYS_SELECT_H = 1 X_SYS_SIZE_T_H = 0 X_SYS_SOCKET_H = 1 X_SYS_TYPES_H = 1 X_THREAD_MUTEX_INTERNAL_H = 1 X_THREAD_SHARED_TYPES_H = 1 X_T_SIZE = 0 X_T_SIZE_ = 0 Linux = 1 Unix = 1 ) // Bits in the FLAGS argument to `send', `recv', et al. const ( /* socket.h:200:1: */ MSG_OOB = 1 // Process out-of-band data. MSG_PEEK = 2 // Peek at incoming messages. MSG_DONTROUTE = 4 // Don't use local routing. MSG_CTRUNC = 8 // Control data lost before delivery. MSG_PROXY = 16 // Supply or ask second address. MSG_TRUNC = 32 MSG_DONTWAIT = 64 // Nonblocking IO. MSG_EOR = 128 // End of record. MSG_WAITALL = 256 // Wait for a full request. MSG_FIN = 512 MSG_SYN = 1024 MSG_CONFIRM = 2048 // Confirm path validity. MSG_RST = 4096 MSG_ERRQUEUE = 8192 // Fetch message from error queue. MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. MSG_MORE = 32768 // Sender will send more. MSG_WAITFORONE = 65536 // Wait for at least one packet to return. MSG_BATCH = 262144 // sendmmsg: more messages coming. MSG_ZEROCOPY = 67108864 // Use user data in kernel path. MSG_FASTOPEN = 536870912 // Send data in TCP SYN. MSG_CMSG_CLOEXEC = 1073741824 ) // Socket level message types. This must match the definitions in // // <linux/socket.h>. const ( /* socket.h:332:1: */ SCM_RIGHTS = 1 ) // Get the architecture-dependent definition of enum __socket_type. // Define enum __socket_type for generic Linux. // Copyright (C) 1991-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // Types of sockets. const ( /* socket_type.h:24:1: */ SOCK_STREAM = 1 // Sequenced, reliable, connection-based // byte streams. SOCK_DGRAM = 2 // Connectionless, unreliable datagrams // of fixed maximum length. SOCK_RAW = 3 // Raw protocol interface. SOCK_RDM = 4 // Reliably-delivered messages. SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, // datagrams of fixed maximum length. SOCK_DCCP = 6 // Datagram Congestion Control Protocol. SOCK_PACKET = 10 // Linux specific way of getting packets // at the dev level. For writing rarp and // other similar things on the user level. // Flags to be ORed into the type parameter of socket and socketpair and // used for the flags parameter of paccept. SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the // new descriptor(s). SOCK_NONBLOCK = 2048 ) // Standard well-known ports. const ( /* in.h:122:1: */ IPPORT_ECHO = 7 // Echo service. IPPORT_DISCARD = 9 // Discard transmissions service. IPPORT_SYSTAT = 11 // System status service. IPPORT_DAYTIME = 13 // Time of day service. IPPORT_NETSTAT = 15 // Network status service. IPPORT_FTP = 21 // File Transfer Protocol. IPPORT_TELNET = 23 // Telnet protocol. IPPORT_SMTP = 25 // Simple Mail Transfer Protocol. IPPORT_TIMESERVER = 37 // Timeserver service. IPPORT_NAMESERVER = 42 // Domain Name Service. IPPORT_WHOIS = 43 // Internet Whois service. IPPORT_MTP = 57 IPPORT_TFTP = 69 // Trivial File Transfer Protocol. IPPORT_RJE = 77 IPPORT_FINGER = 79 // Finger service. IPPORT_TTYLINK = 87 IPPORT_SUPDUP = 95 // SUPDUP protocol. IPPORT_EXECSERVER = 512 // execd service. IPPORT_LOGINSERVER = 513 // rlogind service. IPPORT_CMDSERVER = 514 IPPORT_EFSSERVER = 520 // UDP ports. IPPORT_BIFFUDP = 512 IPPORT_WHOSERVER = 513 IPPORT_ROUTESERVER = 520 // Ports less than this value are reserved for privileged processes. IPPORT_RESERVED = 1024 // Ports greater this value are reserved for (non-privileged) servers. IPPORT_USERRESERVED = 5000 ) // Options for use with `getsockopt' and `setsockopt' at the IPv6 level. // The first word in the comment at the right is the data type used; // "bool" means a boolean value stored in an `int'. // Advanced API (RFC3542) (1). // Advanced API (RFC3542) (2). // RFC5014. // RFC5082. // Obsolete synonyms for the above. // IPV6_MTU_DISCOVER values. // Socket level values for IPv6. // Routing header options for IPv6. // Standard well-defined IP protocols. const ( /* in.h:40:1: */ IPPROTO_IP = 0 // Dummy protocol for TCP. IPPROTO_ICMP = 1 // Internet Control Message Protocol. IPPROTO_IGMP = 2 // Internet Group Management Protocol. IPPROTO_IPIP = 4 // IPIP tunnels (older KA9Q tunnels use 94). IPPROTO_TCP = 6 // Transmission Control Protocol. IPPROTO_EGP = 8 // Exterior Gateway Protocol. IPPROTO_PUP = 12 // PUP protocol. IPPROTO_UDP = 17 // User Datagram Protocol. IPPROTO_IDP = 22 // XNS IDP protocol. IPPROTO_TP = 29 // SO Transport Protocol Class 4. IPPROTO_DCCP = 33 // Datagram Congestion Control Protocol. IPPROTO_IPV6 = 41 // IPv6 header. IPPROTO_RSVP = 46 // Reservation Protocol. IPPROTO_GRE = 47 // General Routing Encapsulation. IPPROTO_ESP = 50 // encapsulating security payload. IPPROTO_AH = 51 // authentication header. IPPROTO_MTP = 92 // Multicast Transport Protocol. IPPROTO_BEETPH = 94 // IP option pseudo header for BEET. IPPROTO_ENCAP = 98 // Encapsulation Header. IPPROTO_PIM = 103 // Protocol Independent Multicast. IPPROTO_COMP = 108 // Compression Header Protocol. IPPROTO_SCTP = 132 // Stream Control Transmission Protocol. IPPROTO_UDPLITE = 136 // UDP-Lite protocol. IPPROTO_MPLS = 137 // MPLS in IP. IPPROTO_RAW = 255 // Raw IP packets. IPPROTO_MAX = 256 ) // If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel // // network headers first and we should use those ABI-identical definitions // instead of our own, otherwise 0. const ( /* in.h:99:1: */ IPPROTO_HOPOPTS = 0 // IPv6 Hop-by-Hop options. IPPROTO_ROUTING = 43 // IPv6 routing header. IPPROTO_FRAGMENT = 44 // IPv6 fragmentation header. IPPROTO_ICMPV6 = 58 // ICMPv6. IPPROTO_NONE = 59 // IPv6 no next header. IPPROTO_DSTOPTS = 60 // IPv6 destination options. IPPROTO_MH = 135 ) // The following constants should be used for the second parameter of // // `shutdown'. const ( /* socket.h:41:1: */ SHUT_RD = 0 // No more receptions. SHUT_WR = 1 // No more transmissions. SHUT_RDWR = 2 ) type Ptrdiff_t = int64 /* <builtin>:3:26 */ type Size_t = uint64 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__int128_t = struct { Flo int64 Fhi int64 } /* <builtin>:21:43 */ // must match modernc.org/mathutil.Int128 type X__uint128_t = struct { Flo uint64 Fhi uint64 } /* <builtin>:22:44 */ // must match modernc.org/mathutil.Int128 type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // Copyright (C) 1996-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // All data returned by the network data base library are supplied in // host order and returned in network order (suitable for use in // system calls). // Copyright (C) 1991-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // These are defined by the user (or the compiler) // to specify the desired environment: // // __STRICT_ANSI__ ISO Standard C. // _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. // _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. // _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. // __STDC_WANT_LIB_EXT2__ // Extensions to ISO C99 from TR 27431-2:2010. // __STDC_WANT_IEC_60559_BFP_EXT__ // Extensions to ISO C11 from TS 18661-1:2014. // __STDC_WANT_IEC_60559_FUNCS_EXT__ // Extensions to ISO C11 from TS 18661-4:2015. // __STDC_WANT_IEC_60559_TYPES_EXT__ // Extensions to ISO C11 from TS 18661-3:2015. // // _POSIX_SOURCE IEEE Std 1003.1. // _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; // if >=199309L, add IEEE Std 1003.1b-1993; // if >=199506L, add IEEE Std 1003.1c-1995; // if >=200112L, all of IEEE 1003.1-2004 // if >=200809L, all of IEEE 1003.1-2008 // _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if // Single Unix conformance is wanted, to 600 for the // sixth revision, to 700 for the seventh revision. // _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. // _LARGEFILE_SOURCE Some more functions for correct standard I/O. // _LARGEFILE64_SOURCE Additional functionality from LFS for large files. // _FILE_OFFSET_BITS=N Select default filesystem interface. // _ATFILE_SOURCE Additional *at interfaces. // _GNU_SOURCE All of the above, plus GNU extensions. // _DEFAULT_SOURCE The default set of features (taking precedence over // __STRICT_ANSI__). // // _FORTIFY_SOURCE Add security hardening to many library functions. // Set to 1 or 2; 2 performs stricter checks than 1. // // _REENTRANT, _THREAD_SAFE // Obsolete; equivalent to _POSIX_C_SOURCE=199506L. // // The `-ansi' switch to the GNU C compiler, and standards conformance // options such as `-std=c99', define __STRICT_ANSI__. If none of // these are defined, or if _DEFAULT_SOURCE is defined, the default is // to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to // 200809L, as well as enabling miscellaneous functions from BSD and // SVID. If more than one of these are defined, they accumulate. For // example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together // give you ISO C, 1003.1, and 1003.2, but nothing else. // // These are defined by this file and are used by the // header files to decide what to declare or define: // // __GLIBC_USE (F) Define things from feature set F. This is defined // to 1 or 0; the subsequent macros are either defined // or undefined, and those tests should be moved to // __GLIBC_USE. // __USE_ISOC11 Define ISO C11 things. // __USE_ISOC99 Define ISO C99 things. // __USE_ISOC95 Define ISO C90 AMD1 (C95) things. // __USE_ISOCXX11 Define ISO C++11 things. // __USE_POSIX Define IEEE Std 1003.1 things. // __USE_POSIX2 Define IEEE Std 1003.2 things. // __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. // __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. // __USE_XOPEN Define XPG things. // __USE_XOPEN_EXTENDED Define X/Open Unix things. // __USE_UNIX98 Define Single Unix V2 things. // __USE_XOPEN2K Define XPG6 things. // __USE_XOPEN2KXSI Define XPG6 XSI things. // __USE_XOPEN2K8 Define XPG7 things. // __USE_XOPEN2K8XSI Define XPG7 XSI things. // __USE_LARGEFILE Define correct standard I/O things. // __USE_LARGEFILE64 Define LFS things with separate names. // __USE_FILE_OFFSET64 Define 64bit interface as default. // __USE_MISC Define things from 4.3BSD or System V Unix. // __USE_ATFILE Define *at interfaces and AT_* constants for them. // __USE_GNU Define GNU extensions. // __USE_FORTIFY_LEVEL Additional security measures used, according to level. // // The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are // defined by this file unconditionally. `__GNU_LIBRARY__' is provided // only for compatibility. All new code should use the other symbols // to test for features. // // All macros listed above as possibly being defined by this file are // explicitly undefined if they are not explicitly defined. // Feature-test macros that are not defined by the user or compiler // but are implied by the other feature-test macros defined (or by the // lack of any definitions) are defined by the file. // // ISO C feature test macros depend on the definition of the macro // when an affected header is included, not when the first system // header is included, and so they are handled in // <bits/libc-header-start.h>, which does not have a multiple include // guard. Feature test macros that can be handled from the first // system header included are handled here. // Undefine everything, so we get a clean slate. // Suppress kernel-name space pollution unless user expressedly asks // for it. // Convenience macro to test the version of gcc. // Use like this: // #if __GNUC_PREREQ (2,8) // ... code requiring gcc 2.8 or later ... // #endif // Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was // added in 2.0. // Similarly for clang. Features added to GCC after version 4.2 may // or may not also be available in clang, and clang's definitions of // __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such // features can be queried via __has_extension/__has_feature. // Whether to use feature set F. // _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for // _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_illumos_amd64.go
vendor/modernc.org/libc/netdb/netdb_illumos_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_illumos_amd64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_802 = 18 // socket.h:296:1: AF_APPLETALK = 16 // socket.h:294:1: AF_CCITT = 10 // socket.h:288:1: AF_CHAOS = 5 // socket.h:283:1: AF_DATAKIT = 9 // socket.h:287:1: AF_DECnet = 12 // socket.h:290:1: AF_DLI = 13 // socket.h:291:1: AF_ECMA = 8 // socket.h:286:1: AF_FILE = 1 // socket.h:279:1: AF_GOSIP = 22 // socket.h:300:1: AF_HYLINK = 15 // socket.h:293:1: AF_IMPLINK = 3 // socket.h:281:1: AF_INET = 2 // socket.h:280:1: AF_INET6 = 26 // socket.h:304:1: AF_INET_OFFLOAD = 30 // socket.h:308:1: AF_IPX = 23 // socket.h:301:1: AF_KEY = 27 // socket.h:305:1: AF_LAT = 14 // socket.h:292:1: AF_LINK = 25 // socket.h:303:1: AF_LOCAL = 1 // socket.h:278:1: AF_LX_NETLINK = 33 // socket.h:311:1: AF_MAX = 33 // socket.h:313:1: AF_NBS = 7 // socket.h:285:1: AF_NCA = 28 // socket.h:306:1: AF_NIT = 17 // socket.h:295:1: AF_NS = 6 // socket.h:284:1: AF_OSI = 19 // socket.h:297:1: AF_OSINET = 21 // socket.h:299:1: AF_PACKET = 32 // socket.h:310:1: AF_POLICY = 29 // socket.h:307:1: AF_PUP = 4 // socket.h:282:1: AF_ROUTE = 24 // socket.h:302:1: AF_SNA = 11 // socket.h:289:1: AF_TRILL = 31 // socket.h:309:1: AF_UNIX = 1 // socket.h:277:1: AF_UNSPEC = 0 // socket.h:276:1: AF_X25 = 20 // socket.h:298:1: AI_ADDRCONFIG = 0x0004 // netdb.h:139:1: AI_ALL = 0x0002 // netdb.h:138:1: AI_CANONNAME = 0x0010 // netdb.h:132:1: AI_DEFAULT = 5 // netdb.h:147:1: AI_NUMERICHOST = 0x0020 // netdb.h:133:1: AI_NUMERICSERV = 0x0040 // netdb.h:134:1: AI_PASSIVE = 0x0008 // netdb.h:131:1: AI_V4MAPPED = 0x0001 // netdb.h:137:1: CANBSIZ = 256 // param.h:91:1: CDLIMIT = 2048 // param.h:164:1: CLOCKS_PER_SEC = 1000000 // time_iso.h:78:1: CLOCK_HIGHRES = 4 // time_impl.h:126:1: CLOCK_MONOTONIC = 4 // time_impl.h:124:1: CLOCK_PROCESS_CPUTIME_ID = 5 // time_impl.h:125:1: CLOCK_PROF = 2 // time_impl.h:127:1: CLOCK_REALTIME = 3 // time_impl.h:123:1: CLOCK_THREAD_CPUTIME_ID = 2 // time_impl.h:122:1: CLOCK_VIRTUAL = 1 // time_impl.h:121:1: CMASK = 022 // param.h:163:1: DEFAULT_JUMPPID = 0 // param.h:120:1: DEFAULT_MAXPID = 30000 // param.h:119:1: DEV_BSHIFT = 9 // param.h:251:1: DEV_BSIZE = 512 // param.h:250:1: DST_AUST = 2 // time.h:115:1: DST_AUSTALT = 10 // time.h:123:1: DST_CAN = 6 // time.h:119:1: DST_EET = 5 // time.h:118:1: DST_GB = 7 // time.h:120:1: DST_MET = 4 // time.h:117:1: DST_NONE = 0 // time.h:113:1: DST_RUM = 8 // time.h:121:1: DST_TUR = 9 // time.h:122:1: DST_USA = 1 // time.h:114:1: DST_WET = 3 // time.h:116:1: EAI_ADDRFAMILY = 1 // netdb.h:150:1: EAI_AGAIN = 2 // netdb.h:153:1: EAI_BADFLAGS = 3 // netdb.h:154:1: EAI_FAIL = 4 // netdb.h:155:1: EAI_FAMILY = 5 // netdb.h:156:1: EAI_MAX = 14 // netdb.h:164:1: EAI_MEMORY = 6 // netdb.h:157:1: EAI_NODATA = 7 // netdb.h:151:1: EAI_NONAME = 8 // netdb.h:158:1: EAI_OVERFLOW = 12 // netdb.h:162:1: EAI_PROTOCOL = 13 // netdb.h:163:1: EAI_SERVICE = 9 // netdb.h:159:1: EAI_SOCKTYPE = 10 // netdb.h:160:1: EAI_SYSTEM = 11 // netdb.h:161:1: FD_SETSIZE = 65536 // select.h:88:1: FILF_AUTO = 0x2 // socket.h:232:1: FILF_BYPASS = 0x4 // socket.h:233:1: FILF_PROG = 0x1 // socket.h:231:1: FILNAME_MAX = 32 // socket.h:221:1: FIL_ATTACH = 0x1 // socket.h:217:1: FIL_DETACH = 0x2 // socket.h:218:1: FIL_LIST = 0x3 // socket.h:219:1: FSCALE = 256 // param.h:304:1: FSHIFT = 8 // param.h:303:1: GID_NETADM = 65 // param.h:100:1: GID_NOBODY = 60001 // param.h:95:1: GID_UNKNOWN = 96 // param.h:97:1: HOST_NOT_FOUND = 1 // netdb.h:381:1: IMPLINK_HIGHEXPER = 158 // in.h:284:1: IMPLINK_IP = 155 // in.h:282:1: IMPLINK_LOWEXPER = 156 // in.h:283:1: INADDR_6TO4RRANYCAST = 0xc0586301 // in.h:392:1: INADDR_ALLHOSTS_GROUP = 0xe0000001 // in.h:372:1: INADDR_ALLRPTS_GROUP = 0xe0000016 // in.h:374:1: INADDR_ALLRTRS_GROUP = 0xe0000002 // in.h:373:1: INADDR_ANY = 0x00000000 // in.h:366:1: INADDR_BROADCAST = 0xffffffff // in.h:368:1: INADDR_LOOPBACK = 0x7F000001 // in.h:367:1: INADDR_MAX_LOCAL_GROUP = 0xe00000ff // in.h:375:1: INADDR_NONE = 0xffffffff // in.h:369:1: INADDR_UNSPEC_GROUP = 0xe0000000 // in.h:371:1: INET6_ADDRSTRLEN = 46 // in.h:1212:1: INET_ADDRSTRLEN = 16 // in.h:1210:1: IN_AUTOCONF_MASK = 0xffff0000 // in.h:379:1: IN_AUTOCONF_NET = 0xa9fe0000 // in.h:378:1: IN_CLASSA_HOST = 0x00ffffff // in.h:332:1: IN_CLASSA_MAX = 128 // in.h:333:1: IN_CLASSA_NET = 0xff000000 // in.h:330:1: IN_CLASSA_NSHIFT = 24 // in.h:331:1: IN_CLASSB_HOST = 0x0000ffff // in.h:338:1: IN_CLASSB_MAX = 65536 // in.h:339:1: IN_CLASSB_NET = 0xffff0000 // in.h:336:1: IN_CLASSB_NSHIFT = 16 // in.h:337:1: IN_CLASSC_HOST = 0x000000ff // in.h:344:1: IN_CLASSC_NET = 0xffffff00 // in.h:342:1: IN_CLASSC_NSHIFT = 8 // in.h:343:1: IN_CLASSD_HOST = 0x0fffffff // in.h:349:1: IN_CLASSD_NET = 0xf0000000 // in.h:347:1: IN_CLASSD_NSHIFT = 28 // in.h:348:1: IN_CLASSE_NET = 0xffffffff // in.h:352:1: IN_LOOPBACKNET = 127 // in.h:395:1: IN_PRIVATE12_MASK = 0xfff00000 // in.h:383:1: IN_PRIVATE12_NET = 0xac100000 // in.h:382:1: IN_PRIVATE16_MASK = 0xffff0000 // in.h:385:1: IN_PRIVATE16_NET = 0xc0a80000 // in.h:384:1: IN_PRIVATE8_MASK = 0xff000000 // in.h:381:1: IN_PRIVATE8_NET = 0x0a000000 // in.h:380:1: IPPORT_BIFFUDP = 512 // in.h:250:1: IPPORT_BOOTPC = 68 // in.h:214:1: IPPORT_BOOTPS = 67 // in.h:213:1: IPPORT_CHARGEN = 19 // in.h:199:1: IPPORT_CMDSERVER = 514 // in.h:243:1: IPPORT_DAYTIME = 13 // in.h:197:1: IPPORT_DHCPV6C = 546 // in.h:260:1: IPPORT_DHCPV6S = 547 // in.h:261:1: IPPORT_DISCARD = 9 // in.h:195:1: IPPORT_DOMAIN = 53 // in.h:206:1: IPPORT_ECHO = 7 // in.h:194:1: IPPORT_EFSSERVER = 520 // in.h:245:1: IPPORT_EXECSERVER = 512 // in.h:241:1: IPPORT_FINGER = 79 // in.h:217:1: IPPORT_FTP = 21 // in.h:200:1: IPPORT_HTTP = 80 // in.h:218:1: IPPORT_HTTP_ALT = 8080 // in.h:219:1: IPPORT_IKE = 500 // in.h:235:1: IPPORT_IKE_NATT = 4500 // in.h:236:1: IPPORT_LDAP = 389 // in.h:226:1: IPPORT_LOGINSERVER = 513 // in.h:242:1: IPPORT_MDNS = 5353 // in.h:207:1: IPPORT_MIP = 434 // in.h:228:1: IPPORT_MTP = 57 // in.h:208:1: IPPORT_NAMESERVER = 42 // in.h:204:1: IPPORT_NETBIOS_DGM = 138 // in.h:224:1: IPPORT_NETBIOS_NS = 137 // in.h:223:1: IPPORT_NETBIOS_SSN = 139 // in.h:225:1: IPPORT_NETSTAT = 15 // in.h:198:1: IPPORT_NTP = 123 // in.h:222:1: IPPORT_PRINTER = 515 // in.h:244:1: IPPORT_RESERVED = 1024 // in.h:271:1: IPPORT_RIPNG = 521 // in.h:255:1: IPPORT_RJE = 77 // in.h:216:1: IPPORT_ROUTESERVER = 520 // in.h:254:1: IPPORT_SLP = 427 // in.h:227:1: IPPORT_SMB = 445 // in.h:229:1: IPPORT_SMTP = 25 // in.h:202:1: IPPORT_SOCKS = 1080 // in.h:263:1: IPPORT_SUPDUP = 95 // in.h:221:1: IPPORT_SYSLOG = 514 // in.h:252:1: IPPORT_SYSTAT = 11 // in.h:196:1: IPPORT_TALK = 517 // in.h:253:1: IPPORT_TELNET = 23 // in.h:201:1: IPPORT_TFTP = 69 // in.h:215:1: IPPORT_TIMESERVER = 37 // in.h:203:1: IPPORT_TTYLINK = 87 // in.h:220:1: IPPORT_USERRESERVED = 5000 // in.h:272:1: IPPORT_VXLAN = 4789 // in.h:230:1: IPPORT_WHOIS = 43 // in.h:205:1: IPPORT_WHOSERVER = 513 // in.h:251:1: IPPROTO_AH = 51 // in.h:169:1: IPPROTO_DSTOPTS = 60 // in.h:172:1: IPPROTO_EGP = 8 // in.h:160:1: IPPROTO_ENCAP = 4 // in.h:158:1: IPPROTO_EON = 80 // in.h:175:1: IPPROTO_ESP = 50 // in.h:168:1: IPPROTO_FRAGMENT = 44 // in.h:166:1: IPPROTO_GGP = 3 // in.h:157:1: IPPROTO_HELLO = 63 // in.h:173:1: IPPROTO_HOPOPTS = 0 // in.h:154:1: IPPROTO_ICMP = 1 // in.h:155:1: IPPROTO_ICMPV6 = 58 // in.h:170:1: IPPROTO_IDP = 22 // in.h:163:1: IPPROTO_IGMP = 2 // in.h:156:1: IPPROTO_IP = 0 // in.h:153:1: IPPROTO_IPV6 = 41 // in.h:164:1: IPPROTO_MAX = 256 // in.h:182:1: IPPROTO_ND = 77 // in.h:174:1: IPPROTO_NONE = 59 // in.h:171:1: IPPROTO_OSPF = 89 // in.h:176:1: IPPROTO_PIM = 103 // in.h:177:1: IPPROTO_PUP = 12 // in.h:161:1: IPPROTO_RAW = 255 // in.h:181:1: IPPROTO_ROUTING = 43 // in.h:165:1: IPPROTO_RSVP = 46 // in.h:167:1: IPPROTO_SCTP = 132 // in.h:178:1: IPPROTO_TCP = 6 // in.h:159:1: IPPROTO_UDP = 17 // in.h:162:1: IPSEC_PREF_NEVER = 0x01 // in.h:941:1: IPSEC_PREF_REQUIRED = 0x02 // in.h:942:1: IPSEC_PREF_UNIQUE = 0x04 // in.h:943:1: IPSEC_PROTO_AH = 2 // netdb.h:209:1: IPSEC_PROTO_ESP = 3 // netdb.h:210:1: IPV6_ADD_MEMBERSHIP = 0x9 // in.h:1224:1: IPV6_BOUND_IF = 0x41 // in.h:1307:1: IPV6_CHECKSUM = 0x18 // in.h:1257:1: IPV6_DONTFRAG = 0x21 // in.h:1260:1: IPV6_DROP_MEMBERSHIP = 0xa // in.h:1226:1: IPV6_DSTOPTS = 0xf // in.h:1234:1: IPV6_FLOWINFO_FLOWLABEL = 0xffff0f00 // in.h:447:1: IPV6_FLOWINFO_TCLASS = 0x0000f00f // in.h:448:1: IPV6_HOPLIMIT = 0xc // in.h:1231:1: IPV6_HOPOPTS = 0xe // in.h:1233:1: IPV6_JOIN_GROUP = 0x9 // in.h:1202:1: IPV6_LEAVE_GROUP = 0xa // in.h:1204:1: IPV6_MULTICAST_HOPS = 0x7 // in.h:1196:1: IPV6_MULTICAST_IF = 0x6 // in.h:1193:1: IPV6_MULTICAST_LOOP = 0x8 // in.h:1199:1: IPV6_NEXTHOP = 0xd // in.h:1232:1: IPV6_PAD1_OPT = 0 // in.h:1314:1: IPV6_PATHMTU = 0x25 // in.h:1264:1: IPV6_PKTINFO = 0xb // in.h:1229:1: IPV6_PREFER_SRC_CGA = 0x00000020 // in.h:1289:1: IPV6_PREFER_SRC_CGADEFAULT = 16 // in.h:1296:1: IPV6_PREFER_SRC_CGAMASK = 48 // in.h:1295:1: IPV6_PREFER_SRC_COA = 0x00000002 // in.h:1285:1: IPV6_PREFER_SRC_DEFAULT = 21 // in.h:1301:1: IPV6_PREFER_SRC_HOME = 0x00000001 // in.h:1284:1: IPV6_PREFER_SRC_MASK = 63 // in.h:1298:1: IPV6_PREFER_SRC_MIPDEFAULT = 1 // in.h:1292:1: IPV6_PREFER_SRC_MIPMASK = 3 // in.h:1291:1: IPV6_PREFER_SRC_NONCGA = 0x00000010 // in.h:1288:1: IPV6_PREFER_SRC_PUBLIC = 0x00000004 // in.h:1286:1: IPV6_PREFER_SRC_TMP = 0x00000008 // in.h:1287:1: IPV6_PREFER_SRC_TMPDEFAULT = 4 // in.h:1294:1: IPV6_PREFER_SRC_TMPMASK = 12 // in.h:1293:1: IPV6_RECVDSTOPTS = 0x28 // in.h:1271:1: IPV6_RECVHOPLIMIT = 0x13 // in.h:1240:1: IPV6_RECVHOPOPTS = 0x14 // in.h:1241:1: IPV6_RECVPATHMTU = 0x24 // in.h:1263:1: IPV6_RECVPKTINFO = 0x12 // in.h:1239:1: IPV6_RECVRTHDR = 0x16 // in.h:1249:1: IPV6_RECVRTHDRDSTOPTS = 0x17 // in.h:1255:1: IPV6_RECVTCLASS = 0x19 // in.h:1258:1: IPV6_RTHDR = 0x10 // in.h:1236:1: IPV6_RTHDRDSTOPTS = 0x11 // in.h:1237:1: IPV6_RTHDR_TYPE_0 = 0 // in.h:1152:1: IPV6_SEC_OPT = 0x22 // in.h:1261:1: IPV6_SRC_PREFERENCES = 0x23 // in.h:1262:1: IPV6_TCLASS = 0x26 // in.h:1265:1: IPV6_UNICAST_HOPS = 0x5 // in.h:1190:1: IPV6_UNSPEC_SRC = 0x42 // in.h:1308:1: IPV6_USE_MIN_MTU = 0x20 // in.h:1259:1: IPV6_V6ONLY = 0x27 // in.h:1266:1: IP_ADD_MEMBERSHIP = 0x13 // in.h:921:1: IP_ADD_SOURCE_MEMBERSHIP = 0x17 // in.h:925:1: IP_BLOCK_SOURCE = 0x15 // in.h:923:1: IP_BOUND_IF = 0x41 // in.h:976:1: IP_BROADCAST = 0x106 // in.h:994:1: IP_BROADCAST_TTL = 0x43 // in.h:978:1: IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:1009:1: IP_DEFAULT_MULTICAST_TTL = 1 // in.h:1008:1: IP_DHCPINIT_IF = 0x45 // in.h:980:1: IP_DONTFRAG = 0x1b // in.h:934:1: IP_DONTROUTE = 0x105 // in.h:990:1: IP_DROP_MEMBERSHIP = 0x14 // in.h:922:1: IP_DROP_SOURCE_MEMBERSHIP = 0x18 // in.h:926:1: IP_HDRINCL = 2 // in.h:899:1: IP_MULTICAST_IF = 0x10 // in.h:918:1: IP_MULTICAST_LOOP = 0x12 // in.h:920:1: IP_MULTICAST_TTL = 0x11 // in.h:919:1: IP_NEXTHOP = 0x19 // in.h:927:1: IP_OPTIONS = 1 // in.h:896:1: IP_PKTINFO = 0x1a // in.h:932:1: IP_RECVDSTADDR = 0x7 // in.h:911:1: IP_RECVIF = 0x9 // in.h:913:1: IP_RECVOPTS = 0x5 // in.h:909:1: IP_RECVPKTINFO = 0x1a // in.h:933:1: IP_RECVRETOPTS = 0x6 // in.h:910:1: IP_RECVSLLA = 0xa // in.h:914:1: IP_RECVTOS = 0xc // in.h:916:1: IP_RECVTTL = 0xb // in.h:915:1: IP_RETOPTS = 0x8 // in.h:912:1: IP_REUSEADDR = 0x104 // in.h:986:1: IP_SEC_OPT = 0x22 // in.h:940:1: IP_TOS = 3 // in.h:902:1: IP_TTL = 4 // in.h:906:1: IP_UNBLOCK_SOURCE = 0x16 // in.h:924:1: IP_UNSPEC_SRC = 0x42 // in.h:977:1: ITIMER_PROF = 2 // time.h:201:1: ITIMER_REAL = 0 // time.h:199:1: ITIMER_REALPROF = 3 // time.h:204:1: ITIMER_VIRTUAL = 1 // time.h:200:1: LINUX_SLL_BROADCAST = 1 // socket_impl.h:122:1: LINUX_SLL_HOST = 0 // socket_impl.h:121:1: LINUX_SLL_MULTICAST = 2 // socket_impl.h:123:1: LINUX_SLL_OTHERHOST = 3 // socket_impl.h:124:1: LINUX_SLL_OUTGOING = 4 // socket_impl.h:125:1: MAXADDRS = 35 // netdb.h:397:1: MAXALIASES = 35 // netdb.h:396:1: MAXBSIZE = 8192 // param.h:249:1: MAXFRAG = 8 // param.h:252:1: MAXHOSTNAMELEN = 256 // netdb.h:394:1: MAXLINK = 32767 // param.h:126:1: MAXLINKNAMELEN = 32 // param.h:209:1: MAXNAMELEN = 256 // param.h:202:1: MAXOFFSET_T = 0x7fffffffffffffff // param.h:258:1: MAXOFF_T = 0x7fffffffffffffff // param.h:257:1: MAXPATHLEN = 1024 // param.h:199:1: MAXPROJID = 2147483647 // param.h:125:1: MAXSYMLINKS = 20 // param.h:201:1: MAXUID = 2147483647 // param.h:123:1: MAX_CANON = 256 // param.h:89:1: MAX_INPUT = 512 // param.h:86:1: MCAST_BLOCK_SOURCE = 0x2b // in.h:1278:1: MCAST_EXCLUDE = 2 // in.h:1122:1: MCAST_INCLUDE = 1 // in.h:1121:1: MCAST_JOIN_GROUP = 0x29 // in.h:1276:1: MCAST_JOIN_SOURCE_GROUP = 0x2d // in.h:1280:1: MCAST_LEAVE_GROUP = 0x2a // in.h:1277:1: MCAST_LEAVE_SOURCE_GROUP = 0x2e // in.h:1281:1: MCAST_UNBLOCK_SOURCE = 0x2c // in.h:1279:1: MICROSEC = 1000000 // time.h:246:1: MILLISEC = 1000 // time.h:245:1: MINEPHUID = 0x80000000 // param.h:128:1: MSG_CTRUNC = 0x10 // socket.h:429:1: MSG_DONTROUTE = 0x4 // socket.h:427:1: MSG_DONTWAIT = 0x80 // socket.h:432:1: MSG_DUPCTRL = 0x800 // socket.h:435:1: MSG_EOR = 0x8 // socket.h:428:1: MSG_MAXIOVLEN = 16 // socket.h:440:1: MSG_NOSIGNAL = 0x200 // socket.h:434:1: MSG_NOTIFICATION = 0x100 // socket.h:433:1: MSG_OOB = 0x1 // socket.h:425:1: MSG_PEEK = 0x2 // socket.h:426:1: MSG_TRUNC = 0x20 // socket.h:430:1: MSG_WAITALL = 0x40 // socket.h:431:1: MSG_XPG4_2 = 0x8000 // socket.h:437:1: NADDR = 13 // param.h:212:1: NANOSEC = 1000000000 // time.h:247:1: NBBY = 8 // select.h:103:1: NBPS = 0x20000 // param.h:165:1: NBPSCTR = 512 // param.h:166:1: NCARGS = 2097152 // param.h:294:1: NCARGS32 = 0x100000 // param.h:291:1: NCARGS64 = 0x200000 // param.h:292:1: NC_APPLETALK = "appletalk" // netconfig.h:108:1: NC_BROADCAST = 02 // netconfig.h:85:1: NC_CCITT = "ccitt" // netconfig.h:102:1: NC_CHAOS = "chaos" // netconfig.h:97:1: NC_DATAKIT = "datakit" // netconfig.h:101:1: NC_DECNET = "decnet" // netconfig.h:104:1: NC_DLI = "dli" // netconfig.h:105:1: NC_ECMA = "ecma" // netconfig.h:100:1: NC_GOSIP = "gosip" // netconfig.h:114:1: NC_HYLINK = "hylink" // netconfig.h:107:1: NC_IBTF = "ibtf" // netconfig.h:138:1: NC_ICMP = "icmp" // netconfig.h:132:1: NC_IEEE802 = "ieee802" // netconfig.h:110:1: NC_IMPLINK = "implink" // netconfig.h:95:1: NC_INET = "inet" // netconfig.h:93:1: NC_INET6 = "inet6" // netconfig.h:94:1: NC_KDAPL = "kdapl" // netconfig.h:139:1: NC_KVIPL = "kvipl" // netconfig.h:137:1: NC_LAT = "lat" // netconfig.h:106:1: NC_LOOPBACK = "loopback" // netconfig.h:92:1: NC_NBS = "nbs" // netconfig.h:99:1: NC_NIT = "nit" // netconfig.h:109:1: NC_NOFLAG = 00 // netconfig.h:83:1: NC_NOPROTO = "-" // netconfig.h:129:1: NC_NOPROTOFMLY = "-" // netconfig.h:91:1: NC_NS = "ns" // netconfig.h:98:1: NC_OSI = "osi" // netconfig.h:111:1: NC_OSINET = "osinet" // netconfig.h:113:1: NC_PUP = "pup" // netconfig.h:96:1: NC_RDMA = "rdma" // netconfig.h:123:1: NC_SNA = "sna" // netconfig.h:103:1: NC_TCP = "tcp" // netconfig.h:130:1: NC_TPI_CLTS = 1 // netconfig.h:65:1: NC_TPI_COTS = 2 // netconfig.h:66:1: NC_TPI_COTS_ORD = 3 // netconfig.h:67:1: NC_TPI_RAW = 4 // netconfig.h:68:1: NC_TPI_RDMA = 5 // netconfig.h:77:1: NC_UDP = "udp" // netconfig.h:131:1: NC_VISIBLE = 01 // netconfig.h:84:1: NC_X25 = "x25" // netconfig.h:112:1: NETCONFIG = "/etc/netconfig" // netconfig.h:41:1: NETDB_INTERNAL = -1 // netdb.h:390:1: NETDB_SUCCESS = 0 // netdb.h:391:1:
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_linux_riscv64.go
vendor/modernc.org/libc/netdb/netdb_linux_riscv64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_riscv64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_ALG = 38 AF_APPLETALK = 5 AF_ASH = 18 AF_ATMPVC = 8 AF_ATMSVC = 20 AF_AX25 = 3 AF_BLUETOOTH = 31 AF_BRIDGE = 7 AF_CAIF = 37 AF_CAN = 29 AF_DECnet = 12 AF_ECONET = 19 AF_FILE = 1 AF_IB = 27 AF_IEEE802154 = 36 AF_INET = 2 AF_INET6 = 10 AF_IPX = 4 AF_IRDA = 23 AF_ISDN = 34 AF_IUCV = 32 AF_KCM = 41 AF_KEY = 15 AF_LLC = 26 AF_LOCAL = 1 AF_MAX = 45 AF_MPLS = 28 AF_NETBEUI = 13 AF_NETLINK = 16 AF_NETROM = 6 AF_NFC = 39 AF_PACKET = 17 AF_PHONET = 35 AF_PPPOX = 24 AF_QIPCRTR = 42 AF_RDS = 21 AF_ROSE = 11 AF_ROUTE = 16 AF_RXRPC = 33 AF_SECURITY = 14 AF_SMC = 43 AF_SNA = 22 AF_TIPC = 30 AF_UNIX = 1 AF_UNSPEC = 0 AF_VSOCK = 40 AF_WANPIPE = 25 AF_X25 = 9 AF_XDP = 44 AI_ADDRCONFIG = 0x0020 AI_ALL = 0x0010 AI_CANONNAME = 0x0002 AI_NUMERICHOST = 0x0004 AI_NUMERICSERV = 0x0400 AI_PASSIVE = 0x0001 AI_V4MAPPED = 0x0008 BIG_ENDIAN = 4321 BYTE_ORDER = 1234 EAI_AGAIN = -3 EAI_BADFLAGS = -1 EAI_FAIL = -4 EAI_FAMILY = -6 EAI_MEMORY = -10 EAI_NONAME = -2 EAI_OVERFLOW = -12 EAI_SERVICE = -8 EAI_SOCKTYPE = -7 EAI_SYSTEM = -11 FD_SETSIZE = 1024 FIOGETOWN = 0x8903 FIOSETOWN = 0x8901 HOST_NOT_FOUND = 1 INET6_ADDRSTRLEN = 46 INET_ADDRSTRLEN = 16 IN_CLASSA_HOST = 16777215 IN_CLASSA_MAX = 128 IN_CLASSA_NET = 0xff000000 IN_CLASSA_NSHIFT = 24 IN_CLASSB_HOST = 65535 IN_CLASSB_MAX = 65536 IN_CLASSB_NET = 0xffff0000 IN_CLASSB_NSHIFT = 16 IN_CLASSC_HOST = 255 IN_CLASSC_NET = 0xffffff00 IN_CLASSC_NSHIFT = 8 IN_LOOPBACKNET = 127 IPPORT_RESERVED1 = 1024 IPV6_2292DSTOPTS = 4 IPV6_2292HOPLIMIT = 8 IPV6_2292HOPOPTS = 3 IPV6_2292PKTINFO = 2 IPV6_2292PKTOPTIONS = 6 IPV6_2292RTHDR = 5 IPV6_ADDRFORM = 1 IPV6_ADDR_PREFERENCES = 72 IPV6_ADD_MEMBERSHIP = 20 IPV6_AUTHHDR = 10 IPV6_AUTOFLOWLABEL = 70 IPV6_CHECKSUM = 7 IPV6_DONTFRAG = 62 IPV6_DROP_MEMBERSHIP = 21 IPV6_DSTOPTS = 59 IPV6_FREEBIND = 78 IPV6_HDRINCL = 36 IPV6_HOPLIMIT = 52 IPV6_HOPOPTS = 54 IPV6_IPSEC_POLICY = 34 IPV6_JOIN_ANYCAST = 27 IPV6_JOIN_GROUP = 20 IPV6_LEAVE_ANYCAST = 28 IPV6_LEAVE_GROUP = 21 IPV6_MINHOPCOUNT = 73 IPV6_MTU = 24 IPV6_MTU_DISCOVER = 23 IPV6_MULTICAST_ALL = 29 IPV6_MULTICAST_HOPS = 18 IPV6_MULTICAST_IF = 17 IPV6_MULTICAST_LOOP = 19 IPV6_NEXTHOP = 9 IPV6_ORIGDSTADDR = 74 IPV6_PATHMTU = 61 IPV6_PKTINFO = 50 IPV6_PMTUDISC_DO = 2 IPV6_PMTUDISC_DONT = 0 IPV6_PMTUDISC_INTERFACE = 4 IPV6_PMTUDISC_OMIT = 5 IPV6_PMTUDISC_PROBE = 3 IPV6_PMTUDISC_WANT = 1 IPV6_RECVDSTOPTS = 58 IPV6_RECVERR = 25 IPV6_RECVERR_RFC4884 = 31 IPV6_RECVFRAGSIZE = 77 IPV6_RECVHOPLIMIT = 51 IPV6_RECVHOPOPTS = 53 IPV6_RECVORIGDSTADDR = 74 IPV6_RECVPATHMTU = 60 IPV6_RECVPKTINFO = 49 IPV6_RECVRTHDR = 56 IPV6_RECVTCLASS = 66 IPV6_ROUTER_ALERT = 22 IPV6_ROUTER_ALERT_ISOLATE = 30 IPV6_RTHDR = 57 IPV6_RTHDRDSTOPTS = 55 IPV6_RTHDR_LOOSE = 0 IPV6_RTHDR_STRICT = 1 IPV6_RTHDR_TYPE_0 = 0 IPV6_RXDSTOPTS = 59 IPV6_RXHOPOPTS = 54 IPV6_TCLASS = 67 IPV6_TRANSPARENT = 75 IPV6_UNICAST_HOPS = 16 IPV6_UNICAST_IF = 76 IPV6_V6ONLY = 26 IPV6_XFRM_POLICY = 35 IP_ADD_MEMBERSHIP = 35 IP_ADD_SOURCE_MEMBERSHIP = 39 IP_BIND_ADDRESS_NO_PORT = 24 IP_BLOCK_SOURCE = 38 IP_CHECKSUM = 23 IP_DEFAULT_MULTICAST_LOOP = 1 IP_DEFAULT_MULTICAST_TTL = 1 IP_DROP_MEMBERSHIP = 36 IP_DROP_SOURCE_MEMBERSHIP = 40 IP_FREEBIND = 15 IP_HDRINCL = 3 IP_IPSEC_POLICY = 16 IP_MAX_MEMBERSHIPS = 20 IP_MINTTL = 21 IP_MSFILTER = 41 IP_MTU = 14 IP_MTU_DISCOVER = 10 IP_MULTICAST_ALL = 49 IP_MULTICAST_IF = 32 IP_MULTICAST_LOOP = 34 IP_MULTICAST_TTL = 33 IP_NODEFRAG = 22 IP_OPTIONS = 4 IP_ORIGDSTADDR = 20 IP_PASSSEC = 18 IP_PKTINFO = 8 IP_PKTOPTIONS = 9 IP_PMTUDISC = 10 IP_PMTUDISC_DO = 2 IP_PMTUDISC_DONT = 0 IP_PMTUDISC_INTERFACE = 4 IP_PMTUDISC_OMIT = 5 IP_PMTUDISC_PROBE = 3 IP_PMTUDISC_WANT = 1 IP_RECVERR = 11 IP_RECVERR_RFC4884 = 26 IP_RECVFRAGSIZE = 25 IP_RECVOPTS = 6 IP_RECVORIGDSTADDR = 20 IP_RECVRETOPTS = 7 IP_RECVTOS = 13 IP_RECVTTL = 12 IP_RETOPTS = 7 IP_ROUTER_ALERT = 5 IP_TOS = 1 IP_TRANSPARENT = 19 IP_TTL = 2 IP_UNBLOCK_SOURCE = 37 IP_UNICAST_IF = 50 IP_XFRM_POLICY = 17 LITTLE_ENDIAN = 1234 MCAST_BLOCK_SOURCE = 43 MCAST_EXCLUDE = 0 MCAST_INCLUDE = 1 MCAST_JOIN_GROUP = 42 MCAST_JOIN_SOURCE_GROUP = 46 MCAST_LEAVE_GROUP = 45 MCAST_LEAVE_SOURCE_GROUP = 47 MCAST_MSFILTER = 48 MCAST_UNBLOCK_SOURCE = 44 NETDB_INTERNAL = -1 NETDB_SUCCESS = 0 NI_DGRAM = 16 NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 8 NI_NOFQDN = 4 NI_NUMERICHOST = 1 NI_NUMERICSERV = 2 NO_ADDRESS = 4 NO_DATA = 4 NO_RECOVERY = 3 PDP_ENDIAN = 3412 PF_ALG = 38 PF_APPLETALK = 5 PF_ASH = 18 PF_ATMPVC = 8 PF_ATMSVC = 20 PF_AX25 = 3 PF_BLUETOOTH = 31 PF_BRIDGE = 7 PF_CAIF = 37 PF_CAN = 29 PF_DECnet = 12 PF_ECONET = 19 PF_FILE = 1 PF_IB = 27 PF_IEEE802154 = 36 PF_INET = 2 PF_INET6 = 10 PF_IPX = 4 PF_IRDA = 23 PF_ISDN = 34 PF_IUCV = 32 PF_KCM = 41 PF_KEY = 15 PF_LLC = 26 PF_LOCAL = 1 PF_MAX = 45 PF_MPLS = 28 PF_NETBEUI = 13 PF_NETLINK = 16 PF_NETROM = 6 PF_NFC = 39 PF_PACKET = 17 PF_PHONET = 35 PF_PPPOX = 24 PF_QIPCRTR = 42 PF_RDS = 21 PF_ROSE = 11 PF_ROUTE = 16 PF_RXRPC = 33 PF_SECURITY = 14 PF_SMC = 43 PF_SNA = 22 PF_TIPC = 30 PF_UNIX = 1 PF_UNSPEC = 0 PF_VSOCK = 40 PF_WANPIPE = 25 PF_X25 = 9 PF_XDP = 44 SCM_TIMESTAMP = 29 SCM_TIMESTAMPING = 37 SCM_TIMESTAMPING_OPT_STATS = 54 SCM_TIMESTAMPING_PKTINFO = 58 SCM_TIMESTAMPNS = 35 SCM_TXTIME = 61 SCM_WIFI_STATUS = 41 SIOCATMARK = 0x8905 SIOCGPGRP = 0x8904 SIOCGSTAMPNS_OLD = 0x8907 SIOCGSTAMP_OLD = 0x8906 SIOCSPGRP = 0x8902 SOL_AAL = 265 SOL_ALG = 279 SOL_ATM = 264 SOL_BLUETOOTH = 274 SOL_CAIF = 278 SOL_DCCP = 269 SOL_DECNET = 261 SOL_ICMPV6 = 58 SOL_IP = 0 SOL_IPV6 = 41 SOL_IRDA = 266 SOL_IUCV = 277 SOL_KCM = 281 SOL_LLC = 268 SOL_NETBEUI = 267 SOL_NETLINK = 270 SOL_NFC = 280 SOL_PACKET = 263 SOL_PNPIPE = 275 SOL_PPPOL2TP = 273 SOL_RAW = 255 SOL_RDS = 276 SOL_RXRPC = 272 SOL_SOCKET = 1 SOL_TIPC = 271 SOL_TLS = 282 SOL_X25 = 262 SOL_XDP = 283 SOMAXCONN = 4096 SO_ACCEPTCONN = 30 SO_ATTACH_BPF = 50 SO_ATTACH_FILTER = 26 SO_ATTACH_REUSEPORT_CBPF = 51 SO_ATTACH_REUSEPORT_EBPF = 52 SO_BINDTODEVICE = 25 SO_BINDTOIFINDEX = 62 SO_BPF_EXTENSIONS = 48 SO_BROADCAST = 6 SO_BSDCOMPAT = 14 SO_BUSY_POLL = 46 SO_BUSY_POLL_BUDGET = 70 SO_CNX_ADVICE = 53 SO_COOKIE = 57 SO_DEBUG = 1 SO_DETACH_BPF = 27 SO_DETACH_FILTER = 27 SO_DETACH_REUSEPORT_BPF = 68 SO_DOMAIN = 39 SO_DONTROUTE = 5 SO_ERROR = 4 SO_GET_FILTER = 26 SO_INCOMING_CPU = 49 SO_INCOMING_NAPI_ID = 56 SO_KEEPALIVE = 9 SO_LINGER = 13 SO_LOCK_FILTER = 44 SO_MARK = 36 SO_MAX_PACING_RATE = 47 SO_MEMINFO = 55 SO_NETNS_COOKIE = 71 SO_NOFCS = 43 SO_NO_CHECK = 11 SO_OOBINLINE = 10 SO_PASSCRED = 16 SO_PASSSEC = 34 SO_PEEK_OFF = 42 SO_PEERCRED = 17 SO_PEERGROUPS = 59 SO_PEERNAME = 28 SO_PEERSEC = 31 SO_PREFER_BUSY_POLL = 69 SO_PRIORITY = 12 SO_PROTOCOL = 38 SO_RCVBUF = 8 SO_RCVBUFFORCE = 33 SO_RCVLOWAT = 18 SO_RCVTIMEO = 20 SO_RCVTIMEO_NEW = 66 SO_RCVTIMEO_OLD = 20 SO_REUSEADDR = 2 SO_REUSEPORT = 15 SO_RXQ_OVFL = 40 SO_SECURITY_AUTHENTICATION = 22 SO_SECURITY_ENCRYPTION_NETWORK = 24 SO_SECURITY_ENCRYPTION_TRANSPORT = 23 SO_SELECT_ERR_QUEUE = 45 SO_SNDBUF = 7 SO_SNDBUFFORCE = 32 SO_SNDLOWAT = 19 SO_SNDTIMEO = 21 SO_SNDTIMEO_NEW = 67 SO_SNDTIMEO_OLD = 21 SO_TIMESTAMP = 29 SO_TIMESTAMPING = 37 SO_TIMESTAMPING_NEW = 65 SO_TIMESTAMPING_OLD = 37 SO_TIMESTAMPNS = 35 SO_TIMESTAMPNS_NEW = 64 SO_TIMESTAMPNS_OLD = 35 SO_TIMESTAMP_NEW = 63 SO_TIMESTAMP_OLD = 29 SO_TXTIME = 61 SO_TYPE = 3 SO_WIFI_STATUS = 41 SO_ZEROCOPY = 60 TRY_AGAIN = 2 X_ASM_RISCV_BITSPERLONG_H = 0 X_ATFILE_SOURCE = 1 X_BITS_BYTESWAP_H = 1 X_BITS_ENDIANNESS_H = 1 X_BITS_ENDIAN_H = 1 X_BITS_PTHREADTYPES_ARCH_H = 1 X_BITS_PTHREADTYPES_COMMON_H = 1 X_BITS_SOCKADDR_H = 1 X_BITS_STDINT_INTN_H = 1 X_BITS_STDINT_UINTN_H = 1 X_BITS_TIME64_H = 1 X_BITS_TYPESIZES_H = 1 X_BITS_TYPES_H = 1 X_BITS_UINTN_IDENTITY_H = 1 X_BSD_SIZE_T_ = 0 X_BSD_SIZE_T_DEFINED_ = 0 X_DEFAULT_SOURCE = 1 X_ENDIAN_H = 1 X_FEATURES_H = 1 X_FILE_OFFSET_BITS = 64 X_GCC_SIZE_T = 0 X_LINUX_POSIX_TYPES_H = 0 X_LP64 = 1 X_NETDB_H = 1 X_NETINET_IN_H = 1 X_PATH_HEQUIV = "/etc/hosts.equiv" X_PATH_HOSTS = "/etc/hosts" X_PATH_NETWORKS = "/etc/networks" X_PATH_NSSWITCH_CONF = "/etc/nsswitch.conf" X_PATH_PROTOCOLS = "/etc/protocols" X_PATH_SERVICES = "/etc/services" X_POSIX_C_SOURCE = 200809 X_POSIX_SOURCE = 1 X_RPC_NETDB_H = 1 X_RWLOCK_INTERNAL_H = 0 X_SIZET_ = 0 X_SIZE_T = 0 X_SIZE_T_ = 0 X_SIZE_T_DECLARED = 0 X_SIZE_T_DEFINED = 0 X_SIZE_T_DEFINED_ = 0 X_SS_SIZE = 128 X_STDC_PREDEF_H = 1 X_STRUCT_TIMESPEC = 1 X_SYS_CDEFS_H = 1 X_SYS_SELECT_H = 1 X_SYS_SIZE_T_H = 0 X_SYS_SOCKET_H = 1 X_SYS_TYPES_H = 1 X_THREAD_MUTEX_INTERNAL_H = 1 X_THREAD_SHARED_TYPES_H = 1 X_T_SIZE = 0 X_T_SIZE_ = 0 Linux = 1 Unix = 1 ) // If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel // // network headers first and we should use those ABI-identical definitions // instead of our own, otherwise 0. const ( /* in.h:103:1: */ IPPROTO_HOPOPTS = 0 // IPv6 Hop-by-Hop options. IPPROTO_ROUTING = 43 // IPv6 routing header. IPPROTO_FRAGMENT = 44 // IPv6 fragmentation header. IPPROTO_ICMPV6 = 58 // ICMPv6. IPPROTO_NONE = 59 // IPv6 no next header. IPPROTO_DSTOPTS = 60 // IPv6 destination options. IPPROTO_MH = 135 ) // Standard well-known ports. const ( /* in.h:126:1: */ IPPORT_ECHO = 7 // Echo service. IPPORT_DISCARD = 9 // Discard transmissions service. IPPORT_SYSTAT = 11 // System status service. IPPORT_DAYTIME = 13 // Time of day service. IPPORT_NETSTAT = 15 // Network status service. IPPORT_FTP = 21 // File Transfer Protocol. IPPORT_TELNET = 23 // Telnet protocol. IPPORT_SMTP = 25 // Simple Mail Transfer Protocol. IPPORT_TIMESERVER = 37 // Timeserver service. IPPORT_NAMESERVER = 42 // Domain Name Service. IPPORT_WHOIS = 43 // Internet Whois service. IPPORT_MTP = 57 IPPORT_TFTP = 69 // Trivial File Transfer Protocol. IPPORT_RJE = 77 IPPORT_FINGER = 79 // Finger service. IPPORT_TTYLINK = 87 IPPORT_SUPDUP = 95 // SUPDUP protocol. IPPORT_EXECSERVER = 512 // execd service. IPPORT_LOGINSERVER = 513 // rlogind service. IPPORT_CMDSERVER = 514 IPPORT_EFSSERVER = 520 // UDP ports. IPPORT_BIFFUDP = 512 IPPORT_WHOSERVER = 513 IPPORT_ROUTESERVER = 520 // Ports less than this value are reserved for privileged processes. IPPORT_RESERVED = 1024 // Ports greater this value are reserved for (non-privileged) servers. IPPORT_USERRESERVED = 5000 ) // Options for use with `getsockopt' and `setsockopt' at the IPv6 level. // The first word in the comment at the right is the data type used; // "bool" means a boolean value stored in an `int'. // Advanced API (RFC3542) (1). // Advanced API (RFC3542) (2). // RFC5014. // RFC5082. // Obsolete synonyms for the above. // IPV6_MTU_DISCOVER values. // Socket level values for IPv6. // Routing header options for IPv6. // Standard well-defined IP protocols. const ( /* in.h:40:1: */ IPPROTO_IP = 0 // Dummy protocol for TCP. IPPROTO_ICMP = 1 // Internet Control Message Protocol. IPPROTO_IGMP = 2 // Internet Group Management Protocol. IPPROTO_IPIP = 4 // IPIP tunnels (older KA9Q tunnels use 94). IPPROTO_TCP = 6 // Transmission Control Protocol. IPPROTO_EGP = 8 // Exterior Gateway Protocol. IPPROTO_PUP = 12 // PUP protocol. IPPROTO_UDP = 17 // User Datagram Protocol. IPPROTO_IDP = 22 // XNS IDP protocol. IPPROTO_TP = 29 // SO Transport Protocol Class 4. IPPROTO_DCCP = 33 // Datagram Congestion Control Protocol. IPPROTO_IPV6 = 41 // IPv6 header. IPPROTO_RSVP = 46 // Reservation Protocol. IPPROTO_GRE = 47 // General Routing Encapsulation. IPPROTO_ESP = 50 // encapsulating security payload. IPPROTO_AH = 51 // authentication header. IPPROTO_MTP = 92 // Multicast Transport Protocol. IPPROTO_BEETPH = 94 // IP option pseudo header for BEET. IPPROTO_ENCAP = 98 // Encapsulation Header. IPPROTO_PIM = 103 // Protocol Independent Multicast. IPPROTO_COMP = 108 // Compression Header Protocol. IPPROTO_SCTP = 132 // Stream Control Transmission Protocol. IPPROTO_UDPLITE = 136 // UDP-Lite protocol. IPPROTO_MPLS = 137 // MPLS in IP. IPPROTO_ETHERNET = 143 // Ethernet-within-IPv6 Encapsulation. IPPROTO_RAW = 255 // Raw IP packets. IPPROTO_MPTCP = 262 // Multipath TCP connection. IPPROTO_MAX = 263 ) // Bits in the FLAGS argument to `send', `recv', et al. const ( /* socket.h:200:1: */ MSG_OOB = 1 // Process out-of-band data. MSG_PEEK = 2 // Peek at incoming messages. MSG_DONTROUTE = 4 // Don't use local routing. MSG_CTRUNC = 8 // Control data lost before delivery. MSG_PROXY = 16 // Supply or ask second address. MSG_TRUNC = 32 MSG_DONTWAIT = 64 // Nonblocking IO. MSG_EOR = 128 // End of record. MSG_WAITALL = 256 // Wait for a full request. MSG_FIN = 512 MSG_SYN = 1024 MSG_CONFIRM = 2048 // Confirm path validity. MSG_RST = 4096 MSG_ERRQUEUE = 8192 // Fetch message from error queue. MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. MSG_MORE = 32768 // Sender will send more. MSG_WAITFORONE = 65536 // Wait for at least one packet to return. MSG_BATCH = 262144 // sendmmsg: more messages coming. MSG_ZEROCOPY = 67108864 // Use user data in kernel path. MSG_FASTOPEN = 536870912 // Send data in TCP SYN. MSG_CMSG_CLOEXEC = 1073741824 ) // Socket level message types. This must match the definitions in // // <linux/socket.h>. const ( /* socket.h:332:1: */ SCM_RIGHTS = 1 ) // Get the architecture-dependent definition of enum __socket_type. // Define enum __socket_type for generic Linux. // Copyright (C) 1991-2021 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // Types of sockets. const ( /* socket_type.h:24:1: */ SOCK_STREAM = 1 // Sequenced, reliable, connection-based // byte streams. SOCK_DGRAM = 2 // Connectionless, unreliable datagrams // of fixed maximum length. SOCK_RAW = 3 // Raw protocol interface. SOCK_RDM = 4 // Reliably-delivered messages. SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, // datagrams of fixed maximum length. SOCK_DCCP = 6 // Datagram Congestion Control Protocol. SOCK_PACKET = 10 // Linux specific way of getting packets // at the dev level. For writing rarp and // other similar things on the user level. // Flags to be ORed into the type parameter of socket and socketpair and // used for the flags parameter of paccept. SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the // new descriptor(s). SOCK_NONBLOCK = 2048 ) // The following constants should be used for the second parameter of // // `shutdown'. const ( /* socket.h:41:1: */ SHUT_RD = 0 // No more receptions. SHUT_WR = 1 // No more transmissions. SHUT_RDWR = 2 ) type Ptrdiff_t = int64 /* <builtin>:3:26 */ type Size_t = uint64 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__int128_t = struct { Flo int64 Fhi int64 } /* <builtin>:21:43 */ // must match modernc.org/mathutil.Int128 type X__uint128_t = struct { Flo uint64 Fhi uint64 } /* <builtin>:22:44 */ // must match modernc.org/mathutil.Int128 type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // Copyright (C) 1996-2021 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // All data returned by the network data base library are supplied in // host order and returned in network order (suitable for use in // system calls). // Copyright (C) 1991-2021 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // These are defined by the user (or the compiler) // to specify the desired environment: // // __STRICT_ANSI__ ISO Standard C. // _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. // _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. // _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. // __STDC_WANT_LIB_EXT2__ // Extensions to ISO C99 from TR 27431-2:2010. // __STDC_WANT_IEC_60559_BFP_EXT__ // Extensions to ISO C11 from TS 18661-1:2014. // __STDC_WANT_IEC_60559_FUNCS_EXT__ // Extensions to ISO C11 from TS 18661-4:2015. // __STDC_WANT_IEC_60559_TYPES_EXT__ // Extensions to ISO C11 from TS 18661-3:2015. // __STDC_WANT_IEC_60559_EXT__ // ISO C2X interfaces defined only in Annex F. // // _POSIX_SOURCE IEEE Std 1003.1. // _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; // if >=199309L, add IEEE Std 1003.1b-1993; // if >=199506L, add IEEE Std 1003.1c-1995; // if >=200112L, all of IEEE 1003.1-2004 // if >=200809L, all of IEEE 1003.1-2008 // _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if // Single Unix conformance is wanted, to 600 for the // sixth revision, to 700 for the seventh revision. // _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. // _LARGEFILE_SOURCE Some more functions for correct standard I/O. // _LARGEFILE64_SOURCE Additional functionality from LFS for large files. // _FILE_OFFSET_BITS=N Select default filesystem interface. // _ATFILE_SOURCE Additional *at interfaces. // _DYNAMIC_STACK_SIZE_SOURCE Select correct (but non compile-time constant) // MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN. // _GNU_SOURCE All of the above, plus GNU extensions. // _DEFAULT_SOURCE The default set of features (taking precedence over // __STRICT_ANSI__). // // _FORTIFY_SOURCE Add security hardening to many library functions. // Set to 1 or 2; 2 performs stricter checks than 1. // // _REENTRANT, _THREAD_SAFE // Obsolete; equivalent to _POSIX_C_SOURCE=199506L. // // The `-ansi' switch to the GNU C compiler, and standards conformance // options such as `-std=c99', define __STRICT_ANSI__. If none of // these are defined, or if _DEFAULT_SOURCE is defined, the default is // to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to // 200809L, as well as enabling miscellaneous functions from BSD and // SVID. If more than one of these are defined, they accumulate. For // example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together // give you ISO C, 1003.1, and 1003.2, but nothing else. // // These are defined by this file and are used by the // header files to decide what to declare or define: // // __GLIBC_USE (F) Define things from feature set F. This is defined // to 1 or 0; the subsequent macros are either defined // or undefined, and those tests should be moved to // __GLIBC_USE. // __USE_ISOC11 Define ISO C11 things. // __USE_ISOC99 Define ISO C99 things. // __USE_ISOC95 Define ISO C90 AMD1 (C95) things. // __USE_ISOCXX11 Define ISO C++11 things. // __USE_POSIX Define IEEE Std 1003.1 things. // __USE_POSIX2 Define IEEE Std 1003.2 things. // __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. // __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. // __USE_XOPEN Define XPG things. // __USE_XOPEN_EXTENDED Define X/Open Unix things. // __USE_UNIX98 Define Single Unix V2 things. // __USE_XOPEN2K Define XPG6 things. // __USE_XOPEN2KXSI Define XPG6 XSI things. // __USE_XOPEN2K8 Define XPG7 things. // __USE_XOPEN2K8XSI Define XPG7 XSI things. // __USE_LARGEFILE Define correct standard I/O things. // __USE_LARGEFILE64 Define LFS things with separate names. // __USE_FILE_OFFSET64 Define 64bit interface as default. // __USE_MISC Define things from 4.3BSD or System V Unix. // __USE_ATFILE Define *at interfaces and AT_* constants for them. // __USE_DYNAMIC_STACK_SIZE Define correct (but non compile-time constant) // MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN. // __USE_GNU Define GNU extensions. // __USE_FORTIFY_LEVEL Additional security measures used, according to level. // // The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are // defined by this file unconditionally. `__GNU_LIBRARY__' is provided // only for compatibility. All new code should use the other symbols // to test for features. // // All macros listed above as possibly being defined by this file are // explicitly undefined if they are not explicitly defined. // Feature-test macros that are not defined by the user or compiler // but are implied by the other feature-test macros defined (or by the // lack of any definitions) are defined by the file. // // ISO C feature test macros depend on the definition of the macro // when an affected header is included, not when the first system // header is included, and so they are handled in // <bits/libc-header-start.h>, which does not have a multiple include // guard. Feature test macros that can be handled from the first // system header included are handled here. // Undefine everything, so we get a clean slate. // Suppress kernel-name space pollution unless user expressedly asks // for it.
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_linux_mips64le.go
vendor/modernc.org/libc/netdb/capi_linux_mips64le.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_linux_amd64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_freebsd_386.go
vendor/modernc.org/libc/netdb/netdb_freebsd_386.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_freebsd_386.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AI_ADDRCONFIG = 0x00000400 // netdb.h:200:1: AI_ALL = 0x00000100 // netdb.h:198:1: AI_CANONNAME = 0x00000002 // netdb.h:190:1: AI_DEFAULT = 1536 // netdb.h:203:1: AI_MASK = 3343 // netdb.h:194:1: AI_NUMERICHOST = 0x00000004 // netdb.h:191:1: AI_NUMERICSERV = 0x00000008 // netdb.h:192:1: AI_PASSIVE = 0x00000001 // netdb.h:189:1: AI_V4MAPPED = 0x00000800 // netdb.h:201:1: AI_V4MAPPED_CFG = 0x00000200 // netdb.h:199:1: EAI_AGAIN = 2 // netdb.h:168:1: EAI_BADFLAGS = 3 // netdb.h:169:1: EAI_BADHINTS = 12 // netdb.h:181:1: EAI_FAIL = 4 // netdb.h:170:1: EAI_FAMILY = 5 // netdb.h:171:1: EAI_MAX = 15 // netdb.h:184:1: EAI_MEMORY = 6 // netdb.h:172:1: EAI_NONAME = 8 // netdb.h:177:1: EAI_OVERFLOW = 14 // netdb.h:183:1: EAI_PROTOCOL = 13 // netdb.h:182:1: EAI_SERVICE = 9 // netdb.h:178:1: EAI_SOCKTYPE = 10 // netdb.h:179:1: EAI_SYSTEM = 11 // netdb.h:180:1: HOST_NOT_FOUND = 1 // netdb.h:155:1: IPPORT_RESERVED = 1024 // netdb.h:146:1: NETDB_INTERNAL = -1 // netdb.h:153:1: NETDB_SUCCESS = 0 // netdb.h:154:1: NI_DGRAM = 0x00000010 // netdb.h:218:1: NI_MAXHOST = 1025 // netdb.h:208:1: NI_MAXSERV = 32 // netdb.h:209:1: NI_NAMEREQD = 0x00000004 // netdb.h:216:1: NI_NOFQDN = 0x00000001 // netdb.h:214:1: NI_NUMERICHOST = 0x00000002 // netdb.h:215:1: NI_NUMERICSCOPE = 0x00000020 // netdb.h:219:1: NI_NUMERICSERV = 0x00000008 // netdb.h:217:1: NO_ADDRESS = 4 // netdb.h:159:1: NO_DATA = 4 // netdb.h:158:1: NO_RECOVERY = 3 // netdb.h:157:1: SCOPE_DELIMITER = 37 // netdb.h:224:1: TRY_AGAIN = 2 // netdb.h:156:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_ILP32 = 1 // <predefined>:1:1: X_IN_ADDR_T_DECLARED = 0 // netdb.h:67:1: X_IN_PORT_T_DECLARED = 0 // netdb.h:72:1: X_MACHINE__LIMITS_H_ = 0 // _limits.h:36:1: X_MACHINE__TYPES_H_ = 0 // _types.h:42:1: X_NETDB_H_ = 0 // netdb.h:60:1: X_Nonnull = 0 // cdefs.h:790:1: X_Null_unspecified = 0 // cdefs.h:792:1: X_Nullable = 0 // cdefs.h:791:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:91:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:93:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:94:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:95:1: X_PATH_SERVICES = "/etc/services" // netdb.h:96:1: X_PATH_SERVICES_DB = "/var/db/services.db" // netdb.h:97:1: X_SIZE_T_DECLARED = 0 // netdb.h:77:1: X_SOCKLEN_T_DECLARED = 0 // netdb.h:82:1: X_SYS_CDEFS_H_ = 0 // cdefs.h:39:1: X_SYS__TYPES_H_ = 0 // _types.h:32:1: X_UINT32_T_DECLARED = 0 // netdb.h:87:1: I386 = 1 // <predefined>:335:1: Unix = 1 // <predefined>:336:1: ) type Ptrdiff_t = int32 /* <builtin>:3:26 */ type Size_t = uint32 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // - // SPDX-License-Identifier: (BSD-3-Clause AND ISC) // // Copyright (c) 1980, 1983, 1988, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // - // Portions Copyright (c) 1993 by Digital Equipment Corporation. // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies, and that // the name of Digital Equipment Corporation not be used in advertising or // publicity pertaining to distribution of the document or software without // specific, written prior permission. // // THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL // WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT // CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL // DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR // PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS // ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS // SOFTWARE. // - // --Copyright-- // @(#)netdb.h 8.1 (Berkeley) 6/2/93 // From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $ // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 // $FreeBSD$ // Testing against Clang-specific extensions. // This code has been put in place to help reduce the addition of // compiler specific defines in FreeBSD code. It helps to aid in // having a compiler-agnostic source tree. // Compiler memory barriers, specific to gcc and clang. // XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced // Macro to test if we're using a specific version of gcc or later. // The __CONCAT macro is used to concatenate parts of symbol names, e.g. // with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. // The __CONCAT macro is a bit tricky to use if it must work in non-ANSI // mode -- there must be no spaces between its arguments, and for nested // __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also // concatenate double-quoted strings produced by the __STRING macro, but // this only works with ANSI C. // // __XSTRING is like __STRING, but it expands any macros in its argument // first. It is only available with ANSI C. // Compiler-dependent macros to help declare dead (non-returning) and // pure (no side effects) functions, and unused variables. They are // null except for versions of gcc that are known to support the features // properly (old versions of gcc-2 supported the dead and pure features // in a different (wrong) way). If we do not provide an implementation // for a given compiler, let the compile fail if it is told to use // a feature that we cannot live without. // Keywords added in C11. // Emulation of C11 _Generic(). Unlike the previously defined C11 // keywords, it is not possible to implement this using exactly the same // syntax. Therefore implement something similar under the name // __generic(). Unlike _Generic(), this macro can only distinguish // between a single type, so it requires nested invocations to // distinguish multiple cases. // C99 Static array indices in function parameter declarations. Syntax such as: // void bar(int myArray[static 10]); // is allowed in C99 but not in C++. Define __min_size appropriately so // headers using it can be compiled in either language. Use like this: // void bar(int myArray[__min_size(10)]); // XXX: should use `#if __STDC_VERSION__ < 199901'. // C++11 exposes a load of C99 stuff // GCC 2.95 provides `__restrict' as an extension to C90 to support the // C99-specific `restrict' type qualifier. We happen to use `__restrict' as // a way to define the `restrict' type qualifier without disturbing older // software that is unaware of C99 keywords. // GNU C version 2.96 adds explicit branch prediction so that // the CPU back-end can hint the processor and also so that // code blocks can be reordered such that the predicted path // sees a more linear flow, thus improving cache behavior, etc. // // The following two macros provide us with a way to utilize this // compiler feature. Use __predict_true() if you expect the expression // to evaluate to true, and __predict_false() if you expect the // expression to evaluate to false. // // A few notes about usage: // // * Generally, __predict_false() error condition checks (unless // you have some _strong_ reason to do otherwise, in which case // document it), and/or __predict_true() `no-error' condition // checks, assuming you want to optimize for the no-error case. // // * Other than that, if you don't know the likelihood of a test // succeeding from empirical or other `hard' evidence, don't // make predictions. // // * These are meant to be used in places that are run `a lot'. // It is wasteful to make predictions in code that is run // seldomly (e.g. at subsystem initialization time) as the // basic block reordering that this affects can often generate // larger code. // We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h> // require it. // Given the pointer x to the member m of the struct s, return // a pointer to the containing structure. When using GCC, we first // assign pointer x to a local variable, to check that its type is // compatible with member m. // Compiler-dependent macros to declare that functions take printf-like // or scanf-like arguments. They are null except for versions of gcc // that are known to support the features properly (old versions of gcc-2 // didn't permit keeping the keywords out of the application namespace). // Compiler-dependent macros that rely on FreeBSD-specific extensions. // Embed the rcs id of a source file in the resulting library. Note that in // more recent ELF binutils, we use .ident allowing the ID to be stripped. // Usage: // __FBSDID("$FreeBSD$"); // - // The following definitions are an extension of the behavior originally // implemented in <sys/_posix.h>, but with a different level of granularity. // POSIX.1 requires that the macros we test be defined before any standard // header file is included. // // Here's a quick run-down of the versions: // defined(_POSIX_SOURCE) 1003.1-1988 // _POSIX_C_SOURCE == 1 1003.1-1990 // _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option // _POSIX_C_SOURCE == 199309 1003.1b-1993 // _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, // and the omnibus ISO/IEC 9945-1: 1996 // _POSIX_C_SOURCE == 200112 1003.1-2001 // _POSIX_C_SOURCE == 200809 1003.1-2008 // // In addition, the X/Open Portability Guide, which is now the Single UNIX // Specification, defines a feature-test macro which indicates the version of // that specification, and which subsumes _POSIX_C_SOURCE. // // Our macros begin with two underscores to avoid namespace screwage. // Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. // Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. // Deal with various X/Open Portability Guides and Single UNIX Spec. // Deal with all versions of POSIX. The ordering relative to the tests above is // important. // - // Deal with _ANSI_SOURCE: // If it is defined, and no other compilation environment is explicitly // requested, then define our internal feature-test macros to zero. This // makes no difference to the preprocessor (undefined symbols in preprocessing // expressions are defined to have value zero), but makes it more convenient for // a test program to print out the values. // // If a program mistakenly defines _ANSI_SOURCE and some other macro such as // _POSIX_C_SOURCE, we will assume that it wants the broader compilation // environment (and in fact we will never get here). // User override __EXT1_VISIBLE // Old versions of GCC use non-standard ARM arch symbols; acle-compat.h // translates them to __ARM_ARCH and the modern feature symbols defined by ARM. // Nullability qualifiers: currently only supported by Clang. // Type Safety Checking // // Clang provides additional attributes to enable checking type safety // properties that cannot be enforced by the C type system. // Lock annotations. // // Clang provides support for doing basic thread-safety tests at // compile-time, by marking which locks will/should be held when // entering/leaving a functions. // // Furthermore, it is also possible to annotate variables and structure // members to enforce that they are only accessed when certain locks are // held. // Structure implements a lock. // Function acquires an exclusive or shared lock. // Function attempts to acquire an exclusive or shared lock. // Function releases a lock. // Function asserts that an exclusive or shared lock is held. // Function requires that an exclusive or shared lock is or is not held. // Function should not be analyzed. // Function or variable should not be sanitized, e.g., by AddressSanitizer. // GCC has the nosanitize attribute, but as a function attribute only, and // warns on use as a variable attribute. // Guard variables and structure members by lock. // Alignment builtins for better type checking and improved code generation. // Provide fallback versions for other compilers (GCC/Clang < 10): // - // SPDX-License-Identifier: BSD-2-Clause-FreeBSD // // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 // $FreeBSD$ // - // This file is in the public domain. // $FreeBSD$ // - // SPDX-License-Identifier: BSD-4-Clause // // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> // Copyright (c) 1990, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. All advertising materials mentioning features or use of this software // must display the following acknowledgement: // This product includes software developed by the University of // California, Berkeley and its contributors. // 4. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 // From: @(#)types.h 8.3 (Berkeley) 1/5/94 // $FreeBSD$ // - // This file is in the public domain. // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1988, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)limits.h 8.3 (Berkeley) 1/4/94 // $FreeBSD$ // According to ANSI (section 2.2.4.2), the values below must be usable by // #if preprocessing directives. Additionally, the expression must have the // same type as would an expression that is an object of the corresponding // type converted according to the integral promotions. The subtraction for // INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an // unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). // max value for an unsigned long long // Minimum signal stack size. // Basic types upon which most other types are built. type X__int8_t = int8 /* _types.h:55:22 */ type X__uint8_t = uint8 /* _types.h:56:24 */ type X__int16_t = int16 /* _types.h:57:17 */ type X__uint16_t = uint16 /* _types.h:58:25 */ type X__int32_t = int32 /* _types.h:59:15 */ type X__uint32_t = uint32 /* _types.h:60:23 */ type X__int64_t = int64 /* _types.h:66:20 */ type X__uint64_t = uint64 /* _types.h:68:28 */ // Standard type definitions. type X__clock_t = uint32 /* _types.h:84:23 */ type X__critical_t = X__int32_t /* _types.h:85:19 */ type X__double_t = float64 /* _types.h:87:21 */ type X__float_t = float64 /* _types.h:88:21 */ type X__intfptr_t = X__int32_t /* _types.h:90:19 */ type X__intptr_t = X__int32_t /* _types.h:91:19 */ type X__intmax_t = X__int64_t /* _types.h:93:19 */ type X__int_fast8_t = X__int32_t /* _types.h:94:19 */ type X__int_fast16_t = X__int32_t /* _types.h:95:19 */ type X__int_fast32_t = X__int32_t /* _types.h:96:19 */ type X__int_fast64_t = X__int64_t /* _types.h:97:19 */ type X__int_least8_t = X__int8_t /* _types.h:98:18 */ type X__int_least16_t = X__int16_t /* _types.h:99:19 */ type X__int_least32_t = X__int32_t /* _types.h:100:19 */ type X__int_least64_t = X__int64_t /* _types.h:101:19 */ type X__ptrdiff_t = X__int32_t /* _types.h:112:19 */ type X__register_t = X__int32_t /* _types.h:113:19 */ type X__segsz_t = X__int32_t /* _types.h:114:19 */ type X__size_t = X__uint32_t /* _types.h:115:20 */ type X__ssize_t = X__int32_t /* _types.h:116:19 */ type X__time_t = X__int32_t /* _types.h:117:19 */ type X__uintfptr_t = X__uint32_t /* _types.h:118:20 */ type X__uintptr_t = X__uint32_t /* _types.h:119:20 */ type X__uintmax_t = X__uint64_t /* _types.h:121:20 */ type X__uint_fast8_t = X__uint32_t /* _types.h:122:20 */ type X__uint_fast16_t = X__uint32_t /* _types.h:123:20 */ type X__uint_fast32_t = X__uint32_t /* _types.h:124:20 */ type X__uint_fast64_t = X__uint64_t /* _types.h:125:20 */ type X__uint_least8_t = X__uint8_t /* _types.h:126:19 */ type X__uint_least16_t = X__uint16_t /* _types.h:127:20 */ type X__uint_least32_t = X__uint32_t /* _types.h:128:20 */ type X__uint_least64_t = X__uint64_t /* _types.h:129:20 */ type X__u_register_t = X__uint32_t /* _types.h:136:20 */ type X__vm_offset_t = X__uint32_t /* _types.h:137:20 */ type X__vm_paddr_t = X__uint64_t /* _types.h:138:20 */ type X__vm_size_t = X__uint32_t /* _types.h:139:20 */ type X___wchar_t = int32 /* _types.h:141:14 */ // Standard type definitions. type X__blksize_t = X__int32_t /* _types.h:40:19 */ // file block size type X__blkcnt_t = X__int64_t /* _types.h:41:19 */ // file block count type X__clockid_t = X__int32_t /* _types.h:42:19 */ // clock_gettime()... type X__fflags_t = X__uint32_t /* _types.h:43:20 */ // file flags type X__fsblkcnt_t = X__uint64_t /* _types.h:44:20 */ type X__fsfilcnt_t = X__uint64_t /* _types.h:45:20 */ type X__gid_t = X__uint32_t /* _types.h:46:20 */ type X__id_t = X__int64_t /* _types.h:47:19 */ // can hold a gid_t, pid_t, or uid_t type X__ino_t = X__uint64_t /* _types.h:48:20 */ // inode number type X__key_t = int32 /* _types.h:49:15 */ // IPC key (for Sys V IPC) type X__lwpid_t = X__int32_t /* _types.h:50:19 */ // Thread ID (a.k.a. LWP) type X__mode_t = X__uint16_t /* _types.h:51:20 */ // permissions type X__accmode_t = int32 /* _types.h:52:14 */ // access permissions type X__nl_item = int32 /* _types.h:53:14 */ type X__nlink_t = X__uint64_t /* _types.h:54:20 */ // link count type X__off_t = X__int64_t /* _types.h:55:19 */ // file offset type X__off64_t = X__int64_t /* _types.h:56:19 */ // file offset (alias) type X__pid_t = X__int32_t /* _types.h:57:19 */ // process [group] type X__rlim_t = X__int64_t /* _types.h:58:19 */ // resource limit - intentionally // signed, because of legacy code // that uses -1 for RLIM_INFINITY type X__sa_family_t = X__uint8_t /* _types.h:61:19 */ type X__socklen_t = X__uint32_t /* _types.h:62:20 */ type X__suseconds_t = int32 /* _types.h:63:15 */ // microseconds (signed) type X__timer_t = uintptr /* _types.h:64:24 */ // timer_gettime()... type X__mqd_t = uintptr /* _types.h:65:21 */ // mq_open()... type X__uid_t = X__uint32_t /* _types.h:66:20 */ type X__useconds_t = uint32 /* _types.h:67:22 */ // microseconds (unsigned) type X__cpuwhich_t = int32 /* _types.h:68:14 */ // which parameter for cpuset. type X__cpulevel_t = int32 /* _types.h:69:14 */ // level parameter for cpuset. type X__cpusetid_t = int32 /* _types.h:70:14 */ // cpuset identifier. type X__daddr_t = X__int64_t /* _types.h:71:19 */ // bwrite(3), FIOBMAP2, etc // Unusual type definitions. // rune_t is declared to be an “int” instead of the more natural // “unsigned long” or “long”. Two things are happening here. It is not // unsigned so that EOF (-1) can be naturally assigned to it and used. Also, // it looks like 10646 will be a 31 bit standard. This means that if your // ints cannot hold 32 bits, you will be in trouble. The reason an int was // chosen over a long is that the is*() and to*() routines take ints (says // ANSI C), but they use __ct_rune_t instead of int. // // NOTE: rune_t is not covered by ANSI nor other standards, and should not // be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and // rune_t must be the same type. Also, wint_t should be able to hold all // members of the largest character set plus one extra value (WEOF), and // must be at least 16 bits. type X__ct_rune_t = int32 /* _types.h:91:14 */ // arg type for ctype funcs type X__rune_t = X__ct_rune_t /* _types.h:92:21 */ // rune_t (see above) type X__wint_t = X__ct_rune_t /* _types.h:93:21 */ // wint_t (see above) // Clang already provides these types as built-ins, but only in C++ mode. type X__char16_t = X__uint_least16_t /* _types.h:97:26 */ type X__char32_t = X__uint_least32_t /* _types.h:98:26 */ // In C++11, char16_t and char32_t are built-in types. type X__max_align_t = struct { F__max_align1 int64 F__max_align2 float64 } /* _types.h:111:3 */ type X__dev_t = X__uint64_t /* _types.h:113:20 */ // device number type X__fixpt_t = X__uint32_t /* _types.h:115:20 */ // fixed point number // mbstate_t is an opaque object to keep conversion state during multibyte // stream conversions. type X__mbstate_t = struct { F__ccgo_pad1 [0]uint32 F__mbstate8 [128]int8 } /* _types.h:124:3 */ type X__rman_res_t = X__uintmax_t /* _types.h:126:25 */ // Types for varargs. These are all provided by builtin types these // days, so centralize their definition. type X__va_list = X__builtin_va_list /* _types.h:133:27 */ // internally known to gcc type X__gnuc_va_list = X__va_list /* _types.h:140:20 */ // compatibility w/GNU headers // When the following macro is defined, the system uses 64-bit inode numbers. // Programs can use this to avoid including <sys/param.h>, with its associated // namespace pollution. type In_addr_t = X__uint32_t /* netdb.h:66:20 */ type In_port_t = X__uint16_t /* netdb.h:71:20 */ type Socklen_t = X__socklen_t /* netdb.h:81:21 */ type Uint32_t = X__uint32_t /* netdb.h:86:20 */ // Structures returned by network data base library. All addresses are // supplied in host order, and returned in network order (suitable for // use in system calls). type Hostent = struct { Fh_name uintptr Fh_aliases uintptr Fh_addrtype int32 Fh_length int32 Fh_addr_list uintptr } /* netdb.h:106:1 */ type Netent = struct { Fn_name uintptr Fn_aliases uintptr Fn_addrtype int32 Fn_net Uint32_t
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_linux_s390x.go
vendor/modernc.org/libc/netdb/capi_linux_s390x.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_s390x.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_darwin_amd64.go
vendor/modernc.org/libc/netdb/capi_darwin_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_darwin_amd64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{ "__darwin_check_fd_set": {}, "__darwin_check_fd_set_overflow": {}, "__darwin_fd_clr": {}, "__darwin_fd_isset": {}, "__darwin_fd_set": {}, }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_linux_amd64.go
vendor/modernc.org/libc/netdb/netdb_linux_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_linux_amd64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_ALG = 38 // socket.h:133:1: AF_APPLETALK = 5 // socket.h:99:1: AF_ASH = 18 // socket.h:113:1: AF_ATMPVC = 8 // socket.h:102:1: AF_ATMSVC = 20 // socket.h:115:1: AF_AX25 = 3 // socket.h:97:1: AF_BLUETOOTH = 31 // socket.h:126:1: AF_BRIDGE = 7 // socket.h:101:1: AF_CAIF = 37 // socket.h:132:1: AF_CAN = 29 // socket.h:124:1: AF_DECnet = 12 // socket.h:106:1: AF_ECONET = 19 // socket.h:114:1: AF_FILE = 1 // socket.h:95:1: AF_IB = 27 // socket.h:122:1: AF_IEEE802154 = 36 // socket.h:131:1: AF_INET = 2 // socket.h:96:1: AF_INET6 = 10 // socket.h:104:1: AF_IPX = 4 // socket.h:98:1: AF_IRDA = 23 // socket.h:118:1: AF_ISDN = 34 // socket.h:129:1: AF_IUCV = 32 // socket.h:127:1: AF_KCM = 41 // socket.h:136:1: AF_KEY = 15 // socket.h:109:1: AF_LLC = 26 // socket.h:121:1: AF_LOCAL = 1 // socket.h:93:1: AF_MAX = 45 // socket.h:140:1: AF_MPLS = 28 // socket.h:123:1: AF_NETBEUI = 13 // socket.h:107:1: AF_NETLINK = 16 // socket.h:110:1: AF_NETROM = 6 // socket.h:100:1: AF_NFC = 39 // socket.h:134:1: AF_PACKET = 17 // socket.h:112:1: AF_PHONET = 35 // socket.h:130:1: AF_PPPOX = 24 // socket.h:119:1: AF_QIPCRTR = 42 // socket.h:137:1: AF_RDS = 21 // socket.h:116:1: AF_ROSE = 11 // socket.h:105:1: AF_ROUTE = 16 // socket.h:111:1: AF_RXRPC = 33 // socket.h:128:1: AF_SECURITY = 14 // socket.h:108:1: AF_SMC = 43 // socket.h:138:1: AF_SNA = 22 // socket.h:117:1: AF_TIPC = 30 // socket.h:125:1: AF_UNIX = 1 // socket.h:94:1: AF_UNSPEC = 0 // socket.h:92:1: AF_VSOCK = 40 // socket.h:135:1: AF_WANPIPE = 25 // socket.h:120:1: AF_X25 = 9 // socket.h:103:1: AF_XDP = 44 // socket.h:139:1: AI_ADDRCONFIG = 0x0020 // netdb.h:601:1: AI_ALL = 0x0010 // netdb.h:600:1: AI_CANONNAME = 0x0002 // netdb.h:597:1: AI_NUMERICHOST = 0x0004 // netdb.h:598:1: AI_NUMERICSERV = 0x0400 // netdb.h:613:1: AI_PASSIVE = 0x0001 // netdb.h:596:1: AI_V4MAPPED = 0x0008 // netdb.h:599:1: BIG_ENDIAN = 4321 // endian.h:28:1: BYTE_ORDER = 1234 // endian.h:30:1: EAI_AGAIN = -3 // netdb.h:618:1: EAI_BADFLAGS = -1 // netdb.h:616:1: EAI_FAIL = -4 // netdb.h:619:1: EAI_FAMILY = -6 // netdb.h:620:1: EAI_MEMORY = -10 // netdb.h:623:1: EAI_NONAME = -2 // netdb.h:617:1: EAI_OVERFLOW = -12 // netdb.h:625:1: EAI_SERVICE = -8 // netdb.h:622:1: EAI_SOCKTYPE = -7 // netdb.h:621:1: EAI_SYSTEM = -11 // netdb.h:624:1: FD_SETSIZE = 1024 // select.h:73:1: FIOGETOWN = 0x8903 // sockios.h:8:1: FIOSETOWN = 0x8901 // sockios.h:6:1: HOST_NOT_FOUND = 1 // netdb.h:63:1: INET6_ADDRSTRLEN = 46 // in.h:234:1: INET_ADDRSTRLEN = 16 // in.h:233:1: IN_CLASSA_HOST = 16777215 // in.h:169:1: IN_CLASSA_MAX = 128 // in.h:170:1: IN_CLASSA_NET = 0xff000000 // in.h:167:1: IN_CLASSA_NSHIFT = 24 // in.h:168:1: IN_CLASSB_HOST = 65535 // in.h:175:1: IN_CLASSB_MAX = 65536 // in.h:176:1: IN_CLASSB_NET = 0xffff0000 // in.h:173:1: IN_CLASSB_NSHIFT = 16 // in.h:174:1: IN_CLASSC_HOST = 255 // in.h:181:1: IN_CLASSC_NET = 0xffffff00 // in.h:179:1: IN_CLASSC_NSHIFT = 8 // in.h:180:1: IN_LOOPBACKNET = 127 // in.h:197:1: IPPORT_RESERVED1 = 1024 // netdb.h:79:1: IPV6_2292DSTOPTS = 4 // in.h:171:1: IPV6_2292HOPLIMIT = 8 // in.h:175:1: IPV6_2292HOPOPTS = 3 // in.h:170:1: IPV6_2292PKTINFO = 2 // in.h:169:1: IPV6_2292PKTOPTIONS = 6 // in.h:173:1: IPV6_2292RTHDR = 5 // in.h:172:1: IPV6_ADDRFORM = 1 // in.h:168:1: IPV6_ADDR_PREFERENCES = 72 // in.h:223:1: IPV6_ADD_MEMBERSHIP = 20 // in.h:237:1: IPV6_AUTHHDR = 10 // in.h:180:1: IPV6_AUTOFLOWLABEL = 70 // in.h:220:1: IPV6_CHECKSUM = 7 // in.h:174:1: IPV6_DONTFRAG = 62 // in.h:214:1: IPV6_DROP_MEMBERSHIP = 21 // in.h:238:1: IPV6_DSTOPTS = 59 // in.h:211:1: IPV6_FREEBIND = 78 // in.h:233:1: IPV6_HDRINCL = 36 // in.h:198:1: IPV6_HOPLIMIT = 52 // in.h:204:1: IPV6_HOPOPTS = 54 // in.h:206:1: IPV6_IPSEC_POLICY = 34 // in.h:196:1: IPV6_JOIN_ANYCAST = 27 // in.h:192:1: IPV6_JOIN_GROUP = 20 // in.h:185:1: IPV6_LEAVE_ANYCAST = 28 // in.h:193:1: IPV6_LEAVE_GROUP = 21 // in.h:186:1: IPV6_MINHOPCOUNT = 73 // in.h:226:1: IPV6_MTU = 24 // in.h:189:1: IPV6_MTU_DISCOVER = 23 // in.h:188:1: IPV6_MULTICAST_ALL = 29 // in.h:194:1: IPV6_MULTICAST_HOPS = 18 // in.h:183:1: IPV6_MULTICAST_IF = 17 // in.h:182:1: IPV6_MULTICAST_LOOP = 19 // in.h:184:1: IPV6_NEXTHOP = 9 // in.h:179:1: IPV6_ORIGDSTADDR = 74 // in.h:228:1: IPV6_PATHMTU = 61 // in.h:213:1: IPV6_PKTINFO = 50 // in.h:202:1: IPV6_PMTUDISC_DO = 2 // in.h:246:1: IPV6_PMTUDISC_DONT = 0 // in.h:244:1: IPV6_PMTUDISC_INTERFACE = 4 // in.h:248:1: IPV6_PMTUDISC_OMIT = 5 // in.h:249:1: IPV6_PMTUDISC_PROBE = 3 // in.h:247:1: IPV6_PMTUDISC_WANT = 1 // in.h:245:1: IPV6_RECVDSTOPTS = 58 // in.h:210:1: IPV6_RECVERR = 25 // in.h:190:1: IPV6_RECVFRAGSIZE = 77 // in.h:232:1: IPV6_RECVHOPLIMIT = 51 // in.h:203:1: IPV6_RECVHOPOPTS = 53 // in.h:205:1: IPV6_RECVORIGDSTADDR = 74 // in.h:229:1: IPV6_RECVPATHMTU = 60 // in.h:212:1: IPV6_RECVPKTINFO = 49 // in.h:201:1: IPV6_RECVRTHDR = 56 // in.h:208:1: IPV6_RECVTCLASS = 66 // in.h:217:1: IPV6_ROUTER_ALERT = 22 // in.h:187:1: IPV6_ROUTER_ALERT_ISOLATE = 30 // in.h:195:1: IPV6_RTHDR = 57 // in.h:209:1: IPV6_RTHDRDSTOPTS = 55 // in.h:207:1: IPV6_RTHDR_LOOSE = 0 // in.h:256:1: IPV6_RTHDR_STRICT = 1 // in.h:257:1: IPV6_RTHDR_TYPE_0 = 0 // in.h:259:1: IPV6_RXDSTOPTS = 59 // in.h:241:1: IPV6_RXHOPOPTS = 54 // in.h:240:1: IPV6_TCLASS = 67 // in.h:218:1: IPV6_TRANSPARENT = 75 // in.h:230:1: IPV6_UNICAST_HOPS = 16 // in.h:181:1: IPV6_UNICAST_IF = 76 // in.h:231:1: IPV6_V6ONLY = 26 // in.h:191:1: IPV6_XFRM_POLICY = 35 // in.h:197:1: IP_ADD_MEMBERSHIP = 35 // in.h:121:1: IP_ADD_SOURCE_MEMBERSHIP = 39 // in.h:125:1: IP_BIND_ADDRESS_NO_PORT = 24 // in.h:103:1: IP_BLOCK_SOURCE = 38 // in.h:124:1: IP_CHECKSUM = 23 // in.h:102:1: IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:135:1: IP_DEFAULT_MULTICAST_TTL = 1 // in.h:134:1: IP_DROP_MEMBERSHIP = 36 // in.h:122:1: IP_DROP_SOURCE_MEMBERSHIP = 40 // in.h:126:1: IP_FREEBIND = 15 // in.h:89:1: IP_HDRINCL = 3 // in.h:48:1: IP_IPSEC_POLICY = 16 // in.h:90:1: IP_MAX_MEMBERSHIPS = 20 // in.h:136:1: IP_MINTTL = 21 // in.h:100:1: IP_MSFILTER = 41 // in.h:127:1: IP_MTU = 14 // in.h:88:1: IP_MTU_DISCOVER = 10 // in.h:84:1: IP_MULTICAST_ALL = 49 // in.h:128:1: IP_MULTICAST_IF = 32 // in.h:118:1: IP_MULTICAST_LOOP = 34 // in.h:120:1: IP_MULTICAST_TTL = 33 // in.h:119:1: IP_NODEFRAG = 22 // in.h:101:1: IP_OPTIONS = 4 // in.h:47:1: IP_ORIGDSTADDR = 20 // in.h:97:1: IP_PASSSEC = 18 // in.h:92:1: IP_PKTINFO = 8 // in.h:81:1: IP_PKTOPTIONS = 9 // in.h:82:1: IP_PMTUDISC = 10 // in.h:83:1: IP_PMTUDISC_DO = 2 // in.h:109:1: IP_PMTUDISC_DONT = 0 // in.h:107:1: IP_PMTUDISC_INTERFACE = 4 // in.h:114:1: IP_PMTUDISC_OMIT = 5 // in.h:116:1: IP_PMTUDISC_PROBE = 3 // in.h:110:1: IP_PMTUDISC_WANT = 1 // in.h:108:1: IP_RECVERR = 11 // in.h:85:1: IP_RECVFRAGSIZE = 25 // in.h:104:1: IP_RECVOPTS = 6 // in.h:51:1: IP_RECVORIGDSTADDR = 20 // in.h:98:1: IP_RECVRETOPTS = 7 // in.h:53:1: IP_RECVTOS = 13 // in.h:87:1: IP_RECVTTL = 12 // in.h:86:1: IP_RETOPTS = 7 // in.h:54:1: IP_ROUTER_ALERT = 5 // in.h:80:1: IP_TOS = 1 // in.h:49:1: IP_TRANSPARENT = 19 // in.h:93:1: IP_TTL = 2 // in.h:50:1: IP_UNBLOCK_SOURCE = 37 // in.h:123:1: IP_UNICAST_IF = 50 // in.h:129:1: IP_XFRM_POLICY = 17 // in.h:91:1: LITTLE_ENDIAN = 1234 // endian.h:27:1: MCAST_BLOCK_SOURCE = 43 // in.h:67:1: MCAST_EXCLUDE = 0 // in.h:76:1: MCAST_INCLUDE = 1 // in.h:77:1: MCAST_JOIN_GROUP = 42 // in.h:66:1: MCAST_JOIN_SOURCE_GROUP = 46 // in.h:70:1: MCAST_LEAVE_GROUP = 45 // in.h:69:1: MCAST_LEAVE_SOURCE_GROUP = 47 // in.h:71:1: MCAST_MSFILTER = 48 // in.h:72:1: MCAST_UNBLOCK_SOURCE = 44 // in.h:68:1: NETDB_INTERNAL = -1 // netdb.h:72:1: NETDB_SUCCESS = 0 // netdb.h:73:1: NI_DGRAM = 16 // netdb.h:646:1: NI_MAXHOST = 1025 // netdb.h:638:1: NI_MAXSERV = 32 // netdb.h:639:1: NI_NAMEREQD = 8 // netdb.h:645:1: NI_NOFQDN = 4 // netdb.h:644:1: NI_NUMERICHOST = 1 // netdb.h:642:1: NI_NUMERICSERV = 2 // netdb.h:643:1: NO_ADDRESS = 4 // netdb.h:74:1: NO_DATA = 4 // netdb.h:68:1: NO_RECOVERY = 3 // netdb.h:66:1: PDP_ENDIAN = 3412 // endian.h:29:1: PF_ALG = 38 // socket.h:82:1: PF_APPLETALK = 5 // socket.h:48:1: PF_ASH = 18 // socket.h:62:1: PF_ATMPVC = 8 // socket.h:51:1: PF_ATMSVC = 20 // socket.h:64:1: PF_AX25 = 3 // socket.h:46:1: PF_BLUETOOTH = 31 // socket.h:75:1: PF_BRIDGE = 7 // socket.h:50:1: PF_CAIF = 37 // socket.h:81:1: PF_CAN = 29 // socket.h:73:1: PF_DECnet = 12 // socket.h:55:1: PF_ECONET = 19 // socket.h:63:1: PF_FILE = 1 // socket.h:44:1: PF_IB = 27 // socket.h:71:1: PF_IEEE802154 = 36 // socket.h:80:1: PF_INET = 2 // socket.h:45:1: PF_INET6 = 10 // socket.h:53:1: PF_IPX = 4 // socket.h:47:1: PF_IRDA = 23 // socket.h:67:1: PF_ISDN = 34 // socket.h:78:1: PF_IUCV = 32 // socket.h:76:1: PF_KCM = 41 // socket.h:85:1: PF_KEY = 15 // socket.h:58:1: PF_LLC = 26 // socket.h:70:1: PF_LOCAL = 1 // socket.h:42:1: PF_MAX = 45 // socket.h:89:1: PF_MPLS = 28 // socket.h:72:1: PF_NETBEUI = 13 // socket.h:56:1: PF_NETLINK = 16 // socket.h:59:1: PF_NETROM = 6 // socket.h:49:1: PF_NFC = 39 // socket.h:83:1: PF_PACKET = 17 // socket.h:61:1: PF_PHONET = 35 // socket.h:79:1: PF_PPPOX = 24 // socket.h:68:1: PF_QIPCRTR = 42 // socket.h:86:1: PF_RDS = 21 // socket.h:65:1: PF_ROSE = 11 // socket.h:54:1: PF_ROUTE = 16 // socket.h:60:1: PF_RXRPC = 33 // socket.h:77:1: PF_SECURITY = 14 // socket.h:57:1: PF_SMC = 43 // socket.h:87:1: PF_SNA = 22 // socket.h:66:1: PF_TIPC = 30 // socket.h:74:1: PF_UNIX = 1 // socket.h:43:1: PF_UNSPEC = 0 // socket.h:41:1: PF_VSOCK = 40 // socket.h:84:1: PF_WANPIPE = 25 // socket.h:69:1: PF_X25 = 9 // socket.h:52:1: PF_XDP = 44 // socket.h:88:1: SCM_TIMESTAMP = 29 // socket.h:140:1: SCM_TIMESTAMPING = 37 // socket.h:142:1: SCM_TIMESTAMPING_OPT_STATS = 54 // socket.h:90:1: SCM_TIMESTAMPING_PKTINFO = 58 // socket.h:98:1: SCM_TIMESTAMPNS = 35 // socket.h:141:1: SCM_TXTIME = 61 // socket.h:105:1: SCM_WIFI_STATUS = 41 // socket.h:64:1: SIOCATMARK = 0x8905 // sockios.h:10:1: SIOCGPGRP = 0x8904 // sockios.h:9:1: SIOCGSTAMP = 0x8906 // sockios.h:11:1: SIOCGSTAMPNS = 0x8907 // sockios.h:12:1: SIOCSPGRP = 0x8902 // sockios.h:7:1: SOL_AAL = 265 // socket.h:151:1: SOL_ALG = 279 // socket.h:165:1: SOL_ATM = 264 // socket.h:150:1: SOL_BLUETOOTH = 274 // socket.h:160:1: SOL_CAIF = 278 // socket.h:164:1: SOL_DCCP = 269 // socket.h:155:1: SOL_DECNET = 261 // socket.h:147:1: SOL_ICMPV6 = 58 // in.h:253:1: SOL_IP = 0 // in.h:132:1: SOL_IPV6 = 41 // in.h:252:1: SOL_IRDA = 266 // socket.h:152:1: SOL_IUCV = 277 // socket.h:163:1: SOL_KCM = 281 // socket.h:167:1: SOL_LLC = 268 // socket.h:154:1: SOL_NETBEUI = 267 // socket.h:153:1: SOL_NETLINK = 270 // socket.h:156:1: SOL_NFC = 280 // socket.h:166:1: SOL_PACKET = 263 // socket.h:149:1: SOL_PNPIPE = 275 // socket.h:161:1: SOL_PPPOL2TP = 273 // socket.h:159:1: SOL_RAW = 255 // socket.h:146:1: SOL_RDS = 276 // socket.h:162:1: SOL_RXRPC = 272 // socket.h:158:1: SOL_SOCKET = 1 // socket.h:9:1: SOL_TIPC = 271 // socket.h:157:1: SOL_TLS = 282 // socket.h:168:1: SOL_X25 = 262 // socket.h:148:1: SOL_XDP = 283 // socket.h:169:1: SOMAXCONN = 4096 // socket.h:172:1: SO_ACCEPTCONN = 30 // socket.h:51:1: SO_ATTACH_BPF = 50 // socket.h:82:1: SO_ATTACH_FILTER = 26 // socket.h:45:1: SO_ATTACH_REUSEPORT_CBPF = 51 // socket.h:85:1: SO_ATTACH_REUSEPORT_EBPF = 52 // socket.h:86:1: SO_BINDTODEVICE = 25 // socket.h:42:1: SO_BINDTOIFINDEX = 62 // socket.h:107:1: SO_BPF_EXTENSIONS = 48 // socket.h:78:1: SO_BROADCAST = 6 // socket.h:16:1: SO_BSDCOMPAT = 14 // socket.h:26:1: SO_BUSY_POLL = 46 // socket.h:74:1: SO_CNX_ADVICE = 53 // socket.h:88:1: SO_COOKIE = 57 // socket.h:96:1: SO_DEBUG = 1 // socket.h:11:1: SO_DETACH_BPF = 27 // socket.h:83:1: SO_DETACH_FILTER = 27 // socket.h:46:1: SO_DETACH_REUSEPORT_BPF = 68 // socket.h:120:1: SO_DOMAIN = 39 // socket.h:59:1: SO_DONTROUTE = 5 // socket.h:15:1: SO_ERROR = 4 // socket.h:14:1: SO_GET_FILTER = 26 // socket.h:47:1: SO_INCOMING_CPU = 49 // socket.h:80:1: SO_INCOMING_NAPI_ID = 56 // socket.h:94:1: SO_KEEPALIVE = 9 // socket.h:21:1: SO_LINGER = 13 // socket.h:25:1: SO_LOCK_FILTER = 44 // socket.h:70:1: SO_MARK = 36 // socket.h:56:1: SO_MAX_PACING_RATE = 47 // socket.h:76:1: SO_MEMINFO = 55 // socket.h:92:1: SO_NOFCS = 43 // socket.h:68:1: SO_NO_CHECK = 11 // socket.h:23:1: SO_OOBINLINE = 10 // socket.h:22:1: SO_PASSCRED = 16 // socket.h:29:1: SO_PASSSEC = 34 // socket.h:54:1: SO_PEEK_OFF = 42 // socket.h:65:1: SO_PEERCRED = 17 // socket.h:30:1: SO_PEERGROUPS = 59 // socket.h:100:1: SO_PEERNAME = 28 // socket.h:49:1: SO_PEERSEC = 31 // socket.h:53:1: SO_PRIORITY = 12 // socket.h:24:1: SO_PROTOCOL = 38 // socket.h:58:1: SO_RCVBUF = 8 // socket.h:18:1: SO_RCVBUFFORCE = 33 // socket.h:20:1: SO_RCVLOWAT = 18 // socket.h:31:1: SO_RCVTIMEO = 20 // socket.h:129:1: SO_RCVTIMEO_NEW = 66 // socket.h:117:1: SO_RCVTIMEO_OLD = 20 // socket.h:33:1: SO_REUSEADDR = 2 // socket.h:12:1: SO_REUSEPORT = 15 // socket.h:27:1: SO_RXQ_OVFL = 40 // socket.h:61:1: SO_SECURITY_AUTHENTICATION = 22 // socket.h:38:1: SO_SECURITY_ENCRYPTION_NETWORK = 24 // socket.h:40:1: SO_SECURITY_ENCRYPTION_TRANSPORT = 23 // socket.h:39:1: SO_SELECT_ERR_QUEUE = 45 // socket.h:72:1: SO_SNDBUF = 7 // socket.h:17:1: SO_SNDBUFFORCE = 32 // socket.h:19:1: SO_SNDLOWAT = 19 // socket.h:32:1: SO_SNDTIMEO = 21 // socket.h:130:1: SO_SNDTIMEO_NEW = 67 // socket.h:118:1: SO_SNDTIMEO_OLD = 21 // socket.h:34:1: SO_TIMESTAMP = 29 // socket.h:125:1: SO_TIMESTAMPING = 37 // socket.h:127:1: SO_TIMESTAMPING_NEW = 65 // socket.h:115:1: SO_TIMESTAMPING_OLD = 37 // socket.h:111:1: SO_TIMESTAMPNS = 35 // socket.h:126:1: SO_TIMESTAMPNS_NEW = 64 // socket.h:114:1: SO_TIMESTAMPNS_OLD = 35 // socket.h:110:1: SO_TIMESTAMP_NEW = 63 // socket.h:113:1: SO_TIMESTAMP_OLD = 29 // socket.h:109:1: SO_TXTIME = 61 // socket.h:104:1: SO_TYPE = 3 // socket.h:13:1: SO_WIFI_STATUS = 41 // socket.h:63:1: SO_ZEROCOPY = 60 // socket.h:102:1: TRY_AGAIN = 2 // netdb.h:64:1: X_ASM_X86_POSIX_TYPES_64_H = 0 // posix_types_64.h:3:1: X_ATFILE_SOURCE = 1 // features.h:342:1: X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: X_BITS_ENDIAN_H = 1 // endian.h:20:1: X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: X_BITS_SOCKADDR_H = 1 // sockaddr.h:24:1: X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: X_BITS_STDINT_UINTN_H = 1 // stdint-uintn.h:20:1: X_BITS_TIME64_H = 1 // time64.h:24:1: X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: X_BITS_TYPES_H = 1 // types.h:24:1: X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: X_BSD_SIZE_T_ = 0 // stddef.h:189:1: X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: X_DEFAULT_SOURCE = 1 // features.h:227:1: X_ENDIAN_H = 1 // endian.h:19:1: X_FEATURES_H = 1 // features.h:19:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_GCC_SIZE_T = 0 // stddef.h:195:1: X_LINUX_POSIX_TYPES_H = 0 // posix_types.h:3:1: X_LP64 = 1 // <predefined>:284:1: X_NETDB_H = 1 // netdb.h:23:1: X_NETINET_IN_H = 1 // in.h:19:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:43:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:44:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:45:1: X_PATH_NSSWITCH_CONF = "/etc/nsswitch.conf" // netdb.h:46:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:47:1: X_PATH_SERVICES = "/etc/services" // netdb.h:48:1: X_POSIX_C_SOURCE = 200809 // features.h:281:1: X_POSIX_SOURCE = 1 // features.h:279:1: X_RPC_NETDB_H = 1 // netdb.h:37:1: X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: X_SIZET_ = 0 // stddef.h:196:1: X_SIZE_T = 0 // stddef.h:183:1: X_SIZE_T_ = 0 // stddef.h:188:1: X_SIZE_T_DECLARED = 0 // stddef.h:193:1: X_SIZE_T_DEFINED = 0 // stddef.h:191:1: X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: X_SS_SIZE = 128 // sockaddr.h:40:1: X_STDC_PREDEF_H = 1 // <predefined>:162:1: X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: X_SYS_CDEFS_H = 1 // cdefs.h:19:1:
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_linux_arm.go
vendor/modernc.org/libc/netdb/netdb_linux_arm.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_arm.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_ALG = 38 AF_APPLETALK = 5 AF_ASH = 18 AF_ATMPVC = 8 AF_ATMSVC = 20 AF_AX25 = 3 AF_BLUETOOTH = 31 AF_BRIDGE = 7 AF_CAIF = 37 AF_CAN = 29 AF_DECnet = 12 AF_ECONET = 19 AF_FILE = 1 AF_IB = 27 AF_IEEE802154 = 36 AF_INET = 2 AF_INET6 = 10 AF_IPX = 4 AF_IRDA = 23 AF_ISDN = 34 AF_IUCV = 32 AF_KCM = 41 AF_KEY = 15 AF_LLC = 26 AF_LOCAL = 1 AF_MAX = 45 AF_MPLS = 28 AF_NETBEUI = 13 AF_NETLINK = 16 AF_NETROM = 6 AF_NFC = 39 AF_PACKET = 17 AF_PHONET = 35 AF_PPPOX = 24 AF_QIPCRTR = 42 AF_RDS = 21 AF_ROSE = 11 AF_ROUTE = 16 AF_RXRPC = 33 AF_SECURITY = 14 AF_SMC = 43 AF_SNA = 22 AF_TIPC = 30 AF_UNIX = 1 AF_UNSPEC = 0 AF_VSOCK = 40 AF_WANPIPE = 25 AF_X25 = 9 AF_XDP = 44 AI_ADDRCONFIG = 0x0020 AI_ALL = 0x0010 AI_CANONNAME = 0x0002 AI_NUMERICHOST = 0x0004 AI_NUMERICSERV = 0x0400 AI_PASSIVE = 0x0001 AI_V4MAPPED = 0x0008 BIG_ENDIAN = 4321 BYTE_ORDER = 1234 EAI_AGAIN = -3 EAI_BADFLAGS = -1 EAI_FAIL = -4 EAI_FAMILY = -6 EAI_MEMORY = -10 EAI_NONAME = -2 EAI_OVERFLOW = -12 EAI_SERVICE = -8 EAI_SOCKTYPE = -7 EAI_SYSTEM = -11 FD_SETSIZE = 1024 FIOGETOWN = 0x8903 FIOSETOWN = 0x8901 HOST_NOT_FOUND = 1 INET6_ADDRSTRLEN = 46 INET_ADDRSTRLEN = 16 IN_CLASSA_HOST = 16777215 IN_CLASSA_MAX = 128 IN_CLASSA_NET = 0xff000000 IN_CLASSA_NSHIFT = 24 IN_CLASSB_HOST = 65535 IN_CLASSB_MAX = 65536 IN_CLASSB_NET = 0xffff0000 IN_CLASSB_NSHIFT = 16 IN_CLASSC_HOST = 255 IN_CLASSC_NET = 0xffffff00 IN_CLASSC_NSHIFT = 8 IN_LOOPBACKNET = 127 IPPORT_RESERVED1 = 1024 IPV6_2292DSTOPTS = 4 IPV6_2292HOPLIMIT = 8 IPV6_2292HOPOPTS = 3 IPV6_2292PKTINFO = 2 IPV6_2292PKTOPTIONS = 6 IPV6_2292RTHDR = 5 IPV6_ADDRFORM = 1 IPV6_ADDR_PREFERENCES = 72 IPV6_ADD_MEMBERSHIP = 20 IPV6_AUTHHDR = 10 IPV6_AUTOFLOWLABEL = 70 IPV6_CHECKSUM = 7 IPV6_DONTFRAG = 62 IPV6_DROP_MEMBERSHIP = 21 IPV6_DSTOPTS = 59 IPV6_FREEBIND = 78 IPV6_HDRINCL = 36 IPV6_HOPLIMIT = 52 IPV6_HOPOPTS = 54 IPV6_IPSEC_POLICY = 34 IPV6_JOIN_ANYCAST = 27 IPV6_JOIN_GROUP = 20 IPV6_LEAVE_ANYCAST = 28 IPV6_LEAVE_GROUP = 21 IPV6_MINHOPCOUNT = 73 IPV6_MTU = 24 IPV6_MTU_DISCOVER = 23 IPV6_MULTICAST_ALL = 29 IPV6_MULTICAST_HOPS = 18 IPV6_MULTICAST_IF = 17 IPV6_MULTICAST_LOOP = 19 IPV6_NEXTHOP = 9 IPV6_ORIGDSTADDR = 74 IPV6_PATHMTU = 61 IPV6_PKTINFO = 50 IPV6_PMTUDISC_DO = 2 IPV6_PMTUDISC_DONT = 0 IPV6_PMTUDISC_INTERFACE = 4 IPV6_PMTUDISC_OMIT = 5 IPV6_PMTUDISC_PROBE = 3 IPV6_PMTUDISC_WANT = 1 IPV6_RECVDSTOPTS = 58 IPV6_RECVERR = 25 IPV6_RECVFRAGSIZE = 77 IPV6_RECVHOPLIMIT = 51 IPV6_RECVHOPOPTS = 53 IPV6_RECVORIGDSTADDR = 74 IPV6_RECVPATHMTU = 60 IPV6_RECVPKTINFO = 49 IPV6_RECVRTHDR = 56 IPV6_RECVTCLASS = 66 IPV6_ROUTER_ALERT = 22 IPV6_ROUTER_ALERT_ISOLATE = 30 IPV6_RTHDR = 57 IPV6_RTHDRDSTOPTS = 55 IPV6_RTHDR_LOOSE = 0 IPV6_RTHDR_STRICT = 1 IPV6_RTHDR_TYPE_0 = 0 IPV6_RXDSTOPTS = 59 IPV6_RXHOPOPTS = 54 IPV6_TCLASS = 67 IPV6_TRANSPARENT = 75 IPV6_UNICAST_HOPS = 16 IPV6_UNICAST_IF = 76 IPV6_V6ONLY = 26 IPV6_XFRM_POLICY = 35 IP_ADD_MEMBERSHIP = 35 IP_ADD_SOURCE_MEMBERSHIP = 39 IP_BIND_ADDRESS_NO_PORT = 24 IP_BLOCK_SOURCE = 38 IP_CHECKSUM = 23 IP_DEFAULT_MULTICAST_LOOP = 1 IP_DEFAULT_MULTICAST_TTL = 1 IP_DROP_MEMBERSHIP = 36 IP_DROP_SOURCE_MEMBERSHIP = 40 IP_FREEBIND = 15 IP_HDRINCL = 3 IP_IPSEC_POLICY = 16 IP_MAX_MEMBERSHIPS = 20 IP_MINTTL = 21 IP_MSFILTER = 41 IP_MTU = 14 IP_MTU_DISCOVER = 10 IP_MULTICAST_ALL = 49 IP_MULTICAST_IF = 32 IP_MULTICAST_LOOP = 34 IP_MULTICAST_TTL = 33 IP_NODEFRAG = 22 IP_OPTIONS = 4 IP_ORIGDSTADDR = 20 IP_PASSSEC = 18 IP_PKTINFO = 8 IP_PKTOPTIONS = 9 IP_PMTUDISC = 10 IP_PMTUDISC_DO = 2 IP_PMTUDISC_DONT = 0 IP_PMTUDISC_INTERFACE = 4 IP_PMTUDISC_OMIT = 5 IP_PMTUDISC_PROBE = 3 IP_PMTUDISC_WANT = 1 IP_RECVERR = 11 IP_RECVFRAGSIZE = 25 IP_RECVOPTS = 6 IP_RECVORIGDSTADDR = 20 IP_RECVRETOPTS = 7 IP_RECVTOS = 13 IP_RECVTTL = 12 IP_RETOPTS = 7 IP_ROUTER_ALERT = 5 IP_TOS = 1 IP_TRANSPARENT = 19 IP_TTL = 2 IP_UNBLOCK_SOURCE = 37 IP_UNICAST_IF = 50 IP_XFRM_POLICY = 17 LITTLE_ENDIAN = 1234 MCAST_BLOCK_SOURCE = 43 MCAST_EXCLUDE = 0 MCAST_INCLUDE = 1 MCAST_JOIN_GROUP = 42 MCAST_JOIN_SOURCE_GROUP = 46 MCAST_LEAVE_GROUP = 45 MCAST_LEAVE_SOURCE_GROUP = 47 MCAST_MSFILTER = 48 MCAST_UNBLOCK_SOURCE = 44 NETDB_INTERNAL = -1 NETDB_SUCCESS = 0 NI_DGRAM = 16 NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 8 NI_NOFQDN = 4 NI_NUMERICHOST = 1 NI_NUMERICSERV = 2 NO_ADDRESS = 4 NO_DATA = 4 NO_RECOVERY = 3 PDP_ENDIAN = 3412 PF_ALG = 38 PF_APPLETALK = 5 PF_ASH = 18 PF_ATMPVC = 8 PF_ATMSVC = 20 PF_AX25 = 3 PF_BLUETOOTH = 31 PF_BRIDGE = 7 PF_CAIF = 37 PF_CAN = 29 PF_DECnet = 12 PF_ECONET = 19 PF_FILE = 1 PF_IB = 27 PF_IEEE802154 = 36 PF_INET = 2 PF_INET6 = 10 PF_IPX = 4 PF_IRDA = 23 PF_ISDN = 34 PF_IUCV = 32 PF_KCM = 41 PF_KEY = 15 PF_LLC = 26 PF_LOCAL = 1 PF_MAX = 45 PF_MPLS = 28 PF_NETBEUI = 13 PF_NETLINK = 16 PF_NETROM = 6 PF_NFC = 39 PF_PACKET = 17 PF_PHONET = 35 PF_PPPOX = 24 PF_QIPCRTR = 42 PF_RDS = 21 PF_ROSE = 11 PF_ROUTE = 16 PF_RXRPC = 33 PF_SECURITY = 14 PF_SMC = 43 PF_SNA = 22 PF_TIPC = 30 PF_UNIX = 1 PF_UNSPEC = 0 PF_VSOCK = 40 PF_WANPIPE = 25 PF_X25 = 9 PF_XDP = 44 SCM_TIMESTAMPING_OPT_STATS = 54 SCM_TIMESTAMPING_PKTINFO = 58 SCM_TXTIME = 61 SCM_WIFI_STATUS = 41 SIOCATMARK = 0x8905 SIOCGPGRP = 0x8904 SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 SIOCSPGRP = 0x8902 SOL_AAL = 265 SOL_ALG = 279 SOL_ATM = 264 SOL_BLUETOOTH = 274 SOL_CAIF = 278 SOL_DCCP = 269 SOL_DECNET = 261 SOL_ICMPV6 = 58 SOL_IP = 0 SOL_IPV6 = 41 SOL_IRDA = 266 SOL_IUCV = 277 SOL_KCM = 281 SOL_LLC = 268 SOL_NETBEUI = 267 SOL_NETLINK = 270 SOL_NFC = 280 SOL_PACKET = 263 SOL_PNPIPE = 275 SOL_PPPOL2TP = 273 SOL_RAW = 255 SOL_RDS = 276 SOL_RXRPC = 272 SOL_SOCKET = 1 SOL_TIPC = 271 SOL_TLS = 282 SOL_X25 = 262 SOL_XDP = 283 SOMAXCONN = 4096 SO_ACCEPTCONN = 30 SO_ATTACH_BPF = 50 SO_ATTACH_FILTER = 26 SO_ATTACH_REUSEPORT_CBPF = 51 SO_ATTACH_REUSEPORT_EBPF = 52 SO_BINDTODEVICE = 25 SO_BINDTOIFINDEX = 62 SO_BPF_EXTENSIONS = 48 SO_BROADCAST = 6 SO_BSDCOMPAT = 14 SO_BUSY_POLL = 46 SO_CNX_ADVICE = 53 SO_COOKIE = 57 SO_DEBUG = 1 SO_DETACH_BPF = 27 SO_DETACH_FILTER = 27 SO_DETACH_REUSEPORT_BPF = 68 SO_DOMAIN = 39 SO_DONTROUTE = 5 SO_ERROR = 4 SO_GET_FILTER = 26 SO_INCOMING_CPU = 49 SO_INCOMING_NAPI_ID = 56 SO_KEEPALIVE = 9 SO_LINGER = 13 SO_LOCK_FILTER = 44 SO_MARK = 36 SO_MAX_PACING_RATE = 47 SO_MEMINFO = 55 SO_NOFCS = 43 SO_NO_CHECK = 11 SO_OOBINLINE = 10 SO_PASSCRED = 16 SO_PASSSEC = 34 SO_PEEK_OFF = 42 SO_PEERCRED = 17 SO_PEERGROUPS = 59 SO_PEERNAME = 28 SO_PEERSEC = 31 SO_PRIORITY = 12 SO_PROTOCOL = 38 SO_RCVBUF = 8 SO_RCVBUFFORCE = 33 SO_RCVLOWAT = 18 SO_RCVTIMEO_NEW = 66 SO_RCVTIMEO_OLD = 20 SO_REUSEADDR = 2 SO_REUSEPORT = 15 SO_RXQ_OVFL = 40 SO_SECURITY_AUTHENTICATION = 22 SO_SECURITY_ENCRYPTION_NETWORK = 24 SO_SECURITY_ENCRYPTION_TRANSPORT = 23 SO_SELECT_ERR_QUEUE = 45 SO_SNDBUF = 7 SO_SNDBUFFORCE = 32 SO_SNDLOWAT = 19 SO_SNDTIMEO_NEW = 67 SO_SNDTIMEO_OLD = 21 SO_TIMESTAMPING_NEW = 65 SO_TIMESTAMPING_OLD = 37 SO_TIMESTAMPNS_NEW = 64 SO_TIMESTAMPNS_OLD = 35 SO_TIMESTAMP_NEW = 63 SO_TIMESTAMP_OLD = 29 SO_TXTIME = 61 SO_TYPE = 3 SO_WIFI_STATUS = 41 SO_ZEROCOPY = 60 TRY_AGAIN = 2 X_ATFILE_SOURCE = 1 X_BITS_BYTESWAP_H = 1 X_BITS_ENDIANNESS_H = 1 X_BITS_ENDIAN_H = 1 X_BITS_PTHREADTYPES_ARCH_H = 1 X_BITS_PTHREADTYPES_COMMON_H = 1 X_BITS_SOCKADDR_H = 1 X_BITS_STDINT_INTN_H = 1 X_BITS_STDINT_UINTN_H = 1 X_BITS_TIME64_H = 1 X_BITS_TYPESIZES_H = 1 X_BITS_TYPES_H = 1 X_BITS_UINTN_IDENTITY_H = 1 X_BSD_SIZE_T_ = 0 X_BSD_SIZE_T_DEFINED_ = 0 X_DEFAULT_SOURCE = 1 X_ENDIAN_H = 1 X_FEATURES_H = 1 X_FILE_OFFSET_BITS = 64 X_GCC_SIZE_T = 0 X_LINUX_POSIX_TYPES_H = 0 X_NETDB_H = 1 X_NETINET_IN_H = 1 X_PATH_HEQUIV = "/etc/hosts.equiv" X_PATH_HOSTS = "/etc/hosts" X_PATH_NETWORKS = "/etc/networks" X_PATH_NSSWITCH_CONF = "/etc/nsswitch.conf" X_PATH_PROTOCOLS = "/etc/protocols" X_PATH_SERVICES = "/etc/services" X_POSIX_C_SOURCE = 200809 X_POSIX_SOURCE = 1 X_RPC_NETDB_H = 1 X_SIZET_ = 0 X_SIZE_T = 0 X_SIZE_T_ = 0 X_SIZE_T_DECLARED = 0 X_SIZE_T_DEFINED = 0 X_SIZE_T_DEFINED_ = 0 X_SS_SIZE = 128 X_STDC_PREDEF_H = 1 X_STRUCT_TIMESPEC = 1 X_SYS_CDEFS_H = 1 X_SYS_SELECT_H = 1 X_SYS_SIZE_T_H = 0 X_SYS_SOCKET_H = 1 X_SYS_TYPES_H = 1 X_THREAD_MUTEX_INTERNAL_H = 1 X_THREAD_SHARED_TYPES_H = 1 X_T_SIZE = 0 X_T_SIZE_ = 0 Linux = 1 Unix = 1 ) // Bits in the FLAGS argument to `send', `recv', et al. const ( /* socket.h:200:1: */ MSG_OOB = 1 // Process out-of-band data. MSG_PEEK = 2 // Peek at incoming messages. MSG_DONTROUTE = 4 // Don't use local routing. MSG_CTRUNC = 8 // Control data lost before delivery. MSG_PROXY = 16 // Supply or ask second address. MSG_TRUNC = 32 MSG_DONTWAIT = 64 // Nonblocking IO. MSG_EOR = 128 // End of record. MSG_WAITALL = 256 // Wait for a full request. MSG_FIN = 512 MSG_SYN = 1024 MSG_CONFIRM = 2048 // Confirm path validity. MSG_RST = 4096 MSG_ERRQUEUE = 8192 // Fetch message from error queue. MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. MSG_MORE = 32768 // Sender will send more. MSG_WAITFORONE = 65536 // Wait for at least one packet to return. MSG_BATCH = 262144 // sendmmsg: more messages coming. MSG_ZEROCOPY = 67108864 // Use user data in kernel path. MSG_FASTOPEN = 536870912 // Send data in TCP SYN. MSG_CMSG_CLOEXEC = 1073741824 ) // Socket level message types. This must match the definitions in // // <linux/socket.h>. const ( /* socket.h:332:1: */ SCM_RIGHTS = 1 ) // Get the architecture-dependent definition of enum __socket_type. // Define enum __socket_type for generic Linux. // Copyright (C) 1991-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // Types of sockets. const ( /* socket_type.h:24:1: */ SOCK_STREAM = 1 // Sequenced, reliable, connection-based // byte streams. SOCK_DGRAM = 2 // Connectionless, unreliable datagrams // of fixed maximum length. SOCK_RAW = 3 // Raw protocol interface. SOCK_RDM = 4 // Reliably-delivered messages. SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, // datagrams of fixed maximum length. SOCK_DCCP = 6 // Datagram Congestion Control Protocol. SOCK_PACKET = 10 // Linux specific way of getting packets // at the dev level. For writing rarp and // other similar things on the user level. // Flags to be ORed into the type parameter of socket and socketpair and // used for the flags parameter of paccept. SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the // new descriptor(s). SOCK_NONBLOCK = 2048 ) // Standard well-known ports. const ( /* in.h:122:1: */ IPPORT_ECHO = 7 // Echo service. IPPORT_DISCARD = 9 // Discard transmissions service. IPPORT_SYSTAT = 11 // System status service. IPPORT_DAYTIME = 13 // Time of day service. IPPORT_NETSTAT = 15 // Network status service. IPPORT_FTP = 21 // File Transfer Protocol. IPPORT_TELNET = 23 // Telnet protocol. IPPORT_SMTP = 25 // Simple Mail Transfer Protocol. IPPORT_TIMESERVER = 37 // Timeserver service. IPPORT_NAMESERVER = 42 // Domain Name Service. IPPORT_WHOIS = 43 // Internet Whois service. IPPORT_MTP = 57 IPPORT_TFTP = 69 // Trivial File Transfer Protocol. IPPORT_RJE = 77 IPPORT_FINGER = 79 // Finger service. IPPORT_TTYLINK = 87 IPPORT_SUPDUP = 95 // SUPDUP protocol. IPPORT_EXECSERVER = 512 // execd service. IPPORT_LOGINSERVER = 513 // rlogind service. IPPORT_CMDSERVER = 514 IPPORT_EFSSERVER = 520 // UDP ports. IPPORT_BIFFUDP = 512 IPPORT_WHOSERVER = 513 IPPORT_ROUTESERVER = 520 // Ports less than this value are reserved for privileged processes. IPPORT_RESERVED = 1024 // Ports greater this value are reserved for (non-privileged) servers. IPPORT_USERRESERVED = 5000 ) // Options for use with `getsockopt' and `setsockopt' at the IPv6 level. // The first word in the comment at the right is the data type used; // "bool" means a boolean value stored in an `int'. // Advanced API (RFC3542) (1). // Advanced API (RFC3542) (2). // RFC5014. // RFC5082. // Obsolete synonyms for the above. // IPV6_MTU_DISCOVER values. // Socket level values for IPv6. // Routing header options for IPv6. // Standard well-defined IP protocols. const ( /* in.h:40:1: */ IPPROTO_IP = 0 // Dummy protocol for TCP. IPPROTO_ICMP = 1 // Internet Control Message Protocol. IPPROTO_IGMP = 2 // Internet Group Management Protocol. IPPROTO_IPIP = 4 // IPIP tunnels (older KA9Q tunnels use 94). IPPROTO_TCP = 6 // Transmission Control Protocol. IPPROTO_EGP = 8 // Exterior Gateway Protocol. IPPROTO_PUP = 12 // PUP protocol. IPPROTO_UDP = 17 // User Datagram Protocol. IPPROTO_IDP = 22 // XNS IDP protocol. IPPROTO_TP = 29 // SO Transport Protocol Class 4. IPPROTO_DCCP = 33 // Datagram Congestion Control Protocol. IPPROTO_IPV6 = 41 // IPv6 header. IPPROTO_RSVP = 46 // Reservation Protocol. IPPROTO_GRE = 47 // General Routing Encapsulation. IPPROTO_ESP = 50 // encapsulating security payload. IPPROTO_AH = 51 // authentication header. IPPROTO_MTP = 92 // Multicast Transport Protocol. IPPROTO_BEETPH = 94 // IP option pseudo header for BEET. IPPROTO_ENCAP = 98 // Encapsulation Header. IPPROTO_PIM = 103 // Protocol Independent Multicast. IPPROTO_COMP = 108 // Compression Header Protocol. IPPROTO_SCTP = 132 // Stream Control Transmission Protocol. IPPROTO_UDPLITE = 136 // UDP-Lite protocol. IPPROTO_MPLS = 137 // MPLS in IP. IPPROTO_RAW = 255 // Raw IP packets. IPPROTO_MAX = 256 ) // If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel // // network headers first and we should use those ABI-identical definitions // instead of our own, otherwise 0. const ( /* in.h:99:1: */ IPPROTO_HOPOPTS = 0 // IPv6 Hop-by-Hop options. IPPROTO_ROUTING = 43 // IPv6 routing header. IPPROTO_FRAGMENT = 44 // IPv6 fragmentation header. IPPROTO_ICMPV6 = 58 // ICMPv6. IPPROTO_NONE = 59 // IPv6 no next header. IPPROTO_DSTOPTS = 60 // IPv6 destination options. IPPROTO_MH = 135 ) // The following constants should be used for the second parameter of // // `shutdown'. const ( /* socket.h:41:1: */ SHUT_RD = 0 // No more receptions. SHUT_WR = 1 // No more transmissions. SHUT_RDWR = 2 ) type Ptrdiff_t = int32 /* <builtin>:3:26 */ type Size_t = uint32 /* <builtin>:9:23 */ type Wchar_t = uint32 /* <builtin>:15:24 */ type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // Copyright (C) 1996-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // All data returned by the network data base library are supplied in // host order and returned in network order (suitable for use in // system calls). // Copyright (C) 1991-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // These are defined by the user (or the compiler) // to specify the desired environment: // // __STRICT_ANSI__ ISO Standard C. // _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. // _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. // _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. // __STDC_WANT_LIB_EXT2__ // Extensions to ISO C99 from TR 27431-2:2010. // __STDC_WANT_IEC_60559_BFP_EXT__ // Extensions to ISO C11 from TS 18661-1:2014. // __STDC_WANT_IEC_60559_FUNCS_EXT__ // Extensions to ISO C11 from TS 18661-4:2015. // __STDC_WANT_IEC_60559_TYPES_EXT__ // Extensions to ISO C11 from TS 18661-3:2015. // // _POSIX_SOURCE IEEE Std 1003.1. // _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; // if >=199309L, add IEEE Std 1003.1b-1993; // if >=199506L, add IEEE Std 1003.1c-1995; // if >=200112L, all of IEEE 1003.1-2004 // if >=200809L, all of IEEE 1003.1-2008 // _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if // Single Unix conformance is wanted, to 600 for the // sixth revision, to 700 for the seventh revision. // _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. // _LARGEFILE_SOURCE Some more functions for correct standard I/O. // _LARGEFILE64_SOURCE Additional functionality from LFS for large files. // _FILE_OFFSET_BITS=N Select default filesystem interface. // _ATFILE_SOURCE Additional *at interfaces. // _GNU_SOURCE All of the above, plus GNU extensions. // _DEFAULT_SOURCE The default set of features (taking precedence over // __STRICT_ANSI__). // // _FORTIFY_SOURCE Add security hardening to many library functions. // Set to 1 or 2; 2 performs stricter checks than 1. // // _REENTRANT, _THREAD_SAFE // Obsolete; equivalent to _POSIX_C_SOURCE=199506L. // // The `-ansi' switch to the GNU C compiler, and standards conformance // options such as `-std=c99', define __STRICT_ANSI__. If none of // these are defined, or if _DEFAULT_SOURCE is defined, the default is // to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to // 200809L, as well as enabling miscellaneous functions from BSD and // SVID. If more than one of these are defined, they accumulate. For // example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together // give you ISO C, 1003.1, and 1003.2, but nothing else. // // These are defined by this file and are used by the // header files to decide what to declare or define: // // __GLIBC_USE (F) Define things from feature set F. This is defined // to 1 or 0; the subsequent macros are either defined // or undefined, and those tests should be moved to // __GLIBC_USE. // __USE_ISOC11 Define ISO C11 things. // __USE_ISOC99 Define ISO C99 things. // __USE_ISOC95 Define ISO C90 AMD1 (C95) things. // __USE_ISOCXX11 Define ISO C++11 things. // __USE_POSIX Define IEEE Std 1003.1 things. // __USE_POSIX2 Define IEEE Std 1003.2 things. // __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. // __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. // __USE_XOPEN Define XPG things. // __USE_XOPEN_EXTENDED Define X/Open Unix things. // __USE_UNIX98 Define Single Unix V2 things. // __USE_XOPEN2K Define XPG6 things. // __USE_XOPEN2KXSI Define XPG6 XSI things. // __USE_XOPEN2K8 Define XPG7 things. // __USE_XOPEN2K8XSI Define XPG7 XSI things. // __USE_LARGEFILE Define correct standard I/O things. // __USE_LARGEFILE64 Define LFS things with separate names. // __USE_FILE_OFFSET64 Define 64bit interface as default. // __USE_MISC Define things from 4.3BSD or System V Unix. // __USE_ATFILE Define *at interfaces and AT_* constants for them. // __USE_GNU Define GNU extensions. // __USE_FORTIFY_LEVEL Additional security measures used, according to level. // // The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are // defined by this file unconditionally. `__GNU_LIBRARY__' is provided // only for compatibility. All new code should use the other symbols // to test for features. // // All macros listed above as possibly being defined by this file are // explicitly undefined if they are not explicitly defined. // Feature-test macros that are not defined by the user or compiler // but are implied by the other feature-test macros defined (or by the // lack of any definitions) are defined by the file. // // ISO C feature test macros depend on the definition of the macro // when an affected header is included, not when the first system // header is included, and so they are handled in // <bits/libc-header-start.h>, which does not have a multiple include // guard. Feature test macros that can be handled from the first // system header included are handled here. // Undefine everything, so we get a clean slate. // Suppress kernel-name space pollution unless user expressedly asks // for it. // Convenience macro to test the version of gcc. // Use like this: // #if __GNUC_PREREQ (2,8) // ... code requiring gcc 2.8 or later ... // #endif // Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was // added in 2.0. // Similarly for clang. Features added to GCC after version 4.2 may // or may not also be available in clang, and clang's definitions of // __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such // features can be queried via __has_extension/__has_feature. // Whether to use feature set F. // _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for // _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not // issue a warning; the expectation is that the source is being // transitioned to use the new macro. // If _GNU_SOURCE was defined by the user, turn on all the other features. // If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, // define _DEFAULT_SOURCE. // This is to enable the ISO C2X extension. // This is to enable the ISO C11 extension. // This is to enable the ISO C99 extension. // This is to enable the ISO C90 Amendment 1:1995 extension. // If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE // is defined, use POSIX.1-2008 (or another version depending on // _XOPEN_SOURCE).
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_linux_arm64.go
vendor/modernc.org/libc/netdb/capi_linux_arm64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_arm64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_freebsd_arm64.go
vendor/modernc.org/libc/netdb/netdb_freebsd_arm64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_freebsd_amd64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AI_ADDRCONFIG = 0x00000400 // netdb.h:200:1: AI_ALL = 0x00000100 // netdb.h:198:1: AI_CANONNAME = 0x00000002 // netdb.h:190:1: AI_DEFAULT = 1536 // netdb.h:203:1: AI_MASK = 3343 // netdb.h:194:1: AI_NUMERICHOST = 0x00000004 // netdb.h:191:1: AI_NUMERICSERV = 0x00000008 // netdb.h:192:1: AI_PASSIVE = 0x00000001 // netdb.h:189:1: AI_V4MAPPED = 0x00000800 // netdb.h:201:1: AI_V4MAPPED_CFG = 0x00000200 // netdb.h:199:1: EAI_AGAIN = 2 // netdb.h:168:1: EAI_BADFLAGS = 3 // netdb.h:169:1: EAI_BADHINTS = 12 // netdb.h:181:1: EAI_FAIL = 4 // netdb.h:170:1: EAI_FAMILY = 5 // netdb.h:171:1: EAI_MAX = 15 // netdb.h:184:1: EAI_MEMORY = 6 // netdb.h:172:1: EAI_NONAME = 8 // netdb.h:177:1: EAI_OVERFLOW = 14 // netdb.h:183:1: EAI_PROTOCOL = 13 // netdb.h:182:1: EAI_SERVICE = 9 // netdb.h:178:1: EAI_SOCKTYPE = 10 // netdb.h:179:1: EAI_SYSTEM = 11 // netdb.h:180:1: HOST_NOT_FOUND = 1 // netdb.h:155:1: IPPORT_RESERVED = 1024 // netdb.h:146:1: NETDB_INTERNAL = -1 // netdb.h:153:1: NETDB_SUCCESS = 0 // netdb.h:154:1: NI_DGRAM = 0x00000010 // netdb.h:218:1: NI_MAXHOST = 1025 // netdb.h:208:1: NI_MAXSERV = 32 // netdb.h:209:1: NI_NAMEREQD = 0x00000004 // netdb.h:216:1: NI_NOFQDN = 0x00000001 // netdb.h:214:1: NI_NUMERICHOST = 0x00000002 // netdb.h:215:1: NI_NUMERICSCOPE = 0x00000020 // netdb.h:219:1: NI_NUMERICSERV = 0x00000008 // netdb.h:217:1: NO_ADDRESS = 4 // netdb.h:159:1: NO_DATA = 4 // netdb.h:158:1: NO_RECOVERY = 3 // netdb.h:157:1: SCOPE_DELIMITER = 37 // netdb.h:224:1: TRY_AGAIN = 2 // netdb.h:156:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_IN_ADDR_T_DECLARED = 0 // netdb.h:67:1: X_IN_PORT_T_DECLARED = 0 // netdb.h:72:1: X_LP64 = 1 // <predefined>:1:1: X_MACHINE__LIMITS_H_ = 0 // _limits.h:36:1: X_MACHINE__TYPES_H_ = 0 // _types.h:42:1: X_NETDB_H_ = 0 // netdb.h:60:1: X_Nonnull = 0 // cdefs.h:790:1: X_Null_unspecified = 0 // cdefs.h:792:1: X_Nullable = 0 // cdefs.h:791:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:91:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:93:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:94:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:95:1: X_PATH_SERVICES = "/etc/services" // netdb.h:96:1: X_PATH_SERVICES_DB = "/var/db/services.db" // netdb.h:97:1: X_SIZE_T_DECLARED = 0 // netdb.h:77:1: X_SOCKLEN_T_DECLARED = 0 // netdb.h:82:1: X_SYS_CDEFS_H_ = 0 // cdefs.h:39:1: X_SYS__TYPES_H_ = 0 // _types.h:32:1: X_UINT32_T_DECLARED = 0 // netdb.h:87:1: Unix = 1 // <predefined>:340:1: ) type Ptrdiff_t = int64 /* <builtin>:3:26 */ type Size_t = uint64 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__int128_t = struct { Flo int64 Fhi int64 } /* <builtin>:21:43 */ // must match modernc.org/mathutil.Int128 type X__uint128_t = struct { Flo uint64 Fhi uint64 } /* <builtin>:22:44 */ // must match modernc.org/mathutil.Int128 type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // - // SPDX-License-Identifier: (BSD-3-Clause AND ISC) // // Copyright (c) 1980, 1983, 1988, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // - // Portions Copyright (c) 1993 by Digital Equipment Corporation. // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies, and that // the name of Digital Equipment Corporation not be used in advertising or // publicity pertaining to distribution of the document or software without // specific, written prior permission. // // THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL // WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT // CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL // DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR // PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS // ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS // SOFTWARE. // - // --Copyright-- // @(#)netdb.h 8.1 (Berkeley) 6/2/93 // From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $ // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 // $FreeBSD$ // Testing against Clang-specific extensions. // This code has been put in place to help reduce the addition of // compiler specific defines in FreeBSD code. It helps to aid in // having a compiler-agnostic source tree. // Compiler memory barriers, specific to gcc and clang. // XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced // Macro to test if we're using a specific version of gcc or later. // The __CONCAT macro is used to concatenate parts of symbol names, e.g. // with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. // The __CONCAT macro is a bit tricky to use if it must work in non-ANSI // mode -- there must be no spaces between its arguments, and for nested // __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also // concatenate double-quoted strings produced by the __STRING macro, but // this only works with ANSI C. // // __XSTRING is like __STRING, but it expands any macros in its argument // first. It is only available with ANSI C. // Compiler-dependent macros to help declare dead (non-returning) and // pure (no side effects) functions, and unused variables. They are // null except for versions of gcc that are known to support the features // properly (old versions of gcc-2 supported the dead and pure features // in a different (wrong) way). If we do not provide an implementation // for a given compiler, let the compile fail if it is told to use // a feature that we cannot live without. // Keywords added in C11. // Emulation of C11 _Generic(). Unlike the previously defined C11 // keywords, it is not possible to implement this using exactly the same // syntax. Therefore implement something similar under the name // __generic(). Unlike _Generic(), this macro can only distinguish // between a single type, so it requires nested invocations to // distinguish multiple cases. // C99 Static array indices in function parameter declarations. Syntax such as: // void bar(int myArray[static 10]); // is allowed in C99 but not in C++. Define __min_size appropriately so // headers using it can be compiled in either language. Use like this: // void bar(int myArray[__min_size(10)]); // XXX: should use `#if __STDC_VERSION__ < 199901'. // C++11 exposes a load of C99 stuff // GCC 2.95 provides `__restrict' as an extension to C90 to support the // C99-specific `restrict' type qualifier. We happen to use `__restrict' as // a way to define the `restrict' type qualifier without disturbing older // software that is unaware of C99 keywords. // GNU C version 2.96 adds explicit branch prediction so that // the CPU back-end can hint the processor and also so that // code blocks can be reordered such that the predicted path // sees a more linear flow, thus improving cache behavior, etc. // // The following two macros provide us with a way to utilize this // compiler feature. Use __predict_true() if you expect the expression // to evaluate to true, and __predict_false() if you expect the // expression to evaluate to false. // // A few notes about usage: // // * Generally, __predict_false() error condition checks (unless // you have some _strong_ reason to do otherwise, in which case // document it), and/or __predict_true() `no-error' condition // checks, assuming you want to optimize for the no-error case. // // * Other than that, if you don't know the likelihood of a test // succeeding from empirical or other `hard' evidence, don't // make predictions. // // * These are meant to be used in places that are run `a lot'. // It is wasteful to make predictions in code that is run // seldomly (e.g. at subsystem initialization time) as the // basic block reordering that this affects can often generate // larger code. // We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h> // require it. // Given the pointer x to the member m of the struct s, return // a pointer to the containing structure. When using GCC, we first // assign pointer x to a local variable, to check that its type is // compatible with member m. // Compiler-dependent macros to declare that functions take printf-like // or scanf-like arguments. They are null except for versions of gcc // that are known to support the features properly (old versions of gcc-2 // didn't permit keeping the keywords out of the application namespace). // Compiler-dependent macros that rely on FreeBSD-specific extensions. // Embed the rcs id of a source file in the resulting library. Note that in // more recent ELF binutils, we use .ident allowing the ID to be stripped. // Usage: // __FBSDID("$FreeBSD$"); // - // The following definitions are an extension of the behavior originally // implemented in <sys/_posix.h>, but with a different level of granularity. // POSIX.1 requires that the macros we test be defined before any standard // header file is included. // // Here's a quick run-down of the versions: // defined(_POSIX_SOURCE) 1003.1-1988 // _POSIX_C_SOURCE == 1 1003.1-1990 // _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option // _POSIX_C_SOURCE == 199309 1003.1b-1993 // _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, // and the omnibus ISO/IEC 9945-1: 1996 // _POSIX_C_SOURCE == 200112 1003.1-2001 // _POSIX_C_SOURCE == 200809 1003.1-2008 // // In addition, the X/Open Portability Guide, which is now the Single UNIX // Specification, defines a feature-test macro which indicates the version of // that specification, and which subsumes _POSIX_C_SOURCE. // // Our macros begin with two underscores to avoid namespace screwage. // Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. // Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. // Deal with various X/Open Portability Guides and Single UNIX Spec. // Deal with all versions of POSIX. The ordering relative to the tests above is // important. // - // Deal with _ANSI_SOURCE: // If it is defined, and no other compilation environment is explicitly // requested, then define our internal feature-test macros to zero. This // makes no difference to the preprocessor (undefined symbols in preprocessing // expressions are defined to have value zero), but makes it more convenient for // a test program to print out the values. // // If a program mistakenly defines _ANSI_SOURCE and some other macro such as // _POSIX_C_SOURCE, we will assume that it wants the broader compilation // environment (and in fact we will never get here). // User override __EXT1_VISIBLE // Old versions of GCC use non-standard ARM arch symbols; acle-compat.h // translates them to __ARM_ARCH and the modern feature symbols defined by ARM. // Nullability qualifiers: currently only supported by Clang. // Type Safety Checking // // Clang provides additional attributes to enable checking type safety // properties that cannot be enforced by the C type system. // Lock annotations. // // Clang provides support for doing basic thread-safety tests at // compile-time, by marking which locks will/should be held when // entering/leaving a functions. // // Furthermore, it is also possible to annotate variables and structure // members to enforce that they are only accessed when certain locks are // held. // Structure implements a lock. // Function acquires an exclusive or shared lock. // Function attempts to acquire an exclusive or shared lock. // Function releases a lock. // Function asserts that an exclusive or shared lock is held. // Function requires that an exclusive or shared lock is or is not held. // Function should not be analyzed. // Function or variable should not be sanitized, e.g., by AddressSanitizer. // GCC has the nosanitize attribute, but as a function attribute only, and // warns on use as a variable attribute. // Guard variables and structure members by lock. // Alignment builtins for better type checking and improved code generation. // Provide fallback versions for other compilers (GCC/Clang < 10): // - // SPDX-License-Identifier: BSD-2-Clause-FreeBSD // // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 // $FreeBSD$ // - // This file is in the public domain. // $FreeBSD$ // - // SPDX-License-Identifier: BSD-4-Clause // // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> // Copyright (c) 1990, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. All advertising materials mentioning features or use of this software // must display the following acknowledgement: // This product includes software developed by the University of // California, Berkeley and its contributors. // 4. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 // From: @(#)types.h 8.3 (Berkeley) 1/5/94 // $FreeBSD$ // - // This file is in the public domain. // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1988, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)limits.h 8.3 (Berkeley) 1/4/94 // $FreeBSD$ // According to ANSI (section 2.2.4.2), the values below must be usable by // #if preprocessing directives. Additionally, the expression must have the // same type as would an expression that is an object of the corresponding // type converted according to the integral promotions. The subtraction for // INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an // unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). // max value for an unsigned long long // Quads and longs are the same on the amd64. Ensure they stay in sync. // Minimum signal stack size. // Basic types upon which most other types are built. type X__int8_t = int8 /* _types.h:55:22 */ type X__uint8_t = uint8 /* _types.h:56:24 */ type X__int16_t = int16 /* _types.h:57:17 */ type X__uint16_t = uint16 /* _types.h:58:25 */ type X__int32_t = int32 /* _types.h:59:15 */ type X__uint32_t = uint32 /* _types.h:60:23 */ type X__int64_t = int64 /* _types.h:62:16 */ type X__uint64_t = uint64 /* _types.h:63:24 */ // Standard type definitions. type X__clock_t = X__int32_t /* _types.h:75:19 */ // clock()... type X__critical_t = X__int64_t /* _types.h:76:19 */ type X__double_t = float64 /* _types.h:78:17 */ type X__float_t = float32 /* _types.h:79:16 */ type X__intfptr_t = X__int64_t /* _types.h:81:19 */ type X__intptr_t = X__int64_t /* _types.h:82:19 */ type X__intmax_t = X__int64_t /* _types.h:93:19 */ type X__int_fast8_t = X__int32_t /* _types.h:94:19 */ type X__int_fast16_t = X__int32_t /* _types.h:95:19 */ type X__int_fast32_t = X__int32_t /* _types.h:96:19 */ type X__int_fast64_t = X__int64_t /* _types.h:97:19 */ type X__int_least8_t = X__int8_t /* _types.h:98:18 */ type X__int_least16_t = X__int16_t /* _types.h:99:19 */ type X__int_least32_t = X__int32_t /* _types.h:100:19 */ type X__int_least64_t = X__int64_t /* _types.h:101:19 */ type X__ptrdiff_t = X__int64_t /* _types.h:103:19 */ // ptr1 - ptr2 type X__register_t = X__int64_t /* _types.h:104:19 */ type X__segsz_t = X__int64_t /* _types.h:105:19 */ // segment size (in pages) type X__size_t = X__uint64_t /* _types.h:106:20 */ // sizeof() type X__ssize_t = X__int64_t /* _types.h:107:19 */ // byte count or error type X__time_t = X__int64_t /* _types.h:108:19 */ // time()... type X__uintfptr_t = X__uint64_t /* _types.h:109:20 */ type X__uintptr_t = X__uint64_t /* _types.h:110:20 */ type X__uintmax_t = X__uint64_t /* _types.h:121:20 */ type X__uint_fast8_t = X__uint32_t /* _types.h:122:20 */ type X__uint_fast16_t = X__uint32_t /* _types.h:123:20 */ type X__uint_fast32_t = X__uint32_t /* _types.h:124:20 */ type X__uint_fast64_t = X__uint64_t /* _types.h:125:20 */ type X__uint_least8_t = X__uint8_t /* _types.h:126:19 */ type X__uint_least16_t = X__uint16_t /* _types.h:127:20 */ type X__uint_least32_t = X__uint32_t /* _types.h:128:20 */ type X__uint_least64_t = X__uint64_t /* _types.h:129:20 */ type X__u_register_t = X__uint64_t /* _types.h:131:20 */ type X__vm_offset_t = X__uint64_t /* _types.h:132:20 */ type X__vm_paddr_t = X__uint64_t /* _types.h:133:20 */ type X__vm_size_t = X__uint64_t /* _types.h:134:20 */ type X___wchar_t = int32 /* _types.h:141:14 */ // Standard type definitions. type X__blksize_t = X__int32_t /* _types.h:40:19 */ // file block size type X__blkcnt_t = X__int64_t /* _types.h:41:19 */ // file block count type X__clockid_t = X__int32_t /* _types.h:42:19 */ // clock_gettime()... type X__fflags_t = X__uint32_t /* _types.h:43:20 */ // file flags type X__fsblkcnt_t = X__uint64_t /* _types.h:44:20 */ type X__fsfilcnt_t = X__uint64_t /* _types.h:45:20 */ type X__gid_t = X__uint32_t /* _types.h:46:20 */ type X__id_t = X__int64_t /* _types.h:47:19 */ // can hold a gid_t, pid_t, or uid_t type X__ino_t = X__uint64_t /* _types.h:48:20 */ // inode number type X__key_t = int64 /* _types.h:49:15 */ // IPC key (for Sys V IPC) type X__lwpid_t = X__int32_t /* _types.h:50:19 */ // Thread ID (a.k.a. LWP) type X__mode_t = X__uint16_t /* _types.h:51:20 */ // permissions type X__accmode_t = int32 /* _types.h:52:14 */ // access permissions type X__nl_item = int32 /* _types.h:53:14 */ type X__nlink_t = X__uint64_t /* _types.h:54:20 */ // link count type X__off_t = X__int64_t /* _types.h:55:19 */ // file offset type X__off64_t = X__int64_t /* _types.h:56:19 */ // file offset (alias) type X__pid_t = X__int32_t /* _types.h:57:19 */ // process [group] type X__rlim_t = X__int64_t /* _types.h:58:19 */ // resource limit - intentionally // signed, because of legacy code // that uses -1 for RLIM_INFINITY type X__sa_family_t = X__uint8_t /* _types.h:61:19 */ type X__socklen_t = X__uint32_t /* _types.h:62:20 */ type X__suseconds_t = int64 /* _types.h:63:15 */ // microseconds (signed) type X__timer_t = uintptr /* _types.h:64:24 */ // timer_gettime()... type X__mqd_t = uintptr /* _types.h:65:21 */ // mq_open()... type X__uid_t = X__uint32_t /* _types.h:66:20 */ type X__useconds_t = uint32 /* _types.h:67:22 */ // microseconds (unsigned) type X__cpuwhich_t = int32 /* _types.h:68:14 */ // which parameter for cpuset. type X__cpulevel_t = int32 /* _types.h:69:14 */ // level parameter for cpuset. type X__cpusetid_t = int32 /* _types.h:70:14 */ // cpuset identifier. type X__daddr_t = X__int64_t /* _types.h:71:19 */ // bwrite(3), FIOBMAP2, etc // Unusual type definitions. // rune_t is declared to be an “int” instead of the more natural // “unsigned long” or “long”. Two things are happening here. It is not // unsigned so that EOF (-1) can be naturally assigned to it and used. Also, // it looks like 10646 will be a 31 bit standard. This means that if your // ints cannot hold 32 bits, you will be in trouble. The reason an int was // chosen over a long is that the is*() and to*() routines take ints (says // ANSI C), but they use __ct_rune_t instead of int. // // NOTE: rune_t is not covered by ANSI nor other standards, and should not // be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and // rune_t must be the same type. Also, wint_t should be able to hold all // members of the largest character set plus one extra value (WEOF), and // must be at least 16 bits. type X__ct_rune_t = int32 /* _types.h:91:14 */ // arg type for ctype funcs type X__rune_t = X__ct_rune_t /* _types.h:92:21 */ // rune_t (see above) type X__wint_t = X__ct_rune_t /* _types.h:93:21 */ // wint_t (see above) // Clang already provides these types as built-ins, but only in C++ mode. type X__char16_t = X__uint_least16_t /* _types.h:97:26 */ type X__char32_t = X__uint_least32_t /* _types.h:98:26 */ // In C++11, char16_t and char32_t are built-in types. type X__max_align_t = struct { F__max_align1 int64 F__max_align2 float64 } /* _types.h:111:3 */ type X__dev_t = X__uint64_t /* _types.h:113:20 */ // device number type X__fixpt_t = X__uint32_t /* _types.h:115:20 */ // fixed point number // mbstate_t is an opaque object to keep conversion state during multibyte // stream conversions. type X__mbstate_t = struct { F__ccgo_pad1 [0]uint64 F__mbstate8 [128]int8 } /* _types.h:124:3 */ type X__rman_res_t = X__uintmax_t /* _types.h:126:25 */ // Types for varargs. These are all provided by builtin types these // days, so centralize their definition. type X__va_list = X__builtin_va_list /* _types.h:133:27 */ // internally known to gcc type X__gnuc_va_list = X__va_list /* _types.h:140:20 */ // compatibility w/GNU headers // When the following macro is defined, the system uses 64-bit inode numbers. // Programs can use this to avoid including <sys/param.h>, with its associated // namespace pollution. type In_addr_t = X__uint32_t /* netdb.h:66:20 */ type In_port_t = X__uint16_t /* netdb.h:71:20 */ type Socklen_t = X__socklen_t /* netdb.h:81:21 */ type Uint32_t = X__uint32_t /* netdb.h:86:20 */ // Structures returned by network data base library. All addresses are
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_linux_mips64le.go
vendor/modernc.org/libc/netdb/netdb_linux_mips64le.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_linux_amd64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_ALG = 38 // socket.h:133:1: AF_APPLETALK = 5 // socket.h:99:1: AF_ASH = 18 // socket.h:113:1: AF_ATMPVC = 8 // socket.h:102:1: AF_ATMSVC = 20 // socket.h:115:1: AF_AX25 = 3 // socket.h:97:1: AF_BLUETOOTH = 31 // socket.h:126:1: AF_BRIDGE = 7 // socket.h:101:1: AF_CAIF = 37 // socket.h:132:1: AF_CAN = 29 // socket.h:124:1: AF_DECnet = 12 // socket.h:106:1: AF_ECONET = 19 // socket.h:114:1: AF_FILE = 1 // socket.h:95:1: AF_IB = 27 // socket.h:122:1: AF_IEEE802154 = 36 // socket.h:131:1: AF_INET = 2 // socket.h:96:1: AF_INET6 = 10 // socket.h:104:1: AF_IPX = 4 // socket.h:98:1: AF_IRDA = 23 // socket.h:118:1: AF_ISDN = 34 // socket.h:129:1: AF_IUCV = 32 // socket.h:127:1: AF_KCM = 41 // socket.h:136:1: AF_KEY = 15 // socket.h:109:1: AF_LLC = 26 // socket.h:121:1: AF_LOCAL = 1 // socket.h:93:1: AF_MAX = 45 // socket.h:140:1: AF_MPLS = 28 // socket.h:123:1: AF_NETBEUI = 13 // socket.h:107:1: AF_NETLINK = 16 // socket.h:110:1: AF_NETROM = 6 // socket.h:100:1: AF_NFC = 39 // socket.h:134:1: AF_PACKET = 17 // socket.h:112:1: AF_PHONET = 35 // socket.h:130:1: AF_PPPOX = 24 // socket.h:119:1: AF_QIPCRTR = 42 // socket.h:137:1: AF_RDS = 21 // socket.h:116:1: AF_ROSE = 11 // socket.h:105:1: AF_ROUTE = 16 // socket.h:111:1: AF_RXRPC = 33 // socket.h:128:1: AF_SECURITY = 14 // socket.h:108:1: AF_SMC = 43 // socket.h:138:1: AF_SNA = 22 // socket.h:117:1: AF_TIPC = 30 // socket.h:125:1: AF_UNIX = 1 // socket.h:94:1: AF_UNSPEC = 0 // socket.h:92:1: AF_VSOCK = 40 // socket.h:135:1: AF_WANPIPE = 25 // socket.h:120:1: AF_X25 = 9 // socket.h:103:1: AF_XDP = 44 // socket.h:139:1: AI_ADDRCONFIG = 0x0020 // netdb.h:601:1: AI_ALL = 0x0010 // netdb.h:600:1: AI_CANONNAME = 0x0002 // netdb.h:597:1: AI_NUMERICHOST = 0x0004 // netdb.h:598:1: AI_NUMERICSERV = 0x0400 // netdb.h:613:1: AI_PASSIVE = 0x0001 // netdb.h:596:1: AI_V4MAPPED = 0x0008 // netdb.h:599:1: BIG_ENDIAN = 4321 // endian.h:28:1: BYTE_ORDER = 1234 // endian.h:30:1: EAI_AGAIN = -3 // netdb.h:618:1: EAI_BADFLAGS = -1 // netdb.h:616:1: EAI_FAIL = -4 // netdb.h:619:1: EAI_FAMILY = -6 // netdb.h:620:1: EAI_MEMORY = -10 // netdb.h:623:1: EAI_NONAME = -2 // netdb.h:617:1: EAI_OVERFLOW = -12 // netdb.h:625:1: EAI_SERVICE = -8 // netdb.h:622:1: EAI_SOCKTYPE = -7 // netdb.h:621:1: EAI_SYSTEM = -11 // netdb.h:624:1: FD_SETSIZE = 1024 // select.h:73:1: FIOGETOWN = 0x8903 // sockios.h:8:1: FIOSETOWN = 0x8901 // sockios.h:6:1: HOST_NOT_FOUND = 1 // netdb.h:63:1: INET6_ADDRSTRLEN = 46 // in.h:234:1: INET_ADDRSTRLEN = 16 // in.h:233:1: IN_CLASSA_HOST = 16777215 // in.h:169:1: IN_CLASSA_MAX = 128 // in.h:170:1: IN_CLASSA_NET = 0xff000000 // in.h:167:1: IN_CLASSA_NSHIFT = 24 // in.h:168:1: IN_CLASSB_HOST = 65535 // in.h:175:1: IN_CLASSB_MAX = 65536 // in.h:176:1: IN_CLASSB_NET = 0xffff0000 // in.h:173:1: IN_CLASSB_NSHIFT = 16 // in.h:174:1: IN_CLASSC_HOST = 255 // in.h:181:1: IN_CLASSC_NET = 0xffffff00 // in.h:179:1: IN_CLASSC_NSHIFT = 8 // in.h:180:1: IN_LOOPBACKNET = 127 // in.h:197:1: IPPORT_RESERVED1 = 1024 // netdb.h:79:1: IPV6_2292DSTOPTS = 4 // in.h:171:1: IPV6_2292HOPLIMIT = 8 // in.h:175:1: IPV6_2292HOPOPTS = 3 // in.h:170:1: IPV6_2292PKTINFO = 2 // in.h:169:1: IPV6_2292PKTOPTIONS = 6 // in.h:173:1: IPV6_2292RTHDR = 5 // in.h:172:1: IPV6_ADDRFORM = 1 // in.h:168:1: IPV6_ADDR_PREFERENCES = 72 // in.h:223:1: IPV6_ADD_MEMBERSHIP = 20 // in.h:237:1: IPV6_AUTHHDR = 10 // in.h:180:1: IPV6_AUTOFLOWLABEL = 70 // in.h:220:1: IPV6_CHECKSUM = 7 // in.h:174:1: IPV6_DONTFRAG = 62 // in.h:214:1: IPV6_DROP_MEMBERSHIP = 21 // in.h:238:1: IPV6_DSTOPTS = 59 // in.h:211:1: IPV6_FREEBIND = 78 // in.h:233:1: IPV6_HDRINCL = 36 // in.h:198:1: IPV6_HOPLIMIT = 52 // in.h:204:1: IPV6_HOPOPTS = 54 // in.h:206:1: IPV6_IPSEC_POLICY = 34 // in.h:196:1: IPV6_JOIN_ANYCAST = 27 // in.h:192:1: IPV6_JOIN_GROUP = 20 // in.h:185:1: IPV6_LEAVE_ANYCAST = 28 // in.h:193:1: IPV6_LEAVE_GROUP = 21 // in.h:186:1: IPV6_MINHOPCOUNT = 73 // in.h:226:1: IPV6_MTU = 24 // in.h:189:1: IPV6_MTU_DISCOVER = 23 // in.h:188:1: IPV6_MULTICAST_ALL = 29 // in.h:194:1: IPV6_MULTICAST_HOPS = 18 // in.h:183:1: IPV6_MULTICAST_IF = 17 // in.h:182:1: IPV6_MULTICAST_LOOP = 19 // in.h:184:1: IPV6_NEXTHOP = 9 // in.h:179:1: IPV6_ORIGDSTADDR = 74 // in.h:228:1: IPV6_PATHMTU = 61 // in.h:213:1: IPV6_PKTINFO = 50 // in.h:202:1: IPV6_PMTUDISC_DO = 2 // in.h:246:1: IPV6_PMTUDISC_DONT = 0 // in.h:244:1: IPV6_PMTUDISC_INTERFACE = 4 // in.h:248:1: IPV6_PMTUDISC_OMIT = 5 // in.h:249:1: IPV6_PMTUDISC_PROBE = 3 // in.h:247:1: IPV6_PMTUDISC_WANT = 1 // in.h:245:1: IPV6_RECVDSTOPTS = 58 // in.h:210:1: IPV6_RECVERR = 25 // in.h:190:1: IPV6_RECVFRAGSIZE = 77 // in.h:232:1: IPV6_RECVHOPLIMIT = 51 // in.h:203:1: IPV6_RECVHOPOPTS = 53 // in.h:205:1: IPV6_RECVORIGDSTADDR = 74 // in.h:229:1: IPV6_RECVPATHMTU = 60 // in.h:212:1: IPV6_RECVPKTINFO = 49 // in.h:201:1: IPV6_RECVRTHDR = 56 // in.h:208:1: IPV6_RECVTCLASS = 66 // in.h:217:1: IPV6_ROUTER_ALERT = 22 // in.h:187:1: IPV6_ROUTER_ALERT_ISOLATE = 30 // in.h:195:1: IPV6_RTHDR = 57 // in.h:209:1: IPV6_RTHDRDSTOPTS = 55 // in.h:207:1: IPV6_RTHDR_LOOSE = 0 // in.h:256:1: IPV6_RTHDR_STRICT = 1 // in.h:257:1: IPV6_RTHDR_TYPE_0 = 0 // in.h:259:1: IPV6_RXDSTOPTS = 59 // in.h:241:1: IPV6_RXHOPOPTS = 54 // in.h:240:1: IPV6_TCLASS = 67 // in.h:218:1: IPV6_TRANSPARENT = 75 // in.h:230:1: IPV6_UNICAST_HOPS = 16 // in.h:181:1: IPV6_UNICAST_IF = 76 // in.h:231:1: IPV6_V6ONLY = 26 // in.h:191:1: IPV6_XFRM_POLICY = 35 // in.h:197:1: IP_ADD_MEMBERSHIP = 35 // in.h:121:1: IP_ADD_SOURCE_MEMBERSHIP = 39 // in.h:125:1: IP_BIND_ADDRESS_NO_PORT = 24 // in.h:103:1: IP_BLOCK_SOURCE = 38 // in.h:124:1: IP_CHECKSUM = 23 // in.h:102:1: IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:135:1: IP_DEFAULT_MULTICAST_TTL = 1 // in.h:134:1: IP_DROP_MEMBERSHIP = 36 // in.h:122:1: IP_DROP_SOURCE_MEMBERSHIP = 40 // in.h:126:1: IP_FREEBIND = 15 // in.h:89:1: IP_HDRINCL = 3 // in.h:48:1: IP_IPSEC_POLICY = 16 // in.h:90:1: IP_MAX_MEMBERSHIPS = 20 // in.h:136:1: IP_MINTTL = 21 // in.h:100:1: IP_MSFILTER = 41 // in.h:127:1: IP_MTU = 14 // in.h:88:1: IP_MTU_DISCOVER = 10 // in.h:84:1: IP_MULTICAST_ALL = 49 // in.h:128:1: IP_MULTICAST_IF = 32 // in.h:118:1: IP_MULTICAST_LOOP = 34 // in.h:120:1: IP_MULTICAST_TTL = 33 // in.h:119:1: IP_NODEFRAG = 22 // in.h:101:1: IP_OPTIONS = 4 // in.h:47:1: IP_ORIGDSTADDR = 20 // in.h:97:1: IP_PASSSEC = 18 // in.h:92:1: IP_PKTINFO = 8 // in.h:81:1: IP_PKTOPTIONS = 9 // in.h:82:1: IP_PMTUDISC = 10 // in.h:83:1: IP_PMTUDISC_DO = 2 // in.h:109:1: IP_PMTUDISC_DONT = 0 // in.h:107:1: IP_PMTUDISC_INTERFACE = 4 // in.h:114:1: IP_PMTUDISC_OMIT = 5 // in.h:116:1: IP_PMTUDISC_PROBE = 3 // in.h:110:1: IP_PMTUDISC_WANT = 1 // in.h:108:1: IP_RECVERR = 11 // in.h:85:1: IP_RECVFRAGSIZE = 25 // in.h:104:1: IP_RECVOPTS = 6 // in.h:51:1: IP_RECVORIGDSTADDR = 20 // in.h:98:1: IP_RECVRETOPTS = 7 // in.h:53:1: IP_RECVTOS = 13 // in.h:87:1: IP_RECVTTL = 12 // in.h:86:1: IP_RETOPTS = 7 // in.h:54:1: IP_ROUTER_ALERT = 5 // in.h:80:1: IP_TOS = 1 // in.h:49:1: IP_TRANSPARENT = 19 // in.h:93:1: IP_TTL = 2 // in.h:50:1: IP_UNBLOCK_SOURCE = 37 // in.h:123:1: IP_UNICAST_IF = 50 // in.h:129:1: IP_XFRM_POLICY = 17 // in.h:91:1: LITTLE_ENDIAN = 1234 // endian.h:27:1: MCAST_BLOCK_SOURCE = 43 // in.h:67:1: MCAST_EXCLUDE = 0 // in.h:76:1: MCAST_INCLUDE = 1 // in.h:77:1: MCAST_JOIN_GROUP = 42 // in.h:66:1: MCAST_JOIN_SOURCE_GROUP = 46 // in.h:70:1: MCAST_LEAVE_GROUP = 45 // in.h:69:1: MCAST_LEAVE_SOURCE_GROUP = 47 // in.h:71:1: MCAST_MSFILTER = 48 // in.h:72:1: MCAST_UNBLOCK_SOURCE = 44 // in.h:68:1: NETDB_INTERNAL = -1 // netdb.h:72:1: NETDB_SUCCESS = 0 // netdb.h:73:1: NI_DGRAM = 16 // netdb.h:646:1: NI_MAXHOST = 1025 // netdb.h:638:1: NI_MAXSERV = 32 // netdb.h:639:1: NI_NAMEREQD = 8 // netdb.h:645:1: NI_NOFQDN = 4 // netdb.h:644:1: NI_NUMERICHOST = 1 // netdb.h:642:1: NI_NUMERICSERV = 2 // netdb.h:643:1: NO_ADDRESS = 4 // netdb.h:74:1: NO_DATA = 4 // netdb.h:68:1: NO_RECOVERY = 3 // netdb.h:66:1: PDP_ENDIAN = 3412 // endian.h:29:1: PF_ALG = 38 // socket.h:82:1: PF_APPLETALK = 5 // socket.h:48:1: PF_ASH = 18 // socket.h:62:1: PF_ATMPVC = 8 // socket.h:51:1: PF_ATMSVC = 20 // socket.h:64:1: PF_AX25 = 3 // socket.h:46:1: PF_BLUETOOTH = 31 // socket.h:75:1: PF_BRIDGE = 7 // socket.h:50:1: PF_CAIF = 37 // socket.h:81:1: PF_CAN = 29 // socket.h:73:1: PF_DECnet = 12 // socket.h:55:1: PF_ECONET = 19 // socket.h:63:1: PF_FILE = 1 // socket.h:44:1: PF_IB = 27 // socket.h:71:1: PF_IEEE802154 = 36 // socket.h:80:1: PF_INET = 2 // socket.h:45:1: PF_INET6 = 10 // socket.h:53:1: PF_IPX = 4 // socket.h:47:1: PF_IRDA = 23 // socket.h:67:1: PF_ISDN = 34 // socket.h:78:1: PF_IUCV = 32 // socket.h:76:1: PF_KCM = 41 // socket.h:85:1: PF_KEY = 15 // socket.h:58:1: PF_LLC = 26 // socket.h:70:1: PF_LOCAL = 1 // socket.h:42:1: PF_MAX = 45 // socket.h:89:1: PF_MPLS = 28 // socket.h:72:1: PF_NETBEUI = 13 // socket.h:56:1: PF_NETLINK = 16 // socket.h:59:1: PF_NETROM = 6 // socket.h:49:1: PF_NFC = 39 // socket.h:83:1: PF_PACKET = 17 // socket.h:61:1: PF_PHONET = 35 // socket.h:79:1: PF_PPPOX = 24 // socket.h:68:1: PF_QIPCRTR = 42 // socket.h:86:1: PF_RDS = 21 // socket.h:65:1: PF_ROSE = 11 // socket.h:54:1: PF_ROUTE = 16 // socket.h:60:1: PF_RXRPC = 33 // socket.h:77:1: PF_SECURITY = 14 // socket.h:57:1: PF_SMC = 43 // socket.h:87:1: PF_SNA = 22 // socket.h:66:1: PF_TIPC = 30 // socket.h:74:1: PF_UNIX = 1 // socket.h:43:1: PF_UNSPEC = 0 // socket.h:41:1: PF_VSOCK = 40 // socket.h:84:1: PF_WANPIPE = 25 // socket.h:69:1: PF_X25 = 9 // socket.h:52:1: PF_XDP = 44 // socket.h:88:1: SCM_TIMESTAMP = 29 // socket.h:140:1: SCM_TIMESTAMPING = 37 // socket.h:142:1: SCM_TIMESTAMPING_OPT_STATS = 54 // socket.h:90:1: SCM_TIMESTAMPING_PKTINFO = 58 // socket.h:98:1: SCM_TIMESTAMPNS = 35 // socket.h:141:1: SCM_TXTIME = 61 // socket.h:105:1: SCM_WIFI_STATUS = 41 // socket.h:64:1: SIOCATMARK = 0x8905 // sockios.h:10:1: SIOCGPGRP = 0x8904 // sockios.h:9:1: SIOCGSTAMP = 0x8906 // sockios.h:11:1: SIOCGSTAMPNS = 0x8907 // sockios.h:12:1: SIOCSPGRP = 0x8902 // sockios.h:7:1: SOL_AAL = 265 // socket.h:151:1: SOL_ALG = 279 // socket.h:165:1: SOL_ATM = 264 // socket.h:150:1: SOL_BLUETOOTH = 274 // socket.h:160:1: SOL_CAIF = 278 // socket.h:164:1: SOL_DCCP = 269 // socket.h:155:1: SOL_DECNET = 261 // socket.h:147:1: SOL_ICMPV6 = 58 // in.h:253:1: SOL_IP = 0 // in.h:132:1: SOL_IPV6 = 41 // in.h:252:1: SOL_IRDA = 266 // socket.h:152:1: SOL_IUCV = 277 // socket.h:163:1: SOL_KCM = 281 // socket.h:167:1: SOL_LLC = 268 // socket.h:154:1: SOL_NETBEUI = 267 // socket.h:153:1: SOL_NETLINK = 270 // socket.h:156:1: SOL_NFC = 280 // socket.h:166:1: SOL_PACKET = 263 // socket.h:149:1: SOL_PNPIPE = 275 // socket.h:161:1: SOL_PPPOL2TP = 273 // socket.h:159:1: SOL_RAW = 255 // socket.h:146:1: SOL_RDS = 276 // socket.h:162:1: SOL_RXRPC = 272 // socket.h:158:1: SOL_SOCKET = 1 // socket.h:9:1: SOL_TIPC = 271 // socket.h:157:1: SOL_TLS = 282 // socket.h:168:1: SOL_X25 = 262 // socket.h:148:1: SOL_XDP = 283 // socket.h:169:1: SOMAXCONN = 4096 // socket.h:172:1: SO_ACCEPTCONN = 30 // socket.h:51:1: SO_ATTACH_BPF = 50 // socket.h:82:1: SO_ATTACH_FILTER = 26 // socket.h:45:1: SO_ATTACH_REUSEPORT_CBPF = 51 // socket.h:85:1: SO_ATTACH_REUSEPORT_EBPF = 52 // socket.h:86:1: SO_BINDTODEVICE = 25 // socket.h:42:1: SO_BINDTOIFINDEX = 62 // socket.h:107:1: SO_BPF_EXTENSIONS = 48 // socket.h:78:1: SO_BROADCAST = 6 // socket.h:16:1: SO_BSDCOMPAT = 14 // socket.h:26:1: SO_BUSY_POLL = 46 // socket.h:74:1: SO_CNX_ADVICE = 53 // socket.h:88:1: SO_COOKIE = 57 // socket.h:96:1: SO_DEBUG = 1 // socket.h:11:1: SO_DETACH_BPF = 27 // socket.h:83:1: SO_DETACH_FILTER = 27 // socket.h:46:1: SO_DETACH_REUSEPORT_BPF = 68 // socket.h:120:1: SO_DOMAIN = 39 // socket.h:59:1: SO_DONTROUTE = 5 // socket.h:15:1: SO_ERROR = 4 // socket.h:14:1: SO_GET_FILTER = 26 // socket.h:47:1: SO_INCOMING_CPU = 49 // socket.h:80:1: SO_INCOMING_NAPI_ID = 56 // socket.h:94:1: SO_KEEPALIVE = 9 // socket.h:21:1: SO_LINGER = 13 // socket.h:25:1: SO_LOCK_FILTER = 44 // socket.h:70:1: SO_MARK = 36 // socket.h:56:1: SO_MAX_PACING_RATE = 47 // socket.h:76:1: SO_MEMINFO = 55 // socket.h:92:1: SO_NOFCS = 43 // socket.h:68:1: SO_NO_CHECK = 11 // socket.h:23:1: SO_OOBINLINE = 10 // socket.h:22:1: SO_PASSCRED = 16 // socket.h:29:1: SO_PASSSEC = 34 // socket.h:54:1: SO_PEEK_OFF = 42 // socket.h:65:1: SO_PEERCRED = 17 // socket.h:30:1: SO_PEERGROUPS = 59 // socket.h:100:1: SO_PEERNAME = 28 // socket.h:49:1: SO_PEERSEC = 31 // socket.h:53:1: SO_PRIORITY = 12 // socket.h:24:1: SO_PROTOCOL = 38 // socket.h:58:1: SO_RCVBUF = 8 // socket.h:18:1: SO_RCVBUFFORCE = 33 // socket.h:20:1: SO_RCVLOWAT = 18 // socket.h:31:1: SO_RCVTIMEO = 20 // socket.h:129:1: SO_RCVTIMEO_NEW = 66 // socket.h:117:1: SO_RCVTIMEO_OLD = 20 // socket.h:33:1: SO_REUSEADDR = 2 // socket.h:12:1: SO_REUSEPORT = 15 // socket.h:27:1: SO_RXQ_OVFL = 40 // socket.h:61:1: SO_SECURITY_AUTHENTICATION = 22 // socket.h:38:1: SO_SECURITY_ENCRYPTION_NETWORK = 24 // socket.h:40:1: SO_SECURITY_ENCRYPTION_TRANSPORT = 23 // socket.h:39:1: SO_SELECT_ERR_QUEUE = 45 // socket.h:72:1: SO_SNDBUF = 7 // socket.h:17:1: SO_SNDBUFFORCE = 32 // socket.h:19:1: SO_SNDLOWAT = 19 // socket.h:32:1: SO_SNDTIMEO = 21 // socket.h:130:1: SO_SNDTIMEO_NEW = 67 // socket.h:118:1: SO_SNDTIMEO_OLD = 21 // socket.h:34:1: SO_TIMESTAMP = 29 // socket.h:125:1: SO_TIMESTAMPING = 37 // socket.h:127:1: SO_TIMESTAMPING_NEW = 65 // socket.h:115:1: SO_TIMESTAMPING_OLD = 37 // socket.h:111:1: SO_TIMESTAMPNS = 35 // socket.h:126:1: SO_TIMESTAMPNS_NEW = 64 // socket.h:114:1: SO_TIMESTAMPNS_OLD = 35 // socket.h:110:1: SO_TIMESTAMP_NEW = 63 // socket.h:113:1: SO_TIMESTAMP_OLD = 29 // socket.h:109:1: SO_TXTIME = 61 // socket.h:104:1: SO_TYPE = 3 // socket.h:13:1: SO_WIFI_STATUS = 41 // socket.h:63:1: SO_ZEROCOPY = 60 // socket.h:102:1: TRY_AGAIN = 2 // netdb.h:64:1: X_ASM_X86_POSIX_TYPES_64_H = 0 // posix_types_64.h:3:1: X_ATFILE_SOURCE = 1 // features.h:342:1: X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: X_BITS_ENDIAN_H = 1 // endian.h:20:1: X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: X_BITS_SOCKADDR_H = 1 // sockaddr.h:24:1: X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: X_BITS_STDINT_UINTN_H = 1 // stdint-uintn.h:20:1: X_BITS_TIME64_H = 1 // time64.h:24:1: X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: X_BITS_TYPES_H = 1 // types.h:24:1: X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: X_BSD_SIZE_T_ = 0 // stddef.h:189:1: X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: X_DEFAULT_SOURCE = 1 // features.h:227:1: X_ENDIAN_H = 1 // endian.h:19:1: X_FEATURES_H = 1 // features.h:19:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_GCC_SIZE_T = 0 // stddef.h:195:1: X_LINUX_POSIX_TYPES_H = 0 // posix_types.h:3:1: X_LP64 = 1 // <predefined>:284:1: X_NETDB_H = 1 // netdb.h:23:1: X_NETINET_IN_H = 1 // in.h:19:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:43:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:44:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:45:1: X_PATH_NSSWITCH_CONF = "/etc/nsswitch.conf" // netdb.h:46:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:47:1: X_PATH_SERVICES = "/etc/services" // netdb.h:48:1: X_POSIX_C_SOURCE = 200809 // features.h:281:1: X_POSIX_SOURCE = 1 // features.h:279:1: X_RPC_NETDB_H = 1 // netdb.h:37:1: X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: X_SIZET_ = 0 // stddef.h:196:1: X_SIZE_T = 0 // stddef.h:183:1: X_SIZE_T_ = 0 // stddef.h:188:1: X_SIZE_T_DECLARED = 0 // stddef.h:193:1: X_SIZE_T_DEFINED = 0 // stddef.h:191:1: X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: X_SS_SIZE = 128 // sockaddr.h:40:1: X_STDC_PREDEF_H = 1 // <predefined>:162:1: X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: X_SYS_CDEFS_H = 1 // cdefs.h:19:1:
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_linux_arm64.go
vendor/modernc.org/libc/netdb/netdb_linux_arm64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_arm64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_ALG = 38 AF_APPLETALK = 5 AF_ASH = 18 AF_ATMPVC = 8 AF_ATMSVC = 20 AF_AX25 = 3 AF_BLUETOOTH = 31 AF_BRIDGE = 7 AF_CAIF = 37 AF_CAN = 29 AF_DECnet = 12 AF_ECONET = 19 AF_FILE = 1 AF_IB = 27 AF_IEEE802154 = 36 AF_INET = 2 AF_INET6 = 10 AF_IPX = 4 AF_IRDA = 23 AF_ISDN = 34 AF_IUCV = 32 AF_KCM = 41 AF_KEY = 15 AF_LLC = 26 AF_LOCAL = 1 AF_MAX = 45 AF_MPLS = 28 AF_NETBEUI = 13 AF_NETLINK = 16 AF_NETROM = 6 AF_NFC = 39 AF_PACKET = 17 AF_PHONET = 35 AF_PPPOX = 24 AF_QIPCRTR = 42 AF_RDS = 21 AF_ROSE = 11 AF_ROUTE = 16 AF_RXRPC = 33 AF_SECURITY = 14 AF_SMC = 43 AF_SNA = 22 AF_TIPC = 30 AF_UNIX = 1 AF_UNSPEC = 0 AF_VSOCK = 40 AF_WANPIPE = 25 AF_X25 = 9 AF_XDP = 44 AI_ADDRCONFIG = 0x0020 AI_ALL = 0x0010 AI_CANONNAME = 0x0002 AI_NUMERICHOST = 0x0004 AI_NUMERICSERV = 0x0400 AI_PASSIVE = 0x0001 AI_V4MAPPED = 0x0008 BIG_ENDIAN = 4321 BYTE_ORDER = 1234 EAI_AGAIN = -3 EAI_BADFLAGS = -1 EAI_FAIL = -4 EAI_FAMILY = -6 EAI_MEMORY = -10 EAI_NONAME = -2 EAI_OVERFLOW = -12 EAI_SERVICE = -8 EAI_SOCKTYPE = -7 EAI_SYSTEM = -11 FD_SETSIZE = 1024 FIOGETOWN = 0x8903 FIOSETOWN = 0x8901 HOST_NOT_FOUND = 1 INET6_ADDRSTRLEN = 46 INET_ADDRSTRLEN = 16 IN_CLASSA_HOST = 16777215 IN_CLASSA_MAX = 128 IN_CLASSA_NET = 0xff000000 IN_CLASSA_NSHIFT = 24 IN_CLASSB_HOST = 65535 IN_CLASSB_MAX = 65536 IN_CLASSB_NET = 0xffff0000 IN_CLASSB_NSHIFT = 16 IN_CLASSC_HOST = 255 IN_CLASSC_NET = 0xffffff00 IN_CLASSC_NSHIFT = 8 IN_LOOPBACKNET = 127 IPPORT_RESERVED1 = 1024 IPV6_2292DSTOPTS = 4 IPV6_2292HOPLIMIT = 8 IPV6_2292HOPOPTS = 3 IPV6_2292PKTINFO = 2 IPV6_2292PKTOPTIONS = 6 IPV6_2292RTHDR = 5 IPV6_ADDRFORM = 1 IPV6_ADDR_PREFERENCES = 72 IPV6_ADD_MEMBERSHIP = 20 IPV6_AUTHHDR = 10 IPV6_AUTOFLOWLABEL = 70 IPV6_CHECKSUM = 7 IPV6_DONTFRAG = 62 IPV6_DROP_MEMBERSHIP = 21 IPV6_DSTOPTS = 59 IPV6_FREEBIND = 78 IPV6_HDRINCL = 36 IPV6_HOPLIMIT = 52 IPV6_HOPOPTS = 54 IPV6_IPSEC_POLICY = 34 IPV6_JOIN_ANYCAST = 27 IPV6_JOIN_GROUP = 20 IPV6_LEAVE_ANYCAST = 28 IPV6_LEAVE_GROUP = 21 IPV6_MINHOPCOUNT = 73 IPV6_MTU = 24 IPV6_MTU_DISCOVER = 23 IPV6_MULTICAST_ALL = 29 IPV6_MULTICAST_HOPS = 18 IPV6_MULTICAST_IF = 17 IPV6_MULTICAST_LOOP = 19 IPV6_NEXTHOP = 9 IPV6_ORIGDSTADDR = 74 IPV6_PATHMTU = 61 IPV6_PKTINFO = 50 IPV6_PMTUDISC_DO = 2 IPV6_PMTUDISC_DONT = 0 IPV6_PMTUDISC_INTERFACE = 4 IPV6_PMTUDISC_OMIT = 5 IPV6_PMTUDISC_PROBE = 3 IPV6_PMTUDISC_WANT = 1 IPV6_RECVDSTOPTS = 58 IPV6_RECVERR = 25 IPV6_RECVFRAGSIZE = 77 IPV6_RECVHOPLIMIT = 51 IPV6_RECVHOPOPTS = 53 IPV6_RECVORIGDSTADDR = 74 IPV6_RECVPATHMTU = 60 IPV6_RECVPKTINFO = 49 IPV6_RECVRTHDR = 56 IPV6_RECVTCLASS = 66 IPV6_ROUTER_ALERT = 22 IPV6_ROUTER_ALERT_ISOLATE = 30 IPV6_RTHDR = 57 IPV6_RTHDRDSTOPTS = 55 IPV6_RTHDR_LOOSE = 0 IPV6_RTHDR_STRICT = 1 IPV6_RTHDR_TYPE_0 = 0 IPV6_RXDSTOPTS = 59 IPV6_RXHOPOPTS = 54 IPV6_TCLASS = 67 IPV6_TRANSPARENT = 75 IPV6_UNICAST_HOPS = 16 IPV6_UNICAST_IF = 76 IPV6_V6ONLY = 26 IPV6_XFRM_POLICY = 35 IP_ADD_MEMBERSHIP = 35 IP_ADD_SOURCE_MEMBERSHIP = 39 IP_BIND_ADDRESS_NO_PORT = 24 IP_BLOCK_SOURCE = 38 IP_CHECKSUM = 23 IP_DEFAULT_MULTICAST_LOOP = 1 IP_DEFAULT_MULTICAST_TTL = 1 IP_DROP_MEMBERSHIP = 36 IP_DROP_SOURCE_MEMBERSHIP = 40 IP_FREEBIND = 15 IP_HDRINCL = 3 IP_IPSEC_POLICY = 16 IP_MAX_MEMBERSHIPS = 20 IP_MINTTL = 21 IP_MSFILTER = 41 IP_MTU = 14 IP_MTU_DISCOVER = 10 IP_MULTICAST_ALL = 49 IP_MULTICAST_IF = 32 IP_MULTICAST_LOOP = 34 IP_MULTICAST_TTL = 33 IP_NODEFRAG = 22 IP_OPTIONS = 4 IP_ORIGDSTADDR = 20 IP_PASSSEC = 18 IP_PKTINFO = 8 IP_PKTOPTIONS = 9 IP_PMTUDISC = 10 IP_PMTUDISC_DO = 2 IP_PMTUDISC_DONT = 0 IP_PMTUDISC_INTERFACE = 4 IP_PMTUDISC_OMIT = 5 IP_PMTUDISC_PROBE = 3 IP_PMTUDISC_WANT = 1 IP_RECVERR = 11 IP_RECVFRAGSIZE = 25 IP_RECVOPTS = 6 IP_RECVORIGDSTADDR = 20 IP_RECVRETOPTS = 7 IP_RECVTOS = 13 IP_RECVTTL = 12 IP_RETOPTS = 7 IP_ROUTER_ALERT = 5 IP_TOS = 1 IP_TRANSPARENT = 19 IP_TTL = 2 IP_UNBLOCK_SOURCE = 37 IP_UNICAST_IF = 50 IP_XFRM_POLICY = 17 LITTLE_ENDIAN = 1234 MCAST_BLOCK_SOURCE = 43 MCAST_EXCLUDE = 0 MCAST_INCLUDE = 1 MCAST_JOIN_GROUP = 42 MCAST_JOIN_SOURCE_GROUP = 46 MCAST_LEAVE_GROUP = 45 MCAST_LEAVE_SOURCE_GROUP = 47 MCAST_MSFILTER = 48 MCAST_UNBLOCK_SOURCE = 44 NETDB_INTERNAL = -1 NETDB_SUCCESS = 0 NI_DGRAM = 16 NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 8 NI_NOFQDN = 4 NI_NUMERICHOST = 1 NI_NUMERICSERV = 2 NO_ADDRESS = 4 NO_DATA = 4 NO_RECOVERY = 3 PDP_ENDIAN = 3412 PF_ALG = 38 PF_APPLETALK = 5 PF_ASH = 18 PF_ATMPVC = 8 PF_ATMSVC = 20 PF_AX25 = 3 PF_BLUETOOTH = 31 PF_BRIDGE = 7 PF_CAIF = 37 PF_CAN = 29 PF_DECnet = 12 PF_ECONET = 19 PF_FILE = 1 PF_IB = 27 PF_IEEE802154 = 36 PF_INET = 2 PF_INET6 = 10 PF_IPX = 4 PF_IRDA = 23 PF_ISDN = 34 PF_IUCV = 32 PF_KCM = 41 PF_KEY = 15 PF_LLC = 26 PF_LOCAL = 1 PF_MAX = 45 PF_MPLS = 28 PF_NETBEUI = 13 PF_NETLINK = 16 PF_NETROM = 6 PF_NFC = 39 PF_PACKET = 17 PF_PHONET = 35 PF_PPPOX = 24 PF_QIPCRTR = 42 PF_RDS = 21 PF_ROSE = 11 PF_ROUTE = 16 PF_RXRPC = 33 PF_SECURITY = 14 PF_SMC = 43 PF_SNA = 22 PF_TIPC = 30 PF_UNIX = 1 PF_UNSPEC = 0 PF_VSOCK = 40 PF_WANPIPE = 25 PF_X25 = 9 PF_XDP = 44 SCM_TIMESTAMP = 29 SCM_TIMESTAMPING = 37 SCM_TIMESTAMPING_OPT_STATS = 54 SCM_TIMESTAMPING_PKTINFO = 58 SCM_TIMESTAMPNS = 35 SCM_TXTIME = 61 SCM_WIFI_STATUS = 41 SIOCATMARK = 0x8905 SIOCGPGRP = 0x8904 SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 SIOCSPGRP = 0x8902 SOL_AAL = 265 SOL_ALG = 279 SOL_ATM = 264 SOL_BLUETOOTH = 274 SOL_CAIF = 278 SOL_DCCP = 269 SOL_DECNET = 261 SOL_ICMPV6 = 58 SOL_IP = 0 SOL_IPV6 = 41 SOL_IRDA = 266 SOL_IUCV = 277 SOL_KCM = 281 SOL_LLC = 268 SOL_NETBEUI = 267 SOL_NETLINK = 270 SOL_NFC = 280 SOL_PACKET = 263 SOL_PNPIPE = 275 SOL_PPPOL2TP = 273 SOL_RAW = 255 SOL_RDS = 276 SOL_RXRPC = 272 SOL_SOCKET = 1 SOL_TIPC = 271 SOL_TLS = 282 SOL_X25 = 262 SOL_XDP = 283 SOMAXCONN = 4096 SO_ACCEPTCONN = 30 SO_ATTACH_BPF = 50 SO_ATTACH_FILTER = 26 SO_ATTACH_REUSEPORT_CBPF = 51 SO_ATTACH_REUSEPORT_EBPF = 52 SO_BINDTODEVICE = 25 SO_BINDTOIFINDEX = 62 SO_BPF_EXTENSIONS = 48 SO_BROADCAST = 6 SO_BSDCOMPAT = 14 SO_BUSY_POLL = 46 SO_CNX_ADVICE = 53 SO_COOKIE = 57 SO_DEBUG = 1 SO_DETACH_BPF = 27 SO_DETACH_FILTER = 27 SO_DETACH_REUSEPORT_BPF = 68 SO_DOMAIN = 39 SO_DONTROUTE = 5 SO_ERROR = 4 SO_GET_FILTER = 26 SO_INCOMING_CPU = 49 SO_INCOMING_NAPI_ID = 56 SO_KEEPALIVE = 9 SO_LINGER = 13 SO_LOCK_FILTER = 44 SO_MARK = 36 SO_MAX_PACING_RATE = 47 SO_MEMINFO = 55 SO_NOFCS = 43 SO_NO_CHECK = 11 SO_OOBINLINE = 10 SO_PASSCRED = 16 SO_PASSSEC = 34 SO_PEEK_OFF = 42 SO_PEERCRED = 17 SO_PEERGROUPS = 59 SO_PEERNAME = 28 SO_PEERSEC = 31 SO_PRIORITY = 12 SO_PROTOCOL = 38 SO_RCVBUF = 8 SO_RCVBUFFORCE = 33 SO_RCVLOWAT = 18 SO_RCVTIMEO = 20 SO_RCVTIMEO_NEW = 66 SO_RCVTIMEO_OLD = 20 SO_REUSEADDR = 2 SO_REUSEPORT = 15 SO_RXQ_OVFL = 40 SO_SECURITY_AUTHENTICATION = 22 SO_SECURITY_ENCRYPTION_NETWORK = 24 SO_SECURITY_ENCRYPTION_TRANSPORT = 23 SO_SELECT_ERR_QUEUE = 45 SO_SNDBUF = 7 SO_SNDBUFFORCE = 32 SO_SNDLOWAT = 19 SO_SNDTIMEO = 21 SO_SNDTIMEO_NEW = 67 SO_SNDTIMEO_OLD = 21 SO_TIMESTAMP = 29 SO_TIMESTAMPING = 37 SO_TIMESTAMPING_NEW = 65 SO_TIMESTAMPING_OLD = 37 SO_TIMESTAMPNS = 35 SO_TIMESTAMPNS_NEW = 64 SO_TIMESTAMPNS_OLD = 35 SO_TIMESTAMP_NEW = 63 SO_TIMESTAMP_OLD = 29 SO_TXTIME = 61 SO_TYPE = 3 SO_WIFI_STATUS = 41 SO_ZEROCOPY = 60 TRY_AGAIN = 2 X_ATFILE_SOURCE = 1 X_BITS_BYTESWAP_H = 1 X_BITS_ENDIANNESS_H = 1 X_BITS_ENDIAN_H = 1 X_BITS_PTHREADTYPES_ARCH_H = 1 X_BITS_PTHREADTYPES_COMMON_H = 1 X_BITS_SOCKADDR_H = 1 X_BITS_STDINT_INTN_H = 1 X_BITS_STDINT_UINTN_H = 1 X_BITS_TIME64_H = 1 X_BITS_TYPESIZES_H = 1 X_BITS_TYPES_H = 1 X_BITS_UINTN_IDENTITY_H = 1 X_BSD_SIZE_T_ = 0 X_BSD_SIZE_T_DEFINED_ = 0 X_DEFAULT_SOURCE = 1 X_ENDIAN_H = 1 X_FEATURES_H = 1 X_FILE_OFFSET_BITS = 64 X_GCC_SIZE_T = 0 X_LINUX_POSIX_TYPES_H = 0 X_LP64 = 1 X_NETDB_H = 1 X_NETINET_IN_H = 1 X_PATH_HEQUIV = "/etc/hosts.equiv" X_PATH_HOSTS = "/etc/hosts" X_PATH_NETWORKS = "/etc/networks" X_PATH_NSSWITCH_CONF = "/etc/nsswitch.conf" X_PATH_PROTOCOLS = "/etc/protocols" X_PATH_SERVICES = "/etc/services" X_POSIX_C_SOURCE = 200809 X_POSIX_SOURCE = 1 X_RPC_NETDB_H = 1 X_RWLOCK_INTERNAL_H = 0 X_SIZET_ = 0 X_SIZE_T = 0 X_SIZE_T_ = 0 X_SIZE_T_DECLARED = 0 X_SIZE_T_DEFINED = 0 X_SIZE_T_DEFINED_ = 0 X_SS_SIZE = 128 X_STDC_PREDEF_H = 1 X_STRUCT_TIMESPEC = 1 X_SYS_CDEFS_H = 1 X_SYS_SELECT_H = 1 X_SYS_SIZE_T_H = 0 X_SYS_SOCKET_H = 1 X_SYS_TYPES_H = 1 X_THREAD_MUTEX_INTERNAL_H = 1 X_THREAD_SHARED_TYPES_H = 1 X_T_SIZE = 0 X_T_SIZE_ = 0 Linux = 1 Unix = 1 ) // Bits in the FLAGS argument to `send', `recv', et al. const ( /* socket.h:200:1: */ MSG_OOB = 1 // Process out-of-band data. MSG_PEEK = 2 // Peek at incoming messages. MSG_DONTROUTE = 4 // Don't use local routing. MSG_CTRUNC = 8 // Control data lost before delivery. MSG_PROXY = 16 // Supply or ask second address. MSG_TRUNC = 32 MSG_DONTWAIT = 64 // Nonblocking IO. MSG_EOR = 128 // End of record. MSG_WAITALL = 256 // Wait for a full request. MSG_FIN = 512 MSG_SYN = 1024 MSG_CONFIRM = 2048 // Confirm path validity. MSG_RST = 4096 MSG_ERRQUEUE = 8192 // Fetch message from error queue. MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. MSG_MORE = 32768 // Sender will send more. MSG_WAITFORONE = 65536 // Wait for at least one packet to return. MSG_BATCH = 262144 // sendmmsg: more messages coming. MSG_ZEROCOPY = 67108864 // Use user data in kernel path. MSG_FASTOPEN = 536870912 // Send data in TCP SYN. MSG_CMSG_CLOEXEC = 1073741824 ) // Socket level message types. This must match the definitions in // // <linux/socket.h>. const ( /* socket.h:332:1: */ SCM_RIGHTS = 1 ) // Get the architecture-dependent definition of enum __socket_type. // Define enum __socket_type for generic Linux. // Copyright (C) 1991-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // Types of sockets. const ( /* socket_type.h:24:1: */ SOCK_STREAM = 1 // Sequenced, reliable, connection-based // byte streams. SOCK_DGRAM = 2 // Connectionless, unreliable datagrams // of fixed maximum length. SOCK_RAW = 3 // Raw protocol interface. SOCK_RDM = 4 // Reliably-delivered messages. SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, // datagrams of fixed maximum length. SOCK_DCCP = 6 // Datagram Congestion Control Protocol. SOCK_PACKET = 10 // Linux specific way of getting packets // at the dev level. For writing rarp and // other similar things on the user level. // Flags to be ORed into the type parameter of socket and socketpair and // used for the flags parameter of paccept. SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the // new descriptor(s). SOCK_NONBLOCK = 2048 ) // Standard well-known ports. const ( /* in.h:122:1: */ IPPORT_ECHO = 7 // Echo service. IPPORT_DISCARD = 9 // Discard transmissions service. IPPORT_SYSTAT = 11 // System status service. IPPORT_DAYTIME = 13 // Time of day service. IPPORT_NETSTAT = 15 // Network status service. IPPORT_FTP = 21 // File Transfer Protocol. IPPORT_TELNET = 23 // Telnet protocol. IPPORT_SMTP = 25 // Simple Mail Transfer Protocol. IPPORT_TIMESERVER = 37 // Timeserver service. IPPORT_NAMESERVER = 42 // Domain Name Service. IPPORT_WHOIS = 43 // Internet Whois service. IPPORT_MTP = 57 IPPORT_TFTP = 69 // Trivial File Transfer Protocol. IPPORT_RJE = 77 IPPORT_FINGER = 79 // Finger service. IPPORT_TTYLINK = 87 IPPORT_SUPDUP = 95 // SUPDUP protocol. IPPORT_EXECSERVER = 512 // execd service. IPPORT_LOGINSERVER = 513 // rlogind service. IPPORT_CMDSERVER = 514 IPPORT_EFSSERVER = 520 // UDP ports. IPPORT_BIFFUDP = 512 IPPORT_WHOSERVER = 513 IPPORT_ROUTESERVER = 520 // Ports less than this value are reserved for privileged processes. IPPORT_RESERVED = 1024 // Ports greater this value are reserved for (non-privileged) servers. IPPORT_USERRESERVED = 5000 ) // Options for use with `getsockopt' and `setsockopt' at the IPv6 level. // The first word in the comment at the right is the data type used; // "bool" means a boolean value stored in an `int'. // Advanced API (RFC3542) (1). // Advanced API (RFC3542) (2). // RFC5014. // RFC5082. // Obsolete synonyms for the above. // IPV6_MTU_DISCOVER values. // Socket level values for IPv6. // Routing header options for IPv6. // Standard well-defined IP protocols. const ( /* in.h:40:1: */ IPPROTO_IP = 0 // Dummy protocol for TCP. IPPROTO_ICMP = 1 // Internet Control Message Protocol. IPPROTO_IGMP = 2 // Internet Group Management Protocol. IPPROTO_IPIP = 4 // IPIP tunnels (older KA9Q tunnels use 94). IPPROTO_TCP = 6 // Transmission Control Protocol. IPPROTO_EGP = 8 // Exterior Gateway Protocol. IPPROTO_PUP = 12 // PUP protocol. IPPROTO_UDP = 17 // User Datagram Protocol. IPPROTO_IDP = 22 // XNS IDP protocol. IPPROTO_TP = 29 // SO Transport Protocol Class 4. IPPROTO_DCCP = 33 // Datagram Congestion Control Protocol. IPPROTO_IPV6 = 41 // IPv6 header. IPPROTO_RSVP = 46 // Reservation Protocol. IPPROTO_GRE = 47 // General Routing Encapsulation. IPPROTO_ESP = 50 // encapsulating security payload. IPPROTO_AH = 51 // authentication header. IPPROTO_MTP = 92 // Multicast Transport Protocol. IPPROTO_BEETPH = 94 // IP option pseudo header for BEET. IPPROTO_ENCAP = 98 // Encapsulation Header. IPPROTO_PIM = 103 // Protocol Independent Multicast. IPPROTO_COMP = 108 // Compression Header Protocol. IPPROTO_SCTP = 132 // Stream Control Transmission Protocol. IPPROTO_UDPLITE = 136 // UDP-Lite protocol. IPPROTO_MPLS = 137 // MPLS in IP. IPPROTO_RAW = 255 // Raw IP packets. IPPROTO_MAX = 256 ) // If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel // // network headers first and we should use those ABI-identical definitions // instead of our own, otherwise 0. const ( /* in.h:99:1: */ IPPROTO_HOPOPTS = 0 // IPv6 Hop-by-Hop options. IPPROTO_ROUTING = 43 // IPv6 routing header. IPPROTO_FRAGMENT = 44 // IPv6 fragmentation header. IPPROTO_ICMPV6 = 58 // ICMPv6. IPPROTO_NONE = 59 // IPv6 no next header. IPPROTO_DSTOPTS = 60 // IPv6 destination options. IPPROTO_MH = 135 ) // The following constants should be used for the second parameter of // // `shutdown'. const ( /* socket.h:41:1: */ SHUT_RD = 0 // No more receptions. SHUT_WR = 1 // No more transmissions. SHUT_RDWR = 2 ) type Ptrdiff_t = int64 /* <builtin>:3:26 */ type Size_t = uint64 /* <builtin>:9:23 */ type Wchar_t = uint32 /* <builtin>:15:24 */ type X__int128_t = struct { Flo int64 Fhi int64 } /* <builtin>:21:43 */ // must match modernc.org/mathutil.Int128 type X__uint128_t = struct { Flo uint64 Fhi uint64 } /* <builtin>:22:44 */ // must match modernc.org/mathutil.Int128 type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // Copyright (C) 1996-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // All data returned by the network data base library are supplied in // host order and returned in network order (suitable for use in // system calls). // Copyright (C) 1991-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // These are defined by the user (or the compiler) // to specify the desired environment: // // __STRICT_ANSI__ ISO Standard C. // _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. // _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. // _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. // __STDC_WANT_LIB_EXT2__ // Extensions to ISO C99 from TR 27431-2:2010. // __STDC_WANT_IEC_60559_BFP_EXT__ // Extensions to ISO C11 from TS 18661-1:2014. // __STDC_WANT_IEC_60559_FUNCS_EXT__ // Extensions to ISO C11 from TS 18661-4:2015. // __STDC_WANT_IEC_60559_TYPES_EXT__ // Extensions to ISO C11 from TS 18661-3:2015. // // _POSIX_SOURCE IEEE Std 1003.1. // _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; // if >=199309L, add IEEE Std 1003.1b-1993; // if >=199506L, add IEEE Std 1003.1c-1995; // if >=200112L, all of IEEE 1003.1-2004 // if >=200809L, all of IEEE 1003.1-2008 // _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if // Single Unix conformance is wanted, to 600 for the // sixth revision, to 700 for the seventh revision. // _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. // _LARGEFILE_SOURCE Some more functions for correct standard I/O. // _LARGEFILE64_SOURCE Additional functionality from LFS for large files. // _FILE_OFFSET_BITS=N Select default filesystem interface. // _ATFILE_SOURCE Additional *at interfaces. // _GNU_SOURCE All of the above, plus GNU extensions. // _DEFAULT_SOURCE The default set of features (taking precedence over // __STRICT_ANSI__). // // _FORTIFY_SOURCE Add security hardening to many library functions. // Set to 1 or 2; 2 performs stricter checks than 1. // // _REENTRANT, _THREAD_SAFE // Obsolete; equivalent to _POSIX_C_SOURCE=199506L. // // The `-ansi' switch to the GNU C compiler, and standards conformance // options such as `-std=c99', define __STRICT_ANSI__. If none of // these are defined, or if _DEFAULT_SOURCE is defined, the default is // to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to // 200809L, as well as enabling miscellaneous functions from BSD and // SVID. If more than one of these are defined, they accumulate. For // example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together // give you ISO C, 1003.1, and 1003.2, but nothing else. // // These are defined by this file and are used by the // header files to decide what to declare or define: // // __GLIBC_USE (F) Define things from feature set F. This is defined // to 1 or 0; the subsequent macros are either defined // or undefined, and those tests should be moved to // __GLIBC_USE. // __USE_ISOC11 Define ISO C11 things. // __USE_ISOC99 Define ISO C99 things. // __USE_ISOC95 Define ISO C90 AMD1 (C95) things. // __USE_ISOCXX11 Define ISO C++11 things. // __USE_POSIX Define IEEE Std 1003.1 things. // __USE_POSIX2 Define IEEE Std 1003.2 things. // __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. // __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. // __USE_XOPEN Define XPG things. // __USE_XOPEN_EXTENDED Define X/Open Unix things. // __USE_UNIX98 Define Single Unix V2 things. // __USE_XOPEN2K Define XPG6 things. // __USE_XOPEN2KXSI Define XPG6 XSI things. // __USE_XOPEN2K8 Define XPG7 things. // __USE_XOPEN2K8XSI Define XPG7 XSI things. // __USE_LARGEFILE Define correct standard I/O things. // __USE_LARGEFILE64 Define LFS things with separate names. // __USE_FILE_OFFSET64 Define 64bit interface as default. // __USE_MISC Define things from 4.3BSD or System V Unix. // __USE_ATFILE Define *at interfaces and AT_* constants for them. // __USE_GNU Define GNU extensions. // __USE_FORTIFY_LEVEL Additional security measures used, according to level. // // The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are // defined by this file unconditionally. `__GNU_LIBRARY__' is provided // only for compatibility. All new code should use the other symbols // to test for features. // // All macros listed above as possibly being defined by this file are // explicitly undefined if they are not explicitly defined. // Feature-test macros that are not defined by the user or compiler // but are implied by the other feature-test macros defined (or by the // lack of any definitions) are defined by the file. // // ISO C feature test macros depend on the definition of the macro // when an affected header is included, not when the first system // header is included, and so they are handled in // <bits/libc-header-start.h>, which does not have a multiple include // guard. Feature test macros that can be handled from the first // system header included are handled here. // Undefine everything, so we get a clean slate. // Suppress kernel-name space pollution unless user expressedly asks // for it. // Convenience macro to test the version of gcc. // Use like this: // #if __GNUC_PREREQ (2,8) // ... code requiring gcc 2.8 or later ... // #endif // Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was // added in 2.0. // Similarly for clang. Features added to GCC after version 4.2 may // or may not also be available in clang, and clang's definitions of // __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such // features can be queried via __has_extension/__has_feature. // Whether to use feature set F. // _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for // _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_linux_loong64.go
vendor/modernc.org/libc/netdb/capi_linux_loong64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_linux_loong64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_darwin_arm64.go
vendor/modernc.org/libc/netdb/netdb_darwin_arm64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_darwin_arm64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_APPLETALK = 16 // socket.h:379:1: AF_CCITT = 10 // socket.h:373:1: AF_CHAOS = 5 // socket.h:367:1: AF_CNT = 21 // socket.h:384:1: AF_COIP = 20 // socket.h:383:1: AF_DATAKIT = 9 // socket.h:372:1: AF_DECnet = 12 // socket.h:375:1: AF_DLI = 13 // socket.h:376:1: AF_E164 = 28 // socket.h:391:1: AF_ECMA = 8 // socket.h:371:1: AF_HYLINK = 15 // socket.h:378:1: AF_IEEE80211 = 37 // socket.h:403:1: AF_IMPLINK = 3 // socket.h:365:1: AF_INET = 2 // socket.h:363:1: AF_INET6 = 30 // socket.h:394:1: AF_IPX = 23 // socket.h:386:1: AF_ISDN = 28 // socket.h:390:1: AF_ISO = 7 // socket.h:369:1: AF_LAT = 14 // socket.h:377:1: AF_LINK = 18 // socket.h:381:1: AF_LOCAL = 1 // socket.h:361:1: AF_MAX = 41 // socket.h:406:1: AF_NATM = 31 // socket.h:396:1: AF_NDRV = 27 // socket.h:389:1: AF_NETBIOS = 33 // socket.h:398:1: AF_NS = 6 // socket.h:368:1: AF_OSI = 7 // socket.h:370:1: AF_PPP = 34 // socket.h:399:1: AF_PUP = 4 // socket.h:366:1: AF_RESERVED_36 = 36 // socket.h:402:1: AF_ROUTE = 17 // socket.h:380:1: AF_SIP = 24 // socket.h:387:1: AF_SNA = 11 // socket.h:374:1: AF_SYSTEM = 32 // socket.h:397:1: AF_UNIX = 1 // socket.h:359:1: AF_UNSPEC = 0 // socket.h:358:1: AF_UTUN = 38 // socket.h:404:1: AF_VSOCK = 40 // socket.h:405:1: AI_ADDRCONFIG = 0x00000400 // netdb.h:226:1: AI_ALL = 0x00000100 // netdb.h:222:1: AI_CANONNAME = 0x00000002 // netdb.h:212:1: AI_DEFAULT = 1536 // netdb.h:230:1: AI_MASK = 5127 // netdb.h:217:1: AI_NUMERICHOST = 0x00000004 // netdb.h:213:1: AI_NUMERICSERV = 0x00001000 // netdb.h:214:1: AI_PASSIVE = 0x00000001 // netdb.h:211:1: AI_UNUSABLE = 0x10000000 // netdb.h:234:1: AI_V4MAPPED = 0x00000800 // netdb.h:227:1: AI_V4MAPPED_CFG = 0x00000200 // netdb.h:224:1: BIG_ENDIAN = 4321 // endian.h:72:1: BYTE_ORDER = 1234 // endian.h:75:1: CONNECT_DATA_AUTHENTICATED = 0x4 // socket.h:304:1: CONNECT_DATA_IDEMPOTENT = 0x2 // socket.h:303:1: CONNECT_RESUME_ON_READ_WRITE = 0x1 // socket.h:302:1: EAI_ADDRFAMILY = 1 // netdb.h:185:1: EAI_AGAIN = 2 // netdb.h:187:1: EAI_BADFLAGS = 3 // netdb.h:188:1: EAI_BADHINTS = 12 // netdb.h:200:1: EAI_FAIL = 4 // netdb.h:189:1: EAI_FAMILY = 5 // netdb.h:190:1: EAI_MAX = 15 // netdb.h:205:1: EAI_MEMORY = 6 // netdb.h:191:1: EAI_NODATA = 7 // netdb.h:193:1: EAI_NONAME = 8 // netdb.h:195:1: EAI_OVERFLOW = 14 // netdb.h:203:1: EAI_PROTOCOL = 13 // netdb.h:201:1: EAI_SERVICE = 9 // netdb.h:196:1: EAI_SOCKTYPE = 10 // netdb.h:197:1: EAI_SYSTEM = 11 // netdb.h:198:1: FD_SETSIZE = 1024 // _fd_setsize.h:29:1: HOST_NOT_FOUND = 1 // netdb.h:174:1: ICMP6_FILTER = 18 // in6.h:394:1: ICMPV6CTL_ND6_ONLINKNSRFC4861 = 50 // in6.h:629:1: INADDR_NONE = 0xffffffff // in.h:342:1: INET6_ADDRSTRLEN = 46 // in6.h:162:1: INET_ADDRSTRLEN = 16 // in.h:388:1: INT16_MAX = 32767 // stdint.h:599:1: INT16_MIN = -32768 // stdint.h:600:1: INT32_MAX = 2147483647 // stdint.h:555:1: INT32_MIN = -2147483648 // stdint.h:556:1: INT64_MAX = 9223372036854775807 // stdint.h:461:1: INT64_MIN = -9223372036854775808 // stdint.h:462:1: INT8_MAX = 127 // stdint.h:621:1: INT8_MIN = -128 // stdint.h:622:1: INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: INT_FAST16_MAX = 32767 // stdint.h:615:1: INT_FAST16_MIN = -32768 // stdint.h:614:1: INT_FAST32_MAX = 2147483647 // stdint.h:574:1: INT_FAST32_MIN = -2147483648 // stdint.h:573:1: INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: INT_FAST8_MAX = 127 // stdint.h:634:1: INT_FAST8_MIN = -128 // stdint.h:633:1: INT_LEAST16_MAX = 32767 // stdint.h:612:1: INT_LEAST16_MIN = -32768 // stdint.h:611:1: INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: INT_LEAST8_MAX = 127 // stdint.h:631:1: INT_LEAST8_MIN = -128 // stdint.h:630:1: IN_CLASSA_HOST = 0x00ffffff // in.h:317:1: IN_CLASSA_MAX = 128 // in.h:318:1: IN_CLASSA_NET = 0xff000000 // in.h:315:1: IN_CLASSA_NSHIFT = 24 // in.h:316:1: IN_CLASSB_HOST = 0x0000ffff // in.h:323:1: IN_CLASSB_MAX = 65536 // in.h:324:1: IN_CLASSB_NET = 0xffff0000 // in.h:321:1: IN_CLASSB_NSHIFT = 16 // in.h:322:1: IN_CLASSC_HOST = 0x000000ff // in.h:329:1: IN_CLASSC_NET = 0xffffff00 // in.h:327:1: IN_CLASSC_NSHIFT = 8 // in.h:328:1: IN_CLASSD_HOST = 0x0fffffff // in.h:334:1: IN_CLASSD_NET = 0xf0000000 // in.h:332:1: IN_CLASSD_NSHIFT = 28 // in.h:333:1: IN_LOOPBACKNET = 127 // in.h:369:1: IPCTL_ACCEPTSOURCEROUTE = 13 // in.h:650:1: IPCTL_DEFTTL = 3 // in.h:638:1: IPCTL_DIRECTEDBROADCAST = 9 // in.h:646:1: IPCTL_FASTFORWARDING = 14 // in.h:651:1: IPCTL_FORWARDING = 1 // in.h:636:1: IPCTL_GIF_TTL = 16 // in.h:653:1: IPCTL_INTRQDROPS = 11 // in.h:648:1: IPCTL_INTRQMAXLEN = 10 // in.h:647:1: IPCTL_KEEPFAITH = 15 // in.h:652:1: IPCTL_MAXID = 17 // in.h:654:1: IPCTL_RTEXPIRE = 5 // in.h:642:1: IPCTL_RTMAXCACHE = 7 // in.h:644:1: IPCTL_RTMINEXPIRE = 6 // in.h:643:1: IPCTL_SENDREDIRECTS = 2 // in.h:637:1: IPCTL_SOURCEROUTE = 8 // in.h:645:1: IPCTL_STATS = 12 // in.h:649:1: IPPORT_HIFIRSTAUTO = 49152 // in.h:286:1: IPPORT_HILASTAUTO = 65535 // in.h:287:1: IPPORT_RESERVED = 1024 // in.h:279:1: IPPORT_RESERVEDSTART = 600 // in.h:295:1: IPPORT_USERRESERVED = 5000 // in.h:281:1: IPPROTO_3PC = 34 // in.h:139:1: IPPROTO_ADFS = 68 // in.h:173:1: IPPROTO_AH = 51 // in.h:158:1: IPPROTO_AHIP = 61 // in.h:166:1: IPPROTO_APES = 99 // in.h:204:1: IPPROTO_ARGUS = 13 // in.h:116:1: IPPROTO_AX25 = 93 // in.h:198:1: IPPROTO_BHA = 49 // in.h:156:1: IPPROTO_BLT = 30 // in.h:135:1: IPPROTO_BRSATMON = 76 // in.h:181:1: IPPROTO_CFTP = 62 // in.h:167:1: IPPROTO_CHAOS = 16 // in.h:119:1: IPPROTO_CMTP = 38 // in.h:143:1: IPPROTO_CPHB = 73 // in.h:178:1: IPPROTO_CPNX = 72 // in.h:177:1: IPPROTO_DDP = 37 // in.h:142:1: IPPROTO_DGP = 86 // in.h:191:1: IPPROTO_DIVERT = 254 // in.h:213:1: IPPROTO_DONE = 257 // in.h:221:1: IPPROTO_DSTOPTS = 60 // in.h:165:1: IPPROTO_EGP = 8 // in.h:111:1: IPPROTO_EMCON = 14 // in.h:117:1: IPPROTO_ENCAP = 98 // in.h:203:1: IPPROTO_EON = 80 // in.h:185:1: IPPROTO_ESP = 50 // in.h:157:1: IPPROTO_ETHERIP = 97 // in.h:202:1: IPPROTO_FRAGMENT = 44 // in.h:151:1: IPPROTO_GGP = 3 // in.h:104:1: IPPROTO_GMTP = 100 // in.h:205:1: IPPROTO_GRE = 47 // in.h:154:1: IPPROTO_HELLO = 63 // in.h:168:1: IPPROTO_HMP = 20 // in.h:125:1: IPPROTO_HOPOPTS = 0 // in.h:99:1: IPPROTO_ICMP = 1 // in.h:101:1: IPPROTO_ICMPV6 = 58 // in.h:163:1: IPPROTO_IDP = 22 // in.h:127:1: IPPROTO_IDPR = 35 // in.h:140:1: IPPROTO_IDRP = 45 // in.h:152:1: IPPROTO_IGMP = 2 // in.h:103:1: IPPROTO_IGP = 85 // in.h:190:1: IPPROTO_IGRP = 88 // in.h:193:1: IPPROTO_IL = 40 // in.h:145:1: IPPROTO_INLSP = 52 // in.h:159:1: IPPROTO_INP = 32 // in.h:137:1: IPPROTO_IP = 0 // in.h:97:1: IPPROTO_IPCOMP = 108 // in.h:208:1: IPPROTO_IPCV = 71 // in.h:176:1: IPPROTO_IPEIP = 94 // in.h:199:1: IPPROTO_IPIP = 4 // in.h:106:1: IPPROTO_IPPC = 67 // in.h:172:1: IPPROTO_IPV4 = 4 // in.h:105:1: IPPROTO_IPV6 = 41 // in.h:147:1: IPPROTO_IRTP = 28 // in.h:133:1: IPPROTO_KRYPTOLAN = 65 // in.h:170:1: IPPROTO_LARP = 91 // in.h:196:1: IPPROTO_LEAF1 = 25 // in.h:130:1: IPPROTO_LEAF2 = 26 // in.h:131:1: IPPROTO_MAX = 256 // in.h:218:1: IPPROTO_MAXID = 52 // in.h:630:1: IPPROTO_MEAS = 19 // in.h:124:1: IPPROTO_MHRP = 48 // in.h:155:1: IPPROTO_MICP = 95 // in.h:200:1: IPPROTO_MTP = 92 // in.h:197:1: IPPROTO_MUX = 18 // in.h:123:1: IPPROTO_ND = 77 // in.h:182:1: IPPROTO_NHRP = 54 // in.h:161:1: IPPROTO_NONE = 59 // in.h:164:1: IPPROTO_NSP = 31 // in.h:136:1: IPPROTO_NVPII = 11 // in.h:114:1: IPPROTO_OSPFIGP = 89 // in.h:194:1: IPPROTO_PGM = 113 // in.h:209:1: IPPROTO_PIGP = 9 // in.h:112:1: IPPROTO_PIM = 103 // in.h:207:1: IPPROTO_PRM = 21 // in.h:126:1: IPPROTO_PUP = 12 // in.h:115:1: IPPROTO_PVP = 75 // in.h:180:1: IPPROTO_RAW = 255 // in.h:215:1: IPPROTO_RCCMON = 10 // in.h:113:1: IPPROTO_RDP = 27 // in.h:132:1: IPPROTO_ROUTING = 43 // in.h:150:1: IPPROTO_RSVP = 46 // in.h:153:1: IPPROTO_RVD = 66 // in.h:171:1: IPPROTO_SATEXPAK = 64 // in.h:169:1: IPPROTO_SATMON = 69 // in.h:174:1: IPPROTO_SCCSP = 96 // in.h:201:1: IPPROTO_SCTP = 132 // in.h:210:1: IPPROTO_SDRP = 42 // in.h:149:1: IPPROTO_SEP = 33 // in.h:138:1: IPPROTO_SRPC = 90 // in.h:195:1: IPPROTO_ST = 7 // in.h:110:1: IPPROTO_SVMTP = 82 // in.h:187:1: IPPROTO_SWIPE = 53 // in.h:160:1: IPPROTO_TCF = 87 // in.h:192:1: IPPROTO_TCP = 6 // in.h:108:1: IPPROTO_TP = 29 // in.h:134:1: IPPROTO_TPXX = 39 // in.h:144:1: IPPROTO_TRUNK1 = 23 // in.h:128:1: IPPROTO_TRUNK2 = 24 // in.h:129:1: IPPROTO_TTP = 84 // in.h:189:1: IPPROTO_UDP = 17 // in.h:121:1: IPPROTO_VINES = 83 // in.h:188:1: IPPROTO_VISA = 70 // in.h:175:1: IPPROTO_VMTP = 81 // in.h:186:1: IPPROTO_WBEXPAK = 79 // in.h:184:1: IPPROTO_WBMON = 78 // in.h:183:1: IPPROTO_WSN = 74 // in.h:179:1: IPPROTO_XNET = 15 // in.h:118:1: IPPROTO_XTP = 36 // in.h:141:1: IPV6CTL_ACCEPT_RTADV = 12 // in6.h:594:1: IPV6CTL_ADDRCTLPOLICY = 38 // in6.h:619:1: IPV6CTL_AUTO_FLOWLABEL = 17 // in6.h:599:1: IPV6CTL_AUTO_LINKLOCAL = 35 // in6.h:616:1: IPV6CTL_DAD_COUNT = 16 // in6.h:598:1: IPV6CTL_DEFHLIM = 3 // in6.h:583:1: IPV6CTL_DEFMCASTHLIM = 18 // in6.h:600:1: IPV6CTL_FORWARDING = 1 // in6.h:581:1: IPV6CTL_FORWSRCRT = 5 // in6.h:587:1: IPV6CTL_GIF_HLIM = 19 // in6.h:601:1: IPV6CTL_HDRNESTLIMIT = 15 // in6.h:597:1: IPV6CTL_KAME_VERSION = 20 // in6.h:602:1: IPV6CTL_KEEPFAITH = 13 // in6.h:595:1: IPV6CTL_LOG_INTERVAL = 14 // in6.h:596:1: IPV6CTL_MAXDYNROUTES = 49 // in6.h:628:1: IPV6CTL_MAXFRAGPACKETS = 9 // in6.h:591:1: IPV6CTL_MAXFRAGS = 41 // in6.h:622:1: IPV6CTL_MAXID = 51 // in6.h:635:1: IPV6CTL_MAXIFDEFROUTERS = 48 // in6.h:627:1: IPV6CTL_MAXIFPREFIXES = 47 // in6.h:626:1: IPV6CTL_MCAST_PMTU = 44 // in6.h:623:1: IPV6CTL_MRTPROTO = 8 // in6.h:590:1: IPV6CTL_MRTSTATS = 7 // in6.h:589:1: IPV6CTL_NEIGHBORGCTHRESH = 46 // in6.h:625:1: IPV6CTL_PREFER_TEMPADDR = 37 // in6.h:618:1: IPV6CTL_RIP6STATS = 36 // in6.h:617:1: IPV6CTL_RR_PRUNE = 22 // in6.h:604:1: IPV6CTL_RTEXPIRE = 25 // in6.h:609:1: IPV6CTL_RTMAXCACHE = 27 // in6.h:611:1: IPV6CTL_RTMINEXPIRE = 26 // in6.h:610:1: IPV6CTL_SENDREDIRECTS = 2 // in6.h:582:1: IPV6CTL_SOURCECHECK = 10 // in6.h:592:1: IPV6CTL_SOURCECHECK_LOGINT = 11 // in6.h:593:1: IPV6CTL_STATS = 6 // in6.h:588:1: IPV6CTL_TEMPPLTIME = 33 // in6.h:614:1: IPV6CTL_TEMPVLTIME = 34 // in6.h:615:1: IPV6CTL_ULA_USETEMPADDR = 51 // in6.h:630:1: IPV6CTL_USETEMPADDR = 32 // in6.h:613:1: IPV6CTL_USE_DEFAULTZONE = 39 // in6.h:620:1: IPV6CTL_USE_DEPRECATED = 21 // in6.h:603:1: IPV6CTL_V6ONLY = 24 // in6.h:608:1: IPV6PORT_ANONMAX = 65535 // in6.h:144:1: IPV6PORT_ANONMIN = 49152 // in6.h:143:1: IPV6PORT_RESERVED = 1024 // in6.h:142:1: IPV6PORT_RESERVEDMAX = 1023 // in6.h:146:1: IPV6PORT_RESERVEDMIN = 600 // in6.h:145:1: IPV6PROTO_MAXID = 104 // in6.h:576:1: IPV6_2292DSTOPTS = 23 // in6.h:399:1: IPV6_2292HOPLIMIT = 20 // in6.h:396:1: IPV6_2292HOPOPTS = 22 // in6.h:398:1: IPV6_2292NEXTHOP = 21 // in6.h:397:1: IPV6_2292PKTINFO = 19 // in6.h:395:1: IPV6_2292PKTOPTIONS = 25 // in6.h:403:1: IPV6_2292RTHDR = 24 // in6.h:400:1: IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 // in6.h:306:1: IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 // in6.h:305:1: IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 48 // in6.h:307:1: IPV6_BINDV6ONLY = 27 // in6.h:419:1: IPV6_BOUND_IF = 125 // in6.h:508:1: IPV6_CHECKSUM = 26 // in6.h:415:1: IPV6_DEFAULT_MULTICAST_HOPS = 1 // in6.h:520:1: IPV6_DEFAULT_MULTICAST_LOOP = 1 // in6.h:521:1: IPV6_FAITH = 29 // in6.h:425:1: IPV6_FW_ADD = 30 // in6.h:428:1: IPV6_FW_DEL = 31 // in6.h:429:1: IPV6_FW_FLUSH = 32 // in6.h:430:1: IPV6_FW_GET = 34 // in6.h:432:1: IPV6_FW_ZERO = 33 // in6.h:431:1: IPV6_IPSEC_POLICY = 28 // in6.h:423:1: IPV6_JOIN_GROUP = 12 // in6.h:389:1: IPV6_LEAVE_GROUP = 13 // in6.h:390:1: IPV6_MAX_GROUP_SRC_FILTER = 512 // in6.h:535:1: IPV6_MAX_MEMBERSHIPS = 4095 // in6.h:529:1: IPV6_MAX_SOCK_SRC_FILTER = 128 // in6.h:536:1: IPV6_MIN_MEMBERSHIPS = 31 // in6.h:528:1: IPV6_MULTICAST_HOPS = 10 // in6.h:387:1: IPV6_MULTICAST_IF = 9 // in6.h:386:1: IPV6_MULTICAST_LOOP = 11 // in6.h:388:1: IPV6_PORTRANGE = 14 // in6.h:393:1: IPV6_PORTRANGE_DEFAULT = 0 // in6.h:566:1: IPV6_PORTRANGE_HIGH = 1 // in6.h:567:1: IPV6_PORTRANGE_LOW = 2 // in6.h:568:1: IPV6_RECVTCLASS = 35 // in6.h:440:1: IPV6_RTHDR_LOOSE = 0 // in6.h:513:1: IPV6_RTHDR_STRICT = 1 // in6.h:514:1: IPV6_RTHDR_TYPE_0 = 0 // in6.h:515:1: IPV6_SOCKOPT_RESERVED1 = 3 // in6.h:383:1: IPV6_TCLASS = 36 // in6.h:441:1: IPV6_UNICAST_HOPS = 4 // in6.h:385:1: IPV6_V6ONLY = 27 // in6.h:417:1: IP_ADD_MEMBERSHIP = 12 // in.h:418:1: IP_ADD_SOURCE_MEMBERSHIP = 70 // in.h:465:1: IP_BLOCK_SOURCE = 72 // in.h:467:1: IP_BOUND_IF = 25 // in.h:434:1: IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:486:1: IP_DEFAULT_MULTICAST_TTL = 1 // in.h:485:1: IP_DONTFRAG = 28 // in.h:438:1: IP_DROP_MEMBERSHIP = 13 // in.h:419:1: IP_DROP_SOURCE_MEMBERSHIP = 71 // in.h:466:1: IP_DUMMYNET_CONFIGURE = 60 // in.h:456:1: IP_DUMMYNET_DEL = 61 // in.h:457:1: IP_DUMMYNET_FLUSH = 62 // in.h:458:1: IP_DUMMYNET_GET = 64 // in.h:459:1: IP_FAITH = 22 // in.h:429:1: IP_FW_ADD = 40 // in.h:440:1: IP_FW_DEL = 41 // in.h:441:1: IP_FW_FLUSH = 42 // in.h:442:1: IP_FW_GET = 44 // in.h:444:1: IP_FW_RESETLOG = 45 // in.h:445:1: IP_FW_ZERO = 43 // in.h:443:1: IP_HDRINCL = 2 // in.h:408:1: IP_IPSEC_POLICY = 21 // in.h:428:1: IP_MAX_GROUP_SRC_FILTER = 512 // in.h:500:1: IP_MAX_MEMBERSHIPS = 4095 // in.h:494:1: IP_MAX_SOCK_MUTE_FILTER = 128 // in.h:502:1: IP_MAX_SOCK_SRC_FILTER = 128 // in.h:501:1: IP_MIN_MEMBERSHIPS = 31 // in.h:493:1: IP_MSFILTER = 74 // in.h:471:1: IP_MULTICAST_IF = 9 // in.h:415:1: IP_MULTICAST_IFINDEX = 66 // in.h:462:1: IP_MULTICAST_LOOP = 11 // in.h:417:1: IP_MULTICAST_TTL = 10 // in.h:416:1: IP_MULTICAST_VIF = 14 // in.h:420:1: IP_NAT__XXX = 55 // in.h:453:1: IP_OLD_FW_ADD = 50 // in.h:448:1: IP_OLD_FW_DEL = 51 // in.h:449:1: IP_OLD_FW_FLUSH = 52 // in.h:450:1: IP_OLD_FW_GET = 54 // in.h:452:1: IP_OLD_FW_RESETLOG = 56 // in.h:454:1: IP_OLD_FW_ZERO = 53 // in.h:451:1: IP_OPTIONS = 1 // in.h:407:1: IP_PKTINFO = 26 // in.h:435:1: IP_PORTRANGE = 19 // in.h:425:1: IP_PORTRANGE_DEFAULT = 0 // in.h:594:1: IP_PORTRANGE_HIGH = 1 // in.h:595:1: IP_PORTRANGE_LOW = 2 // in.h:596:1: IP_RECVDSTADDR = 7 // in.h:413:1: IP_RECVIF = 20 // in.h:426:1: IP_RECVOPTS = 5 // in.h:411:1: IP_RECVPKTINFO = 26 // in.h:436:1: IP_RECVRETOPTS = 6 // in.h:412:1: IP_RECVTOS = 27 // in.h:437:1: IP_RECVTTL = 24 // in.h:433:1: IP_RETOPTS = 8 // in.h:414:1: IP_RSVP_OFF = 16 // in.h:422:1: IP_RSVP_ON = 15 // in.h:421:1: IP_RSVP_VIF_OFF = 18 // in.h:424:1: IP_RSVP_VIF_ON = 17 // in.h:423:1: IP_STRIPHDR = 23 // in.h:431:1: IP_TOS = 3 // in.h:409:1: IP_TRAFFIC_MGT_BACKGROUND = 65 // in.h:461:1: IP_TTL = 4 // in.h:410:1: IP_UNBLOCK_SOURCE = 73 // in.h:468:1: KEV_DL_ADDMULTI = 7 // net_kev.h:61:1: KEV_DL_AWDL_RESTRICTED = 26 // net_kev.h:80:1: KEV_DL_AWDL_UNRESTRICTED = 27 // net_kev.h:81:1: KEV_DL_DELMULTI = 8 // net_kev.h:62:1: KEV_DL_IFCAP_CHANGED = 19 // net_kev.h:73:1: KEV_DL_IFDELEGATE_CHANGED = 25 // net_kev.h:79:1:
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_freebsd_amd64.go
vendor/modernc.org/libc/netdb/netdb_freebsd_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_freebsd_amd64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AI_ADDRCONFIG = 0x00000400 // netdb.h:200:1: AI_ALL = 0x00000100 // netdb.h:198:1: AI_CANONNAME = 0x00000002 // netdb.h:190:1: AI_DEFAULT = 1536 // netdb.h:203:1: AI_MASK = 3343 // netdb.h:194:1: AI_NUMERICHOST = 0x00000004 // netdb.h:191:1: AI_NUMERICSERV = 0x00000008 // netdb.h:192:1: AI_PASSIVE = 0x00000001 // netdb.h:189:1: AI_V4MAPPED = 0x00000800 // netdb.h:201:1: AI_V4MAPPED_CFG = 0x00000200 // netdb.h:199:1: EAI_AGAIN = 2 // netdb.h:168:1: EAI_BADFLAGS = 3 // netdb.h:169:1: EAI_BADHINTS = 12 // netdb.h:181:1: EAI_FAIL = 4 // netdb.h:170:1: EAI_FAMILY = 5 // netdb.h:171:1: EAI_MAX = 15 // netdb.h:184:1: EAI_MEMORY = 6 // netdb.h:172:1: EAI_NONAME = 8 // netdb.h:177:1: EAI_OVERFLOW = 14 // netdb.h:183:1: EAI_PROTOCOL = 13 // netdb.h:182:1: EAI_SERVICE = 9 // netdb.h:178:1: EAI_SOCKTYPE = 10 // netdb.h:179:1: EAI_SYSTEM = 11 // netdb.h:180:1: HOST_NOT_FOUND = 1 // netdb.h:155:1: IPPORT_RESERVED = 1024 // netdb.h:146:1: NETDB_INTERNAL = -1 // netdb.h:153:1: NETDB_SUCCESS = 0 // netdb.h:154:1: NI_DGRAM = 0x00000010 // netdb.h:218:1: NI_MAXHOST = 1025 // netdb.h:208:1: NI_MAXSERV = 32 // netdb.h:209:1: NI_NAMEREQD = 0x00000004 // netdb.h:216:1: NI_NOFQDN = 0x00000001 // netdb.h:214:1: NI_NUMERICHOST = 0x00000002 // netdb.h:215:1: NI_NUMERICSCOPE = 0x00000020 // netdb.h:219:1: NI_NUMERICSERV = 0x00000008 // netdb.h:217:1: NO_ADDRESS = 4 // netdb.h:159:1: NO_DATA = 4 // netdb.h:158:1: NO_RECOVERY = 3 // netdb.h:157:1: SCOPE_DELIMITER = 37 // netdb.h:224:1: TRY_AGAIN = 2 // netdb.h:156:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_IN_ADDR_T_DECLARED = 0 // netdb.h:67:1: X_IN_PORT_T_DECLARED = 0 // netdb.h:72:1: X_LP64 = 1 // <predefined>:1:1: X_MACHINE__LIMITS_H_ = 0 // _limits.h:36:1: X_MACHINE__TYPES_H_ = 0 // _types.h:42:1: X_NETDB_H_ = 0 // netdb.h:60:1: X_Nonnull = 0 // cdefs.h:790:1: X_Null_unspecified = 0 // cdefs.h:792:1: X_Nullable = 0 // cdefs.h:791:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:91:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:93:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:94:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:95:1: X_PATH_SERVICES = "/etc/services" // netdb.h:96:1: X_PATH_SERVICES_DB = "/var/db/services.db" // netdb.h:97:1: X_SIZE_T_DECLARED = 0 // netdb.h:77:1: X_SOCKLEN_T_DECLARED = 0 // netdb.h:82:1: X_SYS_CDEFS_H_ = 0 // cdefs.h:39:1: X_SYS__TYPES_H_ = 0 // _types.h:32:1: X_UINT32_T_DECLARED = 0 // netdb.h:87:1: Unix = 1 // <predefined>:340:1: ) type Ptrdiff_t = int64 /* <builtin>:3:26 */ type Size_t = uint64 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__int128_t = struct { Flo int64 Fhi int64 } /* <builtin>:21:43 */ // must match modernc.org/mathutil.Int128 type X__uint128_t = struct { Flo uint64 Fhi uint64 } /* <builtin>:22:44 */ // must match modernc.org/mathutil.Int128 type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // - // SPDX-License-Identifier: (BSD-3-Clause AND ISC) // // Copyright (c) 1980, 1983, 1988, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // - // Portions Copyright (c) 1993 by Digital Equipment Corporation. // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies, and that // the name of Digital Equipment Corporation not be used in advertising or // publicity pertaining to distribution of the document or software without // specific, written prior permission. // // THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL // WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT // CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL // DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR // PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS // ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS // SOFTWARE. // - // --Copyright-- // @(#)netdb.h 8.1 (Berkeley) 6/2/93 // From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $ // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 // $FreeBSD$ // Testing against Clang-specific extensions. // This code has been put in place to help reduce the addition of // compiler specific defines in FreeBSD code. It helps to aid in // having a compiler-agnostic source tree. // Compiler memory barriers, specific to gcc and clang. // XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced // Macro to test if we're using a specific version of gcc or later. // The __CONCAT macro is used to concatenate parts of symbol names, e.g. // with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. // The __CONCAT macro is a bit tricky to use if it must work in non-ANSI // mode -- there must be no spaces between its arguments, and for nested // __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also // concatenate double-quoted strings produced by the __STRING macro, but // this only works with ANSI C. // // __XSTRING is like __STRING, but it expands any macros in its argument // first. It is only available with ANSI C. // Compiler-dependent macros to help declare dead (non-returning) and // pure (no side effects) functions, and unused variables. They are // null except for versions of gcc that are known to support the features // properly (old versions of gcc-2 supported the dead and pure features // in a different (wrong) way). If we do not provide an implementation // for a given compiler, let the compile fail if it is told to use // a feature that we cannot live without. // Keywords added in C11. // Emulation of C11 _Generic(). Unlike the previously defined C11 // keywords, it is not possible to implement this using exactly the same // syntax. Therefore implement something similar under the name // __generic(). Unlike _Generic(), this macro can only distinguish // between a single type, so it requires nested invocations to // distinguish multiple cases. // C99 Static array indices in function parameter declarations. Syntax such as: // void bar(int myArray[static 10]); // is allowed in C99 but not in C++. Define __min_size appropriately so // headers using it can be compiled in either language. Use like this: // void bar(int myArray[__min_size(10)]); // XXX: should use `#if __STDC_VERSION__ < 199901'. // C++11 exposes a load of C99 stuff // GCC 2.95 provides `__restrict' as an extension to C90 to support the // C99-specific `restrict' type qualifier. We happen to use `__restrict' as // a way to define the `restrict' type qualifier without disturbing older // software that is unaware of C99 keywords. // GNU C version 2.96 adds explicit branch prediction so that // the CPU back-end can hint the processor and also so that // code blocks can be reordered such that the predicted path // sees a more linear flow, thus improving cache behavior, etc. // // The following two macros provide us with a way to utilize this // compiler feature. Use __predict_true() if you expect the expression // to evaluate to true, and __predict_false() if you expect the // expression to evaluate to false. // // A few notes about usage: // // * Generally, __predict_false() error condition checks (unless // you have some _strong_ reason to do otherwise, in which case // document it), and/or __predict_true() `no-error' condition // checks, assuming you want to optimize for the no-error case. // // * Other than that, if you don't know the likelihood of a test // succeeding from empirical or other `hard' evidence, don't // make predictions. // // * These are meant to be used in places that are run `a lot'. // It is wasteful to make predictions in code that is run // seldomly (e.g. at subsystem initialization time) as the // basic block reordering that this affects can often generate // larger code. // We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h> // require it. // Given the pointer x to the member m of the struct s, return // a pointer to the containing structure. When using GCC, we first // assign pointer x to a local variable, to check that its type is // compatible with member m. // Compiler-dependent macros to declare that functions take printf-like // or scanf-like arguments. They are null except for versions of gcc // that are known to support the features properly (old versions of gcc-2 // didn't permit keeping the keywords out of the application namespace). // Compiler-dependent macros that rely on FreeBSD-specific extensions. // Embed the rcs id of a source file in the resulting library. Note that in // more recent ELF binutils, we use .ident allowing the ID to be stripped. // Usage: // __FBSDID("$FreeBSD$"); // - // The following definitions are an extension of the behavior originally // implemented in <sys/_posix.h>, but with a different level of granularity. // POSIX.1 requires that the macros we test be defined before any standard // header file is included. // // Here's a quick run-down of the versions: // defined(_POSIX_SOURCE) 1003.1-1988 // _POSIX_C_SOURCE == 1 1003.1-1990 // _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option // _POSIX_C_SOURCE == 199309 1003.1b-1993 // _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, // and the omnibus ISO/IEC 9945-1: 1996 // _POSIX_C_SOURCE == 200112 1003.1-2001 // _POSIX_C_SOURCE == 200809 1003.1-2008 // // In addition, the X/Open Portability Guide, which is now the Single UNIX // Specification, defines a feature-test macro which indicates the version of // that specification, and which subsumes _POSIX_C_SOURCE. // // Our macros begin with two underscores to avoid namespace screwage. // Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. // Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. // Deal with various X/Open Portability Guides and Single UNIX Spec. // Deal with all versions of POSIX. The ordering relative to the tests above is // important. // - // Deal with _ANSI_SOURCE: // If it is defined, and no other compilation environment is explicitly // requested, then define our internal feature-test macros to zero. This // makes no difference to the preprocessor (undefined symbols in preprocessing // expressions are defined to have value zero), but makes it more convenient for // a test program to print out the values. // // If a program mistakenly defines _ANSI_SOURCE and some other macro such as // _POSIX_C_SOURCE, we will assume that it wants the broader compilation // environment (and in fact we will never get here). // User override __EXT1_VISIBLE // Old versions of GCC use non-standard ARM arch symbols; acle-compat.h // translates them to __ARM_ARCH and the modern feature symbols defined by ARM. // Nullability qualifiers: currently only supported by Clang. // Type Safety Checking // // Clang provides additional attributes to enable checking type safety // properties that cannot be enforced by the C type system. // Lock annotations. // // Clang provides support for doing basic thread-safety tests at // compile-time, by marking which locks will/should be held when // entering/leaving a functions. // // Furthermore, it is also possible to annotate variables and structure // members to enforce that they are only accessed when certain locks are // held. // Structure implements a lock. // Function acquires an exclusive or shared lock. // Function attempts to acquire an exclusive or shared lock. // Function releases a lock. // Function asserts that an exclusive or shared lock is held. // Function requires that an exclusive or shared lock is or is not held. // Function should not be analyzed. // Function or variable should not be sanitized, e.g., by AddressSanitizer. // GCC has the nosanitize attribute, but as a function attribute only, and // warns on use as a variable attribute. // Guard variables and structure members by lock. // Alignment builtins for better type checking and improved code generation. // Provide fallback versions for other compilers (GCC/Clang < 10): // - // SPDX-License-Identifier: BSD-2-Clause-FreeBSD // // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 // $FreeBSD$ // - // This file is in the public domain. // $FreeBSD$ // - // SPDX-License-Identifier: BSD-4-Clause // // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> // Copyright (c) 1990, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. All advertising materials mentioning features or use of this software // must display the following acknowledgement: // This product includes software developed by the University of // California, Berkeley and its contributors. // 4. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 // From: @(#)types.h 8.3 (Berkeley) 1/5/94 // $FreeBSD$ // - // This file is in the public domain. // $FreeBSD$ // - // SPDX-License-Identifier: BSD-3-Clause // // Copyright (c) 1988, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)limits.h 8.3 (Berkeley) 1/4/94 // $FreeBSD$ // According to ANSI (section 2.2.4.2), the values below must be usable by // #if preprocessing directives. Additionally, the expression must have the // same type as would an expression that is an object of the corresponding // type converted according to the integral promotions. The subtraction for // INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an // unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). // max value for an unsigned long long // Quads and longs are the same on the amd64. Ensure they stay in sync. // Minimum signal stack size. // Basic types upon which most other types are built. type X__int8_t = int8 /* _types.h:55:22 */ type X__uint8_t = uint8 /* _types.h:56:24 */ type X__int16_t = int16 /* _types.h:57:17 */ type X__uint16_t = uint16 /* _types.h:58:25 */ type X__int32_t = int32 /* _types.h:59:15 */ type X__uint32_t = uint32 /* _types.h:60:23 */ type X__int64_t = int64 /* _types.h:62:16 */ type X__uint64_t = uint64 /* _types.h:63:24 */ // Standard type definitions. type X__clock_t = X__int32_t /* _types.h:75:19 */ // clock()... type X__critical_t = X__int64_t /* _types.h:76:19 */ type X__double_t = float64 /* _types.h:78:17 */ type X__float_t = float32 /* _types.h:79:16 */ type X__intfptr_t = X__int64_t /* _types.h:81:19 */ type X__intptr_t = X__int64_t /* _types.h:82:19 */ type X__intmax_t = X__int64_t /* _types.h:93:19 */ type X__int_fast8_t = X__int32_t /* _types.h:94:19 */ type X__int_fast16_t = X__int32_t /* _types.h:95:19 */ type X__int_fast32_t = X__int32_t /* _types.h:96:19 */ type X__int_fast64_t = X__int64_t /* _types.h:97:19 */ type X__int_least8_t = X__int8_t /* _types.h:98:18 */ type X__int_least16_t = X__int16_t /* _types.h:99:19 */ type X__int_least32_t = X__int32_t /* _types.h:100:19 */ type X__int_least64_t = X__int64_t /* _types.h:101:19 */ type X__ptrdiff_t = X__int64_t /* _types.h:103:19 */ // ptr1 - ptr2 type X__register_t = X__int64_t /* _types.h:104:19 */ type X__segsz_t = X__int64_t /* _types.h:105:19 */ // segment size (in pages) type X__size_t = X__uint64_t /* _types.h:106:20 */ // sizeof() type X__ssize_t = X__int64_t /* _types.h:107:19 */ // byte count or error type X__time_t = X__int64_t /* _types.h:108:19 */ // time()... type X__uintfptr_t = X__uint64_t /* _types.h:109:20 */ type X__uintptr_t = X__uint64_t /* _types.h:110:20 */ type X__uintmax_t = X__uint64_t /* _types.h:121:20 */ type X__uint_fast8_t = X__uint32_t /* _types.h:122:20 */ type X__uint_fast16_t = X__uint32_t /* _types.h:123:20 */ type X__uint_fast32_t = X__uint32_t /* _types.h:124:20 */ type X__uint_fast64_t = X__uint64_t /* _types.h:125:20 */ type X__uint_least8_t = X__uint8_t /* _types.h:126:19 */ type X__uint_least16_t = X__uint16_t /* _types.h:127:20 */ type X__uint_least32_t = X__uint32_t /* _types.h:128:20 */ type X__uint_least64_t = X__uint64_t /* _types.h:129:20 */ type X__u_register_t = X__uint64_t /* _types.h:131:20 */ type X__vm_offset_t = X__uint64_t /* _types.h:132:20 */ type X__vm_paddr_t = X__uint64_t /* _types.h:133:20 */ type X__vm_size_t = X__uint64_t /* _types.h:134:20 */ type X___wchar_t = int32 /* _types.h:141:14 */ // Standard type definitions. type X__blksize_t = X__int32_t /* _types.h:40:19 */ // file block size type X__blkcnt_t = X__int64_t /* _types.h:41:19 */ // file block count type X__clockid_t = X__int32_t /* _types.h:42:19 */ // clock_gettime()... type X__fflags_t = X__uint32_t /* _types.h:43:20 */ // file flags type X__fsblkcnt_t = X__uint64_t /* _types.h:44:20 */ type X__fsfilcnt_t = X__uint64_t /* _types.h:45:20 */ type X__gid_t = X__uint32_t /* _types.h:46:20 */ type X__id_t = X__int64_t /* _types.h:47:19 */ // can hold a gid_t, pid_t, or uid_t type X__ino_t = X__uint64_t /* _types.h:48:20 */ // inode number type X__key_t = int64 /* _types.h:49:15 */ // IPC key (for Sys V IPC) type X__lwpid_t = X__int32_t /* _types.h:50:19 */ // Thread ID (a.k.a. LWP) type X__mode_t = X__uint16_t /* _types.h:51:20 */ // permissions type X__accmode_t = int32 /* _types.h:52:14 */ // access permissions type X__nl_item = int32 /* _types.h:53:14 */ type X__nlink_t = X__uint64_t /* _types.h:54:20 */ // link count type X__off_t = X__int64_t /* _types.h:55:19 */ // file offset type X__off64_t = X__int64_t /* _types.h:56:19 */ // file offset (alias) type X__pid_t = X__int32_t /* _types.h:57:19 */ // process [group] type X__rlim_t = X__int64_t /* _types.h:58:19 */ // resource limit - intentionally // signed, because of legacy code // that uses -1 for RLIM_INFINITY type X__sa_family_t = X__uint8_t /* _types.h:61:19 */ type X__socklen_t = X__uint32_t /* _types.h:62:20 */ type X__suseconds_t = int64 /* _types.h:63:15 */ // microseconds (signed) type X__timer_t = uintptr /* _types.h:64:24 */ // timer_gettime()... type X__mqd_t = uintptr /* _types.h:65:21 */ // mq_open()... type X__uid_t = X__uint32_t /* _types.h:66:20 */ type X__useconds_t = uint32 /* _types.h:67:22 */ // microseconds (unsigned) type X__cpuwhich_t = int32 /* _types.h:68:14 */ // which parameter for cpuset. type X__cpulevel_t = int32 /* _types.h:69:14 */ // level parameter for cpuset. type X__cpusetid_t = int32 /* _types.h:70:14 */ // cpuset identifier. type X__daddr_t = X__int64_t /* _types.h:71:19 */ // bwrite(3), FIOBMAP2, etc // Unusual type definitions. // rune_t is declared to be an “int” instead of the more natural // “unsigned long” or “long”. Two things are happening here. It is not // unsigned so that EOF (-1) can be naturally assigned to it and used. Also, // it looks like 10646 will be a 31 bit standard. This means that if your // ints cannot hold 32 bits, you will be in trouble. The reason an int was // chosen over a long is that the is*() and to*() routines take ints (says // ANSI C), but they use __ct_rune_t instead of int. // // NOTE: rune_t is not covered by ANSI nor other standards, and should not // be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and // rune_t must be the same type. Also, wint_t should be able to hold all // members of the largest character set plus one extra value (WEOF), and // must be at least 16 bits. type X__ct_rune_t = int32 /* _types.h:91:14 */ // arg type for ctype funcs type X__rune_t = X__ct_rune_t /* _types.h:92:21 */ // rune_t (see above) type X__wint_t = X__ct_rune_t /* _types.h:93:21 */ // wint_t (see above) // Clang already provides these types as built-ins, but only in C++ mode. type X__char16_t = X__uint_least16_t /* _types.h:97:26 */ type X__char32_t = X__uint_least32_t /* _types.h:98:26 */ // In C++11, char16_t and char32_t are built-in types. type X__max_align_t = struct { F__max_align1 int64 F__max_align2 float64 } /* _types.h:111:3 */ type X__dev_t = X__uint64_t /* _types.h:113:20 */ // device number type X__fixpt_t = X__uint32_t /* _types.h:115:20 */ // fixed point number // mbstate_t is an opaque object to keep conversion state during multibyte // stream conversions. type X__mbstate_t = struct { F__ccgo_pad1 [0]uint64 F__mbstate8 [128]int8 } /* _types.h:124:3 */ type X__rman_res_t = X__uintmax_t /* _types.h:126:25 */ // Types for varargs. These are all provided by builtin types these // days, so centralize their definition. type X__va_list = X__builtin_va_list /* _types.h:133:27 */ // internally known to gcc type X__gnuc_va_list = X__va_list /* _types.h:140:20 */ // compatibility w/GNU headers // When the following macro is defined, the system uses 64-bit inode numbers. // Programs can use this to avoid including <sys/param.h>, with its associated // namespace pollution. type In_addr_t = X__uint32_t /* netdb.h:66:20 */ type In_port_t = X__uint16_t /* netdb.h:71:20 */ type Socklen_t = X__socklen_t /* netdb.h:81:21 */ type Uint32_t = X__uint32_t /* netdb.h:86:20 */ // Structures returned by network data base library. All addresses are
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_linux_ppc64le.go
vendor/modernc.org/libc/netdb/capi_linux_ppc64le.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_linux_ppc64le.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_netbsd_amd64.go
vendor/modernc.org/libc/netdb/capi_netbsd_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_netbsd_amd64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_linux_386.go
vendor/modernc.org/libc/netdb/netdb_linux_386.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_386.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_ALG = 38 AF_APPLETALK = 5 AF_ASH = 18 AF_ATMPVC = 8 AF_ATMSVC = 20 AF_AX25 = 3 AF_BLUETOOTH = 31 AF_BRIDGE = 7 AF_CAIF = 37 AF_CAN = 29 AF_DECnet = 12 AF_ECONET = 19 AF_FILE = 1 AF_IB = 27 AF_IEEE802154 = 36 AF_INET = 2 AF_INET6 = 10 AF_IPX = 4 AF_IRDA = 23 AF_ISDN = 34 AF_IUCV = 32 AF_KCM = 41 AF_KEY = 15 AF_LLC = 26 AF_LOCAL = 1 AF_MAX = 45 AF_MPLS = 28 AF_NETBEUI = 13 AF_NETLINK = 16 AF_NETROM = 6 AF_NFC = 39 AF_PACKET = 17 AF_PHONET = 35 AF_PPPOX = 24 AF_QIPCRTR = 42 AF_RDS = 21 AF_ROSE = 11 AF_ROUTE = 16 AF_RXRPC = 33 AF_SECURITY = 14 AF_SMC = 43 AF_SNA = 22 AF_TIPC = 30 AF_UNIX = 1 AF_UNSPEC = 0 AF_VSOCK = 40 AF_WANPIPE = 25 AF_X25 = 9 AF_XDP = 44 AI_ADDRCONFIG = 0x0020 AI_ALL = 0x0010 AI_CANONNAME = 0x0002 AI_NUMERICHOST = 0x0004 AI_NUMERICSERV = 0x0400 AI_PASSIVE = 0x0001 AI_V4MAPPED = 0x0008 BIG_ENDIAN = 4321 BYTE_ORDER = 1234 EAI_AGAIN = -3 EAI_BADFLAGS = -1 EAI_FAIL = -4 EAI_FAMILY = -6 EAI_MEMORY = -10 EAI_NONAME = -2 EAI_OVERFLOW = -12 EAI_SERVICE = -8 EAI_SOCKTYPE = -7 EAI_SYSTEM = -11 FD_SETSIZE = 1024 FIOGETOWN = 0x8903 FIOSETOWN = 0x8901 HOST_NOT_FOUND = 1 INET6_ADDRSTRLEN = 46 INET_ADDRSTRLEN = 16 IN_CLASSA_HOST = 16777215 IN_CLASSA_MAX = 128 IN_CLASSA_NET = 0xff000000 IN_CLASSA_NSHIFT = 24 IN_CLASSB_HOST = 65535 IN_CLASSB_MAX = 65536 IN_CLASSB_NET = 0xffff0000 IN_CLASSB_NSHIFT = 16 IN_CLASSC_HOST = 255 IN_CLASSC_NET = 0xffffff00 IN_CLASSC_NSHIFT = 8 IN_LOOPBACKNET = 127 IPPORT_RESERVED1 = 1024 IPV6_2292DSTOPTS = 4 IPV6_2292HOPLIMIT = 8 IPV6_2292HOPOPTS = 3 IPV6_2292PKTINFO = 2 IPV6_2292PKTOPTIONS = 6 IPV6_2292RTHDR = 5 IPV6_ADDRFORM = 1 IPV6_ADDR_PREFERENCES = 72 IPV6_ADD_MEMBERSHIP = 20 IPV6_AUTHHDR = 10 IPV6_AUTOFLOWLABEL = 70 IPV6_CHECKSUM = 7 IPV6_DONTFRAG = 62 IPV6_DROP_MEMBERSHIP = 21 IPV6_DSTOPTS = 59 IPV6_FREEBIND = 78 IPV6_HDRINCL = 36 IPV6_HOPLIMIT = 52 IPV6_HOPOPTS = 54 IPV6_IPSEC_POLICY = 34 IPV6_JOIN_ANYCAST = 27 IPV6_JOIN_GROUP = 20 IPV6_LEAVE_ANYCAST = 28 IPV6_LEAVE_GROUP = 21 IPV6_MINHOPCOUNT = 73 IPV6_MTU = 24 IPV6_MTU_DISCOVER = 23 IPV6_MULTICAST_ALL = 29 IPV6_MULTICAST_HOPS = 18 IPV6_MULTICAST_IF = 17 IPV6_MULTICAST_LOOP = 19 IPV6_NEXTHOP = 9 IPV6_ORIGDSTADDR = 74 IPV6_PATHMTU = 61 IPV6_PKTINFO = 50 IPV6_PMTUDISC_DO = 2 IPV6_PMTUDISC_DONT = 0 IPV6_PMTUDISC_INTERFACE = 4 IPV6_PMTUDISC_OMIT = 5 IPV6_PMTUDISC_PROBE = 3 IPV6_PMTUDISC_WANT = 1 IPV6_RECVDSTOPTS = 58 IPV6_RECVERR = 25 IPV6_RECVFRAGSIZE = 77 IPV6_RECVHOPLIMIT = 51 IPV6_RECVHOPOPTS = 53 IPV6_RECVORIGDSTADDR = 74 IPV6_RECVPATHMTU = 60 IPV6_RECVPKTINFO = 49 IPV6_RECVRTHDR = 56 IPV6_RECVTCLASS = 66 IPV6_ROUTER_ALERT = 22 IPV6_ROUTER_ALERT_ISOLATE = 30 IPV6_RTHDR = 57 IPV6_RTHDRDSTOPTS = 55 IPV6_RTHDR_LOOSE = 0 IPV6_RTHDR_STRICT = 1 IPV6_RTHDR_TYPE_0 = 0 IPV6_RXDSTOPTS = 59 IPV6_RXHOPOPTS = 54 IPV6_TCLASS = 67 IPV6_TRANSPARENT = 75 IPV6_UNICAST_HOPS = 16 IPV6_UNICAST_IF = 76 IPV6_V6ONLY = 26 IPV6_XFRM_POLICY = 35 IP_ADD_MEMBERSHIP = 35 IP_ADD_SOURCE_MEMBERSHIP = 39 IP_BIND_ADDRESS_NO_PORT = 24 IP_BLOCK_SOURCE = 38 IP_CHECKSUM = 23 IP_DEFAULT_MULTICAST_LOOP = 1 IP_DEFAULT_MULTICAST_TTL = 1 IP_DROP_MEMBERSHIP = 36 IP_DROP_SOURCE_MEMBERSHIP = 40 IP_FREEBIND = 15 IP_HDRINCL = 3 IP_IPSEC_POLICY = 16 IP_MAX_MEMBERSHIPS = 20 IP_MINTTL = 21 IP_MSFILTER = 41 IP_MTU = 14 IP_MTU_DISCOVER = 10 IP_MULTICAST_ALL = 49 IP_MULTICAST_IF = 32 IP_MULTICAST_LOOP = 34 IP_MULTICAST_TTL = 33 IP_NODEFRAG = 22 IP_OPTIONS = 4 IP_ORIGDSTADDR = 20 IP_PASSSEC = 18 IP_PKTINFO = 8 IP_PKTOPTIONS = 9 IP_PMTUDISC = 10 IP_PMTUDISC_DO = 2 IP_PMTUDISC_DONT = 0 IP_PMTUDISC_INTERFACE = 4 IP_PMTUDISC_OMIT = 5 IP_PMTUDISC_PROBE = 3 IP_PMTUDISC_WANT = 1 IP_RECVERR = 11 IP_RECVFRAGSIZE = 25 IP_RECVOPTS = 6 IP_RECVORIGDSTADDR = 20 IP_RECVRETOPTS = 7 IP_RECVTOS = 13 IP_RECVTTL = 12 IP_RETOPTS = 7 IP_ROUTER_ALERT = 5 IP_TOS = 1 IP_TRANSPARENT = 19 IP_TTL = 2 IP_UNBLOCK_SOURCE = 37 IP_UNICAST_IF = 50 IP_XFRM_POLICY = 17 LITTLE_ENDIAN = 1234 MCAST_BLOCK_SOURCE = 43 MCAST_EXCLUDE = 0 MCAST_INCLUDE = 1 MCAST_JOIN_GROUP = 42 MCAST_JOIN_SOURCE_GROUP = 46 MCAST_LEAVE_GROUP = 45 MCAST_LEAVE_SOURCE_GROUP = 47 MCAST_MSFILTER = 48 MCAST_UNBLOCK_SOURCE = 44 NETDB_INTERNAL = -1 NETDB_SUCCESS = 0 NI_DGRAM = 16 NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 8 NI_NOFQDN = 4 NI_NUMERICHOST = 1 NI_NUMERICSERV = 2 NO_ADDRESS = 4 NO_DATA = 4 NO_RECOVERY = 3 PDP_ENDIAN = 3412 PF_ALG = 38 PF_APPLETALK = 5 PF_ASH = 18 PF_ATMPVC = 8 PF_ATMSVC = 20 PF_AX25 = 3 PF_BLUETOOTH = 31 PF_BRIDGE = 7 PF_CAIF = 37 PF_CAN = 29 PF_DECnet = 12 PF_ECONET = 19 PF_FILE = 1 PF_IB = 27 PF_IEEE802154 = 36 PF_INET = 2 PF_INET6 = 10 PF_IPX = 4 PF_IRDA = 23 PF_ISDN = 34 PF_IUCV = 32 PF_KCM = 41 PF_KEY = 15 PF_LLC = 26 PF_LOCAL = 1 PF_MAX = 45 PF_MPLS = 28 PF_NETBEUI = 13 PF_NETLINK = 16 PF_NETROM = 6 PF_NFC = 39 PF_PACKET = 17 PF_PHONET = 35 PF_PPPOX = 24 PF_QIPCRTR = 42 PF_RDS = 21 PF_ROSE = 11 PF_ROUTE = 16 PF_RXRPC = 33 PF_SECURITY = 14 PF_SMC = 43 PF_SNA = 22 PF_TIPC = 30 PF_UNIX = 1 PF_UNSPEC = 0 PF_VSOCK = 40 PF_WANPIPE = 25 PF_X25 = 9 PF_XDP = 44 SCM_TIMESTAMPING_OPT_STATS = 54 SCM_TIMESTAMPING_PKTINFO = 58 SCM_TXTIME = 61 SCM_WIFI_STATUS = 41 SIOCATMARK = 0x8905 SIOCGPGRP = 0x8904 SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 SIOCSPGRP = 0x8902 SOL_AAL = 265 SOL_ALG = 279 SOL_ATM = 264 SOL_BLUETOOTH = 274 SOL_CAIF = 278 SOL_DCCP = 269 SOL_DECNET = 261 SOL_ICMPV6 = 58 SOL_IP = 0 SOL_IPV6 = 41 SOL_IRDA = 266 SOL_IUCV = 277 SOL_KCM = 281 SOL_LLC = 268 SOL_NETBEUI = 267 SOL_NETLINK = 270 SOL_NFC = 280 SOL_PACKET = 263 SOL_PNPIPE = 275 SOL_PPPOL2TP = 273 SOL_RAW = 255 SOL_RDS = 276 SOL_RXRPC = 272 SOL_SOCKET = 1 SOL_TIPC = 271 SOL_TLS = 282 SOL_X25 = 262 SOL_XDP = 283 SOMAXCONN = 4096 SO_ACCEPTCONN = 30 SO_ATTACH_BPF = 50 SO_ATTACH_FILTER = 26 SO_ATTACH_REUSEPORT_CBPF = 51 SO_ATTACH_REUSEPORT_EBPF = 52 SO_BINDTODEVICE = 25 SO_BINDTOIFINDEX = 62 SO_BPF_EXTENSIONS = 48 SO_BROADCAST = 6 SO_BSDCOMPAT = 14 SO_BUSY_POLL = 46 SO_CNX_ADVICE = 53 SO_COOKIE = 57 SO_DEBUG = 1 SO_DETACH_BPF = 27 SO_DETACH_FILTER = 27 SO_DETACH_REUSEPORT_BPF = 68 SO_DOMAIN = 39 SO_DONTROUTE = 5 SO_ERROR = 4 SO_GET_FILTER = 26 SO_INCOMING_CPU = 49 SO_INCOMING_NAPI_ID = 56 SO_KEEPALIVE = 9 SO_LINGER = 13 SO_LOCK_FILTER = 44 SO_MARK = 36 SO_MAX_PACING_RATE = 47 SO_MEMINFO = 55 SO_NOFCS = 43 SO_NO_CHECK = 11 SO_OOBINLINE = 10 SO_PASSCRED = 16 SO_PASSSEC = 34 SO_PEEK_OFF = 42 SO_PEERCRED = 17 SO_PEERGROUPS = 59 SO_PEERNAME = 28 SO_PEERSEC = 31 SO_PRIORITY = 12 SO_PROTOCOL = 38 SO_RCVBUF = 8 SO_RCVBUFFORCE = 33 SO_RCVLOWAT = 18 SO_RCVTIMEO_NEW = 66 SO_RCVTIMEO_OLD = 20 SO_REUSEADDR = 2 SO_REUSEPORT = 15 SO_RXQ_OVFL = 40 SO_SECURITY_AUTHENTICATION = 22 SO_SECURITY_ENCRYPTION_NETWORK = 24 SO_SECURITY_ENCRYPTION_TRANSPORT = 23 SO_SELECT_ERR_QUEUE = 45 SO_SNDBUF = 7 SO_SNDBUFFORCE = 32 SO_SNDLOWAT = 19 SO_SNDTIMEO_NEW = 67 SO_SNDTIMEO_OLD = 21 SO_TIMESTAMPING_NEW = 65 SO_TIMESTAMPING_OLD = 37 SO_TIMESTAMPNS_NEW = 64 SO_TIMESTAMPNS_OLD = 35 SO_TIMESTAMP_NEW = 63 SO_TIMESTAMP_OLD = 29 SO_TXTIME = 61 SO_TYPE = 3 SO_WIFI_STATUS = 41 SO_ZEROCOPY = 60 TRY_AGAIN = 2 X_ASM_X86_POSIX_TYPES_32_H = 0 X_ATFILE_SOURCE = 1 X_BITS_BYTESWAP_H = 1 X_BITS_ENDIANNESS_H = 1 X_BITS_ENDIAN_H = 1 X_BITS_PTHREADTYPES_ARCH_H = 1 X_BITS_PTHREADTYPES_COMMON_H = 1 X_BITS_SOCKADDR_H = 1 X_BITS_STDINT_INTN_H = 1 X_BITS_STDINT_UINTN_H = 1 X_BITS_TIME64_H = 1 X_BITS_TYPESIZES_H = 1 X_BITS_TYPES_H = 1 X_BITS_UINTN_IDENTITY_H = 1 X_BSD_SIZE_T_ = 0 X_BSD_SIZE_T_DEFINED_ = 0 X_DEFAULT_SOURCE = 1 X_ENDIAN_H = 1 X_FEATURES_H = 1 X_FILE_OFFSET_BITS = 64 X_GCC_SIZE_T = 0 X_ILP32 = 1 X_LINUX_POSIX_TYPES_H = 0 X_NETDB_H = 1 X_NETINET_IN_H = 1 X_PATH_HEQUIV = "/etc/hosts.equiv" X_PATH_HOSTS = "/etc/hosts" X_PATH_NETWORKS = "/etc/networks" X_PATH_NSSWITCH_CONF = "/etc/nsswitch.conf" X_PATH_PROTOCOLS = "/etc/protocols" X_PATH_SERVICES = "/etc/services" X_POSIX_C_SOURCE = 200809 X_POSIX_SOURCE = 1 X_RPC_NETDB_H = 1 X_RWLOCK_INTERNAL_H = 0 X_SIZET_ = 0 X_SIZE_T = 0 X_SIZE_T_ = 0 X_SIZE_T_DECLARED = 0 X_SIZE_T_DEFINED = 0 X_SIZE_T_DEFINED_ = 0 X_SS_SIZE = 128 X_STDC_PREDEF_H = 1 X_STRUCT_TIMESPEC = 1 X_SYS_CDEFS_H = 1 X_SYS_SELECT_H = 1 X_SYS_SIZE_T_H = 0 X_SYS_SOCKET_H = 1 X_SYS_TYPES_H = 1 X_THREAD_MUTEX_INTERNAL_H = 1 X_THREAD_SHARED_TYPES_H = 1 X_T_SIZE = 0 X_T_SIZE_ = 0 I386 = 1 Linux = 1 Unix = 1 ) // Bits in the FLAGS argument to `send', `recv', et al. const ( /* socket.h:200:1: */ MSG_OOB = 1 // Process out-of-band data. MSG_PEEK = 2 // Peek at incoming messages. MSG_DONTROUTE = 4 // Don't use local routing. MSG_CTRUNC = 8 // Control data lost before delivery. MSG_PROXY = 16 // Supply or ask second address. MSG_TRUNC = 32 MSG_DONTWAIT = 64 // Nonblocking IO. MSG_EOR = 128 // End of record. MSG_WAITALL = 256 // Wait for a full request. MSG_FIN = 512 MSG_SYN = 1024 MSG_CONFIRM = 2048 // Confirm path validity. MSG_RST = 4096 MSG_ERRQUEUE = 8192 // Fetch message from error queue. MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. MSG_MORE = 32768 // Sender will send more. MSG_WAITFORONE = 65536 // Wait for at least one packet to return. MSG_BATCH = 262144 // sendmmsg: more messages coming. MSG_ZEROCOPY = 67108864 // Use user data in kernel path. MSG_FASTOPEN = 536870912 // Send data in TCP SYN. MSG_CMSG_CLOEXEC = 1073741824 ) // Socket level message types. This must match the definitions in // // <linux/socket.h>. const ( /* socket.h:332:1: */ SCM_RIGHTS = 1 ) // Get the architecture-dependent definition of enum __socket_type. // Define enum __socket_type for generic Linux. // Copyright (C) 1991-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // Types of sockets. const ( /* socket_type.h:24:1: */ SOCK_STREAM = 1 // Sequenced, reliable, connection-based // byte streams. SOCK_DGRAM = 2 // Connectionless, unreliable datagrams // of fixed maximum length. SOCK_RAW = 3 // Raw protocol interface. SOCK_RDM = 4 // Reliably-delivered messages. SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, // datagrams of fixed maximum length. SOCK_DCCP = 6 // Datagram Congestion Control Protocol. SOCK_PACKET = 10 // Linux specific way of getting packets // at the dev level. For writing rarp and // other similar things on the user level. // Flags to be ORed into the type parameter of socket and socketpair and // used for the flags parameter of paccept. SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the // new descriptor(s). SOCK_NONBLOCK = 2048 ) // Standard well-known ports. const ( /* in.h:122:1: */ IPPORT_ECHO = 7 // Echo service. IPPORT_DISCARD = 9 // Discard transmissions service. IPPORT_SYSTAT = 11 // System status service. IPPORT_DAYTIME = 13 // Time of day service. IPPORT_NETSTAT = 15 // Network status service. IPPORT_FTP = 21 // File Transfer Protocol. IPPORT_TELNET = 23 // Telnet protocol. IPPORT_SMTP = 25 // Simple Mail Transfer Protocol. IPPORT_TIMESERVER = 37 // Timeserver service. IPPORT_NAMESERVER = 42 // Domain Name Service. IPPORT_WHOIS = 43 // Internet Whois service. IPPORT_MTP = 57 IPPORT_TFTP = 69 // Trivial File Transfer Protocol. IPPORT_RJE = 77 IPPORT_FINGER = 79 // Finger service. IPPORT_TTYLINK = 87 IPPORT_SUPDUP = 95 // SUPDUP protocol. IPPORT_EXECSERVER = 512 // execd service. IPPORT_LOGINSERVER = 513 // rlogind service. IPPORT_CMDSERVER = 514 IPPORT_EFSSERVER = 520 // UDP ports. IPPORT_BIFFUDP = 512 IPPORT_WHOSERVER = 513 IPPORT_ROUTESERVER = 520 // Ports less than this value are reserved for privileged processes. IPPORT_RESERVED = 1024 // Ports greater this value are reserved for (non-privileged) servers. IPPORT_USERRESERVED = 5000 ) // Options for use with `getsockopt' and `setsockopt' at the IPv6 level. // The first word in the comment at the right is the data type used; // "bool" means a boolean value stored in an `int'. // Advanced API (RFC3542) (1). // Advanced API (RFC3542) (2). // RFC5014. // RFC5082. // Obsolete synonyms for the above. // IPV6_MTU_DISCOVER values. // Socket level values for IPv6. // Routing header options for IPv6. // Standard well-defined IP protocols. const ( /* in.h:40:1: */ IPPROTO_IP = 0 // Dummy protocol for TCP. IPPROTO_ICMP = 1 // Internet Control Message Protocol. IPPROTO_IGMP = 2 // Internet Group Management Protocol. IPPROTO_IPIP = 4 // IPIP tunnels (older KA9Q tunnels use 94). IPPROTO_TCP = 6 // Transmission Control Protocol. IPPROTO_EGP = 8 // Exterior Gateway Protocol. IPPROTO_PUP = 12 // PUP protocol. IPPROTO_UDP = 17 // User Datagram Protocol. IPPROTO_IDP = 22 // XNS IDP protocol. IPPROTO_TP = 29 // SO Transport Protocol Class 4. IPPROTO_DCCP = 33 // Datagram Congestion Control Protocol. IPPROTO_IPV6 = 41 // IPv6 header. IPPROTO_RSVP = 46 // Reservation Protocol. IPPROTO_GRE = 47 // General Routing Encapsulation. IPPROTO_ESP = 50 // encapsulating security payload. IPPROTO_AH = 51 // authentication header. IPPROTO_MTP = 92 // Multicast Transport Protocol. IPPROTO_BEETPH = 94 // IP option pseudo header for BEET. IPPROTO_ENCAP = 98 // Encapsulation Header. IPPROTO_PIM = 103 // Protocol Independent Multicast. IPPROTO_COMP = 108 // Compression Header Protocol. IPPROTO_SCTP = 132 // Stream Control Transmission Protocol. IPPROTO_UDPLITE = 136 // UDP-Lite protocol. IPPROTO_MPLS = 137 // MPLS in IP. IPPROTO_RAW = 255 // Raw IP packets. IPPROTO_MAX = 256 ) // If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel // // network headers first and we should use those ABI-identical definitions // instead of our own, otherwise 0. const ( /* in.h:99:1: */ IPPROTO_HOPOPTS = 0 // IPv6 Hop-by-Hop options. IPPROTO_ROUTING = 43 // IPv6 routing header. IPPROTO_FRAGMENT = 44 // IPv6 fragmentation header. IPPROTO_ICMPV6 = 58 // ICMPv6. IPPROTO_NONE = 59 // IPv6 no next header. IPPROTO_DSTOPTS = 60 // IPv6 destination options. IPPROTO_MH = 135 ) // The following constants should be used for the second parameter of // // `shutdown'. const ( /* socket.h:41:1: */ SHUT_RD = 0 // No more receptions. SHUT_WR = 1 // No more transmissions. SHUT_RDWR = 2 ) type Ptrdiff_t = int32 /* <builtin>:3:26 */ type Size_t = uint32 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // Copyright (C) 1996-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // All data returned by the network data base library are supplied in // host order and returned in network order (suitable for use in // system calls). // Copyright (C) 1991-2020 Free Software Foundation, Inc. // This file is part of the GNU C Library. // // The GNU C Library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // The GNU C Library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with the GNU C Library; if not, see // <https://www.gnu.org/licenses/>. // These are defined by the user (or the compiler) // to specify the desired environment: // // __STRICT_ANSI__ ISO Standard C. // _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. // _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. // _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. // __STDC_WANT_LIB_EXT2__ // Extensions to ISO C99 from TR 27431-2:2010. // __STDC_WANT_IEC_60559_BFP_EXT__ // Extensions to ISO C11 from TS 18661-1:2014. // __STDC_WANT_IEC_60559_FUNCS_EXT__ // Extensions to ISO C11 from TS 18661-4:2015. // __STDC_WANT_IEC_60559_TYPES_EXT__ // Extensions to ISO C11 from TS 18661-3:2015. // // _POSIX_SOURCE IEEE Std 1003.1. // _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; // if >=199309L, add IEEE Std 1003.1b-1993; // if >=199506L, add IEEE Std 1003.1c-1995; // if >=200112L, all of IEEE 1003.1-2004 // if >=200809L, all of IEEE 1003.1-2008 // _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if // Single Unix conformance is wanted, to 600 for the // sixth revision, to 700 for the seventh revision. // _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. // _LARGEFILE_SOURCE Some more functions for correct standard I/O. // _LARGEFILE64_SOURCE Additional functionality from LFS for large files. // _FILE_OFFSET_BITS=N Select default filesystem interface. // _ATFILE_SOURCE Additional *at interfaces. // _GNU_SOURCE All of the above, plus GNU extensions. // _DEFAULT_SOURCE The default set of features (taking precedence over // __STRICT_ANSI__). // // _FORTIFY_SOURCE Add security hardening to many library functions. // Set to 1 or 2; 2 performs stricter checks than 1. // // _REENTRANT, _THREAD_SAFE // Obsolete; equivalent to _POSIX_C_SOURCE=199506L. // // The `-ansi' switch to the GNU C compiler, and standards conformance // options such as `-std=c99', define __STRICT_ANSI__. If none of // these are defined, or if _DEFAULT_SOURCE is defined, the default is // to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to // 200809L, as well as enabling miscellaneous functions from BSD and // SVID. If more than one of these are defined, they accumulate. For // example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together // give you ISO C, 1003.1, and 1003.2, but nothing else. // // These are defined by this file and are used by the // header files to decide what to declare or define: // // __GLIBC_USE (F) Define things from feature set F. This is defined // to 1 or 0; the subsequent macros are either defined // or undefined, and those tests should be moved to // __GLIBC_USE. // __USE_ISOC11 Define ISO C11 things. // __USE_ISOC99 Define ISO C99 things. // __USE_ISOC95 Define ISO C90 AMD1 (C95) things. // __USE_ISOCXX11 Define ISO C++11 things. // __USE_POSIX Define IEEE Std 1003.1 things. // __USE_POSIX2 Define IEEE Std 1003.2 things. // __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. // __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. // __USE_XOPEN Define XPG things. // __USE_XOPEN_EXTENDED Define X/Open Unix things. // __USE_UNIX98 Define Single Unix V2 things. // __USE_XOPEN2K Define XPG6 things. // __USE_XOPEN2KXSI Define XPG6 XSI things. // __USE_XOPEN2K8 Define XPG7 things. // __USE_XOPEN2K8XSI Define XPG7 XSI things. // __USE_LARGEFILE Define correct standard I/O things. // __USE_LARGEFILE64 Define LFS things with separate names. // __USE_FILE_OFFSET64 Define 64bit interface as default. // __USE_MISC Define things from 4.3BSD or System V Unix. // __USE_ATFILE Define *at interfaces and AT_* constants for them. // __USE_GNU Define GNU extensions. // __USE_FORTIFY_LEVEL Additional security measures used, according to level. // // The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are // defined by this file unconditionally. `__GNU_LIBRARY__' is provided // only for compatibility. All new code should use the other symbols // to test for features. // // All macros listed above as possibly being defined by this file are // explicitly undefined if they are not explicitly defined. // Feature-test macros that are not defined by the user or compiler // but are implied by the other feature-test macros defined (or by the // lack of any definitions) are defined by the file. // // ISO C feature test macros depend on the definition of the macro // when an affected header is included, not when the first system // header is included, and so they are handled in // <bits/libc-header-start.h>, which does not have a multiple include // guard. Feature test macros that can be handled from the first // system header included are handled here. // Undefine everything, so we get a clean slate. // Suppress kernel-name space pollution unless user expressedly asks // for it. // Convenience macro to test the version of gcc. // Use like this: // #if __GNUC_PREREQ (2,8) // ... code requiring gcc 2.8 or later ... // #endif // Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was // added in 2.0. // Similarly for clang. Features added to GCC after version 4.2 may // or may not also be available in clang, and clang's definitions of // __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such // features can be queried via __has_extension/__has_feature. // Whether to use feature set F. // _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for // _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not // issue a warning; the expectation is that the source is being // transitioned to use the new macro. // If _GNU_SOURCE was defined by the user, turn on all the other features. // If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, // define _DEFAULT_SOURCE. // This is to enable the ISO C2X extension. // This is to enable the ISO C11 extension. // This is to enable the ISO C99 extension. // This is to enable the ISO C90 Amendment 1:1995 extension.
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_freebsd_arm64.go
vendor/modernc.org/libc/netdb/capi_freebsd_arm64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_freebsd_amd64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_openbsd_386.go
vendor/modernc.org/libc/netdb/netdb_openbsd_386.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_openbsd_386.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AI_ADDRCONFIG = 64 // netdb.h:165:1: AI_CANONNAME = 2 // netdb.h:160:1: AI_EXT = 8 // netdb.h:162:1: AI_FQDN = 32 // netdb.h:164:1: AI_MASK = 119 // netdb.h:167:1: AI_NUMERICHOST = 4 // netdb.h:161:1: AI_NUMERICSERV = 16 // netdb.h:163:1: AI_PASSIVE = 1 // netdb.h:159:1: BIG_ENDIAN = 4321 // endian.h:45:1: BYTE_ORDER = 1234 // endian.h:47:1: EAI_ADDRFAMILY = -9 // netdb.h:196:1: EAI_AGAIN = -3 // netdb.h:190:1: EAI_BADFLAGS = -1 // netdb.h:188:1: EAI_BADHINTS = -12 // netdb.h:199:1: EAI_FAIL = -4 // netdb.h:191:1: EAI_FAMILY = -6 // netdb.h:193:1: EAI_MEMORY = -10 // netdb.h:197:1: EAI_NODATA = -5 // netdb.h:192:1: EAI_NONAME = -2 // netdb.h:189:1: EAI_OVERFLOW = -14 // netdb.h:201:1: EAI_PROTOCOL = -13 // netdb.h:200:1: EAI_SERVICE = -8 // netdb.h:195:1: EAI_SOCKTYPE = -7 // netdb.h:194:1: EAI_SYSTEM = -11 // netdb.h:198:1: ERRSET_FAIL = 2 // netdb.h:225:1: ERRSET_INVAL = 3 // netdb.h:226:1: ERRSET_NODATA = 5 // netdb.h:228:1: ERRSET_NOMEMORY = 1 // netdb.h:224:1: ERRSET_NONAME = 4 // netdb.h:227:1: ERRSET_SUCCESS = 0 // netdb.h:223:1: HOST_NOT_FOUND = 1 // netdb.h:151:1: ICMP6_FILTER = 18 // in6.h:304:1: INET6_ADDRSTRLEN = 46 // in6.h:97:1: INET_ADDRSTRLEN = 16 // in.h:382:1: IN_CLASSA_MAX = 128 // in.h:195:1: IN_CLASSA_NSHIFT = 24 // in.h:193:1: IN_CLASSB_MAX = 65536 // in.h:202:1: IN_CLASSB_NSHIFT = 16 // in.h:200:1: IN_CLASSC_NSHIFT = 8 // in.h:207:1: IN_CLASSD_NSHIFT = 28 // in.h:214:1: IN_LOOPBACKNET = 127 // in.h:253:1: IN_RFC3021_NSHIFT = 31 // in.h:219:1: IPCTL_ARPDOWN = 40 // in.h:698:1: IPCTL_ARPQUEUE = 41 // in.h:699:1: IPCTL_ARPQUEUED = 36 // in.h:694:1: IPCTL_ARPTIMEOUT = 39 // in.h:697:1: IPCTL_DEFTTL = 3 // in.h:662:1: IPCTL_DIRECTEDBCAST = 6 // in.h:664:1: IPCTL_ENCDEBUG = 12 // in.h:670:1: IPCTL_FORWARDING = 1 // in.h:660:1: IPCTL_IFQUEUE = 30 // in.h:688:1: IPCTL_IPPORT_FIRSTAUTO = 7 // in.h:665:1: IPCTL_IPPORT_HIFIRSTAUTO = 9 // in.h:667:1: IPCTL_IPPORT_HILASTAUTO = 10 // in.h:668:1: IPCTL_IPPORT_LASTAUTO = 8 // in.h:666:1: IPCTL_IPPORT_MAXQUEUE = 11 // in.h:669:1: IPCTL_IPSEC_ALLOCATIONS = 18 // in.h:676:1: IPCTL_IPSEC_AUTH_ALGORITHM = 26 // in.h:684:1: IPCTL_IPSEC_BYTES = 20 // in.h:678:1: IPCTL_IPSEC_EMBRYONIC_SA_TIMEOUT = 15 // in.h:673:1: IPCTL_IPSEC_ENC_ALGORITHM = 25 // in.h:683:1: IPCTL_IPSEC_EXPIRE_ACQUIRE = 14 // in.h:672:1: IPCTL_IPSEC_FIRSTUSE = 24 // in.h:682:1: IPCTL_IPSEC_IPCOMP_ALGORITHM = 29 // in.h:687:1: IPCTL_IPSEC_REQUIRE_PFS = 16 // in.h:674:1: IPCTL_IPSEC_SOFT_ALLOCATIONS = 17 // in.h:675:1: IPCTL_IPSEC_SOFT_BYTES = 19 // in.h:677:1: IPCTL_IPSEC_SOFT_FIRSTUSE = 23 // in.h:681:1: IPCTL_IPSEC_SOFT_TIMEOUT = 22 // in.h:680:1: IPCTL_IPSEC_STATS = 13 // in.h:671:1: IPCTL_IPSEC_TIMEOUT = 21 // in.h:679:1: IPCTL_MAXID = 42 // in.h:700:1: IPCTL_MFORWARDING = 31 // in.h:689:1: IPCTL_MRTMFC = 37 // in.h:695:1: IPCTL_MRTPROTO = 34 // in.h:692:1: IPCTL_MRTSTATS = 35 // in.h:693:1: IPCTL_MRTVIF = 38 // in.h:696:1: IPCTL_MTUDISC = 27 // in.h:685:1: IPCTL_MTUDISCTIMEOUT = 28 // in.h:686:1: IPCTL_MULTIPATH = 32 // in.h:690:1: IPCTL_SENDREDIRECTS = 2 // in.h:661:1: IPCTL_SOURCEROUTE = 5 // in.h:663:1: IPCTL_STATS = 33 // in.h:691:1: IPPORT_HIFIRSTAUTO = 49152 // in.h:159:1: IPPORT_HILASTAUTO = 65535 // in.h:160:1: IPPORT_RESERVED = 1024 // in.h:153:1: IPPORT_USERRESERVED = 49151 // in.h:154:1: IPPROTO_AH = 51 // in.h:89:1: IPPROTO_CARP = 112 // in.h:99:1: IPPROTO_DIVERT = 258 // in.h:109:1: IPPROTO_DONE = 257 // in.h:173:1: IPPROTO_DSTOPTS = 60 // in.h:93:1: IPPROTO_EGP = 8 // in.h:78:1: IPPROTO_ENCAP = 98 // in.h:96:1: IPPROTO_EON = 80 // in.h:94:1: IPPROTO_ESP = 50 // in.h:88:1: IPPROTO_ETHERIP = 97 // in.h:95:1: IPPROTO_FRAGMENT = 44 // in.h:85:1: IPPROTO_GGP = 3 // in.h:74:1: IPPROTO_GRE = 47 // in.h:87:1: IPPROTO_HOPOPTS = 0 // in.h:71:1: IPPROTO_ICMP = 1 // in.h:72:1: IPPROTO_ICMPV6 = 58 // in.h:91:1: IPPROTO_IDP = 22 // in.h:81:1: IPPROTO_IGMP = 2 // in.h:73:1: IPPROTO_IP = 0 // in.h:70:1: IPPROTO_IPCOMP = 108 // in.h:98:1: IPPROTO_IPIP = 4 // in.h:75:1: IPPROTO_IPV4 = 4 // in.h:76:1: IPPROTO_IPV6 = 41 // in.h:83:1: IPPROTO_MAX = 256 // in.h:106:1: IPPROTO_MAXID = 259 // in.h:393:1: IPPROTO_MOBILE = 55 // in.h:90:1: IPPROTO_MPLS = 137 // in.h:102:1: IPPROTO_NONE = 59 // in.h:92:1: IPPROTO_PFSYNC = 240 // in.h:103:1: IPPROTO_PIM = 103 // in.h:97:1: IPPROTO_PUP = 12 // in.h:79:1: IPPROTO_RAW = 255 // in.h:104:1: IPPROTO_ROUTING = 43 // in.h:84:1: IPPROTO_RSVP = 46 // in.h:86:1: IPPROTO_SCTP = 132 // in.h:100:1: IPPROTO_TCP = 6 // in.h:77:1: IPPROTO_TP = 29 // in.h:82:1: IPPROTO_UDP = 17 // in.h:80:1: IPPROTO_UDPLITE = 136 // in.h:101:1: IPSEC6_OUTSA = 56 // in6.h:337:1: IPSEC_AUTH_LEVEL_DEFAULT = 1 // in.h:336:1: IPSEC_ESP_NETWORK_LEVEL_DEFAULT = 1 // in.h:338:1: IPSEC_ESP_TRANS_LEVEL_DEFAULT = 1 // in.h:337:1: IPSEC_IPCOMP_LEVEL_DEFAULT = 1 // in.h:339:1: IPSEC_LEVEL_AVAIL = 0x01 // in.h:330:1: IPSEC_LEVEL_BYPASS = 0x00 // in.h:328:1: IPSEC_LEVEL_DEFAULT = 1 // in.h:334:1: IPSEC_LEVEL_NONE = 0x00 // in.h:329:1: IPSEC_LEVEL_REQUIRE = 0x03 // in.h:332:1: IPSEC_LEVEL_UNIQUE = 0x04 // in.h:333:1: IPSEC_LEVEL_USE = 0x02 // in.h:331:1: IPV6CTL_ACCEPT_RTADV = 12 // in6.h:575:1: IPV6CTL_AUTO_FLOWLABEL = 17 // in6.h:579:1: IPV6CTL_DAD_COUNT = 16 // in6.h:578:1: IPV6CTL_DAD_PENDING = 49 // in6.h:589:1: IPV6CTL_DEFHLIM = 3 // in6.h:567:1: IPV6CTL_DEFMCASTHLIM = 18 // in6.h:580:1: IPV6CTL_FORWARDING = 1 // in6.h:565:1: IPV6CTL_FORWSRCRT = 5 // in6.h:568:1: IPV6CTL_HDRNESTLIMIT = 15 // in6.h:577:1: IPV6CTL_IFQUEUE = 51 // in6.h:591:1: IPV6CTL_LOG_INTERVAL = 14 // in6.h:576:1: IPV6CTL_MAXDYNROUTES = 48 // in6.h:588:1: IPV6CTL_MAXFRAGPACKETS = 9 // in6.h:572:1: IPV6CTL_MAXFRAGS = 41 // in6.h:583:1: IPV6CTL_MAXID = 55 // in6.h:595:1: IPV6CTL_MCAST_PMTU = 44 // in6.h:586:1: IPV6CTL_MFORWARDING = 42 // in6.h:584:1: IPV6CTL_MRTMFC = 53 // in6.h:593:1: IPV6CTL_MRTMIF = 52 // in6.h:592:1: IPV6CTL_MRTPROTO = 8 // in6.h:571:1: IPV6CTL_MRTSTATS = 7 // in6.h:570:1: IPV6CTL_MTUDISCTIMEOUT = 50 // in6.h:590:1: IPV6CTL_MULTIPATH = 43 // in6.h:585:1: IPV6CTL_NEIGHBORGCTHRESH = 45 // in6.h:587:1: IPV6CTL_SENDREDIRECTS = 2 // in6.h:566:1: IPV6CTL_SOIIKEY = 54 // in6.h:594:1: IPV6CTL_SOURCECHECK = 10 // in6.h:573:1: IPV6CTL_SOURCECHECK_LOGINT = 11 // in6.h:574:1: IPV6CTL_STATS = 6 // in6.h:569:1: IPV6CTL_USE_DEPRECATED = 21 // in6.h:581:1: IPV6PROTO_MAXID = 259 // in6.h:470:1: IPV6_AUTH_LEVEL = 53 // in6.h:333:1: IPV6_AUTOFLOWLABEL = 59 // in6.h:341:1: IPV6_CHECKSUM = 26 // in6.h:307:1: IPV6_DEFAULT_MULTICAST_HOPS = 1 // in6.h:360:1: IPV6_DEFAULT_MULTICAST_LOOP = 1 // in6.h:361:1: IPV6_DONTFRAG = 62 // in6.h:345:1: IPV6_DSTOPTS = 50 // in6.h:330:1: IPV6_ESP_NETWORK_LEVEL = 55 // in6.h:335:1: IPV6_ESP_TRANS_LEVEL = 54 // in6.h:334:1: IPV6_HOPLIMIT = 47 // in6.h:327:1: IPV6_HOPOPTS = 49 // in6.h:329:1: IPV6_IPCOMP_LEVEL = 60 // in6.h:342:1: IPV6_JOIN_GROUP = 12 // in6.h:300:1: IPV6_LEAVE_GROUP = 13 // in6.h:301:1: IPV6_MINHOPCOUNT = 65 // in6.h:349:1: IPV6_MULTICAST_HOPS = 10 // in6.h:298:1: IPV6_MULTICAST_IF = 9 // in6.h:297:1: IPV6_MULTICAST_LOOP = 11 // in6.h:299:1: IPV6_NEXTHOP = 48 // in6.h:328:1: IPV6_PATHMTU = 44 // in6.h:322:1: IPV6_PIPEX = 63 // in6.h:346:1: IPV6_PKTINFO = 46 // in6.h:326:1: IPV6_PORTRANGE = 14 // in6.h:302:1: IPV6_PORTRANGE_DEFAULT = 0 // in6.h:393:1: IPV6_PORTRANGE_HIGH = 1 // in6.h:394:1: IPV6_PORTRANGE_LOW = 2 // in6.h:395:1: IPV6_RECVDSTOPTS = 40 // in6.h:317:1: IPV6_RECVDSTPORT = 64 // in6.h:348:1: IPV6_RECVHOPLIMIT = 37 // in6.h:314:1: IPV6_RECVHOPOPTS = 39 // in6.h:316:1: IPV6_RECVPATHMTU = 43 // in6.h:320:1: IPV6_RECVPKTINFO = 36 // in6.h:313:1: IPV6_RECVRTHDR = 38 // in6.h:315:1: IPV6_RECVTCLASS = 57 // in6.h:339:1: IPV6_RTABLE = 0x1021 // in6.h:351:1: IPV6_RTHDR = 51 // in6.h:331:1: IPV6_RTHDRDSTOPTS = 35 // in6.h:311:1: IPV6_RTHDR_LOOSE = 0 // in6.h:354:1: IPV6_RTHDR_TYPE_0 = 0 // in6.h:355:1: IPV6_TCLASS = 61 // in6.h:344:1: IPV6_UNICAST_HOPS = 4 // in6.h:296:1: IPV6_USE_MIN_MTU = 42 // in6.h:319:1: IPV6_V6ONLY = 27 // in6.h:308:1: IP_ADD_MEMBERSHIP = 12 // in.h:297:1: IP_AUTH_LEVEL = 20 // in.h:300:1: IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:347:1: IP_DEFAULT_MULTICAST_TTL = 1 // in.h:346:1: IP_DROP_MEMBERSHIP = 13 // in.h:298:1: IP_ESP_NETWORK_LEVEL = 22 // in.h:302:1: IP_ESP_TRANS_LEVEL = 21 // in.h:301:1: IP_HDRINCL = 2 // in.h:287:1: IP_IPCOMP_LEVEL = 29 // in.h:309:1: IP_IPDEFTTL = 37 // in.h:317:1: IP_IPSECFLOWINFO = 36 // in.h:316:1: IP_IPSEC_LOCAL_AUTH = 27 // in.h:307:1: IP_IPSEC_LOCAL_CRED = 25 // in.h:305:1: IP_IPSEC_LOCAL_ID = 23 // in.h:303:1: IP_IPSEC_REMOTE_AUTH = 28 // in.h:308:1: IP_IPSEC_REMOTE_CRED = 26 // in.h:306:1: IP_IPSEC_REMOTE_ID = 24 // in.h:304:1: IP_MAX_MEMBERSHIPS = 4095 // in.h:354:1: IP_MINTTL = 32 // in.h:312:1: IP_MIN_MEMBERSHIPS = 15 // in.h:353:1: IP_MULTICAST_IF = 9 // in.h:294:1: IP_MULTICAST_LOOP = 11 // in.h:296:1: IP_MULTICAST_TTL = 10 // in.h:295:1: IP_OPTIONS = 1 // in.h:286:1: IP_PIPEX = 34 // in.h:314:1: IP_PORTRANGE = 19 // in.h:299:1: IP_PORTRANGE_DEFAULT = 0 // in.h:374:1: IP_PORTRANGE_HIGH = 1 // in.h:375:1: IP_PORTRANGE_LOW = 2 // in.h:376:1: IP_RECVDSTADDR = 7 // in.h:292:1: IP_RECVDSTPORT = 33 // in.h:313:1: IP_RECVIF = 30 // in.h:310:1: IP_RECVOPTS = 5 // in.h:290:1: IP_RECVRETOPTS = 6 // in.h:291:1: IP_RECVRTABLE = 35 // in.h:315:1: IP_RECVTTL = 31 // in.h:311:1: IP_RETOPTS = 8 // in.h:293:1: IP_RTABLE = 0x1021 // in.h:321:1: IP_SENDSRCADDR = 7 // in.h:318:1: IP_TOS = 3 // in.h:288:1: IP_TTL = 4 // in.h:289:1: LITTLE_ENDIAN = 1234 // endian.h:44:1: NETDB_INTERNAL = -1 // netdb.h:149:1: NETDB_SUCCESS = 0 // netdb.h:150:1: NI_DGRAM = 16 // netdb.h:175:1: NI_MAXHOST = 256 // netdb.h:179:1: NI_MAXSERV = 32 // netdb.h:180:1: NI_NAMEREQD = 8 // netdb.h:174:1: NI_NOFQDN = 4 // netdb.h:173:1: NI_NUMERICHOST = 1 // netdb.h:171:1: NI_NUMERICSERV = 2 // netdb.h:172:1: NO_ADDRESS = 4 // netdb.h:155:1: NO_DATA = 4 // netdb.h:154:1: NO_RECOVERY = 3 // netdb.h:153:1: PDP_ENDIAN = 3412 // endian.h:46:1: RRSET_VALIDATED = 1 // netdb.h:218:1: SCOPE_DELIMITER = 37 // netdb.h:185:1: SIN6_LEN = 0 // in6.h:104:1: TRY_AGAIN = 2 // netdb.h:152:1: X_BIG_ENDIAN = 4321 // _endian.h:43:1: X_BYTE_ORDER = 1234 // endian.h:58:1: X_CLOCKID_T_DEFINED_ = 0 // types.h:162:1: X_CLOCK_T_DEFINED_ = 0 // types.h:157:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_ILP32 = 1 // <predefined>:1:1: X_INT16_T_DEFINED_ = 0 // types.h:84:1: X_INT32_T_DEFINED_ = 0 // types.h:94:1: X_INT64_T_DEFINED_ = 0 // types.h:104:1: X_INT8_T_DEFINED_ = 0 // types.h:74:1: X_IN_ADDR_DECLARED = 0 // in.h:163:1: X_IN_TYPES_DEFINED_ = 0 // in.h:62:1: X_LITTLE_ENDIAN = 1234 // _endian.h:42:1: X_MACHINE_CDEFS_H_ = 0 // cdefs.h:9:1: X_MACHINE_ENDIAN_H_ = 0 // endian.h:28:1: X_MACHINE__TYPES_H_ = 0 // _types.h:36:1: X_MAX_PAGE_SHIFT = 12 // _types.h:52:1: X_NETDB_H_ = 0 // netdb.h:88:1: X_NETINET6_IN6_H_ = 0 // in6.h:69:1: X_NETINET_IN_H_ = 0 // in.h:39:1: X_OFF_T_DEFINED_ = 0 // types.h:192:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:97:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:98:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:99:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:100:1: X_PATH_SERVICES = "/etc/services" // netdb.h:101:1: X_PDP_ENDIAN = 3412 // _endian.h:44:1: X_PID_T_DEFINED_ = 0 // types.h:167:1: X_QUAD_HIGHWORD = 1 // _endian.h:95:1: X_QUAD_LOWWORD = 0 // _endian.h:96:1: X_SA_FAMILY_T_DEFINED_ = 0 // in.h:57:1: X_SIZE_T_DEFINED_ = 0 // types.h:172:1: X_SOCKLEN_T_DEFINED_ = 0 // in6.h:400:1: X_SSIZE_T_DEFINED_ = 0 // types.h:177:1: X_STACKALIGNBYTES = 15 // _types.h:49:1: X_SYS_CDEFS_H_ = 0 // cdefs.h:39:1: X_SYS_ENDIAN_H_ = 0 // endian.h:38:1: X_SYS_TYPES_H_ = 0 // types.h:41:1: X_SYS__ENDIAN_H_ = 0 // _endian.h:34:1: X_SYS__TYPES_H_ = 0 // _types.h:35:1: X_TIMER_T_DEFINED_ = 0 // types.h:187:1: X_TIME_T_DEFINED_ = 0 // types.h:182:1: X_UINT16_T_DEFINED_ = 0 // types.h:89:1: X_UINT32_T_DEFINED_ = 0 // types.h:99:1: X_UINT64_T_DEFINED_ = 0 // types.h:109:1: X_UINT8_T_DEFINED_ = 0 // types.h:79:1: I386 = 1 // <predefined>:339:1: Unix = 1 // <predefined>:340:1: ) type Ptrdiff_t = int32 /* <builtin>:3:26 */ type Size_t = uint32 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // $OpenBSD: netdb.h,v 1.33 2015/01/18 20:29:31 deraadt Exp $ // ++Copyright++ 1980, 1983, 1988, 1993 // - // Copyright (c) 1980, 1983, 1988, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // - // Portions Copyright (c) 1993 by Digital Equipment Corporation. // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies, and that // the name of Digital Equipment Corporation not be used in advertising or // publicity pertaining to distribution of the document or software without // specific, written prior permission. // // THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL // WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT // CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL // DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR // PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS // ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS // SOFTWARE. // - // --Copyright-- // Copyright (c) 1995, 1996, 1997, 1998, 1999 Craig Metz. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the author nor the names of any contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // @(#)netdb.h 8.1 (Berkeley) 6/2/93 // $From: netdb.h,v 8.7 1996/05/09 05:59:09 vixie Exp $ // $OpenBSD: in.h,v 1.141 2021/06/02 00:09:57 dlg Exp $ // $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ // Copyright (c) 1982, 1986, 1990, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // Constants and structures defined by the internet system, // Per RFC 790, September 1981, and numerous additions. // $OpenBSD: cdefs.h,v 1.43 2018/10/29 17:10:40 guenther Exp $ // $NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $ // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.7 (Berkeley) 1/21/94 // $OpenBSD: cdefs.h,v 1.10 2013/03/28 17:30:45 martynas Exp $ // Written by J.T. Conklin <jtc@wimsey.com> 01/17/95. // Public domain. // Macro to test if we're using a specific version of gcc or later. // The __CONCAT macro is used to concatenate parts of symbol names, e.g. // with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. // The __CONCAT macro is a bit tricky -- make sure you don't put spaces // in between its arguments. Do not use __CONCAT on double-quoted strings, // such as those from the __STRING macro: to concatenate strings just put // them next to each other. // GCC1 and some versions of GCC2 declare dead (non-returning) and // pure (no side effects) functions using "volatile" and "const"; // unfortunately, these then cause warnings under "-ansi -pedantic". // GCC >= 2.5 uses the __attribute__((attrs)) style. All of these // work for GNU C++ (modulo a slight glitch in the C++ grammar in // the distribution version of 2.5.5). // __returns_twice makes the compiler not assume the function // only returns once. This affects registerisation of variables: // even local variables need to be in memory across such a call. // Example: setjmp() // __only_inline makes the compiler only use this function definition
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_linux_riscv64.go
vendor/modernc.org/libc/netdb/capi_linux_riscv64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_riscv64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_linux_ppc64le.go
vendor/modernc.org/libc/netdb/netdb_linux_ppc64le.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_linux_ppc64le.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_ALG = 38 // socket.h:133:1: AF_APPLETALK = 5 // socket.h:99:1: AF_ASH = 18 // socket.h:113:1: AF_ATMPVC = 8 // socket.h:102:1: AF_ATMSVC = 20 // socket.h:115:1: AF_AX25 = 3 // socket.h:97:1: AF_BLUETOOTH = 31 // socket.h:126:1: AF_BRIDGE = 7 // socket.h:101:1: AF_CAIF = 37 // socket.h:132:1: AF_CAN = 29 // socket.h:124:1: AF_DECnet = 12 // socket.h:106:1: AF_ECONET = 19 // socket.h:114:1: AF_FILE = 1 // socket.h:95:1: AF_IB = 27 // socket.h:122:1: AF_IEEE802154 = 36 // socket.h:131:1: AF_INET = 2 // socket.h:96:1: AF_INET6 = 10 // socket.h:104:1: AF_IPX = 4 // socket.h:98:1: AF_IRDA = 23 // socket.h:118:1: AF_ISDN = 34 // socket.h:129:1: AF_IUCV = 32 // socket.h:127:1: AF_KCM = 41 // socket.h:136:1: AF_KEY = 15 // socket.h:109:1: AF_LLC = 26 // socket.h:121:1: AF_LOCAL = 1 // socket.h:93:1: AF_MAX = 45 // socket.h:140:1: AF_MPLS = 28 // socket.h:123:1: AF_NETBEUI = 13 // socket.h:107:1: AF_NETLINK = 16 // socket.h:110:1: AF_NETROM = 6 // socket.h:100:1: AF_NFC = 39 // socket.h:134:1: AF_PACKET = 17 // socket.h:112:1: AF_PHONET = 35 // socket.h:130:1: AF_PPPOX = 24 // socket.h:119:1: AF_QIPCRTR = 42 // socket.h:137:1: AF_RDS = 21 // socket.h:116:1: AF_ROSE = 11 // socket.h:105:1: AF_ROUTE = 16 // socket.h:111:1: AF_RXRPC = 33 // socket.h:128:1: AF_SECURITY = 14 // socket.h:108:1: AF_SMC = 43 // socket.h:138:1: AF_SNA = 22 // socket.h:117:1: AF_TIPC = 30 // socket.h:125:1: AF_UNIX = 1 // socket.h:94:1: AF_UNSPEC = 0 // socket.h:92:1: AF_VSOCK = 40 // socket.h:135:1: AF_WANPIPE = 25 // socket.h:120:1: AF_X25 = 9 // socket.h:103:1: AF_XDP = 44 // socket.h:139:1: AI_ADDRCONFIG = 0x0020 // netdb.h:601:1: AI_ALL = 0x0010 // netdb.h:600:1: AI_CANONNAME = 0x0002 // netdb.h:597:1: AI_NUMERICHOST = 0x0004 // netdb.h:598:1: AI_NUMERICSERV = 0x0400 // netdb.h:613:1: AI_PASSIVE = 0x0001 // netdb.h:596:1: AI_V4MAPPED = 0x0008 // netdb.h:599:1: BIG_ENDIAN = 4321 // endian.h:28:1: BYTE_ORDER = 1234 // endian.h:30:1: EAI_AGAIN = -3 // netdb.h:618:1: EAI_BADFLAGS = -1 // netdb.h:616:1: EAI_FAIL = -4 // netdb.h:619:1: EAI_FAMILY = -6 // netdb.h:620:1: EAI_MEMORY = -10 // netdb.h:623:1: EAI_NONAME = -2 // netdb.h:617:1: EAI_OVERFLOW = -12 // netdb.h:625:1: EAI_SERVICE = -8 // netdb.h:622:1: EAI_SOCKTYPE = -7 // netdb.h:621:1: EAI_SYSTEM = -11 // netdb.h:624:1: FD_SETSIZE = 1024 // select.h:73:1: FIOGETOWN = 0x8903 // sockios.h:8:1: FIOSETOWN = 0x8901 // sockios.h:6:1: HOST_NOT_FOUND = 1 // netdb.h:63:1: INET6_ADDRSTRLEN = 46 // in.h:234:1: INET_ADDRSTRLEN = 16 // in.h:233:1: IN_CLASSA_HOST = 16777215 // in.h:169:1: IN_CLASSA_MAX = 128 // in.h:170:1: IN_CLASSA_NET = 0xff000000 // in.h:167:1: IN_CLASSA_NSHIFT = 24 // in.h:168:1: IN_CLASSB_HOST = 65535 // in.h:175:1: IN_CLASSB_MAX = 65536 // in.h:176:1: IN_CLASSB_NET = 0xffff0000 // in.h:173:1: IN_CLASSB_NSHIFT = 16 // in.h:174:1: IN_CLASSC_HOST = 255 // in.h:181:1: IN_CLASSC_NET = 0xffffff00 // in.h:179:1: IN_CLASSC_NSHIFT = 8 // in.h:180:1: IN_LOOPBACKNET = 127 // in.h:197:1: IPPORT_RESERVED1 = 1024 // netdb.h:79:1: IPV6_2292DSTOPTS = 4 // in.h:171:1: IPV6_2292HOPLIMIT = 8 // in.h:175:1: IPV6_2292HOPOPTS = 3 // in.h:170:1: IPV6_2292PKTINFO = 2 // in.h:169:1: IPV6_2292PKTOPTIONS = 6 // in.h:173:1: IPV6_2292RTHDR = 5 // in.h:172:1: IPV6_ADDRFORM = 1 // in.h:168:1: IPV6_ADDR_PREFERENCES = 72 // in.h:223:1: IPV6_ADD_MEMBERSHIP = 20 // in.h:237:1: IPV6_AUTHHDR = 10 // in.h:180:1: IPV6_AUTOFLOWLABEL = 70 // in.h:220:1: IPV6_CHECKSUM = 7 // in.h:174:1: IPV6_DONTFRAG = 62 // in.h:214:1: IPV6_DROP_MEMBERSHIP = 21 // in.h:238:1: IPV6_DSTOPTS = 59 // in.h:211:1: IPV6_FREEBIND = 78 // in.h:233:1: IPV6_HDRINCL = 36 // in.h:198:1: IPV6_HOPLIMIT = 52 // in.h:204:1: IPV6_HOPOPTS = 54 // in.h:206:1: IPV6_IPSEC_POLICY = 34 // in.h:196:1: IPV6_JOIN_ANYCAST = 27 // in.h:192:1: IPV6_JOIN_GROUP = 20 // in.h:185:1: IPV6_LEAVE_ANYCAST = 28 // in.h:193:1: IPV6_LEAVE_GROUP = 21 // in.h:186:1: IPV6_MINHOPCOUNT = 73 // in.h:226:1: IPV6_MTU = 24 // in.h:189:1: IPV6_MTU_DISCOVER = 23 // in.h:188:1: IPV6_MULTICAST_ALL = 29 // in.h:194:1: IPV6_MULTICAST_HOPS = 18 // in.h:183:1: IPV6_MULTICAST_IF = 17 // in.h:182:1: IPV6_MULTICAST_LOOP = 19 // in.h:184:1: IPV6_NEXTHOP = 9 // in.h:179:1: IPV6_ORIGDSTADDR = 74 // in.h:228:1: IPV6_PATHMTU = 61 // in.h:213:1: IPV6_PKTINFO = 50 // in.h:202:1: IPV6_PMTUDISC_DO = 2 // in.h:246:1: IPV6_PMTUDISC_DONT = 0 // in.h:244:1: IPV6_PMTUDISC_INTERFACE = 4 // in.h:248:1: IPV6_PMTUDISC_OMIT = 5 // in.h:249:1: IPV6_PMTUDISC_PROBE = 3 // in.h:247:1: IPV6_PMTUDISC_WANT = 1 // in.h:245:1: IPV6_RECVDSTOPTS = 58 // in.h:210:1: IPV6_RECVERR = 25 // in.h:190:1: IPV6_RECVFRAGSIZE = 77 // in.h:232:1: IPV6_RECVHOPLIMIT = 51 // in.h:203:1: IPV6_RECVHOPOPTS = 53 // in.h:205:1: IPV6_RECVORIGDSTADDR = 74 // in.h:229:1: IPV6_RECVPATHMTU = 60 // in.h:212:1: IPV6_RECVPKTINFO = 49 // in.h:201:1: IPV6_RECVRTHDR = 56 // in.h:208:1: IPV6_RECVTCLASS = 66 // in.h:217:1: IPV6_ROUTER_ALERT = 22 // in.h:187:1: IPV6_ROUTER_ALERT_ISOLATE = 30 // in.h:195:1: IPV6_RTHDR = 57 // in.h:209:1: IPV6_RTHDRDSTOPTS = 55 // in.h:207:1: IPV6_RTHDR_LOOSE = 0 // in.h:256:1: IPV6_RTHDR_STRICT = 1 // in.h:257:1: IPV6_RTHDR_TYPE_0 = 0 // in.h:259:1: IPV6_RXDSTOPTS = 59 // in.h:241:1: IPV6_RXHOPOPTS = 54 // in.h:240:1: IPV6_TCLASS = 67 // in.h:218:1: IPV6_TRANSPARENT = 75 // in.h:230:1: IPV6_UNICAST_HOPS = 16 // in.h:181:1: IPV6_UNICAST_IF = 76 // in.h:231:1: IPV6_V6ONLY = 26 // in.h:191:1: IPV6_XFRM_POLICY = 35 // in.h:197:1: IP_ADD_MEMBERSHIP = 35 // in.h:121:1: IP_ADD_SOURCE_MEMBERSHIP = 39 // in.h:125:1: IP_BIND_ADDRESS_NO_PORT = 24 // in.h:103:1: IP_BLOCK_SOURCE = 38 // in.h:124:1: IP_CHECKSUM = 23 // in.h:102:1: IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:135:1: IP_DEFAULT_MULTICAST_TTL = 1 // in.h:134:1: IP_DROP_MEMBERSHIP = 36 // in.h:122:1: IP_DROP_SOURCE_MEMBERSHIP = 40 // in.h:126:1: IP_FREEBIND = 15 // in.h:89:1: IP_HDRINCL = 3 // in.h:48:1: IP_IPSEC_POLICY = 16 // in.h:90:1: IP_MAX_MEMBERSHIPS = 20 // in.h:136:1: IP_MINTTL = 21 // in.h:100:1: IP_MSFILTER = 41 // in.h:127:1: IP_MTU = 14 // in.h:88:1: IP_MTU_DISCOVER = 10 // in.h:84:1: IP_MULTICAST_ALL = 49 // in.h:128:1: IP_MULTICAST_IF = 32 // in.h:118:1: IP_MULTICAST_LOOP = 34 // in.h:120:1: IP_MULTICAST_TTL = 33 // in.h:119:1: IP_NODEFRAG = 22 // in.h:101:1: IP_OPTIONS = 4 // in.h:47:1: IP_ORIGDSTADDR = 20 // in.h:97:1: IP_PASSSEC = 18 // in.h:92:1: IP_PKTINFO = 8 // in.h:81:1: IP_PKTOPTIONS = 9 // in.h:82:1: IP_PMTUDISC = 10 // in.h:83:1: IP_PMTUDISC_DO = 2 // in.h:109:1: IP_PMTUDISC_DONT = 0 // in.h:107:1: IP_PMTUDISC_INTERFACE = 4 // in.h:114:1: IP_PMTUDISC_OMIT = 5 // in.h:116:1: IP_PMTUDISC_PROBE = 3 // in.h:110:1: IP_PMTUDISC_WANT = 1 // in.h:108:1: IP_RECVERR = 11 // in.h:85:1: IP_RECVFRAGSIZE = 25 // in.h:104:1: IP_RECVOPTS = 6 // in.h:51:1: IP_RECVORIGDSTADDR = 20 // in.h:98:1: IP_RECVRETOPTS = 7 // in.h:53:1: IP_RECVTOS = 13 // in.h:87:1: IP_RECVTTL = 12 // in.h:86:1: IP_RETOPTS = 7 // in.h:54:1: IP_ROUTER_ALERT = 5 // in.h:80:1: IP_TOS = 1 // in.h:49:1: IP_TRANSPARENT = 19 // in.h:93:1: IP_TTL = 2 // in.h:50:1: IP_UNBLOCK_SOURCE = 37 // in.h:123:1: IP_UNICAST_IF = 50 // in.h:129:1: IP_XFRM_POLICY = 17 // in.h:91:1: LITTLE_ENDIAN = 1234 // endian.h:27:1: MCAST_BLOCK_SOURCE = 43 // in.h:67:1: MCAST_EXCLUDE = 0 // in.h:76:1: MCAST_INCLUDE = 1 // in.h:77:1: MCAST_JOIN_GROUP = 42 // in.h:66:1: MCAST_JOIN_SOURCE_GROUP = 46 // in.h:70:1: MCAST_LEAVE_GROUP = 45 // in.h:69:1: MCAST_LEAVE_SOURCE_GROUP = 47 // in.h:71:1: MCAST_MSFILTER = 48 // in.h:72:1: MCAST_UNBLOCK_SOURCE = 44 // in.h:68:1: NETDB_INTERNAL = -1 // netdb.h:72:1: NETDB_SUCCESS = 0 // netdb.h:73:1: NI_DGRAM = 16 // netdb.h:646:1: NI_MAXHOST = 1025 // netdb.h:638:1: NI_MAXSERV = 32 // netdb.h:639:1: NI_NAMEREQD = 8 // netdb.h:645:1: NI_NOFQDN = 4 // netdb.h:644:1: NI_NUMERICHOST = 1 // netdb.h:642:1: NI_NUMERICSERV = 2 // netdb.h:643:1: NO_ADDRESS = 4 // netdb.h:74:1: NO_DATA = 4 // netdb.h:68:1: NO_RECOVERY = 3 // netdb.h:66:1: PDP_ENDIAN = 3412 // endian.h:29:1: PF_ALG = 38 // socket.h:82:1: PF_APPLETALK = 5 // socket.h:48:1: PF_ASH = 18 // socket.h:62:1: PF_ATMPVC = 8 // socket.h:51:1: PF_ATMSVC = 20 // socket.h:64:1: PF_AX25 = 3 // socket.h:46:1: PF_BLUETOOTH = 31 // socket.h:75:1: PF_BRIDGE = 7 // socket.h:50:1: PF_CAIF = 37 // socket.h:81:1: PF_CAN = 29 // socket.h:73:1: PF_DECnet = 12 // socket.h:55:1: PF_ECONET = 19 // socket.h:63:1: PF_FILE = 1 // socket.h:44:1: PF_IB = 27 // socket.h:71:1: PF_IEEE802154 = 36 // socket.h:80:1: PF_INET = 2 // socket.h:45:1: PF_INET6 = 10 // socket.h:53:1: PF_IPX = 4 // socket.h:47:1: PF_IRDA = 23 // socket.h:67:1: PF_ISDN = 34 // socket.h:78:1: PF_IUCV = 32 // socket.h:76:1: PF_KCM = 41 // socket.h:85:1: PF_KEY = 15 // socket.h:58:1: PF_LLC = 26 // socket.h:70:1: PF_LOCAL = 1 // socket.h:42:1: PF_MAX = 45 // socket.h:89:1: PF_MPLS = 28 // socket.h:72:1: PF_NETBEUI = 13 // socket.h:56:1: PF_NETLINK = 16 // socket.h:59:1: PF_NETROM = 6 // socket.h:49:1: PF_NFC = 39 // socket.h:83:1: PF_PACKET = 17 // socket.h:61:1: PF_PHONET = 35 // socket.h:79:1: PF_PPPOX = 24 // socket.h:68:1: PF_QIPCRTR = 42 // socket.h:86:1: PF_RDS = 21 // socket.h:65:1: PF_ROSE = 11 // socket.h:54:1: PF_ROUTE = 16 // socket.h:60:1: PF_RXRPC = 33 // socket.h:77:1: PF_SECURITY = 14 // socket.h:57:1: PF_SMC = 43 // socket.h:87:1: PF_SNA = 22 // socket.h:66:1: PF_TIPC = 30 // socket.h:74:1: PF_UNIX = 1 // socket.h:43:1: PF_UNSPEC = 0 // socket.h:41:1: PF_VSOCK = 40 // socket.h:84:1: PF_WANPIPE = 25 // socket.h:69:1: PF_X25 = 9 // socket.h:52:1: PF_XDP = 44 // socket.h:88:1: SCM_TIMESTAMP = 29 // socket.h:140:1: SCM_TIMESTAMPING = 37 // socket.h:142:1: SCM_TIMESTAMPING_OPT_STATS = 54 // socket.h:90:1: SCM_TIMESTAMPING_PKTINFO = 58 // socket.h:98:1: SCM_TIMESTAMPNS = 35 // socket.h:141:1: SCM_TXTIME = 61 // socket.h:105:1: SCM_WIFI_STATUS = 41 // socket.h:64:1: SIOCATMARK = 0x8905 // sockios.h:10:1: SIOCGPGRP = 0x8904 // sockios.h:9:1: SIOCGSTAMP = 0x8906 // sockios.h:11:1: SIOCGSTAMPNS = 0x8907 // sockios.h:12:1: SIOCSPGRP = 0x8902 // sockios.h:7:1: SOL_AAL = 265 // socket.h:151:1: SOL_ALG = 279 // socket.h:165:1: SOL_ATM = 264 // socket.h:150:1: SOL_BLUETOOTH = 274 // socket.h:160:1: SOL_CAIF = 278 // socket.h:164:1: SOL_DCCP = 269 // socket.h:155:1: SOL_DECNET = 261 // socket.h:147:1: SOL_ICMPV6 = 58 // in.h:253:1: SOL_IP = 0 // in.h:132:1: SOL_IPV6 = 41 // in.h:252:1: SOL_IRDA = 266 // socket.h:152:1: SOL_IUCV = 277 // socket.h:163:1: SOL_KCM = 281 // socket.h:167:1: SOL_LLC = 268 // socket.h:154:1: SOL_NETBEUI = 267 // socket.h:153:1: SOL_NETLINK = 270 // socket.h:156:1: SOL_NFC = 280 // socket.h:166:1: SOL_PACKET = 263 // socket.h:149:1: SOL_PNPIPE = 275 // socket.h:161:1: SOL_PPPOL2TP = 273 // socket.h:159:1: SOL_RAW = 255 // socket.h:146:1: SOL_RDS = 276 // socket.h:162:1: SOL_RXRPC = 272 // socket.h:158:1: SOL_SOCKET = 1 // socket.h:9:1: SOL_TIPC = 271 // socket.h:157:1: SOL_TLS = 282 // socket.h:168:1: SOL_X25 = 262 // socket.h:148:1: SOL_XDP = 283 // socket.h:169:1: SOMAXCONN = 4096 // socket.h:172:1: SO_ACCEPTCONN = 30 // socket.h:51:1: SO_ATTACH_BPF = 50 // socket.h:82:1: SO_ATTACH_FILTER = 26 // socket.h:45:1: SO_ATTACH_REUSEPORT_CBPF = 51 // socket.h:85:1: SO_ATTACH_REUSEPORT_EBPF = 52 // socket.h:86:1: SO_BINDTODEVICE = 25 // socket.h:42:1: SO_BINDTOIFINDEX = 62 // socket.h:107:1: SO_BPF_EXTENSIONS = 48 // socket.h:78:1: SO_BROADCAST = 6 // socket.h:16:1: SO_BSDCOMPAT = 14 // socket.h:26:1: SO_BUSY_POLL = 46 // socket.h:74:1: SO_CNX_ADVICE = 53 // socket.h:88:1: SO_COOKIE = 57 // socket.h:96:1: SO_DEBUG = 1 // socket.h:11:1: SO_DETACH_BPF = 27 // socket.h:83:1: SO_DETACH_FILTER = 27 // socket.h:46:1: SO_DETACH_REUSEPORT_BPF = 68 // socket.h:120:1: SO_DOMAIN = 39 // socket.h:59:1: SO_DONTROUTE = 5 // socket.h:15:1: SO_ERROR = 4 // socket.h:14:1: SO_GET_FILTER = 26 // socket.h:47:1: SO_INCOMING_CPU = 49 // socket.h:80:1: SO_INCOMING_NAPI_ID = 56 // socket.h:94:1: SO_KEEPALIVE = 9 // socket.h:21:1: SO_LINGER = 13 // socket.h:25:1: SO_LOCK_FILTER = 44 // socket.h:70:1: SO_MARK = 36 // socket.h:56:1: SO_MAX_PACING_RATE = 47 // socket.h:76:1: SO_MEMINFO = 55 // socket.h:92:1: SO_NOFCS = 43 // socket.h:68:1: SO_NO_CHECK = 11 // socket.h:23:1: SO_OOBINLINE = 10 // socket.h:22:1: SO_PASSCRED = 20 // socket.h:16:1: SO_PASSSEC = 34 // socket.h:54:1: SO_PEEK_OFF = 42 // socket.h:65:1: SO_PEERCRED = 21 // socket.h:17:1: SO_PEERGROUPS = 59 // socket.h:100:1: SO_PEERNAME = 28 // socket.h:49:1: SO_PEERSEC = 31 // socket.h:53:1: SO_PRIORITY = 12 // socket.h:24:1: SO_PROTOCOL = 38 // socket.h:58:1: SO_RCVBUF = 8 // socket.h:18:1: SO_RCVBUFFORCE = 33 // socket.h:20:1: SO_RCVLOWAT = 16 // socket.h:12:1: SO_RCVTIMEO = 18 // socket.h:129:1: SO_RCVTIMEO_NEW = 66 // socket.h:117:1: SO_RCVTIMEO_OLD = 18 // socket.h:14:1: SO_REUSEADDR = 2 // socket.h:12:1: SO_REUSEPORT = 15 // socket.h:27:1: SO_RXQ_OVFL = 40 // socket.h:61:1: SO_SECURITY_AUTHENTICATION = 22 // socket.h:38:1: SO_SECURITY_ENCRYPTION_NETWORK = 24 // socket.h:40:1: SO_SECURITY_ENCRYPTION_TRANSPORT = 23 // socket.h:39:1: SO_SELECT_ERR_QUEUE = 45 // socket.h:72:1: SO_SNDBUF = 7 // socket.h:17:1: SO_SNDBUFFORCE = 32 // socket.h:19:1: SO_SNDLOWAT = 17 // socket.h:13:1: SO_SNDTIMEO = 19 // socket.h:130:1: SO_SNDTIMEO_NEW = 67 // socket.h:118:1: SO_SNDTIMEO_OLD = 19 // socket.h:15:1: SO_TIMESTAMP = 29 // socket.h:125:1: SO_TIMESTAMPING = 37 // socket.h:127:1: SO_TIMESTAMPING_NEW = 65 // socket.h:115:1: SO_TIMESTAMPING_OLD = 37 // socket.h:111:1: SO_TIMESTAMPNS = 35 // socket.h:126:1: SO_TIMESTAMPNS_NEW = 64 // socket.h:114:1: SO_TIMESTAMPNS_OLD = 35 // socket.h:110:1: SO_TIMESTAMP_NEW = 63 // socket.h:113:1: SO_TIMESTAMP_OLD = 29 // socket.h:109:1: SO_TXTIME = 61 // socket.h:104:1: SO_TYPE = 3 // socket.h:13:1: SO_WIFI_STATUS = 41 // socket.h:63:1: SO_ZEROCOPY = 60 // socket.h:102:1: TRY_AGAIN = 2 // netdb.h:64:1: X_ARCH_PPC = 1 // <predefined>:198:1: X_ARCH_PPC64 = 1 // <predefined>:402:1: X_ARCH_PPCGR = 1 // <predefined>:15:1: X_ARCH_PPCSQ = 1 // <predefined>:43:1: X_ARCH_PWR4 = 1 // <predefined>:381:1: X_ARCH_PWR5 = 1 // <predefined>:90:1: X_ARCH_PWR5X = 1 // <predefined>:137:1: X_ARCH_PWR6 = 1 // <predefined>:91:1: X_ARCH_PWR7 = 1 // <predefined>:92:1: X_ARCH_PWR8 = 1 // <predefined>:93:1: X_ASM_POWERPC_POSIX_TYPES_H = 0 // posix_types.h:3:1: X_ASM_POWERPC_SOCKET_H = 0 // socket.h:3:1: X_ATFILE_SOURCE = 1 // features.h:342:1: X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: X_BITS_ENDIAN_H = 1 // endian.h:20:1: X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:21:1: X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: X_BITS_SOCKADDR_H = 1 // sockaddr.h:24:1: X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: X_BITS_STDINT_UINTN_H = 1 // stdint-uintn.h:20:1: X_BITS_TIME64_H = 1 // time64.h:24:1: X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: X_BITS_TYPES_H = 1 // types.h:24:1: X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: X_BSD_SIZE_T_ = 0 // stddef.h:189:1: X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: X_CALL_ELF = 2 // <predefined>:415:1: X_CALL_LINUX = 1 // <predefined>:123:1: X_DEFAULT_SOURCE = 1 // features.h:227:1: X_ENDIAN_H = 1 // endian.h:19:1: X_FEATURES_H = 1 // features.h:19:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_GCC_SIZE_T = 0 // stddef.h:195:1: X_LINUX_POSIX_TYPES_H = 0 // posix_types.h:3:1: X_LITTLE_ENDIAN = 1 // <predefined>:37:1: X_LP64 = 1 // <predefined>:335:1: X_NETDB_H = 1 // netdb.h:23:1: X_NETINET_IN_H = 1 // in.h:19:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:43:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:44:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:45:1: X_PATH_NSSWITCH_CONF = "/etc/nsswitch.conf" // netdb.h:46:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:47:1: X_PATH_SERVICES = "/etc/services" // netdb.h:48:1:
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_freebsd_amd64.go
vendor/modernc.org/libc/netdb/capi_freebsd_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_freebsd_amd64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_openbsd_amd64.go
vendor/modernc.org/libc/netdb/capi_openbsd_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_openbsd_amd64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_illumos_amd64.go
vendor/modernc.org/libc/netdb/capi_illumos_amd64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_illumos_amd64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_openbsd_arm64.go
vendor/modernc.org/libc/netdb/netdb_openbsd_arm64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_openbsd_arm64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AI_ADDRCONFIG = 64 // netdb.h:165:1: AI_CANONNAME = 2 // netdb.h:160:1: AI_EXT = 8 // netdb.h:162:1: AI_FQDN = 32 // netdb.h:164:1: AI_MASK = 119 // netdb.h:167:1: AI_NUMERICHOST = 4 // netdb.h:161:1: AI_NUMERICSERV = 16 // netdb.h:163:1: AI_PASSIVE = 1 // netdb.h:159:1: BIG_ENDIAN = 4321 // endian.h:45:1: BYTE_ORDER = 1234 // endian.h:47:1: EAI_ADDRFAMILY = -9 // netdb.h:196:1: EAI_AGAIN = -3 // netdb.h:190:1: EAI_BADFLAGS = -1 // netdb.h:188:1: EAI_BADHINTS = -12 // netdb.h:199:1: EAI_FAIL = -4 // netdb.h:191:1: EAI_FAMILY = -6 // netdb.h:193:1: EAI_MEMORY = -10 // netdb.h:197:1: EAI_NODATA = -5 // netdb.h:192:1: EAI_NONAME = -2 // netdb.h:189:1: EAI_OVERFLOW = -14 // netdb.h:201:1: EAI_PROTOCOL = -13 // netdb.h:200:1: EAI_SERVICE = -8 // netdb.h:195:1: EAI_SOCKTYPE = -7 // netdb.h:194:1: EAI_SYSTEM = -11 // netdb.h:198:1: ERRSET_FAIL = 2 // netdb.h:225:1: ERRSET_INVAL = 3 // netdb.h:226:1: ERRSET_NODATA = 5 // netdb.h:228:1: ERRSET_NOMEMORY = 1 // netdb.h:224:1: ERRSET_NONAME = 4 // netdb.h:227:1: ERRSET_SUCCESS = 0 // netdb.h:223:1: HOST_NOT_FOUND = 1 // netdb.h:151:1: ICMP6_FILTER = 18 // in6.h:304:1: INET6_ADDRSTRLEN = 46 // in6.h:97:1: INET_ADDRSTRLEN = 16 // in.h:382:1: IN_CLASSA_MAX = 128 // in.h:195:1: IN_CLASSA_NSHIFT = 24 // in.h:193:1: IN_CLASSB_MAX = 65536 // in.h:202:1: IN_CLASSB_NSHIFT = 16 // in.h:200:1: IN_CLASSC_NSHIFT = 8 // in.h:207:1: IN_CLASSD_NSHIFT = 28 // in.h:214:1: IN_LOOPBACKNET = 127 // in.h:253:1: IN_RFC3021_NSHIFT = 31 // in.h:219:1: IPCTL_ARPDOWN = 40 // in.h:698:1: IPCTL_ARPQUEUE = 41 // in.h:699:1: IPCTL_ARPQUEUED = 36 // in.h:694:1: IPCTL_ARPTIMEOUT = 39 // in.h:697:1: IPCTL_DEFTTL = 3 // in.h:662:1: IPCTL_DIRECTEDBCAST = 6 // in.h:664:1: IPCTL_ENCDEBUG = 12 // in.h:670:1: IPCTL_FORWARDING = 1 // in.h:660:1: IPCTL_IFQUEUE = 30 // in.h:688:1: IPCTL_IPPORT_FIRSTAUTO = 7 // in.h:665:1: IPCTL_IPPORT_HIFIRSTAUTO = 9 // in.h:667:1: IPCTL_IPPORT_HILASTAUTO = 10 // in.h:668:1: IPCTL_IPPORT_LASTAUTO = 8 // in.h:666:1: IPCTL_IPPORT_MAXQUEUE = 11 // in.h:669:1: IPCTL_IPSEC_ALLOCATIONS = 18 // in.h:676:1: IPCTL_IPSEC_AUTH_ALGORITHM = 26 // in.h:684:1: IPCTL_IPSEC_BYTES = 20 // in.h:678:1: IPCTL_IPSEC_EMBRYONIC_SA_TIMEOUT = 15 // in.h:673:1: IPCTL_IPSEC_ENC_ALGORITHM = 25 // in.h:683:1: IPCTL_IPSEC_EXPIRE_ACQUIRE = 14 // in.h:672:1: IPCTL_IPSEC_FIRSTUSE = 24 // in.h:682:1: IPCTL_IPSEC_IPCOMP_ALGORITHM = 29 // in.h:687:1: IPCTL_IPSEC_REQUIRE_PFS = 16 // in.h:674:1: IPCTL_IPSEC_SOFT_ALLOCATIONS = 17 // in.h:675:1: IPCTL_IPSEC_SOFT_BYTES = 19 // in.h:677:1: IPCTL_IPSEC_SOFT_FIRSTUSE = 23 // in.h:681:1: IPCTL_IPSEC_SOFT_TIMEOUT = 22 // in.h:680:1: IPCTL_IPSEC_STATS = 13 // in.h:671:1: IPCTL_IPSEC_TIMEOUT = 21 // in.h:679:1: IPCTL_MAXID = 42 // in.h:700:1: IPCTL_MFORWARDING = 31 // in.h:689:1: IPCTL_MRTMFC = 37 // in.h:695:1: IPCTL_MRTPROTO = 34 // in.h:692:1: IPCTL_MRTSTATS = 35 // in.h:693:1: IPCTL_MRTVIF = 38 // in.h:696:1: IPCTL_MTUDISC = 27 // in.h:685:1: IPCTL_MTUDISCTIMEOUT = 28 // in.h:686:1: IPCTL_MULTIPATH = 32 // in.h:690:1: IPCTL_SENDREDIRECTS = 2 // in.h:661:1: IPCTL_SOURCEROUTE = 5 // in.h:663:1: IPCTL_STATS = 33 // in.h:691:1: IPPORT_HIFIRSTAUTO = 49152 // in.h:159:1: IPPORT_HILASTAUTO = 65535 // in.h:160:1: IPPORT_RESERVED = 1024 // in.h:153:1: IPPORT_USERRESERVED = 49151 // in.h:154:1: IPPROTO_AH = 51 // in.h:89:1: IPPROTO_CARP = 112 // in.h:99:1: IPPROTO_DIVERT = 258 // in.h:109:1: IPPROTO_DONE = 257 // in.h:173:1: IPPROTO_DSTOPTS = 60 // in.h:93:1: IPPROTO_EGP = 8 // in.h:78:1: IPPROTO_ENCAP = 98 // in.h:96:1: IPPROTO_EON = 80 // in.h:94:1: IPPROTO_ESP = 50 // in.h:88:1: IPPROTO_ETHERIP = 97 // in.h:95:1: IPPROTO_FRAGMENT = 44 // in.h:85:1: IPPROTO_GGP = 3 // in.h:74:1: IPPROTO_GRE = 47 // in.h:87:1: IPPROTO_HOPOPTS = 0 // in.h:71:1: IPPROTO_ICMP = 1 // in.h:72:1: IPPROTO_ICMPV6 = 58 // in.h:91:1: IPPROTO_IDP = 22 // in.h:81:1: IPPROTO_IGMP = 2 // in.h:73:1: IPPROTO_IP = 0 // in.h:70:1: IPPROTO_IPCOMP = 108 // in.h:98:1: IPPROTO_IPIP = 4 // in.h:75:1: IPPROTO_IPV4 = 4 // in.h:76:1: IPPROTO_IPV6 = 41 // in.h:83:1: IPPROTO_MAX = 256 // in.h:106:1: IPPROTO_MAXID = 259 // in.h:393:1: IPPROTO_MOBILE = 55 // in.h:90:1: IPPROTO_MPLS = 137 // in.h:102:1: IPPROTO_NONE = 59 // in.h:92:1: IPPROTO_PFSYNC = 240 // in.h:103:1: IPPROTO_PIM = 103 // in.h:97:1: IPPROTO_PUP = 12 // in.h:79:1: IPPROTO_RAW = 255 // in.h:104:1: IPPROTO_ROUTING = 43 // in.h:84:1: IPPROTO_RSVP = 46 // in.h:86:1: IPPROTO_SCTP = 132 // in.h:100:1: IPPROTO_TCP = 6 // in.h:77:1: IPPROTO_TP = 29 // in.h:82:1: IPPROTO_UDP = 17 // in.h:80:1: IPPROTO_UDPLITE = 136 // in.h:101:1: IPSEC6_OUTSA = 56 // in6.h:337:1: IPSEC_AUTH_LEVEL_DEFAULT = 1 // in.h:336:1: IPSEC_ESP_NETWORK_LEVEL_DEFAULT = 1 // in.h:338:1: IPSEC_ESP_TRANS_LEVEL_DEFAULT = 1 // in.h:337:1: IPSEC_IPCOMP_LEVEL_DEFAULT = 1 // in.h:339:1: IPSEC_LEVEL_AVAIL = 0x01 // in.h:330:1: IPSEC_LEVEL_BYPASS = 0x00 // in.h:328:1: IPSEC_LEVEL_DEFAULT = 1 // in.h:334:1: IPSEC_LEVEL_NONE = 0x00 // in.h:329:1: IPSEC_LEVEL_REQUIRE = 0x03 // in.h:332:1: IPSEC_LEVEL_UNIQUE = 0x04 // in.h:333:1: IPSEC_LEVEL_USE = 0x02 // in.h:331:1: IPV6CTL_ACCEPT_RTADV = 12 // in6.h:575:1: IPV6CTL_AUTO_FLOWLABEL = 17 // in6.h:579:1: IPV6CTL_DAD_COUNT = 16 // in6.h:578:1: IPV6CTL_DAD_PENDING = 49 // in6.h:589:1: IPV6CTL_DEFHLIM = 3 // in6.h:567:1: IPV6CTL_DEFMCASTHLIM = 18 // in6.h:580:1: IPV6CTL_FORWARDING = 1 // in6.h:565:1: IPV6CTL_FORWSRCRT = 5 // in6.h:568:1: IPV6CTL_HDRNESTLIMIT = 15 // in6.h:577:1: IPV6CTL_IFQUEUE = 51 // in6.h:591:1: IPV6CTL_LOG_INTERVAL = 14 // in6.h:576:1: IPV6CTL_MAXDYNROUTES = 48 // in6.h:588:1: IPV6CTL_MAXFRAGPACKETS = 9 // in6.h:572:1: IPV6CTL_MAXFRAGS = 41 // in6.h:583:1: IPV6CTL_MAXID = 55 // in6.h:595:1: IPV6CTL_MCAST_PMTU = 44 // in6.h:586:1: IPV6CTL_MFORWARDING = 42 // in6.h:584:1: IPV6CTL_MRTMFC = 53 // in6.h:593:1: IPV6CTL_MRTMIF = 52 // in6.h:592:1: IPV6CTL_MRTPROTO = 8 // in6.h:571:1: IPV6CTL_MRTSTATS = 7 // in6.h:570:1: IPV6CTL_MTUDISCTIMEOUT = 50 // in6.h:590:1: IPV6CTL_MULTIPATH = 43 // in6.h:585:1: IPV6CTL_NEIGHBORGCTHRESH = 45 // in6.h:587:1: IPV6CTL_SENDREDIRECTS = 2 // in6.h:566:1: IPV6CTL_SOIIKEY = 54 // in6.h:594:1: IPV6CTL_SOURCECHECK = 10 // in6.h:573:1: IPV6CTL_SOURCECHECK_LOGINT = 11 // in6.h:574:1: IPV6CTL_STATS = 6 // in6.h:569:1: IPV6CTL_USE_DEPRECATED = 21 // in6.h:581:1: IPV6PROTO_MAXID = 259 // in6.h:470:1: IPV6_AUTH_LEVEL = 53 // in6.h:333:1: IPV6_AUTOFLOWLABEL = 59 // in6.h:341:1: IPV6_CHECKSUM = 26 // in6.h:307:1: IPV6_DEFAULT_MULTICAST_HOPS = 1 // in6.h:360:1: IPV6_DEFAULT_MULTICAST_LOOP = 1 // in6.h:361:1: IPV6_DONTFRAG = 62 // in6.h:345:1: IPV6_DSTOPTS = 50 // in6.h:330:1: IPV6_ESP_NETWORK_LEVEL = 55 // in6.h:335:1: IPV6_ESP_TRANS_LEVEL = 54 // in6.h:334:1: IPV6_HOPLIMIT = 47 // in6.h:327:1: IPV6_HOPOPTS = 49 // in6.h:329:1: IPV6_IPCOMP_LEVEL = 60 // in6.h:342:1: IPV6_JOIN_GROUP = 12 // in6.h:300:1: IPV6_LEAVE_GROUP = 13 // in6.h:301:1: IPV6_MINHOPCOUNT = 65 // in6.h:349:1: IPV6_MULTICAST_HOPS = 10 // in6.h:298:1: IPV6_MULTICAST_IF = 9 // in6.h:297:1: IPV6_MULTICAST_LOOP = 11 // in6.h:299:1: IPV6_NEXTHOP = 48 // in6.h:328:1: IPV6_PATHMTU = 44 // in6.h:322:1: IPV6_PIPEX = 63 // in6.h:346:1: IPV6_PKTINFO = 46 // in6.h:326:1: IPV6_PORTRANGE = 14 // in6.h:302:1: IPV6_PORTRANGE_DEFAULT = 0 // in6.h:393:1: IPV6_PORTRANGE_HIGH = 1 // in6.h:394:1: IPV6_PORTRANGE_LOW = 2 // in6.h:395:1: IPV6_RECVDSTOPTS = 40 // in6.h:317:1: IPV6_RECVDSTPORT = 64 // in6.h:348:1: IPV6_RECVHOPLIMIT = 37 // in6.h:314:1: IPV6_RECVHOPOPTS = 39 // in6.h:316:1: IPV6_RECVPATHMTU = 43 // in6.h:320:1: IPV6_RECVPKTINFO = 36 // in6.h:313:1: IPV6_RECVRTHDR = 38 // in6.h:315:1: IPV6_RECVTCLASS = 57 // in6.h:339:1: IPV6_RTABLE = 0x1021 // in6.h:351:1: IPV6_RTHDR = 51 // in6.h:331:1: IPV6_RTHDRDSTOPTS = 35 // in6.h:311:1: IPV6_RTHDR_LOOSE = 0 // in6.h:354:1: IPV6_RTHDR_TYPE_0 = 0 // in6.h:355:1: IPV6_TCLASS = 61 // in6.h:344:1: IPV6_UNICAST_HOPS = 4 // in6.h:296:1: IPV6_USE_MIN_MTU = 42 // in6.h:319:1: IPV6_V6ONLY = 27 // in6.h:308:1: IP_ADD_MEMBERSHIP = 12 // in.h:297:1: IP_AUTH_LEVEL = 20 // in.h:300:1: IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:347:1: IP_DEFAULT_MULTICAST_TTL = 1 // in.h:346:1: IP_DROP_MEMBERSHIP = 13 // in.h:298:1: IP_ESP_NETWORK_LEVEL = 22 // in.h:302:1: IP_ESP_TRANS_LEVEL = 21 // in.h:301:1: IP_HDRINCL = 2 // in.h:287:1: IP_IPCOMP_LEVEL = 29 // in.h:309:1: IP_IPDEFTTL = 37 // in.h:317:1: IP_IPSECFLOWINFO = 36 // in.h:316:1: IP_IPSEC_LOCAL_AUTH = 27 // in.h:307:1: IP_IPSEC_LOCAL_CRED = 25 // in.h:305:1: IP_IPSEC_LOCAL_ID = 23 // in.h:303:1: IP_IPSEC_REMOTE_AUTH = 28 // in.h:308:1: IP_IPSEC_REMOTE_CRED = 26 // in.h:306:1: IP_IPSEC_REMOTE_ID = 24 // in.h:304:1: IP_MAX_MEMBERSHIPS = 4095 // in.h:354:1: IP_MINTTL = 32 // in.h:312:1: IP_MIN_MEMBERSHIPS = 15 // in.h:353:1: IP_MULTICAST_IF = 9 // in.h:294:1: IP_MULTICAST_LOOP = 11 // in.h:296:1: IP_MULTICAST_TTL = 10 // in.h:295:1: IP_OPTIONS = 1 // in.h:286:1: IP_PIPEX = 34 // in.h:314:1: IP_PORTRANGE = 19 // in.h:299:1: IP_PORTRANGE_DEFAULT = 0 // in.h:374:1: IP_PORTRANGE_HIGH = 1 // in.h:375:1: IP_PORTRANGE_LOW = 2 // in.h:376:1: IP_RECVDSTADDR = 7 // in.h:292:1: IP_RECVDSTPORT = 33 // in.h:313:1: IP_RECVIF = 30 // in.h:310:1: IP_RECVOPTS = 5 // in.h:290:1: IP_RECVRETOPTS = 6 // in.h:291:1: IP_RECVRTABLE = 35 // in.h:315:1: IP_RECVTTL = 31 // in.h:311:1: IP_RETOPTS = 8 // in.h:293:1: IP_RTABLE = 0x1021 // in.h:321:1: IP_SENDSRCADDR = 7 // in.h:318:1: IP_TOS = 3 // in.h:288:1: IP_TTL = 4 // in.h:289:1: LITTLE_ENDIAN = 1234 // endian.h:44:1: NETDB_INTERNAL = -1 // netdb.h:149:1: NETDB_SUCCESS = 0 // netdb.h:150:1: NI_DGRAM = 16 // netdb.h:175:1: NI_MAXHOST = 256 // netdb.h:179:1: NI_MAXSERV = 32 // netdb.h:180:1: NI_NAMEREQD = 8 // netdb.h:174:1: NI_NOFQDN = 4 // netdb.h:173:1: NI_NUMERICHOST = 1 // netdb.h:171:1: NI_NUMERICSERV = 2 // netdb.h:172:1: NO_ADDRESS = 4 // netdb.h:155:1: NO_DATA = 4 // netdb.h:154:1: NO_RECOVERY = 3 // netdb.h:153:1: PDP_ENDIAN = 3412 // endian.h:46:1: RRSET_VALIDATED = 1 // netdb.h:218:1: SCOPE_DELIMITER = 37 // netdb.h:185:1: SIN6_LEN = 0 // in6.h:104:1: TRY_AGAIN = 2 // netdb.h:152:1: X_BIG_ENDIAN = 4321 // _endian.h:43:1: X_BYTE_ORDER = 1234 // endian.h:60:1: X_CLOCKID_T_DEFINED_ = 0 // types.h:162:1: X_CLOCK_T_DEFINED_ = 0 // types.h:157:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_INT16_T_DEFINED_ = 0 // types.h:84:1: X_INT32_T_DEFINED_ = 0 // types.h:94:1: X_INT64_T_DEFINED_ = 0 // types.h:104:1: X_INT8_T_DEFINED_ = 0 // types.h:74:1: X_IN_ADDR_DECLARED = 0 // in.h:163:1: X_IN_TYPES_DEFINED_ = 0 // in.h:62:1: X_LITTLE_ENDIAN = 1234 // _endian.h:42:1: X_LP64 = 1 // <predefined>:1:1: X_MACHINE_CDEFS_H_ = 0 // cdefs.h:4:1: X_MACHINE_ENDIAN_H_ = 0 // endian.h:20:1: X_MACHINE__TYPES_H_ = 0 // _types.h:35:1: X_MAX_PAGE_SHIFT = 12 // _types.h:57:1: X_NETDB_H_ = 0 // netdb.h:88:1: X_NETINET6_IN6_H_ = 0 // in6.h:69:1: X_NETINET_IN_H_ = 0 // in.h:39:1: X_OFF_T_DEFINED_ = 0 // types.h:192:1: X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:97:1: X_PATH_HOSTS = "/etc/hosts" // netdb.h:98:1: X_PATH_NETWORKS = "/etc/networks" // netdb.h:99:1: X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:100:1: X_PATH_SERVICES = "/etc/services" // netdb.h:101:1: X_PDP_ENDIAN = 3412 // _endian.h:44:1: X_PID_T_DEFINED_ = 0 // types.h:167:1: X_QUAD_HIGHWORD = 1 // _endian.h:95:1: X_QUAD_LOWWORD = 0 // _endian.h:96:1: X_RET_PROTECTOR = 1 // <predefined>:2:1: X_SA_FAMILY_T_DEFINED_ = 0 // in.h:57:1: X_SIZE_T_DEFINED_ = 0 // types.h:172:1: X_SOCKLEN_T_DEFINED_ = 0 // in6.h:400:1: X_SSIZE_T_DEFINED_ = 0 // types.h:177:1: X_STACKALIGNBYTES = 15 // _types.h:54:1: X_SYS_CDEFS_H_ = 0 // cdefs.h:39:1: X_SYS_ENDIAN_H_ = 0 // endian.h:38:1: X_SYS_TYPES_H_ = 0 // types.h:41:1: X_SYS__ENDIAN_H_ = 0 // _endian.h:34:1: X_SYS__TYPES_H_ = 0 // _types.h:35:1: X_TIMER_T_DEFINED_ = 0 // types.h:187:1: X_TIME_T_DEFINED_ = 0 // types.h:182:1: X_UINT16_T_DEFINED_ = 0 // types.h:89:1: X_UINT32_T_DEFINED_ = 0 // types.h:99:1: X_UINT64_T_DEFINED_ = 0 // types.h:109:1: X_UINT8_T_DEFINED_ = 0 // types.h:79:1: Unix = 1 // <predefined>:360:1: ) type Ptrdiff_t = int64 /* <builtin>:3:26 */ type Size_t = uint64 /* <builtin>:9:23 */ type Wchar_t = int32 /* <builtin>:15:24 */ type X__int128_t = struct { Flo int64 Fhi int64 } /* <builtin>:21:43 */ // must match modernc.org/mathutil.Int128 type X__uint128_t = struct { Flo uint64 Fhi uint64 } /* <builtin>:22:44 */ // must match modernc.org/mathutil.Int128 type X__builtin_va_list = uintptr /* <builtin>:46:14 */ type X__float128 = float64 /* <builtin>:47:21 */ // $OpenBSD: netdb.h,v 1.33 2015/01/18 20:29:31 deraadt Exp $ // ++Copyright++ 1980, 1983, 1988, 1993 // - // Copyright (c) 1980, 1983, 1988, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // - // Portions Copyright (c) 1993 by Digital Equipment Corporation. // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies, and that // the name of Digital Equipment Corporation not be used in advertising or // publicity pertaining to distribution of the document or software without // specific, written prior permission. // // THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL // WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT // CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL // DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR // PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS // ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS // SOFTWARE. // - // --Copyright-- // Copyright (c) 1995, 1996, 1997, 1998, 1999 Craig Metz. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the author nor the names of any contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // @(#)netdb.h 8.1 (Berkeley) 6/2/93 // $From: netdb.h,v 8.7 1996/05/09 05:59:09 vixie Exp $ // $OpenBSD: in.h,v 1.141 2021/06/02 00:09:57 dlg Exp $ // $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ // Copyright (c) 1982, 1986, 1990, 1993 // The Regents of the University of California. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // Constants and structures defined by the internet system, // Per RFC 790, September 1981, and numerous additions. // $OpenBSD: cdefs.h,v 1.43 2018/10/29 17:10:40 guenther Exp $ // $NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $ // Copyright (c) 1991, 1993 // The Regents of the University of California. All rights reserved. // // This code is derived from software contributed to Berkeley by // Berkeley Software Design, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // @(#)cdefs.h 8.7 (Berkeley) 1/21/94 // $OpenBSD: cdefs.h,v 1.1 2016/12/17 23:38:33 patrick Exp $ // Macro to test if we're using a specific version of gcc or later. // The __CONCAT macro is used to concatenate parts of symbol names, e.g. // with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. // The __CONCAT macro is a bit tricky -- make sure you don't put spaces // in between its arguments. Do not use __CONCAT on double-quoted strings, // such as those from the __STRING macro: to concatenate strings just put // them next to each other. // GCC1 and some versions of GCC2 declare dead (non-returning) and // pure (no side effects) functions using "volatile" and "const"; // unfortunately, these then cause warnings under "-ansi -pedantic". // GCC >= 2.5 uses the __attribute__((attrs)) style. All of these // work for GNU C++ (modulo a slight glitch in the C++ grammar in // the distribution version of 2.5.5). // __returns_twice makes the compiler not assume the function // only returns once. This affects registerisation of variables:
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_darwin_arm64.go
vendor/modernc.org/libc/netdb/capi_darwin_arm64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_darwin_arm64.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{ "__darwin_check_fd_set": {}, "__darwin_check_fd_set_overflow": {}, "__darwin_fd_clr": {}, "__darwin_fd_isset": {}, "__darwin_fd_set": {}, }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_linux_arm.go
vendor/modernc.org/libc/netdb/capi_linux_arm.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_arm.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/capi_freebsd_arm.go
vendor/modernc.org/libc/netdb/capi_freebsd_arm.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_freebsd_arm.go -pkgname netdb', DO NOT EDIT. package netdb var CAPI = map[string]struct{}{}
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/libc/netdb/netdb_linux_loong64.go
vendor/modernc.org/libc/netdb/netdb_linux_loong64.go
// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_linux_loong64.go -pkgname netdb', DO NOT EDIT. package netdb import ( "math" "reflect" "sync/atomic" "unsafe" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer const ( AF_ALG = 38 // socket.h:134:1: AF_APPLETALK = 5 // socket.h:100:1: AF_ASH = 18 // socket.h:114:1: AF_ATMPVC = 8 // socket.h:103:1: AF_ATMSVC = 20 // socket.h:116:1: AF_AX25 = 3 // socket.h:98:1: AF_BLUETOOTH = 31 // socket.h:127:1: AF_BRIDGE = 7 // socket.h:102:1: AF_CAIF = 37 // socket.h:133:1: AF_CAN = 29 // socket.h:125:1: AF_DECnet = 12 // socket.h:107:1: AF_ECONET = 19 // socket.h:115:1: AF_FILE = 1 // socket.h:96:1: AF_IB = 27 // socket.h:123:1: AF_IEEE802154 = 36 // socket.h:132:1: AF_INET = 2 // socket.h:97:1: AF_INET6 = 10 // socket.h:105:1: AF_IPX = 4 // socket.h:99:1: AF_IRDA = 23 // socket.h:119:1: AF_ISDN = 34 // socket.h:130:1: AF_IUCV = 32 // socket.h:128:1: AF_KCM = 41 // socket.h:137:1: AF_KEY = 15 // socket.h:110:1: AF_LLC = 26 // socket.h:122:1: AF_LOCAL = 1 // socket.h:94:1: AF_MAX = 46 // socket.h:142:1: AF_MCTP = 45 // socket.h:141:1: AF_MPLS = 28 // socket.h:124:1: AF_NETBEUI = 13 // socket.h:108:1: AF_NETLINK = 16 // socket.h:111:1: AF_NETROM = 6 // socket.h:101:1: AF_NFC = 39 // socket.h:135:1: AF_PACKET = 17 // socket.h:113:1: AF_PHONET = 35 // socket.h:131:1: AF_PPPOX = 24 // socket.h:120:1: AF_QIPCRTR = 42 // socket.h:138:1: AF_RDS = 21 // socket.h:117:1: AF_ROSE = 11 // socket.h:106:1: AF_ROUTE = 16 // socket.h:112:1: AF_RXRPC = 33 // socket.h:129:1: AF_SECURITY = 14 // socket.h:109:1: AF_SMC = 43 // socket.h:139:1: AF_SNA = 22 // socket.h:118:1: AF_TIPC = 30 // socket.h:126:1: AF_UNIX = 1 // socket.h:95:1: AF_UNSPEC = 0 // socket.h:93:1: AF_VSOCK = 40 // socket.h:136:1: AF_WANPIPE = 25 // socket.h:121:1: AF_X25 = 9 // socket.h:104:1: AF_XDP = 44 // socket.h:140:1: AI_ADDRCONFIG = 0x0020 // netdb.h:601:1: AI_ALL = 0x0010 // netdb.h:600:1: AI_CANONNAME = 0x0002 // netdb.h:597:1: AI_NUMERICHOST = 0x0004 // netdb.h:598:1: AI_NUMERICSERV = 0x0400 // netdb.h:613:1: AI_PASSIVE = 0x0001 // netdb.h:596:1: AI_V4MAPPED = 0x0008 // netdb.h:599:1: BIG_ENDIAN = 4321 // endian.h:28:1: BYTE_ORDER = 1234 // endian.h:30:1: EAI_AGAIN = -3 // netdb.h:618:1: EAI_BADFLAGS = -1 // netdb.h:616:1: EAI_FAIL = -4 // netdb.h:619:1: EAI_FAMILY = -6 // netdb.h:620:1: EAI_MEMORY = -10 // netdb.h:623:1: EAI_NONAME = -2 // netdb.h:617:1: EAI_OVERFLOW = -12 // netdb.h:625:1: EAI_SERVICE = -8 // netdb.h:622:1: EAI_SOCKTYPE = -7 // netdb.h:621:1: EAI_SYSTEM = -11 // netdb.h:624:1: FD_SETSIZE = 1024 // select.h:73:1: FIOGETOWN = 0x8903 // sockios.h:8:1: FIOSETOWN = 0x8901 // sockios.h:6:1: HOST_NOT_FOUND = 1 // netdb.h:63:1: INET6_ADDRSTRLEN = 46 // in.h:243:1: INET_ADDRSTRLEN = 16 // in.h:242:1: IN_CLASSA_HOST = 16777215 // in.h:175:1: IN_CLASSA_MAX = 128 // in.h:176:1: IN_CLASSA_NET = 0xff000000 // in.h:173:1: IN_CLASSA_NSHIFT = 24 // in.h:174:1: IN_CLASSB_HOST = 65535 // in.h:181:1: IN_CLASSB_MAX = 65536 // in.h:182:1: IN_CLASSB_NET = 0xffff0000 // in.h:179:1: IN_CLASSB_NSHIFT = 16 // in.h:180:1: IN_CLASSC_HOST = 255 // in.h:187:1: IN_CLASSC_NET = 0xffffff00 // in.h:185:1: IN_CLASSC_NSHIFT = 8 // in.h:186:1: IN_LOOPBACKNET = 127 // in.h:206:1: IPPORT_RESERVED1 = 1024 // netdb.h:79:1: IPV6_2292DSTOPTS = 4 // in.h:166:1: IPV6_2292HOPLIMIT = 8 // in.h:170:1: IPV6_2292HOPOPTS = 3 // in.h:165:1: IPV6_2292PKTINFO = 2 // in.h:164:1: IPV6_2292PKTOPTIONS = 6 // in.h:168:1: IPV6_2292RTHDR = 5 // in.h:167:1: IPV6_ADDRFORM = 1 // in.h:163:1: IPV6_ADDR_PREFERENCES = 72 // in.h:219:1: IPV6_ADD_MEMBERSHIP = 20 // in.h:233:1: IPV6_AUTHHDR = 10 // in.h:175:1: IPV6_AUTOFLOWLABEL = 70 // in.h:216:1: IPV6_CHECKSUM = 7 // in.h:169:1: IPV6_DONTFRAG = 62 // in.h:210:1: IPV6_DROP_MEMBERSHIP = 21 // in.h:234:1: IPV6_DSTOPTS = 59 // in.h:207:1: IPV6_FREEBIND = 78 // in.h:229:1: IPV6_HDRINCL = 36 // in.h:194:1: IPV6_HOPLIMIT = 52 // in.h:200:1: IPV6_HOPOPTS = 54 // in.h:202:1: IPV6_IPSEC_POLICY = 34 // in.h:192:1: IPV6_JOIN_ANYCAST = 27 // in.h:187:1: IPV6_JOIN_GROUP = 20 // in.h:180:1: IPV6_LEAVE_ANYCAST = 28 // in.h:188:1: IPV6_LEAVE_GROUP = 21 // in.h:181:1: IPV6_MINHOPCOUNT = 73 // in.h:222:1: IPV6_MTU = 24 // in.h:184:1: IPV6_MTU_DISCOVER = 23 // in.h:183:1: IPV6_MULTICAST_ALL = 29 // in.h:189:1: IPV6_MULTICAST_HOPS = 18 // in.h:178:1: IPV6_MULTICAST_IF = 17 // in.h:177:1: IPV6_MULTICAST_LOOP = 19 // in.h:179:1: IPV6_NEXTHOP = 9 // in.h:174:1: IPV6_ORIGDSTADDR = 74 // in.h:224:1: IPV6_PATHMTU = 61 // in.h:209:1: IPV6_PKTINFO = 50 // in.h:198:1: IPV6_PMTUDISC_DO = 2 // in.h:242:1: IPV6_PMTUDISC_DONT = 0 // in.h:240:1: IPV6_PMTUDISC_INTERFACE = 4 // in.h:244:1: IPV6_PMTUDISC_OMIT = 5 // in.h:245:1: IPV6_PMTUDISC_PROBE = 3 // in.h:243:1: IPV6_PMTUDISC_WANT = 1 // in.h:241:1: IPV6_RECVDSTOPTS = 58 // in.h:206:1: IPV6_RECVERR = 25 // in.h:185:1: IPV6_RECVERR_RFC4884 = 31 // in.h:191:1: IPV6_RECVFRAGSIZE = 77 // in.h:228:1: IPV6_RECVHOPLIMIT = 51 // in.h:199:1: IPV6_RECVHOPOPTS = 53 // in.h:201:1: IPV6_RECVORIGDSTADDR = 74 // in.h:225:1: IPV6_RECVPATHMTU = 60 // in.h:208:1: IPV6_RECVPKTINFO = 49 // in.h:197:1: IPV6_RECVRTHDR = 56 // in.h:204:1: IPV6_RECVTCLASS = 66 // in.h:213:1: IPV6_ROUTER_ALERT = 22 // in.h:182:1: IPV6_ROUTER_ALERT_ISOLATE = 30 // in.h:190:1: IPV6_RTHDR = 57 // in.h:205:1: IPV6_RTHDRDSTOPTS = 55 // in.h:203:1: IPV6_RTHDR_LOOSE = 0 // in.h:252:1: IPV6_RTHDR_STRICT = 1 // in.h:253:1: IPV6_RTHDR_TYPE_0 = 0 // in.h:255:1: IPV6_RXDSTOPTS = 59 // in.h:237:1: IPV6_RXHOPOPTS = 54 // in.h:236:1: IPV6_TCLASS = 67 // in.h:214:1: IPV6_TRANSPARENT = 75 // in.h:226:1: IPV6_UNICAST_HOPS = 16 // in.h:176:1: IPV6_UNICAST_IF = 76 // in.h:227:1: IPV6_V6ONLY = 26 // in.h:186:1: IPV6_XFRM_POLICY = 35 // in.h:193:1: IP_ADD_MEMBERSHIP = 35 // in.h:122:1: IP_ADD_SOURCE_MEMBERSHIP = 39 // in.h:126:1: IP_BIND_ADDRESS_NO_PORT = 24 // in.h:103:1: IP_BLOCK_SOURCE = 38 // in.h:125:1: IP_CHECKSUM = 23 // in.h:102:1: IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:138:1: IP_DEFAULT_MULTICAST_TTL = 1 // in.h:137:1: IP_DROP_MEMBERSHIP = 36 // in.h:123:1: IP_DROP_SOURCE_MEMBERSHIP = 40 // in.h:127:1: IP_FREEBIND = 15 // in.h:89:1: IP_HDRINCL = 3 // in.h:48:1: IP_IPSEC_POLICY = 16 // in.h:90:1: IP_LOCAL_PORT_RANGE = 51 // in.h:131:1: IP_MAX_MEMBERSHIPS = 20 // in.h:139:1: IP_MINTTL = 21 // in.h:100:1: IP_MSFILTER = 41 // in.h:128:1: IP_MTU = 14 // in.h:88:1: IP_MTU_DISCOVER = 10 // in.h:84:1: IP_MULTICAST_ALL = 49 // in.h:129:1: IP_MULTICAST_IF = 32 // in.h:119:1: IP_MULTICAST_LOOP = 34 // in.h:121:1: IP_MULTICAST_TTL = 33 // in.h:120:1: IP_NODEFRAG = 22 // in.h:101:1: IP_OPTIONS = 4 // in.h:47:1: IP_ORIGDSTADDR = 20 // in.h:97:1: IP_PASSSEC = 18 // in.h:92:1: IP_PKTINFO = 8 // in.h:81:1: IP_PKTOPTIONS = 9 // in.h:82:1: IP_PMTUDISC = 10 // in.h:83:1: IP_PMTUDISC_DO = 2 // in.h:110:1: IP_PMTUDISC_DONT = 0 // in.h:108:1: IP_PMTUDISC_INTERFACE = 4 // in.h:115:1: IP_PMTUDISC_OMIT = 5 // in.h:117:1: IP_PMTUDISC_PROBE = 3 // in.h:111:1: IP_PMTUDISC_WANT = 1 // in.h:109:1: IP_PROTOCOL = 52 // in.h:132:1: IP_RECVERR = 11 // in.h:85:1: IP_RECVERR_RFC4884 = 26 // in.h:105:1: IP_RECVFRAGSIZE = 25 // in.h:104:1: IP_RECVOPTS = 6 // in.h:51:1: IP_RECVORIGDSTADDR = 20 // in.h:98:1: IP_RECVRETOPTS = 7 // in.h:53:1: IP_RECVTOS = 13 // in.h:87:1: IP_RECVTTL = 12 // in.h:86:1: IP_RETOPTS = 7 // in.h:54:1: IP_ROUTER_ALERT = 5 // in.h:80:1: IP_TOS = 1 // in.h:49:1: IP_TRANSPARENT = 19 // in.h:93:1: IP_TTL = 2 // in.h:50:1: IP_UNBLOCK_SOURCE = 37 // in.h:124:1: IP_UNICAST_IF = 50 // in.h:130:1: IP_XFRM_POLICY = 17 // in.h:91:1: LITTLE_ENDIAN = 1234 // endian.h:27:1: MCAST_BLOCK_SOURCE = 43 // in.h:67:1: MCAST_EXCLUDE = 0 // in.h:76:1: MCAST_INCLUDE = 1 // in.h:77:1: MCAST_JOIN_GROUP = 42 // in.h:66:1: MCAST_JOIN_SOURCE_GROUP = 46 // in.h:70:1: MCAST_LEAVE_GROUP = 45 // in.h:69:1: MCAST_LEAVE_SOURCE_GROUP = 47 // in.h:71:1: MCAST_MSFILTER = 48 // in.h:72:1: MCAST_UNBLOCK_SOURCE = 44 // in.h:68:1: NETDB_INTERNAL = -1 // netdb.h:72:1: NETDB_SUCCESS = 0 // netdb.h:73:1: NI_DGRAM = 16 // netdb.h:646:1: NI_MAXHOST = 1025 // netdb.h:638:1: NI_MAXSERV = 32 // netdb.h:639:1: NI_NAMEREQD = 8 // netdb.h:645:1: NI_NOFQDN = 4 // netdb.h:644:1: NI_NUMERICHOST = 1 // netdb.h:642:1: NI_NUMERICSERV = 2 // netdb.h:643:1: NO_ADDRESS = 4 // netdb.h:74:1: NO_DATA = 4 // netdb.h:68:1: NO_RECOVERY = 3 // netdb.h:66:1: PDP_ENDIAN = 3412 // endian.h:29:1: PF_ALG = 38 // socket.h:82:1: PF_APPLETALK = 5 // socket.h:48:1: PF_ASH = 18 // socket.h:62:1: PF_ATMPVC = 8 // socket.h:51:1: PF_ATMSVC = 20 // socket.h:64:1: PF_AX25 = 3 // socket.h:46:1: PF_BLUETOOTH = 31 // socket.h:75:1: PF_BRIDGE = 7 // socket.h:50:1: PF_CAIF = 37 // socket.h:81:1: PF_CAN = 29 // socket.h:73:1: PF_DECnet = 12 // socket.h:55:1: PF_ECONET = 19 // socket.h:63:1: PF_FILE = 1 // socket.h:44:1: PF_IB = 27 // socket.h:71:1: PF_IEEE802154 = 36 // socket.h:80:1: PF_INET = 2 // socket.h:45:1: PF_INET6 = 10 // socket.h:53:1: PF_IPX = 4 // socket.h:47:1: PF_IRDA = 23 // socket.h:67:1: PF_ISDN = 34 // socket.h:78:1: PF_IUCV = 32 // socket.h:76:1: PF_KCM = 41 // socket.h:85:1: PF_KEY = 15 // socket.h:58:1: PF_LLC = 26 // socket.h:70:1: PF_LOCAL = 1 // socket.h:42:1: PF_MAX = 46 // socket.h:90:1: PF_MCTP = 45 // socket.h:89:1: PF_MPLS = 28 // socket.h:72:1: PF_NETBEUI = 13 // socket.h:56:1: PF_NETLINK = 16 // socket.h:59:1: PF_NETROM = 6 // socket.h:49:1: PF_NFC = 39 // socket.h:83:1: PF_PACKET = 17 // socket.h:61:1: PF_PHONET = 35 // socket.h:79:1: PF_PPPOX = 24 // socket.h:68:1: PF_QIPCRTR = 42 // socket.h:86:1: PF_RDS = 21 // socket.h:65:1: PF_ROSE = 11 // socket.h:54:1: PF_ROUTE = 16 // socket.h:60:1: PF_RXRPC = 33 // socket.h:77:1: PF_SECURITY = 14 // socket.h:57:1: PF_SMC = 43 // socket.h:87:1: PF_SNA = 22 // socket.h:66:1: PF_TIPC = 30 // socket.h:74:1: PF_UNIX = 1 // socket.h:43:1: PF_UNSPEC = 0 // socket.h:41:1: PF_VSOCK = 40 // socket.h:84:1: PF_WANPIPE = 25 // socket.h:69:1: PF_X25 = 9 // socket.h:52:1: PF_XDP = 44 // socket.h:88:1: SCM_TIMESTAMP = 29 // socket.h:156:1: SCM_TIMESTAMPING = 37 // socket.h:158:1: SCM_TIMESTAMPING_OPT_STATS = 54 // socket.h:90:1: SCM_TIMESTAMPING_PKTINFO = 58 // socket.h:98:1: SCM_TIMESTAMPNS = 35 // socket.h:157:1: SCM_TXTIME = 61 // socket.h:105:1: SCM_WIFI_STATUS = 41 // socket.h:64:1: SIOCATMARK = 0x8905 // sockios.h:10:1: SIOCGPGRP = 0x8904 // sockios.h:9:1: SIOCGSTAMPNS_OLD = 0x8907 // sockios.h:12:1: SIOCGSTAMP_OLD = 0x8906 // sockios.h:11:1: SIOCSPGRP = 0x8902 // sockios.h:7:1: SOL_AAL = 265 // socket.h:153:1: SOL_ALG = 279 // socket.h:167:1: SOL_ATM = 264 // socket.h:152:1: SOL_BLUETOOTH = 274 // socket.h:162:1: SOL_CAIF = 278 // socket.h:166:1: SOL_DCCP = 269 // socket.h:157:1: SOL_DECNET = 261 // socket.h:149:1: SOL_ICMPV6 = 58 // in.h:249:1: SOL_IP = 0 // in.h:135:1: SOL_IPV6 = 41 // in.h:248:1: SOL_IRDA = 266 // socket.h:154:1: SOL_IUCV = 277 // socket.h:165:1: SOL_KCM = 281 // socket.h:169:1: SOL_LLC = 268 // socket.h:156:1: SOL_MCTP = 285 // socket.h:173:1: SOL_MPTCP = 284 // socket.h:172:1: SOL_NETBEUI = 267 // socket.h:155:1: SOL_NETLINK = 270 // socket.h:158:1: SOL_NFC = 280 // socket.h:168:1: SOL_PACKET = 263 // socket.h:151:1: SOL_PNPIPE = 275 // socket.h:163:1: SOL_PPPOL2TP = 273 // socket.h:161:1: SOL_RAW = 255 // socket.h:148:1: SOL_RDS = 276 // socket.h:164:1: SOL_RXRPC = 272 // socket.h:160:1: SOL_SMC = 286 // socket.h:174:1: SOL_SOCKET = 1 // socket.h:9:1: SOL_TIPC = 271 // socket.h:159:1: SOL_TLS = 282 // socket.h:170:1: SOL_X25 = 262 // socket.h:150:1: SOL_XDP = 283 // socket.h:171:1: SOMAXCONN = 4096 // socket.h:177:1: SO_ACCEPTCONN = 30 // socket.h:51:1: SO_ATTACH_BPF = 50 // socket.h:82:1: SO_ATTACH_FILTER = 26 // socket.h:45:1: SO_ATTACH_REUSEPORT_CBPF = 51 // socket.h:85:1: SO_ATTACH_REUSEPORT_EBPF = 52 // socket.h:86:1: SO_BINDTODEVICE = 25 // socket.h:42:1: SO_BINDTOIFINDEX = 62 // socket.h:107:1: SO_BPF_EXTENSIONS = 48 // socket.h:78:1: SO_BROADCAST = 6 // socket.h:16:1: SO_BSDCOMPAT = 14 // socket.h:26:1: SO_BUF_LOCK = 72 // socket.h:127:1: SO_BUSY_POLL = 46 // socket.h:74:1: SO_BUSY_POLL_BUDGET = 70 // socket.h:123:1: SO_CNX_ADVICE = 53 // socket.h:88:1: SO_COOKIE = 57 // socket.h:96:1: SO_DEBUG = 1 // socket.h:11:1: SO_DETACH_BPF = 27 // socket.h:83:1: SO_DETACH_FILTER = 27 // socket.h:46:1: SO_DETACH_REUSEPORT_BPF = 68 // socket.h:120:1: SO_DOMAIN = 39 // socket.h:59:1: SO_DONTROUTE = 5 // socket.h:15:1: SO_ERROR = 4 // socket.h:14:1: SO_GET_FILTER = 26 // socket.h:47:1: SO_INCOMING_CPU = 49 // socket.h:80:1: SO_INCOMING_NAPI_ID = 56 // socket.h:94:1: SO_KEEPALIVE = 9 // socket.h:21:1: SO_LINGER = 13 // socket.h:25:1: SO_LOCK_FILTER = 44 // socket.h:70:1: SO_MARK = 36 // socket.h:56:1: SO_MAX_PACING_RATE = 47 // socket.h:76:1: SO_MEMINFO = 55 // socket.h:92:1: SO_NETNS_COOKIE = 71 // socket.h:125:1: SO_NOFCS = 43 // socket.h:68:1: SO_NO_CHECK = 11 // socket.h:23:1: SO_OOBINLINE = 10 // socket.h:22:1: SO_PASSCRED = 16 // socket.h:29:1: SO_PASSPIDFD = 76 // socket.h:135:1: SO_PASSSEC = 34 // socket.h:54:1: SO_PEEK_OFF = 42 // socket.h:65:1: SO_PEERCRED = 17 // socket.h:30:1: SO_PEERGROUPS = 59 // socket.h:100:1: SO_PEERNAME = 28 // socket.h:49:1: SO_PEERPIDFD = 77 // socket.h:136:1: SO_PEERSEC = 31 // socket.h:53:1: SO_PREFER_BUSY_POLL = 69 // socket.h:122:1: SO_PRIORITY = 12 // socket.h:24:1: SO_PROTOCOL = 38 // socket.h:58:1: SO_RCVBUF = 8 // socket.h:18:1: SO_RCVBUFFORCE = 33 // socket.h:20:1: SO_RCVLOWAT = 18 // socket.h:31:1: SO_RCVMARK = 75 // socket.h:133:1: SO_RCVTIMEO = 20 // socket.h:145:1: SO_RCVTIMEO_NEW = 66 // socket.h:117:1: SO_RCVTIMEO_OLD = 20 // socket.h:33:1: SO_RESERVE_MEM = 73 // socket.h:129:1: SO_REUSEADDR = 2 // socket.h:12:1: SO_REUSEPORT = 15 // socket.h:27:1: SO_RXQ_OVFL = 40 // socket.h:61:1: SO_SECURITY_AUTHENTICATION = 22 // socket.h:38:1: SO_SECURITY_ENCRYPTION_NETWORK = 24 // socket.h:40:1: SO_SECURITY_ENCRYPTION_TRANSPORT = 23 // socket.h:39:1: SO_SELECT_ERR_QUEUE = 45 // socket.h:72:1: SO_SNDBUF = 7 // socket.h:17:1: SO_SNDBUFFORCE = 32 // socket.h:19:1: SO_SNDLOWAT = 19 // socket.h:32:1: SO_SNDTIMEO = 21 // socket.h:146:1: SO_SNDTIMEO_NEW = 67 // socket.h:118:1: SO_SNDTIMEO_OLD = 21 // socket.h:34:1: SO_TIMESTAMP = 29 // socket.h:141:1: SO_TIMESTAMPING = 37 // socket.h:143:1: SO_TIMESTAMPING_NEW = 65 // socket.h:115:1: SO_TIMESTAMPING_OLD = 37 // socket.h:111:1: SO_TIMESTAMPNS = 35 // socket.h:142:1: SO_TIMESTAMPNS_NEW = 64 // socket.h:114:1: SO_TIMESTAMPNS_OLD = 35 // socket.h:110:1: SO_TIMESTAMP_NEW = 63 // socket.h:113:1: SO_TIMESTAMP_OLD = 29 // socket.h:109:1: SO_TXREHASH = 74 // socket.h:131:1: SO_TXTIME = 61 // socket.h:104:1: SO_TYPE = 3 // socket.h:13:1: SO_WIFI_STATUS = 41 // socket.h:63:1: SO_ZEROCOPY = 60 // socket.h:102:1: TRY_AGAIN = 2 // netdb.h:64:1: X_ABILP64 = 3 // <predefined>:377:1: X_ATFILE_SOURCE = 1 // features.h:353:1: X_BITS_ATOMIC_WIDE_COUNTER_H = 0 // atomic_wide_counter.h:20:1: X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: X_BITS_ENDIAN_H = 1 // endian.h:20:1: X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:21:1: X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: X_BITS_SOCKADDR_H = 1 // sockaddr.h:24:1: X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: X_BITS_STDINT_UINTN_H = 1 // stdint-uintn.h:20:1: X_BITS_TIME64_H = 1 // time64.h:24:1: X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: X_BITS_TYPES_H = 1 // types.h:24:1: X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: X_BSD_SIZE_T_ = 0 // stddef.h:193:1: X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:196:1: X_DEFAULT_SOURCE = 1 // features.h:238:1: X_ENDIAN_H = 1 // endian.h:19:1: X_FEATURES_H = 1 // features.h:19:1: X_FILE_OFFSET_BITS = 64 // <builtin>:25:1: X_GCC_SIZE_T = 0 // stddef.h:200:1: X_LINUX_POSIX_TYPES_H = 0 // posix_types.h:3:1: X_LINUX_STDDEF_H = 0 // stddef.h:3:1: X_LOONGARCH_ARCH = "loongarch64" // <predefined>:214:1: X_LOONGARCH_ARCH_LOONGARCH64 = 1 // <predefined>:340:1: X_LOONGARCH_FPSET = 32 // <predefined>:265:1:
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/memory/trace_enabled.go
vendor/modernc.org/memory/trace_enabled.go
// Copyright 2017 The Memory Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build memory.trace // +build memory.trace package memory // import "modernc.org/memory" const trace = true
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/memory/mmap_windows.go
vendor/modernc.org/memory/mmap_windows.go
// Copyright 2017 The Memory Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package memory // import "modernc.org/memory" import ( syscall "golang.org/x/sys/windows" "os" ) const ( _MEM_COMMIT = 0x1000 _MEM_RESERVE = 0x2000 _MEM_DECOMMIT = 0x4000 _MEM_RELEASE = 0x8000 _PAGE_READWRITE = 0x0004 _PAGE_NOACCESS = 0x0001 ) const pageSizeLog = 16 var ( modkernel32 = syscall.NewLazySystemDLL("kernel32.dll") osPageMask = osPageSize - 1 osPageSize = os.Getpagesize() procVirtualAlloc = modkernel32.NewProc("VirtualAlloc") procVirtualFree = modkernel32.NewProc("VirtualFree") ) // pageSize aligned. func mmap(size int) (uintptr, int, error) { size = roundup(size, pageSize) addr, _, err := procVirtualAlloc.Call(0, uintptr(size), _MEM_COMMIT|_MEM_RESERVE, _PAGE_READWRITE) if err.(syscall.Errno) != 0 || addr == 0 { return addr, size, err } return addr, size, nil } func unmap(addr uintptr, size int) error { r, _, err := procVirtualFree.Call(addr, 0, _MEM_RELEASE) if r == 0 { return err } return nil }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/memory/memory.go
vendor/modernc.org/memory/memory.go
// Copyright 2017 The Memory Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package memory implements a memory allocator. // // # Build status // // available at https://modern-c.appspot.com/-/builder/?importpath=modernc.org%2fmemory // // # Changelog // // 2017-10-03 Added alternative, unsafe.Pointer-based API. // // Package memory implements a memory allocator. // // # Changelog // // 2017-10-03 Added alternative, unsafe.Pointer-based API. // // # Benchmarks // // jnml@3900x:~/src/modernc.org/memory$ date ; go version ; go test -run @ -bench . -benchmem |& tee log // Mon Sep 25 16:02:02 CEST 2023 // go version go1.21.1 linux/amd64 // goos: linux // goarch: amd64 // pkg: modernc.org/memory // cpu: AMD Ryzen 9 3900X 12-Core Processor // BenchmarkFree16-24 123506772 9.802 ns/op 0 B/op 0 allocs/op // BenchmarkFree32-24 73853230 15.08 ns/op 0 B/op 0 allocs/op // BenchmarkFree64-24 43070334 25.15 ns/op 0 B/op 0 allocs/op // BenchmarkCalloc16-24 59353304 18.92 ns/op 0 B/op 0 allocs/op // BenchmarkCalloc32-24 39415004 29.00 ns/op 0 B/op 0 allocs/op // BenchmarkCalloc64-24 35825725 32.02 ns/op 0 B/op 0 allocs/op // BenchmarkGoCalloc16-24 38274313 26.99 ns/op 16 B/op 1 allocs/op // BenchmarkGoCalloc32-24 44590477 33.06 ns/op 32 B/op 1 allocs/op // BenchmarkGoCalloc64-24 44233016 37.20 ns/op 64 B/op 1 allocs/op // BenchmarkMalloc16-24 145736911 7.720 ns/op 0 B/op 0 allocs/op // BenchmarkMalloc32-24 128898334 7.887 ns/op 0 B/op 0 allocs/op // BenchmarkMalloc64-24 149569483 7.994 ns/op 0 B/op 0 allocs/op // BenchmarkUintptrFree16-24 117043012 9.205 ns/op 0 B/op 0 allocs/op // BenchmarkUintptrFree32-24 77399617 14.20 ns/op 0 B/op 0 allocs/op // BenchmarkUintptrFree64-24 48770785 25.04 ns/op 0 B/op 0 allocs/op // BenchmarkUintptrCalloc16-24 79257636 15.44 ns/op 0 B/op 0 allocs/op // BenchmarkUintptrCalloc32-24 49644562 23.62 ns/op 0 B/op 0 allocs/op // BenchmarkUintptrCalloc64-24 39854710 28.22 ns/op 0 B/op 0 allocs/op // BenchmarkUintptrMalloc16-24 252987727 4.525 ns/op 0 B/op 0 allocs/op // BenchmarkUintptrMalloc32-24 241423840 4.433 ns/op 0 B/op 0 allocs/op // BenchmarkUintptrMalloc64-24 256450324 4.669 ns/op 0 B/op 0 allocs/op // PASS // ok modernc.org/memory 93.178s // jnml@3900x:~/src/modernc.org/memory$ package memory // import "modernc.org/memory" import ( "fmt" "math/bits" "os" "unsafe" ) const ( headerSize = unsafe.Sizeof(page{}) mallocAllign = 2 * unsafe.Sizeof(uintptr(0)) maxSlotSize = 1 << maxSlotSizeLog maxSlotSizeLog = pageSizeLog - 2 pageAvail = pageSize - headerSize pageMask = pageSize - 1 pageSize = 1 << pageSizeLog ) func init() { if unsafe.Sizeof(page{})%mallocAllign != 0 { panic("internal error") } } // if n%m != 0 { n += m-n%m }. m must be a power of 2. func roundup(n, m int) int { return (n + m - 1) &^ (m - 1) } type node struct { prev, next uintptr // *node } type page struct { brk int log uint size int used int } // Allocator allocates and frees memory. Its zero value is ready for use. The // exported counters are updated only when build tag memory.counters is // present. type Allocator struct { Allocs int // # of allocs. Bytes int // Asked from OS. cap [64]int lists [64]uintptr // *node Mmaps int // Asked from OS. pages [64]uintptr // *page regs map[uintptr]struct{} // map[*page]struct{} } func (a *Allocator) mmap(size int) (uintptr /* *page */, error) { p, size, err := mmap(size) if err != nil { return 0, err } //TODO(jnml) The returned size may now be nearly as twice as large as we asked //for. Use that extra capacity. For that we need to move the respective //Allocator.cap item into the page struct so the page cap becomes dynamic. // // Related: This is a consequence of fixing the bigsort.test failures on // linux/s390x, see: https://gitlab.com/cznic/sqlite/-/issues/207 if counters { a.Mmaps++ a.Bytes += size } if a.regs == nil { a.regs = map[uintptr]struct{}{} } (*page)(unsafe.Pointer(p)).size = size a.regs[p] = struct{}{} return p, nil } func (a *Allocator) newPage(size int) (uintptr /* *page */, error) { size += int(headerSize) p, err := a.mmap(size) if err != nil { return 0, err } (*page)(unsafe.Pointer(p)).log = 0 return p, nil } func (a *Allocator) newSharedPage(log uint) (uintptr /* *page */, error) { if a.cap[log] == 0 { a.cap[log] = int(pageAvail) / (1 << log) } size := int(headerSize) + a.cap[log]<<log p, err := a.mmap(size) if err != nil { return 0, err } a.pages[log] = p (*page)(unsafe.Pointer(p)).log = log return p, nil } func (a *Allocator) unmap(p uintptr /* *page */) error { delete(a.regs, p) if counters { a.Mmaps-- } return unmap(p, (*page)(unsafe.Pointer(p)).size) } // UintptrCalloc is like Calloc except it returns an uintptr. func (a *Allocator) UintptrCalloc(size int) (r uintptr, err error) { if trace { defer func() { fmt.Fprintf(os.Stderr, "Calloc(%#x) %#x, %v\n", size, r, err) }() } if r, err = a.UintptrMalloc(size); r == 0 || err != nil { return 0, err } b := ((*rawmem)(unsafe.Pointer(r)))[:size:size] for i := range b { b[i] = 0 } return r, nil } // UintptrFree is like Free except its argument is an uintptr, which must have // been acquired from UintptrCalloc or UintptrMalloc or UintptrRealloc. func (a *Allocator) UintptrFree(p uintptr) (err error) { if trace { defer func() { fmt.Fprintf(os.Stderr, "Free(%#x) %v\n", p, err) }() } if p == 0 { return nil } if counters { a.Allocs-- } pg := p &^ uintptr(pageMask) log := (*page)(unsafe.Pointer(pg)).log if log == 0 { if counters { a.Bytes -= (*page)(unsafe.Pointer(pg)).size } return a.unmap(pg) } (*node)(unsafe.Pointer(p)).prev = 0 (*node)(unsafe.Pointer(p)).next = a.lists[log] if next := (*node)(unsafe.Pointer(p)).next; next != 0 { (*node)(unsafe.Pointer(next)).prev = p } a.lists[log] = p (*page)(unsafe.Pointer(pg)).used-- if (*page)(unsafe.Pointer(pg)).used != 0 { return nil } for i := 0; i < (*page)(unsafe.Pointer(pg)).brk; i++ { n := pg + headerSize + uintptr(i)<<log next := (*node)(unsafe.Pointer(n)).next prev := (*node)(unsafe.Pointer(n)).prev switch { case prev == 0: a.lists[log] = next if next != 0 { (*node)(unsafe.Pointer(next)).prev = 0 } case next == 0: (*node)(unsafe.Pointer(prev)).next = 0 default: (*node)(unsafe.Pointer(prev)).next = next (*node)(unsafe.Pointer(next)).prev = prev } } if a.pages[log] == pg { a.pages[log] = 0 } if counters { a.Bytes -= (*page)(unsafe.Pointer(pg)).size } return a.unmap(pg) } // UintptrMalloc is like Malloc except it returns an uinptr. func (a *Allocator) UintptrMalloc(size int) (r uintptr, err error) { if trace { defer func() { fmt.Fprintf(os.Stderr, "Malloc(%#x) %#x, %v\n", size, r, err) }() } if size < 0 { panic("invalid malloc size") } if size == 0 { return 0, nil } if counters { a.Allocs++ } log := uint(bits.Len(uint((size+int(mallocAllign)-1)&^int(mallocAllign-1) - 1))) if log > maxSlotSizeLog { p, err := a.newPage(size) if err != nil { return 0, err } return p + headerSize, nil } if a.lists[log] == 0 && a.pages[log] == 0 { if _, err := a.newSharedPage(log); err != nil { return 0, err } } if p := a.pages[log]; p != 0 { (*page)(unsafe.Pointer(p)).used++ (*page)(unsafe.Pointer(p)).brk++ if (*page)(unsafe.Pointer(p)).brk == a.cap[log] { a.pages[log] = 0 } return p + headerSize + uintptr((*page)(unsafe.Pointer(p)).brk-1)<<log, nil } n := a.lists[log] p := n &^ uintptr(pageMask) a.lists[log] = (*node)(unsafe.Pointer(n)).next if next := (*node)(unsafe.Pointer(n)).next; next != 0 { (*node)(unsafe.Pointer(next)).prev = 0 } (*page)(unsafe.Pointer(p)).used++ return n, nil } // UintptrRealloc is like Realloc except its first argument is an uintptr, // which must have been returned from UintptrCalloc, UintptrMalloc or // UintptrRealloc. func (a *Allocator) UintptrRealloc(p uintptr, size int) (r uintptr, err error) { if trace { defer func() { fmt.Fprintf(os.Stderr, "UnsafeRealloc(%#x, %#x) %#x, %v\n", p, size, r, err) }() } switch { case p == 0: return a.UintptrMalloc(size) case size == 0 && p != 0: return 0, a.UintptrFree(p) } us := UintptrUsableSize(p) if us >= size { return p, nil } if r, err = a.UintptrMalloc(size); err != nil { return 0, err } if us < size { size = us } copy((*rawmem)(unsafe.Pointer(r))[:size:size], (*rawmem)(unsafe.Pointer(p))[:size:size]) return r, a.UintptrFree(p) } // UintptrUsableSize is like UsableSize except its argument is an uintptr, // which must have been returned from UintptrCalloc, UintptrMalloc or // UintptrRealloc. func UintptrUsableSize(p uintptr) (r int) { if trace { defer func() { fmt.Fprintf(os.Stderr, "UsableSize(%#x) %#x\n", p, r) }() } if p == 0 { return 0 } return usableSize(p) } func usableSize(p uintptr) (r int) { pg := p &^ uintptr(pageMask) if log := (*page)(unsafe.Pointer(pg)).log; log != 0 { return 1 << log } return (*page)(unsafe.Pointer(pg)).size - int(headerSize) } // Calloc is like Malloc except the allocated memory is zeroed. func (a *Allocator) Calloc(size int) (r []byte, err error) { p, err := a.UintptrCalloc(size) if err != nil { return nil, err } return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil } // Close releases all OS resources used by a and sets it to its zero value. // // It's not necessary to Close the Allocator when exiting a process. func (a *Allocator) Close() (err error) { for p := range a.regs { if e := a.unmap(p); e != nil && err == nil { err = e } } *a = Allocator{} return err } // Free deallocates memory (as in C.free). The argument of Free must have been // acquired from Calloc or Malloc or Realloc. func (a *Allocator) Free(b []byte) (err error) { if b = b[:cap(b)]; len(b) == 0 { return nil } return a.UintptrFree(uintptr(unsafe.Pointer(&b[0]))) } // Malloc allocates size bytes and returns a byte slice of the allocated // memory. The memory is not initialized. Malloc panics for size < 0 and // returns (nil, nil) for zero size. // // It's ok to reslice the returned slice but the result of appending to it // cannot be passed to Free or Realloc as it may refer to a different backing // array afterwards. func (a *Allocator) Malloc(size int) (r []byte, err error) { p, err := a.UintptrMalloc(size) if p == 0 || err != nil { return nil, err } return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil } // Realloc changes the size of the backing array of b to size bytes or returns // an error, if any. The contents will be unchanged in the range from the // start of the region up to the minimum of the old and new sizes. If the // new size is larger than the old size, the added memory will not be // initialized. If b's backing array is of zero size, then the call is // equivalent to Malloc(size), for all values of size; if size is equal to // zero, and b's backing array is not of zero size, then the call is equivalent // to Free(b). Unless b's backing array is of zero size, it must have been // returned by an earlier call to Malloc, Calloc or Realloc. If the area // pointed to was moved, a Free(b) is done. func (a *Allocator) Realloc(b []byte, size int) (r []byte, err error) { var p uintptr if b = b[:cap(b)]; len(b) != 0 { p = uintptr(unsafe.Pointer(&b[0])) } if p, err = a.UintptrRealloc(p, size); p == 0 || err != nil { return nil, err } return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil } // UsableSize reports the size of the memory block allocated at p, which must // point to the first byte of a slice returned from Calloc, Malloc or Realloc. // The allocated memory block size can be larger than the size originally // requested from Calloc, Malloc or Realloc. func UsableSize(p *byte) (r int) { return UintptrUsableSize(uintptr(unsafe.Pointer(p))) } // UnsafeCalloc is like Calloc except it returns an unsafe.Pointer. func (a *Allocator) UnsafeCalloc(size int) (r unsafe.Pointer, err error) { p, err := a.UintptrCalloc(size) if err != nil { return nil, err } return unsafe.Pointer(p), nil } // UnsafeFree is like Free except its argument is an unsafe.Pointer, which must // have been acquired from UnsafeCalloc or UnsafeMalloc or UnsafeRealloc. func (a *Allocator) UnsafeFree(p unsafe.Pointer) (err error) { return a.UintptrFree(uintptr(p)) } // UnsafeMalloc is like Malloc except it returns an unsafe.Pointer. func (a *Allocator) UnsafeMalloc(size int) (r unsafe.Pointer, err error) { p, err := a.UintptrMalloc(size) if err != nil { return nil, err } return unsafe.Pointer(p), nil } // UnsafeRealloc is like Realloc except its first argument is an // unsafe.Pointer, which must have been returned from UnsafeCalloc, // UnsafeMalloc or UnsafeRealloc. func (a *Allocator) UnsafeRealloc(p unsafe.Pointer, size int) (r unsafe.Pointer, err error) { q, err := a.UintptrRealloc(uintptr(p), size) if err != nil { return nil, err } return unsafe.Pointer(q), nil } // UnsafeUsableSize is like UsableSize except its argument is an // unsafe.Pointer, which must have been returned from UnsafeCalloc, // UnsafeMalloc or UnsafeRealloc. func UnsafeUsableSize(p unsafe.Pointer) (r int) { return UintptrUsableSize(uintptr(p)) }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/memory/mmap_unix.go
vendor/modernc.org/memory/mmap_unix.go
// Copyright 2011 Evan Shaw. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE-MMAP-GO file. //go:build unix // Modifications (c) 2017 The Memory Authors. package memory // import "modernc.org/memory" import ( "golang.org/x/sys/unix" "os" "unsafe" ) const pageSizeLog = 16 var ( osPageMask = osPageSize - 1 osPageSize = os.Getpagesize() ) func unmap(addr uintptr, size int) error { return unix.MunmapPtr(unsafe.Pointer(addr), uintptr(size)) } // pageSize aligned. func mmap(size int) (uintptr, int, error) { size = roundup(size, osPageSize) // Ask for more so we can align the result at a pageSize boundary n := size + pageSize up, err := unix.MmapPtr(-1, 0, nil, uintptr(n), unix.PROT_READ|unix.PROT_WRITE, unix.MAP_PRIVATE|unix.MAP_ANON) if err != nil { return 0, 0, err } p := uintptr(up) if p&uintptr(osPageMask) != 0 { panic("internal error") } mod := int(p) & pageMask if mod != 0 { // Return the extra part before pageSize aligned block m := pageSize - mod if err := unmap(p, m); err != nil { unmap(p, n) // Do not leak the first mmap return 0, 0, err } n -= m p += uintptr(m) } if p&uintptr(pageMask) != 0 { panic("internal error") } if n > size { // Return the extra part after pageSize aligned block if err := unmap(p+uintptr(size), n-size); err != nil { // Do not error when the kernel rejects the extra part after, just return the // unexpectedly enlarged size. // // Fixes the bigsort.test failures on linux/s390x, see: https://gitlab.com/cznic/sqlite/-/issues/207 size = n } } return p, size, nil }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/memory/memory64.go
vendor/modernc.org/memory/memory64.go
// Copyright 2018 The Memory Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build amd64 || amd64p32 || arm64 || arm64be || mips64 || mips64le || mips64p32 || mips64p32le || ppc64 || ppc64le || sparc64 || riscv64 || loong64 // +build amd64 amd64p32 arm64 arm64be mips64 mips64le mips64p32 mips64p32le ppc64 ppc64le sparc64 riscv64 loong64 package memory // import "modernc.org/memory" type rawmem [1<<50 - 1]byte
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/memory/memory32.go
vendor/modernc.org/memory/memory32.go
// Copyright 2018 The Memory Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build 386 || arm || armbe || mips || mipsle || ppc || s390 || s390x || sparc // +build 386 arm armbe mips mipsle ppc s390 s390x sparc package memory // import "modernc.org/memory" type rawmem [1<<31 - 2]byte
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/memory/nocounters.go
vendor/modernc.org/memory/nocounters.go
// Copyright 2017 The Memory Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build !memory.counters // +build !memory.counters package memory // import "modernc.org/memory" const counters = false
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/memory/trace_disabled.go
vendor/modernc.org/memory/trace_disabled.go
// Copyright 2017 The Memory Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build !memory.trace // +build !memory.trace package memory // import "modernc.org/memory" const trace = false
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/memory/counters.go
vendor/modernc.org/memory/counters.go
// Copyright 2017 The Memory Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build memory.counters // +build memory.counters package memory // import "modernc.org/memory" const counters = true
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/sqr.go
vendor/modernc.org/mathutil/sqr.go
//go:build !riscv64 && !loong64 // +build !riscv64,!loong64 package mathutil import "github.com/remyoudompheng/bigfft" func (f *float) sqr() { f.n = bigfft.Mul(f.n, f.n) f.fracBits *= 2 f.normalize() }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/binarylog.go
vendor/modernc.org/mathutil/binarylog.go
// Copyright (c) 2016 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mathutil // import "modernc.org/mathutil" import ( "math/big" ) type float struct { n *big.Int fracBits int maxFracBits int } func newFloat(n *big.Int, fracBits, maxFracBits int) float { f := float{n: n, fracBits: fracBits, maxFracBits: maxFracBits} f.normalize() return f } func (f *float) normalize() { n := f.n.BitLen() if n == 0 { return } if n := f.fracBits - f.maxFracBits; n > 0 { bit := f.n.Bit(n - 1) f.n.Rsh(f.n, uint(n)) if bit != 0 { f.n.Add(f.n, _1) } f.fracBits -= n } var i int for ; f.fracBits > 0 && i <= f.fracBits && f.n.Bit(i) == 0; i++ { f.fracBits-- } if i != 0 { f.n.Rsh(f.n, uint(i)) } } func (f *float) eq1() bool { return f.fracBits == 0 && f.n.BitLen() == 1 } func (f *float) ge2() bool { return f.n.BitLen() > f.fracBits+1 } func (f *float) div2() { f.fracBits++ f.normalize() } // BinaryLog computes the binary logarithm of n. The result consists of a // characteristic and a mantissa having precision mantissaBits. The value of // the binary logarithm is // // characteristic + mantissa*(2^-mantissaBits) // // BinaryLog panics for n <= 0 or mantissaBits < 0. func BinaryLog(n *big.Int, mantissaBits int) (characteristic int, mantissa *big.Int) { if n.Sign() <= 0 || mantissaBits < 0 { panic("invalid argument of BinaryLog") } characteristic = n.BitLen() - 1 mantissa = big.NewInt(0) x := newFloat(n, characteristic, mantissaBits) for ; mantissaBits != 0 && !x.eq1(); mantissaBits-- { x.sqr() mantissa.Lsh(mantissa, 1) if x.ge2() { mantissa.SetBit(mantissa, 0, 1) x.div2() } } return characteristic, mantissa }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/bits.go
vendor/modernc.org/mathutil/bits.go
// Copyright (c) 2014 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mathutil // import "modernc.org/mathutil" import ( "math/big" ) // BitLenByte returns the bit width of the non zero part of n. func BitLenByte(n byte) int { return log2[n] + 1 } // BitLenUint16 returns the bit width of the non zero part of n. func BitLenUint16(n uint16) int { if b := n >> 8; b != 0 { return log2[b] + 8 + 1 } return log2[n] + 1 } // BitLenUint32 returns the bit width of the non zero part of n. func BitLenUint32(n uint32) int { if b := n >> 24; b != 0 { return log2[b] + 24 + 1 } if b := n >> 16; b != 0 { return log2[b] + 16 + 1 } if b := n >> 8; b != 0 { return log2[b] + 8 + 1 } return log2[n] + 1 } // BitLen returns the bit width of the non zero part of n. func BitLen(n int) int { // Should handle correctly [future] 64 bit Go ints if IntBits == 64 { return BitLenUint64(uint64(n)) } if b := byte(n >> 24); b != 0 { return log2[b] + 24 + 1 } if b := byte(n >> 16); b != 0 { return log2[b] + 16 + 1 } if b := byte(n >> 8); b != 0 { return log2[b] + 8 + 1 } return log2[byte(n)] + 1 } // BitLenUint returns the bit width of the non zero part of n. func BitLenUint(n uint) int { // Should handle correctly [future] 64 bit Go uints if IntBits == 64 { return BitLenUint64(uint64(n)) } if b := n >> 24; b != 0 { return log2[b] + 24 + 1 } if b := n >> 16; b != 0 { return log2[b] + 16 + 1 } if b := n >> 8; b != 0 { return log2[b] + 8 + 1 } return log2[n] + 1 } // BitLenUint64 returns the bit width of the non zero part of n. func BitLenUint64(n uint64) int { if b := n >> 56; b != 0 { return log2[b] + 56 + 1 } if b := n >> 48; b != 0 { return log2[b] + 48 + 1 } if b := n >> 40; b != 0 { return log2[b] + 40 + 1 } if b := n >> 32; b != 0 { return log2[b] + 32 + 1 } if b := n >> 24; b != 0 { return log2[b] + 24 + 1 } if b := n >> 16; b != 0 { return log2[b] + 16 + 1 } if b := n >> 8; b != 0 { return log2[b] + 8 + 1 } return log2[n] + 1 } // BitLenUintptr returns the bit width of the non zero part of n. func BitLenUintptr(n uintptr) int { if b := n >> 56; b != 0 { return log2[b] + 56 + 1 } if b := n >> 48; b != 0 { return log2[b] + 48 + 1 } if b := n >> 40; b != 0 { return log2[b] + 40 + 1 } if b := n >> 32; b != 0 { return log2[b] + 32 + 1 } if b := n >> 24; b != 0 { return log2[b] + 24 + 1 } if b := n >> 16; b != 0 { return log2[b] + 16 + 1 } if b := n >> 8; b != 0 { return log2[b] + 8 + 1 } return log2[n] + 1 } // PopCountByte returns population count of n (number of bits set in n). func PopCountByte(n byte) int { return int(popcnt[n]) } // PopCountUint16 returns population count of n (number of bits set in n). func PopCountUint16(n uint16) int { return int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) } // PopCountUint32 returns population count of n (number of bits set in n). func PopCountUint32(n uint32) int { return int(popcnt[byte(n>>24)]) + int(popcnt[byte(n>>16)]) + int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) } // PopCount returns population count of n (number of bits set in n). func PopCount(n int) int { // Should handle correctly [future] 64 bit Go ints if IntBits == 64 { return PopCountUint64(uint64(n)) } return PopCountUint32(uint32(n)) } // PopCountUint returns population count of n (number of bits set in n). func PopCountUint(n uint) int { // Should handle correctly [future] 64 bit Go uints if IntBits == 64 { return PopCountUint64(uint64(n)) } return PopCountUint32(uint32(n)) } // PopCountUintptr returns population count of n (number of bits set in n). func PopCountUintptr(n uintptr) int { if UintPtrBits == 64 { return PopCountUint64(uint64(n)) } return PopCountUint32(uint32(n)) } // PopCountUint64 returns population count of n (number of bits set in n). func PopCountUint64(n uint64) int { return int(popcnt[byte(n>>56)]) + int(popcnt[byte(n>>48)]) + int(popcnt[byte(n>>40)]) + int(popcnt[byte(n>>32)]) + int(popcnt[byte(n>>24)]) + int(popcnt[byte(n>>16)]) + int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) } // PopCountBigInt returns population count of |n| (number of bits set in |n|). func PopCountBigInt(n *big.Int) (r int) { for _, v := range n.Bits() { r += PopCountUintptr(uintptr(v)) } return }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/rat.go
vendor/modernc.org/mathutil/rat.go
// Copyright (c) 2014 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mathutil // import "modernc.org/mathutil" // QCmpUint32 compares a/b and c/d and returns: // // -1 if a/b < c/d // 0 if a/b == c/d // +1 if a/b > c/d func QCmpUint32(a, b, c, d uint32) int { switch x, y := uint64(a)*uint64(d), uint64(b)*uint64(c); { case x < y: return -1 case x == y: return 0 default: // x > y return 1 } } // QScaleUint32 returns a such that a/b >= c/d. func QScaleUint32(b, c, d uint32) (a uint64) { return 1 + (uint64(b)*uint64(c))/uint64(d) }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/sqr_std.go
vendor/modernc.org/mathutil/sqr_std.go
//go:build riscv64 || loong64 // +build riscv64 loong64 package mathutil func (f *float) sqr() { f.n.Mul(f.n, f.n) f.fracBits *= 2 f.normalize() }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/envelope.go
vendor/modernc.org/mathutil/envelope.go
// Copyright (c) 2014 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mathutil // import "modernc.org/mathutil" import ( "math" ) // Approximation type determines approximation methods used by e.g. Envelope. type Approximation int // Specific approximation method tags const ( _ Approximation = iota Linear // As named Sinusoidal // Smooth for all derivations ) // Envelope is an utility for defining simple curves using a small (usually) // set of data points. Envelope returns a value defined by x, points and // approximation. The value of x must be in [0,1) otherwise the result is // undefined or the function may panic. Points are interpreted as dividing the // [0,1) interval in len(points)-1 sections, so len(points) must be > 1 or the // function may panic. According to the left and right points closing/adjacent // to the section the resulting value is interpolated using the chosen // approximation method. Unsupported values of approximation are silently // interpreted as 'Linear'. func Envelope(x float64, points []float64, approximation Approximation) float64 { step := 1 / float64(len(points)-1) fslot := math.Floor(x / step) mod := x - fslot*step slot := int(fslot) l, r := points[slot], points[slot+1] rmod := mod / step switch approximation { case Sinusoidal: k := (math.Sin(math.Pi*(rmod-0.5)) + 1) / 2 return l + (r-l)*k case Linear: fallthrough default: return l + (r-l)*rmod } }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/permute.go
vendor/modernc.org/mathutil/permute.go
// Copyright (c) 2014 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mathutil // import "modernc.org/mathutil" import ( "sort" ) // PermutationFirst generates the first permutation of data. func PermutationFirst(data sort.Interface) { sort.Sort(data) } // PermutationNext generates the next permutation of data if possible and // return true. Return false if there is no more permutation left. Based on // the algorithm described here: // http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order func PermutationNext(data sort.Interface) bool { var k, l int for k = data.Len() - 2; ; k-- { // 1. if k < 0 { return false } if data.Less(k, k+1) { break } } for l = data.Len() - 1; !data.Less(k, l); l-- { // 2. } data.Swap(k, l) // 3. for i, j := k+1, data.Len()-1; i < j; i++ { // 4. data.Swap(i, j) j-- } return true }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/mathutil.go
vendor/modernc.org/mathutil/mathutil.go
// Copyright (c) 2014 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package mathutil provides utilities supplementing the standard 'math' and // 'math/rand' packages. // // # Release history and compatibility issues // // 2020-12-20 v1.2.1 fixes MulOverflowInt64. // // 2020-12-19 Added {Add,Sub,Mul}OverflowInt{8,16,32,64} // // 2018-10-21 Added BinaryLog // // 2018-04-25: New functions for determining Max/Min of nullable values. Ex: // // func MaxPtr(a, b *int) *int { // func MinPtr(a, b *int) *int { // func MaxBytePtr(a, b *byte) *byte { // func MinBytePtr(a, b *byte) *byte { // ... // // 2017-10-14: New variadic functions for Max/Min. Ex: // // func MaxVal(val int, vals ...int) int { // func MinVal(val int, vals ...int) int { // func MaxByteVal(val byte, vals ...byte) byte { // func MinByteVal(val byte, vals ...byte) byte { // ... // // 2016-10-10: New functions QuadPolyDiscriminant and QuadPolyFactors. // // 2013-12-13: The following functions have been REMOVED // // func Uint64ToBigInt(n uint64) *big.Int // func Uint64FromBigInt(n *big.Int) (uint64, bool) // // 2013-05-13: The following functions are now DEPRECATED // // func Uint64ToBigInt(n uint64) *big.Int // func Uint64FromBigInt(n *big.Int) (uint64, bool) // // These functions will be REMOVED with Go release 1.1+1. // // 2013-01-21: The following functions have been REMOVED // // func MaxInt() int // func MinInt() int // func MaxUint() uint // func UintPtrBits() int // // They are now replaced by untyped constants // // MaxInt // MinInt // MaxUint // UintPtrBits // // Additionally one more untyped constant was added // // IntBits // // This change breaks any existing code depending on the above removed // functions. They should have not been published in the first place, that was // unfortunate. Instead, defining such architecture and/or implementation // specific integer limits and bit widths as untyped constants improves // performance and allows for static dead code elimination if it depends on // these values. Thanks to minux for pointing it out in the mail list // (https://groups.google.com/d/msg/golang-nuts/tlPpLW6aJw8/NT3mpToH-a4J). // // 2012-12-12: The following functions will be DEPRECATED with Go release // 1.0.3+1 and REMOVED with Go release 1.0.3+2, b/c of // http://code.google.com/p/go/source/detail?r=954a79ee3ea8 // // func Uint64ToBigInt(n uint64) *big.Int // func Uint64FromBigInt(n *big.Int) (uint64, bool) package mathutil // import "modernc.org/mathutil" import ( "math" "math/big" ) // Architecture and/or implementation specific integer limits and bit widths. const ( MaxInt = 1<<(IntBits-1) - 1 MinInt = -MaxInt - 1 MaxUint = 1<<IntBits - 1 IntBits = 1 << (^uint(0)>>32&1 + ^uint(0)>>16&1 + ^uint(0)>>8&1 + 3) UintPtrBits = 1 << (^uintptr(0)>>32&1 + ^uintptr(0)>>16&1 + ^uintptr(0)>>8&1 + 3) ) var ( _1 = big.NewInt(1) _2 = big.NewInt(2) ) // GCDByte returns the greatest common divisor of a and b. Based on: // http://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations func GCDByte(a, b byte) byte { for b != 0 { a, b = b, a%b } return a } // GCDUint16 returns the greatest common divisor of a and b. func GCDUint16(a, b uint16) uint16 { for b != 0 { a, b = b, a%b } return a } // GCDUint32 returns the greatest common divisor of a and b. func GCDUint32(a, b uint32) uint32 { for b != 0 { a, b = b, a%b } return a } // GCDUint64 returns the greatest common divisor of a and b. func GCDUint64(a, b uint64) uint64 { for b != 0 { a, b = b, a%b } return a } // ISqrt returns floor(sqrt(n)). Typical run time is few hundreds of ns. func ISqrt(n uint32) (x uint32) { if n == 0 { return } if n >= math.MaxUint16*math.MaxUint16 { return math.MaxUint16 } var px, nx uint32 for x = n; ; px, x = x, nx { nx = (x + n/x) / 2 if nx == x || nx == px { break } } return } // SqrtUint64 returns floor(sqrt(n)). Typical run time is about 0.5 µs. func SqrtUint64(n uint64) (x uint64) { if n == 0 { return } if n >= math.MaxUint32*math.MaxUint32 { return math.MaxUint32 } var px, nx uint64 for x = n; ; px, x = x, nx { nx = (x + n/x) / 2 if nx == x || nx == px { break } } return } // SqrtBig returns floor(sqrt(n)). It panics on n < 0. func SqrtBig(n *big.Int) (x *big.Int) { switch n.Sign() { case -1: panic(-1) case 0: return big.NewInt(0) } var px, nx big.Int x = big.NewInt(0) x.SetBit(x, n.BitLen()/2+1, 1) for { nx.Rsh(nx.Add(x, nx.Div(n, x)), 1) if nx.Cmp(x) == 0 || nx.Cmp(&px) == 0 { break } px.Set(x) x.Set(&nx) } return } // Log2Byte returns log base 2 of n. It's the same as index of the highest // bit set in n. For n == 0 -1 is returned. func Log2Byte(n byte) int { return log2[n] } // Log2Uint16 returns log base 2 of n. It's the same as index of the highest // bit set in n. For n == 0 -1 is returned. func Log2Uint16(n uint16) int { if b := n >> 8; b != 0 { return log2[b] + 8 } return log2[n] } // Log2Uint32 returns log base 2 of n. It's the same as index of the highest // bit set in n. For n == 0 -1 is returned. func Log2Uint32(n uint32) int { if b := n >> 24; b != 0 { return log2[b] + 24 } if b := n >> 16; b != 0 { return log2[b] + 16 } if b := n >> 8; b != 0 { return log2[b] + 8 } return log2[n] } // Log2Uint64 returns log base 2 of n. It's the same as index of the highest // bit set in n. For n == 0 -1 is returned. func Log2Uint64(n uint64) int { if b := n >> 56; b != 0 { return log2[b] + 56 } if b := n >> 48; b != 0 { return log2[b] + 48 } if b := n >> 40; b != 0 { return log2[b] + 40 } if b := n >> 32; b != 0 { return log2[b] + 32 } if b := n >> 24; b != 0 { return log2[b] + 24 } if b := n >> 16; b != 0 { return log2[b] + 16 } if b := n >> 8; b != 0 { return log2[b] + 8 } return log2[n] } // ModPowByte computes (b^e)%m. It panics for m == 0 || b == e == 0. // // See also: http://en.wikipedia.org/wiki/Modular_exponentiation#Right-to-left_binary_method func ModPowByte(b, e, m byte) byte { if b == 0 && e == 0 { panic(0) } if m == 1 { return 0 } r := uint16(1) for b, m := uint16(b), uint16(m); e > 0; b, e = b*b%m, e>>1 { if e&1 == 1 { r = r * b % m } } return byte(r) } // ModPowUint16 computes (b^e)%m. It panics for m == 0 || b == e == 0. func ModPowUint16(b, e, m uint16) uint16 { if b == 0 && e == 0 { panic(0) } if m == 1 { return 0 } r := uint32(1) for b, m := uint32(b), uint32(m); e > 0; b, e = b*b%m, e>>1 { if e&1 == 1 { r = r * b % m } } return uint16(r) } // ModPowUint32 computes (b^e)%m. It panics for m == 0 || b == e == 0. func ModPowUint32(b, e, m uint32) uint32 { if b == 0 && e == 0 { panic(0) } if m == 1 { return 0 } r := uint64(1) for b, m := uint64(b), uint64(m); e > 0; b, e = b*b%m, e>>1 { if e&1 == 1 { r = r * b % m } } return uint32(r) } // ModPowUint64 computes (b^e)%m. It panics for m == 0 || b == e == 0. func ModPowUint64(b, e, m uint64) (r uint64) { if b == 0 && e == 0 { panic(0) } if m == 1 { return 0 } return modPowBigInt(big.NewInt(0).SetUint64(b), big.NewInt(0).SetUint64(e), big.NewInt(0).SetUint64(m)).Uint64() } func modPowBigInt(b, e, m *big.Int) (r *big.Int) { r = big.NewInt(1) for i, n := 0, e.BitLen(); i < n; i++ { if e.Bit(i) != 0 { r.Mod(r.Mul(r, b), m) } b.Mod(b.Mul(b, b), m) } return } // ModPowBigInt computes (b^e)%m. Returns nil for e < 0. It panics for m == 0 || b == e == 0. func ModPowBigInt(b, e, m *big.Int) (r *big.Int) { if b.Sign() == 0 && e.Sign() == 0 { panic(0) } if m.Cmp(_1) == 0 { return big.NewInt(0) } if e.Sign() < 0 { return } return modPowBigInt(big.NewInt(0).Set(b), big.NewInt(0).Set(e), m) } var uint64ToBigIntDelta big.Int func init() { uint64ToBigIntDelta.SetBit(&uint64ToBigIntDelta, 63, 1) } var uintptrBits int func init() { x := uint64(math.MaxUint64) uintptrBits = BitLenUintptr(uintptr(x)) } // UintptrBits returns the bit width of an uintptr at the executing machine. func UintptrBits() int { return uintptrBits } // AddUint128_64 returns the uint128 sum of uint64 a and b. func AddUint128_64(a, b uint64) (hi uint64, lo uint64) { lo = a + b if lo < a { hi = 1 } return hi, lo } // MulUint128_64 returns the uint128 bit product of uint64 a and b. func MulUint128_64(a, b uint64) (hi, lo uint64) { /* 2^(2 W) ahi bhi + 2^W alo bhi + 2^W ahi blo + alo blo FEDCBA98 76543210 FEDCBA98 76543210 ---- alo*blo ---- ---- alo*bhi ---- ---- ahi*blo ---- ---- ahi*bhi ---- */ const w = 32 const m = 1<<w - 1 ahi, bhi, alo, blo := a>>w, b>>w, a&m, b&m lo = alo * blo mid1 := alo * bhi mid2 := ahi * blo c1, lo := AddUint128_64(lo, mid1<<w) c2, lo := AddUint128_64(lo, mid2<<w) _, hi = AddUint128_64(ahi*bhi, mid1>>w+mid2>>w+c1+c2) return } // PowerizeBigInt returns (e, p) such that e is the smallest number for which p // == b^e is greater or equal n. For n < 0 or b < 2 (0, nil) is returned. // // NOTE: Run time for large values of n (above about 2^1e6 ~= 1e300000) can be // significant and/or unacceptabe. For any smaller values of n the function // typically performs in sub second time. For "small" values of n (cca bellow // 2^1e3 ~= 1e300) the same can be easily below 10 µs. // // A special (and trivial) case of b == 2 is handled separately and performs // much faster. func PowerizeBigInt(b, n *big.Int) (e uint32, p *big.Int) { switch { case b.Cmp(_2) < 0 || n.Sign() < 0: return case n.Sign() == 0 || n.Cmp(_1) == 0: return 0, big.NewInt(1) case b.Cmp(_2) == 0: p = big.NewInt(0) e = uint32(n.BitLen() - 1) p.SetBit(p, int(e), 1) if p.Cmp(n) < 0 { p.Mul(p, _2) e++ } return } bw := b.BitLen() nw := n.BitLen() p = big.NewInt(1) var bb, r big.Int for { switch p.Cmp(n) { case -1: x := uint32((nw - p.BitLen()) / bw) if x == 0 { x = 1 } e += x switch x { case 1: p.Mul(p, b) default: r.Set(_1) bb.Set(b) e := x for { if e&1 != 0 { r.Mul(&r, &bb) } if e >>= 1; e == 0 { break } bb.Mul(&bb, &bb) } p.Mul(p, &r) } case 0, 1: return } } } // PowerizeUint32BigInt returns (e, p) such that e is the smallest number for // which p == b^e is greater or equal n. For n < 0 or b < 2 (0, nil) is // returned. // // More info: see PowerizeBigInt. func PowerizeUint32BigInt(b uint32, n *big.Int) (e uint32, p *big.Int) { switch { case b < 2 || n.Sign() < 0: return case n.Sign() == 0 || n.Cmp(_1) == 0: return 0, big.NewInt(1) case b == 2: p = big.NewInt(0) e = uint32(n.BitLen() - 1) p.SetBit(p, int(e), 1) if p.Cmp(n) < 0 { p.Mul(p, _2) e++ } return } var bb big.Int bb.SetInt64(int64(b)) return PowerizeBigInt(&bb, n) } /* ProbablyPrimeUint32 returns true if n is prime or n is a pseudoprime to base a. It implements the Miller-Rabin primality test for one specific value of 'a' and k == 1. Wrt pseudocode shown at http://en.wikipedia.org/wiki/Miller-Rabin_primality_test#Algorithm_and_running_time Input: n > 3, an odd integer to be tested for primality; Input: k, a parameter that determines the accuracy of the test Output: composite if n is composite, otherwise probably prime write n − 1 as 2^s·d with d odd by factoring powers of 2 from n − 1 LOOP: repeat k times: pick a random integer a in the range [2, n − 2] x ← a^d mod n if x = 1 or x = n − 1 then do next LOOP for r = 1 .. s − 1 x ← x^2 mod n if x = 1 then return composite if x = n − 1 then do next LOOP return composite return probably prime ... this function behaves like passing 1 for 'k' and additionally a fixed/non-random 'a'. Otherwise it's the same algorithm. See also: http://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html */ func ProbablyPrimeUint32(n, a uint32) bool { d, s := n-1, 0 for ; d&1 == 0; d, s = d>>1, s+1 { } x := uint64(ModPowUint32(a, d, n)) if x == 1 || uint32(x) == n-1 { return true } for ; s > 1; s-- { if x = x * x % uint64(n); x == 1 { return false } if uint32(x) == n-1 { return true } } return false } // ProbablyPrimeUint64_32 returns true if n is prime or n is a pseudoprime to // base a. It implements the Miller-Rabin primality test for one specific value // of 'a' and k == 1. See also ProbablyPrimeUint32. func ProbablyPrimeUint64_32(n uint64, a uint32) bool { d, s := n-1, 0 for ; d&1 == 0; d, s = d>>1, s+1 { } x := ModPowUint64(uint64(a), d, n) if x == 1 || x == n-1 { return true } bx, bn := big.NewInt(0).SetUint64(x), big.NewInt(0).SetUint64(n) for ; s > 1; s-- { if x = bx.Mod(bx.Mul(bx, bx), bn).Uint64(); x == 1 { return false } if x == n-1 { return true } } return false } // ProbablyPrimeBigInt_32 returns true if n is prime or n is a pseudoprime to // base a. It implements the Miller-Rabin primality test for one specific value // of 'a' and k == 1. See also ProbablyPrimeUint32. func ProbablyPrimeBigInt_32(n *big.Int, a uint32) bool { var d big.Int d.Set(n) d.Sub(&d, _1) // d <- n-1 s := 0 for ; d.Bit(s) == 0; s++ { } nMinus1 := big.NewInt(0).Set(&d) d.Rsh(&d, uint(s)) x := ModPowBigInt(big.NewInt(int64(a)), &d, n) if x.Cmp(_1) == 0 || x.Cmp(nMinus1) == 0 { return true } for ; s > 1; s-- { if x = x.Mod(x.Mul(x, x), n); x.Cmp(_1) == 0 { return false } if x.Cmp(nMinus1) == 0 { return true } } return false } // ProbablyPrimeBigInt returns true if n is prime or n is a pseudoprime to base // a. It implements the Miller-Rabin primality test for one specific value of // 'a' and k == 1. See also ProbablyPrimeUint32. func ProbablyPrimeBigInt(n, a *big.Int) bool { var d big.Int d.Set(n) d.Sub(&d, _1) // d <- n-1 s := 0 for ; d.Bit(s) == 0; s++ { } nMinus1 := big.NewInt(0).Set(&d) d.Rsh(&d, uint(s)) x := ModPowBigInt(a, &d, n) if x.Cmp(_1) == 0 || x.Cmp(nMinus1) == 0 { return true } for ; s > 1; s-- { if x = x.Mod(x.Mul(x, x), n); x.Cmp(_1) == 0 { return false } if x.Cmp(nMinus1) == 0 { return true } } return false } // Max returns the larger of a and b. func Max(a, b int) int { if a > b { return a } return b } // Min returns the smaller of a and b. func Min(a, b int) int { if a < b { return a } return b } // MaxPtr returns a pointer to the larger of a and b, or nil. func MaxPtr(a, b *int) *int { if a == nil { return b } if b == nil { return a } if *a > *b { return a } return b } // MinPtr returns a pointer to the smaller of a and b, or nil. func MinPtr(a, b *int) *int { if a == nil { return b } if b == nil { return a } if *a < *b { return a } return b } // MaxVal returns the largest argument passed. func MaxVal(val int, vals ...int) int { res := val for _, v := range vals { if v > res { res = v } } return res } // MinVal returns the smallest argument passed. func MinVal(val int, vals ...int) int { res := val for _, v := range vals { if v < res { res = v } } return res } // Clamp returns a value restricted between lo and hi. func Clamp(v, lo, hi int) int { return Min(Max(v, lo), hi) } // UMax returns the larger of a and b. func UMax(a, b uint) uint { if a > b { return a } return b } // UMin returns the smaller of a and b. func UMin(a, b uint) uint { if a < b { return a } return b } // UMaxPtr returns a pointer to the larger of a and b, or nil. func UMaxPtr(a, b *uint) *uint { if a == nil { return b } if b == nil { return a } if *a > *b { return a } return b } // UMinPtr returns a pointer to the smaller of a and b, or nil. func UMinPtr(a, b *uint) *uint { if a == nil { return b } if b == nil { return a } if *a < *b { return a } return b } // UMaxVal returns the largest argument passed. func UMaxVal(val uint, vals ...uint) uint { res := val for _, v := range vals { if v > res { res = v } } return res } // UMinVal returns the smallest argument passed. func UMinVal(val uint, vals ...uint) uint { res := val for _, v := range vals { if v < res { res = v } } return res } // UClamp returns a value restricted between lo and hi. func UClamp(v, lo, hi uint) uint { return UMin(UMax(v, lo), hi) } // MaxByte returns the larger of a and b. func MaxByte(a, b byte) byte { if a > b { return a } return b } // MinByte returns the smaller of a and b. func MinByte(a, b byte) byte { if a < b { return a } return b } // MaxBytePtr returns a pointer to the larger of a and b, or nil. func MaxBytePtr(a, b *byte) *byte { if a == nil { return b } if b == nil { return a } if *a > *b { return a } return b } // MinBytePtr returns a pointer to the smaller of a and b, or nil. func MinBytePtr(a, b *byte) *byte { if a == nil { return b } if b == nil { return a } if *a < *b { return a } return b } // MaxByteVal returns the largest argument passed. func MaxByteVal(val byte, vals ...byte) byte { res := val for _, v := range vals { if v > res { res = v } } return res } // MinByteVal returns the smallest argument passed. func MinByteVal(val byte, vals ...byte) byte { res := val for _, v := range vals { if v < res { res = v } } return res } // ClampByte returns a value restricted between lo and hi. func ClampByte(v, lo, hi byte) byte { return MinByte(MaxByte(v, lo), hi) } // MaxInt8 returns the larger of a and b. func MaxInt8(a, b int8) int8 { if a > b { return a } return b } // MinInt8 returns the smaller of a and b. func MinInt8(a, b int8) int8 { if a < b { return a } return b } // MaxInt8Ptr returns a pointer to the larger of a and b, or nil. func MaxInt8Ptr(a, b *int8) *int8 { if a == nil { return b } if b == nil { return a } if *a > *b { return a } return b } // MinInt8Ptr returns a pointer to the smaller of a and b, or nil. func MinInt8Ptr(a, b *int8) *int8 { if a == nil { return b } if b == nil { return a } if *a < *b { return a } return b } // MaxInt8Val returns the largest argument passed. func MaxInt8Val(val int8, vals ...int8) int8 { res := val for _, v := range vals { if v > res { res = v } } return res } // MinInt8Val returns the smallest argument passed. func MinInt8Val(val int8, vals ...int8) int8 { res := val for _, v := range vals { if v < res { res = v } } return res } // ClampInt8 returns a value restricted between lo and hi. func ClampInt8(v, lo, hi int8) int8 { return MinInt8(MaxInt8(v, lo), hi) } // MaxUint16 returns the larger of a and b. func MaxUint16(a, b uint16) uint16 { if a > b { return a } return b } // MinUint16 returns the smaller of a and b. func MinUint16(a, b uint16) uint16 { if a < b { return a } return b } // MaxUint16Ptr returns a pointer to the larger of a and b, or nil. func MaxUint16Ptr(a, b *uint16) *uint16 { if a == nil { return b } if b == nil { return a } if *a > *b { return a } return b } // MinUint16Ptr returns a pointer to the smaller of a and b, or nil. func MinUint16Ptr(a, b *uint16) *uint16 { if a == nil { return b } if b == nil { return a } if *a < *b { return a } return b } // MaxUint16Val returns the largest argument passed. func MaxUint16Val(val uint16, vals ...uint16) uint16 { res := val for _, v := range vals { if v > res { res = v } } return res } // MinUint16Val returns the smallest argument passed. func MinUint16Val(val uint16, vals ...uint16) uint16 { res := val for _, v := range vals { if v < res { res = v } } return res } // ClampUint16 returns a value restricted between lo and hi. func ClampUint16(v, lo, hi uint16) uint16 { return MinUint16(MaxUint16(v, lo), hi) } // MaxInt16 returns the larger of a and b. func MaxInt16(a, b int16) int16 { if a > b { return a } return b } // MinInt16 returns the smaller of a and b. func MinInt16(a, b int16) int16 { if a < b { return a } return b } // MaxInt16Ptr returns a pointer to the larger of a and b, or nil. func MaxInt16Ptr(a, b *int16) *int16 { if a == nil { return b } if b == nil { return a } if *a > *b { return a } return b } // MinInt16Ptr returns a pointer to the smaller of a and b, or nil. func MinInt16Ptr(a, b *int16) *int16 { if a == nil { return b } if b == nil { return a } if *a < *b { return a } return b } // MaxInt16Val returns the largest argument passed. func MaxInt16Val(val int16, vals ...int16) int16 { res := val for _, v := range vals { if v > res { res = v } } return res } // MinInt16Val returns the smallest argument passed. func MinInt16Val(val int16, vals ...int16) int16 { res := val for _, v := range vals { if v < res { res = v } } return res } // ClampInt16 returns a value restricted between lo and hi. func ClampInt16(v, lo, hi int16) int16 { return MinInt16(MaxInt16(v, lo), hi) } // MaxUint32 returns the larger of a and b. func MaxUint32(a, b uint32) uint32 { if a > b { return a } return b } // MinUint32 returns the smaller of a and b. func MinUint32(a, b uint32) uint32 { if a < b { return a } return b } // MaxUint32Ptr returns a pointer to the larger of a and b, or nil. func MaxUint32Ptr(a, b *uint32) *uint32 { if a == nil { return b } if b == nil { return a } if *a > *b { return a } return b } // MinUint32Ptr returns a pointer to the smaller of a and b, or nil. func MinUint32Ptr(a, b *uint32) *uint32 { if a == nil { return b } if b == nil { return a } if *a < *b { return a } return b } // MaxUint32Val returns the largest argument passed. func MaxUint32Val(val uint32, vals ...uint32) uint32 { res := val for _, v := range vals { if v > res { res = v } } return res } // MinUint32Val returns the smallest argument passed. func MinUint32Val(val uint32, vals ...uint32) uint32 { res := val for _, v := range vals { if v < res { res = v } } return res } // ClampUint32 returns a value restricted between lo and hi. func ClampUint32(v, lo, hi uint32) uint32 { return MinUint32(MaxUint32(v, lo), hi) } // MaxInt32 returns the larger of a and b. func MaxInt32(a, b int32) int32 { if a > b { return a } return b } // MinInt32 returns the smaller of a and b. func MinInt32(a, b int32) int32 { if a < b { return a } return b } // MaxInt32Ptr returns a pointer to the larger of a and b, or nil. func MaxInt32Ptr(a, b *int32) *int32 { if a == nil { return b } if b == nil { return a } if *a > *b { return a } return b } // MinInt32Ptr returns a pointer to the smaller of a and b, or nil. func MinInt32Ptr(a, b *int32) *int32 { if a == nil { return b } if b == nil { return a } if *a < *b { return a } return b } // MaxInt32Val returns the largest argument passed. func MaxInt32Val(val int32, vals ...int32) int32 { res := val for _, v := range vals { if v > res { res = v } } return res } // MinInt32Val returns the smallest argument passed. func MinInt32Val(val int32, vals ...int32) int32 { res := val for _, v := range vals { if v < res { res = v } } return res } // ClampInt32 returns a value restricted between lo and hi. func ClampInt32(v, lo, hi int32) int32 { return MinInt32(MaxInt32(v, lo), hi) } // MaxUint64 returns the larger of a and b. func MaxUint64(a, b uint64) uint64 { if a > b { return a } return b } // MinUint64 returns the smaller of a and b. func MinUint64(a, b uint64) uint64 { if a < b { return a } return b } // MaxUint64Ptr returns a pointer to the larger of a and b, or nil. func MaxUint64Ptr(a, b *uint64) *uint64 { if a == nil { return b } if b == nil { return a } if *a > *b { return a } return b } // MinUint64Ptr returns a pointer to the smaller of a and b, or nil. func MinUint64Ptr(a, b *uint64) *uint64 { if a == nil { return b } if b == nil { return a } if *a < *b { return a } return b } // MaxUint64Val returns the largest argument passed. func MaxUint64Val(val uint64, vals ...uint64) uint64 { res := val for _, v := range vals { if v > res { res = v } } return res } // MinUint64Val returns the smallest argument passed. func MinUint64Val(val uint64, vals ...uint64) uint64 { res := val for _, v := range vals { if v < res { res = v } } return res } // ClampUint64 returns a value restricted between lo and hi. func ClampUint64(v, lo, hi uint64) uint64 { return MinUint64(MaxUint64(v, lo), hi) } // MaxInt64 returns the larger of a and b. func MaxInt64(a, b int64) int64 { if a > b { return a } return b } // MinInt64 returns the smaller of a and b. func MinInt64(a, b int64) int64 { if a < b { return a } return b } // MaxInt64Ptr returns a pointer to the larger of a and b, or nil. func MaxInt64Ptr(a, b *int64) *int64 { if a == nil { return b } if b == nil { return a } if *a > *b { return a } return b } // MinInt64Ptr returns a pointer to the smaller of a and b, or nil. func MinInt64Ptr(a, b *int64) *int64 { if a == nil { return b } if b == nil { return a } if *a < *b { return a } return b } // MaxInt64Val returns the largest argument passed. func MaxInt64Val(val int64, vals ...int64) int64 { res := val for _, v := range vals { if v > res { res = v } } return res } // MinInt64Val returns the smallest argument passed. func MinInt64Val(val int64, vals ...int64) int64 { res := val for _, v := range vals { if v < res { res = v } } return res } // ClampInt64 returns a value restricted between lo and hi. func ClampInt64(v, lo, hi int64) int64 { return MinInt64(MaxInt64(v, lo), hi) } // ToBase produces n in base b. For example // // ToBase(2047, 22) -> [1, 5, 4] // // 1 * 22^0 1 // 5 * 22^1 110 // 4 * 22^2 1936 // ---- // 2047 // // ToBase panics for bases < 2. func ToBase(n *big.Int, b int) []int { var nn big.Int nn.Set(n) if b < 2 { panic("invalid base") } k := 1 switch nn.Sign() { case -1: nn.Neg(&nn) k = -1 case 0: return []int{0} } bb := big.NewInt(int64(b)) var r []int rem := big.NewInt(0) for nn.Sign() != 0 { nn.QuoRem(&nn, bb, rem) r = append(r, k*int(rem.Int64())) } return r } // CheckAddInt64 returns the a+b and an indicator that the result is greater // than math.MaxInt64. func CheckAddInt64(a, b int64) (sum int64, gt bool) { return a + b, a > 0 && b > math.MaxInt64-a || a < 0 && b < math.MinInt64-a } // CheckSubInt64 returns a-b and an indicator that the result is less than than // math.MinInt64. func CheckSubInt64(a, b int64) (sum int64, lt bool) { return a - b, a > 0 && a-math.MaxInt64 > b || a < 0 && a-math.MinInt64 < b } // AddOverflowInt8 returns a + b and an indication whether the addition // overflowed the int8 range. func AddOverflowInt8(a, b int8) (r int8, ovf bool) { r = a + b if a > 0 && b > 0 { return r, uint8(r) > math.MaxInt8 } if a < 0 && b < 0 { return r, uint8(r) <= math.MaxInt8 } return r, false } // AddOverflowInt16 returns a + b and an indication whether the addition // overflowed the int16 range. func AddOverflowInt16(a, b int16) (r int16, ovf bool) { r = a + b if a > 0 && b > 0 { return r, uint16(r) > math.MaxInt16 } if a < 0 && b < 0 { return r, uint16(r) <= math.MaxInt16 } return r, false } // AddOverflowInt32 returns a + b and an indication whether the addition // overflowed the int32 range. func AddOverflowInt32(a, b int32) (r int32, ovf bool) { r = a + b if a > 0 && b > 0 { return r, uint32(r) > math.MaxInt32 } if a < 0 && b < 0 { return r, uint32(r) <= math.MaxInt32 } return r, false } // AddOverflowInt64 returns a + b and an indication whether the addition // overflowed the int64 range. func AddOverflowInt64(a, b int64) (r int64, ovf bool) { r = a + b if a > 0 && b > 0 { return r, uint64(r) > math.MaxInt64 } if a < 0 && b < 0 { return r, uint64(r) <= math.MaxInt64 } return r, false } // SubOverflowInt8 returns a - b and an indication whether the subtraction // overflowed the int8 range. func SubOverflowInt8(a, b int8) (r int8, ovf bool) { r = a - b if a >= 0 && b < 0 { return r, uint8(r) >= math.MaxInt8+1 } if a < 0 && b > 0 { return r, uint8(r) <= math.MaxInt8 } return r, false } // SubOverflowInt16 returns a - b and an indication whether the subtraction // overflowed the int16 range. func SubOverflowInt16(a, b int16) (r int16, ovf bool) { r = a - b if a >= 0 && b < 0 { return r, uint16(r) >= math.MaxInt16+1 } if a < 0 && b > 0 { return r, uint16(r) <= math.MaxInt16 } return r, false } // SubOverflowInt32 returns a - b and an indication whether the subtraction // overflowed the int32 range. func SubOverflowInt32(a, b int32) (r int32, ovf bool) { r = a - b if a >= 0 && b < 0 { return r, uint32(r) >= math.MaxInt32+1 } if a < 0 && b > 0 { return r, uint32(r) <= math.MaxInt32 } return r, false } // SubOverflowInt64 returns a - b and an indication whether the subtraction // overflowed the int64 range. func SubOverflowInt64(a, b int64) (r int64, ovf bool) { r = a - b if a >= 0 && b < 0 { return r, uint64(r) >= math.MaxInt64+1 } if a < 0 && b > 0 { return r, uint64(r) <= math.MaxInt64 } return r, false } // MulOverflowInt8 returns a * b and an indication whether the product // overflowed the int8 range. func MulOverflowInt8(a, b int8) (r int8, ovf bool) { if a == 0 || b == 0 { return 0, false } z := int16(a) * int16(b) return int8(z), z < math.MinInt8 || z > math.MaxInt8 } // MulOverflowInt16 returns a * b and an indication whether the product // overflowed the int16 range. func MulOverflowInt16(a, b int16) (r int16, ovf bool) { if a == 0 || b == 0 { return 0, false } z := int32(a) * int32(b) return int16(z), z < math.MinInt16 || z > math.MaxInt16 } // MulOverflowInt32 returns a * b and an indication whether the product // overflowed the int32 range. func MulOverflowInt32(a, b int32) (r int32, ovf bool) { if a == 0 || b == 0 { return 0, false } z := int64(a) * int64(b) return int32(z), z < math.MinInt32 || z > math.MaxInt32 } // MulOverflowInt64 returns a * b and an indication whether the product // overflowed the int64 range. func MulOverflowInt64(a, b int64) (r int64, ovf bool) { // https://groups.google.com/g/golang-nuts/c/h5oSN5t3Au4/m/KaNQREhZh0QJ const mostPositive = 1<<63 - 1 const mostNegative = -(mostPositive + 1) r = a * b if a == 0 || b == 0 || a == 1 || b == 1 { return r, false } if a == mostNegative || b == mostNegative { return r, true } return r, r/b != a }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/rnd.go
vendor/modernc.org/mathutil/rnd.go
// Copyright (c) 2014 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mathutil // import "modernc.org/mathutil" import ( "fmt" "math" "math/big" ) // FC32 is a full cycle PRNG covering the 32 bit signed integer range. // In contrast to full cycle generators shown at e.g. http://en.wikipedia.org/wiki/Full_cycle, // this code doesn't produce values at constant delta (mod cycle length). // The 32 bit limit is per this implementation, the algorithm used has no intrinsic limit on the cycle size. // Properties include: // - Adjustable limits on creation (hi, lo). // - Positionable/randomly accessible (Pos, Seek). // - Repeatable (deterministic). // - Can run forward or backward (Next, Prev). // - For a billion numbers cycle the Next/Prev PRN can be produced in cca 100-150ns. // That's like 5-10 times slower compared to PRNs generated using the (non FC) rand package. type FC32 struct { cycle int64 // On average: 3 * delta / 2, (HQ: 2 * delta) delta int64 // hi - lo factors [][]int64 // This trades some space for hopefully a bit of speed (multiple adding vs multiplying). lo int mods []int // pos % set pos int64 // Within cycle. primes []int64 // Ordered. ∏ primes == cycle. set []int64 // Reordered primes (magnitude order bases) according to seed. } // NewFC32 returns a newly created FC32 adjusted for the closed interval [lo, hi] or an Error if any. // If hq == true then trade some generation time for improved (pseudo)randomness. func NewFC32(lo, hi int, hq bool) (r *FC32, err error) { if lo > hi { return nil, fmt.Errorf("invalid range %d > %d", lo, hi) } if uint64(hi)-uint64(lo) > math.MaxUint32 { return nil, fmt.Errorf("range out of int32 limits %d, %d", lo, hi) } delta := int64(hi) - int64(lo) // Find the primorial covering whole delta n, set, p := int64(1), []int64{}, uint32(2) if hq { p++ } for { set = append(set, int64(p)) n *= int64(p) if n > delta { break } p, _ = NextPrime(p) } // Adjust the set so n ∊ [delta, 2 * delta] (HQ: [delta, 3 * delta]) // while keeping the cardinality of the set (correlates with the statistic "randomness quality") // at max, i.e. discard atmost one member. i := -1 // no candidate prime if n > 2*(delta+1) { for j, p := range set { q := n / p if q < delta+1 { break } i = j // mark the highest candidate prime set index } } if i >= 0 { // shrink the inner cycle n = n / set[i] set = delete(set, i) } r = &FC32{ cycle: n, delta: delta, factors: make([][]int64, len(set)), lo: lo, mods: make([]int, len(set)), primes: set, } r.Seed(1) // the default seed should be always non zero return } // Cycle reports the length of the inner FCPRNG cycle. // Cycle is atmost the double (HQ: triple) of the generator period (hi - lo + 1). func (r *FC32) Cycle() int64 { return r.cycle } // Next returns the first PRN after Pos. func (r *FC32) Next() int { return r.step(1) } // Pos reports the current position within the inner cycle. func (r *FC32) Pos() int64 { return r.pos } // Prev return the first PRN before Pos. func (r *FC32) Prev() int { return r.step(-1) } // Seed uses the provided seed value to initialize the generator to a deterministic state. // A zero seed produces a "canonical" generator with worse randomness than for most non zero seeds. // Still, the FC property holds for any seed value. func (r *FC32) Seed(seed int64) { u := uint64(seed) r.set = mix(r.primes, &u) n := int64(1) for i, p := range r.set { k := make([]int64, p) v := int64(0) for j := range k { k[j] = v v += n } n *= p r.factors[i] = mix(k, &u) } } // Seek sets Pos to |pos| % Cycle. func (r *FC32) Seek(pos int64) { //vet:ignore if pos < 0 { pos = -pos } pos %= r.cycle r.pos = pos for i, p := range r.set { r.mods[i] = int(pos % p) } } func (r *FC32) step(dir int) int { for { // avg loops per step: 3/2 (HQ: 2) y := int64(0) pos := r.pos pos += int64(dir) switch { case pos < 0: pos = r.cycle - 1 case pos >= r.cycle: pos = 0 } r.pos = pos for i, mod := range r.mods { mod += dir p := int(r.set[i]) switch { case mod < 0: mod = p - 1 case mod >= p: mod = 0 } r.mods[i] = mod y += r.factors[i][mod] } if y <= r.delta { return int(y) + r.lo } } } func delete(set []int64, i int) (y []int64) { for j, v := range set { if j != i { y = append(y, v) } } return } func mix(set []int64, seed *uint64) (y []int64) { for len(set) != 0 { *seed = rol(*seed) i := int(*seed % uint64(len(set))) y = append(y, set[i]) set = delete(set, i) } return } func rol(u uint64) (y uint64) { y = u << 1 if int64(u) < 0 { y |= 1 } return } // FCBig is a full cycle PRNG covering ranges outside of the int32 limits. // For more info see the FC32 docs. // Next/Prev PRN on a 1e15 cycle can be produced in about 2 µsec. type FCBig struct { cycle *big.Int // On average: 3 * delta / 2, (HQ: 2 * delta) delta *big.Int // hi - lo factors [][]*big.Int // This trades some space for hopefully a bit of speed (multiple adding vs multiplying). lo *big.Int mods []int // pos % set pos *big.Int // Within cycle. primes []int64 // Ordered. ∏ primes == cycle. set []int64 // Reordered primes (magnitude order bases) according to seed. } // NewFCBig returns a newly created FCBig adjusted for the closed interval [lo, hi] or an Error if any. // If hq == true then trade some generation time for improved (pseudo)randomness. func NewFCBig(lo, hi *big.Int, hq bool) (r *FCBig, err error) { if lo.Cmp(hi) > 0 { return nil, fmt.Errorf("invalid range %d > %d", lo, hi) } delta := big.NewInt(0) delta.Add(delta, hi).Sub(delta, lo) // Find the primorial covering whole delta n, set, pp, p := big.NewInt(1), []int64{}, big.NewInt(0), uint32(2) if hq { p++ } for { set = append(set, int64(p)) pp.SetInt64(int64(p)) n.Mul(n, pp) if n.Cmp(delta) > 0 { break } p, _ = NextPrime(p) } // Adjust the set so n ∊ [delta, 2 * delta] (HQ: [delta, 3 * delta]) // while keeping the cardinality of the set (correlates with the statistic "randomness quality") // at max, i.e. discard atmost one member. dd1 := big.NewInt(1) dd1.Add(dd1, delta) dd2 := big.NewInt(0) dd2.Lsh(dd1, 1) i := -1 // no candidate prime if n.Cmp(dd2) > 0 { q := big.NewInt(0) for j, p := range set { pp.SetInt64(p) q.Set(n) q.Div(q, pp) if q.Cmp(dd1) < 0 { break } i = j // mark the highest candidate prime set index } } if i >= 0 { // shrink the inner cycle pp.SetInt64(set[i]) n.Div(n, pp) set = delete(set, i) } r = &FCBig{ cycle: n, delta: delta, factors: make([][]*big.Int, len(set)), lo: lo, mods: make([]int, len(set)), pos: big.NewInt(0), primes: set, } r.Seed(1) // the default seed should be always non zero return } // Cycle reports the length of the inner FCPRNG cycle. // Cycle is atmost the double (HQ: triple) of the generator period (hi - lo + 1). func (r *FCBig) Cycle() *big.Int { return r.cycle } // Next returns the first PRN after Pos. func (r *FCBig) Next() *big.Int { return r.step(1) } // Pos reports the current position within the inner cycle. func (r *FCBig) Pos() *big.Int { return r.pos } // Prev return the first PRN before Pos. func (r *FCBig) Prev() *big.Int { return r.step(-1) } // Seed uses the provided seed value to initialize the generator to a deterministic state. // A zero seed produces a "canonical" generator with worse randomness than for most non zero seeds. // Still, the FC property holds for any seed value. func (r *FCBig) Seed(seed int64) { u := uint64(seed) r.set = mix(r.primes, &u) n := big.NewInt(1) v := big.NewInt(0) pp := big.NewInt(0) for i, p := range r.set { k := make([]*big.Int, p) v.SetInt64(0) for j := range k { k[j] = big.NewInt(0) k[j].Set(v) v.Add(v, n) } pp.SetInt64(p) n.Mul(n, pp) r.factors[i] = mixBig(k, &u) } } // Seek sets Pos to |pos| % Cycle. func (r *FCBig) Seek(pos *big.Int) { r.pos.Set(pos) r.pos.Abs(r.pos) r.pos.Mod(r.pos, r.cycle) mod := big.NewInt(0) pp := big.NewInt(0) for i, p := range r.set { pp.SetInt64(p) r.mods[i] = int(mod.Mod(r.pos, pp).Int64()) } } func (r *FCBig) step(dir int) (y *big.Int) { y = big.NewInt(0) d := big.NewInt(int64(dir)) for { // avg loops per step: 3/2 (HQ: 2) r.pos.Add(r.pos, d) switch { case r.pos.Sign() < 0: r.pos.Add(r.pos, r.cycle) case r.pos.Cmp(r.cycle) >= 0: r.pos.SetInt64(0) } for i, mod := range r.mods { mod += dir p := int(r.set[i]) switch { case mod < 0: mod = p - 1 case mod >= p: mod = 0 } r.mods[i] = mod y.Add(y, r.factors[i][mod]) } if y.Cmp(r.delta) <= 0 { y.Add(y, r.lo) return } y.SetInt64(0) } } func deleteBig(set []*big.Int, i int) (y []*big.Int) { for j, v := range set { if j != i { y = append(y, v) } } return } func mixBig(set []*big.Int, seed *uint64) (y []*big.Int) { for len(set) != 0 { *seed = rol(*seed) i := int(*seed % uint64(len(set))) y = append(y, set[i]) set = deleteBig(set, i) } return }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/tables.go
vendor/modernc.org/mathutil/tables.go
// Copyright (c) 2014 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // "Static" data package mathutil // import "modernc.org/mathutil" var ( // Set bits count in a byte popcnt = [256]byte{ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, // 0 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 1 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 2 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 3 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 4 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 5 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 6 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 7 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 8 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 9 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 10 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 11 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 12 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 13 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 14 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, // 15 } // Highest set bit index in a byte log2 = [256]int{ -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, // 0 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // 1 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 2 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 3 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 4 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 5 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 6 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 7 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 8 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 9 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 10 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 11 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 12 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 13 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 14 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 15 } // "Predivisors": 2-53 liars = [3660]uint32{ 31621, 42799, 49141, 49981, 65077, 65281, 80581, 83333, 88357, 90751, 104653, 130561, 164737, 188057, 194221, 196093, 215749, 219781, 220729, 253241, 256999, 271951, 280601, 282133, 357761, 390937, 458989, 486737, 489997, 514447, 580337, 587861, 611701, 647089, 653333, 657901, 665281, 665333, 688213, 710533, 721801, 722261, 738541, 741751, 742813, 745889, 769757, 818201, 838861, 873181, 877099, 916327, 976873, 983401, 1016801, 1018921, 1053761, 1064053, 1073021, 1082401, 1109461, 1132657, 1145257, 1168513, 1194649, 1207361, 1251949, 1252697, 1302451, 1325843, 1357441, 1373653, 1397419, 1441091, 1493857, 1507963, 1509709, 1530787, 1584133, 1678541, 1690501, 1730977, 1735841, 1811573, 1876393, 1969417, 1987021, 2004403, 2081713, 2163001, 2181961, 2205967, 2261953, 2264369, 2269093, 2284453, 2304167, 2387797, 2487941, 2510569, 2670361, 2746477, 2748023, 2757241, 2811271, 2909197, 2944261, 2976487, 3048841, 3090091, 3116107, 3125281, 3225601, 3363121, 3375041, 3400013, 3413533, 3429037, 3539101, 3542533, 3567481, 3568661, 3605429, 3656449, 3763801, 3828001, 3898129, 3911197, 3985921, 4072729, 4181921, 4188889, 4209661, 4360621, 4469471, 4480477, 4513841, 4835209, 4863127, 4869313, 4877641, 4922413, 5016191, 5044033, 5095177, 5173169, 5173601, 5176153, 5256091, 5271841, 5284333, 5351537, 5489641, 5590621, 5672041, 5919187, 6027193, 6118141, 6140161, 6159301, 6189121, 6226193, 6233977, 6236257, 6278533, 6334351, 6368689, 6386993, 6631549, 6658669, 6779137, 6787327, 6836233, 6952037, 6955541, 6998881, 7017193, 7232321, 7306261, 7306561, 7429117, 7462001, 7674967, 7725901, 7759937, 7820201, 7883731, 8036033, 8095447, 8239477, 8384513, 8534233, 8725753, 8727391, 8902741, 9006401, 9056501, 9073513, 9131401, 9345541, 9371251, 9439201, 9480461, 9533701, 9564169, 9567673, 9588151, 9591661, 9729301, 9774181, 9863461, 10024561, 10084177, 10323769, 10331141, 10386241, 10425511, 10610063, 10700761, 10712857, 10763653, 10974881, 11081459, 11115037, 11335501, 11541307, 11585293, 11592397, 11777599, 12032021, 12096613, 12263131, 12322133, 12327121, 12599233, 12854437, 13057787, 13338371, 13446253, 13500313, 13635289, 13694761, 13747361, 13773061, 14026897, 14154337, 14179537, 14324473, 14469841, 14671801, 14676481, 14709241, 14794081, 14796289, 14865121, 15101893, 15139199, 15162941, 15188557, 15220951, 15247621, 15479777, 15525241, 15603391, 15621409, 15700301, 15802681, 15976747, 15978007, 16070429, 16132321, 16149169, 16153633, 16324001, 16349477, 16360381, 16705021, 16773121, 16822081, 16843009, 16853077, 16879501, 16973393, 17098369, 17116837, 17134043, 17208601, 17236801, 17327773, 17375249, 17405537, 17585969, 17870561, 18067501, 18073817, 18366937, 18443701, 18454921, 18535177, 18653353, 18740971, 19328653, 19384289, 19404139, 19471033, 19607561, 20261251, 20417311, 20647621, 20968501, 21042001, 21303343, 21306157, 21359521, 21397381, 21400481, 21623659, 21654533, 22075579, 22087477, 22369621, 22591301, 22669501, 22711873, 22849481, 22953673, 23247901, 23382529, 23464033, 23577497, 23634181, 23734901, 23828017, 23872213, 23963869, 24214051, 24356377, 25080101, 25150501, 25276421, 25326001, 25457833, 25629913, 25696133, 25768261, 25909453, 26280073, 26377921, 26821601, 26840269, 26877421, 26886817, 27108397, 27118601, 27219697, 27271151, 27279409, 27331921, 27380831, 27392041, 27409541, 27491237, 27509653, 27664033, 27798461, 27808463, 28325881, 28527049, 28572961, 29111881, 29214541, 29581501, 30022129, 30090817, 30185569, 30219757, 30295141, 30338593, 30388753, 30418957, 30576151, 30662497, 30740417, 30881551, 30894307, 31040833, 31166803, 31436123, 31735621, 31759121, 32091781, 32095057, 32168117, 32285041, 32497921, 32676481, 33146717, 33298337, 33600533, 33627301, 33704101, 33872593, 34003061, 34043101, 34124641, 34540801, 34856167, 34944001, 35576599, 35703361, 35820937, 35851037, 36291193, 36307981, 36861901, 36919681, 36974341, 37109467, 37376509, 37439201, 37964809, 37988497, 38010307, 38046817, 38118763, 38210323, 39465091, 39512773, 39655153, 39684157, 40165093, 40238797, 40315441, 40361197, 40629601, 40782589, 40827473, 40987201, 41121433, 41568101, 41604109, 41642681, 41662297, 41840809, 42009217, 42485119, 42623017, 42984589, 43224397, 43363601, 43661257, 44070841, 44314129, 44465221, 44482901, 45100177, 45175201, 45219329, 45414433, 45819541, 45879941, 46094401, 46325029, 46386589, 46469809, 46517857, 46679761, 46860001, 47220367, 47903701, 47918581, 48064021, 48191653, 48269761, 48316969, 48400753, 48448661, 48551161, 48563089, 49075417, 49303801, 49411801, 49459801, 50155733, 50201089, 50443201, 50523661, 51030601, 51129781, 51302353, 51500521, 52072021, 52119289, 52204237, 53283169, 53399449, 53656021, 53675623, 53695721, 53711113, 54029741, 54449431, 55109401, 55176097, 55318957, 55729957, 56052361, 56420033, 56479897, 56810137, 57762433, 58003213, 58422409, 58449847, 58509977, 58679941, 58755877, 59631211, 59840537, 59913157, 59953741, 60155201, 60352921, 60547831, 60566431, 60581401, 60696661, 60738257, 60957361, 61201009, 61219789, 61377109, 61832377, 62756641, 63001801, 63002501, 63065281, 63167743, 63318169, 63328469, 63346999, 63388033, 64148717, 64605041, 64735897, 65144501, 65254393, 65301013, 65350801, 65359477, 66096253, 67194401, 67642513, 67928221, 68102641, 68154001, 68165761, 68512867, 68621701, 68839597, 69030901, 69128641, 69176647, 69228967, 69231061, 69485281, 69612061, 69885649, 70149631, 70463489, 70593931, 70728121, 71079661, 71734417, 72498253, 72543547, 73562833, 73645001, 74411131, 74927161, 75140137, 75565873, 76725091, 76745101, 77533123, 77648941, 77812153, 77817979, 78939089, 79398901, 79411201, 79417801, 79464533, 79786523, 80142761, 80146909, 80375707, 80556337, 80687881, 80891009, 81433591, 81954133, 82273201, 82506439, 82870517, 82929001, 83083001, 83103329, 83204801, 84164033, 84350561, 84421081, 84487457, 84998503, 85328717, 85519337, 85823401, 86027329, 86438857, 86530621, 86999837, 87499651, 87694261, 88256449, 88368853, 88661861, 89308771, 89784581, 90270613, 90278161, 90341197, 90665789, 90698401, 91433281, 91659283, 92438581, 92625121, 93431521, 93541537, 93571633, 93643201, 93677761, 93926197, 94316401, 94502701, 95451361, 95452781, 96135601, 96618397, 96791881, 96888641, 96895441, 96904081, 96925921, 97255801, 97496449, 97796953, 97863529, 97924217, 99036001, 99115297, 99486889, 99789673, 99898801, 100463443, 100618933, 100943201, 101152133, 101218921, 101270251, 101276579, 101649241, 102004421, 102678031, 102690677, 102690901, 103301633, 104078857, 104524421, 104988673, 105305443, 105919633, 106485121, 106622353, 106743073, 107360641, 107543333, 108596953, 109231229, 109437751, 109541461, 109879837, 110135821, 110139499, 110312773, 110413333, 110717861, 111370141, 111654401, 112032001, 112402981, 112828801, 113589601, 113605201, 113730481, 113892589, 114305441, 114329881, 114701341, 114842677, 114910489, 115039081, 115174681, 115497901, 115804501, 115873801, 116090081, 116321617, 116617289, 116682721, 116696161, 116998669, 117987841, 118466401, 118901521, 119092801, 119204809, 119261113, 119327041, 119558011, 119743537, 119940853, 120296677, 120517021, 120838609, 121062001, 121374241, 121472359, 121609489, 122166307, 122396737, 122941981, 123481777, 123671671, 123877081, 123987793, 124145473, 124630273, 124818601, 125284141, 125686241, 125848577, 126132553, 127050067, 128079409, 128124151, 128396921, 128468957, 128665319, 128987429, 129205781, 129256273, 129357061, 129461617, 129524669, 130556329, 130693393, 130944133, 131023201, 131567929, 131938561, 132332201, 132338881, 132440521, 132575071, 133216381, 133302781, 133467517, 133800661, 134696801, 134767153, 134868029, 135263269, 135296053, 135308881, 135945853, 135969401, 136043641, 136661201, 136722433, 137415821, 137763037, 138030721, 138403981, 138828821, 139295701, 139487041, 140197051, 142525333, 142922413, 143106133, 143168581, 145348529, 146156617, 146272901, 146659801, 146843929, 146884393, 147028001, 147287141, 148109473, 148171769, 148910653, 149389633, 150379693, 150960239, 150988753, 151533377, 151589881, 152716537, 152922001, 152991841, 153369061, 153589801, 153754873, 153928133, 154287451, 154513633, 154944533, 155203361, 156114061, 156532799, 157069189, 157368661, 157405249, 157725829, 158068153, 158192317, 158397247, 158496911, 158544401, 158895281, 160348189, 160378861, 160491329, 160587841, 160672201, 160730389, 161184013, 161216021, 161289649, 161304001, 161423377, 162026869, 162067441, 162690481, 162771337, 162776041, 163442551, 163954561, 164111281, 165061909, 165224321, 165938653, 166082309, 166339057, 166406561, 166827943, 167579497, 167582377, 167692141, 167881121, 168566501, 169655641, 170640961, 170782921, 170856533, 171454321, 172116181, 172436713, 172947529, 173401621, 174479729, 176030977, 176597821, 176609441, 176977921, 177167233, 177254533, 177693521, 177927641, 177951973, 178837201, 178956971, 179083601, 179285137, 179820257, 180115489, 180497633, 180703451, 181285001, 181285537, 181542601, 181647497, 182383111, 183677341, 184411567, 185653333, 186183469, 186393481, 186983521, 187050529, 187667969, 187761241, 188516329, 188985961, 189714193, 189738361, 189941761, 190212181, 190382161, 190913297, 191233813, 191648161, 191981609, 192346153, 192857761, 193330237, 193638337, 193949641, 194556451, 196035001, 196049701, 196231393, 198982759, 199674721, 200143351, 200753281, 201261061, 202130197, 202156813, 202538857, 203505697, 204280501, 204582457, 204766381, 205057561, 206304961, 206453509, 206504033, 206529737, 207008569, 207030541, 207132481, 207477001, 207618781, 208051201, 208969223, 209246701, 209404369, 209990881, 210592873, 210842113, 213035761, 214038533, 214110541, 214852609, 214858717, 215436241, 216821881, 217123069, 217875571, 218603617, 218642029, 218947121, 219621781, 220531501, 220883521, 221368153, 221415781, 221884001, 222010721, 222630193, 223449463, 223625851, 223782263, 224074369, 224136013, 224769241, 224957893, 225853633, 226359547, 226450297, 227132641, 227444101, 227475481, 228652201, 228842209, 228988033, 229589413, 230357761, 231383461, 231405701, 231927781, 232114433, 232460821, 232771501, 233110081, 234869009, 235426913, 235928071, 237791143, 238001653, 238833421, 240068041, 240371713, 240694513, 240785047, 241505377, 242067841, 242650717, 242860069, 243583201, 243955141, 244883981, 245006623, 245950561, 246099317, 246282511, 246434761, 246658441, 247318957, 247321301, 247416101, 249582481, 250436033, 250958401, 250988173, 251528401, 251663837, 251855893, 252853921, 253610281, 253893397, 255416897, 256831433, 257590661, 258020473, 258043229, 258234401, 258944401, 259763093, 259765747, 260156101, 260518801, 260736341, 260963389, 261186001, 261703417, 262979501, 263428181, 264269449, 264384469, 265020001, 265584133, 265735969, 265836161, 266790481, 266925601, 270525737, 271272569, 271763467, 271826629, 271950829, 273361789, 273480637, 274701913, 274810241, 274919401, 275283401, 275619961, 276018913, 276131137, 276542401, 276638321, 277787141, 278943061, 279377281, 280885153, 282253141, 282471853, 282769771, 283900961, 284166877, 284301751, 284736091, 284834299, 285820501, 286316801, 287160301, 287449091, 287715121, 288099001, 288117721, 288735277, 290643601, 290706781, 290953921, 291088513, 291461633, 292153681, 292290181, 292433321, 292902481, 293346637, 293847721, 293938261, 295419097, 295743017, 297624961, 297798961, 298212601, 299367877, 299736181, 301413001, 302635351, 304080001, 307629401, 307694323, 307972801, 308483209, 309666361, 310474249, 310978027, 311177213, 311411629, 311655829, 311671361, 312408113, 312614021, 314184487, 315034513, 315351521, 317137969, 317365933, 317641171, 317796119, 319053281, 319374577, 319440769, 319726177, 320326003, 321324589, 321850849, 322469701, 322941881, 324477697, 325028089, 325352101, 325546873, 326266051, 326405713, 326469137, 326628721, 326694301, 326695141, 327073601, 327093409, 327398009, 328302901, 329153653, 329769721, 330198331, 330759617, 331658081, 331934989, 337135501, 337420679, 337665901, 337783981, 338125537, 338458807, 338914369, 339195097, 339492169, 339794641, 341958121, 341994131, 343017529, 343052833, 344201441, 344255551, 344776301, 346080391, 348989101, 349752913, 350031973, 350244577, 351058753, 351177769, 352802803, 352932337, 353815801, 353932801, 354062809, 356604421, 356836819, 357348601, 357872971, 358416577, 359394751, 359727073, 360145633, 360375181, 360787771, 361307521, 361312337, 362569201, 363170837, 363430637, 364550761, 365077373, 365231401, 366487201, 366532321, 366652201, 367559501, 367632301, 368016949, 368476501, 369667561, 371011801, 371611153, 372167101, 373012777, 373533617, 373669453, 373906513, 374346361, 374988661, 376957153, 377192353, 377334497, 377458849, 377806687, 377869031, 378792649, 379732501, 380137633, 382304161, 384100001, 385175113, 385319089, 387072661, 388695301, 390609941, 390612221, 391014937, 392679737, 393611653, 394723177, 396864469, 399156661, 399302581, 399647221, 400385701, 400557109, 401100881, 403095967, 403293313, 405739681, 405782623, 407737201, 407889161, 409302001, 409458241, 410613809, 410680357, 411618241, 411851389, 412836689, 413138881, 413429801, 413778817, 414216461, 414368641, 415200361, 415204501, 415476343, 416964241, 417767201, 417779909, 418044563, 418226581, 418616161, 418617281, 418667401, 419184481, 420607441, 421942951, 422429041, 422928101, 423384001, 423465001, 424175761, 424411501, 424431541, 425967301, 426174101, 426219649, 426770437, 426783811, 427294141, 428180191, 428758201, 429135841, 429509837, 430046857, 430381921, 430646401, 430733701, 432227449, 434042801, 435016187, 435358657, 435993301, 436465501, 437247841, 437462101, 437597101, 437866087, 439309261, 441354497, 441650591, 441758461, 442050577, 442181291, 442543553, 444660421, 445429693, 446414621, 446619617, 449501761, 450807481, 450866021, 450872573, 452990401, 453366029, 453967739, 454745773, 455198563, 457274161, 457320533, 459785089, 460251733, 460585861, 461151121, 461272267, 461329601, 462587329, 462639409, 462701513, 464012033, 464955857, 465505633, 466290949, 466758181, 467100937, 468410113, 468950021, 470120257, 470268137, 470644021, 471535373, 471664513, 472814413, 473581057, 474892741, 474970501, 474983881, 475723849, 478614067, 479962009, 480668347, 481153501, 481239361, 482488393, 482824669, 482921297, 483006889, 483029821, 483945601, 484200289, 486063001, 486902929, 487896601, 488104681, 488169289, 488585521, 488656981, 489994201, 490950461, 491738801, 493108481, 494288677, 495909871, 496109729, 496560349, 497148599, 497285713, 498662561, 498706651, 498905189, 500747293, 501172241, 501472333, 502686713, 504870241, 505473263, 505532773, 505798213, 506349421, 507142567, 507323521, 508606771, 509302873, 509551201, 510925609, 511098521, 511215521, 511611673, 512330281, 514738981, 516045197, 516259657, 516764063, 517662001, 518216201, 518548801, 521501473, 522390109, 522758233, 523756711, 526067821, 526359289, 526686889, 528013333, 528043753, 528220117, 530630701, 531095029, 531681281, 532126801, 532758241, 532800133, 533429881, 534782293, 535252867, 535428577, 535517581, 536003333, 536114197, 536342419, 536870911, 540207097, 540621181, 540654409, 540680141, 542497201, 542536457, 544861633, 545550433, 545622401, 546102481, 546117301, 546322201, 548080513, 548989561, 549308761, 550132741, 550230409, 550635373, 550853137, 551313001, 552573793, 553027201, 554487121, 554599051, 554964001, 555321007, 555465601, 556001377, 556069849, 556095433, 556114609, 557165209, 558235109, 558900821, 558977761, 561448487, 562367821, 563298061, 563947141, 564298489, 564689381, 565664761, 565707061, 567358513, 567596401, 568902001, 568967221, 569332177, 569495809, 570941881, 572123521, 572228929, 572430769, 572567353, 572936869, 573817861, 573862021, 574998841, 575326033, 576724219, 577210181, 577352641, 577613261, 579606301, 579956653, 581618143, 582389641, 582799951, 585261637, 586706821, 587343541, 588049001, 591242653, 591822001, 592467451, 592468777, 593682169, 593728489, 595405201, 595590841, 597537361, 597717121, 599135767, 599945293, 600893921, 601606487, 602379181, 604584221, 605454917, 605961049, 606872449, 607148653, 607750681, 608421637, 608917753, 609361567, 609813781, 611097401, 611374453, 611770513, 611812321, 611817421, 612006253, 613849601, 614742241, 615361183, 615760133, 615895897, 616280897, 617087701, 619239457, 619365121, 619480601, 620169409, 620544961, 620755537, 621769669, 622137601, 623735953, 624303241, 624732421, 625060801, 625482001, 626717471, 627886657, 628868467, 629134081, 630496621, 630622753, 630811513, 631767943, 631974613, 633289807, 635155291, 635291077, 635319361, 636287653, 636337073, 636936697, 638502913, 638837761, 639305921, 639807781, 640650931, 640977373, 643036321, 643316461, 643552909, 644004817, 644453633, 644457551, 644731357, 644900257, 645556481, 648056449, 648328801, 651011329, 651064681, 651151801, 651514753, 652469641, 653235841, 653260633, 655264369, 657732349, 659526601, 659846021, 660095641, 660754117, 661122881, 661207177, 662134201, 663760681, 665462081, 668498321, 670976641, 670987021, 671716921, 672103001, 672108193, 673778827, 675260477, 676359391, 678481693, 680983817, 681019921, 681124207, 681303241, 682528687, 683316001, 683362681, 684350833, 686059921, 687741401, 689537441, 690035713, 690562601, 691131349, 692535637, 693456521, 694116893, 696042901, 696321949, 696998251, 697821857, 698192041, 698819711, 702683101, 705303457, 705351583, 706728377, 707691601, 709409993, 710382401, 710617861, 710721001, 714490481, 717096641, 717653129, 717831211, 720767521, 722955773, 724160251, 724969087, 725508241, 731276521, 732805681, 734166217, 736668013, 739444021, 739576801, 740988151, 741182401, 741214237, 742017181, 742550401, 744500641, 745493761, 745745461, 746331041, 747406801, 748638001, 749172821, 749640161, 750632137, 751226401, 751705597, 752186593, 753233717, 753574537, 753594001, 754020361, 754874257, 756205633, 756271909, 756980137, 758581651, 758687581, 758901701, 759252367, 759266621, 759638881, 762699649, 763907741, 764033999, 764240611, 765378241, 766303693, 766823797, 770201221, 770909107, 770937931, 771043201, 771337891, 772495777, 773131927, 773807401, 775368901, 775896181, 776443769, 777218989, 781471001, 782823281, 784450393, 784777393, 784783477, 784966297, 787085857, 787209277, 788046901, 788931361, 789082001, 790453049, 791118043, 792144161, 792145729, 794201333, 794399041, 794937601, 795064909, 796072003, 796200901, 796560703, 797418997, 797834017, 799162561, 799630753, 799898833, 799916101, 801093011, 801227269, 801866647, 804978721, 805505957, 805771501, 807115753, 807218413, 808214161, 809790881, 810023881, 810455101, 811110301, 811478533, 811607777, 811730923, 815430533, 815796413, 816024161, 816215401, 816549121, 817832329, 818401321, 819466201, 819743233, 822018961, 822531841, 824389441, 826004467, 829512001, 830664451, 831933901, 832048447, 832127489, 832169857, 833610751, 837766217, 839268139, 839280691, 839908217, 840749761, 841217653, 841660961, 842785841, 842824981, 842960981, 843161887, 844545271, 845376533, 846961321, 848090377, 848755969, 849548671, 852432769, 854094781, 854868257, 855734401, 857100421, 857902861, 858687103, 859096477, 860334301, 862082677, 862678081, 863196181, 863609113, 863984881, 865242841, 867022747, 867110501, 867638201, 868088341, 868111597, 868691401, 870985223, 871157233, 871195561, 871908481, 876850801, 877542481, 878492941, 878940833, 879995689, 880870513, 880922657, 883276549, 884304037, 884952001, 886180429, 887795221, 888868441, 892740853, 893692819, 894264337, 896901461, 897087361, 897283213, 899019353, 900736411, 901848301, 902566501, 903108821, 903390643, 905040953, 907378669, 907670501, 907711561, 908005249, 910202509, 910867481, 911484421, 914348737, 914906539, 920375821, 920696653, 921858631, 922845241, 923437213, 926756881, 927106561, 927877001, 929159941, 930530701, 932148253, 933729421, 935794081, 936421141, 937675393, 938376181, 939947009, 940123801, 941056273, 941734657, 943271569, 944832533, 946034057, 946787377, 947878081, 949317217, 949697233, 952893881, 954924013, 957600541, 957631249, 958131157, 958735681, 960269377, 960946321, 962442001, 962489557, 962523169, 964412837, 965501857, 967266451, 967287751, 967790401, 968283247, 968413217, 968751241, 969528337, 970586713, 971975071, 974113601, 974471243, 974774401, 975576281, 976396961, 977483449, 979363153, 980056507, 980725201, 981484561, 983456377, 984133441, 984252001, 985052881, 985075681, 987842101, 994133479, 995586373, 995650921, 997836841, 998489017, 998590601, 998596741, 998724481, 999828727, 1002261781, 1003062061, 1005402133, 1005833971, 1006800829, 1008777001, 1008839999, 1009025263, 1009140161, 1011319501, 1011333061, 1011570457, 1011909271, 1012438391, 1013833153, 1015339441, 1015626151, 1017748057, 1020515761, 1021281301, 1022336611, 1024041853, 1024123501, 1024605121, 1025035129, 1026738161, 1027744453, 1028494429, 1034252929, 1034958601, 1040234231, 1049584313, 1050102901, 1050535501, 1054999441, 1055009117, 1056121453, 1057426651, 1063212481, 1065508321, 1065602281, 1066972301, 1069388497, 1070639389, 1070941987, 1071512749, 1071643249, 1072898711, 1073159281, 1073288581, 1073484823, 1075100041, 1077133397, 1078467589, 1081798061, 1082472553, 1084241341, 1084444481, 1090858081, 1093150081, 1093352833, 1093526353, 1094042321, 1097416321, 1098743563, 1100624857, 1101623381, 1101673501, 1102573501, 1102750013, 1104194521, 1105038871, 1106529761, 1106580817, 1106595493, 1107138961, 1108135381, 1109304913, 1110582947, 1111205873, 1111939201, 1112671603, 1114277221, 1116379301, 1117202557, 1117785881, 1117828001, 1117890019, 1119412321, 1120076281, 1120981021, 1121176981, 1123406047, 1123625501, 1123727617, 1124396521, 1125038377, 1127040769, 1130933429, 1134367777, 1138289041, 1138607233, 1139137057, 1140573601, 1142466151, 1147434289, 1148578201, 1150229761, 1151670001, 1153164097, 1153440289, 1154343961, 1154691409, 1154987209, 1155939709, 1156761911, 1156993373, 1157839381, 1159421509, 1160844821, 1163098249, 1163227759, 1164218641, 1165717129, 1166475601, 1166598217, 1168221121, 1168256953, 1168492417, 1173229201, 1173545533, 1174300093, 1180970407, 1181566219, 1183338241, 1184554801, 1186325981, 1187235193, 1191153937, 1191216133, 1192314817, 1192412033, 1192903531, 1193229577, 1193557093, 1195524181, 1196852273, 1198650961, 1198880261, 1200456577, 1200778753, 1202142061, 1204205449, 1205606533, 1205772499, 1209998077, 1210393801, 1210562701, 1210653541, 1213619761, 1217181061, 1217823517, 1217924159, 1219816261, 1219858921, 1220114377, 1221127013, 1222861271, 1223531677, 1223941657, 1225128829, 1226230297, 1226855293, 1227220801, 1229491063, 1229751667, 1230446653, 1231362793, 1232445677, 1234125721, 1234646533, 1235188597, 1235864033, 1236313501, 1236442421, 1238825569, 1242171349, 1242858317, 1249166881, 1249785941, 1250656621, 1252236421, 1254277909, 1255665613, 1257102001, 1258903981, 1260332137, 1263293281, 1264145401, 1265477791, 1266003461, 1266273793, 1266425101, 1267345081, 1269295201, 1269835201, 1270193401, 1270489621, 1270667353, 1272558739, 1272866167, 1282447477, 1282568741, 1285636801, 1286298133, 1286298263, 1296613501, 1297443913, 1299072721, 1299784141, 1299963601, 1301509249, 1301926081, 1302745481, 1306836001, 1307004641, 1307520469, 1307823661, 1308758533, 1308998741, 1309723213, 1309983901, 1310329567, 1311255661, 1311616153, 1312332001, 1312573123, 1313396221, 1315858381, 1316169541, 1318126321, 1318717531, 1319978701, 1319992181, 1320793813, 1321058213, 1323668917, 1325172421, 1325329297, 1328256247, 1329174601, 1329431689, 1331973329, 1341010577, 1341926401, 1343575381, 1344597577, 1344975721, 1345514101, 1345523401, 1347387361, 1348964401, 1350685001, 1351126261, 1352453257, 1353051517, 1356241321, 1356328121, 1357459183, 1362463807, 1362515701, 1362742561, 1365662917, 1366587661, 1366608377, 1368769681, 1371908137, 1372681861, 1375322101, 1376799577, 1378646179, 1379464633, 1382453333, 1383283129, 1385656829, 1386705433, 1388972353, 1389353941, 1389975149, 1391890033, 1393851553, 1394640941, 1394746081, 1394942473, 1397357851, 1398883201, 1400859847, 1401840833, 1404008369, 1404253369, 1406826241, 1406851249, 1409372779, 1413803197, 1414154827, 1414529533, 1415969101, 1417986901, 1421475031, 1424503849, 1425860101, 1426319563, 1426534201, 1427771089, 1428966001, 1432354901, 1435091377, 1438648993, 1440231941, 1440922891, 1441139641, 1441678411, 1442945689, 1443388481, 1443742273, 1446298309, 1446434677, 1446818651, 1448921633, 1451635201, 1454282449, 1454445413, 1456527461, 1457378449, 1461307717, 1463065501, 1463178817, 1463992661, 1464568381, 1465908193, 1465945417, 1468540477, 1468824787, 1469059481, 1469960377, 1470080501, 1470650851, 1471628401, 1472221921, 1473580001, 1477289941, 1481626513, 1482274513, 1482876673, 1483873861, 1483918801, 1485061471, 1486564301, 1493114149, 1495190699, 1497221281, 1497965713, 1499971457, 1499989177, 1500142001, 1501165097, 1502171117, 1502403121, 1503240559, 1503705601, 1504139521, 1504832033, 1507746241, 1509156013, 1510870241, 1511558533, 1515175087, 1515785041, 1517039371, 1518014689, 1518290707, 1520190341, 1521221473, 1522302121, 1526732803, 1529648231, 1529819971, 1530495289, 1532419099, 1532569681, 1532755369, 1533343261, 1534063081, 1535020133, 1536112001, 1536251047, 1536883357, 1537433899, 1537641691, 1538012449, 1539583921, 1539804001, 1540454761, 1540550413, 1541047813, 1541849761, 1541955409, 1544145121, 1545019813, 1545177581, 1546106773, 1546340401, 1546508057, 1547140841, 1547543161, 1547712601, 1550924873, 1554270481, 1557118081, 1560312001, 1560620041, 1561800833, 1565893201, 1566594551, 1567830241, 1568916311, 1574362441, 1574601601, 1577983489, 1578009401, 1580449201, 1581576641, 1581714481, 1582783777, 1583230241, 1583658649, 1586436193, 1587650401, 1590394313, 1593706201, 1595647351, 1595887921, 1598197201, 1602517949, 1603765021, 1603810561, 1603994701, 1609916491, 1609935913, 1612121473, 1614508267, 1617795181, 1617921667, 1619447741, 1620646177, 1627103521, 1627898401, 1628692201, 1630062253, 1630307617, 1631314609, 1632286673, 1632513601, 1633044241, 1636185601, 1637434657, 1637436457, 1637930893, 1638294661, 1639351981, 1639846391, 1641971701, 1642814653, 1644637051, 1645413001, 1647225529, 1648076041, 1649430889, 1650265549, 1650682153, 1654940509, 1655660761, 1656229921, 1656280033, 1656917377, 1659009601, 1661202113, 1668037621, 1668926629, 1669893661, 1671603667, 1671714241, 1672125131, 1674091141, 1674658133, 1675978193, 1678274581, 1679130641, 1680901381, 1683174533, 1685433413, 1686001861, 1687248001, 1691745821, 1692605041, 1694128129, 1695158921, 1696893101, 1698707377, 1699279441, 1700250049, 1709909293, 1710753001, 1712392321, 1714322377, 1716160321, 1716714793, 1716774481, 1718013133, 1718088301, 1719197621, 1721061497, 1721986313, 1722007169, 1722685777, 1725675451, 1726372441, 1731048937, 1731995497, 1732924001, 1734059291, 1734285601, 1735071913, 1736481601, 1738687469, 1740214841, 1742288881, 1742815621, 1743166441, 1744605097, 1746692641, 1746721681, 1749124829, 1750412161, 1754818561, 1757148121, 1760014561, 1766984389, 1767234613, 1769091241, 1769267761, 1770236893, 1771303801, 1772267281, 1773582977, 1776439261, 1776820033, 1779649381, 1779892577, 1784306273, 1784638309, 1785843547, 1786005521, 1787934881, 1790023861, 1791426787, 1792442737, 1792588813, 1794814103, 1801558201, 1801774081, 1802510669, 1803768091, 1804906517, 1805947313, 1809888967, 1816408273, 1817067169, 1819829749, 1820306953, 1821514633, 1828682101, 1828887061, 1831258601, 1835114401, 1837156049, 1837599769, 1839568981, 1841034961, 1841099261, 1841479501, 1844028961, 1846171781, 1847811673, 1849964117, 1850233897, 1850598961, 1852496761, 1853926777, 1854084649, 1854940231, 1856689453, 1857221281, 1858098497, 1858197961, 1860373241, 1861026133, 1861880689, 1862880401, 1866409861, 1867906721, 1868682241, 1871987041, 1872937057, 1873177693, 1874634721, 1874849929, 1878691753, 1879111697, 1879623157, 1879775501, 1883509633, 1883785681, 1885915841, 1894909141, 1894955311, 1897700113, 1899081757, 1899525601, 1900687381, 1903447841, 1904658913, 1905958891, 1908088001, 1909566073, 1910134309, 1911197947, 1912950241, 1914303841, 1915391521, 1916987593, 1917397637, 1920301951, 1921309633, 1922092567, 1922687293, 1923224689, 1923311317, 1923845801, 1924201501, 1925042737, 1928903971, 1929862849, 1930403333, 1930447501, 1930534453, 1930915169, 1934350351, 1938264241, 1940048881, 1943951041, 1944125633, 1945042181, 1950987193, 1952513369, 1952968753, 1957705177, 1959659857, 1960708261, 1963149553, 1965007601, 1968002149, 1970065681, 1974474049, 1977257441, 1982123893, 1982826961, 1988071801, 1988713189, 1988835713, 1988965861, 1989192277, 1991063449, 1995784961, 1995830761, 1996231189, 1996339649, 1997844157, 1998780001, 1999053601, 1999111801, 1999743661, 2004299641, 2007646961, 2013554869, 2013834961, 2016481477, 2017021333, 2017509601, 2019564769, 2021392369, 2021884343, 2027675701, 2028279793, 2028631361, 2028812399, 2029830409, 2030600833, 2036224321, 2043173273, 2049293401, 2050617713, 2052149221, 2054711381, 2055634561, 2057267941, 2057835781, 2058072041, 2059739221, 2062612033, 2068867841, 2070739441, 2072624761, 2076192007, 2081039297, 2081551753, 2082146617, 2083034113, 2083997441, 2085453649, 2085882661, 2086645009, 2093300401, 2095627153, 2096046457, 2097317377, 2100292841, 2101470541, 2101744837, 2104994449, 2106147457, 2107148761, 2114643217, 2115769633, 2115986557, 2116483027, 2116541221, 2117031263, 2117555641, 2118621097, 2120096161, 2123601751, 2124078653, 2124691213, 2127197489, 2128104001, 2129304997, 2130134533, 2131004737, 2131811501, 2140699681, 2140771609, 2141340833, 2144961253, 2147418113, 2147429509, 2152627801, 2154446641, 2155416251, 2156151313, 2164282177, 2168431201, 2170282969, 2172155819, 2173499329, 2173540951, 2173579801, 2175126601, 2175406201, 2175646177,
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/poly.go
vendor/modernc.org/mathutil/poly.go
// Copyright (c) 2016 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mathutil // import "modernc.org/mathutil" import ( "fmt" "math/big" ) func abs(n int) uint64 { if n >= 0 { return uint64(n) } return uint64(-n) } // QuadPolyDiscriminant returns the discriminant of a quadratic polynomial in // one variable of the form a*x^2+b*x+c with integer coefficients a, b, c, or // an error on overflow. // // ds is the square of the discriminant. If |ds| is a square number, d is set // to sqrt(|ds|), otherwise d is < 0. func QuadPolyDiscriminant(a, b, c int) (ds, d int, _ error) { if 2*BitLenUint64(abs(b)) > IntBits-1 || 2+BitLenUint64(abs(a))+BitLenUint64(abs(c)) > IntBits-1 { return 0, 0, fmt.Errorf("overflow") } ds = b*b - 4*a*c s := ds if s < 0 { s = -s } d64 := SqrtUint64(uint64(s)) if d64*d64 != uint64(s) { return ds, -1, nil } return ds, int(d64), nil } // PolyFactor describes an irreducible factor of a polynomial in one variable // with integer coefficients P, Q of the form P*x+Q. type PolyFactor struct { P, Q int } // QuadPolyFactors returns the content and the irreducible factors of the // primitive part of a quadratic polynomial in one variable with integer // coefficients a, b, c of the form a*x^2+b*x+c in integers, or an error on // overflow. // // If the factorization in integers does not exists, the return value is (0, // nil, nil). // // See also: // https://en.wikipedia.org/wiki/Factorization_of_polynomials#Primitive_part.E2.80.93content_factorization func QuadPolyFactors(a, b, c int) (content int, primitivePart []PolyFactor, _ error) { content = int(GCDUint64(abs(a), GCDUint64(abs(b), abs(c)))) switch { case content == 0: content = 1 case content > 0: if a < 0 || a == 0 && b < 0 { content = -content } } a /= content b /= content c /= content if a == 0 { if b == 0 { return content, []PolyFactor{{0, c}}, nil } if b < 0 && c < 0 { b = -b c = -c } if b < 0 { b = -b c = -c } return content, []PolyFactor{{b, c}}, nil } ds, d, err := QuadPolyDiscriminant(a, b, c) if err != nil { return 0, nil, err } if ds < 0 || d < 0 { return 0, nil, nil } x1num := -b + d x1denom := 2 * a gcd := int(GCDUint64(abs(x1num), abs(x1denom))) x1num /= gcd x1denom /= gcd x2num := -b - d x2denom := 2 * a gcd = int(GCDUint64(abs(x2num), abs(x2denom))) x2num /= gcd x2denom /= gcd return content, []PolyFactor{{x1denom, -x1num}, {x2denom, -x2num}}, nil } // QuadPolyDiscriminantBig returns the discriminant of a quadratic polynomial // in one variable of the form a*x^2+b*x+c with integer coefficients a, b, c. // // ds is the square of the discriminant. If |ds| is a square number, d is set // to sqrt(|ds|), otherwise d is nil. func QuadPolyDiscriminantBig(a, b, c *big.Int) (ds, d *big.Int) { ds = big.NewInt(0).Set(b) ds.Mul(ds, b) x := big.NewInt(4) x.Mul(x, a) x.Mul(x, c) ds.Sub(ds, x) s := big.NewInt(0).Set(ds) if s.Sign() < 0 { s.Neg(s) } if s.Bit(1) != 0 { // s is not a square number return ds, nil } d = SqrtBig(s) x.Set(d) x.Mul(x, x) if x.Cmp(s) != 0 { // s is not a square number d = nil } return ds, d } // PolyFactorBig describes an irreducible factor of a polynomial in one // variable with integer coefficients P, Q of the form P*x+Q. type PolyFactorBig struct { P, Q *big.Int } // QuadPolyFactorsBig returns the content and the irreducible factors of the // primitive part of a quadratic polynomial in one variable with integer // coefficients a, b, c of the form a*x^2+b*x+c in integers. // // If the factorization in integers does not exists, the return value is (nil, // nil). // // See also: // https://en.wikipedia.org/wiki/Factorization_of_polynomials#Primitive_part.E2.80.93content_factorization func QuadPolyFactorsBig(a, b, c *big.Int) (content *big.Int, primitivePart []PolyFactorBig) { content = bigGCD(bigAbs(a), bigGCD(bigAbs(b), bigAbs(c))) switch { case content.Sign() == 0: content.SetInt64(1) case content.Sign() > 0: if a.Sign() < 0 || a.Sign() == 0 && b.Sign() < 0 { content = bigNeg(content) } } a = bigDiv(a, content) b = bigDiv(b, content) c = bigDiv(c, content) if a.Sign() == 0 { if b.Sign() == 0 { return content, []PolyFactorBig{{big.NewInt(0), c}} } if b.Sign() < 0 && c.Sign() < 0 { b = bigNeg(b) c = bigNeg(c) } if b.Sign() < 0 { b = bigNeg(b) c = bigNeg(c) } return content, []PolyFactorBig{{b, c}} } ds, d := QuadPolyDiscriminantBig(a, b, c) if ds.Sign() < 0 || d == nil { return nil, nil } x1num := bigAdd(bigNeg(b), d) x1denom := bigMul(_2, a) gcd := bigGCD(bigAbs(x1num), bigAbs(x1denom)) x1num = bigDiv(x1num, gcd) x1denom = bigDiv(x1denom, gcd) x2num := bigAdd(bigNeg(b), bigNeg(d)) x2denom := bigMul(_2, a) gcd = bigGCD(bigAbs(x2num), bigAbs(x2denom)) x2num = bigDiv(x2num, gcd) x2denom = bigDiv(x2denom, gcd) return content, []PolyFactorBig{{x1denom, bigNeg(x1num)}, {x2denom, bigNeg(x2num)}} } func bigAbs(n *big.Int) *big.Int { n = big.NewInt(0).Set(n) if n.Sign() >= 0 { return n } return n.Neg(n) } func bigDiv(a, b *big.Int) *big.Int { a = big.NewInt(0).Set(a) return a.Div(a, b) } func bigGCD(a, b *big.Int) *big.Int { a = big.NewInt(0).Set(a) b = big.NewInt(0).Set(b) for b.Sign() != 0 { c := big.NewInt(0) c.Mod(a, b) a, b = b, c } return a } func bigNeg(n *big.Int) *big.Int { n = big.NewInt(0).Set(n) return n.Neg(n) } func bigMul(a, b *big.Int) *big.Int { r := big.NewInt(0).Set(a) return r.Mul(r, b) } func bigAdd(a, b *big.Int) *big.Int { r := big.NewInt(0).Set(a) return r.Add(r, b) }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/int.go
vendor/modernc.org/mathutil/int.go
// Copyright (c) 2018 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mathutil // import "modernc.org/mathutil" import ( "fmt" "math" "math/big" ) var ( // MaxInt128 represents the maximun Int128 value as big.Int MaxInt128 *big.Int // MinInt128 represents the minimun Int128 value as big.Int MinInt128 *big.Int // MaxUint128 represents the maximun Uint128 value as big.Int MaxUint128 *big.Int ) func init() { var ok bool MaxInt128, ok = big.NewInt(0).SetString("0x7fffffff_ffffffff_ffffffff_ffffffff", 0) if !ok { panic("internal error") } MinInt128 = big.NewInt(0).Set(MaxInt128) MinInt128.Add(MinInt128, _1) MinInt128.Neg(MinInt128) MaxUint128, ok = big.NewInt(0).SetString("0xffffffff_ffffffff_ffffffff_ffffffff", 0) if !ok { panic("internal error") } } const ( maxInt128 = 1<<127 - 1 maxUint128 = 1<<128 - 1 minInt128 = -maxInt128 - 1 ) // Int128 is an 128 bit signed integer. type Int128 struct { Lo int64 // Bits 63..0. Hi int64 // Bits 127..64. } // Add returns the sum of x and y and a carry indication. func (x Int128) Add(y Int128) (r Int128, cy bool) { r.Lo = x.Lo + y.Lo r.Hi = x.Hi + y.Hi if uint64(r.Lo) < uint64(x.Lo) { r.Hi++ } return r, (r.Cmp(x) < 0) == (y.Sign() >= 0) } // BigInt returns x in the form of a big.Int. func (x Int128) BigInt() *big.Int { r := big.NewInt(x.Hi) r.Lsh(r, 64) lo := big.NewInt(0) lo.SetUint64(uint64(x.Lo)) return r.Add(r, lo) } // Cmp compares x and y and returns: // // -1 if x < y // 0 if x == y // +1 if x > y func (x Int128) Cmp(y Int128) int { if x.Hi > y.Hi { return 1 } if x.Hi < y.Hi { return -1 } if uint64(x.Lo) > uint64(y.Lo) { return 1 } if uint64(x.Lo) < uint64(y.Lo) { return -1 } return 0 } // Neg returns -x and an indication that x was not equal to MinInt128. func (x Int128) Neg() (r Int128, ok bool) { if x == (Int128{Hi: math.MinInt64}) { return x, false } x.Lo = ^x.Lo x.Hi = ^x.Hi r, _ = x.Add(Int128{Lo: 1}) return r, true } // SetBigInt sets x to y, returns x and an error, if any. func (x *Int128) SetBigInt(y *big.Int) (r Int128, err error) { if y.Cmp(MaxInt128) > 0 { return *x, fmt.Errorf("%T.SetInt: overflow", x) } if y.Cmp(MinInt128) < 0 { return *x, fmt.Errorf("%T.SetInt: underflow", x) } neg := y.Sign() < 0 var z big.Int z.Set(y) if neg { z.Neg(&z) } r.Lo = z.Int64() z.Rsh(&z, 64) r.Hi = z.Int64() if neg { r, _ = r.Neg() } *x = r return r, nil } // SetInt64 sets x to y and returns x. func (x *Int128) SetInt64(y int64) (r Int128) { r.Lo = y if y >= 0 { r.Hi = 0 *x = r return r } r.Hi = -1 *x = r return r } // SetUint64 sets x to y and returns x. func (x *Int128) SetUint64(y uint64) (r Int128) { r = Int128{Lo: int64(y)} *x = r return r } // Sign returns: // // -1 if x < 0 // 0 if x == 0 // +1 if x > 0 func (x Int128) Sign() int { if x.Hi < 0 { return -1 } if x.Hi != 0 || x.Lo != 0 { return 1 } return 0 } // String implements fmt.Stringer() func (x Int128) String() string { return x.BigInt().String() } // NewInt128FromInt64 return a new Int128 value initialized to n. func NewInt128FromInt64(n int64) (r Int128) { r.Lo = n if n < 0 { r.Hi = -1 } return r } // NewInt128FromUint64 return a new Int128 value initialized to n. func NewInt128FromUint64(n uint64) (r Int128) { return Int128{Lo: int64(n)} } // NewInt128FromFloat32 returns a new Int128 value initialized to n. Result is // not specified in n does not represent a number within the range of Int128 // values. func NewInt128FromFloat32(n float32) (r Int128) { if n >= minInt128 && n <= maxInt128 { if n >= math.MinInt64 && n <= math.MaxInt64 { return NewInt128FromInt64(int64(n)) } f := big.NewFloat(float64(n)) bi, _ := f.Int(nil) r.SetBigInt(bi) } return r } // NewInt128FromFloat64 returns a new Int128 value initialized to n. Result is // not specified in n does not represent a number within the range of Int128 // values. func NewInt128FromFloat64(n float64) (r Int128) { if n >= minInt128 && n <= maxInt128 { if n >= math.MinInt64 && n <= math.MaxInt64 { return NewInt128FromInt64(int64(n)) } f := big.NewFloat(n) bi, _ := f.Int(nil) r.SetBigInt(bi) } return r } // Uint128 is an 128 bit unsigned integer. type Uint128 struct { Lo uint64 // Bits 63..0. Hi uint64 // Bits 127..64. } // NewUint128FromInt64 return a new Uint128 value initialized to n. func NewUint128FromInt64(n int64) (r Uint128) { r.Lo = uint64(n) if n < 0 { r.Hi = ^uint64(0) } return r } // NewUint128FromUint64 return a new Uint128 value initialized to n. func NewUint128FromUint64(n uint64) (r Uint128) { return Uint128{Lo: n} } // NewUint128FromFloat32 returns a new Uint128 value initialized to n. Result is // not specified in n does not represent a number within the range of Uint128 // values. func NewUint128FromFloat32(n float32) (r Uint128) { if n >= 0 { if n <= math.MaxUint64 { return NewUint128FromUint64(uint64(n)) } f := big.NewFloat(float64(n)) bi, _ := f.Int(nil) r.SetBigInt(bi) } return r } // NewUint128FromFloat64 returns a new Uint128 value initialized to n. Result is // not specified in n does not represent a number within the range of Uint128 // values. func NewUint128FromFloat64(n float64) (r Uint128) { if n >= 0 && n <= maxUint128 { if n <= math.MaxUint64 { return NewUint128FromUint64(uint64(n)) } f := big.NewFloat(n) bi, _ := f.Int(nil) r.SetBigInt(bi) } return r } // SetBigInt sets x to y, returns x and an error, if any. func (x *Uint128) SetBigInt(y *big.Int) (r Uint128, err error) { if y.Sign() < 0 || y.Cmp(MaxUint128) > 0 { return *x, fmt.Errorf("%T.SetInt: overflow", x) } var z big.Int z.Set(y) r.Lo = z.Uint64() z.Rsh(&z, 64) r.Hi = z.Uint64() *x = r return r, nil }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/primes.go
vendor/modernc.org/mathutil/primes.go
// Copyright (c) 2014 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mathutil // import "modernc.org/mathutil" import ( "math" ) // IsPrimeUint16 returns true if n is prime. Typical run time is few ns. func IsPrimeUint16(n uint16) bool { return n > 0 && primes16[n-1] == 1 } // NextPrimeUint16 returns first prime > n and true if successful or an // undefined value and false if there is no next prime in the uint16 limits. // Typical run time is few ns. func NextPrimeUint16(n uint16) (p uint16, ok bool) { return n + uint16(primes16[n]), n < 65521 } // IsPrime returns true if n is prime. Typical run time is about 100 ns. func IsPrime(n uint32) bool { switch { case n&1 == 0: return n == 2 case n%3 == 0: return n == 3 case n%5 == 0: return n == 5 case n%7 == 0: return n == 7 case n%11 == 0: return n == 11 case n%13 == 0: return n == 13 case n%17 == 0: return n == 17 case n%19 == 0: return n == 19 case n%23 == 0: return n == 23 case n%29 == 0: return n == 29 case n%31 == 0: return n == 31 case n%37 == 0: return n == 37 case n%41 == 0: return n == 41 case n%43 == 0: return n == 43 case n%47 == 0: return n == 47 case n%53 == 0: return n == 53 // Benchmarked optimum case n < 65536: // use table data return IsPrimeUint16(uint16(n)) default: mod := ModPowUint32(2, (n+1)/2, n) if mod != 2 && mod != n-2 { return false } blk := &lohi[n>>24] lo, hi := blk.lo, blk.hi for lo <= hi { index := (lo + hi) >> 1 liar := liars[index] switch { case n > liar: lo = index + 1 case n < liar: hi = index - 1 default: return false } } return true } } // IsPrimeUint64 returns true if n is prime. Typical run time is few tens of µs. // // SPRP bases: http://miller-rabin.appspot.com func IsPrimeUint64(n uint64) bool { switch { case n%2 == 0: return n == 2 case n%3 == 0: return n == 3 case n%5 == 0: return n == 5 case n%7 == 0: return n == 7 case n%11 == 0: return n == 11 case n%13 == 0: return n == 13 case n%17 == 0: return n == 17 case n%19 == 0: return n == 19 case n%23 == 0: return n == 23 case n%29 == 0: return n == 29 case n%31 == 0: return n == 31 case n%37 == 0: return n == 37 case n%41 == 0: return n == 41 case n%43 == 0: return n == 43 case n%47 == 0: return n == 47 case n%53 == 0: return n == 53 case n%59 == 0: return n == 59 case n%61 == 0: return n == 61 case n%67 == 0: return n == 67 case n%71 == 0: return n == 71 case n%73 == 0: return n == 73 case n%79 == 0: return n == 79 case n%83 == 0: return n == 83 case n%89 == 0: return n == 89 // Benchmarked optimum case n <= math.MaxUint16: return IsPrimeUint16(uint16(n)) case n <= math.MaxUint32: return ProbablyPrimeUint32(uint32(n), 11000544) && ProbablyPrimeUint32(uint32(n), 31481107) case n < 105936894253: return ProbablyPrimeUint64_32(n, 2) && ProbablyPrimeUint64_32(n, 1005905886) && ProbablyPrimeUint64_32(n, 1340600841) case n < 31858317218647: return ProbablyPrimeUint64_32(n, 2) && ProbablyPrimeUint64_32(n, 642735) && ProbablyPrimeUint64_32(n, 553174392) && ProbablyPrimeUint64_32(n, 3046413974) case n < 3071837692357849: return ProbablyPrimeUint64_32(n, 2) && ProbablyPrimeUint64_32(n, 75088) && ProbablyPrimeUint64_32(n, 642735) && ProbablyPrimeUint64_32(n, 203659041) && ProbablyPrimeUint64_32(n, 3613982119) default: return ProbablyPrimeUint64_32(n, 2) && ProbablyPrimeUint64_32(n, 325) && ProbablyPrimeUint64_32(n, 9375) && ProbablyPrimeUint64_32(n, 28178) && ProbablyPrimeUint64_32(n, 450775) && ProbablyPrimeUint64_32(n, 9780504) && ProbablyPrimeUint64_32(n, 1795265022) } } // NextPrime returns first prime > n and true if successful or an undefined value and false if there // is no next prime in the uint32 limits. Typical run time is about 2 µs. func NextPrime(n uint32) (p uint32, ok bool) { switch { case n < 65521: p16, _ := NextPrimeUint16(uint16(n)) return uint32(p16), true case n >= math.MaxUint32-4: return } n++ var d0, d uint32 switch mod := n % 6; mod { case 0: d0, d = 1, 4 case 1: d = 4 case 2, 3, 4: d0, d = 5-mod, 2 case 5: d = 2 } p = n + d0 if p < n { // overflow return } for { if IsPrime(p) { return p, true } p0 := p p += d if p < p0 { // overflow break } d ^= 6 } return } // NextPrimeUint64 returns first prime > n and true if successful or an undefined value and false if there // is no next prime in the uint64 limits. Typical run time is in hundreds of µs. func NextPrimeUint64(n uint64) (p uint64, ok bool) { switch { case n < 65521: p16, _ := NextPrimeUint16(uint16(n)) return uint64(p16), true case n >= 18446744073709551557: // last uint64 prime return } n++ var d0, d uint64 switch mod := n % 6; mod { case 0: d0, d = 1, 4 case 1: d = 4 case 2, 3, 4: d0, d = 5-mod, 2 case 5: d = 2 } p = n + d0 if p < n { // overflow return } for { if ok = IsPrimeUint64(p); ok { break } p0 := p p += d if p < p0 { // overflow break } d ^= 6 } return } // FactorTerm is one term of an integer factorization. type FactorTerm struct { Prime uint32 // The divisor Power uint32 // Term == Prime^Power } // FactorTerms represent a factorization of an integer type FactorTerms []FactorTerm // FactorInt returns prime factorization of n > 1 or nil otherwise. // Resulting factors are ordered by Prime. Typical run time is few µs. func FactorInt(n uint32) (f FactorTerms) { switch { case n < 2: return case IsPrime(n): return []FactorTerm{{n, 1}} } f, w := make([]FactorTerm, 9), 0 for p := 2; p < len(primes16); p += int(primes16[p]) { if uint(p*p) > uint(n) { break } power := uint32(0) for n%uint32(p) == 0 { n /= uint32(p) power++ } if power != 0 { f[w] = FactorTerm{uint32(p), power} w++ } if n == 1 { break } } if n != 1 { f[w] = FactorTerm{n, 1} w++ } return f[:w] } // PrimorialProductsUint32 returns a slice of numbers in [lo, hi] which are a // product of max 'max' primorials. The slice is not sorted. // // See also: http://en.wikipedia.org/wiki/Primorial func PrimorialProductsUint32(lo, hi, max uint32) (r []uint32) { lo64, hi64 := int64(lo), int64(hi) if max > 31 { // N/A max = 31 } var f func(int64, int64, uint32) f = func(n, p int64, emax uint32) { e := uint32(1) for n <= hi64 && e <= emax { n *= p if n >= lo64 && n <= hi64 { r = append(r, uint32(n)) } if n < hi64 { p, _ := NextPrime(uint32(p)) f(n, int64(p), e) } e++ } } f(1, 2, max) return }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/modernc.org/mathutil/test_deps.go
vendor/modernc.org/mathutil/test_deps.go
// Copyright (c) 2014 The mathutil Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mathutil // import "modernc.org/mathutil" // Pull test dependencies too. // Enables easy 'go test X' after 'go get X' import ( // nothing yet )
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/yaml.go
vendor/gopkg.in/yaml.v2/yaml.go
// Package yaml implements YAML support for the Go language. // // Source code and other details for the project are available at GitHub: // // https://github.com/go-yaml/yaml // package yaml import ( "errors" "fmt" "io" "reflect" "strings" "sync" ) // MapSlice encodes and decodes as a YAML map. // The order of keys is preserved when encoding and decoding. type MapSlice []MapItem // MapItem is an item in a MapSlice. type MapItem struct { Key, Value interface{} } // The Unmarshaler interface may be implemented by types to customize their // behavior when being unmarshaled from a YAML document. The UnmarshalYAML // method receives a function that may be called to unmarshal the original // YAML value into a field or variable. It is safe to call the unmarshal // function parameter more than once if necessary. type Unmarshaler interface { UnmarshalYAML(unmarshal func(interface{}) error) error } // The Marshaler interface may be implemented by types to customize their // behavior when being marshaled into a YAML document. The returned value // is marshaled in place of the original value implementing Marshaler. // // If an error is returned by MarshalYAML, the marshaling procedure stops // and returns with the provided error. type Marshaler interface { MarshalYAML() (interface{}, error) } // Unmarshal decodes the first document found within the in byte slice // and assigns decoded values into the out value. // // Maps and pointers (to a struct, string, int, etc) are accepted as out // values. If an internal pointer within a struct is not initialized, // the yaml package will initialize it if necessary for unmarshalling // the provided data. The out parameter must not be nil. // // The type of the decoded values should be compatible with the respective // values in out. If one or more values cannot be decoded due to a type // mismatches, decoding continues partially until the end of the YAML // content, and a *yaml.TypeError is returned with details for all // missed values. // // Struct fields are only unmarshalled if they are exported (have an // upper case first letter), and are unmarshalled using the field name // lowercased as the default key. Custom keys may be defined via the // "yaml" name in the field tag: the content preceding the first comma // is used as the key, and the following comma-separated options are // used to tweak the marshalling process (see Marshal). // Conflicting names result in a runtime error. // // For example: // // type T struct { // F int `yaml:"a,omitempty"` // B int // } // var t T // yaml.Unmarshal([]byte("a: 1\nb: 2"), &t) // // See the documentation of Marshal for the format of tags and a list of // supported tag options. // func Unmarshal(in []byte, out interface{}) (err error) { return unmarshal(in, out, false) } // UnmarshalStrict is like Unmarshal except that any fields that are found // in the data that do not have corresponding struct members, or mapping // keys that are duplicates, will result in // an error. func UnmarshalStrict(in []byte, out interface{}) (err error) { return unmarshal(in, out, true) } // A Decoder reads and decodes YAML values from an input stream. type Decoder struct { strict bool parser *parser } // NewDecoder returns a new decoder that reads from r. // // The decoder introduces its own buffering and may read // data from r beyond the YAML values requested. func NewDecoder(r io.Reader) *Decoder { return &Decoder{ parser: newParserFromReader(r), } } // SetStrict sets whether strict decoding behaviour is enabled when // decoding items in the data (see UnmarshalStrict). By default, decoding is not strict. func (dec *Decoder) SetStrict(strict bool) { dec.strict = strict } // Decode reads the next YAML-encoded value from its input // and stores it in the value pointed to by v. // // See the documentation for Unmarshal for details about the // conversion of YAML into a Go value. func (dec *Decoder) Decode(v interface{}) (err error) { d := newDecoder(dec.strict) defer handleErr(&err) node := dec.parser.parse() if node == nil { return io.EOF } out := reflect.ValueOf(v) if out.Kind() == reflect.Ptr && !out.IsNil() { out = out.Elem() } d.unmarshal(node, out) if len(d.terrors) > 0 { return &TypeError{d.terrors} } return nil } func unmarshal(in []byte, out interface{}, strict bool) (err error) { defer handleErr(&err) d := newDecoder(strict) p := newParser(in) defer p.destroy() node := p.parse() if node != nil { v := reflect.ValueOf(out) if v.Kind() == reflect.Ptr && !v.IsNil() { v = v.Elem() } d.unmarshal(node, v) } if len(d.terrors) > 0 { return &TypeError{d.terrors} } return nil } // Marshal serializes the value provided into a YAML document. The structure // of the generated document will reflect the structure of the value itself. // Maps and pointers (to struct, string, int, etc) are accepted as the in value. // // Struct fields are only marshalled if they are exported (have an upper case // first letter), and are marshalled using the field name lowercased as the // default key. Custom keys may be defined via the "yaml" name in the field // tag: the content preceding the first comma is used as the key, and the // following comma-separated options are used to tweak the marshalling process. // Conflicting names result in a runtime error. // // The field tag format accepted is: // // `(...) yaml:"[<key>][,<flag1>[,<flag2>]]" (...)` // // The following flags are currently supported: // // omitempty Only include the field if it's not set to the zero // value for the type or to empty slices or maps. // Zero valued structs will be omitted if all their public // fields are zero, unless they implement an IsZero // method (see the IsZeroer interface type), in which // case the field will be excluded if IsZero returns true. // // flow Marshal using a flow style (useful for structs, // sequences and maps). // // inline Inline the field, which must be a struct or a map, // causing all of its fields or keys to be processed as if // they were part of the outer struct. For maps, keys must // not conflict with the yaml keys of other struct fields. // // In addition, if the key is "-", the field is ignored. // // For example: // // type T struct { // F int `yaml:"a,omitempty"` // B int // } // yaml.Marshal(&T{B: 2}) // Returns "b: 2\n" // yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n" // func Marshal(in interface{}) (out []byte, err error) { defer handleErr(&err) e := newEncoder() defer e.destroy() e.marshalDoc("", reflect.ValueOf(in)) e.finish() out = e.out return } // An Encoder writes YAML values to an output stream. type Encoder struct { encoder *encoder } // NewEncoder returns a new encoder that writes to w. // The Encoder should be closed after use to flush all data // to w. func NewEncoder(w io.Writer) *Encoder { return &Encoder{ encoder: newEncoderWithWriter(w), } } // Encode writes the YAML encoding of v to the stream. // If multiple items are encoded to the stream, the // second and subsequent document will be preceded // with a "---" document separator, but the first will not. // // See the documentation for Marshal for details about the conversion of Go // values to YAML. func (e *Encoder) Encode(v interface{}) (err error) { defer handleErr(&err) e.encoder.marshalDoc("", reflect.ValueOf(v)) return nil } // Close closes the encoder by writing any remaining data. // It does not write a stream terminating string "...". func (e *Encoder) Close() (err error) { defer handleErr(&err) e.encoder.finish() return nil } func handleErr(err *error) { if v := recover(); v != nil { if e, ok := v.(yamlError); ok { *err = e.err } else { panic(v) } } } type yamlError struct { err error } func fail(err error) { panic(yamlError{err}) } func failf(format string, args ...interface{}) { panic(yamlError{fmt.Errorf("yaml: "+format, args...)}) } // A TypeError is returned by Unmarshal when one or more fields in // the YAML document cannot be properly decoded into the requested // types. When this error is returned, the value is still // unmarshaled partially. type TypeError struct { Errors []string } func (e *TypeError) Error() string { return fmt.Sprintf("yaml: unmarshal errors:\n %s", strings.Join(e.Errors, "\n ")) } // -------------------------------------------------------------------------- // Maintain a mapping of keys to structure field indexes // The code in this section was copied from mgo/bson. // structInfo holds details for the serialization of fields of // a given struct. type structInfo struct { FieldsMap map[string]fieldInfo FieldsList []fieldInfo // InlineMap is the number of the field in the struct that // contains an ,inline map, or -1 if there's none. InlineMap int } type fieldInfo struct { Key string Num int OmitEmpty bool Flow bool // Id holds the unique field identifier, so we can cheaply // check for field duplicates without maintaining an extra map. Id int // Inline holds the field index if the field is part of an inlined struct. Inline []int } var structMap = make(map[reflect.Type]*structInfo) var fieldMapMutex sync.RWMutex func getStructInfo(st reflect.Type) (*structInfo, error) { fieldMapMutex.RLock() sinfo, found := structMap[st] fieldMapMutex.RUnlock() if found { return sinfo, nil } n := st.NumField() fieldsMap := make(map[string]fieldInfo) fieldsList := make([]fieldInfo, 0, n) inlineMap := -1 for i := 0; i != n; i++ { field := st.Field(i) if field.PkgPath != "" && !field.Anonymous { continue // Private field } info := fieldInfo{Num: i} tag := field.Tag.Get("yaml") if tag == "" && strings.Index(string(field.Tag), ":") < 0 { tag = string(field.Tag) } if tag == "-" { continue } inline := false fields := strings.Split(tag, ",") if len(fields) > 1 { for _, flag := range fields[1:] { switch flag { case "omitempty": info.OmitEmpty = true case "flow": info.Flow = true case "inline": inline = true default: return nil, errors.New(fmt.Sprintf("Unsupported flag %q in tag %q of type %s", flag, tag, st)) } } tag = fields[0] } if inline { switch field.Type.Kind() { case reflect.Map: if inlineMap >= 0 { return nil, errors.New("Multiple ,inline maps in struct " + st.String()) } if field.Type.Key() != reflect.TypeOf("") { return nil, errors.New("Option ,inline needs a map with string keys in struct " + st.String()) } inlineMap = info.Num case reflect.Struct: sinfo, err := getStructInfo(field.Type) if err != nil { return nil, err } for _, finfo := range sinfo.FieldsList { if _, found := fieldsMap[finfo.Key]; found { msg := "Duplicated key '" + finfo.Key + "' in struct " + st.String() return nil, errors.New(msg) } if finfo.Inline == nil { finfo.Inline = []int{i, finfo.Num} } else { finfo.Inline = append([]int{i}, finfo.Inline...) } finfo.Id = len(fieldsList) fieldsMap[finfo.Key] = finfo fieldsList = append(fieldsList, finfo) } default: //return nil, errors.New("Option ,inline needs a struct value or map field") return nil, errors.New("Option ,inline needs a struct value field") } continue } if tag != "" { info.Key = tag } else { info.Key = strings.ToLower(field.Name) } if _, found = fieldsMap[info.Key]; found { msg := "Duplicated key '" + info.Key + "' in struct " + st.String() return nil, errors.New(msg) } info.Id = len(fieldsList) fieldsList = append(fieldsList, info) fieldsMap[info.Key] = info } sinfo = &structInfo{ FieldsMap: fieldsMap, FieldsList: fieldsList, InlineMap: inlineMap, } fieldMapMutex.Lock() structMap[st] = sinfo fieldMapMutex.Unlock() return sinfo, nil } // IsZeroer is used to check whether an object is zero to // determine whether it should be omitted when marshaling // with the omitempty flag. One notable implementation // is time.Time. type IsZeroer interface { IsZero() bool } func isZero(v reflect.Value) bool { kind := v.Kind() if z, ok := v.Interface().(IsZeroer); ok { if (kind == reflect.Ptr || kind == reflect.Interface) && v.IsNil() { return true } return z.IsZero() } switch kind { case reflect.String: return len(v.String()) == 0 case reflect.Interface, reflect.Ptr: return v.IsNil() case reflect.Slice: return v.Len() == 0 case reflect.Map: return v.Len() == 0 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return v.Int() == 0 case reflect.Float32, reflect.Float64: return v.Float() == 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return v.Uint() == 0 case reflect.Bool: return !v.Bool() case reflect.Struct: vt := v.Type() for i := v.NumField() - 1; i >= 0; i-- { if vt.Field(i).PkgPath != "" { continue // Private field } if !isZero(v.Field(i)) { return false } } return true } return false } // FutureLineWrap globally disables line wrapping when encoding long strings. // This is a temporary and thus deprecated method introduced to faciliate // migration towards v3, which offers more control of line lengths on // individual encodings, and has a default matching the behavior introduced // by this function. // // The default formatting of v2 was erroneously changed in v2.3.0 and reverted // in v2.4.0, at which point this function was introduced to help migration. func FutureLineWrap() { disableLineWrapping = true }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/emitterc.go
vendor/gopkg.in/yaml.v2/emitterc.go
package yaml import ( "bytes" "fmt" ) // Flush the buffer if needed. func flush(emitter *yaml_emitter_t) bool { if emitter.buffer_pos+5 >= len(emitter.buffer) { return yaml_emitter_flush(emitter) } return true } // Put a character to the output buffer. func put(emitter *yaml_emitter_t, value byte) bool { if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { return false } emitter.buffer[emitter.buffer_pos] = value emitter.buffer_pos++ emitter.column++ return true } // Put a line break to the output buffer. func put_break(emitter *yaml_emitter_t) bool { if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { return false } switch emitter.line_break { case yaml_CR_BREAK: emitter.buffer[emitter.buffer_pos] = '\r' emitter.buffer_pos += 1 case yaml_LN_BREAK: emitter.buffer[emitter.buffer_pos] = '\n' emitter.buffer_pos += 1 case yaml_CRLN_BREAK: emitter.buffer[emitter.buffer_pos+0] = '\r' emitter.buffer[emitter.buffer_pos+1] = '\n' emitter.buffer_pos += 2 default: panic("unknown line break setting") } emitter.column = 0 emitter.line++ return true } // Copy a character from a string into buffer. func write(emitter *yaml_emitter_t, s []byte, i *int) bool { if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { return false } p := emitter.buffer_pos w := width(s[*i]) switch w { case 4: emitter.buffer[p+3] = s[*i+3] fallthrough case 3: emitter.buffer[p+2] = s[*i+2] fallthrough case 2: emitter.buffer[p+1] = s[*i+1] fallthrough case 1: emitter.buffer[p+0] = s[*i+0] default: panic("unknown character width") } emitter.column++ emitter.buffer_pos += w *i += w return true } // Write a whole string into buffer. func write_all(emitter *yaml_emitter_t, s []byte) bool { for i := 0; i < len(s); { if !write(emitter, s, &i) { return false } } return true } // Copy a line break character from a string into buffer. func write_break(emitter *yaml_emitter_t, s []byte, i *int) bool { if s[*i] == '\n' { if !put_break(emitter) { return false } *i++ } else { if !write(emitter, s, i) { return false } emitter.column = 0 emitter.line++ } return true } // Set an emitter error and return false. func yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool { emitter.error = yaml_EMITTER_ERROR emitter.problem = problem return false } // Emit an event. func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool { emitter.events = append(emitter.events, *event) for !yaml_emitter_need_more_events(emitter) { event := &emitter.events[emitter.events_head] if !yaml_emitter_analyze_event(emitter, event) { return false } if !yaml_emitter_state_machine(emitter, event) { return false } yaml_event_delete(event) emitter.events_head++ } return true } // Check if we need to accumulate more events before emitting. // // We accumulate extra // - 1 event for DOCUMENT-START // - 2 events for SEQUENCE-START // - 3 events for MAPPING-START // func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool { if emitter.events_head == len(emitter.events) { return true } var accumulate int switch emitter.events[emitter.events_head].typ { case yaml_DOCUMENT_START_EVENT: accumulate = 1 break case yaml_SEQUENCE_START_EVENT: accumulate = 2 break case yaml_MAPPING_START_EVENT: accumulate = 3 break default: return false } if len(emitter.events)-emitter.events_head > accumulate { return false } var level int for i := emitter.events_head; i < len(emitter.events); i++ { switch emitter.events[i].typ { case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT: level++ case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT: level-- } if level == 0 { return false } } return true } // Append a directive to the directives stack. func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool { for i := 0; i < len(emitter.tag_directives); i++ { if bytes.Equal(value.handle, emitter.tag_directives[i].handle) { if allow_duplicates { return true } return yaml_emitter_set_emitter_error(emitter, "duplicate %TAG directive") } } // [Go] Do we actually need to copy this given garbage collection // and the lack of deallocating destructors? tag_copy := yaml_tag_directive_t{ handle: make([]byte, len(value.handle)), prefix: make([]byte, len(value.prefix)), } copy(tag_copy.handle, value.handle) copy(tag_copy.prefix, value.prefix) emitter.tag_directives = append(emitter.tag_directives, tag_copy) return true } // Increase the indentation level. func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool { emitter.indents = append(emitter.indents, emitter.indent) if emitter.indent < 0 { if flow { emitter.indent = emitter.best_indent } else { emitter.indent = 0 } } else if !indentless { emitter.indent += emitter.best_indent } return true } // State dispatcher. func yaml_emitter_state_machine(emitter *yaml_emitter_t, event *yaml_event_t) bool { switch emitter.state { default: case yaml_EMIT_STREAM_START_STATE: return yaml_emitter_emit_stream_start(emitter, event) case yaml_EMIT_FIRST_DOCUMENT_START_STATE: return yaml_emitter_emit_document_start(emitter, event, true) case yaml_EMIT_DOCUMENT_START_STATE: return yaml_emitter_emit_document_start(emitter, event, false) case yaml_EMIT_DOCUMENT_CONTENT_STATE: return yaml_emitter_emit_document_content(emitter, event) case yaml_EMIT_DOCUMENT_END_STATE: return yaml_emitter_emit_document_end(emitter, event) case yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE: return yaml_emitter_emit_flow_sequence_item(emitter, event, true) case yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE: return yaml_emitter_emit_flow_sequence_item(emitter, event, false) case yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE: return yaml_emitter_emit_flow_mapping_key(emitter, event, true) case yaml_EMIT_FLOW_MAPPING_KEY_STATE: return yaml_emitter_emit_flow_mapping_key(emitter, event, false) case yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE: return yaml_emitter_emit_flow_mapping_value(emitter, event, true) case yaml_EMIT_FLOW_MAPPING_VALUE_STATE: return yaml_emitter_emit_flow_mapping_value(emitter, event, false) case yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE: return yaml_emitter_emit_block_sequence_item(emitter, event, true) case yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE: return yaml_emitter_emit_block_sequence_item(emitter, event, false) case yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE: return yaml_emitter_emit_block_mapping_key(emitter, event, true) case yaml_EMIT_BLOCK_MAPPING_KEY_STATE: return yaml_emitter_emit_block_mapping_key(emitter, event, false) case yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE: return yaml_emitter_emit_block_mapping_value(emitter, event, true) case yaml_EMIT_BLOCK_MAPPING_VALUE_STATE: return yaml_emitter_emit_block_mapping_value(emitter, event, false) case yaml_EMIT_END_STATE: return yaml_emitter_set_emitter_error(emitter, "expected nothing after STREAM-END") } panic("invalid emitter state") } // Expect STREAM-START. func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { if event.typ != yaml_STREAM_START_EVENT { return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START") } if emitter.encoding == yaml_ANY_ENCODING { emitter.encoding = event.encoding if emitter.encoding == yaml_ANY_ENCODING { emitter.encoding = yaml_UTF8_ENCODING } } if emitter.best_indent < 2 || emitter.best_indent > 9 { emitter.best_indent = 2 } if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 { emitter.best_width = 80 } if emitter.best_width < 0 { emitter.best_width = 1<<31 - 1 } if emitter.line_break == yaml_ANY_BREAK { emitter.line_break = yaml_LN_BREAK } emitter.indent = -1 emitter.line = 0 emitter.column = 0 emitter.whitespace = true emitter.indention = true if emitter.encoding != yaml_UTF8_ENCODING { if !yaml_emitter_write_bom(emitter) { return false } } emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE return true } // Expect DOCUMENT-START or STREAM-END. func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if event.typ == yaml_DOCUMENT_START_EVENT { if event.version_directive != nil { if !yaml_emitter_analyze_version_directive(emitter, event.version_directive) { return false } } for i := 0; i < len(event.tag_directives); i++ { tag_directive := &event.tag_directives[i] if !yaml_emitter_analyze_tag_directive(emitter, tag_directive) { return false } if !yaml_emitter_append_tag_directive(emitter, tag_directive, false) { return false } } for i := 0; i < len(default_tag_directives); i++ { tag_directive := &default_tag_directives[i] if !yaml_emitter_append_tag_directive(emitter, tag_directive, true) { return false } } implicit := event.implicit if !first || emitter.canonical { implicit = false } if emitter.open_ended && (event.version_directive != nil || len(event.tag_directives) > 0) { if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if event.version_directive != nil { implicit = false if !yaml_emitter_write_indicator(emitter, []byte("%YAML"), true, false, false) { return false } if !yaml_emitter_write_indicator(emitter, []byte("1.1"), true, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if len(event.tag_directives) > 0 { implicit = false for i := 0; i < len(event.tag_directives); i++ { tag_directive := &event.tag_directives[i] if !yaml_emitter_write_indicator(emitter, []byte("%TAG"), true, false, false) { return false } if !yaml_emitter_write_tag_handle(emitter, tag_directive.handle) { return false } if !yaml_emitter_write_tag_content(emitter, tag_directive.prefix, true) { return false } if !yaml_emitter_write_indent(emitter) { return false } } } if yaml_emitter_check_empty_document(emitter) { implicit = false } if !implicit { if !yaml_emitter_write_indent(emitter) { return false } if !yaml_emitter_write_indicator(emitter, []byte("---"), true, false, false) { return false } if emitter.canonical { if !yaml_emitter_write_indent(emitter) { return false } } } emitter.state = yaml_EMIT_DOCUMENT_CONTENT_STATE return true } if event.typ == yaml_STREAM_END_EVENT { if emitter.open_ended { if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_flush(emitter) { return false } emitter.state = yaml_EMIT_END_STATE return true } return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-START or STREAM-END") } // Expect the root node. func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool { emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE) return yaml_emitter_emit_node(emitter, event, true, false, false, false) } // Expect DOCUMENT-END. func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool { if event.typ != yaml_DOCUMENT_END_EVENT { return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END") } if !yaml_emitter_write_indent(emitter) { return false } if !event.implicit { // [Go] Allocate the slice elsewhere. if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_flush(emitter) { return false } emitter.state = yaml_EMIT_DOCUMENT_START_STATE emitter.tag_directives = emitter.tag_directives[:0] return true } // Expect a flow item node. func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) { return false } if !yaml_emitter_increase_indent(emitter, true, false) { return false } emitter.flow_level++ } if event.typ == yaml_SEQUENCE_END_EVENT { emitter.flow_level-- emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] if emitter.canonical && !first { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) { return false } emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !first { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } } if emitter.canonical || emitter.column > emitter.best_width { if !yaml_emitter_write_indent(emitter) { return false } } emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE) return yaml_emitter_emit_node(emitter, event, false, true, false, false) } // Expect a flow key node. func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) { return false } if !yaml_emitter_increase_indent(emitter, true, false) { return false } emitter.flow_level++ } if event.typ == yaml_MAPPING_END_EVENT { emitter.flow_level-- emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] if emitter.canonical && !first { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) { return false } emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !first { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } } if emitter.canonical || emitter.column > emitter.best_width { if !yaml_emitter_write_indent(emitter) { return false } } if !emitter.canonical && yaml_emitter_check_simple_key(emitter) { emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, true) } if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) { return false } emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) } // Expect a flow value node. func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { if simple { if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { return false } } else { if emitter.canonical || emitter.column > emitter.best_width { if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) { return false } } emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) } // Expect a block item node. func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_increase_indent(emitter, false, emitter.mapping_context && !emitter.indention) { return false } } if event.typ == yaml_SEQUENCE_END_EVENT { emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !yaml_emitter_write_indent(emitter) { return false } if !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) { return false } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE) return yaml_emitter_emit_node(emitter, event, false, true, false, false) } // Expect a block key node. func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_increase_indent(emitter, false, false) { return false } } if event.typ == yaml_MAPPING_END_EVENT { emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !yaml_emitter_write_indent(emitter) { return false } if yaml_emitter_check_simple_key(emitter) { emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, true) } if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) { return false } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) } // Expect a block value node. func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { if simple { if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { return false } } else { if !yaml_emitter_write_indent(emitter) { return false } if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) { return false } } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) } // Expect a node. func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t, root bool, sequence bool, mapping bool, simple_key bool) bool { emitter.root_context = root emitter.sequence_context = sequence emitter.mapping_context = mapping emitter.simple_key_context = simple_key switch event.typ { case yaml_ALIAS_EVENT: return yaml_emitter_emit_alias(emitter, event) case yaml_SCALAR_EVENT: return yaml_emitter_emit_scalar(emitter, event) case yaml_SEQUENCE_START_EVENT: return yaml_emitter_emit_sequence_start(emitter, event) case yaml_MAPPING_START_EVENT: return yaml_emitter_emit_mapping_start(emitter, event) default: return yaml_emitter_set_emitter_error(emitter, fmt.Sprintf("expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS, but got %v", event.typ)) } } // Expect ALIAS. func yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } // Expect SCALAR. func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_select_scalar_style(emitter, event) { return false } if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if !yaml_emitter_increase_indent(emitter, true, false) { return false } if !yaml_emitter_process_scalar(emitter) { return false } emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } // Expect SEQUENCE-START. func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE || yaml_emitter_check_empty_sequence(emitter) { emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE } else { emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE } return true } // Expect MAPPING-START. func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE || yaml_emitter_check_empty_mapping(emitter) { emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE } else { emitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE } return true } // Check if the document content is an empty scalar. func yaml_emitter_check_empty_document(emitter *yaml_emitter_t) bool { return false // [Go] Huh? } // Check if the next events represent an empty sequence. func yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool { if len(emitter.events)-emitter.events_head < 2 { return false } return emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT && emitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT } // Check if the next events represent an empty mapping. func yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool { if len(emitter.events)-emitter.events_head < 2 { return false } return emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT && emitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT } // Check if the next node can be expressed as a simple key. func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool { length := 0 switch emitter.events[emitter.events_head].typ { case yaml_ALIAS_EVENT: length += len(emitter.anchor_data.anchor) case yaml_SCALAR_EVENT: if emitter.scalar_data.multiline { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) + len(emitter.scalar_data.value) case yaml_SEQUENCE_START_EVENT: if !yaml_emitter_check_empty_sequence(emitter) { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) case yaml_MAPPING_START_EVENT: if !yaml_emitter_check_empty_mapping(emitter) { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) default: return false } return length <= 128 } // Determine an acceptable scalar style. func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool { no_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 if no_tag && !event.implicit && !event.quoted_implicit { return yaml_emitter_set_emitter_error(emitter, "neither tag nor implicit flags are specified") } style := event.scalar_style() if style == yaml_ANY_SCALAR_STYLE { style = yaml_PLAIN_SCALAR_STYLE } if emitter.canonical { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } if emitter.simple_key_context && emitter.scalar_data.multiline { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } if style == yaml_PLAIN_SCALAR_STYLE { if emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed || emitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } if len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } if no_tag && !event.implicit { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } } if style == yaml_SINGLE_QUOTED_SCALAR_STYLE { if !emitter.scalar_data.single_quoted_allowed { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } } if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE { if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } } if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE { emitter.tag_data.handle = []byte{'!'} } emitter.scalar_data.style = style return true } // Write an anchor. func yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool { if emitter.anchor_data.anchor == nil { return true } c := []byte{'&'} if emitter.anchor_data.alias { c[0] = '*' } if !yaml_emitter_write_indicator(emitter, c, true, false, false) { return false } return yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor) } // Write a tag. func yaml_emitter_process_tag(emitter *yaml_emitter_t) bool { if len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 { return true } if len(emitter.tag_data.handle) > 0 { if !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) { return false } if len(emitter.tag_data.suffix) > 0 { if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { return false } } } else { // [Go] Allocate these slices elsewhere. if !yaml_emitter_write_indicator(emitter, []byte("!<"), true, false, false) { return false } if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { return false } if !yaml_emitter_write_indicator(emitter, []byte{'>'}, false, false, false) { return false } } return true } // Write a scalar. func yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool { switch emitter.scalar_data.style { case yaml_PLAIN_SCALAR_STYLE: return yaml_emitter_write_plain_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) case yaml_SINGLE_QUOTED_SCALAR_STYLE: return yaml_emitter_write_single_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) case yaml_DOUBLE_QUOTED_SCALAR_STYLE: return yaml_emitter_write_double_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) case yaml_LITERAL_SCALAR_STYLE: return yaml_emitter_write_literal_scalar(emitter, emitter.scalar_data.value) case yaml_FOLDED_SCALAR_STYLE: return yaml_emitter_write_folded_scalar(emitter, emitter.scalar_data.value) } panic("unknown scalar style") } // Check if a %YAML directive is valid. func yaml_emitter_analyze_version_directive(emitter *yaml_emitter_t, version_directive *yaml_version_directive_t) bool { if version_directive.major != 1 || version_directive.minor != 1 { return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive") } return true } // Check if a %TAG directive is valid. func yaml_emitter_analyze_tag_directive(emitter *yaml_emitter_t, tag_directive *yaml_tag_directive_t) bool { handle := tag_directive.handle prefix := tag_directive.prefix if len(handle) == 0 { return yaml_emitter_set_emitter_error(emitter, "tag handle must not be empty") } if handle[0] != '!' { return yaml_emitter_set_emitter_error(emitter, "tag handle must start with '!'") } if handle[len(handle)-1] != '!' { return yaml_emitter_set_emitter_error(emitter, "tag handle must end with '!'") } for i := 1; i < len(handle)-1; i += width(handle[i]) { if !is_alpha(handle, i) { return yaml_emitter_set_emitter_error(emitter, "tag handle must contain alphanumerical characters only") } } if len(prefix) == 0 { return yaml_emitter_set_emitter_error(emitter, "tag prefix must not be empty") } return true } // Check if an anchor is valid. func yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool { if len(anchor) == 0 { problem := "anchor value must not be empty" if alias { problem = "alias value must not be empty" } return yaml_emitter_set_emitter_error(emitter, problem) } for i := 0; i < len(anchor); i += width(anchor[i]) { if !is_alpha(anchor, i) { problem := "anchor value must contain alphanumerical characters only" if alias { problem = "alias value must contain alphanumerical characters only" } return yaml_emitter_set_emitter_error(emitter, problem) } } emitter.anchor_data.anchor = anchor emitter.anchor_data.alias = alias return true } // Check if a tag is valid. func yaml_emitter_analyze_tag(emitter *yaml_emitter_t, tag []byte) bool { if len(tag) == 0 { return yaml_emitter_set_emitter_error(emitter, "tag value must not be empty") } for i := 0; i < len(emitter.tag_directives); i++ { tag_directive := &emitter.tag_directives[i] if bytes.HasPrefix(tag, tag_directive.prefix) { emitter.tag_data.handle = tag_directive.handle emitter.tag_data.suffix = tag[len(tag_directive.prefix):] return true } } emitter.tag_data.suffix = tag return true } // Check if a scalar is valid. func yaml_emitter_analyze_scalar(emitter *yaml_emitter_t, value []byte) bool { var ( block_indicators = false flow_indicators = false line_breaks = false special_characters = false leading_space = false leading_break = false trailing_space = false trailing_break = false break_space = false space_break = false preceded_by_whitespace = false followed_by_whitespace = false previous_space = false previous_break = false ) emitter.scalar_data.value = value if len(value) == 0 { emitter.scalar_data.multiline = false emitter.scalar_data.flow_plain_allowed = false emitter.scalar_data.block_plain_allowed = true emitter.scalar_data.single_quoted_allowed = true emitter.scalar_data.block_allowed = false return true } if len(value) >= 3 && ((value[0] == '-' && value[1] == '-' && value[2] == '-') || (value[0] == '.' && value[1] == '.' && value[2] == '.')) { block_indicators = true flow_indicators = true } preceded_by_whitespace = true for i, w := 0, 0; i < len(value); i += w { w = width(value[i]) followed_by_whitespace = i+w >= len(value) || is_blank(value, i+w) if i == 0 { switch value[i] { case '#', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\'', '"', '%', '@', '`': flow_indicators = true block_indicators = true case '?', ':': flow_indicators = true if followed_by_whitespace { block_indicators = true } case '-': if followed_by_whitespace { flow_indicators = true block_indicators = true } } } else { switch value[i] { case ',', '?', '[', ']', '{', '}': flow_indicators = true case ':': flow_indicators = true if followed_by_whitespace { block_indicators = true } case '#': if preceded_by_whitespace { flow_indicators = true block_indicators = true } } } if !is_printable(value, i) || !is_ascii(value, i) && !emitter.unicode { special_characters = true } if is_space(value, i) { if i == 0 { leading_space = true } if i+width(value[i]) == len(value) { trailing_space = true } if previous_break { break_space = true } previous_space = true previous_break = false } else if is_break(value, i) { line_breaks = true if i == 0 { leading_break = true } if i+width(value[i]) == len(value) { trailing_break = true } if previous_space { space_break = true } previous_space = false previous_break = true } else { previous_space = false previous_break = false } // [Go]: Why 'z'? Couldn't be the end of the string as that's the loop condition. preceded_by_whitespace = is_blankz(value, i) } emitter.scalar_data.multiline = line_breaks emitter.scalar_data.flow_plain_allowed = true emitter.scalar_data.block_plain_allowed = true emitter.scalar_data.single_quoted_allowed = true emitter.scalar_data.block_allowed = true if leading_space || leading_break || trailing_space || trailing_break { emitter.scalar_data.flow_plain_allowed = false emitter.scalar_data.block_plain_allowed = false } if trailing_space { emitter.scalar_data.block_allowed = false } if break_space { emitter.scalar_data.flow_plain_allowed = false emitter.scalar_data.block_plain_allowed = false emitter.scalar_data.single_quoted_allowed = false } if space_break || special_characters {
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/resolve.go
vendor/gopkg.in/yaml.v2/resolve.go
package yaml import ( "encoding/base64" "math" "regexp" "strconv" "strings" "time" ) type resolveMapItem struct { value interface{} tag string } var resolveTable = make([]byte, 256) var resolveMap = make(map[string]resolveMapItem) func init() { t := resolveTable t[int('+')] = 'S' // Sign t[int('-')] = 'S' for _, c := range "0123456789" { t[int(c)] = 'D' // Digit } for _, c := range "yYnNtTfFoO~" { t[int(c)] = 'M' // In map } t[int('.')] = '.' // Float (potentially in map) var resolveMapList = []struct { v interface{} tag string l []string }{ {true, yaml_BOOL_TAG, []string{"y", "Y", "yes", "Yes", "YES"}}, {true, yaml_BOOL_TAG, []string{"true", "True", "TRUE"}}, {true, yaml_BOOL_TAG, []string{"on", "On", "ON"}}, {false, yaml_BOOL_TAG, []string{"n", "N", "no", "No", "NO"}}, {false, yaml_BOOL_TAG, []string{"false", "False", "FALSE"}}, {false, yaml_BOOL_TAG, []string{"off", "Off", "OFF"}}, {nil, yaml_NULL_TAG, []string{"", "~", "null", "Null", "NULL"}}, {math.NaN(), yaml_FLOAT_TAG, []string{".nan", ".NaN", ".NAN"}}, {math.Inf(+1), yaml_FLOAT_TAG, []string{".inf", ".Inf", ".INF"}}, {math.Inf(+1), yaml_FLOAT_TAG, []string{"+.inf", "+.Inf", "+.INF"}}, {math.Inf(-1), yaml_FLOAT_TAG, []string{"-.inf", "-.Inf", "-.INF"}}, {"<<", yaml_MERGE_TAG, []string{"<<"}}, } m := resolveMap for _, item := range resolveMapList { for _, s := range item.l { m[s] = resolveMapItem{item.v, item.tag} } } } const longTagPrefix = "tag:yaml.org,2002:" func shortTag(tag string) string { // TODO This can easily be made faster and produce less garbage. if strings.HasPrefix(tag, longTagPrefix) { return "!!" + tag[len(longTagPrefix):] } return tag } func longTag(tag string) string { if strings.HasPrefix(tag, "!!") { return longTagPrefix + tag[2:] } return tag } func resolvableTag(tag string) bool { switch tag { case "", yaml_STR_TAG, yaml_BOOL_TAG, yaml_INT_TAG, yaml_FLOAT_TAG, yaml_NULL_TAG, yaml_TIMESTAMP_TAG: return true } return false } var yamlStyleFloat = regexp.MustCompile(`^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?$`) func resolve(tag string, in string) (rtag string, out interface{}) { if !resolvableTag(tag) { return tag, in } defer func() { switch tag { case "", rtag, yaml_STR_TAG, yaml_BINARY_TAG: return case yaml_FLOAT_TAG: if rtag == yaml_INT_TAG { switch v := out.(type) { case int64: rtag = yaml_FLOAT_TAG out = float64(v) return case int: rtag = yaml_FLOAT_TAG out = float64(v) return } } } failf("cannot decode %s `%s` as a %s", shortTag(rtag), in, shortTag(tag)) }() // Any data is accepted as a !!str or !!binary. // Otherwise, the prefix is enough of a hint about what it might be. hint := byte('N') if in != "" { hint = resolveTable[in[0]] } if hint != 0 && tag != yaml_STR_TAG && tag != yaml_BINARY_TAG { // Handle things we can lookup in a map. if item, ok := resolveMap[in]; ok { return item.tag, item.value } // Base 60 floats are a bad idea, were dropped in YAML 1.2, and // are purposefully unsupported here. They're still quoted on // the way out for compatibility with other parser, though. switch hint { case 'M': // We've already checked the map above. case '.': // Not in the map, so maybe a normal float. floatv, err := strconv.ParseFloat(in, 64) if err == nil { return yaml_FLOAT_TAG, floatv } case 'D', 'S': // Int, float, or timestamp. // Only try values as a timestamp if the value is unquoted or there's an explicit // !!timestamp tag. if tag == "" || tag == yaml_TIMESTAMP_TAG { t, ok := parseTimestamp(in) if ok { return yaml_TIMESTAMP_TAG, t } } plain := strings.Replace(in, "_", "", -1) intv, err := strconv.ParseInt(plain, 0, 64) if err == nil { if intv == int64(int(intv)) { return yaml_INT_TAG, int(intv) } else { return yaml_INT_TAG, intv } } uintv, err := strconv.ParseUint(plain, 0, 64) if err == nil { return yaml_INT_TAG, uintv } if yamlStyleFloat.MatchString(plain) { floatv, err := strconv.ParseFloat(plain, 64) if err == nil { return yaml_FLOAT_TAG, floatv } } if strings.HasPrefix(plain, "0b") { intv, err := strconv.ParseInt(plain[2:], 2, 64) if err == nil { if intv == int64(int(intv)) { return yaml_INT_TAG, int(intv) } else { return yaml_INT_TAG, intv } } uintv, err := strconv.ParseUint(plain[2:], 2, 64) if err == nil { return yaml_INT_TAG, uintv } } else if strings.HasPrefix(plain, "-0b") { intv, err := strconv.ParseInt("-" + plain[3:], 2, 64) if err == nil { if true || intv == int64(int(intv)) { return yaml_INT_TAG, int(intv) } else { return yaml_INT_TAG, intv } } } default: panic("resolveTable item not yet handled: " + string(rune(hint)) + " (with " + in + ")") } } return yaml_STR_TAG, in } // encodeBase64 encodes s as base64 that is broken up into multiple lines // as appropriate for the resulting length. func encodeBase64(s string) string { const lineLen = 70 encLen := base64.StdEncoding.EncodedLen(len(s)) lines := encLen/lineLen + 1 buf := make([]byte, encLen*2+lines) in := buf[0:encLen] out := buf[encLen:] base64.StdEncoding.Encode(in, []byte(s)) k := 0 for i := 0; i < len(in); i += lineLen { j := i + lineLen if j > len(in) { j = len(in) } k += copy(out[k:], in[i:j]) if lines > 1 { out[k] = '\n' k++ } } return string(out[:k]) } // This is a subset of the formats allowed by the regular expression // defined at http://yaml.org/type/timestamp.html. var allowedTimestampFormats = []string{ "2006-1-2T15:4:5.999999999Z07:00", // RCF3339Nano with short date fields. "2006-1-2t15:4:5.999999999Z07:00", // RFC3339Nano with short date fields and lower-case "t". "2006-1-2 15:4:5.999999999", // space separated with no time zone "2006-1-2", // date only // Notable exception: time.Parse cannot handle: "2001-12-14 21:59:43.10 -5" // from the set of examples. } // parseTimestamp parses s as a timestamp string and // returns the timestamp and reports whether it succeeded. // Timestamp formats are defined at http://yaml.org/type/timestamp.html func parseTimestamp(s string) (time.Time, bool) { // TODO write code to check all the formats supported by // http://yaml.org/type/timestamp.html instead of using time.Parse. // Quick check: all date formats start with YYYY-. i := 0 for ; i < len(s); i++ { if c := s[i]; c < '0' || c > '9' { break } } if i != 4 || i == len(s) || s[i] != '-' { return time.Time{}, false } for _, format := range allowedTimestampFormats { if t, err := time.Parse(format, s); err == nil { return t, true } } return time.Time{}, false }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/apic.go
vendor/gopkg.in/yaml.v2/apic.go
package yaml import ( "io" ) func yaml_insert_token(parser *yaml_parser_t, pos int, token *yaml_token_t) { //fmt.Println("yaml_insert_token", "pos:", pos, "typ:", token.typ, "head:", parser.tokens_head, "len:", len(parser.tokens)) // Check if we can move the queue at the beginning of the buffer. if parser.tokens_head > 0 && len(parser.tokens) == cap(parser.tokens) { if parser.tokens_head != len(parser.tokens) { copy(parser.tokens, parser.tokens[parser.tokens_head:]) } parser.tokens = parser.tokens[:len(parser.tokens)-parser.tokens_head] parser.tokens_head = 0 } parser.tokens = append(parser.tokens, *token) if pos < 0 { return } copy(parser.tokens[parser.tokens_head+pos+1:], parser.tokens[parser.tokens_head+pos:]) parser.tokens[parser.tokens_head+pos] = *token } // Create a new parser object. func yaml_parser_initialize(parser *yaml_parser_t) bool { *parser = yaml_parser_t{ raw_buffer: make([]byte, 0, input_raw_buffer_size), buffer: make([]byte, 0, input_buffer_size), } return true } // Destroy a parser object. func yaml_parser_delete(parser *yaml_parser_t) { *parser = yaml_parser_t{} } // String read handler. func yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { if parser.input_pos == len(parser.input) { return 0, io.EOF } n = copy(buffer, parser.input[parser.input_pos:]) parser.input_pos += n return n, nil } // Reader read handler. func yaml_reader_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { return parser.input_reader.Read(buffer) } // Set a string input. func yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) { if parser.read_handler != nil { panic("must set the input source only once") } parser.read_handler = yaml_string_read_handler parser.input = input parser.input_pos = 0 } // Set a file input. func yaml_parser_set_input_reader(parser *yaml_parser_t, r io.Reader) { if parser.read_handler != nil { panic("must set the input source only once") } parser.read_handler = yaml_reader_read_handler parser.input_reader = r } // Set the source encoding. func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) { if parser.encoding != yaml_ANY_ENCODING { panic("must set the encoding only once") } parser.encoding = encoding } var disableLineWrapping = false // Create a new emitter object. func yaml_emitter_initialize(emitter *yaml_emitter_t) { *emitter = yaml_emitter_t{ buffer: make([]byte, output_buffer_size), raw_buffer: make([]byte, 0, output_raw_buffer_size), states: make([]yaml_emitter_state_t, 0, initial_stack_size), events: make([]yaml_event_t, 0, initial_queue_size), } if disableLineWrapping { emitter.best_width = -1 } } // Destroy an emitter object. func yaml_emitter_delete(emitter *yaml_emitter_t) { *emitter = yaml_emitter_t{} } // String write handler. func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error { *emitter.output_buffer = append(*emitter.output_buffer, buffer...) return nil } // yaml_writer_write_handler uses emitter.output_writer to write the // emitted text. func yaml_writer_write_handler(emitter *yaml_emitter_t, buffer []byte) error { _, err := emitter.output_writer.Write(buffer) return err } // Set a string output. func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) { if emitter.write_handler != nil { panic("must set the output target only once") } emitter.write_handler = yaml_string_write_handler emitter.output_buffer = output_buffer } // Set a file output. func yaml_emitter_set_output_writer(emitter *yaml_emitter_t, w io.Writer) { if emitter.write_handler != nil { panic("must set the output target only once") } emitter.write_handler = yaml_writer_write_handler emitter.output_writer = w } // Set the output encoding. func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) { if emitter.encoding != yaml_ANY_ENCODING { panic("must set the output encoding only once") } emitter.encoding = encoding } // Set the canonical output style. func yaml_emitter_set_canonical(emitter *yaml_emitter_t, canonical bool) { emitter.canonical = canonical } //// Set the indentation increment. func yaml_emitter_set_indent(emitter *yaml_emitter_t, indent int) { if indent < 2 || indent > 9 { indent = 2 } emitter.best_indent = indent } // Set the preferred line width. func yaml_emitter_set_width(emitter *yaml_emitter_t, width int) { if width < 0 { width = -1 } emitter.best_width = width } // Set if unescaped non-ASCII characters are allowed. func yaml_emitter_set_unicode(emitter *yaml_emitter_t, unicode bool) { emitter.unicode = unicode } // Set the preferred line break character. func yaml_emitter_set_break(emitter *yaml_emitter_t, line_break yaml_break_t) { emitter.line_break = line_break } ///* // * Destroy a token object. // */ // //YAML_DECLARE(void) //yaml_token_delete(yaml_token_t *token) //{ // assert(token); // Non-NULL token object expected. // // switch (token.type) // { // case YAML_TAG_DIRECTIVE_TOKEN: // yaml_free(token.data.tag_directive.handle); // yaml_free(token.data.tag_directive.prefix); // break; // // case YAML_ALIAS_TOKEN: // yaml_free(token.data.alias.value); // break; // // case YAML_ANCHOR_TOKEN: // yaml_free(token.data.anchor.value); // break; // // case YAML_TAG_TOKEN: // yaml_free(token.data.tag.handle); // yaml_free(token.data.tag.suffix); // break; // // case YAML_SCALAR_TOKEN: // yaml_free(token.data.scalar.value); // break; // // default: // break; // } // // memset(token, 0, sizeof(yaml_token_t)); //} // ///* // * Check if a string is a valid UTF-8 sequence. // * // * Check 'reader.c' for more details on UTF-8 encoding. // */ // //static int //yaml_check_utf8(yaml_char_t *start, size_t length) //{ // yaml_char_t *end = start+length; // yaml_char_t *pointer = start; // // while (pointer < end) { // unsigned char octet; // unsigned int width; // unsigned int value; // size_t k; // // octet = pointer[0]; // width = (octet & 0x80) == 0x00 ? 1 : // (octet & 0xE0) == 0xC0 ? 2 : // (octet & 0xF0) == 0xE0 ? 3 : // (octet & 0xF8) == 0xF0 ? 4 : 0; // value = (octet & 0x80) == 0x00 ? octet & 0x7F : // (octet & 0xE0) == 0xC0 ? octet & 0x1F : // (octet & 0xF0) == 0xE0 ? octet & 0x0F : // (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0; // if (!width) return 0; // if (pointer+width > end) return 0; // for (k = 1; k < width; k ++) { // octet = pointer[k]; // if ((octet & 0xC0) != 0x80) return 0; // value = (value << 6) + (octet & 0x3F); // } // if (!((width == 1) || // (width == 2 && value >= 0x80) || // (width == 3 && value >= 0x800) || // (width == 4 && value >= 0x10000))) return 0; // // pointer += width; // } // // return 1; //} // // Create STREAM-START. func yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) { *event = yaml_event_t{ typ: yaml_STREAM_START_EVENT, encoding: encoding, } } // Create STREAM-END. func yaml_stream_end_event_initialize(event *yaml_event_t) { *event = yaml_event_t{ typ: yaml_STREAM_END_EVENT, } } // Create DOCUMENT-START. func yaml_document_start_event_initialize( event *yaml_event_t, version_directive *yaml_version_directive_t, tag_directives []yaml_tag_directive_t, implicit bool, ) { *event = yaml_event_t{ typ: yaml_DOCUMENT_START_EVENT, version_directive: version_directive, tag_directives: tag_directives, implicit: implicit, } } // Create DOCUMENT-END. func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) { *event = yaml_event_t{ typ: yaml_DOCUMENT_END_EVENT, implicit: implicit, } } ///* // * Create ALIAS. // */ // //YAML_DECLARE(int) //yaml_alias_event_initialize(event *yaml_event_t, anchor *yaml_char_t) //{ // mark yaml_mark_t = { 0, 0, 0 } // anchor_copy *yaml_char_t = NULL // // assert(event) // Non-NULL event object is expected. // assert(anchor) // Non-NULL anchor is expected. // // if (!yaml_check_utf8(anchor, strlen((char *)anchor))) return 0 // // anchor_copy = yaml_strdup(anchor) // if (!anchor_copy) // return 0 // // ALIAS_EVENT_INIT(*event, anchor_copy, mark, mark) // // return 1 //} // Create SCALAR. func yaml_scalar_event_initialize(event *yaml_event_t, anchor, tag, value []byte, plain_implicit, quoted_implicit bool, style yaml_scalar_style_t) bool { *event = yaml_event_t{ typ: yaml_SCALAR_EVENT, anchor: anchor, tag: tag, value: value, implicit: plain_implicit, quoted_implicit: quoted_implicit, style: yaml_style_t(style), } return true } // Create SEQUENCE-START. func yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool { *event = yaml_event_t{ typ: yaml_SEQUENCE_START_EVENT, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(style), } return true } // Create SEQUENCE-END. func yaml_sequence_end_event_initialize(event *yaml_event_t) bool { *event = yaml_event_t{ typ: yaml_SEQUENCE_END_EVENT, } return true } // Create MAPPING-START. func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) { *event = yaml_event_t{ typ: yaml_MAPPING_START_EVENT, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(style), } } // Create MAPPING-END. func yaml_mapping_end_event_initialize(event *yaml_event_t) { *event = yaml_event_t{ typ: yaml_MAPPING_END_EVENT, } } // Destroy an event object. func yaml_event_delete(event *yaml_event_t) { *event = yaml_event_t{} } ///* // * Create a document object. // */ // //YAML_DECLARE(int) //yaml_document_initialize(document *yaml_document_t, // version_directive *yaml_version_directive_t, // tag_directives_start *yaml_tag_directive_t, // tag_directives_end *yaml_tag_directive_t, // start_implicit int, end_implicit int) //{ // struct { // error yaml_error_type_t // } context // struct { // start *yaml_node_t // end *yaml_node_t // top *yaml_node_t // } nodes = { NULL, NULL, NULL } // version_directive_copy *yaml_version_directive_t = NULL // struct { // start *yaml_tag_directive_t // end *yaml_tag_directive_t // top *yaml_tag_directive_t // } tag_directives_copy = { NULL, NULL, NULL } // value yaml_tag_directive_t = { NULL, NULL } // mark yaml_mark_t = { 0, 0, 0 } // // assert(document) // Non-NULL document object is expected. // assert((tag_directives_start && tag_directives_end) || // (tag_directives_start == tag_directives_end)) // // Valid tag directives are expected. // // if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error // // if (version_directive) { // version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t)) // if (!version_directive_copy) goto error // version_directive_copy.major = version_directive.major // version_directive_copy.minor = version_directive.minor // } // // if (tag_directives_start != tag_directives_end) { // tag_directive *yaml_tag_directive_t // if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE)) // goto error // for (tag_directive = tag_directives_start // tag_directive != tag_directives_end; tag_directive ++) { // assert(tag_directive.handle) // assert(tag_directive.prefix) // if (!yaml_check_utf8(tag_directive.handle, // strlen((char *)tag_directive.handle))) // goto error // if (!yaml_check_utf8(tag_directive.prefix, // strlen((char *)tag_directive.prefix))) // goto error // value.handle = yaml_strdup(tag_directive.handle) // value.prefix = yaml_strdup(tag_directive.prefix) // if (!value.handle || !value.prefix) goto error // if (!PUSH(&context, tag_directives_copy, value)) // goto error // value.handle = NULL // value.prefix = NULL // } // } // // DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy, // tag_directives_copy.start, tag_directives_copy.top, // start_implicit, end_implicit, mark, mark) // // return 1 // //error: // STACK_DEL(&context, nodes) // yaml_free(version_directive_copy) // while (!STACK_EMPTY(&context, tag_directives_copy)) { // value yaml_tag_directive_t = POP(&context, tag_directives_copy) // yaml_free(value.handle) // yaml_free(value.prefix) // } // STACK_DEL(&context, tag_directives_copy) // yaml_free(value.handle) // yaml_free(value.prefix) // // return 0 //} // ///* // * Destroy a document object. // */ // //YAML_DECLARE(void) //yaml_document_delete(document *yaml_document_t) //{ // struct { // error yaml_error_type_t // } context // tag_directive *yaml_tag_directive_t // // context.error = YAML_NO_ERROR // Eliminate a compiler warning. // // assert(document) // Non-NULL document object is expected. // // while (!STACK_EMPTY(&context, document.nodes)) { // node yaml_node_t = POP(&context, document.nodes) // yaml_free(node.tag) // switch (node.type) { // case YAML_SCALAR_NODE: // yaml_free(node.data.scalar.value) // break // case YAML_SEQUENCE_NODE: // STACK_DEL(&context, node.data.sequence.items) // break // case YAML_MAPPING_NODE: // STACK_DEL(&context, node.data.mapping.pairs) // break // default: // assert(0) // Should not happen. // } // } // STACK_DEL(&context, document.nodes) // // yaml_free(document.version_directive) // for (tag_directive = document.tag_directives.start // tag_directive != document.tag_directives.end // tag_directive++) { // yaml_free(tag_directive.handle) // yaml_free(tag_directive.prefix) // } // yaml_free(document.tag_directives.start) // // memset(document, 0, sizeof(yaml_document_t)) //} // ///** // * Get a document node. // */ // //YAML_DECLARE(yaml_node_t *) //yaml_document_get_node(document *yaml_document_t, index int) //{ // assert(document) // Non-NULL document object is expected. // // if (index > 0 && document.nodes.start + index <= document.nodes.top) { // return document.nodes.start + index - 1 // } // return NULL //} // ///** // * Get the root object. // */ // //YAML_DECLARE(yaml_node_t *) //yaml_document_get_root_node(document *yaml_document_t) //{ // assert(document) // Non-NULL document object is expected. // // if (document.nodes.top != document.nodes.start) { // return document.nodes.start // } // return NULL //} // ///* // * Add a scalar node to a document. // */ // //YAML_DECLARE(int) //yaml_document_add_scalar(document *yaml_document_t, // tag *yaml_char_t, value *yaml_char_t, length int, // style yaml_scalar_style_t) //{ // struct { // error yaml_error_type_t // } context // mark yaml_mark_t = { 0, 0, 0 } // tag_copy *yaml_char_t = NULL // value_copy *yaml_char_t = NULL // node yaml_node_t // // assert(document) // Non-NULL document object is expected. // assert(value) // Non-NULL value is expected. // // if (!tag) { // tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG // } // // if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error // tag_copy = yaml_strdup(tag) // if (!tag_copy) goto error // // if (length < 0) { // length = strlen((char *)value) // } // // if (!yaml_check_utf8(value, length)) goto error // value_copy = yaml_malloc(length+1) // if (!value_copy) goto error // memcpy(value_copy, value, length) // value_copy[length] = '\0' // // SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark) // if (!PUSH(&context, document.nodes, node)) goto error // // return document.nodes.top - document.nodes.start // //error: // yaml_free(tag_copy) // yaml_free(value_copy) // // return 0 //} // ///* // * Add a sequence node to a document. // */ // //YAML_DECLARE(int) //yaml_document_add_sequence(document *yaml_document_t, // tag *yaml_char_t, style yaml_sequence_style_t) //{ // struct { // error yaml_error_type_t // } context // mark yaml_mark_t = { 0, 0, 0 } // tag_copy *yaml_char_t = NULL // struct { // start *yaml_node_item_t // end *yaml_node_item_t // top *yaml_node_item_t // } items = { NULL, NULL, NULL } // node yaml_node_t // // assert(document) // Non-NULL document object is expected. // // if (!tag) { // tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG // } // // if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error // tag_copy = yaml_strdup(tag) // if (!tag_copy) goto error // // if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error // // SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end, // style, mark, mark) // if (!PUSH(&context, document.nodes, node)) goto error // // return document.nodes.top - document.nodes.start // //error: // STACK_DEL(&context, items) // yaml_free(tag_copy) // // return 0 //} // ///* // * Add a mapping node to a document. // */ // //YAML_DECLARE(int) //yaml_document_add_mapping(document *yaml_document_t, // tag *yaml_char_t, style yaml_mapping_style_t) //{ // struct { // error yaml_error_type_t // } context // mark yaml_mark_t = { 0, 0, 0 } // tag_copy *yaml_char_t = NULL // struct { // start *yaml_node_pair_t // end *yaml_node_pair_t // top *yaml_node_pair_t // } pairs = { NULL, NULL, NULL } // node yaml_node_t // // assert(document) // Non-NULL document object is expected. // // if (!tag) { // tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG // } // // if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error // tag_copy = yaml_strdup(tag) // if (!tag_copy) goto error // // if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error // // MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end, // style, mark, mark) // if (!PUSH(&context, document.nodes, node)) goto error // // return document.nodes.top - document.nodes.start // //error: // STACK_DEL(&context, pairs) // yaml_free(tag_copy) // // return 0 //} // ///* // * Append an item to a sequence node. // */ // //YAML_DECLARE(int) //yaml_document_append_sequence_item(document *yaml_document_t, // sequence int, item int) //{ // struct { // error yaml_error_type_t // } context // // assert(document) // Non-NULL document is required. // assert(sequence > 0 // && document.nodes.start + sequence <= document.nodes.top) // // Valid sequence id is required. // assert(document.nodes.start[sequence-1].type == YAML_SEQUENCE_NODE) // // A sequence node is required. // assert(item > 0 && document.nodes.start + item <= document.nodes.top) // // Valid item id is required. // // if (!PUSH(&context, // document.nodes.start[sequence-1].data.sequence.items, item)) // return 0 // // return 1 //} // ///* // * Append a pair of a key and a value to a mapping node. // */ // //YAML_DECLARE(int) //yaml_document_append_mapping_pair(document *yaml_document_t, // mapping int, key int, value int) //{ // struct { // error yaml_error_type_t // } context // // pair yaml_node_pair_t // // assert(document) // Non-NULL document is required. // assert(mapping > 0 // && document.nodes.start + mapping <= document.nodes.top) // // Valid mapping id is required. // assert(document.nodes.start[mapping-1].type == YAML_MAPPING_NODE) // // A mapping node is required. // assert(key > 0 && document.nodes.start + key <= document.nodes.top) // // Valid key id is required. // assert(value > 0 && document.nodes.start + value <= document.nodes.top) // // Valid value id is required. // // pair.key = key // pair.value = value // // if (!PUSH(&context, // document.nodes.start[mapping-1].data.mapping.pairs, pair)) // return 0 // // return 1 //} // //
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/encode.go
vendor/gopkg.in/yaml.v2/encode.go
package yaml import ( "encoding" "fmt" "io" "reflect" "regexp" "sort" "strconv" "strings" "time" "unicode/utf8" ) // jsonNumber is the interface of the encoding/json.Number datatype. // Repeating the interface here avoids a dependency on encoding/json, and also // supports other libraries like jsoniter, which use a similar datatype with // the same interface. Detecting this interface is useful when dealing with // structures containing json.Number, which is a string under the hood. The // encoder should prefer the use of Int64(), Float64() and string(), in that // order, when encoding this type. type jsonNumber interface { Float64() (float64, error) Int64() (int64, error) String() string } type encoder struct { emitter yaml_emitter_t event yaml_event_t out []byte flow bool // doneInit holds whether the initial stream_start_event has been // emitted. doneInit bool } func newEncoder() *encoder { e := &encoder{} yaml_emitter_initialize(&e.emitter) yaml_emitter_set_output_string(&e.emitter, &e.out) yaml_emitter_set_unicode(&e.emitter, true) return e } func newEncoderWithWriter(w io.Writer) *encoder { e := &encoder{} yaml_emitter_initialize(&e.emitter) yaml_emitter_set_output_writer(&e.emitter, w) yaml_emitter_set_unicode(&e.emitter, true) return e } func (e *encoder) init() { if e.doneInit { return } yaml_stream_start_event_initialize(&e.event, yaml_UTF8_ENCODING) e.emit() e.doneInit = true } func (e *encoder) finish() { e.emitter.open_ended = false yaml_stream_end_event_initialize(&e.event) e.emit() } func (e *encoder) destroy() { yaml_emitter_delete(&e.emitter) } func (e *encoder) emit() { // This will internally delete the e.event value. e.must(yaml_emitter_emit(&e.emitter, &e.event)) } func (e *encoder) must(ok bool) { if !ok { msg := e.emitter.problem if msg == "" { msg = "unknown problem generating YAML content" } failf("%s", msg) } } func (e *encoder) marshalDoc(tag string, in reflect.Value) { e.init() yaml_document_start_event_initialize(&e.event, nil, nil, true) e.emit() e.marshal(tag, in) yaml_document_end_event_initialize(&e.event, true) e.emit() } func (e *encoder) marshal(tag string, in reflect.Value) { if !in.IsValid() || in.Kind() == reflect.Ptr && in.IsNil() { e.nilv() return } iface := in.Interface() switch m := iface.(type) { case jsonNumber: integer, err := m.Int64() if err == nil { // In this case the json.Number is a valid int64 in = reflect.ValueOf(integer) break } float, err := m.Float64() if err == nil { // In this case the json.Number is a valid float64 in = reflect.ValueOf(float) break } // fallback case - no number could be obtained in = reflect.ValueOf(m.String()) case time.Time, *time.Time: // Although time.Time implements TextMarshaler, // we don't want to treat it as a string for YAML // purposes because YAML has special support for // timestamps. case Marshaler: v, err := m.MarshalYAML() if err != nil { fail(err) } if v == nil { e.nilv() return } in = reflect.ValueOf(v) case encoding.TextMarshaler: text, err := m.MarshalText() if err != nil { fail(err) } in = reflect.ValueOf(string(text)) case nil: e.nilv() return } switch in.Kind() { case reflect.Interface: e.marshal(tag, in.Elem()) case reflect.Map: e.mapv(tag, in) case reflect.Ptr: if in.Type() == ptrTimeType { e.timev(tag, in.Elem()) } else { e.marshal(tag, in.Elem()) } case reflect.Struct: if in.Type() == timeType { e.timev(tag, in) } else { e.structv(tag, in) } case reflect.Slice, reflect.Array: if in.Type().Elem() == mapItemType { e.itemsv(tag, in) } else { e.slicev(tag, in) } case reflect.String: e.stringv(tag, in) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: if in.Type() == durationType { e.stringv(tag, reflect.ValueOf(iface.(time.Duration).String())) } else { e.intv(tag, in) } case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: e.uintv(tag, in) case reflect.Float32, reflect.Float64: e.floatv(tag, in) case reflect.Bool: e.boolv(tag, in) default: panic("cannot marshal type: " + in.Type().String()) } } func (e *encoder) mapv(tag string, in reflect.Value) { e.mappingv(tag, func() { keys := keyList(in.MapKeys()) sort.Sort(keys) for _, k := range keys { e.marshal("", k) e.marshal("", in.MapIndex(k)) } }) } func (e *encoder) itemsv(tag string, in reflect.Value) { e.mappingv(tag, func() { slice := in.Convert(reflect.TypeOf([]MapItem{})).Interface().([]MapItem) for _, item := range slice { e.marshal("", reflect.ValueOf(item.Key)) e.marshal("", reflect.ValueOf(item.Value)) } }) } func (e *encoder) structv(tag string, in reflect.Value) { sinfo, err := getStructInfo(in.Type()) if err != nil { panic(err) } e.mappingv(tag, func() { for _, info := range sinfo.FieldsList { var value reflect.Value if info.Inline == nil { value = in.Field(info.Num) } else { value = in.FieldByIndex(info.Inline) } if info.OmitEmpty && isZero(value) { continue } e.marshal("", reflect.ValueOf(info.Key)) e.flow = info.Flow e.marshal("", value) } if sinfo.InlineMap >= 0 { m := in.Field(sinfo.InlineMap) if m.Len() > 0 { e.flow = false keys := keyList(m.MapKeys()) sort.Sort(keys) for _, k := range keys { if _, found := sinfo.FieldsMap[k.String()]; found { panic(fmt.Sprintf("Can't have key %q in inlined map; conflicts with struct field", k.String())) } e.marshal("", k) e.flow = false e.marshal("", m.MapIndex(k)) } } } }) } func (e *encoder) mappingv(tag string, f func()) { implicit := tag == "" style := yaml_BLOCK_MAPPING_STYLE if e.flow { e.flow = false style = yaml_FLOW_MAPPING_STYLE } yaml_mapping_start_event_initialize(&e.event, nil, []byte(tag), implicit, style) e.emit() f() yaml_mapping_end_event_initialize(&e.event) e.emit() } func (e *encoder) slicev(tag string, in reflect.Value) { implicit := tag == "" style := yaml_BLOCK_SEQUENCE_STYLE if e.flow { e.flow = false style = yaml_FLOW_SEQUENCE_STYLE } e.must(yaml_sequence_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)) e.emit() n := in.Len() for i := 0; i < n; i++ { e.marshal("", in.Index(i)) } e.must(yaml_sequence_end_event_initialize(&e.event)) e.emit() } // isBase60 returns whether s is in base 60 notation as defined in YAML 1.1. // // The base 60 float notation in YAML 1.1 is a terrible idea and is unsupported // in YAML 1.2 and by this package, but these should be marshalled quoted for // the time being for compatibility with other parsers. func isBase60Float(s string) (result bool) { // Fast path. if s == "" { return false } c := s[0] if !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 { return false } // Do the full match. return base60float.MatchString(s) } // From http://yaml.org/type/float.html, except the regular expression there // is bogus. In practice parsers do not enforce the "\.[0-9_]*" suffix. var base60float = regexp.MustCompile(`^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+(?:\.[0-9_]*)?$`) func (e *encoder) stringv(tag string, in reflect.Value) { var style yaml_scalar_style_t s := in.String() canUsePlain := true switch { case !utf8.ValidString(s): if tag == yaml_BINARY_TAG { failf("explicitly tagged !!binary data must be base64-encoded") } if tag != "" { failf("cannot marshal invalid UTF-8 data as %s", shortTag(tag)) } // It can't be encoded directly as YAML so use a binary tag // and encode it as base64. tag = yaml_BINARY_TAG s = encodeBase64(s) case tag == "": // Check to see if it would resolve to a specific // tag when encoded unquoted. If it doesn't, // there's no need to quote it. rtag, _ := resolve("", s) canUsePlain = rtag == yaml_STR_TAG && !isBase60Float(s) } // Note: it's possible for user code to emit invalid YAML // if they explicitly specify a tag and a string containing // text that's incompatible with that tag. switch { case strings.Contains(s, "\n"): style = yaml_LITERAL_SCALAR_STYLE case canUsePlain: style = yaml_PLAIN_SCALAR_STYLE default: style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } e.emitScalar(s, "", tag, style) } func (e *encoder) boolv(tag string, in reflect.Value) { var s string if in.Bool() { s = "true" } else { s = "false" } e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) } func (e *encoder) intv(tag string, in reflect.Value) { s := strconv.FormatInt(in.Int(), 10) e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) } func (e *encoder) uintv(tag string, in reflect.Value) { s := strconv.FormatUint(in.Uint(), 10) e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) } func (e *encoder) timev(tag string, in reflect.Value) { t := in.Interface().(time.Time) s := t.Format(time.RFC3339Nano) e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) } func (e *encoder) floatv(tag string, in reflect.Value) { // Issue #352: When formatting, use the precision of the underlying value precision := 64 if in.Kind() == reflect.Float32 { precision = 32 } s := strconv.FormatFloat(in.Float(), 'g', -1, precision) switch s { case "+Inf": s = ".inf" case "-Inf": s = "-.inf" case "NaN": s = ".nan" } e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) } func (e *encoder) nilv() { e.emitScalar("null", "", "", yaml_PLAIN_SCALAR_STYLE) } func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t) { implicit := tag == "" e.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style)) e.emit() }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/sorter.go
vendor/gopkg.in/yaml.v2/sorter.go
package yaml import ( "reflect" "unicode" ) type keyList []reflect.Value func (l keyList) Len() int { return len(l) } func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } func (l keyList) Less(i, j int) bool { a := l[i] b := l[j] ak := a.Kind() bk := b.Kind() for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { a = a.Elem() ak = a.Kind() } for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { b = b.Elem() bk = b.Kind() } af, aok := keyFloat(a) bf, bok := keyFloat(b) if aok && bok { if af != bf { return af < bf } if ak != bk { return ak < bk } return numLess(a, b) } if ak != reflect.String || bk != reflect.String { return ak < bk } ar, br := []rune(a.String()), []rune(b.String()) for i := 0; i < len(ar) && i < len(br); i++ { if ar[i] == br[i] { continue } al := unicode.IsLetter(ar[i]) bl := unicode.IsLetter(br[i]) if al && bl { return ar[i] < br[i] } if al || bl { return bl } var ai, bi int var an, bn int64 if ar[i] == '0' || br[i] == '0' { for j := i-1; j >= 0 && unicode.IsDigit(ar[j]); j-- { if ar[j] != '0' { an = 1 bn = 1 break } } } for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { an = an*10 + int64(ar[ai]-'0') } for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { bn = bn*10 + int64(br[bi]-'0') } if an != bn { return an < bn } if ai != bi { return ai < bi } return ar[i] < br[i] } return len(ar) < len(br) } // keyFloat returns a float value for v if it is a number/bool // and whether it is a number/bool or not. func keyFloat(v reflect.Value) (f float64, ok bool) { switch v.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return float64(v.Int()), true case reflect.Float32, reflect.Float64: return v.Float(), true case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return float64(v.Uint()), true case reflect.Bool: if v.Bool() { return 1, true } return 0, true } return 0, false } // numLess returns whether a < b. // a and b must necessarily have the same kind. func numLess(a, b reflect.Value) bool { switch a.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return a.Int() < b.Int() case reflect.Float32, reflect.Float64: return a.Float() < b.Float() case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return a.Uint() < b.Uint() case reflect.Bool: return !a.Bool() && b.Bool() } panic("not a number") }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/yamlprivateh.go
vendor/gopkg.in/yaml.v2/yamlprivateh.go
package yaml const ( // The size of the input raw buffer. input_raw_buffer_size = 512 // The size of the input buffer. // It should be possible to decode the whole raw buffer. input_buffer_size = input_raw_buffer_size * 3 // The size of the output buffer. output_buffer_size = 128 // The size of the output raw buffer. // It should be possible to encode the whole output buffer. output_raw_buffer_size = (output_buffer_size*2 + 2) // The size of other stacks and queues. initial_stack_size = 16 initial_queue_size = 16 initial_string_size = 16 ) // Check if the character at the specified position is an alphabetical // character, a digit, '_', or '-'. func is_alpha(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-' } // Check if the character at the specified position is a digit. func is_digit(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' } // Get the value of a digit. func as_digit(b []byte, i int) int { return int(b[i]) - '0' } // Check if the character at the specified position is a hex-digit. func is_hex(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f' } // Get the value of a hex-digit. func as_hex(b []byte, i int) int { bi := b[i] if bi >= 'A' && bi <= 'F' { return int(bi) - 'A' + 10 } if bi >= 'a' && bi <= 'f' { return int(bi) - 'a' + 10 } return int(bi) - '0' } // Check if the character is ASCII. func is_ascii(b []byte, i int) bool { return b[i] <= 0x7F } // Check if the character at the start of the buffer can be printed unescaped. func is_printable(b []byte, i int) bool { return ((b[i] == 0x0A) || // . == #x0A (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF (b[i] > 0xC2 && b[i] < 0xED) || (b[i] == 0xED && b[i+1] < 0xA0) || (b[i] == 0xEE) || (b[i] == 0xEF && // #xE000 <= . <= #xFFFD !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF)))) } // Check if the character at the specified position is NUL. func is_z(b []byte, i int) bool { return b[i] == 0x00 } // Check if the beginning of the buffer is a BOM. func is_bom(b []byte, i int) bool { return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF } // Check if the character at the specified position is space. func is_space(b []byte, i int) bool { return b[i] == ' ' } // Check if the character at the specified position is tab. func is_tab(b []byte, i int) bool { return b[i] == '\t' } // Check if the character at the specified position is blank (space or tab). func is_blank(b []byte, i int) bool { //return is_space(b, i) || is_tab(b, i) return b[i] == ' ' || b[i] == '\t' } // Check if the character at the specified position is a line break. func is_break(b []byte, i int) bool { return (b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029) } func is_crlf(b []byte, i int) bool { return b[i] == '\r' && b[i+1] == '\n' } // Check if the character is a line break or NUL. func is_breakz(b []byte, i int) bool { //return is_break(b, i) || is_z(b, i) return ( // is_break: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) // is_z: b[i] == 0) } // Check if the character is a line break, space, or NUL. func is_spacez(b []byte, i int) bool { //return is_space(b, i) || is_breakz(b, i) return ( // is_space: b[i] == ' ' || // is_breakz: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) b[i] == 0) } // Check if the character is a line break, space, tab, or NUL. func is_blankz(b []byte, i int) bool { //return is_blank(b, i) || is_breakz(b, i) return ( // is_blank: b[i] == ' ' || b[i] == '\t' || // is_breakz: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) b[i] == 0) } // Determine the width of the character. func width(b byte) int { // Don't replace these by a switch without first // confirming that it is being inlined. if b&0x80 == 0x00 { return 1 } if b&0xE0 == 0xC0 { return 2 } if b&0xF0 == 0xE0 { return 3 } if b&0xF8 == 0xF0 { return 4 } return 0 }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/readerc.go
vendor/gopkg.in/yaml.v2/readerc.go
package yaml import ( "io" ) // Set the reader error and return 0. func yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool { parser.error = yaml_READER_ERROR parser.problem = problem parser.problem_offset = offset parser.problem_value = value return false } // Byte order marks. const ( bom_UTF8 = "\xef\xbb\xbf" bom_UTF16LE = "\xff\xfe" bom_UTF16BE = "\xfe\xff" ) // Determine the input stream encoding by checking the BOM symbol. If no BOM is // found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure. func yaml_parser_determine_encoding(parser *yaml_parser_t) bool { // Ensure that we had enough bytes in the raw buffer. for !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 { if !yaml_parser_update_raw_buffer(parser) { return false } } // Determine the encoding. buf := parser.raw_buffer pos := parser.raw_buffer_pos avail := len(buf) - pos if avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] { parser.encoding = yaml_UTF16LE_ENCODING parser.raw_buffer_pos += 2 parser.offset += 2 } else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] { parser.encoding = yaml_UTF16BE_ENCODING parser.raw_buffer_pos += 2 parser.offset += 2 } else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] { parser.encoding = yaml_UTF8_ENCODING parser.raw_buffer_pos += 3 parser.offset += 3 } else { parser.encoding = yaml_UTF8_ENCODING } return true } // Update the raw buffer. func yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool { size_read := 0 // Return if the raw buffer is full. if parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) { return true } // Return on EOF. if parser.eof { return true } // Move the remaining bytes in the raw buffer to the beginning. if parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) { copy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:]) } parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos] parser.raw_buffer_pos = 0 // Call the read handler to fill the buffer. size_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)]) parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read] if err == io.EOF { parser.eof = true } else if err != nil { return yaml_parser_set_reader_error(parser, "input error: "+err.Error(), parser.offset, -1) } return true } // Ensure that the buffer contains at least `length` characters. // Return true on success, false on failure. // // The length is supposed to be significantly less that the buffer size. func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool { if parser.read_handler == nil { panic("read handler must be set") } // [Go] This function was changed to guarantee the requested length size at EOF. // The fact we need to do this is pretty awful, but the description above implies // for that to be the case, and there are tests // If the EOF flag is set and the raw buffer is empty, do nothing. if parser.eof && parser.raw_buffer_pos == len(parser.raw_buffer) { // [Go] ACTUALLY! Read the documentation of this function above. // This is just broken. To return true, we need to have the // given length in the buffer. Not doing that means every single // check that calls this function to make sure the buffer has a // given length is Go) panicking; or C) accessing invalid memory. //return true } // Return if the buffer contains enough characters. if parser.unread >= length { return true } // Determine the input encoding if it is not known yet. if parser.encoding == yaml_ANY_ENCODING { if !yaml_parser_determine_encoding(parser) { return false } } // Move the unread characters to the beginning of the buffer. buffer_len := len(parser.buffer) if parser.buffer_pos > 0 && parser.buffer_pos < buffer_len { copy(parser.buffer, parser.buffer[parser.buffer_pos:]) buffer_len -= parser.buffer_pos parser.buffer_pos = 0 } else if parser.buffer_pos == buffer_len { buffer_len = 0 parser.buffer_pos = 0 } // Open the whole buffer for writing, and cut it before returning. parser.buffer = parser.buffer[:cap(parser.buffer)] // Fill the buffer until it has enough characters. first := true for parser.unread < length { // Fill the raw buffer if necessary. if !first || parser.raw_buffer_pos == len(parser.raw_buffer) { if !yaml_parser_update_raw_buffer(parser) { parser.buffer = parser.buffer[:buffer_len] return false } } first = false // Decode the raw buffer. inner: for parser.raw_buffer_pos != len(parser.raw_buffer) { var value rune var width int raw_unread := len(parser.raw_buffer) - parser.raw_buffer_pos // Decode the next character. switch parser.encoding { case yaml_UTF8_ENCODING: // Decode a UTF-8 character. Check RFC 3629 // (http://www.ietf.org/rfc/rfc3629.txt) for more details. // // The following table (taken from the RFC) is used for // decoding. // // Char. number range | UTF-8 octet sequence // (hexadecimal) | (binary) // --------------------+------------------------------------ // 0000 0000-0000 007F | 0xxxxxxx // 0000 0080-0000 07FF | 110xxxxx 10xxxxxx // 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx // 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx // // Additionally, the characters in the range 0xD800-0xDFFF // are prohibited as they are reserved for use with UTF-16 // surrogate pairs. // Determine the length of the UTF-8 sequence. octet := parser.raw_buffer[parser.raw_buffer_pos] switch { case octet&0x80 == 0x00: width = 1 case octet&0xE0 == 0xC0: width = 2 case octet&0xF0 == 0xE0: width = 3 case octet&0xF8 == 0xF0: width = 4 default: // The leading octet is invalid. return yaml_parser_set_reader_error(parser, "invalid leading UTF-8 octet", parser.offset, int(octet)) } // Check if the raw buffer contains an incomplete character. if width > raw_unread { if parser.eof { return yaml_parser_set_reader_error(parser, "incomplete UTF-8 octet sequence", parser.offset, -1) } break inner } // Decode the leading octet. switch { case octet&0x80 == 0x00: value = rune(octet & 0x7F) case octet&0xE0 == 0xC0: value = rune(octet & 0x1F) case octet&0xF0 == 0xE0: value = rune(octet & 0x0F) case octet&0xF8 == 0xF0: value = rune(octet & 0x07) default: value = 0 } // Check and decode the trailing octets. for k := 1; k < width; k++ { octet = parser.raw_buffer[parser.raw_buffer_pos+k] // Check if the octet is valid. if (octet & 0xC0) != 0x80 { return yaml_parser_set_reader_error(parser, "invalid trailing UTF-8 octet", parser.offset+k, int(octet)) } // Decode the octet. value = (value << 6) + rune(octet&0x3F) } // Check the length of the sequence against the value. switch { case width == 1: case width == 2 && value >= 0x80: case width == 3 && value >= 0x800: case width == 4 && value >= 0x10000: default: return yaml_parser_set_reader_error(parser, "invalid length of a UTF-8 sequence", parser.offset, -1) } // Check the range of the value. if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF { return yaml_parser_set_reader_error(parser, "invalid Unicode character", parser.offset, int(value)) } case yaml_UTF16LE_ENCODING, yaml_UTF16BE_ENCODING: var low, high int if parser.encoding == yaml_UTF16LE_ENCODING { low, high = 0, 1 } else { low, high = 1, 0 } // The UTF-16 encoding is not as simple as one might // naively think. Check RFC 2781 // (http://www.ietf.org/rfc/rfc2781.txt). // // Normally, two subsequent bytes describe a Unicode // character. However a special technique (called a // surrogate pair) is used for specifying character // values larger than 0xFFFF. // // A surrogate pair consists of two pseudo-characters: // high surrogate area (0xD800-0xDBFF) // low surrogate area (0xDC00-0xDFFF) // // The following formulas are used for decoding // and encoding characters using surrogate pairs: // // U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF) // U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF) // W1 = 110110yyyyyyyyyy // W2 = 110111xxxxxxxxxx // // where U is the character value, W1 is the high surrogate // area, W2 is the low surrogate area. // Check for incomplete UTF-16 character. if raw_unread < 2 { if parser.eof { return yaml_parser_set_reader_error(parser, "incomplete UTF-16 character", parser.offset, -1) } break inner } // Get the character. value = rune(parser.raw_buffer[parser.raw_buffer_pos+low]) + (rune(parser.raw_buffer[parser.raw_buffer_pos+high]) << 8) // Check for unexpected low surrogate area. if value&0xFC00 == 0xDC00 { return yaml_parser_set_reader_error(parser, "unexpected low surrogate area", parser.offset, int(value)) } // Check for a high surrogate area. if value&0xFC00 == 0xD800 { width = 4 // Check for incomplete surrogate pair. if raw_unread < 4 { if parser.eof { return yaml_parser_set_reader_error(parser, "incomplete UTF-16 surrogate pair", parser.offset, -1) } break inner } // Get the next character. value2 := rune(parser.raw_buffer[parser.raw_buffer_pos+low+2]) + (rune(parser.raw_buffer[parser.raw_buffer_pos+high+2]) << 8) // Check for a low surrogate area. if value2&0xFC00 != 0xDC00 { return yaml_parser_set_reader_error(parser, "expected low surrogate area", parser.offset+2, int(value2)) } // Generate the value of the surrogate pair. value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF) } else { width = 2 } default: panic("impossible") } // Check if the character is in the allowed range: // #x9 | #xA | #xD | [#x20-#x7E] (8 bit) // | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit) // | [#x10000-#x10FFFF] (32 bit) switch { case value == 0x09: case value == 0x0A: case value == 0x0D: case value >= 0x20 && value <= 0x7E: case value == 0x85: case value >= 0xA0 && value <= 0xD7FF: case value >= 0xE000 && value <= 0xFFFD: case value >= 0x10000 && value <= 0x10FFFF: default: return yaml_parser_set_reader_error(parser, "control characters are not allowed", parser.offset, int(value)) } // Move the raw pointers. parser.raw_buffer_pos += width parser.offset += width // Finally put the character into the buffer. if value <= 0x7F { // 0000 0000-0000 007F . 0xxxxxxx parser.buffer[buffer_len+0] = byte(value) buffer_len += 1 } else if value <= 0x7FF { // 0000 0080-0000 07FF . 110xxxxx 10xxxxxx parser.buffer[buffer_len+0] = byte(0xC0 + (value >> 6)) parser.buffer[buffer_len+1] = byte(0x80 + (value & 0x3F)) buffer_len += 2 } else if value <= 0xFFFF { // 0000 0800-0000 FFFF . 1110xxxx 10xxxxxx 10xxxxxx parser.buffer[buffer_len+0] = byte(0xE0 + (value >> 12)) parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 6) & 0x3F)) parser.buffer[buffer_len+2] = byte(0x80 + (value & 0x3F)) buffer_len += 3 } else { // 0001 0000-0010 FFFF . 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx parser.buffer[buffer_len+0] = byte(0xF0 + (value >> 18)) parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 12) & 0x3F)) parser.buffer[buffer_len+2] = byte(0x80 + ((value >> 6) & 0x3F)) parser.buffer[buffer_len+3] = byte(0x80 + (value & 0x3F)) buffer_len += 4 } parser.unread++ } // On EOF, put NUL into the buffer and return. if parser.eof { parser.buffer[buffer_len] = 0 buffer_len++ parser.unread++ break } } // [Go] Read the documentation of this function above. To return true, // we need to have the given length in the buffer. Not doing that means // every single check that calls this function to make sure the buffer // has a given length is Go) panicking; or C) accessing invalid memory. // This happens here due to the EOF above breaking early. for buffer_len < length { parser.buffer[buffer_len] = 0 buffer_len++ } parser.buffer = parser.buffer[:buffer_len] return true }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/writerc.go
vendor/gopkg.in/yaml.v2/writerc.go
package yaml // Set the writer error and return false. func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { emitter.error = yaml_WRITER_ERROR emitter.problem = problem return false } // Flush the output buffer. func yaml_emitter_flush(emitter *yaml_emitter_t) bool { if emitter.write_handler == nil { panic("write handler not set") } // Check if the buffer is empty. if emitter.buffer_pos == 0 { return true } if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) } emitter.buffer_pos = 0 return true }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/yamlh.go
vendor/gopkg.in/yaml.v2/yamlh.go
package yaml import ( "fmt" "io" ) // The version directive data. type yaml_version_directive_t struct { major int8 // The major version number. minor int8 // The minor version number. } // The tag directive data. type yaml_tag_directive_t struct { handle []byte // The tag handle. prefix []byte // The tag prefix. } type yaml_encoding_t int // The stream encoding. const ( // Let the parser choose the encoding. yaml_ANY_ENCODING yaml_encoding_t = iota yaml_UTF8_ENCODING // The default UTF-8 encoding. yaml_UTF16LE_ENCODING // The UTF-16-LE encoding with BOM. yaml_UTF16BE_ENCODING // The UTF-16-BE encoding with BOM. ) type yaml_break_t int // Line break types. const ( // Let the parser choose the break type. yaml_ANY_BREAK yaml_break_t = iota yaml_CR_BREAK // Use CR for line breaks (Mac style). yaml_LN_BREAK // Use LN for line breaks (Unix style). yaml_CRLN_BREAK // Use CR LN for line breaks (DOS style). ) type yaml_error_type_t int // Many bad things could happen with the parser and emitter. const ( // No error is produced. yaml_NO_ERROR yaml_error_type_t = iota yaml_MEMORY_ERROR // Cannot allocate or reallocate a block of memory. yaml_READER_ERROR // Cannot read or decode the input stream. yaml_SCANNER_ERROR // Cannot scan the input stream. yaml_PARSER_ERROR // Cannot parse the input stream. yaml_COMPOSER_ERROR // Cannot compose a YAML document. yaml_WRITER_ERROR // Cannot write to the output stream. yaml_EMITTER_ERROR // Cannot emit a YAML stream. ) // The pointer position. type yaml_mark_t struct { index int // The position index. line int // The position line. column int // The position column. } // Node Styles type yaml_style_t int8 type yaml_scalar_style_t yaml_style_t // Scalar styles. const ( // Let the emitter choose the style. yaml_ANY_SCALAR_STYLE yaml_scalar_style_t = iota yaml_PLAIN_SCALAR_STYLE // The plain scalar style. yaml_SINGLE_QUOTED_SCALAR_STYLE // The single-quoted scalar style. yaml_DOUBLE_QUOTED_SCALAR_STYLE // The double-quoted scalar style. yaml_LITERAL_SCALAR_STYLE // The literal scalar style. yaml_FOLDED_SCALAR_STYLE // The folded scalar style. ) type yaml_sequence_style_t yaml_style_t // Sequence styles. const ( // Let the emitter choose the style. yaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota yaml_BLOCK_SEQUENCE_STYLE // The block sequence style. yaml_FLOW_SEQUENCE_STYLE // The flow sequence style. ) type yaml_mapping_style_t yaml_style_t // Mapping styles. const ( // Let the emitter choose the style. yaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota yaml_BLOCK_MAPPING_STYLE // The block mapping style. yaml_FLOW_MAPPING_STYLE // The flow mapping style. ) // Tokens type yaml_token_type_t int // Token types. const ( // An empty token. yaml_NO_TOKEN yaml_token_type_t = iota yaml_STREAM_START_TOKEN // A STREAM-START token. yaml_STREAM_END_TOKEN // A STREAM-END token. yaml_VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token. yaml_TAG_DIRECTIVE_TOKEN // A TAG-DIRECTIVE token. yaml_DOCUMENT_START_TOKEN // A DOCUMENT-START token. yaml_DOCUMENT_END_TOKEN // A DOCUMENT-END token. yaml_BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token. yaml_BLOCK_MAPPING_START_TOKEN // A BLOCK-SEQUENCE-END token. yaml_BLOCK_END_TOKEN // A BLOCK-END token. yaml_FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token. yaml_FLOW_SEQUENCE_END_TOKEN // A FLOW-SEQUENCE-END token. yaml_FLOW_MAPPING_START_TOKEN // A FLOW-MAPPING-START token. yaml_FLOW_MAPPING_END_TOKEN // A FLOW-MAPPING-END token. yaml_BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token. yaml_FLOW_ENTRY_TOKEN // A FLOW-ENTRY token. yaml_KEY_TOKEN // A KEY token. yaml_VALUE_TOKEN // A VALUE token. yaml_ALIAS_TOKEN // An ALIAS token. yaml_ANCHOR_TOKEN // An ANCHOR token. yaml_TAG_TOKEN // A TAG token. yaml_SCALAR_TOKEN // A SCALAR token. ) func (tt yaml_token_type_t) String() string { switch tt { case yaml_NO_TOKEN: return "yaml_NO_TOKEN" case yaml_STREAM_START_TOKEN: return "yaml_STREAM_START_TOKEN" case yaml_STREAM_END_TOKEN: return "yaml_STREAM_END_TOKEN" case yaml_VERSION_DIRECTIVE_TOKEN: return "yaml_VERSION_DIRECTIVE_TOKEN" case yaml_TAG_DIRECTIVE_TOKEN: return "yaml_TAG_DIRECTIVE_TOKEN" case yaml_DOCUMENT_START_TOKEN: return "yaml_DOCUMENT_START_TOKEN" case yaml_DOCUMENT_END_TOKEN: return "yaml_DOCUMENT_END_TOKEN" case yaml_BLOCK_SEQUENCE_START_TOKEN: return "yaml_BLOCK_SEQUENCE_START_TOKEN" case yaml_BLOCK_MAPPING_START_TOKEN: return "yaml_BLOCK_MAPPING_START_TOKEN" case yaml_BLOCK_END_TOKEN: return "yaml_BLOCK_END_TOKEN" case yaml_FLOW_SEQUENCE_START_TOKEN: return "yaml_FLOW_SEQUENCE_START_TOKEN" case yaml_FLOW_SEQUENCE_END_TOKEN: return "yaml_FLOW_SEQUENCE_END_TOKEN" case yaml_FLOW_MAPPING_START_TOKEN: return "yaml_FLOW_MAPPING_START_TOKEN" case yaml_FLOW_MAPPING_END_TOKEN: return "yaml_FLOW_MAPPING_END_TOKEN" case yaml_BLOCK_ENTRY_TOKEN: return "yaml_BLOCK_ENTRY_TOKEN" case yaml_FLOW_ENTRY_TOKEN: return "yaml_FLOW_ENTRY_TOKEN" case yaml_KEY_TOKEN: return "yaml_KEY_TOKEN" case yaml_VALUE_TOKEN: return "yaml_VALUE_TOKEN" case yaml_ALIAS_TOKEN: return "yaml_ALIAS_TOKEN" case yaml_ANCHOR_TOKEN: return "yaml_ANCHOR_TOKEN" case yaml_TAG_TOKEN: return "yaml_TAG_TOKEN" case yaml_SCALAR_TOKEN: return "yaml_SCALAR_TOKEN" } return "<unknown token>" } // The token structure. type yaml_token_t struct { // The token type. typ yaml_token_type_t // The start/end of the token. start_mark, end_mark yaml_mark_t // The stream encoding (for yaml_STREAM_START_TOKEN). encoding yaml_encoding_t // The alias/anchor/scalar value or tag/tag directive handle // (for yaml_ALIAS_TOKEN, yaml_ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN). value []byte // The tag suffix (for yaml_TAG_TOKEN). suffix []byte // The tag directive prefix (for yaml_TAG_DIRECTIVE_TOKEN). prefix []byte // The scalar style (for yaml_SCALAR_TOKEN). style yaml_scalar_style_t // The version directive major/minor (for yaml_VERSION_DIRECTIVE_TOKEN). major, minor int8 } // Events type yaml_event_type_t int8 // Event types. const ( // An empty event. yaml_NO_EVENT yaml_event_type_t = iota yaml_STREAM_START_EVENT // A STREAM-START event. yaml_STREAM_END_EVENT // A STREAM-END event. yaml_DOCUMENT_START_EVENT // A DOCUMENT-START event. yaml_DOCUMENT_END_EVENT // A DOCUMENT-END event. yaml_ALIAS_EVENT // An ALIAS event. yaml_SCALAR_EVENT // A SCALAR event. yaml_SEQUENCE_START_EVENT // A SEQUENCE-START event. yaml_SEQUENCE_END_EVENT // A SEQUENCE-END event. yaml_MAPPING_START_EVENT // A MAPPING-START event. yaml_MAPPING_END_EVENT // A MAPPING-END event. ) var eventStrings = []string{ yaml_NO_EVENT: "none", yaml_STREAM_START_EVENT: "stream start", yaml_STREAM_END_EVENT: "stream end", yaml_DOCUMENT_START_EVENT: "document start", yaml_DOCUMENT_END_EVENT: "document end", yaml_ALIAS_EVENT: "alias", yaml_SCALAR_EVENT: "scalar", yaml_SEQUENCE_START_EVENT: "sequence start", yaml_SEQUENCE_END_EVENT: "sequence end", yaml_MAPPING_START_EVENT: "mapping start", yaml_MAPPING_END_EVENT: "mapping end", } func (e yaml_event_type_t) String() string { if e < 0 || int(e) >= len(eventStrings) { return fmt.Sprintf("unknown event %d", e) } return eventStrings[e] } // The event structure. type yaml_event_t struct { // The event type. typ yaml_event_type_t // The start and end of the event. start_mark, end_mark yaml_mark_t // The document encoding (for yaml_STREAM_START_EVENT). encoding yaml_encoding_t // The version directive (for yaml_DOCUMENT_START_EVENT). version_directive *yaml_version_directive_t // The list of tag directives (for yaml_DOCUMENT_START_EVENT). tag_directives []yaml_tag_directive_t // The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT). anchor []byte // The tag (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). tag []byte // The scalar value (for yaml_SCALAR_EVENT). value []byte // Is the document start/end indicator implicit, or the tag optional? // (for yaml_DOCUMENT_START_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_SCALAR_EVENT). implicit bool // Is the tag optional for any non-plain style? (for yaml_SCALAR_EVENT). quoted_implicit bool // The style (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). style yaml_style_t } func (e *yaml_event_t) scalar_style() yaml_scalar_style_t { return yaml_scalar_style_t(e.style) } func (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) } func (e *yaml_event_t) mapping_style() yaml_mapping_style_t { return yaml_mapping_style_t(e.style) } // Nodes const ( yaml_NULL_TAG = "tag:yaml.org,2002:null" // The tag !!null with the only possible value: null. yaml_BOOL_TAG = "tag:yaml.org,2002:bool" // The tag !!bool with the values: true and false. yaml_STR_TAG = "tag:yaml.org,2002:str" // The tag !!str for string values. yaml_INT_TAG = "tag:yaml.org,2002:int" // The tag !!int for integer values. yaml_FLOAT_TAG = "tag:yaml.org,2002:float" // The tag !!float for float values. yaml_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp" // The tag !!timestamp for date and time values. yaml_SEQ_TAG = "tag:yaml.org,2002:seq" // The tag !!seq is used to denote sequences. yaml_MAP_TAG = "tag:yaml.org,2002:map" // The tag !!map is used to denote mapping. // Not in original libyaml. yaml_BINARY_TAG = "tag:yaml.org,2002:binary" yaml_MERGE_TAG = "tag:yaml.org,2002:merge" yaml_DEFAULT_SCALAR_TAG = yaml_STR_TAG // The default scalar tag is !!str. yaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG // The default sequence tag is !!seq. yaml_DEFAULT_MAPPING_TAG = yaml_MAP_TAG // The default mapping tag is !!map. ) type yaml_node_type_t int // Node types. const ( // An empty node. yaml_NO_NODE yaml_node_type_t = iota yaml_SCALAR_NODE // A scalar node. yaml_SEQUENCE_NODE // A sequence node. yaml_MAPPING_NODE // A mapping node. ) // An element of a sequence node. type yaml_node_item_t int // An element of a mapping node. type yaml_node_pair_t struct { key int // The key of the element. value int // The value of the element. } // The node structure. type yaml_node_t struct { typ yaml_node_type_t // The node type. tag []byte // The node tag. // The node data. // The scalar parameters (for yaml_SCALAR_NODE). scalar struct { value []byte // The scalar value. length int // The length of the scalar value. style yaml_scalar_style_t // The scalar style. } // The sequence parameters (for YAML_SEQUENCE_NODE). sequence struct { items_data []yaml_node_item_t // The stack of sequence items. style yaml_sequence_style_t // The sequence style. } // The mapping parameters (for yaml_MAPPING_NODE). mapping struct { pairs_data []yaml_node_pair_t // The stack of mapping pairs (key, value). pairs_start *yaml_node_pair_t // The beginning of the stack. pairs_end *yaml_node_pair_t // The end of the stack. pairs_top *yaml_node_pair_t // The top of the stack. style yaml_mapping_style_t // The mapping style. } start_mark yaml_mark_t // The beginning of the node. end_mark yaml_mark_t // The end of the node. } // The document structure. type yaml_document_t struct { // The document nodes. nodes []yaml_node_t // The version directive. version_directive *yaml_version_directive_t // The list of tag directives. tag_directives_data []yaml_tag_directive_t tag_directives_start int // The beginning of the tag directives list. tag_directives_end int // The end of the tag directives list. start_implicit int // Is the document start indicator implicit? end_implicit int // Is the document end indicator implicit? // The start/end of the document. start_mark, end_mark yaml_mark_t } // The prototype of a read handler. // // The read handler is called when the parser needs to read more bytes from the // source. The handler should write not more than size bytes to the buffer. // The number of written bytes should be set to the size_read variable. // // [in,out] data A pointer to an application data specified by // yaml_parser_set_input(). // [out] buffer The buffer to write the data from the source. // [in] size The size of the buffer. // [out] size_read The actual number of bytes read from the source. // // On success, the handler should return 1. If the handler failed, // the returned value should be 0. On EOF, the handler should set the // size_read to 0 and return 1. type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error) // This structure holds information about a potential simple key. type yaml_simple_key_t struct { possible bool // Is a simple key possible? required bool // Is a simple key required? token_number int // The number of the token. mark yaml_mark_t // The position mark. } // The states of the parser. type yaml_parser_state_t int const ( yaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE // Expect the beginning of an implicit document. yaml_PARSE_DOCUMENT_START_STATE // Expect DOCUMENT-START. yaml_PARSE_DOCUMENT_CONTENT_STATE // Expect the content of a document. yaml_PARSE_DOCUMENT_END_STATE // Expect DOCUMENT-END. yaml_PARSE_BLOCK_NODE_STATE // Expect a block node. yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE // Expect a block node or indentless sequence. yaml_PARSE_FLOW_NODE_STATE // Expect a flow node. yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a block sequence. yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE // Expect an entry of a block sequence. yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE // Expect an entry of an indentless sequence. yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. yaml_PARSE_BLOCK_MAPPING_KEY_STATE // Expect a block mapping key. yaml_PARSE_BLOCK_MAPPING_VALUE_STATE // Expect a block mapping value. yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a flow sequence. yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE // Expect an entry of a flow sequence. yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE // Expect a key of an ordered mapping. yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE // Expect a value of an ordered mapping. yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE // Expect the and of an ordered mapping entry. yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. yaml_PARSE_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. yaml_PARSE_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE // Expect an empty value of a flow mapping. yaml_PARSE_END_STATE // Expect nothing. ) func (ps yaml_parser_state_t) String() string { switch ps { case yaml_PARSE_STREAM_START_STATE: return "yaml_PARSE_STREAM_START_STATE" case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: return "yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE" case yaml_PARSE_DOCUMENT_START_STATE: return "yaml_PARSE_DOCUMENT_START_STATE" case yaml_PARSE_DOCUMENT_CONTENT_STATE: return "yaml_PARSE_DOCUMENT_CONTENT_STATE" case yaml_PARSE_DOCUMENT_END_STATE: return "yaml_PARSE_DOCUMENT_END_STATE" case yaml_PARSE_BLOCK_NODE_STATE: return "yaml_PARSE_BLOCK_NODE_STATE" case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: return "yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE" case yaml_PARSE_FLOW_NODE_STATE: return "yaml_PARSE_FLOW_NODE_STATE" case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: return "yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE" case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: return "yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE" case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: return "yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE" case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: return "yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE" case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: return "yaml_PARSE_BLOCK_MAPPING_KEY_STATE" case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: return "yaml_PARSE_BLOCK_MAPPING_VALUE_STATE" case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: return "yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE" case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE" case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE" case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE" case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE" case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: return "yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE" case yaml_PARSE_FLOW_MAPPING_KEY_STATE: return "yaml_PARSE_FLOW_MAPPING_KEY_STATE" case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: return "yaml_PARSE_FLOW_MAPPING_VALUE_STATE" case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: return "yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE" case yaml_PARSE_END_STATE: return "yaml_PARSE_END_STATE" } return "<unknown parser state>" } // This structure holds aliases data. type yaml_alias_data_t struct { anchor []byte // The anchor. index int // The node id. mark yaml_mark_t // The anchor mark. } // The parser structure. // // All members are internal. Manage the structure using the // yaml_parser_ family of functions. type yaml_parser_t struct { // Error handling error yaml_error_type_t // Error type. problem string // Error description. // The byte about which the problem occurred. problem_offset int problem_value int problem_mark yaml_mark_t // The error context. context string context_mark yaml_mark_t // Reader stuff read_handler yaml_read_handler_t // Read handler. input_reader io.Reader // File input data. input []byte // String input data. input_pos int eof bool // EOF flag buffer []byte // The working buffer. buffer_pos int // The current position of the buffer. unread int // The number of unread characters in the buffer. raw_buffer []byte // The raw buffer. raw_buffer_pos int // The current position of the buffer. encoding yaml_encoding_t // The input encoding. offset int // The offset of the current position (in bytes). mark yaml_mark_t // The mark of the current position. // Scanner stuff stream_start_produced bool // Have we started to scan the input stream? stream_end_produced bool // Have we reached the end of the input stream? flow_level int // The number of unclosed '[' and '{' indicators. tokens []yaml_token_t // The tokens queue. tokens_head int // The head of the tokens queue. tokens_parsed int // The number of tokens fetched from the queue. token_available bool // Does the tokens queue contain a token ready for dequeueing. indent int // The current indentation level. indents []int // The indentation levels stack. simple_key_allowed bool // May a simple key occur at the current position? simple_keys []yaml_simple_key_t // The stack of simple keys. simple_keys_by_tok map[int]int // possible simple_key indexes indexed by token_number // Parser stuff state yaml_parser_state_t // The current parser state. states []yaml_parser_state_t // The parser states stack. marks []yaml_mark_t // The stack of marks. tag_directives []yaml_tag_directive_t // The list of TAG directives. // Dumper stuff aliases []yaml_alias_data_t // The alias data. document *yaml_document_t // The currently parsed document. } // Emitter Definitions // The prototype of a write handler. // // The write handler is called when the emitter needs to flush the accumulated // characters to the output. The handler should write @a size bytes of the // @a buffer to the output. // // @param[in,out] data A pointer to an application data specified by // yaml_emitter_set_output(). // @param[in] buffer The buffer with bytes to be written. // @param[in] size The size of the buffer. // // @returns On success, the handler should return @c 1. If the handler failed, // the returned value should be @c 0. // type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error type yaml_emitter_state_t int // The emitter states. const ( // Expect STREAM-START. yaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota yaml_EMIT_FIRST_DOCUMENT_START_STATE // Expect the first DOCUMENT-START or STREAM-END. yaml_EMIT_DOCUMENT_START_STATE // Expect DOCUMENT-START or STREAM-END. yaml_EMIT_DOCUMENT_CONTENT_STATE // Expect the content of a document. yaml_EMIT_DOCUMENT_END_STATE // Expect DOCUMENT-END. yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a flow sequence. yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE // Expect an item of a flow sequence. yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. yaml_EMIT_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a flow mapping. yaml_EMIT_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a block sequence. yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE // Expect an item of a block sequence. yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. yaml_EMIT_BLOCK_MAPPING_KEY_STATE // Expect the key of a block mapping. yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a block mapping. yaml_EMIT_BLOCK_MAPPING_VALUE_STATE // Expect a value of a block mapping. yaml_EMIT_END_STATE // Expect nothing. ) // The emitter structure. // // All members are internal. Manage the structure using the @c yaml_emitter_ // family of functions. type yaml_emitter_t struct { // Error handling error yaml_error_type_t // Error type. problem string // Error description. // Writer stuff write_handler yaml_write_handler_t // Write handler. output_buffer *[]byte // String output data. output_writer io.Writer // File output data. buffer []byte // The working buffer. buffer_pos int // The current position of the buffer. raw_buffer []byte // The raw buffer. raw_buffer_pos int // The current position of the buffer. encoding yaml_encoding_t // The stream encoding. // Emitter stuff canonical bool // If the output is in the canonical style? best_indent int // The number of indentation spaces. best_width int // The preferred width of the output lines. unicode bool // Allow unescaped non-ASCII characters? line_break yaml_break_t // The preferred line break. state yaml_emitter_state_t // The current emitter state. states []yaml_emitter_state_t // The stack of states. events []yaml_event_t // The event queue. events_head int // The head of the event queue. indents []int // The stack of indentation levels. tag_directives []yaml_tag_directive_t // The list of tag directives. indent int // The current indentation level. flow_level int // The current flow level. root_context bool // Is it the document root context? sequence_context bool // Is it a sequence context? mapping_context bool // Is it a mapping context? simple_key_context bool // Is it a simple mapping key context? line int // The current line. column int // The current column. whitespace bool // If the last character was a whitespace? indention bool // If the last character was an indentation character (' ', '-', '?', ':')? open_ended bool // If an explicit document end is required? // Anchor analysis. anchor_data struct { anchor []byte // The anchor value. alias bool // Is it an alias? } // Tag analysis. tag_data struct { handle []byte // The tag handle. suffix []byte // The tag suffix. } // Scalar analysis. scalar_data struct { value []byte // The scalar value. multiline bool // Does the scalar contain line breaks? flow_plain_allowed bool // Can the scalar be expessed in the flow plain style? block_plain_allowed bool // Can the scalar be expressed in the block plain style? single_quoted_allowed bool // Can the scalar be expressed in the single quoted style? block_allowed bool // Can the scalar be expressed in the literal or folded styles? style yaml_scalar_style_t // The output style. } // Dumper stuff opened bool // If the stream was already opened? closed bool // If the stream was already closed? // The information associated with the document nodes. anchors *struct { references int // The number of references. anchor int // The anchor id. serialized bool // If the node has been emitted? } last_anchor_id int // The last assigned anchor id. document *yaml_document_t // The currently emitted document. }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/scannerc.go
vendor/gopkg.in/yaml.v2/scannerc.go
package yaml import ( "bytes" "fmt" ) // Introduction // ************ // // The following notes assume that you are familiar with the YAML specification // (http://yaml.org/spec/1.2/spec.html). We mostly follow it, although in // some cases we are less restrictive that it requires. // // The process of transforming a YAML stream into a sequence of events is // divided on two steps: Scanning and Parsing. // // The Scanner transforms the input stream into a sequence of tokens, while the // parser transform the sequence of tokens produced by the Scanner into a // sequence of parsing events. // // The Scanner is rather clever and complicated. The Parser, on the contrary, // is a straightforward implementation of a recursive-descendant parser (or, // LL(1) parser, as it is usually called). // // Actually there are two issues of Scanning that might be called "clever", the // rest is quite straightforward. The issues are "block collection start" and // "simple keys". Both issues are explained below in details. // // Here the Scanning step is explained and implemented. We start with the list // of all the tokens produced by the Scanner together with short descriptions. // // Now, tokens: // // STREAM-START(encoding) # The stream start. // STREAM-END # The stream end. // VERSION-DIRECTIVE(major,minor) # The '%YAML' directive. // TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive. // DOCUMENT-START # '---' // DOCUMENT-END # '...' // BLOCK-SEQUENCE-START # Indentation increase denoting a block // BLOCK-MAPPING-START # sequence or a block mapping. // BLOCK-END # Indentation decrease. // FLOW-SEQUENCE-START # '[' // FLOW-SEQUENCE-END # ']' // BLOCK-SEQUENCE-START # '{' // BLOCK-SEQUENCE-END # '}' // BLOCK-ENTRY # '-' // FLOW-ENTRY # ',' // KEY # '?' or nothing (simple keys). // VALUE # ':' // ALIAS(anchor) # '*anchor' // ANCHOR(anchor) # '&anchor' // TAG(handle,suffix) # '!handle!suffix' // SCALAR(value,style) # A scalar. // // The following two tokens are "virtual" tokens denoting the beginning and the // end of the stream: // // STREAM-START(encoding) // STREAM-END // // We pass the information about the input stream encoding with the // STREAM-START token. // // The next two tokens are responsible for tags: // // VERSION-DIRECTIVE(major,minor) // TAG-DIRECTIVE(handle,prefix) // // Example: // // %YAML 1.1 // %TAG ! !foo // %TAG !yaml! tag:yaml.org,2002: // --- // // The correspoding sequence of tokens: // // STREAM-START(utf-8) // VERSION-DIRECTIVE(1,1) // TAG-DIRECTIVE("!","!foo") // TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:") // DOCUMENT-START // STREAM-END // // Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole // line. // // The document start and end indicators are represented by: // // DOCUMENT-START // DOCUMENT-END // // Note that if a YAML stream contains an implicit document (without '---' // and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be // produced. // // In the following examples, we present whole documents together with the // produced tokens. // // 1. An implicit document: // // 'a scalar' // // Tokens: // // STREAM-START(utf-8) // SCALAR("a scalar",single-quoted) // STREAM-END // // 2. An explicit document: // // --- // 'a scalar' // ... // // Tokens: // // STREAM-START(utf-8) // DOCUMENT-START // SCALAR("a scalar",single-quoted) // DOCUMENT-END // STREAM-END // // 3. Several documents in a stream: // // 'a scalar' // --- // 'another scalar' // --- // 'yet another scalar' // // Tokens: // // STREAM-START(utf-8) // SCALAR("a scalar",single-quoted) // DOCUMENT-START // SCALAR("another scalar",single-quoted) // DOCUMENT-START // SCALAR("yet another scalar",single-quoted) // STREAM-END // // We have already introduced the SCALAR token above. The following tokens are // used to describe aliases, anchors, tag, and scalars: // // ALIAS(anchor) // ANCHOR(anchor) // TAG(handle,suffix) // SCALAR(value,style) // // The following series of examples illustrate the usage of these tokens: // // 1. A recursive sequence: // // &A [ *A ] // // Tokens: // // STREAM-START(utf-8) // ANCHOR("A") // FLOW-SEQUENCE-START // ALIAS("A") // FLOW-SEQUENCE-END // STREAM-END // // 2. A tagged scalar: // // !!float "3.14" # A good approximation. // // Tokens: // // STREAM-START(utf-8) // TAG("!!","float") // SCALAR("3.14",double-quoted) // STREAM-END // // 3. Various scalar styles: // // --- # Implicit empty plain scalars do not produce tokens. // --- a plain scalar // --- 'a single-quoted scalar' // --- "a double-quoted scalar" // --- |- // a literal scalar // --- >- // a folded // scalar // // Tokens: // // STREAM-START(utf-8) // DOCUMENT-START // DOCUMENT-START // SCALAR("a plain scalar",plain) // DOCUMENT-START // SCALAR("a single-quoted scalar",single-quoted) // DOCUMENT-START // SCALAR("a double-quoted scalar",double-quoted) // DOCUMENT-START // SCALAR("a literal scalar",literal) // DOCUMENT-START // SCALAR("a folded scalar",folded) // STREAM-END // // Now it's time to review collection-related tokens. We will start with // flow collections: // // FLOW-SEQUENCE-START // FLOW-SEQUENCE-END // FLOW-MAPPING-START // FLOW-MAPPING-END // FLOW-ENTRY // KEY // VALUE // // The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and // FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}' // correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the // indicators '?' and ':', which are used for denoting mapping keys and values, // are represented by the KEY and VALUE tokens. // // The following examples show flow collections: // // 1. A flow sequence: // // [item 1, item 2, item 3] // // Tokens: // // STREAM-START(utf-8) // FLOW-SEQUENCE-START // SCALAR("item 1",plain) // FLOW-ENTRY // SCALAR("item 2",plain) // FLOW-ENTRY // SCALAR("item 3",plain) // FLOW-SEQUENCE-END // STREAM-END // // 2. A flow mapping: // // { // a simple key: a value, # Note that the KEY token is produced. // ? a complex key: another value, // } // // Tokens: // // STREAM-START(utf-8) // FLOW-MAPPING-START // KEY // SCALAR("a simple key",plain) // VALUE // SCALAR("a value",plain) // FLOW-ENTRY // KEY // SCALAR("a complex key",plain) // VALUE // SCALAR("another value",plain) // FLOW-ENTRY // FLOW-MAPPING-END // STREAM-END // // A simple key is a key which is not denoted by the '?' indicator. Note that // the Scanner still produce the KEY token whenever it encounters a simple key. // // For scanning block collections, the following tokens are used (note that we // repeat KEY and VALUE here): // // BLOCK-SEQUENCE-START // BLOCK-MAPPING-START // BLOCK-END // BLOCK-ENTRY // KEY // VALUE // // The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation // increase that precedes a block collection (cf. the INDENT token in Python). // The token BLOCK-END denote indentation decrease that ends a block collection // (cf. the DEDENT token in Python). However YAML has some syntax pecularities // that makes detections of these tokens more complex. // // The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators // '-', '?', and ':' correspondingly. // // The following examples show how the tokens BLOCK-SEQUENCE-START, // BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner: // // 1. Block sequences: // // - item 1 // - item 2 // - // - item 3.1 // - item 3.2 // - // key 1: value 1 // key 2: value 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-ENTRY // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 3.1",plain) // BLOCK-ENTRY // SCALAR("item 3.2",plain) // BLOCK-END // BLOCK-ENTRY // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // BLOCK-END // STREAM-END // // 2. Block mappings: // // a simple key: a value # The KEY token is produced here. // ? a complex key // : another value // a mapping: // key 1: value 1 // key 2: value 2 // a sequence: // - item 1 // - item 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-MAPPING-START // KEY // SCALAR("a simple key",plain) // VALUE // SCALAR("a value",plain) // KEY // SCALAR("a complex key",plain) // VALUE // SCALAR("another value",plain) // KEY // SCALAR("a mapping",plain) // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // KEY // SCALAR("a sequence",plain) // VALUE // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // BLOCK-END // STREAM-END // // YAML does not always require to start a new block collection from a new // line. If the current line contains only '-', '?', and ':' indicators, a new // block collection may start at the current line. The following examples // illustrate this case: // // 1. Collections in a sequence: // // - - item 1 // - item 2 // - key 1: value 1 // key 2: value 2 // - ? complex key // : complex value // // Tokens: // // STREAM-START(utf-8) // BLOCK-SEQUENCE-START // BLOCK-ENTRY // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // BLOCK-ENTRY // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // BLOCK-ENTRY // BLOCK-MAPPING-START // KEY // SCALAR("complex key") // VALUE // SCALAR("complex value") // BLOCK-END // BLOCK-END // STREAM-END // // 2. Collections in a mapping: // // ? a sequence // : - item 1 // - item 2 // ? a mapping // : key 1: value 1 // key 2: value 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-MAPPING-START // KEY // SCALAR("a sequence",plain) // VALUE // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // KEY // SCALAR("a mapping",plain) // VALUE // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // BLOCK-END // STREAM-END // // YAML also permits non-indented sequences if they are included into a block // mapping. In this case, the token BLOCK-SEQUENCE-START is not produced: // // key: // - item 1 # BLOCK-SEQUENCE-START is NOT produced here. // - item 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-MAPPING-START // KEY // SCALAR("key",plain) // VALUE // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // // Ensure that the buffer contains the required number of characters. // Return true on success, false on failure (reader error or memory error). func cache(parser *yaml_parser_t, length int) bool { // [Go] This was inlined: !cache(A, B) -> unread < B && !update(A, B) return parser.unread >= length || yaml_parser_update_buffer(parser, length) } // Advance the buffer pointer. func skip(parser *yaml_parser_t) { parser.mark.index++ parser.mark.column++ parser.unread-- parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) } func skip_line(parser *yaml_parser_t) { if is_crlf(parser.buffer, parser.buffer_pos) { parser.mark.index += 2 parser.mark.column = 0 parser.mark.line++ parser.unread -= 2 parser.buffer_pos += 2 } else if is_break(parser.buffer, parser.buffer_pos) { parser.mark.index++ parser.mark.column = 0 parser.mark.line++ parser.unread-- parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) } } // Copy a character to a string buffer and advance pointers. func read(parser *yaml_parser_t, s []byte) []byte { w := width(parser.buffer[parser.buffer_pos]) if w == 0 { panic("invalid character sequence") } if len(s) == 0 { s = make([]byte, 0, 32) } if w == 1 && len(s)+w <= cap(s) { s = s[:len(s)+1] s[len(s)-1] = parser.buffer[parser.buffer_pos] parser.buffer_pos++ } else { s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...) parser.buffer_pos += w } parser.mark.index++ parser.mark.column++ parser.unread-- return s } // Copy a line break character to a string buffer and advance pointers. func read_line(parser *yaml_parser_t, s []byte) []byte { buf := parser.buffer pos := parser.buffer_pos switch { case buf[pos] == '\r' && buf[pos+1] == '\n': // CR LF . LF s = append(s, '\n') parser.buffer_pos += 2 parser.mark.index++ parser.unread-- case buf[pos] == '\r' || buf[pos] == '\n': // CR|LF . LF s = append(s, '\n') parser.buffer_pos += 1 case buf[pos] == '\xC2' && buf[pos+1] == '\x85': // NEL . LF s = append(s, '\n') parser.buffer_pos += 2 case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'): // LS|PS . LS|PS s = append(s, buf[parser.buffer_pos:pos+3]...) parser.buffer_pos += 3 default: return s } parser.mark.index++ parser.mark.column = 0 parser.mark.line++ parser.unread-- return s } // Get the next token. func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool { // Erase the token object. *token = yaml_token_t{} // [Go] Is this necessary? // No tokens after STREAM-END or error. if parser.stream_end_produced || parser.error != yaml_NO_ERROR { return true } // Ensure that the tokens queue contains enough tokens. if !parser.token_available { if !yaml_parser_fetch_more_tokens(parser) { return false } } // Fetch the next token from the queue. *token = parser.tokens[parser.tokens_head] parser.tokens_head++ parser.tokens_parsed++ parser.token_available = false if token.typ == yaml_STREAM_END_TOKEN { parser.stream_end_produced = true } return true } // Set the scanner error and return false. func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool { parser.error = yaml_SCANNER_ERROR parser.context = context parser.context_mark = context_mark parser.problem = problem parser.problem_mark = parser.mark return false } func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, context_mark yaml_mark_t, problem string) bool { context := "while parsing a tag" if directive { context = "while parsing a %TAG directive" } return yaml_parser_set_scanner_error(parser, context, context_mark, problem) } func trace(args ...interface{}) func() { pargs := append([]interface{}{"+++"}, args...) fmt.Println(pargs...) pargs = append([]interface{}{"---"}, args...) return func() { fmt.Println(pargs...) } } // Ensure that the tokens queue contains at least one token which can be // returned to the Parser. func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { // While we need more tokens to fetch, do it. for { if parser.tokens_head != len(parser.tokens) { // If queue is non-empty, check if any potential simple key may // occupy the head position. head_tok_idx, ok := parser.simple_keys_by_tok[parser.tokens_parsed] if !ok { break } else if valid, ok := yaml_simple_key_is_valid(parser, &parser.simple_keys[head_tok_idx]); !ok { return false } else if !valid { break } } // Fetch the next token. if !yaml_parser_fetch_next_token(parser) { return false } } parser.token_available = true return true } // The dispatcher for token fetchers. func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { // Ensure that the buffer is initialized. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } // Check if we just started scanning. Fetch STREAM-START then. if !parser.stream_start_produced { return yaml_parser_fetch_stream_start(parser) } // Eat whitespaces and comments until we reach the next token. if !yaml_parser_scan_to_next_token(parser) { return false } // Check the indentation level against the current column. if !yaml_parser_unroll_indent(parser, parser.mark.column) { return false } // Ensure that the buffer contains at least 4 characters. 4 is the length // of the longest indicators ('--- ' and '... '). if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { return false } // Is it the end of the stream? if is_z(parser.buffer, parser.buffer_pos) { return yaml_parser_fetch_stream_end(parser) } // Is it a directive? if parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' { return yaml_parser_fetch_directive(parser) } buf := parser.buffer pos := parser.buffer_pos // Is it the document start indicator? if parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) { return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN) } // Is it the document end indicator? if parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) { return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN) } // Is it the flow sequence start indicator? if buf[pos] == '[' { return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_SEQUENCE_START_TOKEN) } // Is it the flow mapping start indicator? if parser.buffer[parser.buffer_pos] == '{' { return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_MAPPING_START_TOKEN) } // Is it the flow sequence end indicator? if parser.buffer[parser.buffer_pos] == ']' { return yaml_parser_fetch_flow_collection_end(parser, yaml_FLOW_SEQUENCE_END_TOKEN) } // Is it the flow mapping end indicator? if parser.buffer[parser.buffer_pos] == '}' { return yaml_parser_fetch_flow_collection_end(parser, yaml_FLOW_MAPPING_END_TOKEN) } // Is it the flow entry indicator? if parser.buffer[parser.buffer_pos] == ',' { return yaml_parser_fetch_flow_entry(parser) } // Is it the block entry indicator? if parser.buffer[parser.buffer_pos] == '-' && is_blankz(parser.buffer, parser.buffer_pos+1) { return yaml_parser_fetch_block_entry(parser) } // Is it the key indicator? if parser.buffer[parser.buffer_pos] == '?' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { return yaml_parser_fetch_key(parser) } // Is it the value indicator? if parser.buffer[parser.buffer_pos] == ':' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { return yaml_parser_fetch_value(parser) } // Is it an alias? if parser.buffer[parser.buffer_pos] == '*' { return yaml_parser_fetch_anchor(parser, yaml_ALIAS_TOKEN) } // Is it an anchor? if parser.buffer[parser.buffer_pos] == '&' { return yaml_parser_fetch_anchor(parser, yaml_ANCHOR_TOKEN) } // Is it a tag? if parser.buffer[parser.buffer_pos] == '!' { return yaml_parser_fetch_tag(parser) } // Is it a literal scalar? if parser.buffer[parser.buffer_pos] == '|' && parser.flow_level == 0 { return yaml_parser_fetch_block_scalar(parser, true) } // Is it a folded scalar? if parser.buffer[parser.buffer_pos] == '>' && parser.flow_level == 0 { return yaml_parser_fetch_block_scalar(parser, false) } // Is it a single-quoted scalar? if parser.buffer[parser.buffer_pos] == '\'' { return yaml_parser_fetch_flow_scalar(parser, true) } // Is it a double-quoted scalar? if parser.buffer[parser.buffer_pos] == '"' { return yaml_parser_fetch_flow_scalar(parser, false) } // Is it a plain scalar? // // A plain scalar may start with any non-blank characters except // // '-', '?', ':', ',', '[', ']', '{', '}', // '#', '&', '*', '!', '|', '>', '\'', '\"', // '%', '@', '`'. // // In the block context (and, for the '-' indicator, in the flow context // too), it may also start with the characters // // '-', '?', ':' // // if it is followed by a non-space character. // // The last rule is more restrictive than the specification requires. // [Go] Make this logic more reasonable. //switch parser.buffer[parser.buffer_pos] { //case '-', '?', ':', ',', '?', '-', ',', ':', ']', '[', '}', '{', '&', '#', '!', '*', '>', '|', '"', '\'', '@', '%', '-', '`': //} if !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '-' || parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || parser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '#' || parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '|' || parser.buffer[parser.buffer_pos] == '>' || parser.buffer[parser.buffer_pos] == '\'' || parser.buffer[parser.buffer_pos] == '"' || parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') || (parser.buffer[parser.buffer_pos] == '-' && !is_blank(parser.buffer, parser.buffer_pos+1)) || (parser.flow_level == 0 && (parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':') && !is_blankz(parser.buffer, parser.buffer_pos+1)) { return yaml_parser_fetch_plain_scalar(parser) } // If we don't determine the token type so far, it is an error. return yaml_parser_set_scanner_error(parser, "while scanning for the next token", parser.mark, "found character that cannot start any token") } func yaml_simple_key_is_valid(parser *yaml_parser_t, simple_key *yaml_simple_key_t) (valid, ok bool) { if !simple_key.possible { return false, true } // The 1.2 specification says: // // "If the ? indicator is omitted, parsing needs to see past the // implicit key to recognize it as such. To limit the amount of // lookahead required, the “:” indicator must appear at most 1024 // Unicode characters beyond the start of the key. In addition, the key // is restricted to a single line." // if simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index { // Check if the potential simple key to be removed is required. if simple_key.required { return false, yaml_parser_set_scanner_error(parser, "while scanning a simple key", simple_key.mark, "could not find expected ':'") } simple_key.possible = false return false, true } return true, true } // Check if a simple key may start at the current position and add it if // needed. func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { // A simple key is required at the current position if the scanner is in // the block context and the current column coincides with the indentation // level. required := parser.flow_level == 0 && parser.indent == parser.mark.column // // If the current position may start a simple key, save it. // if parser.simple_key_allowed { simple_key := yaml_simple_key_t{ possible: true, required: required, token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), mark: parser.mark, } if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_keys[len(parser.simple_keys)-1] = simple_key parser.simple_keys_by_tok[simple_key.token_number] = len(parser.simple_keys) - 1 } return true } // Remove a potential simple key at the current flow level. func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { i := len(parser.simple_keys) - 1 if parser.simple_keys[i].possible { // If the key is required, it is an error. if parser.simple_keys[i].required { return yaml_parser_set_scanner_error(parser, "while scanning a simple key", parser.simple_keys[i].mark, "could not find expected ':'") } // Remove the key from the stack. parser.simple_keys[i].possible = false delete(parser.simple_keys_by_tok, parser.simple_keys[i].token_number) } return true } // max_flow_level limits the flow_level const max_flow_level = 10000 // Increase the flow level and resize the simple key list if needed. func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { // Reset the simple key on the next level. parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{ possible: false, required: false, token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), mark: parser.mark, }) // Increase the flow level. parser.flow_level++ if parser.flow_level > max_flow_level { return yaml_parser_set_scanner_error(parser, "while increasing flow level", parser.simple_keys[len(parser.simple_keys)-1].mark, fmt.Sprintf("exceeded max depth of %d", max_flow_level)) } return true } // Decrease the flow level. func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { if parser.flow_level > 0 { parser.flow_level-- last := len(parser.simple_keys) - 1 delete(parser.simple_keys_by_tok, parser.simple_keys[last].token_number) parser.simple_keys = parser.simple_keys[:last] } return true } // max_indents limits the indents stack size const max_indents = 10000 // Push the current indentation level to the stack and set the new level // the current column is greater than the indentation level. In this case, // append or insert the specified token into the token queue. func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool { // In the flow context, do nothing. if parser.flow_level > 0 { return true } if parser.indent < column { // Push the current indentation level to the stack and set the new // indentation level. parser.indents = append(parser.indents, parser.indent) parser.indent = column if len(parser.indents) > max_indents { return yaml_parser_set_scanner_error(parser, "while increasing indent level", parser.simple_keys[len(parser.simple_keys)-1].mark, fmt.Sprintf("exceeded max depth of %d", max_indents)) } // Create a token and insert it into the queue. token := yaml_token_t{ typ: typ, start_mark: mark, end_mark: mark, } if number > -1 { number -= parser.tokens_parsed } yaml_insert_token(parser, number, &token) } return true } // Pop indentation levels from the indents stack until the current level // becomes less or equal to the column. For each indentation level, append // the BLOCK-END token. func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool { // In the flow context, do nothing. if parser.flow_level > 0 { return true } // Loop through the indentation levels in the stack. for parser.indent > column { // Create a token and append it to the queue. token := yaml_token_t{ typ: yaml_BLOCK_END_TOKEN, start_mark: parser.mark, end_mark: parser.mark, } yaml_insert_token(parser, -1, &token) // Pop the indentation level. parser.indent = parser.indents[len(parser.indents)-1] parser.indents = parser.indents[:len(parser.indents)-1] } return true } // Initialize the scanner and produce the STREAM-START token. func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { // Set the initial indentation. parser.indent = -1 // Initialize the simple key stack. parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) parser.simple_keys_by_tok = make(map[int]int) // A simple key is allowed at the beginning of the stream. parser.simple_key_allowed = true // We have started. parser.stream_start_produced = true // Create the STREAM-START token and append it to the queue. token := yaml_token_t{ typ: yaml_STREAM_START_TOKEN, start_mark: parser.mark, end_mark: parser.mark, encoding: parser.encoding, } yaml_insert_token(parser, -1, &token) return true } // Produce the STREAM-END token and shut down the scanner. func yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool { // Force new line. if parser.mark.column != 0 { parser.mark.column = 0 parser.mark.line++ } // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Create the STREAM-END token and append it to the queue. token := yaml_token_t{ typ: yaml_STREAM_END_TOKEN, start_mark: parser.mark, end_mark: parser.mark, } yaml_insert_token(parser, -1, &token) return true } // Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token. func yaml_parser_fetch_directive(parser *yaml_parser_t) bool { // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. token := yaml_token_t{} if !yaml_parser_scan_directive(parser, &token) { return false } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true } // Produce the DOCUMENT-START or DOCUMENT-END token. func yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool { // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Consume the token. start_mark := parser.mark skip(parser) skip(parser) skip(parser) end_mark := parser.mark // Create the DOCUMENT-START or DOCUMENT-END token. token := yaml_token_t{ typ: typ, start_mark: start_mark, end_mark: end_mark, } // Append the token to the queue.
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/decode.go
vendor/gopkg.in/yaml.v2/decode.go
package yaml import ( "encoding" "encoding/base64" "fmt" "io" "math" "reflect" "strconv" "time" ) const ( documentNode = 1 << iota mappingNode sequenceNode scalarNode aliasNode ) type node struct { kind int line, column int tag string // For an alias node, alias holds the resolved alias. alias *node value string implicit bool children []*node anchors map[string]*node } // ---------------------------------------------------------------------------- // Parser, produces a node tree out of a libyaml event stream. type parser struct { parser yaml_parser_t event yaml_event_t doc *node doneInit bool } func newParser(b []byte) *parser { p := parser{} if !yaml_parser_initialize(&p.parser) { panic("failed to initialize YAML emitter") } if len(b) == 0 { b = []byte{'\n'} } yaml_parser_set_input_string(&p.parser, b) return &p } func newParserFromReader(r io.Reader) *parser { p := parser{} if !yaml_parser_initialize(&p.parser) { panic("failed to initialize YAML emitter") } yaml_parser_set_input_reader(&p.parser, r) return &p } func (p *parser) init() { if p.doneInit { return } p.expect(yaml_STREAM_START_EVENT) p.doneInit = true } func (p *parser) destroy() { if p.event.typ != yaml_NO_EVENT { yaml_event_delete(&p.event) } yaml_parser_delete(&p.parser) } // expect consumes an event from the event stream and // checks that it's of the expected type. func (p *parser) expect(e yaml_event_type_t) { if p.event.typ == yaml_NO_EVENT { if !yaml_parser_parse(&p.parser, &p.event) { p.fail() } } if p.event.typ == yaml_STREAM_END_EVENT { failf("attempted to go past the end of stream; corrupted value?") } if p.event.typ != e { p.parser.problem = fmt.Sprintf("expected %s event but got %s", e, p.event.typ) p.fail() } yaml_event_delete(&p.event) p.event.typ = yaml_NO_EVENT } // peek peeks at the next event in the event stream, // puts the results into p.event and returns the event type. func (p *parser) peek() yaml_event_type_t { if p.event.typ != yaml_NO_EVENT { return p.event.typ } if !yaml_parser_parse(&p.parser, &p.event) { p.fail() } return p.event.typ } func (p *parser) fail() { var where string var line int if p.parser.problem_mark.line != 0 { line = p.parser.problem_mark.line // Scanner errors don't iterate line before returning error if p.parser.error == yaml_SCANNER_ERROR { line++ } } else if p.parser.context_mark.line != 0 { line = p.parser.context_mark.line } if line != 0 { where = "line " + strconv.Itoa(line) + ": " } var msg string if len(p.parser.problem) > 0 { msg = p.parser.problem } else { msg = "unknown problem parsing YAML content" } failf("%s%s", where, msg) } func (p *parser) anchor(n *node, anchor []byte) { if anchor != nil { p.doc.anchors[string(anchor)] = n } } func (p *parser) parse() *node { p.init() switch p.peek() { case yaml_SCALAR_EVENT: return p.scalar() case yaml_ALIAS_EVENT: return p.alias() case yaml_MAPPING_START_EVENT: return p.mapping() case yaml_SEQUENCE_START_EVENT: return p.sequence() case yaml_DOCUMENT_START_EVENT: return p.document() case yaml_STREAM_END_EVENT: // Happens when attempting to decode an empty buffer. return nil default: panic("attempted to parse unknown event: " + p.event.typ.String()) } } func (p *parser) node(kind int) *node { return &node{ kind: kind, line: p.event.start_mark.line, column: p.event.start_mark.column, } } func (p *parser) document() *node { n := p.node(documentNode) n.anchors = make(map[string]*node) p.doc = n p.expect(yaml_DOCUMENT_START_EVENT) n.children = append(n.children, p.parse()) p.expect(yaml_DOCUMENT_END_EVENT) return n } func (p *parser) alias() *node { n := p.node(aliasNode) n.value = string(p.event.anchor) n.alias = p.doc.anchors[n.value] if n.alias == nil { failf("unknown anchor '%s' referenced", n.value) } p.expect(yaml_ALIAS_EVENT) return n } func (p *parser) scalar() *node { n := p.node(scalarNode) n.value = string(p.event.value) n.tag = string(p.event.tag) n.implicit = p.event.implicit p.anchor(n, p.event.anchor) p.expect(yaml_SCALAR_EVENT) return n } func (p *parser) sequence() *node { n := p.node(sequenceNode) p.anchor(n, p.event.anchor) p.expect(yaml_SEQUENCE_START_EVENT) for p.peek() != yaml_SEQUENCE_END_EVENT { n.children = append(n.children, p.parse()) } p.expect(yaml_SEQUENCE_END_EVENT) return n } func (p *parser) mapping() *node { n := p.node(mappingNode) p.anchor(n, p.event.anchor) p.expect(yaml_MAPPING_START_EVENT) for p.peek() != yaml_MAPPING_END_EVENT { n.children = append(n.children, p.parse(), p.parse()) } p.expect(yaml_MAPPING_END_EVENT) return n } // ---------------------------------------------------------------------------- // Decoder, unmarshals a node into a provided value. type decoder struct { doc *node aliases map[*node]bool mapType reflect.Type terrors []string strict bool decodeCount int aliasCount int aliasDepth int } var ( mapItemType = reflect.TypeOf(MapItem{}) durationType = reflect.TypeOf(time.Duration(0)) defaultMapType = reflect.TypeOf(map[interface{}]interface{}{}) ifaceType = defaultMapType.Elem() timeType = reflect.TypeOf(time.Time{}) ptrTimeType = reflect.TypeOf(&time.Time{}) ) func newDecoder(strict bool) *decoder { d := &decoder{mapType: defaultMapType, strict: strict} d.aliases = make(map[*node]bool) return d } func (d *decoder) terror(n *node, tag string, out reflect.Value) { if n.tag != "" { tag = n.tag } value := n.value if tag != yaml_SEQ_TAG && tag != yaml_MAP_TAG { if len(value) > 10 { value = " `" + value[:7] + "...`" } else { value = " `" + value + "`" } } d.terrors = append(d.terrors, fmt.Sprintf("line %d: cannot unmarshal %s%s into %s", n.line+1, shortTag(tag), value, out.Type())) } func (d *decoder) callUnmarshaler(n *node, u Unmarshaler) (good bool) { terrlen := len(d.terrors) err := u.UnmarshalYAML(func(v interface{}) (err error) { defer handleErr(&err) d.unmarshal(n, reflect.ValueOf(v)) if len(d.terrors) > terrlen { issues := d.terrors[terrlen:] d.terrors = d.terrors[:terrlen] return &TypeError{issues} } return nil }) if e, ok := err.(*TypeError); ok { d.terrors = append(d.terrors, e.Errors...) return false } if err != nil { fail(err) } return true } // d.prepare initializes and dereferences pointers and calls UnmarshalYAML // if a value is found to implement it. // It returns the initialized and dereferenced out value, whether // unmarshalling was already done by UnmarshalYAML, and if so whether // its types unmarshalled appropriately. // // If n holds a null value, prepare returns before doing anything. func (d *decoder) prepare(n *node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) { if n.tag == yaml_NULL_TAG || n.kind == scalarNode && n.tag == "" && (n.value == "null" || n.value == "~" || n.value == "" && n.implicit) { return out, false, false } again := true for again { again = false if out.Kind() == reflect.Ptr { if out.IsNil() { out.Set(reflect.New(out.Type().Elem())) } out = out.Elem() again = true } if out.CanAddr() { if u, ok := out.Addr().Interface().(Unmarshaler); ok { good = d.callUnmarshaler(n, u) return out, true, good } } } return out, false, false } const ( // 400,000 decode operations is ~500kb of dense object declarations, or // ~5kb of dense object declarations with 10000% alias expansion alias_ratio_range_low = 400000 // 4,000,000 decode operations is ~5MB of dense object declarations, or // ~4.5MB of dense object declarations with 10% alias expansion alias_ratio_range_high = 4000000 // alias_ratio_range is the range over which we scale allowed alias ratios alias_ratio_range = float64(alias_ratio_range_high - alias_ratio_range_low) ) func allowedAliasRatio(decodeCount int) float64 { switch { case decodeCount <= alias_ratio_range_low: // allow 99% to come from alias expansion for small-to-medium documents return 0.99 case decodeCount >= alias_ratio_range_high: // allow 10% to come from alias expansion for very large documents return 0.10 default: // scale smoothly from 99% down to 10% over the range. // this maps to 396,000 - 400,000 allowed alias-driven decodes over the range. // 400,000 decode operations is ~100MB of allocations in worst-case scenarios (single-item maps). return 0.99 - 0.89*(float64(decodeCount-alias_ratio_range_low)/alias_ratio_range) } } func (d *decoder) unmarshal(n *node, out reflect.Value) (good bool) { d.decodeCount++ if d.aliasDepth > 0 { d.aliasCount++ } if d.aliasCount > 100 && d.decodeCount > 1000 && float64(d.aliasCount)/float64(d.decodeCount) > allowedAliasRatio(d.decodeCount) { failf("document contains excessive aliasing") } switch n.kind { case documentNode: return d.document(n, out) case aliasNode: return d.alias(n, out) } out, unmarshaled, good := d.prepare(n, out) if unmarshaled { return good } switch n.kind { case scalarNode: good = d.scalar(n, out) case mappingNode: good = d.mapping(n, out) case sequenceNode: good = d.sequence(n, out) default: panic("internal error: unknown node kind: " + strconv.Itoa(n.kind)) } return good } func (d *decoder) document(n *node, out reflect.Value) (good bool) { if len(n.children) == 1 { d.doc = n d.unmarshal(n.children[0], out) return true } return false } func (d *decoder) alias(n *node, out reflect.Value) (good bool) { if d.aliases[n] { // TODO this could actually be allowed in some circumstances. failf("anchor '%s' value contains itself", n.value) } d.aliases[n] = true d.aliasDepth++ good = d.unmarshal(n.alias, out) d.aliasDepth-- delete(d.aliases, n) return good } var zeroValue reflect.Value func resetMap(out reflect.Value) { for _, k := range out.MapKeys() { out.SetMapIndex(k, zeroValue) } } func (d *decoder) scalar(n *node, out reflect.Value) bool { var tag string var resolved interface{} if n.tag == "" && !n.implicit { tag = yaml_STR_TAG resolved = n.value } else { tag, resolved = resolve(n.tag, n.value) if tag == yaml_BINARY_TAG { data, err := base64.StdEncoding.DecodeString(resolved.(string)) if err != nil { failf("!!binary value contains invalid base64 data") } resolved = string(data) } } if resolved == nil { if out.Kind() == reflect.Map && !out.CanAddr() { resetMap(out) } else { out.Set(reflect.Zero(out.Type())) } return true } if resolvedv := reflect.ValueOf(resolved); out.Type() == resolvedv.Type() { // We've resolved to exactly the type we want, so use that. out.Set(resolvedv) return true } // Perhaps we can use the value as a TextUnmarshaler to // set its value. if out.CanAddr() { u, ok := out.Addr().Interface().(encoding.TextUnmarshaler) if ok { var text []byte if tag == yaml_BINARY_TAG { text = []byte(resolved.(string)) } else { // We let any value be unmarshaled into TextUnmarshaler. // That might be more lax than we'd like, but the // TextUnmarshaler itself should bowl out any dubious values. text = []byte(n.value) } err := u.UnmarshalText(text) if err != nil { fail(err) } return true } } switch out.Kind() { case reflect.String: if tag == yaml_BINARY_TAG { out.SetString(resolved.(string)) return true } if resolved != nil { out.SetString(n.value) return true } case reflect.Interface: if resolved == nil { out.Set(reflect.Zero(out.Type())) } else if tag == yaml_TIMESTAMP_TAG { // It looks like a timestamp but for backward compatibility // reasons we set it as a string, so that code that unmarshals // timestamp-like values into interface{} will continue to // see a string and not a time.Time. // TODO(v3) Drop this. out.Set(reflect.ValueOf(n.value)) } else { out.Set(reflect.ValueOf(resolved)) } return true case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: switch resolved := resolved.(type) { case int: if !out.OverflowInt(int64(resolved)) { out.SetInt(int64(resolved)) return true } case int64: if !out.OverflowInt(resolved) { out.SetInt(resolved) return true } case uint64: if resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) { out.SetInt(int64(resolved)) return true } case float64: if resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) { out.SetInt(int64(resolved)) return true } case string: if out.Type() == durationType { d, err := time.ParseDuration(resolved) if err == nil { out.SetInt(int64(d)) return true } } } case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: switch resolved := resolved.(type) { case int: if resolved >= 0 && !out.OverflowUint(uint64(resolved)) { out.SetUint(uint64(resolved)) return true } case int64: if resolved >= 0 && !out.OverflowUint(uint64(resolved)) { out.SetUint(uint64(resolved)) return true } case uint64: if !out.OverflowUint(uint64(resolved)) { out.SetUint(uint64(resolved)) return true } case float64: if resolved <= math.MaxUint64 && !out.OverflowUint(uint64(resolved)) { out.SetUint(uint64(resolved)) return true } } case reflect.Bool: switch resolved := resolved.(type) { case bool: out.SetBool(resolved) return true } case reflect.Float32, reflect.Float64: switch resolved := resolved.(type) { case int: out.SetFloat(float64(resolved)) return true case int64: out.SetFloat(float64(resolved)) return true case uint64: out.SetFloat(float64(resolved)) return true case float64: out.SetFloat(resolved) return true } case reflect.Struct: if resolvedv := reflect.ValueOf(resolved); out.Type() == resolvedv.Type() { out.Set(resolvedv) return true } case reflect.Ptr: if out.Type().Elem() == reflect.TypeOf(resolved) { // TODO DOes this make sense? When is out a Ptr except when decoding a nil value? elem := reflect.New(out.Type().Elem()) elem.Elem().Set(reflect.ValueOf(resolved)) out.Set(elem) return true } } d.terror(n, tag, out) return false } func settableValueOf(i interface{}) reflect.Value { v := reflect.ValueOf(i) sv := reflect.New(v.Type()).Elem() sv.Set(v) return sv } func (d *decoder) sequence(n *node, out reflect.Value) (good bool) { l := len(n.children) var iface reflect.Value switch out.Kind() { case reflect.Slice: out.Set(reflect.MakeSlice(out.Type(), l, l)) case reflect.Array: if l != out.Len() { failf("invalid array: want %d elements but got %d", out.Len(), l) } case reflect.Interface: // No type hints. Will have to use a generic sequence. iface = out out = settableValueOf(make([]interface{}, l)) default: d.terror(n, yaml_SEQ_TAG, out) return false } et := out.Type().Elem() j := 0 for i := 0; i < l; i++ { e := reflect.New(et).Elem() if ok := d.unmarshal(n.children[i], e); ok { out.Index(j).Set(e) j++ } } if out.Kind() != reflect.Array { out.Set(out.Slice(0, j)) } if iface.IsValid() { iface.Set(out) } return true } func (d *decoder) mapping(n *node, out reflect.Value) (good bool) { switch out.Kind() { case reflect.Struct: return d.mappingStruct(n, out) case reflect.Slice: return d.mappingSlice(n, out) case reflect.Map: // okay case reflect.Interface: if d.mapType.Kind() == reflect.Map { iface := out out = reflect.MakeMap(d.mapType) iface.Set(out) } else { slicev := reflect.New(d.mapType).Elem() if !d.mappingSlice(n, slicev) { return false } out.Set(slicev) return true } default: d.terror(n, yaml_MAP_TAG, out) return false } outt := out.Type() kt := outt.Key() et := outt.Elem() mapType := d.mapType if outt.Key() == ifaceType && outt.Elem() == ifaceType { d.mapType = outt } if out.IsNil() { out.Set(reflect.MakeMap(outt)) } l := len(n.children) for i := 0; i < l; i += 2 { if isMerge(n.children[i]) { d.merge(n.children[i+1], out) continue } k := reflect.New(kt).Elem() if d.unmarshal(n.children[i], k) { kkind := k.Kind() if kkind == reflect.Interface { kkind = k.Elem().Kind() } if kkind == reflect.Map || kkind == reflect.Slice { failf("invalid map key: %#v", k.Interface()) } e := reflect.New(et).Elem() if d.unmarshal(n.children[i+1], e) { d.setMapIndex(n.children[i+1], out, k, e) } } } d.mapType = mapType return true } func (d *decoder) setMapIndex(n *node, out, k, v reflect.Value) { if d.strict && out.MapIndex(k) != zeroValue { d.terrors = append(d.terrors, fmt.Sprintf("line %d: key %#v already set in map", n.line+1, k.Interface())) return } out.SetMapIndex(k, v) } func (d *decoder) mappingSlice(n *node, out reflect.Value) (good bool) { outt := out.Type() if outt.Elem() != mapItemType { d.terror(n, yaml_MAP_TAG, out) return false } mapType := d.mapType d.mapType = outt var slice []MapItem var l = len(n.children) for i := 0; i < l; i += 2 { if isMerge(n.children[i]) { d.merge(n.children[i+1], out) continue } item := MapItem{} k := reflect.ValueOf(&item.Key).Elem() if d.unmarshal(n.children[i], k) { v := reflect.ValueOf(&item.Value).Elem() if d.unmarshal(n.children[i+1], v) { slice = append(slice, item) } } } out.Set(reflect.ValueOf(slice)) d.mapType = mapType return true } func (d *decoder) mappingStruct(n *node, out reflect.Value) (good bool) { sinfo, err := getStructInfo(out.Type()) if err != nil { panic(err) } name := settableValueOf("") l := len(n.children) var inlineMap reflect.Value var elemType reflect.Type if sinfo.InlineMap != -1 { inlineMap = out.Field(sinfo.InlineMap) inlineMap.Set(reflect.New(inlineMap.Type()).Elem()) elemType = inlineMap.Type().Elem() } var doneFields []bool if d.strict { doneFields = make([]bool, len(sinfo.FieldsList)) } for i := 0; i < l; i += 2 { ni := n.children[i] if isMerge(ni) { d.merge(n.children[i+1], out) continue } if !d.unmarshal(ni, name) { continue } if info, ok := sinfo.FieldsMap[name.String()]; ok { if d.strict { if doneFields[info.Id] { d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s already set in type %s", ni.line+1, name.String(), out.Type())) continue } doneFields[info.Id] = true } var field reflect.Value if info.Inline == nil { field = out.Field(info.Num) } else { field = out.FieldByIndex(info.Inline) } d.unmarshal(n.children[i+1], field) } else if sinfo.InlineMap != -1 { if inlineMap.IsNil() { inlineMap.Set(reflect.MakeMap(inlineMap.Type())) } value := reflect.New(elemType).Elem() d.unmarshal(n.children[i+1], value) d.setMapIndex(n.children[i+1], inlineMap, name, value) } else if d.strict { d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s not found in type %s", ni.line+1, name.String(), out.Type())) } } return true } func failWantMap() { failf("map merge requires map or sequence of maps as the value") } func (d *decoder) merge(n *node, out reflect.Value) { switch n.kind { case mappingNode: d.unmarshal(n, out) case aliasNode: if n.alias != nil && n.alias.kind != mappingNode { failWantMap() } d.unmarshal(n, out) case sequenceNode: // Step backwards as earlier nodes take precedence. for i := len(n.children) - 1; i >= 0; i-- { ni := n.children[i] if ni.kind == aliasNode { if ni.alias != nil && ni.alias.kind != mappingNode { failWantMap() } } else if ni.kind != mappingNode { failWantMap() } d.unmarshal(ni, out) } default: failWantMap() } } func isMerge(n *node) bool { return n.kind == scalarNode && n.value == "<<" && (n.implicit == true || n.tag == yaml_MERGE_TAG) }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v2/parserc.go
vendor/gopkg.in/yaml.v2/parserc.go
package yaml import ( "bytes" ) // The parser implements the following grammar: // // stream ::= STREAM-START implicit_document? explicit_document* STREAM-END // implicit_document ::= block_node DOCUMENT-END* // explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* // block_node_or_indentless_sequence ::= // ALIAS // | properties (block_content | indentless_block_sequence)? // | block_content // | indentless_block_sequence // block_node ::= ALIAS // | properties block_content? // | block_content // flow_node ::= ALIAS // | properties flow_content? // | flow_content // properties ::= TAG ANCHOR? | ANCHOR TAG? // block_content ::= block_collection | flow_collection | SCALAR // flow_content ::= flow_collection | SCALAR // block_collection ::= block_sequence | block_mapping // flow_collection ::= flow_sequence | flow_mapping // block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END // indentless_sequence ::= (BLOCK-ENTRY block_node?)+ // block_mapping ::= BLOCK-MAPPING_START // ((KEY block_node_or_indentless_sequence?)? // (VALUE block_node_or_indentless_sequence?)?)* // BLOCK-END // flow_sequence ::= FLOW-SEQUENCE-START // (flow_sequence_entry FLOW-ENTRY)* // flow_sequence_entry? // FLOW-SEQUENCE-END // flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // flow_mapping ::= FLOW-MAPPING-START // (flow_mapping_entry FLOW-ENTRY)* // flow_mapping_entry? // FLOW-MAPPING-END // flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // Peek the next token in the token queue. func peek_token(parser *yaml_parser_t) *yaml_token_t { if parser.token_available || yaml_parser_fetch_more_tokens(parser) { return &parser.tokens[parser.tokens_head] } return nil } // Remove the next token from the queue (must be called after peek_token). func skip_token(parser *yaml_parser_t) { parser.token_available = false parser.tokens_parsed++ parser.stream_end_produced = parser.tokens[parser.tokens_head].typ == yaml_STREAM_END_TOKEN parser.tokens_head++ } // Get the next event. func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool { // Erase the event object. *event = yaml_event_t{} // No events after the end of the stream or error. if parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE { return true } // Generate the next event. return yaml_parser_state_machine(parser, event) } // Set parser error. func yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool { parser.error = yaml_PARSER_ERROR parser.problem = problem parser.problem_mark = problem_mark return false } func yaml_parser_set_parser_error_context(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string, problem_mark yaml_mark_t) bool { parser.error = yaml_PARSER_ERROR parser.context = context parser.context_mark = context_mark parser.problem = problem parser.problem_mark = problem_mark return false } // State dispatcher. func yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool { //trace("yaml_parser_state_machine", "state:", parser.state.String()) switch parser.state { case yaml_PARSE_STREAM_START_STATE: return yaml_parser_parse_stream_start(parser, event) case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: return yaml_parser_parse_document_start(parser, event, true) case yaml_PARSE_DOCUMENT_START_STATE: return yaml_parser_parse_document_start(parser, event, false) case yaml_PARSE_DOCUMENT_CONTENT_STATE: return yaml_parser_parse_document_content(parser, event) case yaml_PARSE_DOCUMENT_END_STATE: return yaml_parser_parse_document_end(parser, event) case yaml_PARSE_BLOCK_NODE_STATE: return yaml_parser_parse_node(parser, event, true, false) case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: return yaml_parser_parse_node(parser, event, true, true) case yaml_PARSE_FLOW_NODE_STATE: return yaml_parser_parse_node(parser, event, false, false) case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: return yaml_parser_parse_block_sequence_entry(parser, event, true) case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: return yaml_parser_parse_block_sequence_entry(parser, event, false) case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: return yaml_parser_parse_indentless_sequence_entry(parser, event) case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: return yaml_parser_parse_block_mapping_key(parser, event, true) case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: return yaml_parser_parse_block_mapping_key(parser, event, false) case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: return yaml_parser_parse_block_mapping_value(parser, event) case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: return yaml_parser_parse_flow_sequence_entry(parser, event, true) case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: return yaml_parser_parse_flow_sequence_entry(parser, event, false) case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event) case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event) case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event) case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: return yaml_parser_parse_flow_mapping_key(parser, event, true) case yaml_PARSE_FLOW_MAPPING_KEY_STATE: return yaml_parser_parse_flow_mapping_key(parser, event, false) case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: return yaml_parser_parse_flow_mapping_value(parser, event, false) case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: return yaml_parser_parse_flow_mapping_value(parser, event, true) default: panic("invalid parser state") } } // Parse the production: // stream ::= STREAM-START implicit_document? explicit_document* STREAM-END // ************ func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ != yaml_STREAM_START_TOKEN { return yaml_parser_set_parser_error(parser, "did not find expected <stream-start>", token.start_mark) } parser.state = yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE *event = yaml_event_t{ typ: yaml_STREAM_START_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, encoding: token.encoding, } skip_token(parser) return true } // Parse the productions: // implicit_document ::= block_node DOCUMENT-END* // * // explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* // ************************* func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t, implicit bool) bool { token := peek_token(parser) if token == nil { return false } // Parse extra document end indicators. if !implicit { for token.typ == yaml_DOCUMENT_END_TOKEN { skip_token(parser) token = peek_token(parser) if token == nil { return false } } } if implicit && token.typ != yaml_VERSION_DIRECTIVE_TOKEN && token.typ != yaml_TAG_DIRECTIVE_TOKEN && token.typ != yaml_DOCUMENT_START_TOKEN && token.typ != yaml_STREAM_END_TOKEN { // Parse an implicit document. if !yaml_parser_process_directives(parser, nil, nil) { return false } parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) parser.state = yaml_PARSE_BLOCK_NODE_STATE *event = yaml_event_t{ typ: yaml_DOCUMENT_START_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, } } else if token.typ != yaml_STREAM_END_TOKEN { // Parse an explicit document. var version_directive *yaml_version_directive_t var tag_directives []yaml_tag_directive_t start_mark := token.start_mark if !yaml_parser_process_directives(parser, &version_directive, &tag_directives) { return false } token = peek_token(parser) if token == nil { return false } if token.typ != yaml_DOCUMENT_START_TOKEN { yaml_parser_set_parser_error(parser, "did not find expected <document start>", token.start_mark) return false } parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) parser.state = yaml_PARSE_DOCUMENT_CONTENT_STATE end_mark := token.end_mark *event = yaml_event_t{ typ: yaml_DOCUMENT_START_EVENT, start_mark: start_mark, end_mark: end_mark, version_directive: version_directive, tag_directives: tag_directives, implicit: false, } skip_token(parser) } else { // Parse the stream end. parser.state = yaml_PARSE_END_STATE *event = yaml_event_t{ typ: yaml_STREAM_END_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, } skip_token(parser) } return true } // Parse the productions: // explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* // *********** // func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN || token.typ == yaml_DOCUMENT_START_TOKEN || token.typ == yaml_DOCUMENT_END_TOKEN || token.typ == yaml_STREAM_END_TOKEN { parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] return yaml_parser_process_empty_scalar(parser, event, token.start_mark) } return yaml_parser_parse_node(parser, event, true, false) } // Parse the productions: // implicit_document ::= block_node DOCUMENT-END* // ************* // explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* // func yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } start_mark := token.start_mark end_mark := token.start_mark implicit := true if token.typ == yaml_DOCUMENT_END_TOKEN { end_mark = token.end_mark skip_token(parser) implicit = false } parser.tag_directives = parser.tag_directives[:0] parser.state = yaml_PARSE_DOCUMENT_START_STATE *event = yaml_event_t{ typ: yaml_DOCUMENT_END_EVENT, start_mark: start_mark, end_mark: end_mark, implicit: implicit, } return true } // Parse the productions: // block_node_or_indentless_sequence ::= // ALIAS // ***** // | properties (block_content | indentless_block_sequence)? // ********** * // | block_content | indentless_block_sequence // * // block_node ::= ALIAS // ***** // | properties block_content? // ********** * // | block_content // * // flow_node ::= ALIAS // ***** // | properties flow_content? // ********** * // | flow_content // * // properties ::= TAG ANCHOR? | ANCHOR TAG? // ************************* // block_content ::= block_collection | flow_collection | SCALAR // ****** // flow_content ::= flow_collection | SCALAR // ****** func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, indentless_sequence bool) bool { //defer trace("yaml_parser_parse_node", "block:", block, "indentless_sequence:", indentless_sequence)() token := peek_token(parser) if token == nil { return false } if token.typ == yaml_ALIAS_TOKEN { parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] *event = yaml_event_t{ typ: yaml_ALIAS_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, anchor: token.value, } skip_token(parser) return true } start_mark := token.start_mark end_mark := token.start_mark var tag_token bool var tag_handle, tag_suffix, anchor []byte var tag_mark yaml_mark_t if token.typ == yaml_ANCHOR_TOKEN { anchor = token.value start_mark = token.start_mark end_mark = token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ == yaml_TAG_TOKEN { tag_token = true tag_handle = token.value tag_suffix = token.suffix tag_mark = token.start_mark end_mark = token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } } } else if token.typ == yaml_TAG_TOKEN { tag_token = true tag_handle = token.value tag_suffix = token.suffix start_mark = token.start_mark tag_mark = token.start_mark end_mark = token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ == yaml_ANCHOR_TOKEN { anchor = token.value end_mark = token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } } } var tag []byte if tag_token { if len(tag_handle) == 0 { tag = tag_suffix tag_suffix = nil } else { for i := range parser.tag_directives { if bytes.Equal(parser.tag_directives[i].handle, tag_handle) { tag = append([]byte(nil), parser.tag_directives[i].prefix...) tag = append(tag, tag_suffix...) break } } if len(tag) == 0 { yaml_parser_set_parser_error_context(parser, "while parsing a node", start_mark, "found undefined tag handle", tag_mark) return false } } } implicit := len(tag) == 0 if indentless_sequence && token.typ == yaml_BLOCK_ENTRY_TOKEN { end_mark = token.end_mark parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE *event = yaml_event_t{ typ: yaml_SEQUENCE_START_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), } return true } if token.typ == yaml_SCALAR_TOKEN { var plain_implicit, quoted_implicit bool end_mark = token.end_mark if (len(tag) == 0 && token.style == yaml_PLAIN_SCALAR_STYLE) || (len(tag) == 1 && tag[0] == '!') { plain_implicit = true } else if len(tag) == 0 { quoted_implicit = true } parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] *event = yaml_event_t{ typ: yaml_SCALAR_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, value: token.value, implicit: plain_implicit, quoted_implicit: quoted_implicit, style: yaml_style_t(token.style), } skip_token(parser) return true } if token.typ == yaml_FLOW_SEQUENCE_START_TOKEN { // [Go] Some of the events below can be merged as they differ only on style. end_mark = token.end_mark parser.state = yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE *event = yaml_event_t{ typ: yaml_SEQUENCE_START_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(yaml_FLOW_SEQUENCE_STYLE), } return true } if token.typ == yaml_FLOW_MAPPING_START_TOKEN { end_mark = token.end_mark parser.state = yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE *event = yaml_event_t{ typ: yaml_MAPPING_START_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), } return true } if block && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN { end_mark = token.end_mark parser.state = yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE *event = yaml_event_t{ typ: yaml_SEQUENCE_START_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), } return true } if block && token.typ == yaml_BLOCK_MAPPING_START_TOKEN { end_mark = token.end_mark parser.state = yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE *event = yaml_event_t{ typ: yaml_MAPPING_START_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(yaml_BLOCK_MAPPING_STYLE), } return true } if len(anchor) > 0 || len(tag) > 0 { parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] *event = yaml_event_t{ typ: yaml_SCALAR_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, quoted_implicit: false, style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), } return true } context := "while parsing a flow node" if block { context = "while parsing a block node" } yaml_parser_set_parser_error_context(parser, context, start_mark, "did not find expected node content", token.start_mark) return false } // Parse the productions: // block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END // ******************** *********** * ********* // func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) parser.marks = append(parser.marks, token.start_mark) skip_token(parser) } token := peek_token(parser) if token == nil { return false } if token.typ == yaml_BLOCK_ENTRY_TOKEN { mark := token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE) return yaml_parser_parse_node(parser, event, true, false) } else { parser.state = yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE return yaml_parser_process_empty_scalar(parser, event, mark) } } if token.typ == yaml_BLOCK_END_TOKEN { parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] parser.marks = parser.marks[:len(parser.marks)-1] *event = yaml_event_t{ typ: yaml_SEQUENCE_END_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, } skip_token(parser) return true } context_mark := parser.marks[len(parser.marks)-1] parser.marks = parser.marks[:len(parser.marks)-1] return yaml_parser_set_parser_error_context(parser, "while parsing a block collection", context_mark, "did not find expected '-' indicator", token.start_mark) } // Parse the productions: // indentless_sequence ::= (BLOCK-ENTRY block_node?)+ // *********** * func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ == yaml_BLOCK_ENTRY_TOKEN { mark := token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_KEY_TOKEN && token.typ != yaml_VALUE_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE) return yaml_parser_parse_node(parser, event, true, false) } parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE return yaml_parser_process_empty_scalar(parser, event, mark) } parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] *event = yaml_event_t{ typ: yaml_SEQUENCE_END_EVENT, start_mark: token.start_mark, end_mark: token.start_mark, // [Go] Shouldn't this be token.end_mark? } return true } // Parse the productions: // block_mapping ::= BLOCK-MAPPING_START // ******************* // ((KEY block_node_or_indentless_sequence?)? // *** * // (VALUE block_node_or_indentless_sequence?)?)* // // BLOCK-END // ********* // func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) parser.marks = append(parser.marks, token.start_mark) skip_token(parser) } token := peek_token(parser) if token == nil { return false } if token.typ == yaml_KEY_TOKEN { mark := token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ != yaml_KEY_TOKEN && token.typ != yaml_VALUE_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_VALUE_STATE) return yaml_parser_parse_node(parser, event, true, true) } else { parser.state = yaml_PARSE_BLOCK_MAPPING_VALUE_STATE return yaml_parser_process_empty_scalar(parser, event, mark) } } else if token.typ == yaml_BLOCK_END_TOKEN { parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] parser.marks = parser.marks[:len(parser.marks)-1] *event = yaml_event_t{ typ: yaml_MAPPING_END_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, } skip_token(parser) return true } context_mark := parser.marks[len(parser.marks)-1] parser.marks = parser.marks[:len(parser.marks)-1] return yaml_parser_set_parser_error_context(parser, "while parsing a block mapping", context_mark, "did not find expected key", token.start_mark) } // Parse the productions: // block_mapping ::= BLOCK-MAPPING_START // // ((KEY block_node_or_indentless_sequence?)? // // (VALUE block_node_or_indentless_sequence?)?)* // ***** * // BLOCK-END // // func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ == yaml_VALUE_TOKEN { mark := token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ != yaml_KEY_TOKEN && token.typ != yaml_VALUE_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_KEY_STATE) return yaml_parser_parse_node(parser, event, true, true) } parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE return yaml_parser_process_empty_scalar(parser, event, mark) } parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE return yaml_parser_process_empty_scalar(parser, event, token.start_mark) } // Parse the productions: // flow_sequence ::= FLOW-SEQUENCE-START // ******************* // (flow_sequence_entry FLOW-ENTRY)* // * ********** // flow_sequence_entry? // * // FLOW-SEQUENCE-END // ***************** // flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // * // func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) parser.marks = append(parser.marks, token.start_mark) skip_token(parser) } token := peek_token(parser) if token == nil { return false } if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { if !first { if token.typ == yaml_FLOW_ENTRY_TOKEN { skip_token(parser) token = peek_token(parser) if token == nil { return false } } else { context_mark := parser.marks[len(parser.marks)-1] parser.marks = parser.marks[:len(parser.marks)-1] return yaml_parser_set_parser_error_context(parser, "while parsing a flow sequence", context_mark, "did not find expected ',' or ']'", token.start_mark) } } if token.typ == yaml_KEY_TOKEN { parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE *event = yaml_event_t{ typ: yaml_MAPPING_START_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, implicit: true, style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), } skip_token(parser) return true } else if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE) return yaml_parser_parse_node(parser, event, false, false) } } parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] parser.marks = parser.marks[:len(parser.marks)-1] *event = yaml_event_t{ typ: yaml_SEQUENCE_END_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, } skip_token(parser) return true } // // Parse the productions: // flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // *** * // func yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ != yaml_VALUE_TOKEN && token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE) return yaml_parser_parse_node(parser, event, false, false) } mark := token.end_mark skip_token(parser) parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE return yaml_parser_process_empty_scalar(parser, event, mark) } // Parse the productions: // flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // ***** * // func yaml_parser_parse_flow_sequence_entry_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ == yaml_VALUE_TOKEN { skip_token(parser) token := peek_token(parser) if token == nil { return false } if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE) return yaml_parser_parse_node(parser, event, false, false) } } parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE return yaml_parser_process_empty_scalar(parser, event, token.start_mark) } // Parse the productions: // flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // * // func yaml_parser_parse_flow_sequence_entry_mapping_end(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE *event = yaml_event_t{ typ: yaml_MAPPING_END_EVENT, start_mark: token.start_mark, end_mark: token.start_mark, // [Go] Shouldn't this be end_mark? } return true } // Parse the productions: // flow_mapping ::= FLOW-MAPPING-START // ****************** // (flow_mapping_entry FLOW-ENTRY)* // * ********** // flow_mapping_entry? // ****************** // FLOW-MAPPING-END // **************** // flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // * *** * // func yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) parser.marks = append(parser.marks, token.start_mark) skip_token(parser) } token := peek_token(parser) if token == nil { return false } if token.typ != yaml_FLOW_MAPPING_END_TOKEN { if !first { if token.typ == yaml_FLOW_ENTRY_TOKEN { skip_token(parser) token = peek_token(parser) if token == nil { return false } } else { context_mark := parser.marks[len(parser.marks)-1] parser.marks = parser.marks[:len(parser.marks)-1] return yaml_parser_set_parser_error_context(parser, "while parsing a flow mapping", context_mark, "did not find expected ',' or '}'", token.start_mark) } } if token.typ == yaml_KEY_TOKEN { skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ != yaml_VALUE_TOKEN && token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_MAPPING_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_VALUE_STATE) return yaml_parser_parse_node(parser, event, false, false) } else { parser.state = yaml_PARSE_FLOW_MAPPING_VALUE_STATE return yaml_parser_process_empty_scalar(parser, event, token.start_mark) } } else if token.typ != yaml_FLOW_MAPPING_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE) return yaml_parser_parse_node(parser, event, false, false) } } parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] parser.marks = parser.marks[:len(parser.marks)-1] *event = yaml_event_t{ typ: yaml_MAPPING_END_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, } skip_token(parser) return true } // Parse the productions: // flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // * ***** * // func yaml_parser_parse_flow_mapping_value(parser *yaml_parser_t, event *yaml_event_t, empty bool) bool { token := peek_token(parser) if token == nil { return false } if empty { parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE return yaml_parser_process_empty_scalar(parser, event, token.start_mark) } if token.typ == yaml_VALUE_TOKEN { skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_MAPPING_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_KEY_STATE) return yaml_parser_parse_node(parser, event, false, false) } } parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE return yaml_parser_process_empty_scalar(parser, event, token.start_mark) } // Generate an empty scalar event. func yaml_parser_process_empty_scalar(parser *yaml_parser_t, event *yaml_event_t, mark yaml_mark_t) bool { *event = yaml_event_t{ typ: yaml_SCALAR_EVENT, start_mark: mark, end_mark: mark, value: nil, // Empty implicit: true, style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), } return true } var default_tag_directives = []yaml_tag_directive_t{ {[]byte("!"), []byte("!")}, {[]byte("!!"), []byte("tag:yaml.org,2002:")}, } // Parse directives. func yaml_parser_process_directives(parser *yaml_parser_t, version_directive_ref **yaml_version_directive_t, tag_directives_ref *[]yaml_tag_directive_t) bool { var version_directive *yaml_version_directive_t var tag_directives []yaml_tag_directive_t token := peek_token(parser) if token == nil { return false } for token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN { if token.typ == yaml_VERSION_DIRECTIVE_TOKEN {
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/yaml.go
vendor/gopkg.in/yaml.v3/yaml.go
// // Copyright (c) 2011-2019 Canonical Ltd // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package yaml implements YAML support for the Go language. // // Source code and other details for the project are available at GitHub: // // https://github.com/go-yaml/yaml // package yaml import ( "errors" "fmt" "io" "reflect" "strings" "sync" "unicode/utf8" ) // The Unmarshaler interface may be implemented by types to customize their // behavior when being unmarshaled from a YAML document. type Unmarshaler interface { UnmarshalYAML(value *Node) error } type obsoleteUnmarshaler interface { UnmarshalYAML(unmarshal func(interface{}) error) error } // The Marshaler interface may be implemented by types to customize their // behavior when being marshaled into a YAML document. The returned value // is marshaled in place of the original value implementing Marshaler. // // If an error is returned by MarshalYAML, the marshaling procedure stops // and returns with the provided error. type Marshaler interface { MarshalYAML() (interface{}, error) } // Unmarshal decodes the first document found within the in byte slice // and assigns decoded values into the out value. // // Maps and pointers (to a struct, string, int, etc) are accepted as out // values. If an internal pointer within a struct is not initialized, // the yaml package will initialize it if necessary for unmarshalling // the provided data. The out parameter must not be nil. // // The type of the decoded values should be compatible with the respective // values in out. If one or more values cannot be decoded due to a type // mismatches, decoding continues partially until the end of the YAML // content, and a *yaml.TypeError is returned with details for all // missed values. // // Struct fields are only unmarshalled if they are exported (have an // upper case first letter), and are unmarshalled using the field name // lowercased as the default key. Custom keys may be defined via the // "yaml" name in the field tag: the content preceding the first comma // is used as the key, and the following comma-separated options are // used to tweak the marshalling process (see Marshal). // Conflicting names result in a runtime error. // // For example: // // type T struct { // F int `yaml:"a,omitempty"` // B int // } // var t T // yaml.Unmarshal([]byte("a: 1\nb: 2"), &t) // // See the documentation of Marshal for the format of tags and a list of // supported tag options. // func Unmarshal(in []byte, out interface{}) (err error) { return unmarshal(in, out, false) } // A Decoder reads and decodes YAML values from an input stream. type Decoder struct { parser *parser knownFields bool } // NewDecoder returns a new decoder that reads from r. // // The decoder introduces its own buffering and may read // data from r beyond the YAML values requested. func NewDecoder(r io.Reader) *Decoder { return &Decoder{ parser: newParserFromReader(r), } } // KnownFields ensures that the keys in decoded mappings to // exist as fields in the struct being decoded into. func (dec *Decoder) KnownFields(enable bool) { dec.knownFields = enable } // Decode reads the next YAML-encoded value from its input // and stores it in the value pointed to by v. // // See the documentation for Unmarshal for details about the // conversion of YAML into a Go value. func (dec *Decoder) Decode(v interface{}) (err error) { d := newDecoder() d.knownFields = dec.knownFields defer handleErr(&err) node := dec.parser.parse() if node == nil { return io.EOF } out := reflect.ValueOf(v) if out.Kind() == reflect.Ptr && !out.IsNil() { out = out.Elem() } d.unmarshal(node, out) if len(d.terrors) > 0 { return &TypeError{d.terrors} } return nil } // Decode decodes the node and stores its data into the value pointed to by v. // // See the documentation for Unmarshal for details about the // conversion of YAML into a Go value. func (n *Node) Decode(v interface{}) (err error) { d := newDecoder() defer handleErr(&err) out := reflect.ValueOf(v) if out.Kind() == reflect.Ptr && !out.IsNil() { out = out.Elem() } d.unmarshal(n, out) if len(d.terrors) > 0 { return &TypeError{d.terrors} } return nil } func unmarshal(in []byte, out interface{}, strict bool) (err error) { defer handleErr(&err) d := newDecoder() p := newParser(in) defer p.destroy() node := p.parse() if node != nil { v := reflect.ValueOf(out) if v.Kind() == reflect.Ptr && !v.IsNil() { v = v.Elem() } d.unmarshal(node, v) } if len(d.terrors) > 0 { return &TypeError{d.terrors} } return nil } // Marshal serializes the value provided into a YAML document. The structure // of the generated document will reflect the structure of the value itself. // Maps and pointers (to struct, string, int, etc) are accepted as the in value. // // Struct fields are only marshalled if they are exported (have an upper case // first letter), and are marshalled using the field name lowercased as the // default key. Custom keys may be defined via the "yaml" name in the field // tag: the content preceding the first comma is used as the key, and the // following comma-separated options are used to tweak the marshalling process. // Conflicting names result in a runtime error. // // The field tag format accepted is: // // `(...) yaml:"[<key>][,<flag1>[,<flag2>]]" (...)` // // The following flags are currently supported: // // omitempty Only include the field if it's not set to the zero // value for the type or to empty slices or maps. // Zero valued structs will be omitted if all their public // fields are zero, unless they implement an IsZero // method (see the IsZeroer interface type), in which // case the field will be excluded if IsZero returns true. // // flow Marshal using a flow style (useful for structs, // sequences and maps). // // inline Inline the field, which must be a struct or a map, // causing all of its fields or keys to be processed as if // they were part of the outer struct. For maps, keys must // not conflict with the yaml keys of other struct fields. // // In addition, if the key is "-", the field is ignored. // // For example: // // type T struct { // F int `yaml:"a,omitempty"` // B int // } // yaml.Marshal(&T{B: 2}) // Returns "b: 2\n" // yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n" // func Marshal(in interface{}) (out []byte, err error) { defer handleErr(&err) e := newEncoder() defer e.destroy() e.marshalDoc("", reflect.ValueOf(in)) e.finish() out = e.out return } // An Encoder writes YAML values to an output stream. type Encoder struct { encoder *encoder } // NewEncoder returns a new encoder that writes to w. // The Encoder should be closed after use to flush all data // to w. func NewEncoder(w io.Writer) *Encoder { return &Encoder{ encoder: newEncoderWithWriter(w), } } // Encode writes the YAML encoding of v to the stream. // If multiple items are encoded to the stream, the // second and subsequent document will be preceded // with a "---" document separator, but the first will not. // // See the documentation for Marshal for details about the conversion of Go // values to YAML. func (e *Encoder) Encode(v interface{}) (err error) { defer handleErr(&err) e.encoder.marshalDoc("", reflect.ValueOf(v)) return nil } // Encode encodes value v and stores its representation in n. // // See the documentation for Marshal for details about the // conversion of Go values into YAML. func (n *Node) Encode(v interface{}) (err error) { defer handleErr(&err) e := newEncoder() defer e.destroy() e.marshalDoc("", reflect.ValueOf(v)) e.finish() p := newParser(e.out) p.textless = true defer p.destroy() doc := p.parse() *n = *doc.Content[0] return nil } // SetIndent changes the used indentation used when encoding. func (e *Encoder) SetIndent(spaces int) { if spaces < 0 { panic("yaml: cannot indent to a negative number of spaces") } e.encoder.indent = spaces } // Close closes the encoder by writing any remaining data. // It does not write a stream terminating string "...". func (e *Encoder) Close() (err error) { defer handleErr(&err) e.encoder.finish() return nil } func handleErr(err *error) { if v := recover(); v != nil { if e, ok := v.(yamlError); ok { *err = e.err } else { panic(v) } } } type yamlError struct { err error } func fail(err error) { panic(yamlError{err}) } func failf(format string, args ...interface{}) { panic(yamlError{fmt.Errorf("yaml: "+format, args...)}) } // A TypeError is returned by Unmarshal when one or more fields in // the YAML document cannot be properly decoded into the requested // types. When this error is returned, the value is still // unmarshaled partially. type TypeError struct { Errors []string } func (e *TypeError) Error() string { return fmt.Sprintf("yaml: unmarshal errors:\n %s", strings.Join(e.Errors, "\n ")) } type Kind uint32 const ( DocumentNode Kind = 1 << iota SequenceNode MappingNode ScalarNode AliasNode ) type Style uint32 const ( TaggedStyle Style = 1 << iota DoubleQuotedStyle SingleQuotedStyle LiteralStyle FoldedStyle FlowStyle ) // Node represents an element in the YAML document hierarchy. While documents // are typically encoded and decoded into higher level types, such as structs // and maps, Node is an intermediate representation that allows detailed // control over the content being decoded or encoded. // // It's worth noting that although Node offers access into details such as // line numbers, colums, and comments, the content when re-encoded will not // have its original textual representation preserved. An effort is made to // render the data plesantly, and to preserve comments near the data they // describe, though. // // Values that make use of the Node type interact with the yaml package in the // same way any other type would do, by encoding and decoding yaml data // directly or indirectly into them. // // For example: // // var person struct { // Name string // Address yaml.Node // } // err := yaml.Unmarshal(data, &person) // // Or by itself: // // var person Node // err := yaml.Unmarshal(data, &person) // type Node struct { // Kind defines whether the node is a document, a mapping, a sequence, // a scalar value, or an alias to another node. The specific data type of // scalar nodes may be obtained via the ShortTag and LongTag methods. Kind Kind // Style allows customizing the apperance of the node in the tree. Style Style // Tag holds the YAML tag defining the data type for the value. // When decoding, this field will always be set to the resolved tag, // even when it wasn't explicitly provided in the YAML content. // When encoding, if this field is unset the value type will be // implied from the node properties, and if it is set, it will only // be serialized into the representation if TaggedStyle is used or // the implicit tag diverges from the provided one. Tag string // Value holds the unescaped and unquoted represenation of the value. Value string // Anchor holds the anchor name for this node, which allows aliases to point to it. Anchor string // Alias holds the node that this alias points to. Only valid when Kind is AliasNode. Alias *Node // Content holds contained nodes for documents, mappings, and sequences. Content []*Node // HeadComment holds any comments in the lines preceding the node and // not separated by an empty line. HeadComment string // LineComment holds any comments at the end of the line where the node is in. LineComment string // FootComment holds any comments following the node and before empty lines. FootComment string // Line and Column hold the node position in the decoded YAML text. // These fields are not respected when encoding the node. Line int Column int } // IsZero returns whether the node has all of its fields unset. func (n *Node) IsZero() bool { return n.Kind == 0 && n.Style == 0 && n.Tag == "" && n.Value == "" && n.Anchor == "" && n.Alias == nil && n.Content == nil && n.HeadComment == "" && n.LineComment == "" && n.FootComment == "" && n.Line == 0 && n.Column == 0 } // LongTag returns the long form of the tag that indicates the data type for // the node. If the Tag field isn't explicitly defined, one will be computed // based on the node properties. func (n *Node) LongTag() string { return longTag(n.ShortTag()) } // ShortTag returns the short form of the YAML tag that indicates data type for // the node. If the Tag field isn't explicitly defined, one will be computed // based on the node properties. func (n *Node) ShortTag() string { if n.indicatedString() { return strTag } if n.Tag == "" || n.Tag == "!" { switch n.Kind { case MappingNode: return mapTag case SequenceNode: return seqTag case AliasNode: if n.Alias != nil { return n.Alias.ShortTag() } case ScalarNode: tag, _ := resolve("", n.Value) return tag case 0: // Special case to make the zero value convenient. if n.IsZero() { return nullTag } } return "" } return shortTag(n.Tag) } func (n *Node) indicatedString() bool { return n.Kind == ScalarNode && (shortTag(n.Tag) == strTag || (n.Tag == "" || n.Tag == "!") && n.Style&(SingleQuotedStyle|DoubleQuotedStyle|LiteralStyle|FoldedStyle) != 0) } // SetString is a convenience function that sets the node to a string value // and defines its style in a pleasant way depending on its content. func (n *Node) SetString(s string) { n.Kind = ScalarNode if utf8.ValidString(s) { n.Value = s n.Tag = strTag } else { n.Value = encodeBase64(s) n.Tag = binaryTag } if strings.Contains(n.Value, "\n") { n.Style = LiteralStyle } } // -------------------------------------------------------------------------- // Maintain a mapping of keys to structure field indexes // The code in this section was copied from mgo/bson. // structInfo holds details for the serialization of fields of // a given struct. type structInfo struct { FieldsMap map[string]fieldInfo FieldsList []fieldInfo // InlineMap is the number of the field in the struct that // contains an ,inline map, or -1 if there's none. InlineMap int // InlineUnmarshalers holds indexes to inlined fields that // contain unmarshaler values. InlineUnmarshalers [][]int } type fieldInfo struct { Key string Num int OmitEmpty bool Flow bool // Id holds the unique field identifier, so we can cheaply // check for field duplicates without maintaining an extra map. Id int // Inline holds the field index if the field is part of an inlined struct. Inline []int } var structMap = make(map[reflect.Type]*structInfo) var fieldMapMutex sync.RWMutex var unmarshalerType reflect.Type func init() { var v Unmarshaler unmarshalerType = reflect.ValueOf(&v).Elem().Type() } func getStructInfo(st reflect.Type) (*structInfo, error) { fieldMapMutex.RLock() sinfo, found := structMap[st] fieldMapMutex.RUnlock() if found { return sinfo, nil } n := st.NumField() fieldsMap := make(map[string]fieldInfo) fieldsList := make([]fieldInfo, 0, n) inlineMap := -1 inlineUnmarshalers := [][]int(nil) for i := 0; i != n; i++ { field := st.Field(i) if field.PkgPath != "" && !field.Anonymous { continue // Private field } info := fieldInfo{Num: i} tag := field.Tag.Get("yaml") if tag == "" && strings.Index(string(field.Tag), ":") < 0 { tag = string(field.Tag) } if tag == "-" { continue } inline := false fields := strings.Split(tag, ",") if len(fields) > 1 { for _, flag := range fields[1:] { switch flag { case "omitempty": info.OmitEmpty = true case "flow": info.Flow = true case "inline": inline = true default: return nil, errors.New(fmt.Sprintf("unsupported flag %q in tag %q of type %s", flag, tag, st)) } } tag = fields[0] } if inline { switch field.Type.Kind() { case reflect.Map: if inlineMap >= 0 { return nil, errors.New("multiple ,inline maps in struct " + st.String()) } if field.Type.Key() != reflect.TypeOf("") { return nil, errors.New("option ,inline needs a map with string keys in struct " + st.String()) } inlineMap = info.Num case reflect.Struct, reflect.Ptr: ftype := field.Type for ftype.Kind() == reflect.Ptr { ftype = ftype.Elem() } if ftype.Kind() != reflect.Struct { return nil, errors.New("option ,inline may only be used on a struct or map field") } if reflect.PtrTo(ftype).Implements(unmarshalerType) { inlineUnmarshalers = append(inlineUnmarshalers, []int{i}) } else { sinfo, err := getStructInfo(ftype) if err != nil { return nil, err } for _, index := range sinfo.InlineUnmarshalers { inlineUnmarshalers = append(inlineUnmarshalers, append([]int{i}, index...)) } for _, finfo := range sinfo.FieldsList { if _, found := fieldsMap[finfo.Key]; found { msg := "duplicated key '" + finfo.Key + "' in struct " + st.String() return nil, errors.New(msg) } if finfo.Inline == nil { finfo.Inline = []int{i, finfo.Num} } else { finfo.Inline = append([]int{i}, finfo.Inline...) } finfo.Id = len(fieldsList) fieldsMap[finfo.Key] = finfo fieldsList = append(fieldsList, finfo) } } default: return nil, errors.New("option ,inline may only be used on a struct or map field") } continue } if tag != "" { info.Key = tag } else { info.Key = strings.ToLower(field.Name) } if _, found = fieldsMap[info.Key]; found { msg := "duplicated key '" + info.Key + "' in struct " + st.String() return nil, errors.New(msg) } info.Id = len(fieldsList) fieldsList = append(fieldsList, info) fieldsMap[info.Key] = info } sinfo = &structInfo{ FieldsMap: fieldsMap, FieldsList: fieldsList, InlineMap: inlineMap, InlineUnmarshalers: inlineUnmarshalers, } fieldMapMutex.Lock() structMap[st] = sinfo fieldMapMutex.Unlock() return sinfo, nil } // IsZeroer is used to check whether an object is zero to // determine whether it should be omitted when marshaling // with the omitempty flag. One notable implementation // is time.Time. type IsZeroer interface { IsZero() bool } func isZero(v reflect.Value) bool { kind := v.Kind() if z, ok := v.Interface().(IsZeroer); ok { if (kind == reflect.Ptr || kind == reflect.Interface) && v.IsNil() { return true } return z.IsZero() } switch kind { case reflect.String: return len(v.String()) == 0 case reflect.Interface, reflect.Ptr: return v.IsNil() case reflect.Slice: return v.Len() == 0 case reflect.Map: return v.Len() == 0 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return v.Int() == 0 case reflect.Float32, reflect.Float64: return v.Float() == 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return v.Uint() == 0 case reflect.Bool: return !v.Bool() case reflect.Struct: vt := v.Type() for i := v.NumField() - 1; i >= 0; i-- { if vt.Field(i).PkgPath != "" { continue // Private field } if !isZero(v.Field(i)) { return false } } return true } return false }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/emitterc.go
vendor/gopkg.in/yaml.v3/emitterc.go
// // Copyright (c) 2011-2019 Canonical Ltd // Copyright (c) 2006-2010 Kirill Simonov // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies // of the Software, and to permit persons to whom the Software is furnished to do // so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. package yaml import ( "bytes" "fmt" ) // Flush the buffer if needed. func flush(emitter *yaml_emitter_t) bool { if emitter.buffer_pos+5 >= len(emitter.buffer) { return yaml_emitter_flush(emitter) } return true } // Put a character to the output buffer. func put(emitter *yaml_emitter_t, value byte) bool { if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { return false } emitter.buffer[emitter.buffer_pos] = value emitter.buffer_pos++ emitter.column++ return true } // Put a line break to the output buffer. func put_break(emitter *yaml_emitter_t) bool { if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { return false } switch emitter.line_break { case yaml_CR_BREAK: emitter.buffer[emitter.buffer_pos] = '\r' emitter.buffer_pos += 1 case yaml_LN_BREAK: emitter.buffer[emitter.buffer_pos] = '\n' emitter.buffer_pos += 1 case yaml_CRLN_BREAK: emitter.buffer[emitter.buffer_pos+0] = '\r' emitter.buffer[emitter.buffer_pos+1] = '\n' emitter.buffer_pos += 2 default: panic("unknown line break setting") } if emitter.column == 0 { emitter.space_above = true } emitter.column = 0 emitter.line++ // [Go] Do this here and below and drop from everywhere else (see commented lines). emitter.indention = true return true } // Copy a character from a string into buffer. func write(emitter *yaml_emitter_t, s []byte, i *int) bool { if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { return false } p := emitter.buffer_pos w := width(s[*i]) switch w { case 4: emitter.buffer[p+3] = s[*i+3] fallthrough case 3: emitter.buffer[p+2] = s[*i+2] fallthrough case 2: emitter.buffer[p+1] = s[*i+1] fallthrough case 1: emitter.buffer[p+0] = s[*i+0] default: panic("unknown character width") } emitter.column++ emitter.buffer_pos += w *i += w return true } // Write a whole string into buffer. func write_all(emitter *yaml_emitter_t, s []byte) bool { for i := 0; i < len(s); { if !write(emitter, s, &i) { return false } } return true } // Copy a line break character from a string into buffer. func write_break(emitter *yaml_emitter_t, s []byte, i *int) bool { if s[*i] == '\n' { if !put_break(emitter) { return false } *i++ } else { if !write(emitter, s, i) { return false } if emitter.column == 0 { emitter.space_above = true } emitter.column = 0 emitter.line++ // [Go] Do this here and above and drop from everywhere else (see commented lines). emitter.indention = true } return true } // Set an emitter error and return false. func yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool { emitter.error = yaml_EMITTER_ERROR emitter.problem = problem return false } // Emit an event. func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool { emitter.events = append(emitter.events, *event) for !yaml_emitter_need_more_events(emitter) { event := &emitter.events[emitter.events_head] if !yaml_emitter_analyze_event(emitter, event) { return false } if !yaml_emitter_state_machine(emitter, event) { return false } yaml_event_delete(event) emitter.events_head++ } return true } // Check if we need to accumulate more events before emitting. // // We accumulate extra // - 1 event for DOCUMENT-START // - 2 events for SEQUENCE-START // - 3 events for MAPPING-START // func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool { if emitter.events_head == len(emitter.events) { return true } var accumulate int switch emitter.events[emitter.events_head].typ { case yaml_DOCUMENT_START_EVENT: accumulate = 1 break case yaml_SEQUENCE_START_EVENT: accumulate = 2 break case yaml_MAPPING_START_EVENT: accumulate = 3 break default: return false } if len(emitter.events)-emitter.events_head > accumulate { return false } var level int for i := emitter.events_head; i < len(emitter.events); i++ { switch emitter.events[i].typ { case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT: level++ case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT: level-- } if level == 0 { return false } } return true } // Append a directive to the directives stack. func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool { for i := 0; i < len(emitter.tag_directives); i++ { if bytes.Equal(value.handle, emitter.tag_directives[i].handle) { if allow_duplicates { return true } return yaml_emitter_set_emitter_error(emitter, "duplicate %TAG directive") } } // [Go] Do we actually need to copy this given garbage collection // and the lack of deallocating destructors? tag_copy := yaml_tag_directive_t{ handle: make([]byte, len(value.handle)), prefix: make([]byte, len(value.prefix)), } copy(tag_copy.handle, value.handle) copy(tag_copy.prefix, value.prefix) emitter.tag_directives = append(emitter.tag_directives, tag_copy) return true } // Increase the indentation level. func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool { emitter.indents = append(emitter.indents, emitter.indent) if emitter.indent < 0 { if flow { emitter.indent = emitter.best_indent } else { emitter.indent = 0 } } else if !indentless { // [Go] This was changed so that indentations are more regular. if emitter.states[len(emitter.states)-1] == yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE { // The first indent inside a sequence will just skip the "- " indicator. emitter.indent += 2 } else { // Everything else aligns to the chosen indentation. emitter.indent = emitter.best_indent*((emitter.indent+emitter.best_indent)/emitter.best_indent) } } return true } // State dispatcher. func yaml_emitter_state_machine(emitter *yaml_emitter_t, event *yaml_event_t) bool { switch emitter.state { default: case yaml_EMIT_STREAM_START_STATE: return yaml_emitter_emit_stream_start(emitter, event) case yaml_EMIT_FIRST_DOCUMENT_START_STATE: return yaml_emitter_emit_document_start(emitter, event, true) case yaml_EMIT_DOCUMENT_START_STATE: return yaml_emitter_emit_document_start(emitter, event, false) case yaml_EMIT_DOCUMENT_CONTENT_STATE: return yaml_emitter_emit_document_content(emitter, event) case yaml_EMIT_DOCUMENT_END_STATE: return yaml_emitter_emit_document_end(emitter, event) case yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE: return yaml_emitter_emit_flow_sequence_item(emitter, event, true, false) case yaml_EMIT_FLOW_SEQUENCE_TRAIL_ITEM_STATE: return yaml_emitter_emit_flow_sequence_item(emitter, event, false, true) case yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE: return yaml_emitter_emit_flow_sequence_item(emitter, event, false, false) case yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE: return yaml_emitter_emit_flow_mapping_key(emitter, event, true, false) case yaml_EMIT_FLOW_MAPPING_TRAIL_KEY_STATE: return yaml_emitter_emit_flow_mapping_key(emitter, event, false, true) case yaml_EMIT_FLOW_MAPPING_KEY_STATE: return yaml_emitter_emit_flow_mapping_key(emitter, event, false, false) case yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE: return yaml_emitter_emit_flow_mapping_value(emitter, event, true) case yaml_EMIT_FLOW_MAPPING_VALUE_STATE: return yaml_emitter_emit_flow_mapping_value(emitter, event, false) case yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE: return yaml_emitter_emit_block_sequence_item(emitter, event, true) case yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE: return yaml_emitter_emit_block_sequence_item(emitter, event, false) case yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE: return yaml_emitter_emit_block_mapping_key(emitter, event, true) case yaml_EMIT_BLOCK_MAPPING_KEY_STATE: return yaml_emitter_emit_block_mapping_key(emitter, event, false) case yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE: return yaml_emitter_emit_block_mapping_value(emitter, event, true) case yaml_EMIT_BLOCK_MAPPING_VALUE_STATE: return yaml_emitter_emit_block_mapping_value(emitter, event, false) case yaml_EMIT_END_STATE: return yaml_emitter_set_emitter_error(emitter, "expected nothing after STREAM-END") } panic("invalid emitter state") } // Expect STREAM-START. func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { if event.typ != yaml_STREAM_START_EVENT { return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START") } if emitter.encoding == yaml_ANY_ENCODING { emitter.encoding = event.encoding if emitter.encoding == yaml_ANY_ENCODING { emitter.encoding = yaml_UTF8_ENCODING } } if emitter.best_indent < 2 || emitter.best_indent > 9 { emitter.best_indent = 2 } if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 { emitter.best_width = 80 } if emitter.best_width < 0 { emitter.best_width = 1<<31 - 1 } if emitter.line_break == yaml_ANY_BREAK { emitter.line_break = yaml_LN_BREAK } emitter.indent = -1 emitter.line = 0 emitter.column = 0 emitter.whitespace = true emitter.indention = true emitter.space_above = true emitter.foot_indent = -1 if emitter.encoding != yaml_UTF8_ENCODING { if !yaml_emitter_write_bom(emitter) { return false } } emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE return true } // Expect DOCUMENT-START or STREAM-END. func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if event.typ == yaml_DOCUMENT_START_EVENT { if event.version_directive != nil { if !yaml_emitter_analyze_version_directive(emitter, event.version_directive) { return false } } for i := 0; i < len(event.tag_directives); i++ { tag_directive := &event.tag_directives[i] if !yaml_emitter_analyze_tag_directive(emitter, tag_directive) { return false } if !yaml_emitter_append_tag_directive(emitter, tag_directive, false) { return false } } for i := 0; i < len(default_tag_directives); i++ { tag_directive := &default_tag_directives[i] if !yaml_emitter_append_tag_directive(emitter, tag_directive, true) { return false } } implicit := event.implicit if !first || emitter.canonical { implicit = false } if emitter.open_ended && (event.version_directive != nil || len(event.tag_directives) > 0) { if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if event.version_directive != nil { implicit = false if !yaml_emitter_write_indicator(emitter, []byte("%YAML"), true, false, false) { return false } if !yaml_emitter_write_indicator(emitter, []byte("1.1"), true, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if len(event.tag_directives) > 0 { implicit = false for i := 0; i < len(event.tag_directives); i++ { tag_directive := &event.tag_directives[i] if !yaml_emitter_write_indicator(emitter, []byte("%TAG"), true, false, false) { return false } if !yaml_emitter_write_tag_handle(emitter, tag_directive.handle) { return false } if !yaml_emitter_write_tag_content(emitter, tag_directive.prefix, true) { return false } if !yaml_emitter_write_indent(emitter) { return false } } } if yaml_emitter_check_empty_document(emitter) { implicit = false } if !implicit { if !yaml_emitter_write_indent(emitter) { return false } if !yaml_emitter_write_indicator(emitter, []byte("---"), true, false, false) { return false } if emitter.canonical || true { if !yaml_emitter_write_indent(emitter) { return false } } } if len(emitter.head_comment) > 0 { if !yaml_emitter_process_head_comment(emitter) { return false } if !put_break(emitter) { return false } } emitter.state = yaml_EMIT_DOCUMENT_CONTENT_STATE return true } if event.typ == yaml_STREAM_END_EVENT { if emitter.open_ended { if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_flush(emitter) { return false } emitter.state = yaml_EMIT_END_STATE return true } return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-START or STREAM-END") } // Expect the root node. func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool { emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE) if !yaml_emitter_process_head_comment(emitter) { return false } if !yaml_emitter_emit_node(emitter, event, true, false, false, false) { return false } if !yaml_emitter_process_line_comment(emitter) { return false } if !yaml_emitter_process_foot_comment(emitter) { return false } return true } // Expect DOCUMENT-END. func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool { if event.typ != yaml_DOCUMENT_END_EVENT { return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END") } // [Go] Force document foot separation. emitter.foot_indent = 0 if !yaml_emitter_process_foot_comment(emitter) { return false } emitter.foot_indent = -1 if !yaml_emitter_write_indent(emitter) { return false } if !event.implicit { // [Go] Allocate the slice elsewhere. if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_flush(emitter) { return false } emitter.state = yaml_EMIT_DOCUMENT_START_STATE emitter.tag_directives = emitter.tag_directives[:0] return true } // Expect a flow item node. func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first, trail bool) bool { if first { if !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) { return false } if !yaml_emitter_increase_indent(emitter, true, false) { return false } emitter.flow_level++ } if event.typ == yaml_SEQUENCE_END_EVENT { if emitter.canonical && !first && !trail { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } } emitter.flow_level-- emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] if emitter.column == 0 || emitter.canonical && !first { if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) { return false } if !yaml_emitter_process_line_comment(emitter) { return false } if !yaml_emitter_process_foot_comment(emitter) { return false } emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !first && !trail { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } } if !yaml_emitter_process_head_comment(emitter) { return false } if emitter.column == 0 { if !yaml_emitter_write_indent(emitter) { return false } } if emitter.canonical || emitter.column > emitter.best_width { if !yaml_emitter_write_indent(emitter) { return false } } if len(emitter.line_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0 { emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_TRAIL_ITEM_STATE) } else { emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE) } if !yaml_emitter_emit_node(emitter, event, false, true, false, false) { return false } if len(emitter.line_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0 { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } } if !yaml_emitter_process_line_comment(emitter) { return false } if !yaml_emitter_process_foot_comment(emitter) { return false } return true } // Expect a flow key node. func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first, trail bool) bool { if first { if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) { return false } if !yaml_emitter_increase_indent(emitter, true, false) { return false } emitter.flow_level++ } if event.typ == yaml_MAPPING_END_EVENT { if (emitter.canonical || len(emitter.head_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0) && !first && !trail { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } } if !yaml_emitter_process_head_comment(emitter) { return false } emitter.flow_level-- emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] if emitter.canonical && !first { if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) { return false } if !yaml_emitter_process_line_comment(emitter) { return false } if !yaml_emitter_process_foot_comment(emitter) { return false } emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !first && !trail { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } } if !yaml_emitter_process_head_comment(emitter) { return false } if emitter.column == 0 { if !yaml_emitter_write_indent(emitter) { return false } } if emitter.canonical || emitter.column > emitter.best_width { if !yaml_emitter_write_indent(emitter) { return false } } if !emitter.canonical && yaml_emitter_check_simple_key(emitter) { emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, true) } if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) { return false } emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) } // Expect a flow value node. func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { if simple { if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { return false } } else { if emitter.canonical || emitter.column > emitter.best_width { if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) { return false } } if len(emitter.line_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0 { emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_TRAIL_KEY_STATE) } else { emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE) } if !yaml_emitter_emit_node(emitter, event, false, false, true, false) { return false } if len(emitter.line_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0 { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } } if !yaml_emitter_process_line_comment(emitter) { return false } if !yaml_emitter_process_foot_comment(emitter) { return false } return true } // Expect a block item node. func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_increase_indent(emitter, false, false) { return false } } if event.typ == yaml_SEQUENCE_END_EVENT { emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !yaml_emitter_process_head_comment(emitter) { return false } if !yaml_emitter_write_indent(emitter) { return false } if !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) { return false } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE) if !yaml_emitter_emit_node(emitter, event, false, true, false, false) { return false } if !yaml_emitter_process_line_comment(emitter) { return false } if !yaml_emitter_process_foot_comment(emitter) { return false } return true } // Expect a block key node. func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_increase_indent(emitter, false, false) { return false } } if !yaml_emitter_process_head_comment(emitter) { return false } if event.typ == yaml_MAPPING_END_EVENT { emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !yaml_emitter_write_indent(emitter) { return false } if len(emitter.line_comment) > 0 { // [Go] A line comment was provided for the key. That's unusual as the // scanner associates line comments with the value. Either way, // save the line comment and render it appropriately later. emitter.key_line_comment = emitter.line_comment emitter.line_comment = nil } if yaml_emitter_check_simple_key(emitter) { emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, true) } if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) { return false } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) } // Expect a block value node. func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { if simple { if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { return false } } else { if !yaml_emitter_write_indent(emitter) { return false } if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) { return false } } if len(emitter.key_line_comment) > 0 { // [Go] Line comments are generally associated with the value, but when there's // no value on the same line as a mapping key they end up attached to the // key itself. if event.typ == yaml_SCALAR_EVENT { if len(emitter.line_comment) == 0 { // A scalar is coming and it has no line comments by itself yet, // so just let it handle the line comment as usual. If it has a // line comment, we can't have both so the one from the key is lost. emitter.line_comment = emitter.key_line_comment emitter.key_line_comment = nil } } else if event.sequence_style() != yaml_FLOW_SEQUENCE_STYLE && (event.typ == yaml_MAPPING_START_EVENT || event.typ == yaml_SEQUENCE_START_EVENT) { // An indented block follows, so write the comment right now. emitter.line_comment, emitter.key_line_comment = emitter.key_line_comment, emitter.line_comment if !yaml_emitter_process_line_comment(emitter) { return false } emitter.line_comment, emitter.key_line_comment = emitter.key_line_comment, emitter.line_comment } } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE) if !yaml_emitter_emit_node(emitter, event, false, false, true, false) { return false } if !yaml_emitter_process_line_comment(emitter) { return false } if !yaml_emitter_process_foot_comment(emitter) { return false } return true } func yaml_emitter_silent_nil_event(emitter *yaml_emitter_t, event *yaml_event_t) bool { return event.typ == yaml_SCALAR_EVENT && event.implicit && !emitter.canonical && len(emitter.scalar_data.value) == 0 } // Expect a node. func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t, root bool, sequence bool, mapping bool, simple_key bool) bool { emitter.root_context = root emitter.sequence_context = sequence emitter.mapping_context = mapping emitter.simple_key_context = simple_key switch event.typ { case yaml_ALIAS_EVENT: return yaml_emitter_emit_alias(emitter, event) case yaml_SCALAR_EVENT: return yaml_emitter_emit_scalar(emitter, event) case yaml_SEQUENCE_START_EVENT: return yaml_emitter_emit_sequence_start(emitter, event) case yaml_MAPPING_START_EVENT: return yaml_emitter_emit_mapping_start(emitter, event) default: return yaml_emitter_set_emitter_error(emitter, fmt.Sprintf("expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS, but got %v", event.typ)) } } // Expect ALIAS. func yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } // Expect SCALAR. func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_select_scalar_style(emitter, event) { return false } if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if !yaml_emitter_increase_indent(emitter, true, false) { return false } if !yaml_emitter_process_scalar(emitter) { return false } emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } // Expect SEQUENCE-START. func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE || yaml_emitter_check_empty_sequence(emitter) { emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE } else { emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE } return true } // Expect MAPPING-START. func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE || yaml_emitter_check_empty_mapping(emitter) { emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE } else { emitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE } return true } // Check if the document content is an empty scalar. func yaml_emitter_check_empty_document(emitter *yaml_emitter_t) bool { return false // [Go] Huh? } // Check if the next events represent an empty sequence. func yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool { if len(emitter.events)-emitter.events_head < 2 { return false } return emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT && emitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT } // Check if the next events represent an empty mapping. func yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool { if len(emitter.events)-emitter.events_head < 2 { return false } return emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT && emitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT } // Check if the next node can be expressed as a simple key. func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool { length := 0 switch emitter.events[emitter.events_head].typ { case yaml_ALIAS_EVENT: length += len(emitter.anchor_data.anchor) case yaml_SCALAR_EVENT: if emitter.scalar_data.multiline { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) + len(emitter.scalar_data.value) case yaml_SEQUENCE_START_EVENT: if !yaml_emitter_check_empty_sequence(emitter) { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) case yaml_MAPPING_START_EVENT: if !yaml_emitter_check_empty_mapping(emitter) { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) default: return false } return length <= 128 } // Determine an acceptable scalar style. func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool { no_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 if no_tag && !event.implicit && !event.quoted_implicit { return yaml_emitter_set_emitter_error(emitter, "neither tag nor implicit flags are specified") } style := event.scalar_style() if style == yaml_ANY_SCALAR_STYLE { style = yaml_PLAIN_SCALAR_STYLE } if emitter.canonical { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } if emitter.simple_key_context && emitter.scalar_data.multiline { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } if style == yaml_PLAIN_SCALAR_STYLE { if emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed || emitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } if len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } if no_tag && !event.implicit { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } } if style == yaml_SINGLE_QUOTED_SCALAR_STYLE { if !emitter.scalar_data.single_quoted_allowed { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } } if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE { if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } } if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE { emitter.tag_data.handle = []byte{'!'} } emitter.scalar_data.style = style return true } // Write an anchor. func yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool { if emitter.anchor_data.anchor == nil { return true } c := []byte{'&'} if emitter.anchor_data.alias { c[0] = '*' } if !yaml_emitter_write_indicator(emitter, c, true, false, false) { return false } return yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor) } // Write a tag. func yaml_emitter_process_tag(emitter *yaml_emitter_t) bool { if len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 { return true } if len(emitter.tag_data.handle) > 0 { if !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) { return false } if len(emitter.tag_data.suffix) > 0 { if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { return false } } } else { // [Go] Allocate these slices elsewhere. if !yaml_emitter_write_indicator(emitter, []byte("!<"), true, false, false) { return false } if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { return false }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/resolve.go
vendor/gopkg.in/yaml.v3/resolve.go
// // Copyright (c) 2011-2019 Canonical Ltd // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package yaml import ( "encoding/base64" "math" "regexp" "strconv" "strings" "time" ) type resolveMapItem struct { value interface{} tag string } var resolveTable = make([]byte, 256) var resolveMap = make(map[string]resolveMapItem) func init() { t := resolveTable t[int('+')] = 'S' // Sign t[int('-')] = 'S' for _, c := range "0123456789" { t[int(c)] = 'D' // Digit } for _, c := range "yYnNtTfFoO~" { t[int(c)] = 'M' // In map } t[int('.')] = '.' // Float (potentially in map) var resolveMapList = []struct { v interface{} tag string l []string }{ {true, boolTag, []string{"true", "True", "TRUE"}}, {false, boolTag, []string{"false", "False", "FALSE"}}, {nil, nullTag, []string{"", "~", "null", "Null", "NULL"}}, {math.NaN(), floatTag, []string{".nan", ".NaN", ".NAN"}}, {math.Inf(+1), floatTag, []string{".inf", ".Inf", ".INF"}}, {math.Inf(+1), floatTag, []string{"+.inf", "+.Inf", "+.INF"}}, {math.Inf(-1), floatTag, []string{"-.inf", "-.Inf", "-.INF"}}, {"<<", mergeTag, []string{"<<"}}, } m := resolveMap for _, item := range resolveMapList { for _, s := range item.l { m[s] = resolveMapItem{item.v, item.tag} } } } const ( nullTag = "!!null" boolTag = "!!bool" strTag = "!!str" intTag = "!!int" floatTag = "!!float" timestampTag = "!!timestamp" seqTag = "!!seq" mapTag = "!!map" binaryTag = "!!binary" mergeTag = "!!merge" ) var longTags = make(map[string]string) var shortTags = make(map[string]string) func init() { for _, stag := range []string{nullTag, boolTag, strTag, intTag, floatTag, timestampTag, seqTag, mapTag, binaryTag, mergeTag} { ltag := longTag(stag) longTags[stag] = ltag shortTags[ltag] = stag } } const longTagPrefix = "tag:yaml.org,2002:" func shortTag(tag string) string { if strings.HasPrefix(tag, longTagPrefix) { if stag, ok := shortTags[tag]; ok { return stag } return "!!" + tag[len(longTagPrefix):] } return tag } func longTag(tag string) string { if strings.HasPrefix(tag, "!!") { if ltag, ok := longTags[tag]; ok { return ltag } return longTagPrefix + tag[2:] } return tag } func resolvableTag(tag string) bool { switch tag { case "", strTag, boolTag, intTag, floatTag, nullTag, timestampTag: return true } return false } var yamlStyleFloat = regexp.MustCompile(`^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?$`) func resolve(tag string, in string) (rtag string, out interface{}) { tag = shortTag(tag) if !resolvableTag(tag) { return tag, in } defer func() { switch tag { case "", rtag, strTag, binaryTag: return case floatTag: if rtag == intTag { switch v := out.(type) { case int64: rtag = floatTag out = float64(v) return case int: rtag = floatTag out = float64(v) return } } } failf("cannot decode %s `%s` as a %s", shortTag(rtag), in, shortTag(tag)) }() // Any data is accepted as a !!str or !!binary. // Otherwise, the prefix is enough of a hint about what it might be. hint := byte('N') if in != "" { hint = resolveTable[in[0]] } if hint != 0 && tag != strTag && tag != binaryTag { // Handle things we can lookup in a map. if item, ok := resolveMap[in]; ok { return item.tag, item.value } // Base 60 floats are a bad idea, were dropped in YAML 1.2, and // are purposefully unsupported here. They're still quoted on // the way out for compatibility with other parser, though. switch hint { case 'M': // We've already checked the map above. case '.': // Not in the map, so maybe a normal float. floatv, err := strconv.ParseFloat(in, 64) if err == nil { return floatTag, floatv } case 'D', 'S': // Int, float, or timestamp. // Only try values as a timestamp if the value is unquoted or there's an explicit // !!timestamp tag. if tag == "" || tag == timestampTag { t, ok := parseTimestamp(in) if ok { return timestampTag, t } } plain := strings.Replace(in, "_", "", -1) intv, err := strconv.ParseInt(plain, 0, 64) if err == nil { if intv == int64(int(intv)) { return intTag, int(intv) } else { return intTag, intv } } uintv, err := strconv.ParseUint(plain, 0, 64) if err == nil { return intTag, uintv } if yamlStyleFloat.MatchString(plain) { floatv, err := strconv.ParseFloat(plain, 64) if err == nil { return floatTag, floatv } } if strings.HasPrefix(plain, "0b") { intv, err := strconv.ParseInt(plain[2:], 2, 64) if err == nil { if intv == int64(int(intv)) { return intTag, int(intv) } else { return intTag, intv } } uintv, err := strconv.ParseUint(plain[2:], 2, 64) if err == nil { return intTag, uintv } } else if strings.HasPrefix(plain, "-0b") { intv, err := strconv.ParseInt("-"+plain[3:], 2, 64) if err == nil { if true || intv == int64(int(intv)) { return intTag, int(intv) } else { return intTag, intv } } } // Octals as introduced in version 1.2 of the spec. // Octals from the 1.1 spec, spelled as 0777, are still // decoded by default in v3 as well for compatibility. // May be dropped in v4 depending on how usage evolves. if strings.HasPrefix(plain, "0o") { intv, err := strconv.ParseInt(plain[2:], 8, 64) if err == nil { if intv == int64(int(intv)) { return intTag, int(intv) } else { return intTag, intv } } uintv, err := strconv.ParseUint(plain[2:], 8, 64) if err == nil { return intTag, uintv } } else if strings.HasPrefix(plain, "-0o") { intv, err := strconv.ParseInt("-"+plain[3:], 8, 64) if err == nil { if true || intv == int64(int(intv)) { return intTag, int(intv) } else { return intTag, intv } } } default: panic("internal error: missing handler for resolver table: " + string(rune(hint)) + " (with " + in + ")") } } return strTag, in } // encodeBase64 encodes s as base64 that is broken up into multiple lines // as appropriate for the resulting length. func encodeBase64(s string) string { const lineLen = 70 encLen := base64.StdEncoding.EncodedLen(len(s)) lines := encLen/lineLen + 1 buf := make([]byte, encLen*2+lines) in := buf[0:encLen] out := buf[encLen:] base64.StdEncoding.Encode(in, []byte(s)) k := 0 for i := 0; i < len(in); i += lineLen { j := i + lineLen if j > len(in) { j = len(in) } k += copy(out[k:], in[i:j]) if lines > 1 { out[k] = '\n' k++ } } return string(out[:k]) } // This is a subset of the formats allowed by the regular expression // defined at http://yaml.org/type/timestamp.html. var allowedTimestampFormats = []string{ "2006-1-2T15:4:5.999999999Z07:00", // RCF3339Nano with short date fields. "2006-1-2t15:4:5.999999999Z07:00", // RFC3339Nano with short date fields and lower-case "t". "2006-1-2 15:4:5.999999999", // space separated with no time zone "2006-1-2", // date only // Notable exception: time.Parse cannot handle: "2001-12-14 21:59:43.10 -5" // from the set of examples. } // parseTimestamp parses s as a timestamp string and // returns the timestamp and reports whether it succeeded. // Timestamp formats are defined at http://yaml.org/type/timestamp.html func parseTimestamp(s string) (time.Time, bool) { // TODO write code to check all the formats supported by // http://yaml.org/type/timestamp.html instead of using time.Parse. // Quick check: all date formats start with YYYY-. i := 0 for ; i < len(s); i++ { if c := s[i]; c < '0' || c > '9' { break } } if i != 4 || i == len(s) || s[i] != '-' { return time.Time{}, false } for _, format := range allowedTimestampFormats { if t, err := time.Parse(format, s); err == nil { return t, true } } return time.Time{}, false }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/apic.go
vendor/gopkg.in/yaml.v3/apic.go
// // Copyright (c) 2011-2019 Canonical Ltd // Copyright (c) 2006-2010 Kirill Simonov // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies // of the Software, and to permit persons to whom the Software is furnished to do // so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. package yaml import ( "io" ) func yaml_insert_token(parser *yaml_parser_t, pos int, token *yaml_token_t) { //fmt.Println("yaml_insert_token", "pos:", pos, "typ:", token.typ, "head:", parser.tokens_head, "len:", len(parser.tokens)) // Check if we can move the queue at the beginning of the buffer. if parser.tokens_head > 0 && len(parser.tokens) == cap(parser.tokens) { if parser.tokens_head != len(parser.tokens) { copy(parser.tokens, parser.tokens[parser.tokens_head:]) } parser.tokens = parser.tokens[:len(parser.tokens)-parser.tokens_head] parser.tokens_head = 0 } parser.tokens = append(parser.tokens, *token) if pos < 0 { return } copy(parser.tokens[parser.tokens_head+pos+1:], parser.tokens[parser.tokens_head+pos:]) parser.tokens[parser.tokens_head+pos] = *token } // Create a new parser object. func yaml_parser_initialize(parser *yaml_parser_t) bool { *parser = yaml_parser_t{ raw_buffer: make([]byte, 0, input_raw_buffer_size), buffer: make([]byte, 0, input_buffer_size), } return true } // Destroy a parser object. func yaml_parser_delete(parser *yaml_parser_t) { *parser = yaml_parser_t{} } // String read handler. func yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { if parser.input_pos == len(parser.input) { return 0, io.EOF } n = copy(buffer, parser.input[parser.input_pos:]) parser.input_pos += n return n, nil } // Reader read handler. func yaml_reader_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { return parser.input_reader.Read(buffer) } // Set a string input. func yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) { if parser.read_handler != nil { panic("must set the input source only once") } parser.read_handler = yaml_string_read_handler parser.input = input parser.input_pos = 0 } // Set a file input. func yaml_parser_set_input_reader(parser *yaml_parser_t, r io.Reader) { if parser.read_handler != nil { panic("must set the input source only once") } parser.read_handler = yaml_reader_read_handler parser.input_reader = r } // Set the source encoding. func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) { if parser.encoding != yaml_ANY_ENCODING { panic("must set the encoding only once") } parser.encoding = encoding } // Create a new emitter object. func yaml_emitter_initialize(emitter *yaml_emitter_t) { *emitter = yaml_emitter_t{ buffer: make([]byte, output_buffer_size), raw_buffer: make([]byte, 0, output_raw_buffer_size), states: make([]yaml_emitter_state_t, 0, initial_stack_size), events: make([]yaml_event_t, 0, initial_queue_size), best_width: -1, } } // Destroy an emitter object. func yaml_emitter_delete(emitter *yaml_emitter_t) { *emitter = yaml_emitter_t{} } // String write handler. func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error { *emitter.output_buffer = append(*emitter.output_buffer, buffer...) return nil } // yaml_writer_write_handler uses emitter.output_writer to write the // emitted text. func yaml_writer_write_handler(emitter *yaml_emitter_t, buffer []byte) error { _, err := emitter.output_writer.Write(buffer) return err } // Set a string output. func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) { if emitter.write_handler != nil { panic("must set the output target only once") } emitter.write_handler = yaml_string_write_handler emitter.output_buffer = output_buffer } // Set a file output. func yaml_emitter_set_output_writer(emitter *yaml_emitter_t, w io.Writer) { if emitter.write_handler != nil { panic("must set the output target only once") } emitter.write_handler = yaml_writer_write_handler emitter.output_writer = w } // Set the output encoding. func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) { if emitter.encoding != yaml_ANY_ENCODING { panic("must set the output encoding only once") } emitter.encoding = encoding } // Set the canonical output style. func yaml_emitter_set_canonical(emitter *yaml_emitter_t, canonical bool) { emitter.canonical = canonical } // Set the indentation increment. func yaml_emitter_set_indent(emitter *yaml_emitter_t, indent int) { if indent < 2 || indent > 9 { indent = 2 } emitter.best_indent = indent } // Set the preferred line width. func yaml_emitter_set_width(emitter *yaml_emitter_t, width int) { if width < 0 { width = -1 } emitter.best_width = width } // Set if unescaped non-ASCII characters are allowed. func yaml_emitter_set_unicode(emitter *yaml_emitter_t, unicode bool) { emitter.unicode = unicode } // Set the preferred line break character. func yaml_emitter_set_break(emitter *yaml_emitter_t, line_break yaml_break_t) { emitter.line_break = line_break } ///* // * Destroy a token object. // */ // //YAML_DECLARE(void) //yaml_token_delete(yaml_token_t *token) //{ // assert(token); // Non-NULL token object expected. // // switch (token.type) // { // case YAML_TAG_DIRECTIVE_TOKEN: // yaml_free(token.data.tag_directive.handle); // yaml_free(token.data.tag_directive.prefix); // break; // // case YAML_ALIAS_TOKEN: // yaml_free(token.data.alias.value); // break; // // case YAML_ANCHOR_TOKEN: // yaml_free(token.data.anchor.value); // break; // // case YAML_TAG_TOKEN: // yaml_free(token.data.tag.handle); // yaml_free(token.data.tag.suffix); // break; // // case YAML_SCALAR_TOKEN: // yaml_free(token.data.scalar.value); // break; // // default: // break; // } // // memset(token, 0, sizeof(yaml_token_t)); //} // ///* // * Check if a string is a valid UTF-8 sequence. // * // * Check 'reader.c' for more details on UTF-8 encoding. // */ // //static int //yaml_check_utf8(yaml_char_t *start, size_t length) //{ // yaml_char_t *end = start+length; // yaml_char_t *pointer = start; // // while (pointer < end) { // unsigned char octet; // unsigned int width; // unsigned int value; // size_t k; // // octet = pointer[0]; // width = (octet & 0x80) == 0x00 ? 1 : // (octet & 0xE0) == 0xC0 ? 2 : // (octet & 0xF0) == 0xE0 ? 3 : // (octet & 0xF8) == 0xF0 ? 4 : 0; // value = (octet & 0x80) == 0x00 ? octet & 0x7F : // (octet & 0xE0) == 0xC0 ? octet & 0x1F : // (octet & 0xF0) == 0xE0 ? octet & 0x0F : // (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0; // if (!width) return 0; // if (pointer+width > end) return 0; // for (k = 1; k < width; k ++) { // octet = pointer[k]; // if ((octet & 0xC0) != 0x80) return 0; // value = (value << 6) + (octet & 0x3F); // } // if (!((width == 1) || // (width == 2 && value >= 0x80) || // (width == 3 && value >= 0x800) || // (width == 4 && value >= 0x10000))) return 0; // // pointer += width; // } // // return 1; //} // // Create STREAM-START. func yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) { *event = yaml_event_t{ typ: yaml_STREAM_START_EVENT, encoding: encoding, } } // Create STREAM-END. func yaml_stream_end_event_initialize(event *yaml_event_t) { *event = yaml_event_t{ typ: yaml_STREAM_END_EVENT, } } // Create DOCUMENT-START. func yaml_document_start_event_initialize( event *yaml_event_t, version_directive *yaml_version_directive_t, tag_directives []yaml_tag_directive_t, implicit bool, ) { *event = yaml_event_t{ typ: yaml_DOCUMENT_START_EVENT, version_directive: version_directive, tag_directives: tag_directives, implicit: implicit, } } // Create DOCUMENT-END. func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) { *event = yaml_event_t{ typ: yaml_DOCUMENT_END_EVENT, implicit: implicit, } } // Create ALIAS. func yaml_alias_event_initialize(event *yaml_event_t, anchor []byte) bool { *event = yaml_event_t{ typ: yaml_ALIAS_EVENT, anchor: anchor, } return true } // Create SCALAR. func yaml_scalar_event_initialize(event *yaml_event_t, anchor, tag, value []byte, plain_implicit, quoted_implicit bool, style yaml_scalar_style_t) bool { *event = yaml_event_t{ typ: yaml_SCALAR_EVENT, anchor: anchor, tag: tag, value: value, implicit: plain_implicit, quoted_implicit: quoted_implicit, style: yaml_style_t(style), } return true } // Create SEQUENCE-START. func yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool { *event = yaml_event_t{ typ: yaml_SEQUENCE_START_EVENT, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(style), } return true } // Create SEQUENCE-END. func yaml_sequence_end_event_initialize(event *yaml_event_t) bool { *event = yaml_event_t{ typ: yaml_SEQUENCE_END_EVENT, } return true } // Create MAPPING-START. func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) { *event = yaml_event_t{ typ: yaml_MAPPING_START_EVENT, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(style), } } // Create MAPPING-END. func yaml_mapping_end_event_initialize(event *yaml_event_t) { *event = yaml_event_t{ typ: yaml_MAPPING_END_EVENT, } } // Destroy an event object. func yaml_event_delete(event *yaml_event_t) { *event = yaml_event_t{} } ///* // * Create a document object. // */ // //YAML_DECLARE(int) //yaml_document_initialize(document *yaml_document_t, // version_directive *yaml_version_directive_t, // tag_directives_start *yaml_tag_directive_t, // tag_directives_end *yaml_tag_directive_t, // start_implicit int, end_implicit int) //{ // struct { // error yaml_error_type_t // } context // struct { // start *yaml_node_t // end *yaml_node_t // top *yaml_node_t // } nodes = { NULL, NULL, NULL } // version_directive_copy *yaml_version_directive_t = NULL // struct { // start *yaml_tag_directive_t // end *yaml_tag_directive_t // top *yaml_tag_directive_t // } tag_directives_copy = { NULL, NULL, NULL } // value yaml_tag_directive_t = { NULL, NULL } // mark yaml_mark_t = { 0, 0, 0 } // // assert(document) // Non-NULL document object is expected. // assert((tag_directives_start && tag_directives_end) || // (tag_directives_start == tag_directives_end)) // // Valid tag directives are expected. // // if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error // // if (version_directive) { // version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t)) // if (!version_directive_copy) goto error // version_directive_copy.major = version_directive.major // version_directive_copy.minor = version_directive.minor // } // // if (tag_directives_start != tag_directives_end) { // tag_directive *yaml_tag_directive_t // if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE)) // goto error // for (tag_directive = tag_directives_start // tag_directive != tag_directives_end; tag_directive ++) { // assert(tag_directive.handle) // assert(tag_directive.prefix) // if (!yaml_check_utf8(tag_directive.handle, // strlen((char *)tag_directive.handle))) // goto error // if (!yaml_check_utf8(tag_directive.prefix, // strlen((char *)tag_directive.prefix))) // goto error // value.handle = yaml_strdup(tag_directive.handle) // value.prefix = yaml_strdup(tag_directive.prefix) // if (!value.handle || !value.prefix) goto error // if (!PUSH(&context, tag_directives_copy, value)) // goto error // value.handle = NULL // value.prefix = NULL // } // } // // DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy, // tag_directives_copy.start, tag_directives_copy.top, // start_implicit, end_implicit, mark, mark) // // return 1 // //error: // STACK_DEL(&context, nodes) // yaml_free(version_directive_copy) // while (!STACK_EMPTY(&context, tag_directives_copy)) { // value yaml_tag_directive_t = POP(&context, tag_directives_copy) // yaml_free(value.handle) // yaml_free(value.prefix) // } // STACK_DEL(&context, tag_directives_copy) // yaml_free(value.handle) // yaml_free(value.prefix) // // return 0 //} // ///* // * Destroy a document object. // */ // //YAML_DECLARE(void) //yaml_document_delete(document *yaml_document_t) //{ // struct { // error yaml_error_type_t // } context // tag_directive *yaml_tag_directive_t // // context.error = YAML_NO_ERROR // Eliminate a compiler warning. // // assert(document) // Non-NULL document object is expected. // // while (!STACK_EMPTY(&context, document.nodes)) { // node yaml_node_t = POP(&context, document.nodes) // yaml_free(node.tag) // switch (node.type) { // case YAML_SCALAR_NODE: // yaml_free(node.data.scalar.value) // break // case YAML_SEQUENCE_NODE: // STACK_DEL(&context, node.data.sequence.items) // break // case YAML_MAPPING_NODE: // STACK_DEL(&context, node.data.mapping.pairs) // break // default: // assert(0) // Should not happen. // } // } // STACK_DEL(&context, document.nodes) // // yaml_free(document.version_directive) // for (tag_directive = document.tag_directives.start // tag_directive != document.tag_directives.end // tag_directive++) { // yaml_free(tag_directive.handle) // yaml_free(tag_directive.prefix) // } // yaml_free(document.tag_directives.start) // // memset(document, 0, sizeof(yaml_document_t)) //} // ///** // * Get a document node. // */ // //YAML_DECLARE(yaml_node_t *) //yaml_document_get_node(document *yaml_document_t, index int) //{ // assert(document) // Non-NULL document object is expected. // // if (index > 0 && document.nodes.start + index <= document.nodes.top) { // return document.nodes.start + index - 1 // } // return NULL //} // ///** // * Get the root object. // */ // //YAML_DECLARE(yaml_node_t *) //yaml_document_get_root_node(document *yaml_document_t) //{ // assert(document) // Non-NULL document object is expected. // // if (document.nodes.top != document.nodes.start) { // return document.nodes.start // } // return NULL //} // ///* // * Add a scalar node to a document. // */ // //YAML_DECLARE(int) //yaml_document_add_scalar(document *yaml_document_t, // tag *yaml_char_t, value *yaml_char_t, length int, // style yaml_scalar_style_t) //{ // struct { // error yaml_error_type_t // } context // mark yaml_mark_t = { 0, 0, 0 } // tag_copy *yaml_char_t = NULL // value_copy *yaml_char_t = NULL // node yaml_node_t // // assert(document) // Non-NULL document object is expected. // assert(value) // Non-NULL value is expected. // // if (!tag) { // tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG // } // // if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error // tag_copy = yaml_strdup(tag) // if (!tag_copy) goto error // // if (length < 0) { // length = strlen((char *)value) // } // // if (!yaml_check_utf8(value, length)) goto error // value_copy = yaml_malloc(length+1) // if (!value_copy) goto error // memcpy(value_copy, value, length) // value_copy[length] = '\0' // // SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark) // if (!PUSH(&context, document.nodes, node)) goto error // // return document.nodes.top - document.nodes.start // //error: // yaml_free(tag_copy) // yaml_free(value_copy) // // return 0 //} // ///* // * Add a sequence node to a document. // */ // //YAML_DECLARE(int) //yaml_document_add_sequence(document *yaml_document_t, // tag *yaml_char_t, style yaml_sequence_style_t) //{ // struct { // error yaml_error_type_t // } context // mark yaml_mark_t = { 0, 0, 0 } // tag_copy *yaml_char_t = NULL // struct { // start *yaml_node_item_t // end *yaml_node_item_t // top *yaml_node_item_t // } items = { NULL, NULL, NULL } // node yaml_node_t // // assert(document) // Non-NULL document object is expected. // // if (!tag) { // tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG // } // // if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error // tag_copy = yaml_strdup(tag) // if (!tag_copy) goto error // // if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error // // SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end, // style, mark, mark) // if (!PUSH(&context, document.nodes, node)) goto error // // return document.nodes.top - document.nodes.start // //error: // STACK_DEL(&context, items) // yaml_free(tag_copy) // // return 0 //} // ///* // * Add a mapping node to a document. // */ // //YAML_DECLARE(int) //yaml_document_add_mapping(document *yaml_document_t, // tag *yaml_char_t, style yaml_mapping_style_t) //{ // struct { // error yaml_error_type_t // } context // mark yaml_mark_t = { 0, 0, 0 } // tag_copy *yaml_char_t = NULL // struct { // start *yaml_node_pair_t // end *yaml_node_pair_t // top *yaml_node_pair_t // } pairs = { NULL, NULL, NULL } // node yaml_node_t // // assert(document) // Non-NULL document object is expected. // // if (!tag) { // tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG // } // // if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error // tag_copy = yaml_strdup(tag) // if (!tag_copy) goto error // // if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error // // MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end, // style, mark, mark) // if (!PUSH(&context, document.nodes, node)) goto error // // return document.nodes.top - document.nodes.start // //error: // STACK_DEL(&context, pairs) // yaml_free(tag_copy) // // return 0 //} // ///* // * Append an item to a sequence node. // */ // //YAML_DECLARE(int) //yaml_document_append_sequence_item(document *yaml_document_t, // sequence int, item int) //{ // struct { // error yaml_error_type_t // } context // // assert(document) // Non-NULL document is required. // assert(sequence > 0 // && document.nodes.start + sequence <= document.nodes.top) // // Valid sequence id is required. // assert(document.nodes.start[sequence-1].type == YAML_SEQUENCE_NODE) // // A sequence node is required. // assert(item > 0 && document.nodes.start + item <= document.nodes.top) // // Valid item id is required. // // if (!PUSH(&context, // document.nodes.start[sequence-1].data.sequence.items, item)) // return 0 // // return 1 //} // ///* // * Append a pair of a key and a value to a mapping node. // */ // //YAML_DECLARE(int) //yaml_document_append_mapping_pair(document *yaml_document_t, // mapping int, key int, value int) //{ // struct { // error yaml_error_type_t // } context // // pair yaml_node_pair_t // // assert(document) // Non-NULL document is required. // assert(mapping > 0 // && document.nodes.start + mapping <= document.nodes.top) // // Valid mapping id is required. // assert(document.nodes.start[mapping-1].type == YAML_MAPPING_NODE) // // A mapping node is required. // assert(key > 0 && document.nodes.start + key <= document.nodes.top) // // Valid key id is required. // assert(value > 0 && document.nodes.start + value <= document.nodes.top) // // Valid value id is required. // // pair.key = key // pair.value = value // // if (!PUSH(&context, // document.nodes.start[mapping-1].data.mapping.pairs, pair)) // return 0 // // return 1 //} // //
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/encode.go
vendor/gopkg.in/yaml.v3/encode.go
// // Copyright (c) 2011-2019 Canonical Ltd // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package yaml import ( "encoding" "fmt" "io" "reflect" "regexp" "sort" "strconv" "strings" "time" "unicode/utf8" ) type encoder struct { emitter yaml_emitter_t event yaml_event_t out []byte flow bool indent int doneInit bool } func newEncoder() *encoder { e := &encoder{} yaml_emitter_initialize(&e.emitter) yaml_emitter_set_output_string(&e.emitter, &e.out) yaml_emitter_set_unicode(&e.emitter, true) return e } func newEncoderWithWriter(w io.Writer) *encoder { e := &encoder{} yaml_emitter_initialize(&e.emitter) yaml_emitter_set_output_writer(&e.emitter, w) yaml_emitter_set_unicode(&e.emitter, true) return e } func (e *encoder) init() { if e.doneInit { return } if e.indent == 0 { e.indent = 4 } e.emitter.best_indent = e.indent yaml_stream_start_event_initialize(&e.event, yaml_UTF8_ENCODING) e.emit() e.doneInit = true } func (e *encoder) finish() { e.emitter.open_ended = false yaml_stream_end_event_initialize(&e.event) e.emit() } func (e *encoder) destroy() { yaml_emitter_delete(&e.emitter) } func (e *encoder) emit() { // This will internally delete the e.event value. e.must(yaml_emitter_emit(&e.emitter, &e.event)) } func (e *encoder) must(ok bool) { if !ok { msg := e.emitter.problem if msg == "" { msg = "unknown problem generating YAML content" } failf("%s", msg) } } func (e *encoder) marshalDoc(tag string, in reflect.Value) { e.init() var node *Node if in.IsValid() { node, _ = in.Interface().(*Node) } if node != nil && node.Kind == DocumentNode { e.nodev(in) } else { yaml_document_start_event_initialize(&e.event, nil, nil, true) e.emit() e.marshal(tag, in) yaml_document_end_event_initialize(&e.event, true) e.emit() } } func (e *encoder) marshal(tag string, in reflect.Value) { tag = shortTag(tag) if !in.IsValid() || in.Kind() == reflect.Ptr && in.IsNil() { e.nilv() return } iface := in.Interface() switch value := iface.(type) { case *Node: e.nodev(in) return case Node: if !in.CanAddr() { var n = reflect.New(in.Type()).Elem() n.Set(in) in = n } e.nodev(in.Addr()) return case time.Time: e.timev(tag, in) return case *time.Time: e.timev(tag, in.Elem()) return case time.Duration: e.stringv(tag, reflect.ValueOf(value.String())) return case Marshaler: v, err := value.MarshalYAML() if err != nil { fail(err) } if v == nil { e.nilv() return } e.marshal(tag, reflect.ValueOf(v)) return case encoding.TextMarshaler: text, err := value.MarshalText() if err != nil { fail(err) } in = reflect.ValueOf(string(text)) case nil: e.nilv() return } switch in.Kind() { case reflect.Interface: e.marshal(tag, in.Elem()) case reflect.Map: e.mapv(tag, in) case reflect.Ptr: e.marshal(tag, in.Elem()) case reflect.Struct: e.structv(tag, in) case reflect.Slice, reflect.Array: e.slicev(tag, in) case reflect.String: e.stringv(tag, in) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: e.intv(tag, in) case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: e.uintv(tag, in) case reflect.Float32, reflect.Float64: e.floatv(tag, in) case reflect.Bool: e.boolv(tag, in) default: panic("cannot marshal type: " + in.Type().String()) } } func (e *encoder) mapv(tag string, in reflect.Value) { e.mappingv(tag, func() { keys := keyList(in.MapKeys()) sort.Sort(keys) for _, k := range keys { e.marshal("", k) e.marshal("", in.MapIndex(k)) } }) } func (e *encoder) fieldByIndex(v reflect.Value, index []int) (field reflect.Value) { for _, num := range index { for { if v.Kind() == reflect.Ptr { if v.IsNil() { return reflect.Value{} } v = v.Elem() continue } break } v = v.Field(num) } return v } func (e *encoder) structv(tag string, in reflect.Value) { sinfo, err := getStructInfo(in.Type()) if err != nil { panic(err) } e.mappingv(tag, func() { for _, info := range sinfo.FieldsList { var value reflect.Value if info.Inline == nil { value = in.Field(info.Num) } else { value = e.fieldByIndex(in, info.Inline) if !value.IsValid() { continue } } if info.OmitEmpty && isZero(value) { continue } e.marshal("", reflect.ValueOf(info.Key)) e.flow = info.Flow e.marshal("", value) } if sinfo.InlineMap >= 0 { m := in.Field(sinfo.InlineMap) if m.Len() > 0 { e.flow = false keys := keyList(m.MapKeys()) sort.Sort(keys) for _, k := range keys { if _, found := sinfo.FieldsMap[k.String()]; found { panic(fmt.Sprintf("cannot have key %q in inlined map: conflicts with struct field", k.String())) } e.marshal("", k) e.flow = false e.marshal("", m.MapIndex(k)) } } } }) } func (e *encoder) mappingv(tag string, f func()) { implicit := tag == "" style := yaml_BLOCK_MAPPING_STYLE if e.flow { e.flow = false style = yaml_FLOW_MAPPING_STYLE } yaml_mapping_start_event_initialize(&e.event, nil, []byte(tag), implicit, style) e.emit() f() yaml_mapping_end_event_initialize(&e.event) e.emit() } func (e *encoder) slicev(tag string, in reflect.Value) { implicit := tag == "" style := yaml_BLOCK_SEQUENCE_STYLE if e.flow { e.flow = false style = yaml_FLOW_SEQUENCE_STYLE } e.must(yaml_sequence_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)) e.emit() n := in.Len() for i := 0; i < n; i++ { e.marshal("", in.Index(i)) } e.must(yaml_sequence_end_event_initialize(&e.event)) e.emit() } // isBase60 returns whether s is in base 60 notation as defined in YAML 1.1. // // The base 60 float notation in YAML 1.1 is a terrible idea and is unsupported // in YAML 1.2 and by this package, but these should be marshalled quoted for // the time being for compatibility with other parsers. func isBase60Float(s string) (result bool) { // Fast path. if s == "" { return false } c := s[0] if !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 { return false } // Do the full match. return base60float.MatchString(s) } // From http://yaml.org/type/float.html, except the regular expression there // is bogus. In practice parsers do not enforce the "\.[0-9_]*" suffix. var base60float = regexp.MustCompile(`^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+(?:\.[0-9_]*)?$`) // isOldBool returns whether s is bool notation as defined in YAML 1.1. // // We continue to force strings that YAML 1.1 would interpret as booleans to be // rendered as quotes strings so that the marshalled output valid for YAML 1.1 // parsing. func isOldBool(s string) (result bool) { switch s { case "y", "Y", "yes", "Yes", "YES", "on", "On", "ON", "n", "N", "no", "No", "NO", "off", "Off", "OFF": return true default: return false } } func (e *encoder) stringv(tag string, in reflect.Value) { var style yaml_scalar_style_t s := in.String() canUsePlain := true switch { case !utf8.ValidString(s): if tag == binaryTag { failf("explicitly tagged !!binary data must be base64-encoded") } if tag != "" { failf("cannot marshal invalid UTF-8 data as %s", shortTag(tag)) } // It can't be encoded directly as YAML so use a binary tag // and encode it as base64. tag = binaryTag s = encodeBase64(s) case tag == "": // Check to see if it would resolve to a specific // tag when encoded unquoted. If it doesn't, // there's no need to quote it. rtag, _ := resolve("", s) canUsePlain = rtag == strTag && !(isBase60Float(s) || isOldBool(s)) } // Note: it's possible for user code to emit invalid YAML // if they explicitly specify a tag and a string containing // text that's incompatible with that tag. switch { case strings.Contains(s, "\n"): if e.flow { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } else { style = yaml_LITERAL_SCALAR_STYLE } case canUsePlain: style = yaml_PLAIN_SCALAR_STYLE default: style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } e.emitScalar(s, "", tag, style, nil, nil, nil, nil) } func (e *encoder) boolv(tag string, in reflect.Value) { var s string if in.Bool() { s = "true" } else { s = "false" } e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil) } func (e *encoder) intv(tag string, in reflect.Value) { s := strconv.FormatInt(in.Int(), 10) e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil) } func (e *encoder) uintv(tag string, in reflect.Value) { s := strconv.FormatUint(in.Uint(), 10) e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil) } func (e *encoder) timev(tag string, in reflect.Value) { t := in.Interface().(time.Time) s := t.Format(time.RFC3339Nano) e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil) } func (e *encoder) floatv(tag string, in reflect.Value) { // Issue #352: When formatting, use the precision of the underlying value precision := 64 if in.Kind() == reflect.Float32 { precision = 32 } s := strconv.FormatFloat(in.Float(), 'g', -1, precision) switch s { case "+Inf": s = ".inf" case "-Inf": s = "-.inf" case "NaN": s = ".nan" } e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil) } func (e *encoder) nilv() { e.emitScalar("null", "", "", yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil) } func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t, head, line, foot, tail []byte) { // TODO Kill this function. Replace all initialize calls by their underlining Go literals. implicit := tag == "" if !implicit { tag = longTag(tag) } e.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style)) e.event.head_comment = head e.event.line_comment = line e.event.foot_comment = foot e.event.tail_comment = tail e.emit() } func (e *encoder) nodev(in reflect.Value) { e.node(in.Interface().(*Node), "") } func (e *encoder) node(node *Node, tail string) { // Zero nodes behave as nil. if node.Kind == 0 && node.IsZero() { e.nilv() return } // If the tag was not explicitly requested, and dropping it won't change the // implicit tag of the value, don't include it in the presentation. var tag = node.Tag var stag = shortTag(tag) var forceQuoting bool if tag != "" && node.Style&TaggedStyle == 0 { if node.Kind == ScalarNode { if stag == strTag && node.Style&(SingleQuotedStyle|DoubleQuotedStyle|LiteralStyle|FoldedStyle) != 0 { tag = "" } else { rtag, _ := resolve("", node.Value) if rtag == stag { tag = "" } else if stag == strTag { tag = "" forceQuoting = true } } } else { var rtag string switch node.Kind { case MappingNode: rtag = mapTag case SequenceNode: rtag = seqTag } if rtag == stag { tag = "" } } } switch node.Kind { case DocumentNode: yaml_document_start_event_initialize(&e.event, nil, nil, true) e.event.head_comment = []byte(node.HeadComment) e.emit() for _, node := range node.Content { e.node(node, "") } yaml_document_end_event_initialize(&e.event, true) e.event.foot_comment = []byte(node.FootComment) e.emit() case SequenceNode: style := yaml_BLOCK_SEQUENCE_STYLE if node.Style&FlowStyle != 0 { style = yaml_FLOW_SEQUENCE_STYLE } e.must(yaml_sequence_start_event_initialize(&e.event, []byte(node.Anchor), []byte(longTag(tag)), tag == "", style)) e.event.head_comment = []byte(node.HeadComment) e.emit() for _, node := range node.Content { e.node(node, "") } e.must(yaml_sequence_end_event_initialize(&e.event)) e.event.line_comment = []byte(node.LineComment) e.event.foot_comment = []byte(node.FootComment) e.emit() case MappingNode: style := yaml_BLOCK_MAPPING_STYLE if node.Style&FlowStyle != 0 { style = yaml_FLOW_MAPPING_STYLE } yaml_mapping_start_event_initialize(&e.event, []byte(node.Anchor), []byte(longTag(tag)), tag == "", style) e.event.tail_comment = []byte(tail) e.event.head_comment = []byte(node.HeadComment) e.emit() // The tail logic below moves the foot comment of prior keys to the following key, // since the value for each key may be a nested structure and the foot needs to be // processed only the entirety of the value is streamed. The last tail is processed // with the mapping end event. var tail string for i := 0; i+1 < len(node.Content); i += 2 { k := node.Content[i] foot := k.FootComment if foot != "" { kopy := *k kopy.FootComment = "" k = &kopy } e.node(k, tail) tail = foot v := node.Content[i+1] e.node(v, "") } yaml_mapping_end_event_initialize(&e.event) e.event.tail_comment = []byte(tail) e.event.line_comment = []byte(node.LineComment) e.event.foot_comment = []byte(node.FootComment) e.emit() case AliasNode: yaml_alias_event_initialize(&e.event, []byte(node.Value)) e.event.head_comment = []byte(node.HeadComment) e.event.line_comment = []byte(node.LineComment) e.event.foot_comment = []byte(node.FootComment) e.emit() case ScalarNode: value := node.Value if !utf8.ValidString(value) { if stag == binaryTag { failf("explicitly tagged !!binary data must be base64-encoded") } if stag != "" { failf("cannot marshal invalid UTF-8 data as %s", stag) } // It can't be encoded directly as YAML so use a binary tag // and encode it as base64. tag = binaryTag value = encodeBase64(value) } style := yaml_PLAIN_SCALAR_STYLE switch { case node.Style&DoubleQuotedStyle != 0: style = yaml_DOUBLE_QUOTED_SCALAR_STYLE case node.Style&SingleQuotedStyle != 0: style = yaml_SINGLE_QUOTED_SCALAR_STYLE case node.Style&LiteralStyle != 0: style = yaml_LITERAL_SCALAR_STYLE case node.Style&FoldedStyle != 0: style = yaml_FOLDED_SCALAR_STYLE case strings.Contains(value, "\n"): style = yaml_LITERAL_SCALAR_STYLE case forceQuoting: style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } e.emitScalar(value, node.Anchor, tag, style, []byte(node.HeadComment), []byte(node.LineComment), []byte(node.FootComment), []byte(tail)) default: failf("cannot encode node with unknown kind %d", node.Kind) } }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/sorter.go
vendor/gopkg.in/yaml.v3/sorter.go
// // Copyright (c) 2011-2019 Canonical Ltd // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package yaml import ( "reflect" "unicode" ) type keyList []reflect.Value func (l keyList) Len() int { return len(l) } func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } func (l keyList) Less(i, j int) bool { a := l[i] b := l[j] ak := a.Kind() bk := b.Kind() for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { a = a.Elem() ak = a.Kind() } for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { b = b.Elem() bk = b.Kind() } af, aok := keyFloat(a) bf, bok := keyFloat(b) if aok && bok { if af != bf { return af < bf } if ak != bk { return ak < bk } return numLess(a, b) } if ak != reflect.String || bk != reflect.String { return ak < bk } ar, br := []rune(a.String()), []rune(b.String()) digits := false for i := 0; i < len(ar) && i < len(br); i++ { if ar[i] == br[i] { digits = unicode.IsDigit(ar[i]) continue } al := unicode.IsLetter(ar[i]) bl := unicode.IsLetter(br[i]) if al && bl { return ar[i] < br[i] } if al || bl { if digits { return al } else { return bl } } var ai, bi int var an, bn int64 if ar[i] == '0' || br[i] == '0' { for j := i - 1; j >= 0 && unicode.IsDigit(ar[j]); j-- { if ar[j] != '0' { an = 1 bn = 1 break } } } for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { an = an*10 + int64(ar[ai]-'0') } for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { bn = bn*10 + int64(br[bi]-'0') } if an != bn { return an < bn } if ai != bi { return ai < bi } return ar[i] < br[i] } return len(ar) < len(br) } // keyFloat returns a float value for v if it is a number/bool // and whether it is a number/bool or not. func keyFloat(v reflect.Value) (f float64, ok bool) { switch v.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return float64(v.Int()), true case reflect.Float32, reflect.Float64: return v.Float(), true case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return float64(v.Uint()), true case reflect.Bool: if v.Bool() { return 1, true } return 0, true } return 0, false } // numLess returns whether a < b. // a and b must necessarily have the same kind. func numLess(a, b reflect.Value) bool { switch a.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return a.Int() < b.Int() case reflect.Float32, reflect.Float64: return a.Float() < b.Float() case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return a.Uint() < b.Uint() case reflect.Bool: return !a.Bool() && b.Bool() } panic("not a number") }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/yamlprivateh.go
vendor/gopkg.in/yaml.v3/yamlprivateh.go
// // Copyright (c) 2011-2019 Canonical Ltd // Copyright (c) 2006-2010 Kirill Simonov // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies // of the Software, and to permit persons to whom the Software is furnished to do // so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. package yaml const ( // The size of the input raw buffer. input_raw_buffer_size = 512 // The size of the input buffer. // It should be possible to decode the whole raw buffer. input_buffer_size = input_raw_buffer_size * 3 // The size of the output buffer. output_buffer_size = 128 // The size of the output raw buffer. // It should be possible to encode the whole output buffer. output_raw_buffer_size = (output_buffer_size*2 + 2) // The size of other stacks and queues. initial_stack_size = 16 initial_queue_size = 16 initial_string_size = 16 ) // Check if the character at the specified position is an alphabetical // character, a digit, '_', or '-'. func is_alpha(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-' } // Check if the character at the specified position is a digit. func is_digit(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' } // Get the value of a digit. func as_digit(b []byte, i int) int { return int(b[i]) - '0' } // Check if the character at the specified position is a hex-digit. func is_hex(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f' } // Get the value of a hex-digit. func as_hex(b []byte, i int) int { bi := b[i] if bi >= 'A' && bi <= 'F' { return int(bi) - 'A' + 10 } if bi >= 'a' && bi <= 'f' { return int(bi) - 'a' + 10 } return int(bi) - '0' } // Check if the character is ASCII. func is_ascii(b []byte, i int) bool { return b[i] <= 0x7F } // Check if the character at the start of the buffer can be printed unescaped. func is_printable(b []byte, i int) bool { return ((b[i] == 0x0A) || // . == #x0A (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF (b[i] > 0xC2 && b[i] < 0xED) || (b[i] == 0xED && b[i+1] < 0xA0) || (b[i] == 0xEE) || (b[i] == 0xEF && // #xE000 <= . <= #xFFFD !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF)))) } // Check if the character at the specified position is NUL. func is_z(b []byte, i int) bool { return b[i] == 0x00 } // Check if the beginning of the buffer is a BOM. func is_bom(b []byte, i int) bool { return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF } // Check if the character at the specified position is space. func is_space(b []byte, i int) bool { return b[i] == ' ' } // Check if the character at the specified position is tab. func is_tab(b []byte, i int) bool { return b[i] == '\t' } // Check if the character at the specified position is blank (space or tab). func is_blank(b []byte, i int) bool { //return is_space(b, i) || is_tab(b, i) return b[i] == ' ' || b[i] == '\t' } // Check if the character at the specified position is a line break. func is_break(b []byte, i int) bool { return (b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029) } func is_crlf(b []byte, i int) bool { return b[i] == '\r' && b[i+1] == '\n' } // Check if the character is a line break or NUL. func is_breakz(b []byte, i int) bool { //return is_break(b, i) || is_z(b, i) return ( // is_break: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) // is_z: b[i] == 0) } // Check if the character is a line break, space, or NUL. func is_spacez(b []byte, i int) bool { //return is_space(b, i) || is_breakz(b, i) return ( // is_space: b[i] == ' ' || // is_breakz: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) b[i] == 0) } // Check if the character is a line break, space, tab, or NUL. func is_blankz(b []byte, i int) bool { //return is_blank(b, i) || is_breakz(b, i) return ( // is_blank: b[i] == ' ' || b[i] == '\t' || // is_breakz: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) b[i] == 0) } // Determine the width of the character. func width(b byte) int { // Don't replace these by a switch without first // confirming that it is being inlined. if b&0x80 == 0x00 { return 1 } if b&0xE0 == 0xC0 { return 2 } if b&0xF0 == 0xE0 { return 3 } if b&0xF8 == 0xF0 { return 4 } return 0 }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/readerc.go
vendor/gopkg.in/yaml.v3/readerc.go
// // Copyright (c) 2011-2019 Canonical Ltd // Copyright (c) 2006-2010 Kirill Simonov // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies // of the Software, and to permit persons to whom the Software is furnished to do // so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. package yaml import ( "io" ) // Set the reader error and return 0. func yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool { parser.error = yaml_READER_ERROR parser.problem = problem parser.problem_offset = offset parser.problem_value = value return false } // Byte order marks. const ( bom_UTF8 = "\xef\xbb\xbf" bom_UTF16LE = "\xff\xfe" bom_UTF16BE = "\xfe\xff" ) // Determine the input stream encoding by checking the BOM symbol. If no BOM is // found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure. func yaml_parser_determine_encoding(parser *yaml_parser_t) bool { // Ensure that we had enough bytes in the raw buffer. for !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 { if !yaml_parser_update_raw_buffer(parser) { return false } } // Determine the encoding. buf := parser.raw_buffer pos := parser.raw_buffer_pos avail := len(buf) - pos if avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] { parser.encoding = yaml_UTF16LE_ENCODING parser.raw_buffer_pos += 2 parser.offset += 2 } else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] { parser.encoding = yaml_UTF16BE_ENCODING parser.raw_buffer_pos += 2 parser.offset += 2 } else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] { parser.encoding = yaml_UTF8_ENCODING parser.raw_buffer_pos += 3 parser.offset += 3 } else { parser.encoding = yaml_UTF8_ENCODING } return true } // Update the raw buffer. func yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool { size_read := 0 // Return if the raw buffer is full. if parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) { return true } // Return on EOF. if parser.eof { return true } // Move the remaining bytes in the raw buffer to the beginning. if parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) { copy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:]) } parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos] parser.raw_buffer_pos = 0 // Call the read handler to fill the buffer. size_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)]) parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read] if err == io.EOF { parser.eof = true } else if err != nil { return yaml_parser_set_reader_error(parser, "input error: "+err.Error(), parser.offset, -1) } return true } // Ensure that the buffer contains at least `length` characters. // Return true on success, false on failure. // // The length is supposed to be significantly less that the buffer size. func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool { if parser.read_handler == nil { panic("read handler must be set") } // [Go] This function was changed to guarantee the requested length size at EOF. // The fact we need to do this is pretty awful, but the description above implies // for that to be the case, and there are tests // If the EOF flag is set and the raw buffer is empty, do nothing. if parser.eof && parser.raw_buffer_pos == len(parser.raw_buffer) { // [Go] ACTUALLY! Read the documentation of this function above. // This is just broken. To return true, we need to have the // given length in the buffer. Not doing that means every single // check that calls this function to make sure the buffer has a // given length is Go) panicking; or C) accessing invalid memory. //return true } // Return if the buffer contains enough characters. if parser.unread >= length { return true } // Determine the input encoding if it is not known yet. if parser.encoding == yaml_ANY_ENCODING { if !yaml_parser_determine_encoding(parser) { return false } } // Move the unread characters to the beginning of the buffer. buffer_len := len(parser.buffer) if parser.buffer_pos > 0 && parser.buffer_pos < buffer_len { copy(parser.buffer, parser.buffer[parser.buffer_pos:]) buffer_len -= parser.buffer_pos parser.buffer_pos = 0 } else if parser.buffer_pos == buffer_len { buffer_len = 0 parser.buffer_pos = 0 } // Open the whole buffer for writing, and cut it before returning. parser.buffer = parser.buffer[:cap(parser.buffer)] // Fill the buffer until it has enough characters. first := true for parser.unread < length { // Fill the raw buffer if necessary. if !first || parser.raw_buffer_pos == len(parser.raw_buffer) { if !yaml_parser_update_raw_buffer(parser) { parser.buffer = parser.buffer[:buffer_len] return false } } first = false // Decode the raw buffer. inner: for parser.raw_buffer_pos != len(parser.raw_buffer) { var value rune var width int raw_unread := len(parser.raw_buffer) - parser.raw_buffer_pos // Decode the next character. switch parser.encoding { case yaml_UTF8_ENCODING: // Decode a UTF-8 character. Check RFC 3629 // (http://www.ietf.org/rfc/rfc3629.txt) for more details. // // The following table (taken from the RFC) is used for // decoding. // // Char. number range | UTF-8 octet sequence // (hexadecimal) | (binary) // --------------------+------------------------------------ // 0000 0000-0000 007F | 0xxxxxxx // 0000 0080-0000 07FF | 110xxxxx 10xxxxxx // 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx // 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx // // Additionally, the characters in the range 0xD800-0xDFFF // are prohibited as they are reserved for use with UTF-16 // surrogate pairs. // Determine the length of the UTF-8 sequence. octet := parser.raw_buffer[parser.raw_buffer_pos] switch { case octet&0x80 == 0x00: width = 1 case octet&0xE0 == 0xC0: width = 2 case octet&0xF0 == 0xE0: width = 3 case octet&0xF8 == 0xF0: width = 4 default: // The leading octet is invalid. return yaml_parser_set_reader_error(parser, "invalid leading UTF-8 octet", parser.offset, int(octet)) } // Check if the raw buffer contains an incomplete character. if width > raw_unread { if parser.eof { return yaml_parser_set_reader_error(parser, "incomplete UTF-8 octet sequence", parser.offset, -1) } break inner } // Decode the leading octet. switch { case octet&0x80 == 0x00: value = rune(octet & 0x7F) case octet&0xE0 == 0xC0: value = rune(octet & 0x1F) case octet&0xF0 == 0xE0: value = rune(octet & 0x0F) case octet&0xF8 == 0xF0: value = rune(octet & 0x07) default: value = 0 } // Check and decode the trailing octets. for k := 1; k < width; k++ { octet = parser.raw_buffer[parser.raw_buffer_pos+k] // Check if the octet is valid. if (octet & 0xC0) != 0x80 { return yaml_parser_set_reader_error(parser, "invalid trailing UTF-8 octet", parser.offset+k, int(octet)) } // Decode the octet. value = (value << 6) + rune(octet&0x3F) } // Check the length of the sequence against the value. switch { case width == 1: case width == 2 && value >= 0x80: case width == 3 && value >= 0x800: case width == 4 && value >= 0x10000: default: return yaml_parser_set_reader_error(parser, "invalid length of a UTF-8 sequence", parser.offset, -1) } // Check the range of the value. if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF { return yaml_parser_set_reader_error(parser, "invalid Unicode character", parser.offset, int(value)) } case yaml_UTF16LE_ENCODING, yaml_UTF16BE_ENCODING: var low, high int if parser.encoding == yaml_UTF16LE_ENCODING { low, high = 0, 1 } else { low, high = 1, 0 } // The UTF-16 encoding is not as simple as one might // naively think. Check RFC 2781 // (http://www.ietf.org/rfc/rfc2781.txt). // // Normally, two subsequent bytes describe a Unicode // character. However a special technique (called a // surrogate pair) is used for specifying character // values larger than 0xFFFF. // // A surrogate pair consists of two pseudo-characters: // high surrogate area (0xD800-0xDBFF) // low surrogate area (0xDC00-0xDFFF) // // The following formulas are used for decoding // and encoding characters using surrogate pairs: // // U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF) // U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF) // W1 = 110110yyyyyyyyyy // W2 = 110111xxxxxxxxxx // // where U is the character value, W1 is the high surrogate // area, W2 is the low surrogate area. // Check for incomplete UTF-16 character. if raw_unread < 2 { if parser.eof { return yaml_parser_set_reader_error(parser, "incomplete UTF-16 character", parser.offset, -1) } break inner } // Get the character. value = rune(parser.raw_buffer[parser.raw_buffer_pos+low]) + (rune(parser.raw_buffer[parser.raw_buffer_pos+high]) << 8) // Check for unexpected low surrogate area. if value&0xFC00 == 0xDC00 { return yaml_parser_set_reader_error(parser, "unexpected low surrogate area", parser.offset, int(value)) } // Check for a high surrogate area. if value&0xFC00 == 0xD800 { width = 4 // Check for incomplete surrogate pair. if raw_unread < 4 { if parser.eof { return yaml_parser_set_reader_error(parser, "incomplete UTF-16 surrogate pair", parser.offset, -1) } break inner } // Get the next character. value2 := rune(parser.raw_buffer[parser.raw_buffer_pos+low+2]) + (rune(parser.raw_buffer[parser.raw_buffer_pos+high+2]) << 8) // Check for a low surrogate area. if value2&0xFC00 != 0xDC00 { return yaml_parser_set_reader_error(parser, "expected low surrogate area", parser.offset+2, int(value2)) } // Generate the value of the surrogate pair. value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF) } else { width = 2 } default: panic("impossible") } // Check if the character is in the allowed range: // #x9 | #xA | #xD | [#x20-#x7E] (8 bit) // | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit) // | [#x10000-#x10FFFF] (32 bit) switch { case value == 0x09: case value == 0x0A: case value == 0x0D: case value >= 0x20 && value <= 0x7E: case value == 0x85: case value >= 0xA0 && value <= 0xD7FF: case value >= 0xE000 && value <= 0xFFFD: case value >= 0x10000 && value <= 0x10FFFF: default: return yaml_parser_set_reader_error(parser, "control characters are not allowed", parser.offset, int(value)) } // Move the raw pointers. parser.raw_buffer_pos += width parser.offset += width // Finally put the character into the buffer. if value <= 0x7F { // 0000 0000-0000 007F . 0xxxxxxx parser.buffer[buffer_len+0] = byte(value) buffer_len += 1 } else if value <= 0x7FF { // 0000 0080-0000 07FF . 110xxxxx 10xxxxxx parser.buffer[buffer_len+0] = byte(0xC0 + (value >> 6)) parser.buffer[buffer_len+1] = byte(0x80 + (value & 0x3F)) buffer_len += 2 } else if value <= 0xFFFF { // 0000 0800-0000 FFFF . 1110xxxx 10xxxxxx 10xxxxxx parser.buffer[buffer_len+0] = byte(0xE0 + (value >> 12)) parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 6) & 0x3F)) parser.buffer[buffer_len+2] = byte(0x80 + (value & 0x3F)) buffer_len += 3 } else { // 0001 0000-0010 FFFF . 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx parser.buffer[buffer_len+0] = byte(0xF0 + (value >> 18)) parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 12) & 0x3F)) parser.buffer[buffer_len+2] = byte(0x80 + ((value >> 6) & 0x3F)) parser.buffer[buffer_len+3] = byte(0x80 + (value & 0x3F)) buffer_len += 4 } parser.unread++ } // On EOF, put NUL into the buffer and return. if parser.eof { parser.buffer[buffer_len] = 0 buffer_len++ parser.unread++ break } } // [Go] Read the documentation of this function above. To return true, // we need to have the given length in the buffer. Not doing that means // every single check that calls this function to make sure the buffer // has a given length is Go) panicking; or C) accessing invalid memory. // This happens here due to the EOF above breaking early. for buffer_len < length { parser.buffer[buffer_len] = 0 buffer_len++ } parser.buffer = parser.buffer[:buffer_len] return true }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/writerc.go
vendor/gopkg.in/yaml.v3/writerc.go
// // Copyright (c) 2011-2019 Canonical Ltd // Copyright (c) 2006-2010 Kirill Simonov // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies // of the Software, and to permit persons to whom the Software is furnished to do // so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. package yaml // Set the writer error and return false. func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { emitter.error = yaml_WRITER_ERROR emitter.problem = problem return false } // Flush the output buffer. func yaml_emitter_flush(emitter *yaml_emitter_t) bool { if emitter.write_handler == nil { panic("write handler not set") } // Check if the buffer is empty. if emitter.buffer_pos == 0 { return true } if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) } emitter.buffer_pos = 0 return true }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/yamlh.go
vendor/gopkg.in/yaml.v3/yamlh.go
// // Copyright (c) 2011-2019 Canonical Ltd // Copyright (c) 2006-2010 Kirill Simonov // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies // of the Software, and to permit persons to whom the Software is furnished to do // so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. package yaml import ( "fmt" "io" ) // The version directive data. type yaml_version_directive_t struct { major int8 // The major version number. minor int8 // The minor version number. } // The tag directive data. type yaml_tag_directive_t struct { handle []byte // The tag handle. prefix []byte // The tag prefix. } type yaml_encoding_t int // The stream encoding. const ( // Let the parser choose the encoding. yaml_ANY_ENCODING yaml_encoding_t = iota yaml_UTF8_ENCODING // The default UTF-8 encoding. yaml_UTF16LE_ENCODING // The UTF-16-LE encoding with BOM. yaml_UTF16BE_ENCODING // The UTF-16-BE encoding with BOM. ) type yaml_break_t int // Line break types. const ( // Let the parser choose the break type. yaml_ANY_BREAK yaml_break_t = iota yaml_CR_BREAK // Use CR for line breaks (Mac style). yaml_LN_BREAK // Use LN for line breaks (Unix style). yaml_CRLN_BREAK // Use CR LN for line breaks (DOS style). ) type yaml_error_type_t int // Many bad things could happen with the parser and emitter. const ( // No error is produced. yaml_NO_ERROR yaml_error_type_t = iota yaml_MEMORY_ERROR // Cannot allocate or reallocate a block of memory. yaml_READER_ERROR // Cannot read or decode the input stream. yaml_SCANNER_ERROR // Cannot scan the input stream. yaml_PARSER_ERROR // Cannot parse the input stream. yaml_COMPOSER_ERROR // Cannot compose a YAML document. yaml_WRITER_ERROR // Cannot write to the output stream. yaml_EMITTER_ERROR // Cannot emit a YAML stream. ) // The pointer position. type yaml_mark_t struct { index int // The position index. line int // The position line. column int // The position column. } // Node Styles type yaml_style_t int8 type yaml_scalar_style_t yaml_style_t // Scalar styles. const ( // Let the emitter choose the style. yaml_ANY_SCALAR_STYLE yaml_scalar_style_t = 0 yaml_PLAIN_SCALAR_STYLE yaml_scalar_style_t = 1 << iota // The plain scalar style. yaml_SINGLE_QUOTED_SCALAR_STYLE // The single-quoted scalar style. yaml_DOUBLE_QUOTED_SCALAR_STYLE // The double-quoted scalar style. yaml_LITERAL_SCALAR_STYLE // The literal scalar style. yaml_FOLDED_SCALAR_STYLE // The folded scalar style. ) type yaml_sequence_style_t yaml_style_t // Sequence styles. const ( // Let the emitter choose the style. yaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota yaml_BLOCK_SEQUENCE_STYLE // The block sequence style. yaml_FLOW_SEQUENCE_STYLE // The flow sequence style. ) type yaml_mapping_style_t yaml_style_t // Mapping styles. const ( // Let the emitter choose the style. yaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota yaml_BLOCK_MAPPING_STYLE // The block mapping style. yaml_FLOW_MAPPING_STYLE // The flow mapping style. ) // Tokens type yaml_token_type_t int // Token types. const ( // An empty token. yaml_NO_TOKEN yaml_token_type_t = iota yaml_STREAM_START_TOKEN // A STREAM-START token. yaml_STREAM_END_TOKEN // A STREAM-END token. yaml_VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token. yaml_TAG_DIRECTIVE_TOKEN // A TAG-DIRECTIVE token. yaml_DOCUMENT_START_TOKEN // A DOCUMENT-START token. yaml_DOCUMENT_END_TOKEN // A DOCUMENT-END token. yaml_BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token. yaml_BLOCK_MAPPING_START_TOKEN // A BLOCK-SEQUENCE-END token. yaml_BLOCK_END_TOKEN // A BLOCK-END token. yaml_FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token. yaml_FLOW_SEQUENCE_END_TOKEN // A FLOW-SEQUENCE-END token. yaml_FLOW_MAPPING_START_TOKEN // A FLOW-MAPPING-START token. yaml_FLOW_MAPPING_END_TOKEN // A FLOW-MAPPING-END token. yaml_BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token. yaml_FLOW_ENTRY_TOKEN // A FLOW-ENTRY token. yaml_KEY_TOKEN // A KEY token. yaml_VALUE_TOKEN // A VALUE token. yaml_ALIAS_TOKEN // An ALIAS token. yaml_ANCHOR_TOKEN // An ANCHOR token. yaml_TAG_TOKEN // A TAG token. yaml_SCALAR_TOKEN // A SCALAR token. ) func (tt yaml_token_type_t) String() string { switch tt { case yaml_NO_TOKEN: return "yaml_NO_TOKEN" case yaml_STREAM_START_TOKEN: return "yaml_STREAM_START_TOKEN" case yaml_STREAM_END_TOKEN: return "yaml_STREAM_END_TOKEN" case yaml_VERSION_DIRECTIVE_TOKEN: return "yaml_VERSION_DIRECTIVE_TOKEN" case yaml_TAG_DIRECTIVE_TOKEN: return "yaml_TAG_DIRECTIVE_TOKEN" case yaml_DOCUMENT_START_TOKEN: return "yaml_DOCUMENT_START_TOKEN" case yaml_DOCUMENT_END_TOKEN: return "yaml_DOCUMENT_END_TOKEN" case yaml_BLOCK_SEQUENCE_START_TOKEN: return "yaml_BLOCK_SEQUENCE_START_TOKEN" case yaml_BLOCK_MAPPING_START_TOKEN: return "yaml_BLOCK_MAPPING_START_TOKEN" case yaml_BLOCK_END_TOKEN: return "yaml_BLOCK_END_TOKEN" case yaml_FLOW_SEQUENCE_START_TOKEN: return "yaml_FLOW_SEQUENCE_START_TOKEN" case yaml_FLOW_SEQUENCE_END_TOKEN: return "yaml_FLOW_SEQUENCE_END_TOKEN" case yaml_FLOW_MAPPING_START_TOKEN: return "yaml_FLOW_MAPPING_START_TOKEN" case yaml_FLOW_MAPPING_END_TOKEN: return "yaml_FLOW_MAPPING_END_TOKEN" case yaml_BLOCK_ENTRY_TOKEN: return "yaml_BLOCK_ENTRY_TOKEN" case yaml_FLOW_ENTRY_TOKEN: return "yaml_FLOW_ENTRY_TOKEN" case yaml_KEY_TOKEN: return "yaml_KEY_TOKEN" case yaml_VALUE_TOKEN: return "yaml_VALUE_TOKEN" case yaml_ALIAS_TOKEN: return "yaml_ALIAS_TOKEN" case yaml_ANCHOR_TOKEN: return "yaml_ANCHOR_TOKEN" case yaml_TAG_TOKEN: return "yaml_TAG_TOKEN" case yaml_SCALAR_TOKEN: return "yaml_SCALAR_TOKEN" } return "<unknown token>" } // The token structure. type yaml_token_t struct { // The token type. typ yaml_token_type_t // The start/end of the token. start_mark, end_mark yaml_mark_t // The stream encoding (for yaml_STREAM_START_TOKEN). encoding yaml_encoding_t // The alias/anchor/scalar value or tag/tag directive handle // (for yaml_ALIAS_TOKEN, yaml_ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN). value []byte // The tag suffix (for yaml_TAG_TOKEN). suffix []byte // The tag directive prefix (for yaml_TAG_DIRECTIVE_TOKEN). prefix []byte // The scalar style (for yaml_SCALAR_TOKEN). style yaml_scalar_style_t // The version directive major/minor (for yaml_VERSION_DIRECTIVE_TOKEN). major, minor int8 } // Events type yaml_event_type_t int8 // Event types. const ( // An empty event. yaml_NO_EVENT yaml_event_type_t = iota yaml_STREAM_START_EVENT // A STREAM-START event. yaml_STREAM_END_EVENT // A STREAM-END event. yaml_DOCUMENT_START_EVENT // A DOCUMENT-START event. yaml_DOCUMENT_END_EVENT // A DOCUMENT-END event. yaml_ALIAS_EVENT // An ALIAS event. yaml_SCALAR_EVENT // A SCALAR event. yaml_SEQUENCE_START_EVENT // A SEQUENCE-START event. yaml_SEQUENCE_END_EVENT // A SEQUENCE-END event. yaml_MAPPING_START_EVENT // A MAPPING-START event. yaml_MAPPING_END_EVENT // A MAPPING-END event. yaml_TAIL_COMMENT_EVENT ) var eventStrings = []string{ yaml_NO_EVENT: "none", yaml_STREAM_START_EVENT: "stream start", yaml_STREAM_END_EVENT: "stream end", yaml_DOCUMENT_START_EVENT: "document start", yaml_DOCUMENT_END_EVENT: "document end", yaml_ALIAS_EVENT: "alias", yaml_SCALAR_EVENT: "scalar", yaml_SEQUENCE_START_EVENT: "sequence start", yaml_SEQUENCE_END_EVENT: "sequence end", yaml_MAPPING_START_EVENT: "mapping start", yaml_MAPPING_END_EVENT: "mapping end", yaml_TAIL_COMMENT_EVENT: "tail comment", } func (e yaml_event_type_t) String() string { if e < 0 || int(e) >= len(eventStrings) { return fmt.Sprintf("unknown event %d", e) } return eventStrings[e] } // The event structure. type yaml_event_t struct { // The event type. typ yaml_event_type_t // The start and end of the event. start_mark, end_mark yaml_mark_t // The document encoding (for yaml_STREAM_START_EVENT). encoding yaml_encoding_t // The version directive (for yaml_DOCUMENT_START_EVENT). version_directive *yaml_version_directive_t // The list of tag directives (for yaml_DOCUMENT_START_EVENT). tag_directives []yaml_tag_directive_t // The comments head_comment []byte line_comment []byte foot_comment []byte tail_comment []byte // The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT). anchor []byte // The tag (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). tag []byte // The scalar value (for yaml_SCALAR_EVENT). value []byte // Is the document start/end indicator implicit, or the tag optional? // (for yaml_DOCUMENT_START_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_SCALAR_EVENT). implicit bool // Is the tag optional for any non-plain style? (for yaml_SCALAR_EVENT). quoted_implicit bool // The style (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). style yaml_style_t } func (e *yaml_event_t) scalar_style() yaml_scalar_style_t { return yaml_scalar_style_t(e.style) } func (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) } func (e *yaml_event_t) mapping_style() yaml_mapping_style_t { return yaml_mapping_style_t(e.style) } // Nodes const ( yaml_NULL_TAG = "tag:yaml.org,2002:null" // The tag !!null with the only possible value: null. yaml_BOOL_TAG = "tag:yaml.org,2002:bool" // The tag !!bool with the values: true and false. yaml_STR_TAG = "tag:yaml.org,2002:str" // The tag !!str for string values. yaml_INT_TAG = "tag:yaml.org,2002:int" // The tag !!int for integer values. yaml_FLOAT_TAG = "tag:yaml.org,2002:float" // The tag !!float for float values. yaml_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp" // The tag !!timestamp for date and time values. yaml_SEQ_TAG = "tag:yaml.org,2002:seq" // The tag !!seq is used to denote sequences. yaml_MAP_TAG = "tag:yaml.org,2002:map" // The tag !!map is used to denote mapping. // Not in original libyaml. yaml_BINARY_TAG = "tag:yaml.org,2002:binary" yaml_MERGE_TAG = "tag:yaml.org,2002:merge" yaml_DEFAULT_SCALAR_TAG = yaml_STR_TAG // The default scalar tag is !!str. yaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG // The default sequence tag is !!seq. yaml_DEFAULT_MAPPING_TAG = yaml_MAP_TAG // The default mapping tag is !!map. ) type yaml_node_type_t int // Node types. const ( // An empty node. yaml_NO_NODE yaml_node_type_t = iota yaml_SCALAR_NODE // A scalar node. yaml_SEQUENCE_NODE // A sequence node. yaml_MAPPING_NODE // A mapping node. ) // An element of a sequence node. type yaml_node_item_t int // An element of a mapping node. type yaml_node_pair_t struct { key int // The key of the element. value int // The value of the element. } // The node structure. type yaml_node_t struct { typ yaml_node_type_t // The node type. tag []byte // The node tag. // The node data. // The scalar parameters (for yaml_SCALAR_NODE). scalar struct { value []byte // The scalar value. length int // The length of the scalar value. style yaml_scalar_style_t // The scalar style. } // The sequence parameters (for YAML_SEQUENCE_NODE). sequence struct { items_data []yaml_node_item_t // The stack of sequence items. style yaml_sequence_style_t // The sequence style. } // The mapping parameters (for yaml_MAPPING_NODE). mapping struct { pairs_data []yaml_node_pair_t // The stack of mapping pairs (key, value). pairs_start *yaml_node_pair_t // The beginning of the stack. pairs_end *yaml_node_pair_t // The end of the stack. pairs_top *yaml_node_pair_t // The top of the stack. style yaml_mapping_style_t // The mapping style. } start_mark yaml_mark_t // The beginning of the node. end_mark yaml_mark_t // The end of the node. } // The document structure. type yaml_document_t struct { // The document nodes. nodes []yaml_node_t // The version directive. version_directive *yaml_version_directive_t // The list of tag directives. tag_directives_data []yaml_tag_directive_t tag_directives_start int // The beginning of the tag directives list. tag_directives_end int // The end of the tag directives list. start_implicit int // Is the document start indicator implicit? end_implicit int // Is the document end indicator implicit? // The start/end of the document. start_mark, end_mark yaml_mark_t } // The prototype of a read handler. // // The read handler is called when the parser needs to read more bytes from the // source. The handler should write not more than size bytes to the buffer. // The number of written bytes should be set to the size_read variable. // // [in,out] data A pointer to an application data specified by // yaml_parser_set_input(). // [out] buffer The buffer to write the data from the source. // [in] size The size of the buffer. // [out] size_read The actual number of bytes read from the source. // // On success, the handler should return 1. If the handler failed, // the returned value should be 0. On EOF, the handler should set the // size_read to 0 and return 1. type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error) // This structure holds information about a potential simple key. type yaml_simple_key_t struct { possible bool // Is a simple key possible? required bool // Is a simple key required? token_number int // The number of the token. mark yaml_mark_t // The position mark. } // The states of the parser. type yaml_parser_state_t int const ( yaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE // Expect the beginning of an implicit document. yaml_PARSE_DOCUMENT_START_STATE // Expect DOCUMENT-START. yaml_PARSE_DOCUMENT_CONTENT_STATE // Expect the content of a document. yaml_PARSE_DOCUMENT_END_STATE // Expect DOCUMENT-END. yaml_PARSE_BLOCK_NODE_STATE // Expect a block node. yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE // Expect a block node or indentless sequence. yaml_PARSE_FLOW_NODE_STATE // Expect a flow node. yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a block sequence. yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE // Expect an entry of a block sequence. yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE // Expect an entry of an indentless sequence. yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. yaml_PARSE_BLOCK_MAPPING_KEY_STATE // Expect a block mapping key. yaml_PARSE_BLOCK_MAPPING_VALUE_STATE // Expect a block mapping value. yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a flow sequence. yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE // Expect an entry of a flow sequence. yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE // Expect a key of an ordered mapping. yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE // Expect a value of an ordered mapping. yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE // Expect the and of an ordered mapping entry. yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. yaml_PARSE_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. yaml_PARSE_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE // Expect an empty value of a flow mapping. yaml_PARSE_END_STATE // Expect nothing. ) func (ps yaml_parser_state_t) String() string { switch ps { case yaml_PARSE_STREAM_START_STATE: return "yaml_PARSE_STREAM_START_STATE" case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: return "yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE" case yaml_PARSE_DOCUMENT_START_STATE: return "yaml_PARSE_DOCUMENT_START_STATE" case yaml_PARSE_DOCUMENT_CONTENT_STATE: return "yaml_PARSE_DOCUMENT_CONTENT_STATE" case yaml_PARSE_DOCUMENT_END_STATE: return "yaml_PARSE_DOCUMENT_END_STATE" case yaml_PARSE_BLOCK_NODE_STATE: return "yaml_PARSE_BLOCK_NODE_STATE" case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: return "yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE" case yaml_PARSE_FLOW_NODE_STATE: return "yaml_PARSE_FLOW_NODE_STATE" case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: return "yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE" case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: return "yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE" case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: return "yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE" case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: return "yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE" case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: return "yaml_PARSE_BLOCK_MAPPING_KEY_STATE" case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: return "yaml_PARSE_BLOCK_MAPPING_VALUE_STATE" case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: return "yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE" case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE" case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE" case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE" case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE" case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: return "yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE" case yaml_PARSE_FLOW_MAPPING_KEY_STATE: return "yaml_PARSE_FLOW_MAPPING_KEY_STATE" case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: return "yaml_PARSE_FLOW_MAPPING_VALUE_STATE" case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: return "yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE" case yaml_PARSE_END_STATE: return "yaml_PARSE_END_STATE" } return "<unknown parser state>" } // This structure holds aliases data. type yaml_alias_data_t struct { anchor []byte // The anchor. index int // The node id. mark yaml_mark_t // The anchor mark. } // The parser structure. // // All members are internal. Manage the structure using the // yaml_parser_ family of functions. type yaml_parser_t struct { // Error handling error yaml_error_type_t // Error type. problem string // Error description. // The byte about which the problem occurred. problem_offset int problem_value int problem_mark yaml_mark_t // The error context. context string context_mark yaml_mark_t // Reader stuff read_handler yaml_read_handler_t // Read handler. input_reader io.Reader // File input data. input []byte // String input data. input_pos int eof bool // EOF flag buffer []byte // The working buffer. buffer_pos int // The current position of the buffer. unread int // The number of unread characters in the buffer. newlines int // The number of line breaks since last non-break/non-blank character raw_buffer []byte // The raw buffer. raw_buffer_pos int // The current position of the buffer. encoding yaml_encoding_t // The input encoding. offset int // The offset of the current position (in bytes). mark yaml_mark_t // The mark of the current position. // Comments head_comment []byte // The current head comments line_comment []byte // The current line comments foot_comment []byte // The current foot comments tail_comment []byte // Foot comment that happens at the end of a block. stem_comment []byte // Comment in item preceding a nested structure (list inside list item, etc) comments []yaml_comment_t // The folded comments for all parsed tokens comments_head int // Scanner stuff stream_start_produced bool // Have we started to scan the input stream? stream_end_produced bool // Have we reached the end of the input stream? flow_level int // The number of unclosed '[' and '{' indicators. tokens []yaml_token_t // The tokens queue. tokens_head int // The head of the tokens queue. tokens_parsed int // The number of tokens fetched from the queue. token_available bool // Does the tokens queue contain a token ready for dequeueing. indent int // The current indentation level. indents []int // The indentation levels stack. simple_key_allowed bool // May a simple key occur at the current position? simple_keys []yaml_simple_key_t // The stack of simple keys. simple_keys_by_tok map[int]int // possible simple_key indexes indexed by token_number // Parser stuff state yaml_parser_state_t // The current parser state. states []yaml_parser_state_t // The parser states stack. marks []yaml_mark_t // The stack of marks. tag_directives []yaml_tag_directive_t // The list of TAG directives. // Dumper stuff aliases []yaml_alias_data_t // The alias data. document *yaml_document_t // The currently parsed document. } type yaml_comment_t struct { scan_mark yaml_mark_t // Position where scanning for comments started token_mark yaml_mark_t // Position after which tokens will be associated with this comment start_mark yaml_mark_t // Position of '#' comment mark end_mark yaml_mark_t // Position where comment terminated head []byte line []byte foot []byte } // Emitter Definitions // The prototype of a write handler. // // The write handler is called when the emitter needs to flush the accumulated // characters to the output. The handler should write @a size bytes of the // @a buffer to the output. // // @param[in,out] data A pointer to an application data specified by // yaml_emitter_set_output(). // @param[in] buffer The buffer with bytes to be written. // @param[in] size The size of the buffer. // // @returns On success, the handler should return @c 1. If the handler failed, // the returned value should be @c 0. // type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error type yaml_emitter_state_t int // The emitter states. const ( // Expect STREAM-START. yaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota yaml_EMIT_FIRST_DOCUMENT_START_STATE // Expect the first DOCUMENT-START or STREAM-END. yaml_EMIT_DOCUMENT_START_STATE // Expect DOCUMENT-START or STREAM-END. yaml_EMIT_DOCUMENT_CONTENT_STATE // Expect the content of a document. yaml_EMIT_DOCUMENT_END_STATE // Expect DOCUMENT-END. yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a flow sequence. yaml_EMIT_FLOW_SEQUENCE_TRAIL_ITEM_STATE // Expect the next item of a flow sequence, with the comma already written out yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE // Expect an item of a flow sequence. yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. yaml_EMIT_FLOW_MAPPING_TRAIL_KEY_STATE // Expect the next key of a flow mapping, with the comma already written out yaml_EMIT_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a flow mapping. yaml_EMIT_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a block sequence. yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE // Expect an item of a block sequence. yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. yaml_EMIT_BLOCK_MAPPING_KEY_STATE // Expect the key of a block mapping. yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a block mapping. yaml_EMIT_BLOCK_MAPPING_VALUE_STATE // Expect a value of a block mapping. yaml_EMIT_END_STATE // Expect nothing. ) // The emitter structure. // // All members are internal. Manage the structure using the @c yaml_emitter_ // family of functions. type yaml_emitter_t struct { // Error handling error yaml_error_type_t // Error type. problem string // Error description. // Writer stuff write_handler yaml_write_handler_t // Write handler. output_buffer *[]byte // String output data. output_writer io.Writer // File output data. buffer []byte // The working buffer. buffer_pos int // The current position of the buffer. raw_buffer []byte // The raw buffer. raw_buffer_pos int // The current position of the buffer. encoding yaml_encoding_t // The stream encoding. // Emitter stuff canonical bool // If the output is in the canonical style? best_indent int // The number of indentation spaces. best_width int // The preferred width of the output lines. unicode bool // Allow unescaped non-ASCII characters? line_break yaml_break_t // The preferred line break. state yaml_emitter_state_t // The current emitter state. states []yaml_emitter_state_t // The stack of states. events []yaml_event_t // The event queue. events_head int // The head of the event queue. indents []int // The stack of indentation levels. tag_directives []yaml_tag_directive_t // The list of tag directives. indent int // The current indentation level. flow_level int // The current flow level. root_context bool // Is it the document root context? sequence_context bool // Is it a sequence context? mapping_context bool // Is it a mapping context? simple_key_context bool // Is it a simple mapping key context? line int // The current line. column int // The current column. whitespace bool // If the last character was a whitespace? indention bool // If the last character was an indentation character (' ', '-', '?', ':')? open_ended bool // If an explicit document end is required? space_above bool // Is there's an empty line above? foot_indent int // The indent used to write the foot comment above, or -1 if none. // Anchor analysis. anchor_data struct { anchor []byte // The anchor value. alias bool // Is it an alias? } // Tag analysis. tag_data struct { handle []byte // The tag handle. suffix []byte // The tag suffix. } // Scalar analysis. scalar_data struct { value []byte // The scalar value. multiline bool // Does the scalar contain line breaks? flow_plain_allowed bool // Can the scalar be expessed in the flow plain style? block_plain_allowed bool // Can the scalar be expressed in the block plain style? single_quoted_allowed bool // Can the scalar be expressed in the single quoted style? block_allowed bool // Can the scalar be expressed in the literal or folded styles? style yaml_scalar_style_t // The output style. } // Comments head_comment []byte line_comment []byte foot_comment []byte tail_comment []byte key_line_comment []byte // Dumper stuff opened bool // If the stream was already opened? closed bool // If the stream was already closed? // The information associated with the document nodes. anchors *struct { references int // The number of references. anchor int // The anchor id. serialized bool // If the node has been emitted? } last_anchor_id int // The last assigned anchor id. document *yaml_document_t // The currently emitted document. }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/scannerc.go
vendor/gopkg.in/yaml.v3/scannerc.go
// // Copyright (c) 2011-2019 Canonical Ltd // Copyright (c) 2006-2010 Kirill Simonov // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies // of the Software, and to permit persons to whom the Software is furnished to do // so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. package yaml import ( "bytes" "fmt" ) // Introduction // ************ // // The following notes assume that you are familiar with the YAML specification // (http://yaml.org/spec/1.2/spec.html). We mostly follow it, although in // some cases we are less restrictive that it requires. // // The process of transforming a YAML stream into a sequence of events is // divided on two steps: Scanning and Parsing. // // The Scanner transforms the input stream into a sequence of tokens, while the // parser transform the sequence of tokens produced by the Scanner into a // sequence of parsing events. // // The Scanner is rather clever and complicated. The Parser, on the contrary, // is a straightforward implementation of a recursive-descendant parser (or, // LL(1) parser, as it is usually called). // // Actually there are two issues of Scanning that might be called "clever", the // rest is quite straightforward. The issues are "block collection start" and // "simple keys". Both issues are explained below in details. // // Here the Scanning step is explained and implemented. We start with the list // of all the tokens produced by the Scanner together with short descriptions. // // Now, tokens: // // STREAM-START(encoding) # The stream start. // STREAM-END # The stream end. // VERSION-DIRECTIVE(major,minor) # The '%YAML' directive. // TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive. // DOCUMENT-START # '---' // DOCUMENT-END # '...' // BLOCK-SEQUENCE-START # Indentation increase denoting a block // BLOCK-MAPPING-START # sequence or a block mapping. // BLOCK-END # Indentation decrease. // FLOW-SEQUENCE-START # '[' // FLOW-SEQUENCE-END # ']' // BLOCK-SEQUENCE-START # '{' // BLOCK-SEQUENCE-END # '}' // BLOCK-ENTRY # '-' // FLOW-ENTRY # ',' // KEY # '?' or nothing (simple keys). // VALUE # ':' // ALIAS(anchor) # '*anchor' // ANCHOR(anchor) # '&anchor' // TAG(handle,suffix) # '!handle!suffix' // SCALAR(value,style) # A scalar. // // The following two tokens are "virtual" tokens denoting the beginning and the // end of the stream: // // STREAM-START(encoding) // STREAM-END // // We pass the information about the input stream encoding with the // STREAM-START token. // // The next two tokens are responsible for tags: // // VERSION-DIRECTIVE(major,minor) // TAG-DIRECTIVE(handle,prefix) // // Example: // // %YAML 1.1 // %TAG ! !foo // %TAG !yaml! tag:yaml.org,2002: // --- // // The correspoding sequence of tokens: // // STREAM-START(utf-8) // VERSION-DIRECTIVE(1,1) // TAG-DIRECTIVE("!","!foo") // TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:") // DOCUMENT-START // STREAM-END // // Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole // line. // // The document start and end indicators are represented by: // // DOCUMENT-START // DOCUMENT-END // // Note that if a YAML stream contains an implicit document (without '---' // and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be // produced. // // In the following examples, we present whole documents together with the // produced tokens. // // 1. An implicit document: // // 'a scalar' // // Tokens: // // STREAM-START(utf-8) // SCALAR("a scalar",single-quoted) // STREAM-END // // 2. An explicit document: // // --- // 'a scalar' // ... // // Tokens: // // STREAM-START(utf-8) // DOCUMENT-START // SCALAR("a scalar",single-quoted) // DOCUMENT-END // STREAM-END // // 3. Several documents in a stream: // // 'a scalar' // --- // 'another scalar' // --- // 'yet another scalar' // // Tokens: // // STREAM-START(utf-8) // SCALAR("a scalar",single-quoted) // DOCUMENT-START // SCALAR("another scalar",single-quoted) // DOCUMENT-START // SCALAR("yet another scalar",single-quoted) // STREAM-END // // We have already introduced the SCALAR token above. The following tokens are // used to describe aliases, anchors, tag, and scalars: // // ALIAS(anchor) // ANCHOR(anchor) // TAG(handle,suffix) // SCALAR(value,style) // // The following series of examples illustrate the usage of these tokens: // // 1. A recursive sequence: // // &A [ *A ] // // Tokens: // // STREAM-START(utf-8) // ANCHOR("A") // FLOW-SEQUENCE-START // ALIAS("A") // FLOW-SEQUENCE-END // STREAM-END // // 2. A tagged scalar: // // !!float "3.14" # A good approximation. // // Tokens: // // STREAM-START(utf-8) // TAG("!!","float") // SCALAR("3.14",double-quoted) // STREAM-END // // 3. Various scalar styles: // // --- # Implicit empty plain scalars do not produce tokens. // --- a plain scalar // --- 'a single-quoted scalar' // --- "a double-quoted scalar" // --- |- // a literal scalar // --- >- // a folded // scalar // // Tokens: // // STREAM-START(utf-8) // DOCUMENT-START // DOCUMENT-START // SCALAR("a plain scalar",plain) // DOCUMENT-START // SCALAR("a single-quoted scalar",single-quoted) // DOCUMENT-START // SCALAR("a double-quoted scalar",double-quoted) // DOCUMENT-START // SCALAR("a literal scalar",literal) // DOCUMENT-START // SCALAR("a folded scalar",folded) // STREAM-END // // Now it's time to review collection-related tokens. We will start with // flow collections: // // FLOW-SEQUENCE-START // FLOW-SEQUENCE-END // FLOW-MAPPING-START // FLOW-MAPPING-END // FLOW-ENTRY // KEY // VALUE // // The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and // FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}' // correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the // indicators '?' and ':', which are used for denoting mapping keys and values, // are represented by the KEY and VALUE tokens. // // The following examples show flow collections: // // 1. A flow sequence: // // [item 1, item 2, item 3] // // Tokens: // // STREAM-START(utf-8) // FLOW-SEQUENCE-START // SCALAR("item 1",plain) // FLOW-ENTRY // SCALAR("item 2",plain) // FLOW-ENTRY // SCALAR("item 3",plain) // FLOW-SEQUENCE-END // STREAM-END // // 2. A flow mapping: // // { // a simple key: a value, # Note that the KEY token is produced. // ? a complex key: another value, // } // // Tokens: // // STREAM-START(utf-8) // FLOW-MAPPING-START // KEY // SCALAR("a simple key",plain) // VALUE // SCALAR("a value",plain) // FLOW-ENTRY // KEY // SCALAR("a complex key",plain) // VALUE // SCALAR("another value",plain) // FLOW-ENTRY // FLOW-MAPPING-END // STREAM-END // // A simple key is a key which is not denoted by the '?' indicator. Note that // the Scanner still produce the KEY token whenever it encounters a simple key. // // For scanning block collections, the following tokens are used (note that we // repeat KEY and VALUE here): // // BLOCK-SEQUENCE-START // BLOCK-MAPPING-START // BLOCK-END // BLOCK-ENTRY // KEY // VALUE // // The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation // increase that precedes a block collection (cf. the INDENT token in Python). // The token BLOCK-END denote indentation decrease that ends a block collection // (cf. the DEDENT token in Python). However YAML has some syntax pecularities // that makes detections of these tokens more complex. // // The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators // '-', '?', and ':' correspondingly. // // The following examples show how the tokens BLOCK-SEQUENCE-START, // BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner: // // 1. Block sequences: // // - item 1 // - item 2 // - // - item 3.1 // - item 3.2 // - // key 1: value 1 // key 2: value 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-ENTRY // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 3.1",plain) // BLOCK-ENTRY // SCALAR("item 3.2",plain) // BLOCK-END // BLOCK-ENTRY // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // BLOCK-END // STREAM-END // // 2. Block mappings: // // a simple key: a value # The KEY token is produced here. // ? a complex key // : another value // a mapping: // key 1: value 1 // key 2: value 2 // a sequence: // - item 1 // - item 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-MAPPING-START // KEY // SCALAR("a simple key",plain) // VALUE // SCALAR("a value",plain) // KEY // SCALAR("a complex key",plain) // VALUE // SCALAR("another value",plain) // KEY // SCALAR("a mapping",plain) // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // KEY // SCALAR("a sequence",plain) // VALUE // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // BLOCK-END // STREAM-END // // YAML does not always require to start a new block collection from a new // line. If the current line contains only '-', '?', and ':' indicators, a new // block collection may start at the current line. The following examples // illustrate this case: // // 1. Collections in a sequence: // // - - item 1 // - item 2 // - key 1: value 1 // key 2: value 2 // - ? complex key // : complex value // // Tokens: // // STREAM-START(utf-8) // BLOCK-SEQUENCE-START // BLOCK-ENTRY // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // BLOCK-ENTRY // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // BLOCK-ENTRY // BLOCK-MAPPING-START // KEY // SCALAR("complex key") // VALUE // SCALAR("complex value") // BLOCK-END // BLOCK-END // STREAM-END // // 2. Collections in a mapping: // // ? a sequence // : - item 1 // - item 2 // ? a mapping // : key 1: value 1 // key 2: value 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-MAPPING-START // KEY // SCALAR("a sequence",plain) // VALUE // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // KEY // SCALAR("a mapping",plain) // VALUE // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // BLOCK-END // STREAM-END // // YAML also permits non-indented sequences if they are included into a block // mapping. In this case, the token BLOCK-SEQUENCE-START is not produced: // // key: // - item 1 # BLOCK-SEQUENCE-START is NOT produced here. // - item 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-MAPPING-START // KEY // SCALAR("key",plain) // VALUE // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // // Ensure that the buffer contains the required number of characters. // Return true on success, false on failure (reader error or memory error). func cache(parser *yaml_parser_t, length int) bool { // [Go] This was inlined: !cache(A, B) -> unread < B && !update(A, B) return parser.unread >= length || yaml_parser_update_buffer(parser, length) } // Advance the buffer pointer. func skip(parser *yaml_parser_t) { if !is_blank(parser.buffer, parser.buffer_pos) { parser.newlines = 0 } parser.mark.index++ parser.mark.column++ parser.unread-- parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) } func skip_line(parser *yaml_parser_t) { if is_crlf(parser.buffer, parser.buffer_pos) { parser.mark.index += 2 parser.mark.column = 0 parser.mark.line++ parser.unread -= 2 parser.buffer_pos += 2 parser.newlines++ } else if is_break(parser.buffer, parser.buffer_pos) { parser.mark.index++ parser.mark.column = 0 parser.mark.line++ parser.unread-- parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) parser.newlines++ } } // Copy a character to a string buffer and advance pointers. func read(parser *yaml_parser_t, s []byte) []byte { if !is_blank(parser.buffer, parser.buffer_pos) { parser.newlines = 0 } w := width(parser.buffer[parser.buffer_pos]) if w == 0 { panic("invalid character sequence") } if len(s) == 0 { s = make([]byte, 0, 32) } if w == 1 && len(s)+w <= cap(s) { s = s[:len(s)+1] s[len(s)-1] = parser.buffer[parser.buffer_pos] parser.buffer_pos++ } else { s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...) parser.buffer_pos += w } parser.mark.index++ parser.mark.column++ parser.unread-- return s } // Copy a line break character to a string buffer and advance pointers. func read_line(parser *yaml_parser_t, s []byte) []byte { buf := parser.buffer pos := parser.buffer_pos switch { case buf[pos] == '\r' && buf[pos+1] == '\n': // CR LF . LF s = append(s, '\n') parser.buffer_pos += 2 parser.mark.index++ parser.unread-- case buf[pos] == '\r' || buf[pos] == '\n': // CR|LF . LF s = append(s, '\n') parser.buffer_pos += 1 case buf[pos] == '\xC2' && buf[pos+1] == '\x85': // NEL . LF s = append(s, '\n') parser.buffer_pos += 2 case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'): // LS|PS . LS|PS s = append(s, buf[parser.buffer_pos:pos+3]...) parser.buffer_pos += 3 default: return s } parser.mark.index++ parser.mark.column = 0 parser.mark.line++ parser.unread-- parser.newlines++ return s } // Get the next token. func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool { // Erase the token object. *token = yaml_token_t{} // [Go] Is this necessary? // No tokens after STREAM-END or error. if parser.stream_end_produced || parser.error != yaml_NO_ERROR { return true } // Ensure that the tokens queue contains enough tokens. if !parser.token_available { if !yaml_parser_fetch_more_tokens(parser) { return false } } // Fetch the next token from the queue. *token = parser.tokens[parser.tokens_head] parser.tokens_head++ parser.tokens_parsed++ parser.token_available = false if token.typ == yaml_STREAM_END_TOKEN { parser.stream_end_produced = true } return true } // Set the scanner error and return false. func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool { parser.error = yaml_SCANNER_ERROR parser.context = context parser.context_mark = context_mark parser.problem = problem parser.problem_mark = parser.mark return false } func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, context_mark yaml_mark_t, problem string) bool { context := "while parsing a tag" if directive { context = "while parsing a %TAG directive" } return yaml_parser_set_scanner_error(parser, context, context_mark, problem) } func trace(args ...interface{}) func() { pargs := append([]interface{}{"+++"}, args...) fmt.Println(pargs...) pargs = append([]interface{}{"---"}, args...) return func() { fmt.Println(pargs...) } } // Ensure that the tokens queue contains at least one token which can be // returned to the Parser. func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { // While we need more tokens to fetch, do it. for { // [Go] The comment parsing logic requires a lookahead of two tokens // so that foot comments may be parsed in time of associating them // with the tokens that are parsed before them, and also for line // comments to be transformed into head comments in some edge cases. if parser.tokens_head < len(parser.tokens)-2 { // If a potential simple key is at the head position, we need to fetch // the next token to disambiguate it. head_tok_idx, ok := parser.simple_keys_by_tok[parser.tokens_parsed] if !ok { break } else if valid, ok := yaml_simple_key_is_valid(parser, &parser.simple_keys[head_tok_idx]); !ok { return false } else if !valid { break } } // Fetch the next token. if !yaml_parser_fetch_next_token(parser) { return false } } parser.token_available = true return true } // The dispatcher for token fetchers. func yaml_parser_fetch_next_token(parser *yaml_parser_t) (ok bool) { // Ensure that the buffer is initialized. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } // Check if we just started scanning. Fetch STREAM-START then. if !parser.stream_start_produced { return yaml_parser_fetch_stream_start(parser) } scan_mark := parser.mark // Eat whitespaces and comments until we reach the next token. if !yaml_parser_scan_to_next_token(parser) { return false } // [Go] While unrolling indents, transform the head comments of prior // indentation levels observed after scan_start into foot comments at // the respective indexes. // Check the indentation level against the current column. if !yaml_parser_unroll_indent(parser, parser.mark.column, scan_mark) { return false } // Ensure that the buffer contains at least 4 characters. 4 is the length // of the longest indicators ('--- ' and '... '). if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { return false } // Is it the end of the stream? if is_z(parser.buffer, parser.buffer_pos) { return yaml_parser_fetch_stream_end(parser) } // Is it a directive? if parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' { return yaml_parser_fetch_directive(parser) } buf := parser.buffer pos := parser.buffer_pos // Is it the document start indicator? if parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) { return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN) } // Is it the document end indicator? if parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) { return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN) } comment_mark := parser.mark if len(parser.tokens) > 0 && (parser.flow_level == 0 && buf[pos] == ':' || parser.flow_level > 0 && buf[pos] == ',') { // Associate any following comments with the prior token. comment_mark = parser.tokens[len(parser.tokens)-1].start_mark } defer func() { if !ok { return } if len(parser.tokens) > 0 && parser.tokens[len(parser.tokens)-1].typ == yaml_BLOCK_ENTRY_TOKEN { // Sequence indicators alone have no line comments. It becomes // a head comment for whatever follows. return } if !yaml_parser_scan_line_comment(parser, comment_mark) { ok = false return } }() // Is it the flow sequence start indicator? if buf[pos] == '[' { return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_SEQUENCE_START_TOKEN) } // Is it the flow mapping start indicator? if parser.buffer[parser.buffer_pos] == '{' { return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_MAPPING_START_TOKEN) } // Is it the flow sequence end indicator? if parser.buffer[parser.buffer_pos] == ']' { return yaml_parser_fetch_flow_collection_end(parser, yaml_FLOW_SEQUENCE_END_TOKEN) } // Is it the flow mapping end indicator? if parser.buffer[parser.buffer_pos] == '}' { return yaml_parser_fetch_flow_collection_end(parser, yaml_FLOW_MAPPING_END_TOKEN) } // Is it the flow entry indicator? if parser.buffer[parser.buffer_pos] == ',' { return yaml_parser_fetch_flow_entry(parser) } // Is it the block entry indicator? if parser.buffer[parser.buffer_pos] == '-' && is_blankz(parser.buffer, parser.buffer_pos+1) { return yaml_parser_fetch_block_entry(parser) } // Is it the key indicator? if parser.buffer[parser.buffer_pos] == '?' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { return yaml_parser_fetch_key(parser) } // Is it the value indicator? if parser.buffer[parser.buffer_pos] == ':' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { return yaml_parser_fetch_value(parser) } // Is it an alias? if parser.buffer[parser.buffer_pos] == '*' { return yaml_parser_fetch_anchor(parser, yaml_ALIAS_TOKEN) } // Is it an anchor? if parser.buffer[parser.buffer_pos] == '&' { return yaml_parser_fetch_anchor(parser, yaml_ANCHOR_TOKEN) } // Is it a tag? if parser.buffer[parser.buffer_pos] == '!' { return yaml_parser_fetch_tag(parser) } // Is it a literal scalar? if parser.buffer[parser.buffer_pos] == '|' && parser.flow_level == 0 { return yaml_parser_fetch_block_scalar(parser, true) } // Is it a folded scalar? if parser.buffer[parser.buffer_pos] == '>' && parser.flow_level == 0 { return yaml_parser_fetch_block_scalar(parser, false) } // Is it a single-quoted scalar? if parser.buffer[parser.buffer_pos] == '\'' { return yaml_parser_fetch_flow_scalar(parser, true) } // Is it a double-quoted scalar? if parser.buffer[parser.buffer_pos] == '"' { return yaml_parser_fetch_flow_scalar(parser, false) } // Is it a plain scalar? // // A plain scalar may start with any non-blank characters except // // '-', '?', ':', ',', '[', ']', '{', '}', // '#', '&', '*', '!', '|', '>', '\'', '\"', // '%', '@', '`'. // // In the block context (and, for the '-' indicator, in the flow context // too), it may also start with the characters // // '-', '?', ':' // // if it is followed by a non-space character. // // The last rule is more restrictive than the specification requires. // [Go] TODO Make this logic more reasonable. //switch parser.buffer[parser.buffer_pos] { //case '-', '?', ':', ',', '?', '-', ',', ':', ']', '[', '}', '{', '&', '#', '!', '*', '>', '|', '"', '\'', '@', '%', '-', '`': //} if !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '-' || parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || parser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '#' || parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '|' || parser.buffer[parser.buffer_pos] == '>' || parser.buffer[parser.buffer_pos] == '\'' || parser.buffer[parser.buffer_pos] == '"' || parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') || (parser.buffer[parser.buffer_pos] == '-' && !is_blank(parser.buffer, parser.buffer_pos+1)) || (parser.flow_level == 0 && (parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':') && !is_blankz(parser.buffer, parser.buffer_pos+1)) { return yaml_parser_fetch_plain_scalar(parser) } // If we don't determine the token type so far, it is an error. return yaml_parser_set_scanner_error(parser, "while scanning for the next token", parser.mark, "found character that cannot start any token") } func yaml_simple_key_is_valid(parser *yaml_parser_t, simple_key *yaml_simple_key_t) (valid, ok bool) { if !simple_key.possible { return false, true } // The 1.2 specification says: // // "If the ? indicator is omitted, parsing needs to see past the // implicit key to recognize it as such. To limit the amount of // lookahead required, the “:” indicator must appear at most 1024 // Unicode characters beyond the start of the key. In addition, the key // is restricted to a single line." // if simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index { // Check if the potential simple key to be removed is required. if simple_key.required { return false, yaml_parser_set_scanner_error(parser, "while scanning a simple key", simple_key.mark, "could not find expected ':'") } simple_key.possible = false return false, true } return true, true } // Check if a simple key may start at the current position and add it if // needed. func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { // A simple key is required at the current position if the scanner is in // the block context and the current column coincides with the indentation // level. required := parser.flow_level == 0 && parser.indent == parser.mark.column // // If the current position may start a simple key, save it. // if parser.simple_key_allowed { simple_key := yaml_simple_key_t{ possible: true, required: required, token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), mark: parser.mark, } if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_keys[len(parser.simple_keys)-1] = simple_key parser.simple_keys_by_tok[simple_key.token_number] = len(parser.simple_keys) - 1 } return true } // Remove a potential simple key at the current flow level. func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { i := len(parser.simple_keys) - 1 if parser.simple_keys[i].possible { // If the key is required, it is an error. if parser.simple_keys[i].required { return yaml_parser_set_scanner_error(parser, "while scanning a simple key", parser.simple_keys[i].mark, "could not find expected ':'") } // Remove the key from the stack. parser.simple_keys[i].possible = false delete(parser.simple_keys_by_tok, parser.simple_keys[i].token_number) } return true } // max_flow_level limits the flow_level const max_flow_level = 10000 // Increase the flow level and resize the simple key list if needed. func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { // Reset the simple key on the next level. parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{ possible: false, required: false, token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), mark: parser.mark, }) // Increase the flow level. parser.flow_level++ if parser.flow_level > max_flow_level { return yaml_parser_set_scanner_error(parser, "while increasing flow level", parser.simple_keys[len(parser.simple_keys)-1].mark, fmt.Sprintf("exceeded max depth of %d", max_flow_level)) } return true } // Decrease the flow level. func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { if parser.flow_level > 0 { parser.flow_level-- last := len(parser.simple_keys) - 1 delete(parser.simple_keys_by_tok, parser.simple_keys[last].token_number) parser.simple_keys = parser.simple_keys[:last] } return true } // max_indents limits the indents stack size const max_indents = 10000 // Push the current indentation level to the stack and set the new level // the current column is greater than the indentation level. In this case, // append or insert the specified token into the token queue. func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool { // In the flow context, do nothing. if parser.flow_level > 0 { return true } if parser.indent < column { // Push the current indentation level to the stack and set the new // indentation level. parser.indents = append(parser.indents, parser.indent) parser.indent = column if len(parser.indents) > max_indents { return yaml_parser_set_scanner_error(parser, "while increasing indent level", parser.simple_keys[len(parser.simple_keys)-1].mark, fmt.Sprintf("exceeded max depth of %d", max_indents)) } // Create a token and insert it into the queue. token := yaml_token_t{ typ: typ, start_mark: mark, end_mark: mark, } if number > -1 { number -= parser.tokens_parsed } yaml_insert_token(parser, number, &token) } return true } // Pop indentation levels from the indents stack until the current level // becomes less or equal to the column. For each indentation level, append // the BLOCK-END token. func yaml_parser_unroll_indent(parser *yaml_parser_t, column int, scan_mark yaml_mark_t) bool { // In the flow context, do nothing. if parser.flow_level > 0 { return true } block_mark := scan_mark block_mark.index-- // Loop through the indentation levels in the stack. for parser.indent > column { // [Go] Reposition the end token before potential following // foot comments of parent blocks. For that, search // backwards for recent comments that were at the same // indent as the block that is ending now. stop_index := block_mark.index for i := len(parser.comments) - 1; i >= 0; i-- { comment := &parser.comments[i] if comment.end_mark.index < stop_index { // Don't go back beyond the start of the comment/whitespace scan, unless column < 0.
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/decode.go
vendor/gopkg.in/yaml.v3/decode.go
// // Copyright (c) 2011-2019 Canonical Ltd // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package yaml import ( "encoding" "encoding/base64" "fmt" "io" "math" "reflect" "strconv" "time" ) // ---------------------------------------------------------------------------- // Parser, produces a node tree out of a libyaml event stream. type parser struct { parser yaml_parser_t event yaml_event_t doc *Node anchors map[string]*Node doneInit bool textless bool } func newParser(b []byte) *parser { p := parser{} if !yaml_parser_initialize(&p.parser) { panic("failed to initialize YAML emitter") } if len(b) == 0 { b = []byte{'\n'} } yaml_parser_set_input_string(&p.parser, b) return &p } func newParserFromReader(r io.Reader) *parser { p := parser{} if !yaml_parser_initialize(&p.parser) { panic("failed to initialize YAML emitter") } yaml_parser_set_input_reader(&p.parser, r) return &p } func (p *parser) init() { if p.doneInit { return } p.anchors = make(map[string]*Node) p.expect(yaml_STREAM_START_EVENT) p.doneInit = true } func (p *parser) destroy() { if p.event.typ != yaml_NO_EVENT { yaml_event_delete(&p.event) } yaml_parser_delete(&p.parser) } // expect consumes an event from the event stream and // checks that it's of the expected type. func (p *parser) expect(e yaml_event_type_t) { if p.event.typ == yaml_NO_EVENT { if !yaml_parser_parse(&p.parser, &p.event) { p.fail() } } if p.event.typ == yaml_STREAM_END_EVENT { failf("attempted to go past the end of stream; corrupted value?") } if p.event.typ != e { p.parser.problem = fmt.Sprintf("expected %s event but got %s", e, p.event.typ) p.fail() } yaml_event_delete(&p.event) p.event.typ = yaml_NO_EVENT } // peek peeks at the next event in the event stream, // puts the results into p.event and returns the event type. func (p *parser) peek() yaml_event_type_t { if p.event.typ != yaml_NO_EVENT { return p.event.typ } // It's curious choice from the underlying API to generally return a // positive result on success, but on this case return true in an error // scenario. This was the source of bugs in the past (issue #666). if !yaml_parser_parse(&p.parser, &p.event) || p.parser.error != yaml_NO_ERROR { p.fail() } return p.event.typ } func (p *parser) fail() { var where string var line int if p.parser.context_mark.line != 0 { line = p.parser.context_mark.line // Scanner errors don't iterate line before returning error if p.parser.error == yaml_SCANNER_ERROR { line++ } } else if p.parser.problem_mark.line != 0 { line = p.parser.problem_mark.line // Scanner errors don't iterate line before returning error if p.parser.error == yaml_SCANNER_ERROR { line++ } } if line != 0 { where = "line " + strconv.Itoa(line) + ": " } var msg string if len(p.parser.problem) > 0 { msg = p.parser.problem } else { msg = "unknown problem parsing YAML content" } failf("%s%s", where, msg) } func (p *parser) anchor(n *Node, anchor []byte) { if anchor != nil { n.Anchor = string(anchor) p.anchors[n.Anchor] = n } } func (p *parser) parse() *Node { p.init() switch p.peek() { case yaml_SCALAR_EVENT: return p.scalar() case yaml_ALIAS_EVENT: return p.alias() case yaml_MAPPING_START_EVENT: return p.mapping() case yaml_SEQUENCE_START_EVENT: return p.sequence() case yaml_DOCUMENT_START_EVENT: return p.document() case yaml_STREAM_END_EVENT: // Happens when attempting to decode an empty buffer. return nil case yaml_TAIL_COMMENT_EVENT: panic("internal error: unexpected tail comment event (please report)") default: panic("internal error: attempted to parse unknown event (please report): " + p.event.typ.String()) } } func (p *parser) node(kind Kind, defaultTag, tag, value string) *Node { var style Style if tag != "" && tag != "!" { tag = shortTag(tag) style = TaggedStyle } else if defaultTag != "" { tag = defaultTag } else if kind == ScalarNode { tag, _ = resolve("", value) } n := &Node{ Kind: kind, Tag: tag, Value: value, Style: style, } if !p.textless { n.Line = p.event.start_mark.line + 1 n.Column = p.event.start_mark.column + 1 n.HeadComment = string(p.event.head_comment) n.LineComment = string(p.event.line_comment) n.FootComment = string(p.event.foot_comment) } return n } func (p *parser) parseChild(parent *Node) *Node { child := p.parse() parent.Content = append(parent.Content, child) return child } func (p *parser) document() *Node { n := p.node(DocumentNode, "", "", "") p.doc = n p.expect(yaml_DOCUMENT_START_EVENT) p.parseChild(n) if p.peek() == yaml_DOCUMENT_END_EVENT { n.FootComment = string(p.event.foot_comment) } p.expect(yaml_DOCUMENT_END_EVENT) return n } func (p *parser) alias() *Node { n := p.node(AliasNode, "", "", string(p.event.anchor)) n.Alias = p.anchors[n.Value] if n.Alias == nil { failf("unknown anchor '%s' referenced", n.Value) } p.expect(yaml_ALIAS_EVENT) return n } func (p *parser) scalar() *Node { var parsedStyle = p.event.scalar_style() var nodeStyle Style switch { case parsedStyle&yaml_DOUBLE_QUOTED_SCALAR_STYLE != 0: nodeStyle = DoubleQuotedStyle case parsedStyle&yaml_SINGLE_QUOTED_SCALAR_STYLE != 0: nodeStyle = SingleQuotedStyle case parsedStyle&yaml_LITERAL_SCALAR_STYLE != 0: nodeStyle = LiteralStyle case parsedStyle&yaml_FOLDED_SCALAR_STYLE != 0: nodeStyle = FoldedStyle } var nodeValue = string(p.event.value) var nodeTag = string(p.event.tag) var defaultTag string if nodeStyle == 0 { if nodeValue == "<<" { defaultTag = mergeTag } } else { defaultTag = strTag } n := p.node(ScalarNode, defaultTag, nodeTag, nodeValue) n.Style |= nodeStyle p.anchor(n, p.event.anchor) p.expect(yaml_SCALAR_EVENT) return n } func (p *parser) sequence() *Node { n := p.node(SequenceNode, seqTag, string(p.event.tag), "") if p.event.sequence_style()&yaml_FLOW_SEQUENCE_STYLE != 0 { n.Style |= FlowStyle } p.anchor(n, p.event.anchor) p.expect(yaml_SEQUENCE_START_EVENT) for p.peek() != yaml_SEQUENCE_END_EVENT { p.parseChild(n) } n.LineComment = string(p.event.line_comment) n.FootComment = string(p.event.foot_comment) p.expect(yaml_SEQUENCE_END_EVENT) return n } func (p *parser) mapping() *Node { n := p.node(MappingNode, mapTag, string(p.event.tag), "") block := true if p.event.mapping_style()&yaml_FLOW_MAPPING_STYLE != 0 { block = false n.Style |= FlowStyle } p.anchor(n, p.event.anchor) p.expect(yaml_MAPPING_START_EVENT) for p.peek() != yaml_MAPPING_END_EVENT { k := p.parseChild(n) if block && k.FootComment != "" { // Must be a foot comment for the prior value when being dedented. if len(n.Content) > 2 { n.Content[len(n.Content)-3].FootComment = k.FootComment k.FootComment = "" } } v := p.parseChild(n) if k.FootComment == "" && v.FootComment != "" { k.FootComment = v.FootComment v.FootComment = "" } if p.peek() == yaml_TAIL_COMMENT_EVENT { if k.FootComment == "" { k.FootComment = string(p.event.foot_comment) } p.expect(yaml_TAIL_COMMENT_EVENT) } } n.LineComment = string(p.event.line_comment) n.FootComment = string(p.event.foot_comment) if n.Style&FlowStyle == 0 && n.FootComment != "" && len(n.Content) > 1 { n.Content[len(n.Content)-2].FootComment = n.FootComment n.FootComment = "" } p.expect(yaml_MAPPING_END_EVENT) return n } // ---------------------------------------------------------------------------- // Decoder, unmarshals a node into a provided value. type decoder struct { doc *Node aliases map[*Node]bool terrors []string stringMapType reflect.Type generalMapType reflect.Type knownFields bool uniqueKeys bool decodeCount int aliasCount int aliasDepth int mergedFields map[interface{}]bool } var ( nodeType = reflect.TypeOf(Node{}) durationType = reflect.TypeOf(time.Duration(0)) stringMapType = reflect.TypeOf(map[string]interface{}{}) generalMapType = reflect.TypeOf(map[interface{}]interface{}{}) ifaceType = generalMapType.Elem() timeType = reflect.TypeOf(time.Time{}) ptrTimeType = reflect.TypeOf(&time.Time{}) ) func newDecoder() *decoder { d := &decoder{ stringMapType: stringMapType, generalMapType: generalMapType, uniqueKeys: true, } d.aliases = make(map[*Node]bool) return d } func (d *decoder) terror(n *Node, tag string, out reflect.Value) { if n.Tag != "" { tag = n.Tag } value := n.Value if tag != seqTag && tag != mapTag { if len(value) > 10 { value = " `" + value[:7] + "...`" } else { value = " `" + value + "`" } } d.terrors = append(d.terrors, fmt.Sprintf("line %d: cannot unmarshal %s%s into %s", n.Line, shortTag(tag), value, out.Type())) } func (d *decoder) callUnmarshaler(n *Node, u Unmarshaler) (good bool) { err := u.UnmarshalYAML(n) if e, ok := err.(*TypeError); ok { d.terrors = append(d.terrors, e.Errors...) return false } if err != nil { fail(err) } return true } func (d *decoder) callObsoleteUnmarshaler(n *Node, u obsoleteUnmarshaler) (good bool) { terrlen := len(d.terrors) err := u.UnmarshalYAML(func(v interface{}) (err error) { defer handleErr(&err) d.unmarshal(n, reflect.ValueOf(v)) if len(d.terrors) > terrlen { issues := d.terrors[terrlen:] d.terrors = d.terrors[:terrlen] return &TypeError{issues} } return nil }) if e, ok := err.(*TypeError); ok { d.terrors = append(d.terrors, e.Errors...) return false } if err != nil { fail(err) } return true } // d.prepare initializes and dereferences pointers and calls UnmarshalYAML // if a value is found to implement it. // It returns the initialized and dereferenced out value, whether // unmarshalling was already done by UnmarshalYAML, and if so whether // its types unmarshalled appropriately. // // If n holds a null value, prepare returns before doing anything. func (d *decoder) prepare(n *Node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) { if n.ShortTag() == nullTag { return out, false, false } again := true for again { again = false if out.Kind() == reflect.Ptr { if out.IsNil() { out.Set(reflect.New(out.Type().Elem())) } out = out.Elem() again = true } if out.CanAddr() { outi := out.Addr().Interface() if u, ok := outi.(Unmarshaler); ok { good = d.callUnmarshaler(n, u) return out, true, good } if u, ok := outi.(obsoleteUnmarshaler); ok { good = d.callObsoleteUnmarshaler(n, u) return out, true, good } } } return out, false, false } func (d *decoder) fieldByIndex(n *Node, v reflect.Value, index []int) (field reflect.Value) { if n.ShortTag() == nullTag { return reflect.Value{} } for _, num := range index { for { if v.Kind() == reflect.Ptr { if v.IsNil() { v.Set(reflect.New(v.Type().Elem())) } v = v.Elem() continue } break } v = v.Field(num) } return v } const ( // 400,000 decode operations is ~500kb of dense object declarations, or // ~5kb of dense object declarations with 10000% alias expansion alias_ratio_range_low = 400000 // 4,000,000 decode operations is ~5MB of dense object declarations, or // ~4.5MB of dense object declarations with 10% alias expansion alias_ratio_range_high = 4000000 // alias_ratio_range is the range over which we scale allowed alias ratios alias_ratio_range = float64(alias_ratio_range_high - alias_ratio_range_low) ) func allowedAliasRatio(decodeCount int) float64 { switch { case decodeCount <= alias_ratio_range_low: // allow 99% to come from alias expansion for small-to-medium documents return 0.99 case decodeCount >= alias_ratio_range_high: // allow 10% to come from alias expansion for very large documents return 0.10 default: // scale smoothly from 99% down to 10% over the range. // this maps to 396,000 - 400,000 allowed alias-driven decodes over the range. // 400,000 decode operations is ~100MB of allocations in worst-case scenarios (single-item maps). return 0.99 - 0.89*(float64(decodeCount-alias_ratio_range_low)/alias_ratio_range) } } func (d *decoder) unmarshal(n *Node, out reflect.Value) (good bool) { d.decodeCount++ if d.aliasDepth > 0 { d.aliasCount++ } if d.aliasCount > 100 && d.decodeCount > 1000 && float64(d.aliasCount)/float64(d.decodeCount) > allowedAliasRatio(d.decodeCount) { failf("document contains excessive aliasing") } if out.Type() == nodeType { out.Set(reflect.ValueOf(n).Elem()) return true } switch n.Kind { case DocumentNode: return d.document(n, out) case AliasNode: return d.alias(n, out) } out, unmarshaled, good := d.prepare(n, out) if unmarshaled { return good } switch n.Kind { case ScalarNode: good = d.scalar(n, out) case MappingNode: good = d.mapping(n, out) case SequenceNode: good = d.sequence(n, out) case 0: if n.IsZero() { return d.null(out) } fallthrough default: failf("cannot decode node with unknown kind %d", n.Kind) } return good } func (d *decoder) document(n *Node, out reflect.Value) (good bool) { if len(n.Content) == 1 { d.doc = n d.unmarshal(n.Content[0], out) return true } return false } func (d *decoder) alias(n *Node, out reflect.Value) (good bool) { if d.aliases[n] { // TODO this could actually be allowed in some circumstances. failf("anchor '%s' value contains itself", n.Value) } d.aliases[n] = true d.aliasDepth++ good = d.unmarshal(n.Alias, out) d.aliasDepth-- delete(d.aliases, n) return good } var zeroValue reflect.Value func resetMap(out reflect.Value) { for _, k := range out.MapKeys() { out.SetMapIndex(k, zeroValue) } } func (d *decoder) null(out reflect.Value) bool { if out.CanAddr() { switch out.Kind() { case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice: out.Set(reflect.Zero(out.Type())) return true } } return false } func (d *decoder) scalar(n *Node, out reflect.Value) bool { var tag string var resolved interface{} if n.indicatedString() { tag = strTag resolved = n.Value } else { tag, resolved = resolve(n.Tag, n.Value) if tag == binaryTag { data, err := base64.StdEncoding.DecodeString(resolved.(string)) if err != nil { failf("!!binary value contains invalid base64 data") } resolved = string(data) } } if resolved == nil { return d.null(out) } if resolvedv := reflect.ValueOf(resolved); out.Type() == resolvedv.Type() { // We've resolved to exactly the type we want, so use that. out.Set(resolvedv) return true } // Perhaps we can use the value as a TextUnmarshaler to // set its value. if out.CanAddr() { u, ok := out.Addr().Interface().(encoding.TextUnmarshaler) if ok { var text []byte if tag == binaryTag { text = []byte(resolved.(string)) } else { // We let any value be unmarshaled into TextUnmarshaler. // That might be more lax than we'd like, but the // TextUnmarshaler itself should bowl out any dubious values. text = []byte(n.Value) } err := u.UnmarshalText(text) if err != nil { fail(err) } return true } } switch out.Kind() { case reflect.String: if tag == binaryTag { out.SetString(resolved.(string)) return true } out.SetString(n.Value) return true case reflect.Interface: out.Set(reflect.ValueOf(resolved)) return true case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: // This used to work in v2, but it's very unfriendly. isDuration := out.Type() == durationType switch resolved := resolved.(type) { case int: if !isDuration && !out.OverflowInt(int64(resolved)) { out.SetInt(int64(resolved)) return true } case int64: if !isDuration && !out.OverflowInt(resolved) { out.SetInt(resolved) return true } case uint64: if !isDuration && resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) { out.SetInt(int64(resolved)) return true } case float64: if !isDuration && resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) { out.SetInt(int64(resolved)) return true } case string: if out.Type() == durationType { d, err := time.ParseDuration(resolved) if err == nil { out.SetInt(int64(d)) return true } } } case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: switch resolved := resolved.(type) { case int: if resolved >= 0 && !out.OverflowUint(uint64(resolved)) { out.SetUint(uint64(resolved)) return true } case int64: if resolved >= 0 && !out.OverflowUint(uint64(resolved)) { out.SetUint(uint64(resolved)) return true } case uint64: if !out.OverflowUint(uint64(resolved)) { out.SetUint(uint64(resolved)) return true } case float64: if resolved <= math.MaxUint64 && !out.OverflowUint(uint64(resolved)) { out.SetUint(uint64(resolved)) return true } } case reflect.Bool: switch resolved := resolved.(type) { case bool: out.SetBool(resolved) return true case string: // This offers some compatibility with the 1.1 spec (https://yaml.org/type/bool.html). // It only works if explicitly attempting to unmarshal into a typed bool value. switch resolved { case "y", "Y", "yes", "Yes", "YES", "on", "On", "ON": out.SetBool(true) return true case "n", "N", "no", "No", "NO", "off", "Off", "OFF": out.SetBool(false) return true } } case reflect.Float32, reflect.Float64: switch resolved := resolved.(type) { case int: out.SetFloat(float64(resolved)) return true case int64: out.SetFloat(float64(resolved)) return true case uint64: out.SetFloat(float64(resolved)) return true case float64: out.SetFloat(resolved) return true } case reflect.Struct: if resolvedv := reflect.ValueOf(resolved); out.Type() == resolvedv.Type() { out.Set(resolvedv) return true } case reflect.Ptr: panic("yaml internal error: please report the issue") } d.terror(n, tag, out) return false } func settableValueOf(i interface{}) reflect.Value { v := reflect.ValueOf(i) sv := reflect.New(v.Type()).Elem() sv.Set(v) return sv } func (d *decoder) sequence(n *Node, out reflect.Value) (good bool) { l := len(n.Content) var iface reflect.Value switch out.Kind() { case reflect.Slice: out.Set(reflect.MakeSlice(out.Type(), l, l)) case reflect.Array: if l != out.Len() { failf("invalid array: want %d elements but got %d", out.Len(), l) } case reflect.Interface: // No type hints. Will have to use a generic sequence. iface = out out = settableValueOf(make([]interface{}, l)) default: d.terror(n, seqTag, out) return false } et := out.Type().Elem() j := 0 for i := 0; i < l; i++ { e := reflect.New(et).Elem() if ok := d.unmarshal(n.Content[i], e); ok { out.Index(j).Set(e) j++ } } if out.Kind() != reflect.Array { out.Set(out.Slice(0, j)) } if iface.IsValid() { iface.Set(out) } return true } func (d *decoder) mapping(n *Node, out reflect.Value) (good bool) { l := len(n.Content) if d.uniqueKeys { nerrs := len(d.terrors) for i := 0; i < l; i += 2 { ni := n.Content[i] for j := i + 2; j < l; j += 2 { nj := n.Content[j] if ni.Kind == nj.Kind && ni.Value == nj.Value { d.terrors = append(d.terrors, fmt.Sprintf("line %d: mapping key %#v already defined at line %d", nj.Line, nj.Value, ni.Line)) } } } if len(d.terrors) > nerrs { return false } } switch out.Kind() { case reflect.Struct: return d.mappingStruct(n, out) case reflect.Map: // okay case reflect.Interface: iface := out if isStringMap(n) { out = reflect.MakeMap(d.stringMapType) } else { out = reflect.MakeMap(d.generalMapType) } iface.Set(out) default: d.terror(n, mapTag, out) return false } outt := out.Type() kt := outt.Key() et := outt.Elem() stringMapType := d.stringMapType generalMapType := d.generalMapType if outt.Elem() == ifaceType { if outt.Key().Kind() == reflect.String { d.stringMapType = outt } else if outt.Key() == ifaceType { d.generalMapType = outt } } mergedFields := d.mergedFields d.mergedFields = nil var mergeNode *Node mapIsNew := false if out.IsNil() { out.Set(reflect.MakeMap(outt)) mapIsNew = true } for i := 0; i < l; i += 2 { if isMerge(n.Content[i]) { mergeNode = n.Content[i+1] continue } k := reflect.New(kt).Elem() if d.unmarshal(n.Content[i], k) { if mergedFields != nil { ki := k.Interface() if mergedFields[ki] { continue } mergedFields[ki] = true } kkind := k.Kind() if kkind == reflect.Interface { kkind = k.Elem().Kind() } if kkind == reflect.Map || kkind == reflect.Slice { failf("invalid map key: %#v", k.Interface()) } e := reflect.New(et).Elem() if d.unmarshal(n.Content[i+1], e) || n.Content[i+1].ShortTag() == nullTag && (mapIsNew || !out.MapIndex(k).IsValid()) { out.SetMapIndex(k, e) } } } d.mergedFields = mergedFields if mergeNode != nil { d.merge(n, mergeNode, out) } d.stringMapType = stringMapType d.generalMapType = generalMapType return true } func isStringMap(n *Node) bool { if n.Kind != MappingNode { return false } l := len(n.Content) for i := 0; i < l; i += 2 { shortTag := n.Content[i].ShortTag() if shortTag != strTag && shortTag != mergeTag { return false } } return true } func (d *decoder) mappingStruct(n *Node, out reflect.Value) (good bool) { sinfo, err := getStructInfo(out.Type()) if err != nil { panic(err) } var inlineMap reflect.Value var elemType reflect.Type if sinfo.InlineMap != -1 { inlineMap = out.Field(sinfo.InlineMap) elemType = inlineMap.Type().Elem() } for _, index := range sinfo.InlineUnmarshalers { field := d.fieldByIndex(n, out, index) d.prepare(n, field) } mergedFields := d.mergedFields d.mergedFields = nil var mergeNode *Node var doneFields []bool if d.uniqueKeys { doneFields = make([]bool, len(sinfo.FieldsList)) } name := settableValueOf("") l := len(n.Content) for i := 0; i < l; i += 2 { ni := n.Content[i] if isMerge(ni) { mergeNode = n.Content[i+1] continue } if !d.unmarshal(ni, name) { continue } sname := name.String() if mergedFields != nil { if mergedFields[sname] { continue } mergedFields[sname] = true } if info, ok := sinfo.FieldsMap[sname]; ok { if d.uniqueKeys { if doneFields[info.Id] { d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s already set in type %s", ni.Line, name.String(), out.Type())) continue } doneFields[info.Id] = true } var field reflect.Value if info.Inline == nil { field = out.Field(info.Num) } else { field = d.fieldByIndex(n, out, info.Inline) } d.unmarshal(n.Content[i+1], field) } else if sinfo.InlineMap != -1 { if inlineMap.IsNil() { inlineMap.Set(reflect.MakeMap(inlineMap.Type())) } value := reflect.New(elemType).Elem() d.unmarshal(n.Content[i+1], value) inlineMap.SetMapIndex(name, value) } else if d.knownFields { d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s not found in type %s", ni.Line, name.String(), out.Type())) } } d.mergedFields = mergedFields if mergeNode != nil { d.merge(n, mergeNode, out) } return true } func failWantMap() { failf("map merge requires map or sequence of maps as the value") } func (d *decoder) merge(parent *Node, merge *Node, out reflect.Value) { mergedFields := d.mergedFields if mergedFields == nil { d.mergedFields = make(map[interface{}]bool) for i := 0; i < len(parent.Content); i += 2 { k := reflect.New(ifaceType).Elem() if d.unmarshal(parent.Content[i], k) { d.mergedFields[k.Interface()] = true } } } switch merge.Kind { case MappingNode: d.unmarshal(merge, out) case AliasNode: if merge.Alias != nil && merge.Alias.Kind != MappingNode { failWantMap() } d.unmarshal(merge, out) case SequenceNode: for i := 0; i < len(merge.Content); i++ { ni := merge.Content[i] if ni.Kind == AliasNode { if ni.Alias != nil && ni.Alias.Kind != MappingNode { failWantMap() } } else if ni.Kind != MappingNode { failWantMap() } d.unmarshal(ni, out) } default: failWantMap() } d.mergedFields = mergedFields } func isMerge(n *Node) bool { return n.Kind == ScalarNode && n.Value == "<<" && (n.Tag == "" || n.Tag == "!" || shortTag(n.Tag) == mergeTag) }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/yaml.v3/parserc.go
vendor/gopkg.in/yaml.v3/parserc.go
// // Copyright (c) 2011-2019 Canonical Ltd // Copyright (c) 2006-2010 Kirill Simonov // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies // of the Software, and to permit persons to whom the Software is furnished to do // so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. package yaml import ( "bytes" ) // The parser implements the following grammar: // // stream ::= STREAM-START implicit_document? explicit_document* STREAM-END // implicit_document ::= block_node DOCUMENT-END* // explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* // block_node_or_indentless_sequence ::= // ALIAS // | properties (block_content | indentless_block_sequence)? // | block_content // | indentless_block_sequence // block_node ::= ALIAS // | properties block_content? // | block_content // flow_node ::= ALIAS // | properties flow_content? // | flow_content // properties ::= TAG ANCHOR? | ANCHOR TAG? // block_content ::= block_collection | flow_collection | SCALAR // flow_content ::= flow_collection | SCALAR // block_collection ::= block_sequence | block_mapping // flow_collection ::= flow_sequence | flow_mapping // block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END // indentless_sequence ::= (BLOCK-ENTRY block_node?)+ // block_mapping ::= BLOCK-MAPPING_START // ((KEY block_node_or_indentless_sequence?)? // (VALUE block_node_or_indentless_sequence?)?)* // BLOCK-END // flow_sequence ::= FLOW-SEQUENCE-START // (flow_sequence_entry FLOW-ENTRY)* // flow_sequence_entry? // FLOW-SEQUENCE-END // flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // flow_mapping ::= FLOW-MAPPING-START // (flow_mapping_entry FLOW-ENTRY)* // flow_mapping_entry? // FLOW-MAPPING-END // flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // Peek the next token in the token queue. func peek_token(parser *yaml_parser_t) *yaml_token_t { if parser.token_available || yaml_parser_fetch_more_tokens(parser) { token := &parser.tokens[parser.tokens_head] yaml_parser_unfold_comments(parser, token) return token } return nil } // yaml_parser_unfold_comments walks through the comments queue and joins all // comments behind the position of the provided token into the respective // top-level comment slices in the parser. func yaml_parser_unfold_comments(parser *yaml_parser_t, token *yaml_token_t) { for parser.comments_head < len(parser.comments) && token.start_mark.index >= parser.comments[parser.comments_head].token_mark.index { comment := &parser.comments[parser.comments_head] if len(comment.head) > 0 { if token.typ == yaml_BLOCK_END_TOKEN { // No heads on ends, so keep comment.head for a follow up token. break } if len(parser.head_comment) > 0 { parser.head_comment = append(parser.head_comment, '\n') } parser.head_comment = append(parser.head_comment, comment.head...) } if len(comment.foot) > 0 { if len(parser.foot_comment) > 0 { parser.foot_comment = append(parser.foot_comment, '\n') } parser.foot_comment = append(parser.foot_comment, comment.foot...) } if len(comment.line) > 0 { if len(parser.line_comment) > 0 { parser.line_comment = append(parser.line_comment, '\n') } parser.line_comment = append(parser.line_comment, comment.line...) } *comment = yaml_comment_t{} parser.comments_head++ } } // Remove the next token from the queue (must be called after peek_token). func skip_token(parser *yaml_parser_t) { parser.token_available = false parser.tokens_parsed++ parser.stream_end_produced = parser.tokens[parser.tokens_head].typ == yaml_STREAM_END_TOKEN parser.tokens_head++ } // Get the next event. func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool { // Erase the event object. *event = yaml_event_t{} // No events after the end of the stream or error. if parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE { return true } // Generate the next event. return yaml_parser_state_machine(parser, event) } // Set parser error. func yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool { parser.error = yaml_PARSER_ERROR parser.problem = problem parser.problem_mark = problem_mark return false } func yaml_parser_set_parser_error_context(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string, problem_mark yaml_mark_t) bool { parser.error = yaml_PARSER_ERROR parser.context = context parser.context_mark = context_mark parser.problem = problem parser.problem_mark = problem_mark return false } // State dispatcher. func yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool { //trace("yaml_parser_state_machine", "state:", parser.state.String()) switch parser.state { case yaml_PARSE_STREAM_START_STATE: return yaml_parser_parse_stream_start(parser, event) case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: return yaml_parser_parse_document_start(parser, event, true) case yaml_PARSE_DOCUMENT_START_STATE: return yaml_parser_parse_document_start(parser, event, false) case yaml_PARSE_DOCUMENT_CONTENT_STATE: return yaml_parser_parse_document_content(parser, event) case yaml_PARSE_DOCUMENT_END_STATE: return yaml_parser_parse_document_end(parser, event) case yaml_PARSE_BLOCK_NODE_STATE: return yaml_parser_parse_node(parser, event, true, false) case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: return yaml_parser_parse_node(parser, event, true, true) case yaml_PARSE_FLOW_NODE_STATE: return yaml_parser_parse_node(parser, event, false, false) case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: return yaml_parser_parse_block_sequence_entry(parser, event, true) case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: return yaml_parser_parse_block_sequence_entry(parser, event, false) case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: return yaml_parser_parse_indentless_sequence_entry(parser, event) case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: return yaml_parser_parse_block_mapping_key(parser, event, true) case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: return yaml_parser_parse_block_mapping_key(parser, event, false) case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: return yaml_parser_parse_block_mapping_value(parser, event) case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: return yaml_parser_parse_flow_sequence_entry(parser, event, true) case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: return yaml_parser_parse_flow_sequence_entry(parser, event, false) case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event) case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event) case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event) case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: return yaml_parser_parse_flow_mapping_key(parser, event, true) case yaml_PARSE_FLOW_MAPPING_KEY_STATE: return yaml_parser_parse_flow_mapping_key(parser, event, false) case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: return yaml_parser_parse_flow_mapping_value(parser, event, false) case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: return yaml_parser_parse_flow_mapping_value(parser, event, true) default: panic("invalid parser state") } } // Parse the production: // stream ::= STREAM-START implicit_document? explicit_document* STREAM-END // ************ func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ != yaml_STREAM_START_TOKEN { return yaml_parser_set_parser_error(parser, "did not find expected <stream-start>", token.start_mark) } parser.state = yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE *event = yaml_event_t{ typ: yaml_STREAM_START_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, encoding: token.encoding, } skip_token(parser) return true } // Parse the productions: // implicit_document ::= block_node DOCUMENT-END* // * // explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* // ************************* func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t, implicit bool) bool { token := peek_token(parser) if token == nil { return false } // Parse extra document end indicators. if !implicit { for token.typ == yaml_DOCUMENT_END_TOKEN { skip_token(parser) token = peek_token(parser) if token == nil { return false } } } if implicit && token.typ != yaml_VERSION_DIRECTIVE_TOKEN && token.typ != yaml_TAG_DIRECTIVE_TOKEN && token.typ != yaml_DOCUMENT_START_TOKEN && token.typ != yaml_STREAM_END_TOKEN { // Parse an implicit document. if !yaml_parser_process_directives(parser, nil, nil) { return false } parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) parser.state = yaml_PARSE_BLOCK_NODE_STATE var head_comment []byte if len(parser.head_comment) > 0 { // [Go] Scan the header comment backwards, and if an empty line is found, break // the header so the part before the last empty line goes into the // document header, while the bottom of it goes into a follow up event. for i := len(parser.head_comment) - 1; i > 0; i-- { if parser.head_comment[i] == '\n' { if i == len(parser.head_comment)-1 { head_comment = parser.head_comment[:i] parser.head_comment = parser.head_comment[i+1:] break } else if parser.head_comment[i-1] == '\n' { head_comment = parser.head_comment[:i-1] parser.head_comment = parser.head_comment[i+1:] break } } } } *event = yaml_event_t{ typ: yaml_DOCUMENT_START_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, head_comment: head_comment, } } else if token.typ != yaml_STREAM_END_TOKEN { // Parse an explicit document. var version_directive *yaml_version_directive_t var tag_directives []yaml_tag_directive_t start_mark := token.start_mark if !yaml_parser_process_directives(parser, &version_directive, &tag_directives) { return false } token = peek_token(parser) if token == nil { return false } if token.typ != yaml_DOCUMENT_START_TOKEN { yaml_parser_set_parser_error(parser, "did not find expected <document start>", token.start_mark) return false } parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) parser.state = yaml_PARSE_DOCUMENT_CONTENT_STATE end_mark := token.end_mark *event = yaml_event_t{ typ: yaml_DOCUMENT_START_EVENT, start_mark: start_mark, end_mark: end_mark, version_directive: version_directive, tag_directives: tag_directives, implicit: false, } skip_token(parser) } else { // Parse the stream end. parser.state = yaml_PARSE_END_STATE *event = yaml_event_t{ typ: yaml_STREAM_END_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, } skip_token(parser) } return true } // Parse the productions: // explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* // *********** // func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN || token.typ == yaml_DOCUMENT_START_TOKEN || token.typ == yaml_DOCUMENT_END_TOKEN || token.typ == yaml_STREAM_END_TOKEN { parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] return yaml_parser_process_empty_scalar(parser, event, token.start_mark) } return yaml_parser_parse_node(parser, event, true, false) } // Parse the productions: // implicit_document ::= block_node DOCUMENT-END* // ************* // explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* // func yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } start_mark := token.start_mark end_mark := token.start_mark implicit := true if token.typ == yaml_DOCUMENT_END_TOKEN { end_mark = token.end_mark skip_token(parser) implicit = false } parser.tag_directives = parser.tag_directives[:0] parser.state = yaml_PARSE_DOCUMENT_START_STATE *event = yaml_event_t{ typ: yaml_DOCUMENT_END_EVENT, start_mark: start_mark, end_mark: end_mark, implicit: implicit, } yaml_parser_set_event_comments(parser, event) if len(event.head_comment) > 0 && len(event.foot_comment) == 0 { event.foot_comment = event.head_comment event.head_comment = nil } return true } func yaml_parser_set_event_comments(parser *yaml_parser_t, event *yaml_event_t) { event.head_comment = parser.head_comment event.line_comment = parser.line_comment event.foot_comment = parser.foot_comment parser.head_comment = nil parser.line_comment = nil parser.foot_comment = nil parser.tail_comment = nil parser.stem_comment = nil } // Parse the productions: // block_node_or_indentless_sequence ::= // ALIAS // ***** // | properties (block_content | indentless_block_sequence)? // ********** * // | block_content | indentless_block_sequence // * // block_node ::= ALIAS // ***** // | properties block_content? // ********** * // | block_content // * // flow_node ::= ALIAS // ***** // | properties flow_content? // ********** * // | flow_content // * // properties ::= TAG ANCHOR? | ANCHOR TAG? // ************************* // block_content ::= block_collection | flow_collection | SCALAR // ****** // flow_content ::= flow_collection | SCALAR // ****** func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, indentless_sequence bool) bool { //defer trace("yaml_parser_parse_node", "block:", block, "indentless_sequence:", indentless_sequence)() token := peek_token(parser) if token == nil { return false } if token.typ == yaml_ALIAS_TOKEN { parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] *event = yaml_event_t{ typ: yaml_ALIAS_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, anchor: token.value, } yaml_parser_set_event_comments(parser, event) skip_token(parser) return true } start_mark := token.start_mark end_mark := token.start_mark var tag_token bool var tag_handle, tag_suffix, anchor []byte var tag_mark yaml_mark_t if token.typ == yaml_ANCHOR_TOKEN { anchor = token.value start_mark = token.start_mark end_mark = token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ == yaml_TAG_TOKEN { tag_token = true tag_handle = token.value tag_suffix = token.suffix tag_mark = token.start_mark end_mark = token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } } } else if token.typ == yaml_TAG_TOKEN { tag_token = true tag_handle = token.value tag_suffix = token.suffix start_mark = token.start_mark tag_mark = token.start_mark end_mark = token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ == yaml_ANCHOR_TOKEN { anchor = token.value end_mark = token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } } } var tag []byte if tag_token { if len(tag_handle) == 0 { tag = tag_suffix tag_suffix = nil } else { for i := range parser.tag_directives { if bytes.Equal(parser.tag_directives[i].handle, tag_handle) { tag = append([]byte(nil), parser.tag_directives[i].prefix...) tag = append(tag, tag_suffix...) break } } if len(tag) == 0 { yaml_parser_set_parser_error_context(parser, "while parsing a node", start_mark, "found undefined tag handle", tag_mark) return false } } } implicit := len(tag) == 0 if indentless_sequence && token.typ == yaml_BLOCK_ENTRY_TOKEN { end_mark = token.end_mark parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE *event = yaml_event_t{ typ: yaml_SEQUENCE_START_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), } return true } if token.typ == yaml_SCALAR_TOKEN { var plain_implicit, quoted_implicit bool end_mark = token.end_mark if (len(tag) == 0 && token.style == yaml_PLAIN_SCALAR_STYLE) || (len(tag) == 1 && tag[0] == '!') { plain_implicit = true } else if len(tag) == 0 { quoted_implicit = true } parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] *event = yaml_event_t{ typ: yaml_SCALAR_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, value: token.value, implicit: plain_implicit, quoted_implicit: quoted_implicit, style: yaml_style_t(token.style), } yaml_parser_set_event_comments(parser, event) skip_token(parser) return true } if token.typ == yaml_FLOW_SEQUENCE_START_TOKEN { // [Go] Some of the events below can be merged as they differ only on style. end_mark = token.end_mark parser.state = yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE *event = yaml_event_t{ typ: yaml_SEQUENCE_START_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(yaml_FLOW_SEQUENCE_STYLE), } yaml_parser_set_event_comments(parser, event) return true } if token.typ == yaml_FLOW_MAPPING_START_TOKEN { end_mark = token.end_mark parser.state = yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE *event = yaml_event_t{ typ: yaml_MAPPING_START_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), } yaml_parser_set_event_comments(parser, event) return true } if block && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN { end_mark = token.end_mark parser.state = yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE *event = yaml_event_t{ typ: yaml_SEQUENCE_START_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), } if parser.stem_comment != nil { event.head_comment = parser.stem_comment parser.stem_comment = nil } return true } if block && token.typ == yaml_BLOCK_MAPPING_START_TOKEN { end_mark = token.end_mark parser.state = yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE *event = yaml_event_t{ typ: yaml_MAPPING_START_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(yaml_BLOCK_MAPPING_STYLE), } if parser.stem_comment != nil { event.head_comment = parser.stem_comment parser.stem_comment = nil } return true } if len(anchor) > 0 || len(tag) > 0 { parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] *event = yaml_event_t{ typ: yaml_SCALAR_EVENT, start_mark: start_mark, end_mark: end_mark, anchor: anchor, tag: tag, implicit: implicit, quoted_implicit: false, style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), } return true } context := "while parsing a flow node" if block { context = "while parsing a block node" } yaml_parser_set_parser_error_context(parser, context, start_mark, "did not find expected node content", token.start_mark) return false } // Parse the productions: // block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END // ******************** *********** * ********* // func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) if token == nil { return false } parser.marks = append(parser.marks, token.start_mark) skip_token(parser) } token := peek_token(parser) if token == nil { return false } if token.typ == yaml_BLOCK_ENTRY_TOKEN { mark := token.end_mark prior_head_len := len(parser.head_comment) skip_token(parser) yaml_parser_split_stem_comment(parser, prior_head_len) token = peek_token(parser) if token == nil { return false } if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE) return yaml_parser_parse_node(parser, event, true, false) } else { parser.state = yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE return yaml_parser_process_empty_scalar(parser, event, mark) } } if token.typ == yaml_BLOCK_END_TOKEN { parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] parser.marks = parser.marks[:len(parser.marks)-1] *event = yaml_event_t{ typ: yaml_SEQUENCE_END_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, } skip_token(parser) return true } context_mark := parser.marks[len(parser.marks)-1] parser.marks = parser.marks[:len(parser.marks)-1] return yaml_parser_set_parser_error_context(parser, "while parsing a block collection", context_mark, "did not find expected '-' indicator", token.start_mark) } // Parse the productions: // indentless_sequence ::= (BLOCK-ENTRY block_node?)+ // *********** * func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ == yaml_BLOCK_ENTRY_TOKEN { mark := token.end_mark prior_head_len := len(parser.head_comment) skip_token(parser) yaml_parser_split_stem_comment(parser, prior_head_len) token = peek_token(parser) if token == nil { return false } if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_KEY_TOKEN && token.typ != yaml_VALUE_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE) return yaml_parser_parse_node(parser, event, true, false) } parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE return yaml_parser_process_empty_scalar(parser, event, mark) } parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] *event = yaml_event_t{ typ: yaml_SEQUENCE_END_EVENT, start_mark: token.start_mark, end_mark: token.start_mark, // [Go] Shouldn't this be token.end_mark? } return true } // Split stem comment from head comment. // // When a sequence or map is found under a sequence entry, the former head comment // is assigned to the underlying sequence or map as a whole, not the individual // sequence or map entry as would be expected otherwise. To handle this case the // previous head comment is moved aside as the stem comment. func yaml_parser_split_stem_comment(parser *yaml_parser_t, stem_len int) { if stem_len == 0 { return } token := peek_token(parser) if token == nil || token.typ != yaml_BLOCK_SEQUENCE_START_TOKEN && token.typ != yaml_BLOCK_MAPPING_START_TOKEN { return } parser.stem_comment = parser.head_comment[:stem_len] if len(parser.head_comment) == stem_len { parser.head_comment = nil } else { // Copy suffix to prevent very strange bugs if someone ever appends // further bytes to the prefix in the stem_comment slice above. parser.head_comment = append([]byte(nil), parser.head_comment[stem_len+1:]...) } } // Parse the productions: // block_mapping ::= BLOCK-MAPPING_START // ******************* // ((KEY block_node_or_indentless_sequence?)? // *** * // (VALUE block_node_or_indentless_sequence?)?)* // // BLOCK-END // ********* // func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) if token == nil { return false } parser.marks = append(parser.marks, token.start_mark) skip_token(parser) } token := peek_token(parser) if token == nil { return false } // [Go] A tail comment was left from the prior mapping value processed. Emit an event // as it needs to be processed with that value and not the following key. if len(parser.tail_comment) > 0 { *event = yaml_event_t{ typ: yaml_TAIL_COMMENT_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, foot_comment: parser.tail_comment, } parser.tail_comment = nil return true } if token.typ == yaml_KEY_TOKEN { mark := token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ != yaml_KEY_TOKEN && token.typ != yaml_VALUE_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_VALUE_STATE) return yaml_parser_parse_node(parser, event, true, true) } else { parser.state = yaml_PARSE_BLOCK_MAPPING_VALUE_STATE return yaml_parser_process_empty_scalar(parser, event, mark) } } else if token.typ == yaml_BLOCK_END_TOKEN { parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] parser.marks = parser.marks[:len(parser.marks)-1] *event = yaml_event_t{ typ: yaml_MAPPING_END_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, } yaml_parser_set_event_comments(parser, event) skip_token(parser) return true } context_mark := parser.marks[len(parser.marks)-1] parser.marks = parser.marks[:len(parser.marks)-1] return yaml_parser_set_parser_error_context(parser, "while parsing a block mapping", context_mark, "did not find expected key", token.start_mark) } // Parse the productions: // block_mapping ::= BLOCK-MAPPING_START // // ((KEY block_node_or_indentless_sequence?)? // // (VALUE block_node_or_indentless_sequence?)?)* // ***** * // BLOCK-END // // func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ == yaml_VALUE_TOKEN { mark := token.end_mark skip_token(parser) token = peek_token(parser) if token == nil { return false } if token.typ != yaml_KEY_TOKEN && token.typ != yaml_VALUE_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_KEY_STATE) return yaml_parser_parse_node(parser, event, true, true) } parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE return yaml_parser_process_empty_scalar(parser, event, mark) } parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE return yaml_parser_process_empty_scalar(parser, event, token.start_mark) } // Parse the productions: // flow_sequence ::= FLOW-SEQUENCE-START // ******************* // (flow_sequence_entry FLOW-ENTRY)* // * ********** // flow_sequence_entry? // * // FLOW-SEQUENCE-END // ***************** // flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // * // func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { if first { token := peek_token(parser) if token == nil { return false } parser.marks = append(parser.marks, token.start_mark) skip_token(parser) } token := peek_token(parser) if token == nil { return false } if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { if !first { if token.typ == yaml_FLOW_ENTRY_TOKEN { skip_token(parser) token = peek_token(parser) if token == nil { return false } } else { context_mark := parser.marks[len(parser.marks)-1] parser.marks = parser.marks[:len(parser.marks)-1] return yaml_parser_set_parser_error_context(parser, "while parsing a flow sequence", context_mark, "did not find expected ',' or ']'", token.start_mark) } } if token.typ == yaml_KEY_TOKEN { parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE *event = yaml_event_t{ typ: yaml_MAPPING_START_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, implicit: true, style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), } skip_token(parser) return true } else if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE) return yaml_parser_parse_node(parser, event, false, false) } } parser.state = parser.states[len(parser.states)-1] parser.states = parser.states[:len(parser.states)-1] parser.marks = parser.marks[:len(parser.marks)-1] *event = yaml_event_t{ typ: yaml_SEQUENCE_END_EVENT, start_mark: token.start_mark, end_mark: token.end_mark, } yaml_parser_set_event_comments(parser, event) skip_token(parser) return true } // // Parse the productions: // flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? // *** * // func yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, event *yaml_event_t) bool { token := peek_token(parser) if token == nil { return false } if token.typ != yaml_VALUE_TOKEN && token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE)
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
true
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/tomb.v1/tomb.go
vendor/gopkg.in/tomb.v1/tomb.go
// Copyright (c) 2011 - Gustavo Niemeyer <gustavo@niemeyer.net> // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // The tomb package offers a conventional API for clean goroutine termination. // // A Tomb tracks the lifecycle of a goroutine as alive, dying or dead, // and the reason for its death. // // The zero value of a Tomb assumes that a goroutine is about to be // created or already alive. Once Kill or Killf is called with an // argument that informs the reason for death, the goroutine is in // a dying state and is expected to terminate soon. Right before the // goroutine function or method returns, Done must be called to inform // that the goroutine is indeed dead and about to stop running. // // A Tomb exposes Dying and Dead channels. These channels are closed // when the Tomb state changes in the respective way. They enable // explicit blocking until the state changes, and also to selectively // unblock select statements accordingly. // // When the tomb state changes to dying and there's still logic going // on within the goroutine, nested functions and methods may choose to // return ErrDying as their error value, as this error won't alter the // tomb state if provided to the Kill method. This is a convenient way to // follow standard Go practices in the context of a dying tomb. // // For background and a detailed example, see the following blog post: // // http://blog.labix.org/2011/10/09/death-of-goroutines-under-control // // For a more complex code snippet demonstrating the use of multiple // goroutines with a single Tomb, see: // // http://play.golang.org/p/Xh7qWsDPZP // package tomb import ( "errors" "fmt" "sync" ) // A Tomb tracks the lifecycle of a goroutine as alive, dying or dead, // and the reason for its death. // // See the package documentation for details. type Tomb struct { m sync.Mutex dying chan struct{} dead chan struct{} reason error } var ( ErrStillAlive = errors.New("tomb: still alive") ErrDying = errors.New("tomb: dying") ) func (t *Tomb) init() { t.m.Lock() if t.dead == nil { t.dead = make(chan struct{}) t.dying = make(chan struct{}) t.reason = ErrStillAlive } t.m.Unlock() } // Dead returns the channel that can be used to wait // until t.Done has been called. func (t *Tomb) Dead() <-chan struct{} { t.init() return t.dead } // Dying returns the channel that can be used to wait // until t.Kill or t.Done has been called. func (t *Tomb) Dying() <-chan struct{} { t.init() return t.dying } // Wait blocks until the goroutine is in a dead state and returns the // reason for its death. func (t *Tomb) Wait() error { t.init() <-t.dead t.m.Lock() reason := t.reason t.m.Unlock() return reason } // Done flags the goroutine as dead, and should be called a single time // right before the goroutine function or method returns. // If the goroutine was not already in a dying state before Done is // called, it will be flagged as dying and dead at once with no // error. func (t *Tomb) Done() { t.Kill(nil) close(t.dead) } // Kill flags the goroutine as dying for the given reason. // Kill may be called multiple times, but only the first // non-nil error is recorded as the reason for termination. // // If reason is ErrDying, the previous reason isn't replaced // even if it is nil. It's a runtime error to call Kill with // ErrDying if t is not in a dying state. func (t *Tomb) Kill(reason error) { t.init() t.m.Lock() defer t.m.Unlock() if reason == ErrDying { if t.reason == ErrStillAlive { panic("tomb: Kill with ErrDying while still alive") } return } if t.reason == nil || t.reason == ErrStillAlive { t.reason = reason } // If the receive on t.dying succeeds, then // it can only be because we have already closed it. // If it blocks, then we know that it needs to be closed. select { case <-t.dying: default: close(t.dying) } } // Killf works like Kill, but builds the reason providing the received // arguments to fmt.Errorf. The generated error is also returned. func (t *Tomb) Killf(f string, a ...interface{}) error { err := fmt.Errorf(f, a...) t.Kill(err) return err } // Err returns the reason for the goroutine death provided via Kill // or Killf, or ErrStillAlive when the goroutine is still alive. func (t *Tomb) Err() (reason error) { t.init() t.m.Lock() reason = t.reason t.m.Unlock() return }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/evanphx/json-patch.v4/merge.go
vendor/gopkg.in/evanphx/json-patch.v4/merge.go
package jsonpatch import ( "bytes" "encoding/json" "fmt" "reflect" ) func merge(cur, patch *lazyNode, mergeMerge bool) *lazyNode { curDoc, err := cur.intoDoc() if err != nil { pruneNulls(patch) return patch } patchDoc, err := patch.intoDoc() if err != nil { return patch } mergeDocs(curDoc, patchDoc, mergeMerge) return cur } func mergeDocs(doc, patch *partialDoc, mergeMerge bool) { for k, v := range *patch { if v == nil { if mergeMerge { (*doc)[k] = nil } else { delete(*doc, k) } } else { cur, ok := (*doc)[k] if !ok || cur == nil { if !mergeMerge { pruneNulls(v) } (*doc)[k] = v } else { (*doc)[k] = merge(cur, v, mergeMerge) } } } } func pruneNulls(n *lazyNode) { sub, err := n.intoDoc() if err == nil { pruneDocNulls(sub) } else { ary, err := n.intoAry() if err == nil { pruneAryNulls(ary) } } } func pruneDocNulls(doc *partialDoc) *partialDoc { for k, v := range *doc { if v == nil { delete(*doc, k) } else { pruneNulls(v) } } return doc } func pruneAryNulls(ary *partialArray) *partialArray { newAry := []*lazyNode{} for _, v := range *ary { if v != nil { pruneNulls(v) } newAry = append(newAry, v) } *ary = newAry return ary } var ErrBadJSONDoc = fmt.Errorf("Invalid JSON Document") var ErrBadJSONPatch = fmt.Errorf("Invalid JSON Patch") var errBadMergeTypes = fmt.Errorf("Mismatched JSON Documents") // MergeMergePatches merges two merge patches together, such that // applying this resulting merged merge patch to a document yields the same // as merging each merge patch to the document in succession. func MergeMergePatches(patch1Data, patch2Data []byte) ([]byte, error) { return doMergePatch(patch1Data, patch2Data, true) } // MergePatch merges the patchData into the docData. func MergePatch(docData, patchData []byte) ([]byte, error) { return doMergePatch(docData, patchData, false) } func doMergePatch(docData, patchData []byte, mergeMerge bool) ([]byte, error) { doc := &partialDoc{} docErr := json.Unmarshal(docData, doc) patch := &partialDoc{} patchErr := json.Unmarshal(patchData, patch) if _, ok := docErr.(*json.SyntaxError); ok { return nil, ErrBadJSONDoc } if _, ok := patchErr.(*json.SyntaxError); ok { return nil, ErrBadJSONPatch } if docErr == nil && *doc == nil { return nil, ErrBadJSONDoc } if patchErr == nil && *patch == nil { return nil, ErrBadJSONPatch } if docErr != nil || patchErr != nil { // Not an error, just not a doc, so we turn straight into the patch if patchErr == nil { if mergeMerge { doc = patch } else { doc = pruneDocNulls(patch) } } else { patchAry := &partialArray{} patchErr = json.Unmarshal(patchData, patchAry) if patchErr != nil { return nil, ErrBadJSONPatch } pruneAryNulls(patchAry) out, patchErr := json.Marshal(patchAry) if patchErr != nil { return nil, ErrBadJSONPatch } return out, nil } } else { mergeDocs(doc, patch, mergeMerge) } return json.Marshal(doc) } // resemblesJSONArray indicates whether the byte-slice "appears" to be // a JSON array or not. // False-positives are possible, as this function does not check the internal // structure of the array. It only checks that the outer syntax is present and // correct. func resemblesJSONArray(input []byte) bool { input = bytes.TrimSpace(input) hasPrefix := bytes.HasPrefix(input, []byte("[")) hasSuffix := bytes.HasSuffix(input, []byte("]")) return hasPrefix && hasSuffix } // CreateMergePatch will return a merge patch document capable of converting // the original document(s) to the modified document(s). // The parameters can be bytes of either two JSON Documents, or two arrays of // JSON documents. // The merge patch returned follows the specification defined at http://tools.ietf.org/html/draft-ietf-appsawg-json-merge-patch-07 func CreateMergePatch(originalJSON, modifiedJSON []byte) ([]byte, error) { originalResemblesArray := resemblesJSONArray(originalJSON) modifiedResemblesArray := resemblesJSONArray(modifiedJSON) // Do both byte-slices seem like JSON arrays? if originalResemblesArray && modifiedResemblesArray { return createArrayMergePatch(originalJSON, modifiedJSON) } // Are both byte-slices are not arrays? Then they are likely JSON objects... if !originalResemblesArray && !modifiedResemblesArray { return createObjectMergePatch(originalJSON, modifiedJSON) } // None of the above? Then return an error because of mismatched types. return nil, errBadMergeTypes } // createObjectMergePatch will return a merge-patch document capable of // converting the original document to the modified document. func createObjectMergePatch(originalJSON, modifiedJSON []byte) ([]byte, error) { originalDoc := map[string]interface{}{} modifiedDoc := map[string]interface{}{} err := json.Unmarshal(originalJSON, &originalDoc) if err != nil { return nil, ErrBadJSONDoc } err = json.Unmarshal(modifiedJSON, &modifiedDoc) if err != nil { return nil, ErrBadJSONDoc } dest, err := getDiff(originalDoc, modifiedDoc) if err != nil { return nil, err } return json.Marshal(dest) } // createArrayMergePatch will return an array of merge-patch documents capable // of converting the original document to the modified document for each // pair of JSON documents provided in the arrays. // Arrays of mismatched sizes will result in an error. func createArrayMergePatch(originalJSON, modifiedJSON []byte) ([]byte, error) { originalDocs := []json.RawMessage{} modifiedDocs := []json.RawMessage{} err := json.Unmarshal(originalJSON, &originalDocs) if err != nil { return nil, ErrBadJSONDoc } err = json.Unmarshal(modifiedJSON, &modifiedDocs) if err != nil { return nil, ErrBadJSONDoc } total := len(originalDocs) if len(modifiedDocs) != total { return nil, ErrBadJSONDoc } result := []json.RawMessage{} for i := 0; i < len(originalDocs); i++ { original := originalDocs[i] modified := modifiedDocs[i] patch, err := createObjectMergePatch(original, modified) if err != nil { return nil, err } result = append(result, json.RawMessage(patch)) } return json.Marshal(result) } // Returns true if the array matches (must be json types). // As is idiomatic for go, an empty array is not the same as a nil array. func matchesArray(a, b []interface{}) bool { if len(a) != len(b) { return false } if (a == nil && b != nil) || (a != nil && b == nil) { return false } for i := range a { if !matchesValue(a[i], b[i]) { return false } } return true } // Returns true if the values matches (must be json types) // The types of the values must match, otherwise it will always return false // If two map[string]interface{} are given, all elements must match. func matchesValue(av, bv interface{}) bool { if reflect.TypeOf(av) != reflect.TypeOf(bv) { return false } switch at := av.(type) { case string: bt := bv.(string) if bt == at { return true } case float64: bt := bv.(float64) if bt == at { return true } case bool: bt := bv.(bool) if bt == at { return true } case nil: // Both nil, fine. return true case map[string]interface{}: bt := bv.(map[string]interface{}) if len(bt) != len(at) { return false } for key := range bt { av, aOK := at[key] bv, bOK := bt[key] if aOK != bOK { return false } if !matchesValue(av, bv) { return false } } return true case []interface{}: bt := bv.([]interface{}) return matchesArray(at, bt) } return false } // getDiff returns the (recursive) difference between a and b as a map[string]interface{}. func getDiff(a, b map[string]interface{}) (map[string]interface{}, error) { into := map[string]interface{}{} for key, bv := range b { av, ok := a[key] // value was added if !ok { into[key] = bv continue } // If types have changed, replace completely if reflect.TypeOf(av) != reflect.TypeOf(bv) { into[key] = bv continue } // Types are the same, compare values switch at := av.(type) { case map[string]interface{}: bt := bv.(map[string]interface{}) dst := make(map[string]interface{}, len(bt)) dst, err := getDiff(at, bt) if err != nil { return nil, err } if len(dst) > 0 { into[key] = dst } case string, float64, bool: if !matchesValue(av, bv) { into[key] = bv } case []interface{}: bt := bv.([]interface{}) if !matchesArray(at, bt) { into[key] = bv } case nil: switch bv.(type) { case nil: // Both nil, fine. default: into[key] = bv } default: panic(fmt.Sprintf("Unknown type:%T in key %s", av, key)) } } // Now add all deleted values as nil for key := range a { _, found := b[key] if !found { into[key] = nil } } return into, nil }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/evanphx/json-patch.v4/errors.go
vendor/gopkg.in/evanphx/json-patch.v4/errors.go
package jsonpatch import "fmt" // AccumulatedCopySizeError is an error type returned when the accumulated size // increase caused by copy operations in a patch operation has exceeded the // limit. type AccumulatedCopySizeError struct { limit int64 accumulated int64 } // NewAccumulatedCopySizeError returns an AccumulatedCopySizeError. func NewAccumulatedCopySizeError(l, a int64) *AccumulatedCopySizeError { return &AccumulatedCopySizeError{limit: l, accumulated: a} } // Error implements the error interface. func (a *AccumulatedCopySizeError) Error() string { return fmt.Sprintf("Unable to complete the copy, the accumulated size increase of copy is %d, exceeding the limit %d", a.accumulated, a.limit) } // ArraySizeError is an error type returned when the array size has exceeded // the limit. type ArraySizeError struct { limit int size int } // NewArraySizeError returns an ArraySizeError. func NewArraySizeError(l, s int) *ArraySizeError { return &ArraySizeError{limit: l, size: s} } // Error implements the error interface. func (a *ArraySizeError) Error() string { return fmt.Sprintf("Unable to create array of size %d, limit is %d", a.size, a.limit) }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/evanphx/json-patch.v4/patch.go
vendor/gopkg.in/evanphx/json-patch.v4/patch.go
package jsonpatch import ( "bytes" "encoding/json" "fmt" "strconv" "strings" "github.com/pkg/errors" ) const ( eRaw = iota eDoc eAry ) var ( // SupportNegativeIndices decides whether to support non-standard practice of // allowing negative indices to mean indices starting at the end of an array. // Default to true. SupportNegativeIndices bool = true // AccumulatedCopySizeLimit limits the total size increase in bytes caused by // "copy" operations in a patch. AccumulatedCopySizeLimit int64 = 0 ) var ( ErrTestFailed = errors.New("test failed") ErrMissing = errors.New("missing value") ErrUnknownType = errors.New("unknown object type") ErrInvalid = errors.New("invalid state detected") ErrInvalidIndex = errors.New("invalid index referenced") ) type lazyNode struct { raw *json.RawMessage doc partialDoc ary partialArray which int } // Operation is a single JSON-Patch step, such as a single 'add' operation. type Operation map[string]*json.RawMessage // Patch is an ordered collection of Operations. type Patch []Operation type partialDoc map[string]*lazyNode type partialArray []*lazyNode type container interface { get(key string) (*lazyNode, error) set(key string, val *lazyNode) error add(key string, val *lazyNode) error remove(key string) error } func newLazyNode(raw *json.RawMessage) *lazyNode { return &lazyNode{raw: raw, doc: nil, ary: nil, which: eRaw} } func (n *lazyNode) MarshalJSON() ([]byte, error) { switch n.which { case eRaw: return json.Marshal(n.raw) case eDoc: return json.Marshal(n.doc) case eAry: return json.Marshal(n.ary) default: return nil, ErrUnknownType } } func (n *lazyNode) UnmarshalJSON(data []byte) error { dest := make(json.RawMessage, len(data)) copy(dest, data) n.raw = &dest n.which = eRaw return nil } func deepCopy(src *lazyNode) (*lazyNode, int, error) { if src == nil { return nil, 0, nil } a, err := src.MarshalJSON() if err != nil { return nil, 0, err } sz := len(a) ra := make(json.RawMessage, sz) copy(ra, a) return newLazyNode(&ra), sz, nil } func (n *lazyNode) intoDoc() (*partialDoc, error) { if n.which == eDoc { return &n.doc, nil } if n.raw == nil { return nil, ErrInvalid } err := json.Unmarshal(*n.raw, &n.doc) if err != nil { return nil, err } n.which = eDoc return &n.doc, nil } func (n *lazyNode) intoAry() (*partialArray, error) { if n.which == eAry { return &n.ary, nil } if n.raw == nil { return nil, ErrInvalid } err := json.Unmarshal(*n.raw, &n.ary) if err != nil { return nil, err } n.which = eAry return &n.ary, nil } func (n *lazyNode) compact() []byte { buf := &bytes.Buffer{} if n.raw == nil { return nil } err := json.Compact(buf, *n.raw) if err != nil { return *n.raw } return buf.Bytes() } func (n *lazyNode) tryDoc() bool { if n.raw == nil { return false } err := json.Unmarshal(*n.raw, &n.doc) if err != nil { return false } n.which = eDoc return true } func (n *lazyNode) tryAry() bool { if n.raw == nil { return false } err := json.Unmarshal(*n.raw, &n.ary) if err != nil { return false } n.which = eAry return true } func (n *lazyNode) equal(o *lazyNode) bool { if n.which == eRaw { if !n.tryDoc() && !n.tryAry() { if o.which != eRaw { return false } return bytes.Equal(n.compact(), o.compact()) } } if n.which == eDoc { if o.which == eRaw { if !o.tryDoc() { return false } } if o.which != eDoc { return false } if len(n.doc) != len(o.doc) { return false } for k, v := range n.doc { ov, ok := o.doc[k] if !ok { return false } if (v == nil) != (ov == nil) { return false } if v == nil && ov == nil { continue } if !v.equal(ov) { return false } } return true } if o.which != eAry && !o.tryAry() { return false } if len(n.ary) != len(o.ary) { return false } for idx, val := range n.ary { if !val.equal(o.ary[idx]) { return false } } return true } // Kind reads the "op" field of the Operation. func (o Operation) Kind() string { if obj, ok := o["op"]; ok && obj != nil { var op string err := json.Unmarshal(*obj, &op) if err != nil { return "unknown" } return op } return "unknown" } // Path reads the "path" field of the Operation. func (o Operation) Path() (string, error) { if obj, ok := o["path"]; ok && obj != nil { var op string err := json.Unmarshal(*obj, &op) if err != nil { return "unknown", err } return op, nil } return "unknown", errors.Wrapf(ErrMissing, "operation missing path field") } // From reads the "from" field of the Operation. func (o Operation) From() (string, error) { if obj, ok := o["from"]; ok && obj != nil { var op string err := json.Unmarshal(*obj, &op) if err != nil { return "unknown", err } return op, nil } return "unknown", errors.Wrapf(ErrMissing, "operation, missing from field") } func (o Operation) value() *lazyNode { if obj, ok := o["value"]; ok { return newLazyNode(obj) } return nil } // ValueInterface decodes the operation value into an interface. func (o Operation) ValueInterface() (interface{}, error) { if obj, ok := o["value"]; ok && obj != nil { var v interface{} err := json.Unmarshal(*obj, &v) if err != nil { return nil, err } return v, nil } return nil, errors.Wrapf(ErrMissing, "operation, missing value field") } func isArray(buf []byte) bool { Loop: for _, c := range buf { switch c { case ' ': case '\n': case '\t': continue case '[': return true default: break Loop } } return false } func findObject(pd *container, path string) (container, string) { doc := *pd split := strings.Split(path, "/") if len(split) < 2 { return nil, "" } parts := split[1 : len(split)-1] key := split[len(split)-1] var err error for _, part := range parts { next, ok := doc.get(decodePatchKey(part)) if next == nil || ok != nil { return nil, "" } if isArray(*next.raw) { doc, err = next.intoAry() if err != nil { return nil, "" } } else { doc, err = next.intoDoc() if err != nil { return nil, "" } } } return doc, decodePatchKey(key) } func (d *partialDoc) set(key string, val *lazyNode) error { (*d)[key] = val return nil } func (d *partialDoc) add(key string, val *lazyNode) error { (*d)[key] = val return nil } func (d *partialDoc) get(key string) (*lazyNode, error) { return (*d)[key], nil } func (d *partialDoc) remove(key string) error { _, ok := (*d)[key] if !ok { return errors.Wrapf(ErrMissing, "Unable to remove nonexistent key: %s", key) } delete(*d, key) return nil } // set should only be used to implement the "replace" operation, so "key" must // be an already existing index in "d". func (d *partialArray) set(key string, val *lazyNode) error { idx, err := strconv.Atoi(key) if err != nil { return err } if idx < 0 { if !SupportNegativeIndices { return errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } if idx < -len(*d) { return errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } idx += len(*d) } (*d)[idx] = val return nil } func (d *partialArray) add(key string, val *lazyNode) error { if key == "-" { *d = append(*d, val) return nil } idx, err := strconv.Atoi(key) if err != nil { return errors.Wrapf(err, "value was not a proper array index: '%s'", key) } sz := len(*d) + 1 ary := make([]*lazyNode, sz) cur := *d if idx >= len(ary) { return errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } if idx < 0 { if !SupportNegativeIndices { return errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } if idx < -len(ary) { return errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } idx += len(ary) } copy(ary[0:idx], cur[0:idx]) ary[idx] = val copy(ary[idx+1:], cur[idx:]) *d = ary return nil } func (d *partialArray) get(key string) (*lazyNode, error) { idx, err := strconv.Atoi(key) if err != nil { return nil, err } if idx < 0 { if !SupportNegativeIndices { return nil, errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } if idx < -len(*d) { return nil, errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } idx += len(*d) } if idx >= len(*d) { return nil, errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } return (*d)[idx], nil } func (d *partialArray) remove(key string) error { idx, err := strconv.Atoi(key) if err != nil { return err } cur := *d if idx >= len(cur) { return errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } if idx < 0 { if !SupportNegativeIndices { return errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } if idx < -len(cur) { return errors.Wrapf(ErrInvalidIndex, "Unable to access invalid index: %d", idx) } idx += len(cur) } ary := make([]*lazyNode, len(cur)-1) copy(ary[0:idx], cur[0:idx]) copy(ary[idx:], cur[idx+1:]) *d = ary return nil } func (p Patch) add(doc *container, op Operation) error { path, err := op.Path() if err != nil { return errors.Wrapf(ErrMissing, "add operation failed to decode path") } con, key := findObject(doc, path) if con == nil { return errors.Wrapf(ErrMissing, "add operation does not apply: doc is missing path: \"%s\"", path) } err = con.add(key, op.value()) if err != nil { return errors.Wrapf(err, "error in add for path: '%s'", path) } return nil } func (p Patch) remove(doc *container, op Operation) error { path, err := op.Path() if err != nil { return errors.Wrapf(ErrMissing, "remove operation failed to decode path") } con, key := findObject(doc, path) if con == nil { return errors.Wrapf(ErrMissing, "remove operation does not apply: doc is missing path: \"%s\"", path) } err = con.remove(key) if err != nil { return errors.Wrapf(err, "error in remove for path: '%s'", path) } return nil } func (p Patch) replace(doc *container, op Operation) error { path, err := op.Path() if err != nil { return errors.Wrapf(err, "replace operation failed to decode path") } if path == "" { val := op.value() if val.which == eRaw { if !val.tryDoc() { if !val.tryAry() { return errors.Wrapf(err, "replace operation value must be object or array") } } } switch val.which { case eAry: *doc = &val.ary case eDoc: *doc = &val.doc case eRaw: return errors.Wrapf(err, "replace operation hit impossible case") } return nil } con, key := findObject(doc, path) if con == nil { return errors.Wrapf(ErrMissing, "replace operation does not apply: doc is missing path: %s", path) } _, ok := con.get(key) if ok != nil { return errors.Wrapf(ErrMissing, "replace operation does not apply: doc is missing key: %s", path) } err = con.set(key, op.value()) if err != nil { return errors.Wrapf(err, "error in remove for path: '%s'", path) } return nil } func (p Patch) move(doc *container, op Operation) error { from, err := op.From() if err != nil { return errors.Wrapf(err, "move operation failed to decode from") } con, key := findObject(doc, from) if con == nil { return errors.Wrapf(ErrMissing, "move operation does not apply: doc is missing from path: %s", from) } val, err := con.get(key) if err != nil { return errors.Wrapf(err, "error in move for path: '%s'", key) } err = con.remove(key) if err != nil { return errors.Wrapf(err, "error in move for path: '%s'", key) } path, err := op.Path() if err != nil { return errors.Wrapf(err, "move operation failed to decode path") } con, key = findObject(doc, path) if con == nil { return errors.Wrapf(ErrMissing, "move operation does not apply: doc is missing destination path: %s", path) } err = con.add(key, val) if err != nil { return errors.Wrapf(err, "error in move for path: '%s'", path) } return nil } func (p Patch) test(doc *container, op Operation) error { path, err := op.Path() if err != nil { return errors.Wrapf(err, "test operation failed to decode path") } if path == "" { var self lazyNode switch sv := (*doc).(type) { case *partialDoc: self.doc = *sv self.which = eDoc case *partialArray: self.ary = *sv self.which = eAry } if self.equal(op.value()) { return nil } return errors.Wrapf(ErrTestFailed, "testing value %s failed", path) } con, key := findObject(doc, path) if con == nil { return errors.Wrapf(ErrMissing, "test operation does not apply: is missing path: %s", path) } val, err := con.get(key) if err != nil { return errors.Wrapf(err, "error in test for path: '%s'", path) } if val == nil { if op.value().raw == nil { return nil } return errors.Wrapf(ErrTestFailed, "testing value %s failed", path) } else if op.value() == nil { return errors.Wrapf(ErrTestFailed, "testing value %s failed", path) } if val.equal(op.value()) { return nil } return errors.Wrapf(ErrTestFailed, "testing value %s failed", path) } func (p Patch) copy(doc *container, op Operation, accumulatedCopySize *int64) error { from, err := op.From() if err != nil { return errors.Wrapf(err, "copy operation failed to decode from") } con, key := findObject(doc, from) if con == nil { return errors.Wrapf(ErrMissing, "copy operation does not apply: doc is missing from path: %s", from) } val, err := con.get(key) if err != nil { return errors.Wrapf(err, "error in copy for from: '%s'", from) } path, err := op.Path() if err != nil { return errors.Wrapf(ErrMissing, "copy operation failed to decode path") } con, key = findObject(doc, path) if con == nil { return errors.Wrapf(ErrMissing, "copy operation does not apply: doc is missing destination path: %s", path) } valCopy, sz, err := deepCopy(val) if err != nil { return errors.Wrapf(err, "error while performing deep copy") } (*accumulatedCopySize) += int64(sz) if AccumulatedCopySizeLimit > 0 && *accumulatedCopySize > AccumulatedCopySizeLimit { return NewAccumulatedCopySizeError(AccumulatedCopySizeLimit, *accumulatedCopySize) } err = con.add(key, valCopy) if err != nil { return errors.Wrapf(err, "error while adding value during copy") } return nil } // Equal indicates if 2 JSON documents have the same structural equality. func Equal(a, b []byte) bool { ra := make(json.RawMessage, len(a)) copy(ra, a) la := newLazyNode(&ra) rb := make(json.RawMessage, len(b)) copy(rb, b) lb := newLazyNode(&rb) return la.equal(lb) } // DecodePatch decodes the passed JSON document as an RFC 6902 patch. func DecodePatch(buf []byte) (Patch, error) { var p Patch err := json.Unmarshal(buf, &p) if err != nil { return nil, err } return p, nil } // Apply mutates a JSON document according to the patch, and returns the new // document. func (p Patch) Apply(doc []byte) ([]byte, error) { return p.ApplyIndent(doc, "") } // ApplyIndent mutates a JSON document according to the patch, and returns the new // document indented. func (p Patch) ApplyIndent(doc []byte, indent string) ([]byte, error) { if len(doc) == 0 { return doc, nil } var pd container if doc[0] == '[' { pd = &partialArray{} } else { pd = &partialDoc{} } err := json.Unmarshal(doc, pd) if err != nil { return nil, err } err = nil var accumulatedCopySize int64 for _, op := range p { switch op.Kind() { case "add": err = p.add(&pd, op) case "remove": err = p.remove(&pd, op) case "replace": err = p.replace(&pd, op) case "move": err = p.move(&pd, op) case "test": err = p.test(&pd, op) case "copy": err = p.copy(&pd, op, &accumulatedCopySize) default: err = fmt.Errorf("Unexpected kind: %s", op.Kind()) } if err != nil { return nil, err } } if indent != "" { return json.MarshalIndent(pd, "", indent) } return json.Marshal(pd) } // From http://tools.ietf.org/html/rfc6901#section-4 : // // Evaluation of each reference token begins by decoding any escaped // character sequence. This is performed by first transforming any // occurrence of the sequence '~1' to '/', and then transforming any // occurrence of the sequence '~0' to '~'. var ( rfc6901Decoder = strings.NewReplacer("~1", "/", "~0", "~") ) func decodePatchKey(k string) string { return rfc6901Decoder.Replace(k) }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/inf.v0/rounder.go
vendor/gopkg.in/inf.v0/rounder.go
package inf import ( "math/big" ) // Rounder represents a method for rounding the (possibly infinite decimal) // result of a division to a finite Dec. It is used by Dec.Round() and // Dec.Quo(). // // See the Example for results of using each Rounder with some sample values. // type Rounder rounder // See http://speleotrove.com/decimal/damodel.html#refround for more detailed // definitions of these rounding modes. var ( RoundDown Rounder // towards 0 RoundUp Rounder // away from 0 RoundFloor Rounder // towards -infinity RoundCeil Rounder // towards +infinity RoundHalfDown Rounder // to nearest; towards 0 if same distance RoundHalfUp Rounder // to nearest; away from 0 if same distance RoundHalfEven Rounder // to nearest; even last digit if same distance ) // RoundExact is to be used in the case when rounding is not necessary. // When used with Quo or Round, it returns the result verbatim when it can be // expressed exactly with the given precision, and it returns nil otherwise. // QuoExact is a shorthand for using Quo with RoundExact. var RoundExact Rounder type rounder interface { // When UseRemainder() returns true, the Round() method is passed the // remainder of the division, expressed as the numerator and denominator of // a rational. UseRemainder() bool // Round sets the rounded value of a quotient to z, and returns z. // quo is rounded down (truncated towards zero) to the scale obtained from // the Scaler in Quo(). // // When the remainder is not used, remNum and remDen are nil. // When used, the remainder is normalized between -1 and 1; that is: // // -|remDen| < remNum < |remDen| // // remDen has the same sign as y, and remNum is zero or has the same sign // as x. Round(z, quo *Dec, remNum, remDen *big.Int) *Dec } type rndr struct { useRem bool round func(z, quo *Dec, remNum, remDen *big.Int) *Dec } func (r rndr) UseRemainder() bool { return r.useRem } func (r rndr) Round(z, quo *Dec, remNum, remDen *big.Int) *Dec { return r.round(z, quo, remNum, remDen) } var intSign = []*big.Int{big.NewInt(-1), big.NewInt(0), big.NewInt(1)} func roundHalf(f func(c int, odd uint) (roundUp bool)) func(z, q *Dec, rA, rB *big.Int) *Dec { return func(z, q *Dec, rA, rB *big.Int) *Dec { z.Set(q) brA, brB := rA.BitLen(), rB.BitLen() if brA < brB-1 { // brA < brB-1 => |rA| < |rB/2| return z } roundUp := false srA, srB := rA.Sign(), rB.Sign() s := srA * srB if brA == brB-1 { rA2 := new(big.Int).Lsh(rA, 1) if s < 0 { rA2.Neg(rA2) } roundUp = f(rA2.Cmp(rB)*srB, z.UnscaledBig().Bit(0)) } else { // brA > brB-1 => |rA| > |rB/2| roundUp = true } if roundUp { z.UnscaledBig().Add(z.UnscaledBig(), intSign[s+1]) } return z } } func init() { RoundExact = rndr{true, func(z, q *Dec, rA, rB *big.Int) *Dec { if rA.Sign() != 0 { return nil } return z.Set(q) }} RoundDown = rndr{false, func(z, q *Dec, rA, rB *big.Int) *Dec { return z.Set(q) }} RoundUp = rndr{true, func(z, q *Dec, rA, rB *big.Int) *Dec { z.Set(q) if rA.Sign() != 0 { z.UnscaledBig().Add(z.UnscaledBig(), intSign[rA.Sign()*rB.Sign()+1]) } return z }} RoundFloor = rndr{true, func(z, q *Dec, rA, rB *big.Int) *Dec { z.Set(q) if rA.Sign()*rB.Sign() < 0 { z.UnscaledBig().Add(z.UnscaledBig(), intSign[0]) } return z }} RoundCeil = rndr{true, func(z, q *Dec, rA, rB *big.Int) *Dec { z.Set(q) if rA.Sign()*rB.Sign() > 0 { z.UnscaledBig().Add(z.UnscaledBig(), intSign[2]) } return z }} RoundHalfDown = rndr{true, roundHalf( func(c int, odd uint) bool { return c > 0 })} RoundHalfUp = rndr{true, roundHalf( func(c int, odd uint) bool { return c >= 0 })} RoundHalfEven = rndr{true, roundHalf( func(c int, odd uint) bool { return c > 0 || c == 0 && odd == 1 })} }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/gopkg.in/inf.v0/dec.go
vendor/gopkg.in/inf.v0/dec.go
// Package inf (type inf.Dec) implements "infinite-precision" decimal // arithmetic. // "Infinite precision" describes two characteristics: practically unlimited // precision for decimal number representation and no support for calculating // with any specific fixed precision. // (Although there is no practical limit on precision, inf.Dec can only // represent finite decimals.) // // This package is currently in experimental stage and the API may change. // // This package does NOT support: // - rounding to specific precisions (as opposed to specific decimal positions) // - the notion of context (each rounding must be explicit) // - NaN and Inf values, and distinguishing between positive and negative zero // - conversions to and from float32/64 types // // Features considered for possible addition: // + formatting options // + Exp method // + combined operations such as AddRound/MulAdd etc // + exchanging data in decimal32/64/128 formats // package inf // import "gopkg.in/inf.v0" // TODO: // - avoid excessive deep copying (quo and rounders) import ( "fmt" "io" "math/big" "strings" ) // A Dec represents a signed arbitrary-precision decimal. // It is a combination of a sign, an arbitrary-precision integer coefficient // value, and a signed fixed-precision exponent value. // The sign and the coefficient value are handled together as a signed value // and referred to as the unscaled value. // (Positive and negative zero values are not distinguished.) // Since the exponent is most commonly non-positive, it is handled in negated // form and referred to as scale. // // The mathematical value of a Dec equals: // // unscaled * 10**(-scale) // // Note that different Dec representations may have equal mathematical values. // // unscaled scale String() // ------------------------- // 0 0 "0" // 0 2 "0.00" // 0 -2 "0" // 1 0 "1" // 100 2 "1.00" // 10 0 "10" // 1 -1 "10" // // The zero value for a Dec represents the value 0 with scale 0. // // Operations are typically performed through the *Dec type. // The semantics of the assignment operation "=" for "bare" Dec values is // undefined and should not be relied on. // // Methods are typically of the form: // // func (z *Dec) Op(x, y *Dec) *Dec // // and implement operations z = x Op y with the result as receiver; if it // is one of the operands it may be overwritten (and its memory reused). // To enable chaining of operations, the result is also returned. Methods // returning a result other than *Dec take one of the operands as the receiver. // // A "bare" Quo method (quotient / division operation) is not provided, as the // result is not always a finite decimal and thus in general cannot be // represented as a Dec. // Instead, in the common case when rounding is (potentially) necessary, // QuoRound should be used with a Scale and a Rounder. // QuoExact or QuoRound with RoundExact can be used in the special cases when it // is known that the result is always a finite decimal. // type Dec struct { unscaled big.Int scale Scale } // Scale represents the type used for the scale of a Dec. type Scale int32 const scaleSize = 4 // bytes in a Scale value // Scaler represents a method for obtaining the scale to use for the result of // an operation on x and y. type scaler interface { Scale(x *Dec, y *Dec) Scale } var bigInt = [...]*big.Int{ big.NewInt(0), big.NewInt(1), big.NewInt(2), big.NewInt(3), big.NewInt(4), big.NewInt(5), big.NewInt(6), big.NewInt(7), big.NewInt(8), big.NewInt(9), big.NewInt(10), } var exp10cache [64]big.Int = func() [64]big.Int { e10, e10i := [64]big.Int{}, bigInt[1] for i := range e10 { e10[i].Set(e10i) e10i = new(big.Int).Mul(e10i, bigInt[10]) } return e10 }() // NewDec allocates and returns a new Dec set to the given int64 unscaled value // and scale. func NewDec(unscaled int64, scale Scale) *Dec { return new(Dec).SetUnscaled(unscaled).SetScale(scale) } // NewDecBig allocates and returns a new Dec set to the given *big.Int unscaled // value and scale. func NewDecBig(unscaled *big.Int, scale Scale) *Dec { return new(Dec).SetUnscaledBig(unscaled).SetScale(scale) } // Scale returns the scale of x. func (x *Dec) Scale() Scale { return x.scale } // Unscaled returns the unscaled value of x for u and true for ok when the // unscaled value can be represented as int64; otherwise it returns an undefined // int64 value for u and false for ok. Use x.UnscaledBig().Int64() to avoid // checking the validity of the value when the check is known to be redundant. func (x *Dec) Unscaled() (u int64, ok bool) { u = x.unscaled.Int64() var i big.Int ok = i.SetInt64(u).Cmp(&x.unscaled) == 0 return } // UnscaledBig returns the unscaled value of x as *big.Int. func (x *Dec) UnscaledBig() *big.Int { return &x.unscaled } // SetScale sets the scale of z, with the unscaled value unchanged, and returns // z. // The mathematical value of the Dec changes as if it was multiplied by // 10**(oldscale-scale). func (z *Dec) SetScale(scale Scale) *Dec { z.scale = scale return z } // SetUnscaled sets the unscaled value of z, with the scale unchanged, and // returns z. func (z *Dec) SetUnscaled(unscaled int64) *Dec { z.unscaled.SetInt64(unscaled) return z } // SetUnscaledBig sets the unscaled value of z, with the scale unchanged, and // returns z. func (z *Dec) SetUnscaledBig(unscaled *big.Int) *Dec { z.unscaled.Set(unscaled) return z } // Set sets z to the value of x and returns z. // It does nothing if z == x. func (z *Dec) Set(x *Dec) *Dec { if z != x { z.SetUnscaledBig(x.UnscaledBig()) z.SetScale(x.Scale()) } return z } // Sign returns: // // -1 if x < 0 // 0 if x == 0 // +1 if x > 0 // func (x *Dec) Sign() int { return x.UnscaledBig().Sign() } // Neg sets z to -x and returns z. func (z *Dec) Neg(x *Dec) *Dec { z.SetScale(x.Scale()) z.UnscaledBig().Neg(x.UnscaledBig()) return z } // Cmp compares x and y and returns: // // -1 if x < y // 0 if x == y // +1 if x > y // func (x *Dec) Cmp(y *Dec) int { xx, yy := upscale(x, y) return xx.UnscaledBig().Cmp(yy.UnscaledBig()) } // Abs sets z to |x| (the absolute value of x) and returns z. func (z *Dec) Abs(x *Dec) *Dec { z.SetScale(x.Scale()) z.UnscaledBig().Abs(x.UnscaledBig()) return z } // Add sets z to the sum x+y and returns z. // The scale of z is the greater of the scales of x and y. func (z *Dec) Add(x, y *Dec) *Dec { xx, yy := upscale(x, y) z.SetScale(xx.Scale()) z.UnscaledBig().Add(xx.UnscaledBig(), yy.UnscaledBig()) return z } // Sub sets z to the difference x-y and returns z. // The scale of z is the greater of the scales of x and y. func (z *Dec) Sub(x, y *Dec) *Dec { xx, yy := upscale(x, y) z.SetScale(xx.Scale()) z.UnscaledBig().Sub(xx.UnscaledBig(), yy.UnscaledBig()) return z } // Mul sets z to the product x*y and returns z. // The scale of z is the sum of the scales of x and y. func (z *Dec) Mul(x, y *Dec) *Dec { z.SetScale(x.Scale() + y.Scale()) z.UnscaledBig().Mul(x.UnscaledBig(), y.UnscaledBig()) return z } // Round sets z to the value of x rounded to Scale s using Rounder r, and // returns z. func (z *Dec) Round(x *Dec, s Scale, r Rounder) *Dec { return z.QuoRound(x, NewDec(1, 0), s, r) } // QuoRound sets z to the quotient x/y, rounded using the given Rounder to the // specified scale. // // If the rounder is RoundExact but the result can not be expressed exactly at // the specified scale, QuoRound returns nil, and the value of z is undefined. // // There is no corresponding Div method; the equivalent can be achieved through // the choice of Rounder used. // func (z *Dec) QuoRound(x, y *Dec, s Scale, r Rounder) *Dec { return z.quo(x, y, sclr{s}, r) } func (z *Dec) quo(x, y *Dec, s scaler, r Rounder) *Dec { scl := s.Scale(x, y) var zzz *Dec if r.UseRemainder() { zz, rA, rB := new(Dec).quoRem(x, y, scl, true, new(big.Int), new(big.Int)) zzz = r.Round(new(Dec), zz, rA, rB) } else { zz, _, _ := new(Dec).quoRem(x, y, scl, false, nil, nil) zzz = r.Round(new(Dec), zz, nil, nil) } if zzz == nil { return nil } return z.Set(zzz) } // QuoExact sets z to the quotient x/y and returns z when x/y is a finite // decimal. Otherwise it returns nil and the value of z is undefined. // // The scale of a non-nil result is "x.Scale() - y.Scale()" or greater; it is // calculated so that the remainder will be zero whenever x/y is a finite // decimal. func (z *Dec) QuoExact(x, y *Dec) *Dec { return z.quo(x, y, scaleQuoExact{}, RoundExact) } // quoRem sets z to the quotient x/y with the scale s, and if useRem is true, // it sets remNum and remDen to the numerator and denominator of the remainder. // It returns z, remNum and remDen. // // The remainder is normalized to the range -1 < r < 1 to simplify rounding; // that is, the results satisfy the following equation: // // x / y = z + (remNum/remDen) * 10**(-z.Scale()) // // See Rounder for more details about rounding. // func (z *Dec) quoRem(x, y *Dec, s Scale, useRem bool, remNum, remDen *big.Int) (*Dec, *big.Int, *big.Int) { // difference (required adjustment) compared to "canonical" result scale shift := s - (x.Scale() - y.Scale()) // pointers to adjusted unscaled dividend and divisor var ix, iy *big.Int switch { case shift > 0: // increased scale: decimal-shift dividend left ix = new(big.Int).Mul(x.UnscaledBig(), exp10(shift)) iy = y.UnscaledBig() case shift < 0: // decreased scale: decimal-shift divisor left ix = x.UnscaledBig() iy = new(big.Int).Mul(y.UnscaledBig(), exp10(-shift)) default: ix = x.UnscaledBig() iy = y.UnscaledBig() } // save a copy of iy in case it to be overwritten with the result iy2 := iy if iy == z.UnscaledBig() { iy2 = new(big.Int).Set(iy) } // set scale z.SetScale(s) // set unscaled if useRem { // Int division _, intr := z.UnscaledBig().QuoRem(ix, iy, new(big.Int)) // set remainder remNum.Set(intr) remDen.Set(iy2) } else { z.UnscaledBig().Quo(ix, iy) } return z, remNum, remDen } type sclr struct{ s Scale } func (s sclr) Scale(x, y *Dec) Scale { return s.s } type scaleQuoExact struct{} func (sqe scaleQuoExact) Scale(x, y *Dec) Scale { rem := new(big.Rat).SetFrac(x.UnscaledBig(), y.UnscaledBig()) f2, f5 := factor2(rem.Denom()), factor(rem.Denom(), bigInt[5]) var f10 Scale if f2 > f5 { f10 = Scale(f2) } else { f10 = Scale(f5) } return x.Scale() - y.Scale() + f10 } func factor(n *big.Int, p *big.Int) int { // could be improved for large factors d, f := n, 0 for { dd, dm := new(big.Int).DivMod(d, p, new(big.Int)) if dm.Sign() == 0 { f++ d = dd } else { break } } return f } func factor2(n *big.Int) int { // could be improved for large factors f := 0 for ; n.Bit(f) == 0; f++ { } return f } func upscale(a, b *Dec) (*Dec, *Dec) { if a.Scale() == b.Scale() { return a, b } if a.Scale() > b.Scale() { bb := b.rescale(a.Scale()) return a, bb } aa := a.rescale(b.Scale()) return aa, b } func exp10(x Scale) *big.Int { if int(x) < len(exp10cache) { return &exp10cache[int(x)] } return new(big.Int).Exp(bigInt[10], big.NewInt(int64(x)), nil) } func (x *Dec) rescale(newScale Scale) *Dec { shift := newScale - x.Scale() switch { case shift < 0: e := exp10(-shift) return NewDecBig(new(big.Int).Quo(x.UnscaledBig(), e), newScale) case shift > 0: e := exp10(shift) return NewDecBig(new(big.Int).Mul(x.UnscaledBig(), e), newScale) } return x } var zeros = []byte("00000000000000000000000000000000" + "00000000000000000000000000000000") var lzeros = Scale(len(zeros)) func appendZeros(s []byte, n Scale) []byte { for i := Scale(0); i < n; i += lzeros { if n > i+lzeros { s = append(s, zeros...) } else { s = append(s, zeros[0:n-i]...) } } return s } func (x *Dec) String() string { if x == nil { return "<nil>" } scale := x.Scale() s := []byte(x.UnscaledBig().String()) if scale <= 0 { if scale != 0 && x.unscaled.Sign() != 0 { s = appendZeros(s, -scale) } return string(s) } negbit := Scale(-((x.Sign() - 1) / 2)) // scale > 0 lens := Scale(len(s)) if lens-negbit <= scale { ss := make([]byte, 0, scale+2) if negbit == 1 { ss = append(ss, '-') } ss = append(ss, '0', '.') ss = appendZeros(ss, scale-lens+negbit) ss = append(ss, s[negbit:]...) return string(ss) } // lens > scale ss := make([]byte, 0, lens+1) ss = append(ss, s[:lens-scale]...) ss = append(ss, '.') ss = append(ss, s[lens-scale:]...) return string(ss) } // Format is a support routine for fmt.Formatter. It accepts the decimal // formats 'd' and 'f', and handles both equivalently. // Width, precision, flags and bases 2, 8, 16 are not supported. func (x *Dec) Format(s fmt.State, ch rune) { if ch != 'd' && ch != 'f' && ch != 'v' && ch != 's' { fmt.Fprintf(s, "%%!%c(dec.Dec=%s)", ch, x.String()) return } fmt.Fprintf(s, x.String()) } func (z *Dec) scan(r io.RuneScanner) (*Dec, error) { unscaled := make([]byte, 0, 256) // collects chars of unscaled as bytes dp, dg := -1, -1 // indexes of decimal point, first digit loop: for { ch, _, err := r.ReadRune() if err == io.EOF { break loop } if err != nil { return nil, err } switch { case ch == '+' || ch == '-': if len(unscaled) > 0 || dp >= 0 { // must be first character r.UnreadRune() break loop } case ch == '.': if dp >= 0 { r.UnreadRune() break loop } dp = len(unscaled) continue // don't add to unscaled case ch >= '0' && ch <= '9': if dg == -1 { dg = len(unscaled) } default: r.UnreadRune() break loop } unscaled = append(unscaled, byte(ch)) } if dg == -1 { return nil, fmt.Errorf("no digits read") } if dp >= 0 { z.SetScale(Scale(len(unscaled) - dp)) } else { z.SetScale(0) } _, ok := z.UnscaledBig().SetString(string(unscaled), 10) if !ok { return nil, fmt.Errorf("invalid decimal: %s", string(unscaled)) } return z, nil } // SetString sets z to the value of s, interpreted as a decimal (base 10), // and returns z and a boolean indicating success. The scale of z is the // number of digits after the decimal point (including any trailing 0s), // or 0 if there is no decimal point. If SetString fails, the value of z // is undefined but the returned value is nil. func (z *Dec) SetString(s string) (*Dec, bool) { r := strings.NewReader(s) _, err := z.scan(r) if err != nil { return nil, false } _, _, err = r.ReadRune() if err != io.EOF { return nil, false } // err == io.EOF => scan consumed all of s return z, true } // Scan is a support routine for fmt.Scanner; it sets z to the value of // the scanned number. It accepts the decimal formats 'd' and 'f', and // handles both equivalently. Bases 2, 8, 16 are not supported. // The scale of z is the number of digits after the decimal point // (including any trailing 0s), or 0 if there is no decimal point. func (z *Dec) Scan(s fmt.ScanState, ch rune) error { if ch != 'd' && ch != 'f' && ch != 's' && ch != 'v' { return fmt.Errorf("Dec.Scan: invalid verb '%c'", ch) } s.SkipSpace() _, err := z.scan(s) return err } // Gob encoding version const decGobVersion byte = 1 func scaleBytes(s Scale) []byte { buf := make([]byte, scaleSize) i := scaleSize for j := 0; j < scaleSize; j++ { i-- buf[i] = byte(s) s >>= 8 } return buf } func scale(b []byte) (s Scale) { for j := 0; j < scaleSize; j++ { s <<= 8 s |= Scale(b[j]) } return } // GobEncode implements the gob.GobEncoder interface. func (x *Dec) GobEncode() ([]byte, error) { buf, err := x.UnscaledBig().GobEncode() if err != nil { return nil, err } buf = append(append(buf, scaleBytes(x.Scale())...), decGobVersion) return buf, nil } // GobDecode implements the gob.GobDecoder interface. func (z *Dec) GobDecode(buf []byte) error { if len(buf) == 0 { return fmt.Errorf("Dec.GobDecode: no data") } b := buf[len(buf)-1] if b != decGobVersion { return fmt.Errorf("Dec.GobDecode: encoding version %d not supported", b) } l := len(buf) - scaleSize - 1 err := z.UnscaledBig().GobDecode(buf[:l]) if err != nil { return err } z.SetScale(scale(buf[l : l+scaleSize])) return nil } // MarshalText implements the encoding.TextMarshaler interface. func (x *Dec) MarshalText() ([]byte, error) { return []byte(x.String()), nil } // UnmarshalText implements the encoding.TextUnmarshaler interface. func (z *Dec) UnmarshalText(data []byte) error { _, ok := z.SetString(string(data)) if !ok { return fmt.Errorf("invalid inf.Dec") } return nil }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/sigs.k8s.io/mcs-api/pkg/apis/v1alpha1/zz_generated.deepcopy.go
vendor/sigs.k8s.io/mcs-api/pkg/apis/v1alpha1/zz_generated.deepcopy.go
// +build !ignore_autogenerated /* Copyright 2020 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // Code generated by controller-gen. DO NOT EDIT. package v1alpha1 import ( "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterStatus) DeepCopyInto(out *ClusterStatus) { *out = *in } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStatus. func (in *ClusterStatus) DeepCopy() *ClusterStatus { if in == nil { return nil } out := new(ClusterStatus) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceExport) DeepCopyInto(out *ServiceExport) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceExport. func (in *ServiceExport) DeepCopy() *ServiceExport { if in == nil { return nil } out := new(ServiceExport) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. func (in *ServiceExport) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceExportCondition) DeepCopyInto(out *ServiceExportCondition) { *out = *in if in.LastTransitionTime != nil { in, out := &in.LastTransitionTime, &out.LastTransitionTime *out = (*in).DeepCopy() } if in.Reason != nil { in, out := &in.Reason, &out.Reason *out = new(string) **out = **in } if in.Message != nil { in, out := &in.Message, &out.Message *out = new(string) **out = **in } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceExportCondition. func (in *ServiceExportCondition) DeepCopy() *ServiceExportCondition { if in == nil { return nil } out := new(ServiceExportCondition) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceExportList) DeepCopyInto(out *ServiceExportList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items *out = make([]ServiceExport, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceExportList. func (in *ServiceExportList) DeepCopy() *ServiceExportList { if in == nil { return nil } out := new(ServiceExportList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. func (in *ServiceExportList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceExportStatus) DeepCopyInto(out *ServiceExportStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]ServiceExportCondition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceExportStatus. func (in *ServiceExportStatus) DeepCopy() *ServiceExportStatus { if in == nil { return nil } out := new(ServiceExportStatus) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceImport) DeepCopyInto(out *ServiceImport) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceImport. func (in *ServiceImport) DeepCopy() *ServiceImport { if in == nil { return nil } out := new(ServiceImport) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. func (in *ServiceImport) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceImportList) DeepCopyInto(out *ServiceImportList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items *out = make([]ServiceImport, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceImportList. func (in *ServiceImportList) DeepCopy() *ServiceImportList { if in == nil { return nil } out := new(ServiceImportList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. func (in *ServiceImportList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceImportSpec) DeepCopyInto(out *ServiceImportSpec) { *out = *in if in.Ports != nil { in, out := &in.Ports, &out.Ports *out = make([]ServicePort, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } if in.IPs != nil { in, out := &in.IPs, &out.IPs *out = make([]string, len(*in)) copy(*out, *in) } if in.SessionAffinityConfig != nil { in, out := &in.SessionAffinityConfig, &out.SessionAffinityConfig *out = new(v1.SessionAffinityConfig) (*in).DeepCopyInto(*out) } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceImportSpec. func (in *ServiceImportSpec) DeepCopy() *ServiceImportSpec { if in == nil { return nil } out := new(ServiceImportSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceImportStatus) DeepCopyInto(out *ServiceImportStatus) { *out = *in if in.Clusters != nil { in, out := &in.Clusters, &out.Clusters *out = make([]ClusterStatus, len(*in)) copy(*out, *in) } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceImportStatus. func (in *ServiceImportStatus) DeepCopy() *ServiceImportStatus { if in == nil { return nil } out := new(ServiceImportStatus) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServicePort) DeepCopyInto(out *ServicePort) { *out = *in if in.AppProtocol != nil { in, out := &in.AppProtocol, &out.AppProtocol *out = new(string) **out = **in } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServicePort. func (in *ServicePort) DeepCopy() *ServicePort { if in == nil { return nil } out := new(ServicePort) in.DeepCopyInto(out) return out }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/sigs.k8s.io/mcs-api/pkg/apis/v1alpha1/well_known_labels.go
vendor/sigs.k8s.io/mcs-api/pkg/apis/v1alpha1/well_known_labels.go
/* Copyright 2020 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package v1alpha1 const ( // LabelServiceName is used to indicate the name of multi-cluster service // that an EndpointSlice belongs to. LabelServiceName = "multicluster.kubernetes.io/service-name" )
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/sigs.k8s.io/mcs-api/pkg/apis/v1alpha1/serviceimport.go
vendor/sigs.k8s.io/mcs-api/pkg/apis/v1alpha1/serviceimport.go
/* Copyright 2020 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package v1alpha1 import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // +genclient // +kubebuilder:object:root=true // ServiceImport describes a service imported from clusters in a ClusterSet. type ServiceImport struct { metav1.TypeMeta `json:",inline"` // +optional metav1.ObjectMeta `json:"metadata,omitempty"` // spec defines the behavior of a ServiceImport. // +optional Spec ServiceImportSpec `json:"spec,omitempty"` // status contains information about the exported services that form // the multi-cluster service referenced by this ServiceImport. // +optional Status ServiceImportStatus `json:"status,omitempty"` } // ServiceImportType designates the type of a ServiceImport type ServiceImportType string const ( // ClusterSetIP are only accessible via the ClusterSet IP. ClusterSetIP ServiceImportType = "ClusterSetIP" // Headless services allow backend pods to be addressed directly. Headless ServiceImportType = "Headless" ) // ServiceImportSpec describes an imported service and the information necessary to consume it. type ServiceImportSpec struct { // +listType=atomic Ports []ServicePort `json:"ports"` // ip will be used as the VIP for this service when type is ClusterSetIP. // +kubebuilder:validation:MaxItems:=1 // +optional IPs []string `json:"ips,omitempty"` // type defines the type of this service. // Must be ClusterSetIP or Headless. // +kubebuilder:validation:Enum=ClusterSetIP;Headless Type ServiceImportType `json:"type"` // Supports "ClientIP" and "None". Used to maintain session affinity. // Enable client IP based session affinity. // Must be ClientIP or None. // Defaults to None. // Ignored when type is Headless // More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies // +optional SessionAffinity v1.ServiceAffinity `json:"sessionAffinity,omitempty"` // sessionAffinityConfig contains session affinity configuration. // +optional SessionAffinityConfig *v1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"` } // ServicePort represents the port on which the service is exposed type ServicePort struct { // The name of this port within the service. This must be a DNS_LABEL. // All ports within a ServiceSpec must have unique names. When considering // the endpoints for a Service, this must match the 'name' field in the // EndpointPort. // Optional if only one ServicePort is defined on this service. // +optional Name string `json:"name,omitempty"` // The IP protocol for this port. Supports "TCP", "UDP", and "SCTP". // Default is TCP. // +optional Protocol v1.Protocol `json:"protocol,omitempty"` // The application protocol for this port. // This field follows standard Kubernetes label syntax. // Un-prefixed names are reserved for IANA standard service names (as per // RFC-6335 and http://www.iana.org/assignments/service-names). // Non-standard protocols should use prefixed names such as // mycompany.com/my-custom-protocol. // Field can be enabled with ServiceAppProtocol feature gate. // +optional AppProtocol *string `json:"appProtocol,omitempty"` // The port that will be exposed by this service. Port int32 `json:"port"` } // ServiceImportStatus describes derived state of an imported service. type ServiceImportStatus struct { // clusters is the list of exporting clusters from which this service // was derived. // +optional // +patchStrategy=merge // +patchMergeKey=cluster // +listType=map // +listMapKey=cluster Clusters []ClusterStatus `json:"clusters,omitempty"` } // ClusterStatus contains service configuration mapped to a specific source cluster type ClusterStatus struct { // cluster is the name of the exporting cluster. Must be a valid RFC-1123 DNS // label. Cluster string `json:"cluster"` } // +kubebuilder:object:root=true // ServiceImportList represents a list of endpoint slices type ServiceImportList struct { metav1.TypeMeta `json:",inline"` // Standard list metadata. // +optional metav1.ListMeta `json:"metadata,omitempty"` // List of endpoint slices // +listType=set Items []ServiceImport `json:"items"` }
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false
kubev2v/forklift
https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/sigs.k8s.io/mcs-api/pkg/apis/v1alpha1/doc.go
vendor/sigs.k8s.io/mcs-api/pkg/apis/v1alpha1/doc.go
/* Copyright 2020 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // Package v1alpha1 contains API schema definitions for the Multi-Cluster // Services v1alpha1 API group. // +kubebuilder:object:generate=true // +groupName=multicluster.x-k8s.io package v1alpha1
go
Apache-2.0
b3b4703e958c25d54c4d48138d9e80ae32fadac3
2026-01-07T09:44:30.792320Z
false