[or-cvs] Parse and generate service descriptors
Nick Mathewson
nickm at seul.org
Wed Mar 31 02:04:08 UTC 2004
Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv9412/src/common
Modified Files:
crypto.c util.h
Log Message:
Parse and generate service descriptors
Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- crypto.c 30 Mar 2004 22:50:49 -0000 1.60
+++ crypto.c 31 Mar 2004 02:04:06 -0000 1.61
@@ -569,6 +569,7 @@
}
}
+/* return the size of the public key modulus in 'env', in bytes. */
int crypto_pk_keysize(crypto_pk_env_t *env)
{
assert(env && env->key);
Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- util.h 30 Mar 2004 22:59:00 -0000 1.43
+++ util.h 31 Mar 2004 02:04:06 -0000 1.44
@@ -49,13 +49,36 @@
*/
#define get_uint16(cp) (*(uint16_t*)(cp))
#define get_uint32(cp) (*(uint32_t*)(cp))
-#define set_uint16(cp,v) do { *(uint16_t)(cp) = (v) } while (0)
-#define set_uint32(cp,v) do { *(uint32_t)(cp) = (v) } while (0)
+#define set_uint16(cp,v) do { *(uint16_t*)(cp) = (v); } while (0)
+#define set_uint32(cp,v) do { *(uint32_t*)(cp) = (v); } while (0)
#else
+#if 1
uint16_t get_uint16(char *cp);
uint32_t get_uint32(char *cp);
void set_uint16(char *cp, uint16_t v);
void set_uint32(char *cp, uint32_t v);
+#else
+#define get_uint16(cp) \
+ ( ((*(((uint8_t*)(cp))+0))<<8) + \
+ ((*(((uint8_t*)(cp))+1)) ) )
+#define get_uint32(cp) \
+ ( ((*(((uint8_t*)(cp))+0))<<24) + \
+ ((*(((uint8_t*)(cp))+1))<<16) + \
+ ((*(((uint8_t*)(cp))+2))<<8 ) + \
+ ((*(((uint8_t*)(cp))+3)) ) )
+#define set_uint16(cp,v) \
+ do { \
+ *(((uint8_t*)(cp))+0) = (v >> 8)&0xff; \
+ *(((uint8_t*)(cp))+1) = (v >> 0)&0xff; \
+ } while (0)
+#define set_uint32(cp,v) \
+ do { \
+ *(((uint8_t*)(cp))+0) = (v >> 24)&0xff; \
+ *(((uint8_t*)(cp))+1) = (v >> 16)&0xff; \
+ *(((uint8_t*)(cp))+2) = (v >> 8)&0xff; \
+ *(((uint8_t*)(cp))+3) = (v >> 0)&0xff; \
+ } while (0)
+#endif
#endif
typedef struct {
More information about the tor-commits
mailing list