Move UCS2 macros to common code
authorJelmer Vernooij <jelmer@samba.org>
Fri, 25 Jun 2010 19:51:23 +0000 (21:51 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 25 Jun 2010 20:48:59 +0000 (22:48 +0200)
lib/util/charset/charset.h
source3/include/smb.h

index cc57b3eb542e9bf9e00450d5f52c13bf0df80022..68907aa59303d4a05236311d73d05ae5e104ccf6 100644 (file)
@@ -39,6 +39,29 @@ typedef enum {CH_UTF16LE=0, CH_UTF16=0, CH_UNIX, CH_DISPLAY, CH_DOS, CH_UTF8, CH
 
 typedef uint16_t smb_ucs2_t;
 
+/*
+ * SMB UCS2 (16-bit unicode) internal type.
+ * smb_ucs2_t is *always* in little endian format.
+ */
+
+#ifdef WORDS_BIGENDIAN
+#define UCS2_SHIFT 8
+#else
+#define UCS2_SHIFT 0
+#endif
+
+/* turn a 7 bit character into a ucs2 character */
+#define UCS2_CHAR(c) ((c) << UCS2_SHIFT)
+
+/* return an ascii version of a ucs2 character */
+#define UCS2_TO_CHAR(c) (((c) >> UCS2_SHIFT) & 0xff)
+
+/* Copy into a smb_ucs2_t from a possibly unaligned buffer. Return the copied smb_ucs2_t */
+#define COPY_UCS2_CHAR(dest,src) (((unsigned char *)(dest))[0] = ((unsigned char *)(src))[0],\
+                               ((unsigned char *)(dest))[1] = ((unsigned char *)(src))[1], (dest))
+
+
+
 /*
  *   for each charset we have a function that pulls from that charset to
  *     a ucs2 buffer, and a function that pushes to a ucs2 buffer
index 3cbd0c082dc344edd2a085bbaba6da8e756fd693..defecd7c88aa866f0929c29167e5d7ba8f2c9655 100644 (file)
@@ -144,27 +144,6 @@ typedef union unid_t {
        gid_t gid;
 } unid_t;
 
-/*
- * SMB UCS2 (16-bit unicode) internal type.
- * smb_ucs2_t is *always* in little endian format.
- */
-
-#ifdef WORDS_BIGENDIAN
-#define UCS2_SHIFT 8
-#else
-#define UCS2_SHIFT 0
-#endif
-
-/* turn a 7 bit character into a ucs2 character */
-#define UCS2_CHAR(c) ((c) << UCS2_SHIFT)
-
-/* return an ascii version of a ucs2 character */
-#define UCS2_TO_CHAR(c) (((c) >> UCS2_SHIFT) & 0xff)
-
-/* Copy into a smb_ucs2_t from a possibly unaligned buffer. Return the copied smb_ucs2_t */
-#define COPY_UCS2_CHAR(dest,src) (((unsigned char *)(dest))[0] = ((unsigned char *)(src))[0],\
-                               ((unsigned char *)(dest))[1] = ((unsigned char *)(src))[1], (dest))
-
 /* pipe string names */
 #define PIPE_LANMAN   "\\PIPE\\LANMAN"