annotate src/c-client/misc.h @ 0:ada5e610ab86

imap-2007e
author yuuji@gentei.org
date Mon, 14 Sep 2009 15:17:45 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
1 /* ========================================================================
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
2 * Copyright 1988-2006 University of Washington
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
3 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
4 * Licensed under the Apache License, Version 2.0 (the "License");
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
5 * you may not use this file except in compliance with the License.
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
6 * You may obtain a copy of the License at
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
7 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
8 * http://www.apache.org/licenses/LICENSE-2.0
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
9 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
10 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
11 * ========================================================================
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
12 */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
13
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
14 /*
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
15 * Program: Miscellaneous utility routines
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
16 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
17 * Author: Mark Crispin
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
18 * Networks and Distributed Computing
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
19 * Computing & Communications
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
20 * University of Washington
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
21 * Administration Building, AG-44
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
22 * Seattle, WA 98195
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
23 * Internet: MRC@CAC.Washington.EDU
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
24 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
25 * Date: 5 July 1988
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
26 * Last Edited: 30 August 2006
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
27 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
28 * This original version of this file is
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
29 * Copyright 1988 Stanford University
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
30 * and was developed in the Symbolic Systems Resources Group of the Knowledge
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
31 * Systems Laboratory at Stanford University in 1987-88, and was funded by the
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
32 * Biomedical Research Technology Program of the NationalInstitutes of Health
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
33 * under grant number RR-00785.
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
34 */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
35
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
36 /* Hash table operations */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
37
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
38 #define HASHMULT 29 /* hash polynomial multiplier */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
39
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
40 #define HASHENT struct hash_entry
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
41
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
42 HASHENT {
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
43 HASHENT *next; /* next entry with same hash code */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
44 char *name; /* name of this hash entry */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
45 void *data[1]; /* data of this hash entry */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
46 };
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
47
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
48
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
49 #define HASHTAB struct hash_table
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
50
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
51 HASHTAB {
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
52 size_t size; /* size of this table */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
53 HASHENT *table[1]; /* table */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
54 };
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
55
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
56
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
57 /* KLUDGE ALERT!!!
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
58 *
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
59 * Yes, write() is overridden here instead of in osdep. This
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
60 * is because misc.h is one of the last files that most things #include, so
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
61 * this should avoid problems with some system #include file.
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
62 */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
63
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
64 #define write safe_write
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
65
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
66
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
67 /* Some C compilers have these as macros */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
68
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
69 #undef min
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
70 #undef max
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
71
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
72
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
73 /* And some C libraries have these as int functions */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
74
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
75 #define min Min
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
76 #define max Max
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
77
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
78
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
79 /* Compatibility definitions */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
80
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
81 #define pmatch(s,pat) \
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
82 pmatch_full (s,pat,NIL)
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
83
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
84 /* Function prototypes */
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
85
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
86 unsigned char *ucase (unsigned char *string);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
87 unsigned char *lcase (unsigned char *string);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
88 char *cpystr (const char *string);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
89 char *cpytxt (SIZEDTEXT *dst,char *text,unsigned long size);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
90 char *textcpy (SIZEDTEXT *dst,SIZEDTEXT *src);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
91 char *textcpystring (SIZEDTEXT *text,STRING *bs);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
92 char *textcpyoffstring (SIZEDTEXT *text,STRING *bs,unsigned long offset,
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
93 unsigned long size);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
94 unsigned long find_rightmost_bit (unsigned long *valptr);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
95 long min (long i,long j);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
96 long max (long i,long j);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
97 long search (unsigned char *base,long basec,unsigned char *pat,long patc);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
98 long ssearch (unsigned char *base,long basec,unsigned char *pat,long patc);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
99 HASHTAB *hash_create (size_t size);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
100 void hash_destroy (HASHTAB **hashtab);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
101 void hash_reset (HASHTAB *hashtab);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
102 unsigned long hash_index (HASHTAB *hashtab,char *key);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
103 void **hash_lookup (HASHTAB *hashtab,char *key);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
104 HASHENT *hash_add (HASHTAB *hashtab,char *key,void *data,long extra);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
105 void **hash_lookup_and_add (HASHTAB *hashtab,char *key,void *data,long extra);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
106 unsigned char hex2byte (unsigned char c1,unsigned char c2);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
107 int compare_ulong (unsigned long l1,unsigned long l2);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
108 int compare_uchar (unsigned char c1,unsigned char c2);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
109 int compare_cstring (unsigned char *s1,unsigned char *s2);
ada5e610ab86 imap-2007e
yuuji@gentei.org
parents:
diff changeset
110 int compare_csizedtext (unsigned char *s1,SIZEDTEXT *s2);

yatex.org