/*
- * $Id: pack.c,v 1.2 2005-04-28 20:49:48 bfernhomberg Exp $
+ * $Id: pack.c,v 1.6 2009-10-13 22:55:37 didg Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
#include <atalk/cnid_dbd_private.h>
#include "pack.h"
-#ifdef DEBUG
-/*
- * Auxiliary stuff for stringify_devino. See comments below.
- */
-static char hexchars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
-#endif
-
/* --------------- */
/*
* This implementation is portable, but could probably be faster by using htonl
}
/* --------------- */
-int didname(dbp, pkey, pdata, skey)
-DB *dbp _U_;
-const DBT *pkey _U_, *pdata;
-DBT *skey;
+int didname(DB *dbp _U_, const DBT *pkey _U_, const DBT *pdata, DBT *skey)
{
int len;
}
/* --------------- */
-int devino(dbp, pkey, pdata, skey)
-DB *dbp _U_;
-const DBT *pkey _U_, *pdata;
-DBT *skey;
+int devino(DB *dbp _U_, const DBT *pkey _U_, const DBT *pdata, DBT *skey)
{
memset(skey, 0, sizeof(DBT));
skey->data = (char *)pdata->data + CNID_DEVINO_OFS;
differ from make_cnid_data in that we never return NULL, rqst->name cannot
ever cause start[] to overflow because name length is checked in libatalk. */
-char *pack_cnid_data(struct cnid_dbd_rqst *rqst)
+unsigned char *pack_cnid_data(struct cnid_dbd_rqst *rqst)
{
- static char start[CNID_HEADER_LEN + MAXPATHLEN + 1];
- char *buf = start +CNID_LEN;
+ static unsigned char start[CNID_HEADER_LEN + MAXPATHLEN + 1];
+ unsigned char *buf = start +CNID_LEN;
u_int32_t i;
pack_devino(buf, rqst->dev, rqst->ino);
return start;
}
-#ifdef DEBUG
-
-/*
- * Whack 4 or 8 byte dev/ino numbers into something printable for DEBUG
- * logging. This function must not be used more that once per printf() style
- * invocation. This (or something improved) should probably migrate to
- * libatalk logging. Checking for printf() %ll support would be an alternative.
- */
-
-char *stringify_devino(dev_t dev, ino_t ino)
-{
- static char rbuf[CNID_DEV_LEN * 2 + 1 + CNID_INO_LEN * 2 + 1] = {0};
- char buf[CNID_DEV_LEN + CNID_INO_LEN];
- char *c1;
- char *c2;
- char *middle;
- char *end;
- int ci;
-
- pack_devino(buf, dev, ino);
-
- middle = buf + CNID_DEV_LEN;
- end = buf + CNID_DEV_LEN + CNID_INO_LEN;
- c1 = buf;
- c2 = rbuf;
-
- while (c1 < end) {
- if (c1 == middle) {
- *c2 = '/';
- c2++;
- }
- ci = *c1;
- c2[0] = hexchars[(ci & 0xf0) >> 4];
- c2[1] = hexchars[ci & 0x0f];
- c1++;
- c2 += 2;
- }
- return rbuf;
-}
-#endif