imapext-2007

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

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

UW-IMAP'd extensions by yuuji