home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Archive Magazine 1996
/
ARCHIVE_96.iso
/
discs
/
mag_discs
/
volume_9
/
issue_08
/
toolbox
/
Step3
/
!FormText
/
c
/
err
next >
Wrap
Text File
|
1995-12-05
|
2KB
|
80 lines
/* !FormText.err.c */
/* Error reporting */
#include <stdlib.h>
#include "wimplib.h"
#include "err.h"
/* Copies a string terminated by any ctrl char */
static char *strncpycr(char *s1, const char *s2, size_t n)
{
int m;
for (m=0; m<n; m++)
{
s1[m] = s2[m];
if (s1[m] < ' ')
{
s1[m] = 0;
break;
}
}
return s1;
}
static char err_taskname[32] = "FormText";
void err_set_taskname(const char *name)
{
strncpycr(err_taskname, name, sizeof(err_taskname));
}
int err_check(const _kernel_oserror *er)
{
if (!er)
return 0;
if (wimp_report_error((_kernel_oserror *) er,
Wimp_ReportError_OK|Wimp_ReportError_Cancel, err_taskname)
== Wimp_ReportError_Cancel)
exit(0);
return 1;
}
void err_check_fatal(const _kernel_oserror *er)
{
if (!er)
return;
wimp_report_error((_kernel_oserror *) er, Wimp_ReportError_Cancel,
err_taskname);
exit(0);
}
void err_report(int num, const char *mess)
{
_kernel_oserror er;
er.errnum = num;
strncpycr(er.errmess, mess, sizeof(er.errmess));
wimp_report_error(&er, Wimp_ReportError_OK, err_taskname);
}
void err_complain(int num, const char *mess)
{
_kernel_oserror er;
er.errnum = num;
strncpycr(er.errmess, mess, sizeof(er.errmess));
if (wimp_report_error(&er,
Wimp_ReportError_OK|Wimp_ReportError_Cancel, err_taskname)
== Wimp_ReportError_Cancel)
exit(0);
}
void err_complain_fatal(int num, const char *mess)
{
_kernel_oserror er;
er.errnum = num;
strncpycr(er.errmess, mess, sizeof(er.errmess));
wimp_report_error(&er, Wimp_ReportError_Cancel, err_taskname);
exit(0);
}