1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
/********************************************************************\
* util.h -- utility functions that are used everywhere else for *
* xacc (X-Accountant) *
* Copyright (C) 1997 Robin D. Clark *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
* Author: Rob Clark *
* Internet: rclark@cs.hmc.edu *
* Address: 609 8th Street *
* Huntington Beach, CA 92648-4632 *
\********************************************************************/
#ifndef __XACC_UTIL_H__
#define __XACC_UTIL_H__
#include <stdlib.h>
#include <Xm/Xm.h>
#include "config.h"
#define charset XmSTRING_DEFAULT_CHARSET
extern int loglevel;
/** DEBUGGING MACROS ************************************************/
#include <stdio.h>
#define PERR(x) { if (0 <=loglevel) { \
fprintf (stderr, "Error: "); \
fprintf (stderr, x); }}
#define WARN(x) { if (1 <=loglevel) { \
fprintf (stderr, "Warning: "); \
fprintf (stderr, x); }}
#define INFO(x) { if (2 <=loglevel) { \
fprintf (stderr, "Info: "); \
fprintf (stderr, x); }}
#define INFO_2(x,y) { if (2 <=loglevel) { \
fprintf (stderr, "Info: "); \
fprintf (stderr, x, y); }}
#define DEBUG(x) { if (3 <=loglevel) { \
fprintf (stderr, "Debug: "); \
fprintf (stderr, x); }}
#define ENTER(x) { if (3 <=loglevel) { \
fprintf(stderr,"Entering: %s()\n", x); }}
#define LEAVE(x) { if (3 <=loglevel) { \
fprintf(stderr,"Leaving: %s()\n", x); }}
#define DEBUGCMD(x) { if (3 <=loglevel) { x; }}
#include <errno.h>
#define ERROR() fprintf(stderr,"%s: Line %d, error = %s\n", \
__FILE__, __LINE__, strerror(errno));
#ifdef DEBUGMEMORY
void *dmalloc( size_t size );
void dfree( void *ptr );
size_t dcoresize();
# define _malloc(x) dmalloc(x)
# define _free(x) dfree(x)
# define _coresize() dcoresize()
#else
# define _malloc(x) malloc(x)
# define _free(x) free(x)
# define _coresize() 0
#endif
/** COOL MACROS *****************************************************/
#define ABS(x) ((x)>=0) ? (x) : (-1*(x))
#define DABS(x) ((x)>=0.0) ? (x) : (-1.0*(x))
#define DMAX(x,y) ((x)>(y)) ? (x) : (y)
#define isNum(x) (((x)-0x30) < 0) ? 0 : (((x)-0x30) > 9) ? 0 : 1
#define EPS (1.0e-4)
#define DEQ(x,y) (((((x)+EPS)>(y)) ? 1 : 0) && ((((x)-EPS)<(y)) ? 1 : 0))
/** PROTOTYPES ******************************************************/
#define PRTSYM 0x1
#define PRTSHR 0x2
/*
* The xaccPrintAmount() subroutine converts a double amount
* to a printable string, depending on the argument shrs:
* 0 -- print two decimal places
* 1 -- print currency symbol & two decimal places
* 2 -- print three decimal places
* 3 -- prints three decimal places followed by string "shrs"
* shrs must be bitwise-OR of PRTSYM & PRTSHR
*/
char * xaccPrintAmount (double val, short shrs);
void dateCB( Widget mw, XtPointer cd, XtPointer cb );
void amountCB( Widget mw, XtPointer cd, XtPointer cb );
void noeditCB( Widget mw, XtPointer cd, XtPointer cb );
void destroyShellCB( Widget w, XtPointer cd, XtPointer cb );
void setBusyCursor( Widget w );
void unsetBusyCursor( Widget w );
Boolean verifyBox( Widget parent, char *text );
void errorBox( Widget parent, char *message );
#endif /* __XACC_UTIL_H__ */
|