Add encode/decode macros for integers for use between kdb modules
authorPaul Park <pjpark@mit.edu>
Fri, 4 Aug 1995 20:31:20 +0000 (20:31 +0000)
committerPaul Park <pjpark@mit.edu>
Fri, 4 Aug 1995 20:31:20 +0000 (20:31 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6412 dc483132-0cff-0310-8789-dd5450dbe970

src/include/krb5/kdb.h

index d4fd56ec1d74897dfeb4bf5910b9bb13e519cc10..6aacf4f78614b40edb4ecbfd28fa7b1bcb7069f2 100644 (file)
@@ -135,6 +135,31 @@ typedef struct tl_data_2 {
 extern char *krb5_mkey_pwd_prompt1;
 extern char *krb5_mkey_pwd_prompt2;
 
+/*
+ * These macros specify the encoding of data within the database.
+ *
+ * Data encoding is little-endian.
+ */
+#define        krb5_kdb_decode_int16(cp, i16)  \
+       *((krb5_int16 *) &(i16)) = (((krb5_int16) ((unsigned char) (cp)[0]))| \
+                             ((krb5_int16) ((unsigned char) (cp)[1]) << 8))
+#define        krb5_kdb_decode_int32(cp, i32)  \
+       *((krb5_int32 *) &(i32)) = (((krb5_int32) ((unsigned char) (cp)[0]))| \
+                             ((krb5_int32) ((unsigned char) (cp)[1]) << 8) | \
+                             ((krb5_int32) ((unsigned char) (cp)[2]) << 16)| \
+                             ((krb5_int32) ((unsigned char) (cp)[3]) << 24))
+#define        krb5_kdb_encode_int16(i16, cp)  \
+       {                                                       \
+           (cp)[0] = (unsigned char) ((i16) & 0xff);           \
+           (cp)[1] = (unsigned char) (((i16) >> 8) & 0xff);    \
+       }
+#define        krb5_kdb_encode_int32(i32, cp)  \
+       {                                                       \
+           (cp)[0] = (unsigned char) ((i32) & 0xff);           \
+           (cp)[1] = (unsigned char) (((i32) >> 8) & 0xff);    \
+           (cp)[2] = (unsigned char) (((i32) >> 16) & 0xff);   \
+           (cp)[3] = (unsigned char) (((i32) >> 24) & 0xff);   \
+       }
 
 /* libkdb.spec */
 krb5_error_code krb5_db_set_name