diff options
author | Karl Ramm <kcr@mit.edu> | 2007-12-25 05:37:11 +0000 |
---|---|---|
committer | Karl Ramm <kcr@mit.edu> | 2007-12-25 05:37:11 +0000 |
commit | 627ed4a556b987aba5452199ec6f7931dec944fe (patch) | |
tree | 47312625d2deea3441ab7e3c0f2a7d3ba95164b2 /lib/ZReadZcode.c | |
parent | 75b16e5d8122b87a3dc301c692529d7e9594c8b8 (diff) |
these should have been added when the branch was merged. *sigh*
Diffstat (limited to 'lib/ZReadZcode.c')
-rw-r--r-- | lib/ZReadZcode.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/ZReadZcode.c b/lib/ZReadZcode.c new file mode 100644 index 0000000..ed3a283 --- /dev/null +++ b/lib/ZReadZcode.c @@ -0,0 +1,66 @@ +/* This file is part of the Project Athena Zephyr Notification System. + * It contains source for the ZReadZcode function. + * + * Created by: Jeffrey Hutzelman + * + * $Id$ + * + * Copyright (c) 1987, 1990, 2002 by the Massachusetts Institute of Technology. + * For copying and distribution information, see the file + * "mit-copyright.h". + */ + +#ifndef lint +static char rcsid_ZReadZcode_c[] = "$Id$"; +#endif /* lint */ + +#include <internal.h> +#include <assert.h> + + +#if 0 +Code_t +ZReadAsciiOrZcode(char *buf, int buflen, unsigned char *data, int datalen) +{ + if (buf[0] == 'Z') + return ZReadZcode(buf, buflen, data, datalen); + else + return ZReadAscii(buf, buflen, data, datalen); +} + +Code_t ZReadZcode32(ptr, value_ptr) + unsigned char *ptr; + unsigned long *value_ptr; +{ + abort(); +} +#endif + +Code_t ZReadZcode(ptr, field, max, len) + unsigned char *ptr; + unsigned char *field; + int max; + int *len; +{ + int n = 0; + + if (*ptr++ != 'Z') + return ZERR_BADFIELD; + + while (*ptr && n < max) { + if (*ptr == 0xff) { + ptr++; + switch (*ptr++) { + case 0xf0: field[n++] = 0x00; continue; + case 0xf1: field[n++] = 0xff; continue; + default: return ZERR_BADFIELD; + } + } else { + field[n++] = *ptr++; + } + } + if (*ptr) + return (ZERR_BADFIELD); + *len = n; + return (ZERR_NONE); +} |