imapext-2007
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/c-client/misc.h Mon Sep 14 15:17:45 2009 +0900 1.3 @@ -0,0 +1,110 @@ 1.4 +/* ======================================================================== 1.5 + * Copyright 1988-2006 University of Washington 1.6 + * 1.7 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.8 + * you may not use this file except in compliance with the License. 1.9 + * You may obtain a copy of the License at 1.10 + * 1.11 + * http://www.apache.org/licenses/LICENSE-2.0 1.12 + * 1.13 + * 1.14 + * ======================================================================== 1.15 + */ 1.16 + 1.17 +/* 1.18 + * Program: Miscellaneous utility routines 1.19 + * 1.20 + * Author: Mark Crispin 1.21 + * Networks and Distributed Computing 1.22 + * Computing & Communications 1.23 + * University of Washington 1.24 + * Administration Building, AG-44 1.25 + * Seattle, WA 98195 1.26 + * Internet: MRC@CAC.Washington.EDU 1.27 + * 1.28 + * Date: 5 July 1988 1.29 + * Last Edited: 30 August 2006 1.30 + * 1.31 + * This original version of this file is 1.32 + * Copyright 1988 Stanford University 1.33 + * and was developed in the Symbolic Systems Resources Group of the Knowledge 1.34 + * Systems Laboratory at Stanford University in 1987-88, and was funded by the 1.35 + * Biomedical Research Technology Program of the NationalInstitutes of Health 1.36 + * under grant number RR-00785. 1.37 + */ 1.38 + 1.39 +/* Hash table operations */ 1.40 + 1.41 +#define HASHMULT 29 /* hash polynomial multiplier */ 1.42 + 1.43 +#define HASHENT struct hash_entry 1.44 + 1.45 +HASHENT { 1.46 + HASHENT *next; /* next entry with same hash code */ 1.47 + char *name; /* name of this hash entry */ 1.48 + void *data[1]; /* data of this hash entry */ 1.49 +}; 1.50 + 1.51 + 1.52 +#define HASHTAB struct hash_table 1.53 + 1.54 +HASHTAB { 1.55 + size_t size; /* size of this table */ 1.56 + HASHENT *table[1]; /* table */ 1.57 +}; 1.58 + 1.59 + 1.60 +/* KLUDGE ALERT!!! 1.61 + * 1.62 + * Yes, write() is overridden here instead of in osdep. This 1.63 + * is because misc.h is one of the last files that most things #include, so 1.64 + * this should avoid problems with some system #include file. 1.65 + */ 1.66 + 1.67 +#define write safe_write 1.68 + 1.69 + 1.70 +/* Some C compilers have these as macros */ 1.71 + 1.72 +#undef min 1.73 +#undef max 1.74 + 1.75 + 1.76 +/* And some C libraries have these as int functions */ 1.77 + 1.78 +#define min Min 1.79 +#define max Max 1.80 + 1.81 + 1.82 +/* Compatibility definitions */ 1.83 + 1.84 +#define pmatch(s,pat) \ 1.85 + pmatch_full (s,pat,NIL) 1.86 + 1.87 +/* Function prototypes */ 1.88 + 1.89 +unsigned char *ucase (unsigned char *string); 1.90 +unsigned char *lcase (unsigned char *string); 1.91 +char *cpystr (const char *string); 1.92 +char *cpytxt (SIZEDTEXT *dst,char *text,unsigned long size); 1.93 +char *textcpy (SIZEDTEXT *dst,SIZEDTEXT *src); 1.94 +char *textcpystring (SIZEDTEXT *text,STRING *bs); 1.95 +char *textcpyoffstring (SIZEDTEXT *text,STRING *bs,unsigned long offset, 1.96 + unsigned long size); 1.97 +unsigned long find_rightmost_bit (unsigned long *valptr); 1.98 +long min (long i,long j); 1.99 +long max (long i,long j); 1.100 +long search (unsigned char *base,long basec,unsigned char *pat,long patc); 1.101 +long ssearch (unsigned char *base,long basec,unsigned char *pat,long patc); 1.102 +HASHTAB *hash_create (size_t size); 1.103 +void hash_destroy (HASHTAB **hashtab); 1.104 +void hash_reset (HASHTAB *hashtab); 1.105 +unsigned long hash_index (HASHTAB *hashtab,char *key); 1.106 +void **hash_lookup (HASHTAB *hashtab,char *key); 1.107 +HASHENT *hash_add (HASHTAB *hashtab,char *key,void *data,long extra); 1.108 +void **hash_lookup_and_add (HASHTAB *hashtab,char *key,void *data,long extra); 1.109 +unsigned char hex2byte (unsigned char c1,unsigned char c2); 1.110 +int compare_ulong (unsigned long l1,unsigned long l2); 1.111 +int compare_uchar (unsigned char c1,unsigned char c2); 1.112 +int compare_cstring (unsigned char *s1,unsigned char *s2); 1.113 +int compare_csizedtext (unsigned char *s1,SIZEDTEXT *s2);