diff --git a/AI.md b/AI.md index 7c33da3..c1e85fb 100644 --- a/AI.md +++ b/AI.md @@ -1,9 +1,9 @@ # AI working notes for mars-nwe -## Current handoff status after NSS low-level imports 0404-0410 +## Current handoff status after NSS low-level imports 0404-0412 Current accepted MARS-NWE server line in this work session includes the NSS -low-level libnwcore imports through `0410`: +low-level libnwcore imports through `0412`: - `0404` imports NSS `bitmap.c` directly as `src/core/bitmap.c`. - `0405` moves the imported bitmap/NSS base headers directly into @@ -21,9 +21,18 @@ low-level libnwcore imports through `0410`: - `0410` imports NSS `xUnicode.h`, `unitolower.c`, and `utf_tolower.c` directly into libnwcore and removes the private `crc.c` lowercase fallback. The exported `NSSUniToLower[]` table is now present in libnwcore with the same - ASCII-compatible initialization as the old fallback; the full NSS Unicode - converter/table startup from `public_core/library/unicode/unicodeInit.c` is - still a separate follow-up because it pulls in the NetWare/libc converter + ASCII-compatible initialization as the old fallback. +- `0411` extends the direct NSS Unicode helper import with `unitoupper.c`, + `unilwr.c`, `uniupr.c`, `uniicmp.c`, `uniicmpmac.c`, and `uninicmp.c` in + libnwcore; `unicodeInit.c` now exports both `NSSUniToLower[]` and + `NSSUniToUpper[]` with the same ASCII-compatible bootstrap. +- `0412` imports the NSS Unicode string helper block into libnwcore: + `componentUnicpy.c`, `componentUnilen.c`, `unicat.c`, `unicmp.c`, `unicpy.c`, + `unilen.c`, and `unimcpy.c`, with their matching sharedsrc implementation + headers kept local to `src/core/`. This keeps the original NSS `LB_*` API + names available before replacing older MARS Unicode/string helpers. The full + NSS Unicode converter/table startup from `public_core/library/unicode/unicodeInit.c` + is still a separate follow-up because it pulls in the NetWare/libc converter runtime. Keep future NSS low-level imports directly under `src/core/.c` and @@ -2444,3 +2453,11 @@ logs/archives are usually copied or uploaded later by a normal desktop user. `libnwcore`; `unicodeInit.c` now exports both `NSSUniToLower[]` and `NSSUniToUpper[]` with the same ASCII-compatible bootstrap until the full NSS converter/table startup is imported. + +- `0412` imports the next safe NSS Unicode library block into `libnwcore`: the + component/string helpers `componentUnicpy.c`, `componentUnilen.c`, `unicat.c`, + `unicmp.c`, `unicpy.c`, `unilen.c`, and `unimcpy.c`. Their sharedsrc + implementation headers (`*.c.h`) are kept local under `src/core/` and are not + installed as public API. No MARS callsites are switched yet; this is a + prerequisite for replacing the older hand-written MARS Unicode/string code + piece by piece with NSS-compatible primitives. diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 15c8cad..284fae0 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -85,6 +85,13 @@ set(NWCORE_IMPORTED_NSS_SOURCES bit.c crc.c hash.c + componentUnicpy.c + componentUnilen.c + unicat.c + unicmp.c + unicpy.c + unilen.c + unimcpy.c unicodeInit.c unitolower.c unitoupper.c diff --git a/src/core/componentUnicpy.c b/src/core/componentUnicpy.c new file mode 100644 index 0000000..e986e44 --- /dev/null +++ b/src/core/componentUnicpy.c @@ -0,0 +1,59 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | 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 Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine + +-------------------------------------------------------------------------*/ +#include + + +/************************************************************************** + * Copy string s2 to s1. s1 must be large enough. + * return s1 + ***************************************************************************/ +unicode_t *LB_componentUnicpy( + unicode_t *dest, + CONST unicode_t *src) +{ + unicode_t *odest = dest; + + /* Copy all components until a NULL component is encountered */ + while (*src) + { + /* Copy next individual component, including it's NULL */ + while( (*dest++ = *src++) != (unicode_t)0 ) + ; + } + *dest = 0; + return(odest); +} diff --git a/src/core/componentUnilen.c b/src/core/componentUnilen.c new file mode 100644 index 0000000..728d30d --- /dev/null +++ b/src/core/componentUnilen.c @@ -0,0 +1,56 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | 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 Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This is a temporary routine to emulate what the real unicode_t + | routines will do. + +-------------------------------------------------------------------------*/ +#include + +/************************************************************************** + * Returns the number of characters in the string + ***************************************************************************/ +size_t LB_componentUnilen( + CONST unicode_t *s) +{ + size_t size; + size_t totalSize = 0; + + while (*s) + { + size = unilen(s); + totalSize += (size+1); + s += (size+1); + } + return(totalSize); +} diff --git a/src/core/unicat.c b/src/core/unicat.c new file mode 100644 index 0000000..9e30303 --- /dev/null +++ b/src/core/unicat.c @@ -0,0 +1 @@ +#include "unicat.c.h" diff --git a/src/core/unicat.c.h b/src/core/unicat.c.h new file mode 100644 index 0000000..7d1e171 --- /dev/null +++ b/src/core/unicat.c.h @@ -0,0 +1,87 @@ +/**************************************************************************** + | + | (C) Copyright 1999, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | 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 Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2005-04-05 22:42:53 +0530 (Tue, 05 Apr 2005) $ + | + | $RCSfile$ + | $Revision: 905 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine code taken from LibC in August 2003 + +-------------------------------------------------------------------------*/ +#include + +unicode_t *LB_unicat +( + register unicode_t *t, + register const unicode_t *s +) +{ + unicode_t *base = t; + + while (*t++) + ; + + t--; + + while ( (*t++ = *s++) != (unicode_t)0 ) + ; + + return base; +} + +unicode_t *LB_unincat +( + register unicode_t *t, + register const unicode_t *s, + register size_t n +) +{ + unicode_t *base = t; + + if (n > 0) + { + n++; + + while (*t++) + ; + + t--; + + while ( (*t++ = *s++) != (unicode_t)0 ) + { + if (--n == 0) + { + *(t - 1) = 0x0000; + break; + } + } + } + + return base; +} diff --git a/src/core/unicmp.c b/src/core/unicmp.c new file mode 100644 index 0000000..4967e4f --- /dev/null +++ b/src/core/unicmp.c @@ -0,0 +1 @@ +#include "unicmp.c.h" diff --git a/src/core/unicmp.c.h b/src/core/unicmp.c.h new file mode 100644 index 0000000..0d98bd8 --- /dev/null +++ b/src/core/unicmp.c.h @@ -0,0 +1,75 @@ +/**************************************************************************** + | + | (C) Copyright 1999, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | 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 Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine code taken from LibC in August 2003 + +-------------------------------------------------------------------------*/ +#include + +int LB_unicmp +( + const unicode_t *s1, + const unicode_t *s2 +) +{ + while (*s1 == *s2 && *s1) + { + s1++; + s2++; + } + + return (*s1 - *s2); +} + +int LB_unincmp +( + register const unicode_t *s1, + register const unicode_t *s2, + register size_t n +) +{ + n++; + + if (s1 == s2) + return 0; + + while (--n != 0 && *s1 == *s2) + { + if (!*s1) + return 0; + + s1++; s2++; + } + + return ((n == 0) ? 0 : (*s1 - *s2)); +} diff --git a/src/core/unicpy.c b/src/core/unicpy.c new file mode 100644 index 0000000..b3c2d9c --- /dev/null +++ b/src/core/unicpy.c @@ -0,0 +1 @@ +#include "unicpy.c.h" diff --git a/src/core/unicpy.c.h b/src/core/unicpy.c.h new file mode 100644 index 0000000..2a307ea --- /dev/null +++ b/src/core/unicpy.c.h @@ -0,0 +1,123 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996, 1999, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | 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 Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine + +-------------------------------------------------------------------------*/ +#include + +/************************************************************************** + * Copy string s2 to s1. s1 must be large enough. + * return s1 + ***************************************************************************/ +unicode_t *LB_unicpy( + unicode_t *dest, + const unicode_t *src) +{ + unicode_t *odest = dest; + + while( (*dest++ = *src++) != (unicode_t)0 ) + ; + return(odest); +} + + +/* From LibC Sources */ +unicode_t *LB_unincpy +( + register unicode_t *t, + register const unicode_t *s, + register size_t n +) +{ + register unicode_t *base = t; + + n++; + + while (--n > 0 && (*t++ = *s++)) + ; + + if (n > 0) + { + while (--n > 0) + *t++ = 0x0000; + } + + return base; +} + + +/* From LibC Sources */ +unicode_t *LB_unichr +( + register const unicode_t *sp, + register unicode_t ch +) +{ +/* +** Return the point in 'sp' at which the character ch appears or nil if +** not found. +*/ + do + { + if (*sp == ch) + return (unicode_t *) sp; + } + while (*sp++); + + return (unicode_t *) NULL; +} + + +/* From LibC Sources */ +unicode_t *LB_unirchr +( + register const unicode_t *sp, + register unicode_t ch +) +{ + register const unicode_t *r = (const unicode_t *) NULL; + +/* +** Return the ptr in sp at which the character ch last appears; NULL if +** not found. +*/ + do + { + if (*sp == ch) + r = sp; + } + while (*sp++); + + return (unicode_t *) r; +} diff --git a/src/core/unilen.c b/src/core/unilen.c new file mode 100644 index 0000000..ed77a6e --- /dev/null +++ b/src/core/unilen.c @@ -0,0 +1 @@ +#include "unilen.c.h" diff --git a/src/core/unilen.c.h b/src/core/unilen.c.h new file mode 100644 index 0000000..2b5756e --- /dev/null +++ b/src/core/unilen.c.h @@ -0,0 +1,58 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | 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 Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2005-04-05 22:42:53 +0530 (Tue, 05 Apr 2005) $ + | + | $RCSfile$ + | $Revision: 905 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This is a temporary routine to emulate what the real unicode_t + | routines will do. + +-------------------------------------------------------------------------*/ +#include +#if defined(_WATCOMC_) +#include +#endif + +/************************************************************************** + * Returns the number of characters in the string + ***************************************************************************/ +size_t LB_unilen( + const unicode_t *s) +{ +#if !defined(_WATCOMC_) + const unicode_t *s0 = s; + + while (*s != 0) + s++; + return (s - s0); +#else + return inline_unilen(s); +#endif +} diff --git a/src/core/unimcpy.c b/src/core/unimcpy.c new file mode 100644 index 0000000..918cae1 --- /dev/null +++ b/src/core/unimcpy.c @@ -0,0 +1 @@ +#include "unimcpy.c.h" diff --git a/src/core/unimcpy.c.h b/src/core/unimcpy.c.h new file mode 100644 index 0000000..d90c72e --- /dev/null +++ b/src/core/unimcpy.c.h @@ -0,0 +1,65 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | 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 Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This is a temporary routine to emulate what the real unicode_t + | routines will do. + +-------------------------------------------------------------------------*/ +#include + +/************************************************************************** + * This will copy the source string to the destination string and will + * not overflow the destination buffer. This will guarentee there is a + * null at the end of the destination string. This returns a pointer to + * the front of the destination string. + ***************************************************************************/ +unicode_t *LB_unimcpy( + unicode_t *dest, + CONST unicode_t *src, + size_t destSize) /* sizeof the destination buffer in UNICODE chars*/ +{ + unicode_t *ldest = dest; + if (destSize == 0) + { + return(dest); + } + for (;;) { + if (--destSize <= 0) { + *ldest = 0; + break; + } + if ((*ldest++ = (unicode_t)*src++) == 0) + break; + } + return dest; +}