aboutsummaryrefslogtreecommitdiff
path: root/nls.h
diff options
context:
space:
mode:
authorEduardo Casino <mail@eduardocasino.es>2022-05-16 20:12:19 +0200
committerJavier <dev.git@javispedro.com>2022-05-23 00:01:55 +0200
commit7b243074da3f4be6ed47426925f203c547c1c729 (patch)
treee200ebfbf6d3912458db78d26da4fb152bc1c4bb /nls.h
parentb8eb74ac1d31ffc382e654e19bba4e5e48f0001e (diff)
downloadvbados-7b243074da3f4be6ed47426925f203c547c1c729.tar.gz
vbados-7b243074da3f4be6ed47426925f203c547c1c729.zip
Add support for windows host short file names
Diffstat (limited to 'nls.h')
-rw-r--r--nls.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/nls.h b/nls.h
new file mode 100644
index 0000000..9699bb1
--- /dev/null
+++ b/nls.h
@@ -0,0 +1,78 @@
+/*
+ * VBSF - NLS support functions
+ * Copyright (C) 2011-2022 Eduardo Casino
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General License for more details.
+ *
+ * You should have received a copy of the GNU General License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef NLS_H
+#define NLS_H
+
+static bool illegal_char( unsigned char c )
+{
+ int i= 0;
+
+ for ( i= 0; i < data.file_char->n_illegal; ++i )
+ {
+ if ( c == data.file_char->illegal[i] )
+ {
+ return true;
+ }
+ }
+ if ( ( c < data.file_char->lowest || c > data.file_char->highest ) ||
+ !( c < data.file_char->first_x || c > data.file_char->last_x ) )
+ {
+ return true;
+ }
+
+ return false;
+}
+
+static unsigned char nls_toupper( unsigned char c )
+{
+ if ( c > 0x60 && c < 0x7b )
+ {
+ return c & 0xDF;
+ }
+
+ return ( c < 0x80 ? c : data.file_upper_case[c - 0x80] );
+}
+
+static inline void nls_uppercase(SHFLSTRING *str)
+{
+ int i;
+
+ for (i= 0; i < str->u16Length; ++i)
+ {
+ str->ach[i] = nls_toupper(str->ach[i]);
+ }
+}
+
+static inline bool valid_8_3_file_chars(char __far *fname )
+{
+ int i;
+
+ for (i = 0; i < 11; ++i)
+ {
+ if ( fname[i] != ' ' && illegal_char(fname[i]) )
+ {
+ break;
+ }
+ }
+
+ return ( i == 11 );
+}
+
+#endif // NLS_H