rewrite comments into one, unified style
This commit is contained in:
1 parent
6260de0085
commit
467a58c9c6
163 files changed
+3560
-2556
No files matched your search
@@ -1,3 +1,5 @@
|
||||
// Public NTLite string view ABI declarations shared between kernel, drivers, and user mode.
|
||||
|
||||
#pragma once
|
||||
// sys_string.h - shared native string-view ABI.
|
||||
// A SYS_STRING_VIEW is a borrowed byte span. It is not NUL-terminated by
|
||||
@@ -18,6 +20,7 @@ typedef struct SYS_STRING_VIEW {
|
||||
#define SYS_SV_LITERAL(s) ((SYS_STRING_VIEW){ (s), sizeof(s) - 1 })
|
||||
#define SYS_SV_NULL ((SYS_STRING_VIEW){ (const char*)0, 0 })
|
||||
|
||||
// Implements the sv From Parts operation.
|
||||
static inline SYS_STRING_VIEW SysSvFromParts(const char* data, size_t length) {
|
||||
SYS_STRING_VIEW v;
|
||||
v.Data = data;
|
||||
@@ -25,6 +28,7 @@ static inline SYS_STRING_VIEW SysSvFromParts(const char* data, size_t length) {
|
||||
return v;
|
||||
}
|
||||
|
||||
// Implements the sv From Cstr operation.
|
||||
static inline SYS_STRING_VIEW SysSvFromCstr(const char* s) {
|
||||
SYS_STRING_VIEW v;
|
||||
v.Data = s;
|
||||
@@ -32,14 +36,17 @@ static inline SYS_STRING_VIEW SysSvFromCstr(const char* s) {
|
||||
return v;
|
||||
}
|
||||
|
||||
// Implements the sv Is Empty operation.
|
||||
static inline int SysSvIsEmpty(SYS_STRING_VIEW s) {
|
||||
return s.Length == 0;
|
||||
}
|
||||
|
||||
// Implements the sv Is Valid operation.
|
||||
static inline int SysSvIsValid(SYS_STRING_VIEW s) {
|
||||
return s.Data != (const char*)0 || s.Length == 0;
|
||||
}
|
||||
|
||||
// Implements the sv Equal operation.
|
||||
static inline int SysSvEqual(SYS_STRING_VIEW a, SYS_STRING_VIEW b) {
|
||||
if (a.Length != b.Length) return 0;
|
||||
if (a.Length == 0) return 1;
|
||||
@@ -47,10 +54,12 @@ static inline int SysSvEqual(SYS_STRING_VIEW a, SYS_STRING_VIEW b) {
|
||||
return memcmp(a.Data, b.Data, a.Length) == 0;
|
||||
}
|
||||
|
||||
// Implements the ascii Lower operation.
|
||||
static inline char SysAsciiLower(char c) {
|
||||
return (c >= 'A' && c <= 'Z') ? (char)(c + ('a' - 'A')) : c;
|
||||
}
|
||||
|
||||
// Implements the sv Equal Ascii I operation.
|
||||
static inline int SysSvEqualAsciiI(SYS_STRING_VIEW a, SYS_STRING_VIEW b) {
|
||||
if (a.Length != b.Length) return 0;
|
||||
if (a.Length == 0) return 1;
|
||||
@@ -61,14 +70,17 @@ static inline int SysSvEqualAsciiI(SYS_STRING_VIEW a, SYS_STRING_VIEW b) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Implements the sv Equal Lit operation.
|
||||
static inline int SysSvEqualLit(SYS_STRING_VIEW a, const char* lit) {
|
||||
return SysSvEqual(a, SysSvFromCstr(lit));
|
||||
}
|
||||
|
||||
// Implements the sv Equal Lit Ascii I operation.
|
||||
static inline int SysSvEqualLitAsciiI(SYS_STRING_VIEW a, const char* lit) {
|
||||
return SysSvEqualAsciiI(a, SysSvFromCstr(lit));
|
||||
}
|
||||
|
||||
// Implements the sv Contains Byte operation.
|
||||
static inline int SysSvContainsByte(SYS_STRING_VIEW s, char ch) {
|
||||
if (!s.Data && s.Length) return 0;
|
||||
for (size_t i = 0; i < s.Length; i++) {
|
||||
@@ -77,12 +89,14 @@ static inline int SysSvContainsByte(SYS_STRING_VIEW s, char ch) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Implements the sv Slice operation.
|
||||
static inline SYS_STRING_VIEW SysSvSlice(SYS_STRING_VIEW s, size_t off, size_t len) {
|
||||
if (off > s.Length) off = s.Length;
|
||||
if (len > s.Length - off) len = s.Length - off;
|
||||
return SysSvFromParts(s.Data ? s.Data + off : (const char*)0, len);
|
||||
}
|
||||
|
||||
// Implements the sv Trim Ascii operation.
|
||||
static inline SYS_STRING_VIEW SysSvTrimAscii(SYS_STRING_VIEW s) {
|
||||
size_t begin = 0;
|
||||
size_t end = s.Length;
|
||||
@@ -99,6 +113,7 @@ static inline SYS_STRING_VIEW SysSvTrimAscii(SYS_STRING_VIEW s) {
|
||||
return SysSvSlice(s, begin, end - begin);
|
||||
}
|
||||
|
||||
// Implements the sv Copy Z operation.
|
||||
static inline int SysSvCopyZ(char* dst, size_t dstSize, SYS_STRING_VIEW src) {
|
||||
if (!dst || dstSize == 0) return 0;
|
||||
if (src.Length && !src.Data) return 0;
|
||||
|
||||
Reference in new issue
Block a user