ntlmssp: add string helper functions to handle OEM and UNICODE charset.
authorGünther Deschner <gd@samba.org>
Thu, 13 Aug 2009 22:48:58 +0000 (00:48 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 28 Aug 2009 08:05:00 +0000 (10:05 +0200)
Guenther

librpc/ndr/ndr_ntlmssp.c
librpc/ndr/ndr_ntlmssp.h

index db9a717c23a7a32f4f41d69a26658b6c5fb1c82a..115c7abd02e4b5119609a8a74ee9444abd06cd3b 100644 (file)
 */
 
 #include "includes.h"
+#include "../librpc/ndr/ndr_ntlmssp.h"
 
+_PUBLIC_ size_t ndr_ntlmssp_string_length(uint32_t negotiate_flags, const char *s)
+{
+       if (!s) {
+               return 0;
+       }
+
+       if (negotiate_flags & NTLMSSP_NEGOTIATE_UNICODE) {
+               return strlen(s) * 2;
+       }
+
+       return strlen(s);
+}
+
+_PUBLIC_ uint32_t ndr_ntlmssp_negotiated_string_flags(uint32_t negotiate_flags)
+{
+       uint32_t flags = LIBNDR_FLAG_STR_NOTERM |
+                        LIBNDR_FLAG_STR_CHARLEN |
+                        LIBNDR_FLAG_REMAINING;
+
+       if (!(negotiate_flags & NTLMSSP_NEGOTIATE_UNICODE)) {
+               flags |= LIBNDR_FLAG_STR_ASCII;
+       }
+
+       return flags;
+}
index 753fa5025601740394c07dabaa83db3c44ff89d0..ef00a2e347dcd2b17f4e45eb12dd2c8320354501 100644 (file)
@@ -18,3 +18,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
+
+_PUBLIC_ size_t ndr_ntlmssp_string_length(uint32_t negotiate_flags, const char *s);
+_PUBLIC_ uint32_t ndr_ntlmssp_negotiated_string_flags(uint32_t negotiate_flags);
+