+static const char *leafname(const char *path)
+{
+ const char *slash, *bslash;
+
+ slash = strrchr(path, '/');
+ bslash = strrchr(path, '\\');
+
+ if (slash && bslash) {
+ path = 1 + (slash > bslash ? slash : bslash);
+ } else if (slash) {
+ path = 1 + slash;
+ } else if (bslash) {
+ path = 1 + bslash;
+ }
+
+ return path;
+}
+
+static bool is_netascii(const char *str)
+{
+ for (; *str; ++str) {
+ if (*str < 0x20 || *str > 0x7f) {
+ return false;
+ }
+ }
+
+ return true;
+}
+