remove misc motif code from engine

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@580 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-03-02 04:17:13 +00:00
parent 2cd490c09d
commit 988a792b73
3 changed files with 72 additions and 53 deletions

View File

@ -909,6 +909,40 @@ listCB( Widget mw, XtPointer cd, XtPointer cb )
* datafile - the name of the user's datafile *
* toplevel - the toplevel widget *
\********************************************************************/
#define SHOW_IO_ERR_MSG(io_error) { \
switch (io_error) { \
case ERR_FILEIO_NO_ERROR: \
break; \
case ERR_FILEIO_FILE_NOT_FOUND: \
sprintf (buf, FILE_NOT_FOUND_MSG, datafile); \
errorBox (toplevel, buf); \
break; \
case ERR_FILEIO_FILE_EMPTY: \
sprintf (buf, FILE_EMPTY_MSG, datafile); \
errorBox (toplevel, buf); \
break; \
case ERR_FILEIO_FILE_TOO_NEW: \
errorBox (toplevel, FILE_TOO_NEW_MSG); \
break; \
case ERR_FILEIO_FILE_TOO_OLD: \
if (!verifyBox( toplevel, FILE_TOO_OLD_MSG )) { \
xaccFreeAccountGroup (newgrp); \
newgrp = NULL; \
} \
break; \
case ERR_FILEIO_FILE_BAD_READ: \
if (!verifyBox( toplevel, FILE_BAD_READ_MSG )) { \
xaccFreeAccountGroup (newgrp); \
newgrp = NULL; \
} \
break; \
default: \
break; \
} \
}
void
fileMenubarCB( Widget mw, XtPointer cd, XtPointer cb )
{
@ -965,35 +999,7 @@ fileMenubarCB( Widget mw, XtPointer cd, XtPointer cb )
/* check for i/o error, put up appropriate error message */
io_error = xaccGetFileIOError();
switch (io_error) {
case ERR_FILEIO_NO_ERROR:
break;
case ERR_FILEIO_FILE_NOT_FOUND:
sprintf (buf, FILE_NOT_FOUND_MSG, datafile);
errorBox (toplevel, buf);
break;
case ERR_FILEIO_FILE_EMPTY:
sprintf (buf, FILE_EMPTY_MSG, datafile);
errorBox (toplevel, buf);
break;
case ERR_FILEIO_FILE_TOO_NEW:
errorBox (toplevel, FILE_TOO_NEW_MSG);
break;
case ERR_FILEIO_FILE_TOO_OLD:
if (!verifyBox( toplevel, FILE_TOO_OLD_MSG )) {
xaccFreeAccountGroup (newgrp);
newgrp = NULL;
}
break;
case ERR_FILEIO_FILE_BAD_READ:
if (!verifyBox( toplevel, FILE_BAD_READ_MSG )) {
xaccFreeAccountGroup (newgrp);
newgrp = NULL;
}
break;
default:
break;
}
SHOW_IO_ERR_MSG(io_error);
/* if we managed to read something, then go display it */
if (newgrp) {
@ -1009,6 +1015,8 @@ fileMenubarCB( Widget mw, XtPointer cd, XtPointer cb )
case FMB_IMPORT: {
char * newfile;
char buf[BUFSIZE];
int io_error;
AccountGroup *newgrp;
DEBUG("FMB_IMPORT\n");
@ -1019,7 +1027,11 @@ fileMenubarCB( Widget mw, XtPointer cd, XtPointer cb )
datafile = XtNewString (buf);
/* load the accounts from the users datafile */
grp = xaccReadQIFAccountGroup (newfile);
newgrp = xaccReadQIFAccountGroup (newfile);
/* check for i/o error, put up appropriate error message */
io_error = xaccGetQIFIOError();
SHOW_IO_ERR_MSG(io_error);
if( NULL == topgroup ) {
/* no topgroup exists */
@ -1028,7 +1040,7 @@ fileMenubarCB( Widget mw, XtPointer cd, XtPointer cb )
/* since quicken will not export all accounts
* into one file, we must merge them in one by one */
xaccConcatGroups (topgroup, grp);
xaccConcatGroups (topgroup, newgrp);
xaccMergeAccounts (topgroup);
xaccConsolidateGrpTransactions (topgroup);
}

View File

@ -42,5 +42,6 @@ int xaccWriteAccountGroup (char *datafile, AccountGroup *grp);
int xaccGetFileIOError (void);
AccountGroup *xaccReadQIFAccountGroup (char *datafile);
int xaccGetQIFIOError (void);
#endif /* __FILEIO_H__ */

View File

@ -30,20 +30,28 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <Xm/Xm.h>
#include "config.h"
#include "Account.h"
#include "Group.h"
#include "messages.h"
#include "FileIO.h"
#include "util.h"
#define PERMS 0666
#define WFLAGS (O_WRONLY | O_CREAT | O_TRUNC)
#define RFLAGS O_RDONLY
extern Widget toplevel;
/** GLOBALS *********************************************************/
static int error_code=0; /* error code, if error occurred */
/*******************************************************/
int xaccGetQIFIOError (void)
{
return error_code;
}
/********************************************************************\
* xaccReadQIFLine *
@ -338,8 +346,8 @@ char * xaccReadQIFAccList (int fd, AccountGroup *grp, int cat)
/* trim off the parent account name ... */
/* tok += sizeof(char); leave behind the colon ... */
str = XtNewString (tok);
XtFree (acc->accountName);
str = strdup (tok);
free (acc->accountName);
acc->accountName = str;
xaccInsertSubAccount( parent, acc );
@ -460,9 +468,9 @@ GetSubQIFAccount (AccountGroup *rootgrp, char *qifline, int acc_type)
/* if not, create it */
if (!xfer_acc) {
xfer_acc = xaccMallocAccount ();
xfer_acc->accountName = XtNewString (qifline);
xfer_acc->description = XtNewString ("");
xfer_acc->notes = XtNewString ("");
xfer_acc->accountName = strdup (qifline);
xfer_acc->description = strdup ("");
xfer_acc->notes = strdup ("");
if (0 > acc_type) acc_type = GuessAccountType (qifline);
xfer_acc->type = acc_type;
@ -545,9 +553,9 @@ xaccGetSecurityQIFAccount (Account *acc, char *qifline)
/* if not, create it */
if (!xfer_acc) {
xfer_acc = xaccMallocAccount ();
xfer_acc->accountName = XtNewString (qifline);
xfer_acc->description = XtNewString ("");
xfer_acc->notes = XtNewString ("");
xfer_acc->accountName = strdup (qifline);
xfer_acc->description = strdup ("");
xfer_acc->notes = strdup ("");
xfer_acc->type = STOCK;
xaccInsertSubAccount (acc, xfer_acc);
}
@ -569,7 +577,7 @@ xaccGetSecurityQIFAccount (Account *acc, char *qifline)
#define XACC_ACTION(q,x) \
if (!strncmp (&qifline[1], q, strlen(q))) { \
trans->credit_split.action = XtNewString(x); \
trans->credit_split.action = strdup(x); \
} else
@ -885,8 +893,7 @@ xaccReadQIFAccountGroup( char *datafile )
fd = open( datafile, RFLAGS, 0 );
if( fd == -1 )
{
sprintf (buf, FILE_NOT_FOUND_MSG, datafile);
errorBox (toplevel, buf);
error_code = ERR_FILEIO_FILE_NOT_FOUND;
return NULL;
}
@ -894,8 +901,7 @@ xaccReadQIFAccountGroup( char *datafile )
qifline = xaccReadQIFLine (fd);
if( NULL == qifline )
{
sprintf (buf, FILE_EMPTY_MSG, datafile);
errorBox (toplevel, buf);
error_code = ERR_FILEIO_FILE_EMPTY;
close(fd);
return NULL;
}
@ -908,9 +914,9 @@ xaccReadQIFAccountGroup( char *datafile )
DEBUG ("got bank\n");
acc->type = BANK;
acc->accountName = XtNewString ("Quicken Bank Account");
acc->description = XtNewString ("");
acc->notes = XtNewString ("");
acc->accountName = strdup ("Quicken Bank Account");
acc->description = strdup ("");
acc->notes = strdup ("");
insertAccount( grp, acc );
qifline = xaccReadQIFTransList (fd, acc);
@ -934,9 +940,9 @@ xaccReadQIFAccountGroup( char *datafile )
DEBUG ("got Invst\n");
acc->type = BANK;
acc->accountName = XtNewString ("Quicken Investment Account");
acc->description = XtNewString ("");
acc->notes = XtNewString ("");
acc->accountName = strdup ("Quicken Investment Account");
acc->description = strdup ("");
acc->notes = strdup ("");
insertAccount( grp, acc );
qifline = xaccReadQIFTransList (fd, acc);