-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutils.c
More file actions
44 lines (34 loc) · 731 Bytes
/
Copy pathbutils.c
File metadata and controls
44 lines (34 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Copyright (c) 2000-2004,2005 by Inlab Software GmbH, Gruenwald, Germany.
* All rights reserved.
*
*/
/*
* $Id: butils.c,v 1.1 2010/01/29 10:40:16 t Exp $
*/
#include <balance.h>
char* butils_rcsid="$Id: butils.c,v 1.1 2010/01/29 10:40:16 t Exp $";
unsigned int hash_fold(char* s, int len)
{
unsigned int rc = 0;
int i;
for (i=0; i<len; i++) {
rc = s[i] + 31 * rc;
}
return(rc);
}
ssize_t writen(int fd, unsigned char *ptr, size_t nbytes)
{
int nleft;
ssize_t nwritten;
nleft = nbytes;
while (nleft > 0) {
nwritten = write(fd, ptr, nleft);
if (nwritten <= 0) {
return (nwritten); /* error */
}
nleft -= nwritten;
ptr += nwritten;
}
return (nbytes - nleft);
}