move a few more files to engine directory

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@579 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-03-02 03:51:39 +00:00
parent c3b1a1126b
commit 2cd490c09d
9 changed files with 242 additions and 4 deletions

View File

@ -48,6 +48,7 @@ CPU = @target_cpu@
default:
@cd lib; $(MAKE)
@cd src/engine; $(MAKE)
@cd src/register; $(MAKE)
@cd src; $(MAKE)

View File

@ -58,9 +58,9 @@ LIBENG = libengine.a
######################################################################
SRCS = AccWindow.c AccountMenu.c AdjBWindow.c \
BuildMenu.c Destroy.c FileBox.c HelpWindow.c \
Ledger.c LedgerUtils.c MainWindow.c \
Ledger.c MainWindow.c \
RecnWindow.c RegWindow.c Reports.c TextBox.c \
XferWindow.c main.c util.c xtutil.c
XferWindow.c main.c xtutil.c
# OBJS = ${SRCS:.c=.o} $(LIBHTMLW) $(LIBXBAE) $(LIBCOMBO)
OBJS = ${SRCS:.c=.o} $(LIBENG) $(LIBREG) $(LIBXMHTML) $(LIBXBAE) $(LIBCOMBO)
######################################################################

38
src/engine/LedgerUtils.h Normal file
View File

@ -0,0 +1,38 @@
/*******************************************************************\
* LedgerUtils.h -- utilities for the ledger window (X-Accountant) *
* Copyright (C) 1997 Linas Vepstas *
* *
* 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. *
* *
\********************************************************************/
#ifndef __XACC_LEDGER_UTILS_H__
#define __XACC_LEDGER_UTILS_H__
#include "config.h"
#include "Account.h"
/** PROTOTYPES ******************************************************/
int accListCount (Account **list);
Account ** accListCopy (Account **list);
Split ** accListGetSortedSplits (Account **list);
Account ** xaccGroupToList (Account *);
#endif /* __XACC_LEDGER_UTILS_H__ */
/************************** END OF FILE *************************/

View File

@ -39,7 +39,8 @@ LIBPATH = -L/lib -L/usr/lib -L/usr/local/lib
TARGET = ../libengine.a
######################################################################
SRCS = Account.c FileIO.c Group.c QIFIO.c Transaction.c date.c
SRCS = Account.c FileIO.c Group.c LedgerUtils.c QIFIO.c \
Transaction.c date.c util.c
OBJS = ${SRCS:.c=.o}
######################################################################

View File

@ -38,7 +38,8 @@ LIBPATH = -L/lib -L/usr/lib -L/usr/local/lib
TARGET = ../libengine.a
######################################################################
SRCS = Account.c FileIO.c Group.c QIFIO.c Transaction.c date.c
SRCS = Account.c FileIO.c Group.c LedgerUtils.c QIFIO.c \
Transaction.c date.c util.c
OBJS = ${SRCS:.c=.o}
######################################################################

196
src/engine/util.h Normal file
View File

@ -0,0 +1,196 @@
/********************************************************************\
* 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 "config.h"
#define BUFSIZE 1024
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);
/********************************************************************\
* xaccParseUSAmount *
* parses U.S. style monetary strings *
* (strings of the form DDD,DDD,DDD.CC *
* *
\********************************************************************/
double xaccParseUSAmount (const char * str);
/** TEMPLATES ******************************************************/
#define FIND_IN_LIST(Type,list,id,member,found) \
{ \
int i; \
Type *elt; \
\
/* lets see if we have an */ \
/* open window for this account */ \
found = NULL; \
if (id && list) { \
i = 0; \
elt = list[i]; \
while (elt) { \
if (id == elt->member) found = elt; \
i++; \
elt = list[i]; \
} \
} \
}
#define FETCH_FROM_LIST(Type,list,id,member,elt) \
{ \
int i; \
Type **newlist; \
if (!(id)) return 0x0; \
\
/* lets see if we already have an */ \
/* open window for this account */ \
i = 0; \
if (list) { \
elt = list[i]; \
while (elt) { \
if ((id) == elt->member) return elt; \
i++; \
elt = list[i]; \
} \
} \
\
/* if we are here, we didn't find it */ \
newlist = (Type **) malloc ((i+2) * sizeof (Type *)); \
i = 0; \
if (list) { \
elt = list[i]; \
while (elt) { \
newlist[i] = elt; \
i++; \
elt = list[i]; \
} \
free (list); \
} \
list = newlist; \
\
/* malloc a new one, add it to the list */ \
elt = (Type *) malloc (sizeof (Type)); \
elt->member = (id); \
list [i] = elt; \
list [i+1] = NULL; \
}
#define REMOVE_FROM_LIST(Type,list,id,member) \
{ \
int i,j; \
Type *elt; \
\
/* find the item in the list, and remove it */ \
if (list && id) { \
i = j = 0; \
elt = list[i]; \
while (elt) { \
list[j] = elt; \
if (id == elt->member) j--; \
i++; j++; \
elt = list[i]; \
} \
list[j] = NULL; \
} \
}
#endif /* __XACC_UTIL_H__ */

View File

@ -5,6 +5,7 @@ RANLIB = ranlib
INCLPATH = -I/usr/include \
-I/usr/X11R6/include/. \
-I./../../include \
-I./../engine \
-I./../../lib/ComboBox-1.33 \
-I./../../lib/Xbae-4.6.2-linas