10bbfda8aSnia/* 20bbfda8aSnia * utility routines header file 3645f5050Syouri * 4645f5050Syouri * 50bbfda8aSnia * Copyright 1988 by Evans & Sutherland Computer Corporation, 60bbfda8aSnia * Salt Lake City, Utah 70bbfda8aSnia * Portions Copyright 1989 by the Massachusetts Institute of Technology 80bbfda8aSnia * Cambridge, Massachusetts 9645f5050Syouri * 10645f5050Syouri * $XConsortium: util.h,v 1.10 89/12/10 17:47:04 jim Exp $ 11645f5050Syouri * 120bbfda8aSnia * 28-Oct-87 Thomas E. LaStrange File created 13645f5050Syouri * 140bbfda8aSnia * Copyright 1992 Claude Lecommandeur. 150bbfda8aSnia */ 16645f5050Syouri 170bbfda8aSnia#ifndef _CTWM_UTIL_H 180bbfda8aSnia#define _CTWM_UTIL_H 19645f5050Syouri 200bbfda8aSnia#include <ctype.h> 210bbfda8aSnia#include <stdio.h> 22645f5050Syouri 23df1c27a6Snia 24df1c27a6Snia/* Simple int utils */ 25df1c27a6Sniastatic inline int max(int a, int b) 26df1c27a6Snia{ 27df1c27a6Snia return a > b ? a : b; 28df1c27a6Snia} 29df1c27a6Snia 30df1c27a6Sniastatic inline int min(int a, int b) 31df1c27a6Snia{ 32df1c27a6Snia return a < b ? a : b; 33df1c27a6Snia} 34df1c27a6Snia 350bbfda8aSnia#ifndef MAX 36df1c27a6Snia#define MAX(x,y) (max(x,y)) 370bbfda8aSnia#endif 380bbfda8aSnia#ifndef MIN 39df1c27a6Snia#define MIN(x,y) (min(x,y)) 400bbfda8aSnia#endif 410bbfda8aSnia#ifndef ABS 420bbfda8aSnia#define ABS(x) ((x)<0?-(x):(x)) 43645f5050Syouri#endif 44645f5050Syouri 45645f5050Syouri/* 46645f5050Syouri * Define some helper macros, because "The argument to toupper() must be 47645f5050Syouri * EOF or representable as an unsigned char; otherwise, the behavior is 48645f5050Syouri * undefined." In particular, an argument of type "char" is problematic 49645f5050Syouri * (gcc: warning: array subscript has type 'char'). 50645f5050Syouri */ 510bbfda8aSnia#define Isascii(c) isascii((int)(unsigned char)(c)) 520bbfda8aSnia#define Isdigit(c) isdigit((int)(unsigned char)(c)) 530bbfda8aSnia#define Islower(c) islower((int)(unsigned char)(c)) 540bbfda8aSnia#define Isupper(c) isupper((int)(unsigned char)(c)) 550bbfda8aSnia#define Tolower(c) tolower((int)(unsigned char)(c)) 560bbfda8aSnia#define Toupper(c) toupper((int)(unsigned char)(c)) 57645f5050Syouri 580bbfda8aSniachar *ExpandFilename(const char *name); 590bbfda8aSniachar *ExpandFilePath(char *path); 60645f5050Syouri 610bbfda8aSniavoid GetColor(int kind, Pixel *what, const char *name); 620bbfda8aSniavoid GetShadeColors(ColorPair *cp); 630bbfda8aSniabool UpdateFont(MyFont *font, int height); 64df1c27a6Sniavoid CreateFonts(ScreenInfo *scr); 650bbfda8aSnia#if 0 660bbfda8aSniavoid move_to_after(TwmWindow *t, TwmWindow *after); 67645f5050Syouri#endif 680bbfda8aSniavoid RescueWindows(void); 690bbfda8aSniavoid DebugTrace(char *file); 70645f5050Syouri 71645f5050Syouri 720bbfda8aSniavoid safe_strncpy(char *dest, const char *src, size_t size); 73645f5050Syouri 740bbfda8aSniaextern FILE *tracefile; 75645f5050Syouri 760bbfda8aSnia#endif /* _CTWM_UTIL_H */ 77