home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / Eudora 1.3.1 / source / Include / util.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-16  |  6.0 KB  |  159 lines  |  [TEXT/MPS ]

  1. /* Copyright (c) 1990-1992 by the University of Illinois Board of Trustees */
  2. /**********************************************************************
  3.  * some linked-list macros
  4.  **********************************************************************/
  5. #define LL_Remove(head,item,cast)                                                                             \
  6.     do {                                                                                                                                    \
  7.     if (head==item) head = (*head)->next;                                                                 \
  8.     else                                                                                                                                    \
  9.         for (M_T1=(uLong)head; M_T1; M_T1=(uLong)(*cast M_T1)->next)                \
  10.         {                                                                                                                                     \
  11.             if ((*cast M_T1)->next == item)                                                                     \
  12.             {                                                                                                                                 \
  13.                 (*cast M_T1)->next = (*item)->next;                                                         \
  14.                 break;                                                                                                                    \
  15.             }                                                                                                                                 \
  16.         }                                                                                                                                     \
  17.     } while (0)
  18.  
  19. #define LL_Push(head,item)                                                                                            \
  20.     M_T1 = (uLong) ((*(item))->next = head, head = item)
  21.  
  22. /**********************************************************************
  23.  * declarations for functions in util.c
  24.  **********************************************************************/
  25. Handle NewZHandle(long size);
  26. void WriteZero(UPtr pointer,long size);
  27. void MacInitialize(int masterCount,long ensureStack);
  28. UPtr GetRString(UPtr theString,int theIndex);
  29. UPtr PtoCcpy(UPtr cStr, UPtr pStr);
  30. GetFontID(UPtr theName);
  31. Boolean GrabEvent(EventRecord *theEvent);
  32. void CheckFontSize(int menu,int size,Boolean check);
  33. void CheckFont(int menu,int fontID,Boolean check);
  34. void OutlineFontSizes(int menu,int fontID);
  35. int GetLeading(int fontID,int fontSize);
  36. int GetWidth(int fontID,int fontSize);
  37. int GetDescent(int fontID,int fontSize);
  38. int GetAscent(int fontID,int fontSize);
  39. Boolean IsFixed(int fontID,int fontSize);
  40. UPtr PCat(UPtr string,UPtr suffix);
  41. void AwaitKey(void);
  42. void AddPResource(UPtr,int,long,int,UPtr);
  43. void ChangePResource(UPtr theData,int theLength,long theType,int theID,UPtr theName);
  44. long GetRLong(int index);
  45. int ResourceCpy(short toRef, short fromRef,long type,int id);
  46. void WhiteRect(Rect *r);
  47. int striscmp(UPtr s1,UPtr s2);
  48. void DrawTruncString(UPtr string,int len);
  49. int CalcTextTrunc(UPtr text,short length,short width,GrafPtr port);
  50. #define CalcTrunc(text,width,port) CalcTextTrunc((text)+1,*(text),width,port)
  51. void TrimWhite(PStr s);
  52. void TrimInitialWhite(PStr s);
  53. int WannaSave(MyWindowPtr win);
  54. #ifdef    KERBEROS
  55. int GetPassword(void);
  56. #else
  57. int GetPassword(UPtr forString,UPtr word, int size,short prompt);
  58. #endif
  59. #define PCopy(to,from)    BlockMove(from,to,*(from)+1)
  60. UPtr Tokenize(UPtr string, int size, UPtr *start, UPtr *end, UPtr delims);
  61. void CenterRectIn(Rect *inner,Rect *outer);
  62. void TopCenterRectIn(Rect *inner,Rect *outer);
  63. void BottomCenterRectIn(Rect *inner,Rect *outer);
  64. void ThirdCenterRectIn(Rect *inner,Rect *outer);
  65. typedef enum {Normal, Stop, Note, Caution} AlertEnum;
  66. void MyAppendMenu(MenuHandle menu, UPtr name);
  67. void MyInsMenuItem(MenuHandle menu, UPtr name, short afterItem);
  68. void MyGetItem(MenuHandle menu, short item, UPtr name);
  69. short CurrentModifiers(void);
  70. void SpecialKeys(EventRecord *event);
  71. UPtr PEscCat(UPtr string, UPtr suffix, short escape, char *escapeWhat);
  72. short FindItemByName(MenuHandle menu, UPtr name);
  73. short BinFindItemByName(MenuHandle menu, UPtr name);
  74. void AttachHierMenu(short menu,short item,short hierId);
  75. Boolean DirtyKey(long keyAndChar);
  76. long RemoveSpaces(UPtr text,long size);
  77. UPtr GetRStr(UPtr string,short id);
  78. long atoi(UPtr p);
  79. UPtr PLCat(UPtr string,long num);
  80. UPtr LocalDateTimeStr(UPtr string);
  81. long LocalDateTime(void);
  82. long GMTDateTime(void);
  83. void FixNewlines(UPtr string,long *count);
  84. void GiveTime(void);
  85. long MyMenuKey(EventRecord *event);
  86. void RemoveParens(UPtr string);
  87. long UnadornMessage(EventRecord *event);
  88. Boolean TrimPrefix(UPtr string, UPtr prefix);
  89. UPtr ChangeStrn(short resId,short num,UPtr string);
  90. void RecountStrn(short resId);
  91. void NukeMenuItemByName(short menuId,UPtr itemName);
  92. void RenameItem(short menuId,UPtr oldName,UPtr newName);
  93. Boolean HasSubmenu(MenuHandle mh, short item);
  94. UPtr ComposeString(UPtr into,UPtr format,...);
  95. UPtr VaComposeString(UPtr into,UPtr format,va_list args);
  96. UPtr ComposeRString(UPtr into,short format,...);
  97. UPtr VaComposeRString(UPtr into,short format,va_list args);
  98. void GreyControl(ControlHandle cntl);
  99. Boolean SetGreyControl(ControlHandle cntl, Boolean shdBeGrey);
  100. Boolean IsAUX(void);
  101. long ZoneSecs(void);
  102. void NOOP(void);
  103. Boolean WNE(short eventMask,EventRecord *event,long sleep);
  104. void DlgUpdate(MyWindowPtr win);
  105. long RoundDiv(long quantity,long unit);
  106. void TransLitString(UPtr string);
  107. long TZName2Offset(CStr zoneName);
  108. Boolean EndsWith(PStr name,PStr suffix);
  109. void InvalidatePasswords(Boolean pwGood,Boolean auxpwGood);
  110. Boolean MiniEvents(void);
  111. Boolean MyLClick(Point pt,short modifiers,ListHandle lHandle);
  112.  
  113. typedef struct {
  114.     Handle textH;
  115.     UPtr textP;
  116.     long len;
  117.     long lineBegin;
  118.     long lineEnd;
  119.     short partial;
  120. } WrapDescriptor, WrapPtr;
  121.  
  122. void InitWrap(WrapPtr wp,Handle textH,UPtr textP,long len,long offset,long lastLen);
  123. short Wrap(WrapPtr wp);
  124.  
  125. #define MakePStr(s,p,l) do{*s=MIN(l,sizeof(s)-2);BlockMove(p,s+1,*s);s[*s+1]=0;}while(0)
  126. #define CtoPCpy(p,c) do{short l=strlen(c);MakePStr(p,c,l);}while(0)
  127. #define Pause(t) do {long tk=TickCount(); while (TickCount()-tk<t) {WNE(0,nil,t);}} while(0)
  128. #define PCatC(string,c) (string)[++(string)[0]] = c
  129. #define DIR_MASK    8     /* mask to use to test file attrib for directory bit */
  130. #define OPTIMAL_BUFFER 4096 /* file buffer size */
  131.  
  132. #define optSpace 0xca
  133. #define enterChar 0x03
  134. #define escChar 0x1b
  135. #define clearChar 0x1b
  136. #define escKey 0x35
  137. #define clearKey 0x47
  138. #define delChar 0x7f
  139. #define backSpace 0x08
  140. #define returnChar 0x0d
  141. #define bulletChar 0xa5
  142. #define tabChar 0x09
  143. #define leftArrowChar 0x1c
  144. #define rightArrowChar 0x1d
  145. #define upArrowChar 0x1e
  146. #define downArrowChar 0x1f
  147. #define homeChar 0x01
  148. #define endChar 0x04
  149. #define helpChar 0x05
  150. #define pageUpChar 0x0b
  151. #define pageDownChar 0x0c
  152. #define undoKey 0x7a
  153. #define cutKey 0x78
  154. #define copyKey 0x63
  155. #define pasteKey 0x76
  156. #define clearKey 0x47
  157. #define betaChar 0xa7
  158. #define deltaChar 0xc6
  159. #define nbSpaceChar 0xca