Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / afsweb / apache_afs_cache.h
CommitLineData
805e021f
CE
1/*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
9
10#ifndef _APACHE_AFS_CACHE_H_INCLUDED_
11#define _APACHE_AFS_CACHE_H_INCLUDED_
12
13#include <stdio.h>
14#include "nsafs.h"
15
16#ifdef AIX
17#include <sys/types.h>
18#include <net/nh.h>
19#endif
20
21#ifndef MAX
22#define MAX(A,B) ((A)>(B)?(A):(B))
23#endif /* !MAX */
24#ifndef MIN
25#define MIN(A,B) ((A)<(B)?(A):(B))
26#endif /* !MAX */
27
28/*
29 * Macros to manipulate doubly linked lists
30 */
31
32#define DLL_INIT_LIST(_HEAD, _TAIL) \
33 { _HEAD = NULL ; _TAIL = NULL; }
34
35#define DLL_INSERT_TAIL(_ELEM, _HEAD, _TAIL, _NEXT, _PREV) \
36{ \
37 if (_HEAD == NULL) { \
38 _ELEM->_NEXT = NULL; \
39 _ELEM->_PREV = NULL; \
40 _HEAD = _ELEM; \
41 _TAIL = _ELEM; \
42 } else { \
43 _ELEM->_NEXT = NULL; \
44 _ELEM->_PREV = _TAIL; \
45 _TAIL->_NEXT = _ELEM; \
46 _TAIL = _ELEM; \
47 } \
48}
49
50#define DLL_DELETE(_ELEM, _HEAD, _TAIL, _NEXT, _PREV) \
51{ \
52 if (_ELEM->_NEXT == NULL) { \
53 _TAIL = _ELEM->_PREV; \
54 } else { \
55 _ELEM->_NEXT->_PREV = _ELEM->_PREV; \
56 } \
57 if (_ELEM->_PREV == NULL) { \
58 _HEAD = _ELEM->_NEXT; \
59 } else { \
60 _ELEM->_PREV->_NEXT = _ELEM->_NEXT; \
61 } \
62 _ELEM->_NEXT = NULL; \
63 _ELEM->_PREV = NULL; \
64}
65
66
67#define WEBLOG_BUFFER_SIZE 4096 /* Send/Receive buffer size */
68#define WEBLOG_MAX_PATH 1024 /* Maximum path length */
69#define WEBLOG_USERNAME_MAX 64 /* Maximum username length */
70#define WEBLOG_CELLNAME_MAX 64 /* Maximum password length */
71#define WEBLOG_PASSWORD_MAX 64
72#define WEBLOG_LOGIN_HASH_SIZE 1024 /* MUST be power of two */
73#define TEN_MINUTES 600 /* 10 minutes = 600 seconds */
74
75#define MAXBUFF 1024 /* CHECK THIS - size of token */
76/*
77 * Structure user to store entries in AFS login cache
78 */
79struct weblog_login {
80 afs_uint32 expiration;
81 char token[MAXBUFF];
82 int tokenLen;
83 char username[WEBLOG_USERNAME_MAX];
84 char cellname[WEBLOG_CELLNAME_MAX];
85 char cksum[SHA_HASH_BYTES];
86 struct weblog_login *next;
87 struct weblog_login *prev;
88};
89
90
91
92extern int weblog_login_hash(char *name, char *cell);
93extern void weblog_login_checksum(char *user, char *cell, char *passwd,
94 char *cksum);
95extern int weblog_login_lookup(char *user, char *cell, char *cksum,
96 char *token);
97extern int weblog_login_store(char *user, char *cell, char *cksum,
98 char *token, int tokenLen,
99 afs_uint32 expiration);
100extern int getTokenLen(char *token);
101
102#endif /* _APACHE_AFS_CACHE_H_INCLUDED_ */