1 /*---------------------------------------------------------------------- 2 $Id: general.h 764 2007-10-23 23:44:49Z hubert@u.washington.edu $ 3 ----------------------------------------------------------------------*/ 4 5 /* ======================================================================== 6 * Copyright 2006 University of Washington 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * ======================================================================== 15 */ 16 17 18 #ifndef _GENERAL_INCLUDED 19 #define _GENERAL_INCLUDED 20 21 22 #include "system.h" 23 24 /* 25 * Generally useful definitions and constants 26 */ 27 28 29 /* Might as well be consistent */ 30 #undef FALSE 31 #define FALSE 0 /* False, no, bad, etc. */ 32 #undef TRUE 33 #define TRUE 1 /* True, yes, good, etc. */ 34 #define ABORT 2 /* Death, ^G, abort, etc. */ 35 #define COUNT 3 /* For control-c command */ 36 37 38 #undef MIN 39 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 40 #undef MAX 41 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 42 43 44 #ifdef O_BINARY 45 #define STDIO_READ "rb" 46 #define STDIO_APPEND "a+b" 47 #else /* !O_BINARY */ 48 #define O_BINARY 0 49 #define STDIO_READ "r" 50 #define STDIO_APPEND "a+" 51 #endif /* !O_BINARY */ 52 53 #ifndef O_TEXT 54 #define O_TEXT 0 55 #endif /* !O_TEXT */ 56 57 #ifndef _O_WTEXT 58 #define _O_WTEXT 0 59 #endif /* !O_WTEXT */ 60 61 #ifndef _O_U8TEXT 62 #define _O_U8TEXT 0 63 #endif /* !O_U8TEXT */ 64 65 66 /* Various character constants */ 67 #define BACKSPACE '\b' /* backspace character */ 68 #define TAB '\t' /* tab character */ 69 #define RETURN '\r' /* carriage return char */ 70 #define LINE_FEED '\n' /* line feed character */ 71 #define FORMFEED '\f' /* form feed (^L) char */ 72 #define COMMA ',' /* comma character */ 73 #define SPACE ' ' /* space character */ 74 #define ESCAPE '\033' /* the escape */ 75 #define BELL '\007' /* the bell */ 76 #define LPAREN '(' /* left parenthesis */ 77 #define RPAREN ')' /* right parenthesis */ 78 #define BSLASH '\\' /* back slash */ 79 #define QUOTE '"' /* double quote char */ 80 #define DEL '\177' /* delete */ 81 #define NBSPC '\240' /* Non-breaking space */ 82 83 /* 84 * These help with isspace when dealing with UCS-4 characters. 85 * 0x3000 == Ideographic Space (as wide as a CJK character cell) 86 * 0x2002 == En Space 87 * 0x2003 == Em Space 88 */ 89 #define SPECIAL_SPACE(c) ((c) == 0x3000 || (c) == 0x2002 || (c) == 0x2003) 90 91 92 93 94 /* Longest foldername we ever expect */ 95 #define MAXFOLDER (128) 96 97 98 /* Various maximum field lengths, probably shouldn't be changed. */ 99 #define MAX_FULLNAME (100) 100 #define MAX_NICKNAME (80) 101 #define MAX_ADDRESS (500) 102 #define MAX_NEW_LIST (500) /* Max addrs to be added when creating list */ 103 #define MAX_SEARCH (100) /* Longest string to search for */ 104 #define MAX_ADDR_EXPN (1000) /* Longest expanded addr */ 105 #define MAX_ADDR_FIELD (10000) /* Longest fully-expanded addr field */ 106 107 /* 108 * Input timeout fudge factor 109 */ 110 #define IDLE_TIMEOUT (8) 111 #define FUDGE (30) /* better be at least 20 */ 112 113 114 /* 115 * We use a 32 bit unsigned int to carry UCS-4 characters. 116 * C-client uses unsigned long for this, so we have to do 117 * some minor conversion at that interface. UCS-4 characters 118 * are really only 21 bits. We do use the extra space for 119 * defining some special values that a character might have. 120 * In particular, the set of values like KEY_UP, KEY_RESIZE, 121 * NO_OP_IDLE, F12, and so on are 32 bit quantities that don't 122 * interfere with the actual character values. They are also 123 * all positive values with the most significant bit set to 0, 124 * so a 32 bit signed integer could hold them all. 125 * For most people SUINT32 is UINT32, but the user can define 126 * differently at compilation time, for example, as unsigned long. 127 */ 128 typedef SUINT32 UCS; 129 130 /* 131 * The type of an IMAP UID, which is a 32-bit unsigned int. 132 * This could be UINT32 instead of unsigned long but we use 133 * unsigned long because that's what c-client uses. 134 */ 135 typedef unsigned long imapuid_t; 136 137 138 #endif /* _GENERAL_INCLUDED */ 139