imapext-2007

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

UW-IMAP'd extensions by yuuji