/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*/
-
#include <afsconfig.h>
#include <afs/param.h>
+#include <afs/stds.h>
+#include <roken.h>
/*
* (3) Define a structure, idused, instead of an
* conditions.
*/
-#include <afs/stds.h>
-#include <sys/types.h>
+
#ifdef AFS_NT40_ENV
-#include <winsock2.h>
#include <WINNT/afsevent.h>
-#include <io.h>
#else
-#include <netdb.h>
-#include <netinet/in.h>
#include <sys/file.h>
#endif
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
+
#include <afs/cellconfig.h>
#include <afs/afsutil.h>
#include <ubik.h>
}
static afs_int32
-NameHash(register char *aname)
+NameHash(char *aname)
{
/* returns hash bucket for aname */
- register unsigned int hash = 0;
- register int i;
+ unsigned int hash = 0;
+ int i;
/* stolen directly from the HashString function in the vol package */
for (i = strlen(aname), aname += i - 1; i--; aname--)
hash = (hash * 31) + (*(unsigned char *)aname - 31);
/* now read the info */
r = read(fd, &uheader, sizeof(uheader));
if (r != sizeof(uheader)) {
- printf("error: read of %lu bytes failed: %d %d\n", sizeof(uheader), r,
- errno);
+ printf("error: read of %" AFS_SIZET_FMT " bytes failed: %d %d\n",
+ sizeof(uheader), r, errno);
return (-1);
}
uheader.magic = ntohl(uheader.magic);
- uheader.size = ntohl(uheader.size);
+ uheader.size = ntohs(uheader.size);
uheader.version.epoch = ntohl(uheader.version.epoch);
uheader.version.counter = ntohl(uheader.version.counter);
int noErrors = 1;
int length; /* length of chain */
#if defined(SUPERGROUPS)
- int sgcount; /* number of sgentrys */
+ int sgcount = 0; /* number of sgentrys */
afs_int32 sghead;
#define g (((struct prentryg *)e))
#endif
eid = ntohl(e->id);
bit = MAP_CONT;
#if defined(SUPERGROUPS)
- sgcount = 0;
sghead = ntohl(g->next);
#endif
for (i = 0; i < PRSIZE; i++) {
id = ntohl(e.id);
#if defined(SUPERGROUPS)
if ((id != ANONYMOUSID)
- && ((refCount = idcount(&misc->idmap, id)) != ntohl(e.count)))
+ && ((refCount = idcount(&misc->idmap, id)) != ntohl(e.count)))
#else
if ((id >= misc->minId) && (id <= misc->maxId)
&& (id != ANONYMOUSID)
&& ((refCount = misc->idmap[id - misc->minId]) !=
- ntohl(e.count)))
+ ntohl(e.count)))
#endif /* SUPERGROUPS */
{
afs_int32 na;
{
char *qs;
if (strpbrk(s, " \t")) {
- qs = (char *)malloc(strlen(s) + 3);
- strcpy(qs, "\"");
- strcat(qs, s);
- strcat(qs, "\"");
+ asprintf(&qs, "\"%s\"", s);
} else
qs = s;
return qs;
/* check for duplicate id. This may still lead to duplicate
* names. */
#if defined(SUPERGROUPS)
- if (idcount(&idmap, id))
+ if (idcount(&idmap, id))
#else
- if (idmap[id - misc->minId])
+ if (idmap[id - misc->minId])
#endif
{
fprintf(stderr, "Skipping entry with duplicate id %di\n",
owner = ntohl(e.owner);
#if defined(SUPERGROUPS)
- if (!idcount(&idmap, owner))
+ if (!idcount(&idmap, owner))
#else
- if (idmap[owner - misc->minId] == 0)
+ if (idmap[owner - misc->minId] == 0)
#endif
{
fprintf(stderr,
if ((id < 0) && (flags & PRGRP)) {
int count = 0;
afs_int32 na;
-#if defined(SUPERGROUPS)
- afs_int32 ng;
-#endif
int i;
for (i = 0; i < PRSIZE; i++) {
afs_int32 uid = ntohl(e.entries[i]);
id);
#endif
}
-#if defined(SUPERGROUPS)
-#define g (*((struct prentryg *)&e))
- ng = ntohl(g.nextsg);
- for (i = 0; i < SGSIZE; i++) {
- afs_int32 uid = ntohl(g.supergroup[i]);
- if (uid == 0)
- break;
- if (uid == PRBADID)
- continue;
- fprintf(rc, "au %d %d\n", uid, id);
- count++;
- }
- while (ng) {
- struct prentry c;
- code = pr_Read(ng, (char *)&c, sizeof(c));
- if (code)
- return code;
-
- if ((id == ntohl(c.id)) && (c.flags & htonl(PRCONT))) {
- for (i = 0; i < COSIZE; i++) {
- afs_int32 uid = ntohl(c.entries[i]);
- if (uid == 0)
- break;
- if (uid == PRBADID)
- continue;
- fprintf(rc, "au %d %d\n", uid, id);
- count++;
- }
- } else {
- fprintf(stderr, "Skipping continuation block at %d\n",
- ng);
- break;
- }
- ng = ntohl(c.next);
- }
-#undef g
-#endif /* SUPERGROUPS */
na = ntohl(e.next);
while (na) {
struct prentry c;
n = eof / sizeof(struct prentry);
if ((eof < 0) || (n * sizeof(struct prentry) != eof)) {
code = PRDBBAD;
- afs_com_err(whoami, code, "eof ptr no good: eof=%d, sizeof(prentry)=%d",
+ afs_com_err(whoami, code,
+ "eof ptr no good: eof=%d, sizeof(prentry)=%" AFS_SIZET_FMT,
eof, sizeof(struct prentry));
abort:
return code;
free(map);
return code;
}
-
+
#include "AFS_component_version_number.c"
int
zeromap(struct idused *idmap)
{
while (idmap) {
- memset((char *)idmap->idcount, 0, sizeof idmap->idcount);
+ memset(idmap->idcount, 0, sizeof idmap->idcount);
idmap = idmap->idnext;
}
}
fprintf(stderr, "IDCOUNT must be power of 2!\n");
exit(1);
}
- while (idmap = *idmapp) {
+ while ((idmap = *idmapp) != NULL) {
if (idmap->idstart == (id & ~(IDCOUNT - 1)))
break;
idmapp = &idmap->idnext;
perror("idmap");
exit(1);
}
- memset((char *)idmap, 0, sizeof idmap);
+ memset(idmap, 0, sizeof idmap);
idmap->idstart = id & ~(IDCOUNT - 1);
idmap->idnext = *idmapp;
*idmapp = idmap;
fprintf(stderr, "IDCOUNT must be power of 2!\n");
exit(1);
}
- while (idmap = *idmapp) {
+ while ((idmap = *idmapp) != NULL) {
if (idmap->idstart == (id & ~(IDCOUNT - 1))) {
return idmap->idcount[id & (IDCOUNT - 1)];
}