Mapper
mk_err_msg.c
Go to the documentation of this file.
1 /****************************************************************************\
2 * mk_err_msg *
3 ******************************************************************************
4 * Mk_err_msg() formats an error message. The formatted error message can be *
5 * put in the error log file. The error log file is /usr/db/ERROR.LOG. *
6 * ERROR.LOG stores formatted error messages. When a process crashes, it *
7 * should put an error message in ERROR.LOG. *
8 * *
9 * The pname argument is a pointer to a string that holds the name of the *
10 * process that is generating the error message. The errmsg argument is a *
11 * pointer to a string that holds the error message. The error message *
12 * string may be up to 75 characters. The err argument is a pointer to a *
13 * structure of type error_message. Err will contain the formatted error *
14 * message. Err is a record in ERROR.LOG; once formatted, err can be written *
15 * to ERROR.LOG (using dbwrite). *
16 * *
17 * Err is a two line message that is put into the ERROR.LOG file. The first *
18 * line of err is a dat/time and program name (pname). The second line is a *
19 * 75 character message (errmsg). You do not need to put carriage returns or *
20 * line feeds in pname and errmsg. *
21 * Wayne Martin - CNRFC 09/16/94 *
22 \****************************************************************************/
23 
24 #include <stdio.h>
25 #include <time.h>
26 
27 #include "database.h"
28 
29 void mk_err_msg(char *pname, char *errmsg,
30  struct error_message *err) {
31 
32  unsigned char mon_name[12][4] = {
33  {"Jan"}, {"Feb"}, {"Mar"}, {"Apr"}, {"May"}, {"Jun"},
34  {"Jul"}, {"Aug"}, {"Sep"}, {"Oct"}, {"Nov"}, {"Dec"}
35  };
36  time_t now;
37  struct tm *tp;
38 
39  /* Get time of error message */
40  now = time(NULL);
41  tp = localtime(&now);
42 
43  /* Format error message */
44  sprintf(err->message, "%-16s:%-46s %3s %2d %2d %2d:%02d%c",
45  pname, errmsg, mon_name[tp->tm_mon], tp->tm_mday, tp->tm_year,
46  tp->tm_hour, tp->tm_min, EOL);
47 }
#define EOL
Definition: database.h:16
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
void mk_err_msg(char *pname, char *errmsg, struct error_message *err)
Definition: mk_err_msg.c:29
char * pname
Definition: shef_structs.h:264
char message[80]
Definition: database.h:253