Coda Distributed File System
util.h
Go to the documentation of this file.
1/* BLURB gpl
2
3 Coda File System
4 Release 6
5
6 Copyright (c) 1987-2003 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU General Public Licence Version 2, as shown in the
11file LICENSE. The technical and financial contributors to Coda are
12listed in the file CREDITS.
13
14 Additional copyrights
15
16#*/
17
18/*
19 IBM COPYRIGHT NOTICE
20
21 Copyright (C) 1986
22 International Business Machines Corporation
23 All Rights Reserved
24
25This file contains some code identical to or derived from the 1986
26version of the Andrew File System ("AFS"), which is owned by the IBM
27Corporation. This code is provided "AS IS" and IBM does not warrant
28that it is free of infringement of any intellectual rights of any
29third party. IBM disclaims liability of any kind for any damages
30whatsoever resulting directly or indirectly from use of this software
31or of any derivative work. Carnegie Mellon University has obtained
32permission to modify, distribute and sublicense this code, which is
33based on Version 2 of AFS and does not contain the features and
34enhancements that are part of Version 3 of AFS. Version 3 of AFS is
35commercially available and supported by Transarc Corporation,
36Pittsburgh, PA.
37
38*/
39
40#include "coda_assert.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#include <unistd.h>
47#include <stdlib.h>
48#include <signal.h>
49#include <stdio.h>
50
51#ifndef IN /* rpc2.private.h also defines these */
52/* Parameter usage */
53#define IN /* Input parameter */
54#define OUT /* Output parameter */
55#define INOUT /* Obvious */
56#endif /* !IN */
57
58#define TRUE 1
59#define FALSE 0
60
61/* Useful functions in libutil.a */
62int HashString(char *s, unsigned int size);
63void eprint(const char *, ...);
64void fdprint(long afd, const char *fmt, ...);
65
66/* Routine for conditionally printing timestamped log messages */
67extern void LogMsg(int msglevel, int debuglevel, FILE *fout, const char *fmt,
68 ...);
69#define VLog(level, fmt, a...) LogMsg(level, VolDebugLevel, stdout, fmt, ##a)
70#define SLog(level, fmt, a...) LogMsg(level, SrvDebugLevel, stdout, fmt, ##a)
71#define DLog(level, fmt, a...) LogMsg(level, DirDebugLevel, stdout, fmt, ##a)
72#define ALog(level, fmt, a...) LogMsg(level, VolDebugLevel, stdout, fmt, ##a)
73#define CLog(level, fmt, a...) LogMsg(level, VolDebugLevel, stdout, fmt, ##a)
74
75/* The routine that prints the timestamp */
76extern void PrintTimeStamp(FILE *fout);
77
78/* Hostname related utilities */
79int UtilHostEq(const char *name1, const char *name2);
80char *hostname(char *name);
81
82/* Process releted utilities */
83void UtilDetach();
84
85/* Useful locking macros */
86#define U_wlock(b) ObtainWriteLock(&((b)->lock))
87#define U_rlock(b) ObtainReadLock(&((b)->lock))
88#define U_wunlock(b) ReleaseWriteLock(&((b)->lock))
89#define U_runlock(b) ReleaseReadLock(&((b)->lock))
90
91/* Extern decls for variables used in Coda to control verbosity of
92 messages from LogMsg(). Should these be here?
93*/
94
95extern int SrvDebugLevel; /* Server */
96extern int VolDebugLevel; /* Vol package */
97extern int DirDebugLevel; /* Dir package */
98extern int AL_DebugLevel; /* ACL package */
99extern int AuthDebugLevel; /* Auth package */
100
101#ifdef __CYGWIN32__
102#include <stdarg.h>
103/* int vsnprintf(char *buf, size_t len, char *fmt, va_list ap); */
104int snprintf(char *buf, size_t len, const char *fmt, ...);
105long int gethostid(void);
106#endif
107
108#ifdef __cplusplus
109}
110#endif
#define snprintf(str, size, format...)
Definition: coda_string.h:36
name
Definition: pwdtopdbtool.py:40
int AuthDebugLevel
Definition: util.c:75
void PrintTimeStamp(FILE *fout)
Definition: util.c:90
void eprint(const char *,...)
Definition: util.c:189
void LogMsg(int msglevel, int debuglevel, FILE *fout, const char *fmt,...)
Definition: util.c:147
int VolDebugLevel
Definition: util.c:71
int SrvDebugLevel
Definition: util.c:70
void UtilDetach()
Definition: util.c:255
int HashString(char *s, unsigned int size)
Definition: util.c:77
int DirDebugLevel
Definition: util.c:73
void fdprint(long afd, const char *fmt,...)
Definition: util.c:177
int UtilHostEq(const char *name1, const char *name2)
Definition: util.c:223
char * hostname(char *name)
Definition: util.c:212
int AL_DebugLevel
Definition: util.c:74