diff options
author | Jay Threeth | 2011-04-04 11:48:26 -0700 |
---|---|---|
committer | Jay Threeth | 2011-04-04 11:48:26 -0700 |
commit | 3c9cc506f741b980565ff5b3b001cd8b6ee36b12 (patch) | |
tree | cb862c57b3d5f74177cde3bd962a53fc377166f6 /linden/indra/libotr/libotr-3.2.0/src/serial.h | |
parent | build fixes, might build on linux now (diff) | |
download | meta-impy-3c9cc506f741b980565ff5b3b001cd8b6ee36b12.zip meta-impy-3c9cc506f741b980565ff5b3b001cd8b6ee36b12.tar.gz meta-impy-3c9cc506f741b980565ff5b3b001cd8b6ee36b12.tar.bz2 meta-impy-3c9cc506f741b980565ff5b3b001cd8b6ee36b12.tar.xz |
add source to libraries, and cruft for building under windows
Diffstat (limited to 'linden/indra/libotr/libotr-3.2.0/src/serial.h')
-rwxr-xr-x | linden/indra/libotr/libotr-3.2.0/src/serial.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/linden/indra/libotr/libotr-3.2.0/src/serial.h b/linden/indra/libotr/libotr-3.2.0/src/serial.h new file mode 100755 index 0000000..edc3184 --- /dev/null +++ b/linden/indra/libotr/libotr-3.2.0/src/serial.h | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * Off-the-Record Messaging library | ||
3 | * Copyright (C) 2004-2008 Ian Goldberg, Chris Alexander, Nikita Borisov | ||
4 | * <otr@cypherpunks.ca> | ||
5 | * | ||
6 | * This library is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of version 2.1 of the GNU Lesser General | ||
8 | * Public License as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This library is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * Lesser General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #ifndef __SERIAL_H__ | ||
21 | #define __SERIAL_H__ | ||
22 | |||
23 | #undef DEBUG | ||
24 | |||
25 | #ifdef DEBUG | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #define debug_data(t,b,l) do { const unsigned char *data = (b); size_t i; \ | ||
30 | fprintf(stderr, "%s: ", (t)); \ | ||
31 | for(i=0;i<(l);++i) { \ | ||
32 | fprintf(stderr, "%02x", data[i]); \ | ||
33 | } \ | ||
34 | fprintf(stderr, "\n"); \ | ||
35 | } while(0) | ||
36 | |||
37 | #define debug_int(t,b) do { const unsigned char *data = (b); \ | ||
38 | unsigned int v = \ | ||
39 | (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; \ | ||
40 | fprintf(stderr, "%s: %u (0x%x)\n", (t), v, v); \ | ||
41 | } while(0) | ||
42 | |||
43 | #else | ||
44 | #define debug_data(t,b,l) | ||
45 | #define debug_int(t,b) | ||
46 | #endif | ||
47 | |||
48 | #define write_int(x) do { \ | ||
49 | bufp[0] = ((x) >> 24) & 0xff; \ | ||
50 | bufp[1] = ((x) >> 16) & 0xff; \ | ||
51 | bufp[2] = ((x) >> 8) & 0xff; \ | ||
52 | bufp[3] = (x) & 0xff; \ | ||
53 | bufp += 4; lenp -= 4; \ | ||
54 | } while(0) | ||
55 | |||
56 | #define write_mpi(x,nx,dx) do { \ | ||
57 | write_int(nx); \ | ||
58 | gcry_mpi_print(format, bufp, lenp, NULL, (x)); \ | ||
59 | debug_data((dx), bufp, (nx)); \ | ||
60 | bufp += (nx); lenp -= (nx); \ | ||
61 | } while(0) | ||
62 | |||
63 | #define require_len(l) do { \ | ||
64 | if (lenp < (l)) goto invval; \ | ||
65 | } while(0) | ||
66 | |||
67 | #define read_int(x) do { \ | ||
68 | require_len(4); \ | ||
69 | (x) = (bufp[0] << 24) | (bufp[1] << 16) | (bufp[2] << 8) | bufp[3]; \ | ||
70 | bufp += 4; lenp -= 4; \ | ||
71 | } while(0) | ||
72 | |||
73 | #define read_mpi(x) do { \ | ||
74 | size_t mpilen; \ | ||
75 | read_int(mpilen); \ | ||
76 | if (mpilen) { \ | ||
77 | require_len(mpilen); \ | ||
78 | gcry_mpi_scan(&(x), GCRYMPI_FMT_USG, bufp, mpilen, NULL); \ | ||
79 | } else { \ | ||
80 | (x) = gcry_mpi_set_ui(NULL, 0); \ | ||
81 | } \ | ||
82 | bufp += mpilen; lenp -= mpilen; \ | ||
83 | } while(0) | ||
84 | |||
85 | #endif | ||