about summary refs log tree commit diff stats
path: root/src/netascii.c
diff options
context:
space:
mode:
authorRen Kararou <[email protected]>2025-01-26 03:41:25 -0600
committerRen Kararou <[email protected]>2025-01-26 03:41:25 -0600
commit1bcf3de7f521d83185cce580db2dea6d50a617b6 (patch)
treec06850c6c0df9bdc9ca395ecc9ebe67b7c9dfb86 /src/netascii.c
parent9ec8d6d9dc03791f6ab1e3ad108c8d705d355696 (diff)
downloadnbtpd-1bcf3de7f521d83185cce580db2dea6d50a617b6.tar.gz
nbtpd-1bcf3de7f521d83185cce580db2dea6d50a617b6.tar.bz2
nbtpd-1bcf3de7f521d83185cce580db2dea6d50a617b6.zip
try bazel bazel
Diffstat (limited to 'src/netascii.c')
-rw-r--r--src/netascii.c53
1 files changed, 0 insertions, 53 deletions
diff --git a/src/netascii.c b/src/netascii.c
deleted file mode 100644
index d061e57..0000000
--- a/src/netascii.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "netascii.h"
-
-uint8_t is_netascii_char(char c) {
-	static const uint64_t LUT[4] = 
-		{0xffffffff00003f81,
-		 0x7fffffffffffffff,
-		 0x00,0x00};
-	int i = c / 64;
-	int e = i % 64;
-	return (LUT[i] >> e) & 1;
-}
-
-/// WARNING!  This function is NOT safe.  Use only for strings you have already
-/// verified are NULL terminated!
-uint8_t is_netascii_str(char *str) {
-	for (uint64_t i = 0; str[i] != 0; i++) {
-		if (!is_netascii_char(str[i])) {
-			return 0;
-		} else {
-			if (str[i] == '\r') {
-				if (str[++i] != '\n') {
-					return 0;
-				}
-			}
-		}
-	}
-	return 1;
-}
-
-uint8_t is_netascii_buf(char *buf, size_t len) {
-	for (uint64_t i = 0; i < len; i++) {
-		if (!is_netascii_char(buf[i])) {
-			return 0;
-		} else {
-			if (buf[i] == '\r') {
-				if ((i + 1) < len) {
-					switch (buf[++i]) {
-						case 0: case '\n':
-							break;
-						default:
-							return 0;
-					}
-				} else {
-					return 0;
-				}
-			}
-		}
-	}
-	return 1;
-}