Changeset 272 for trunk/src/sh_error.c


Ignore:
Timestamp:
Jan 27, 2010, 10:52:20 PM (15 years ago)
Author:
katerina
Message:

Fixes tickets #190, #191, #192, #193, and #194.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_error.c

    r214 r272  
    13321332/*@i@*/}
    13331333
     1334#if defined(SH_WITH_MAIL)
     1335void sh_error_mail (const char * alias, int sev,
     1336                    const char * file, long line,
     1337                    long status, unsigned long msg_id, ...)
     1338{
     1339  va_list         vl;                 /* argument list          */
     1340  struct _log_t * lmsg;
     1341
     1342  int    severity;
     1343  unsigned int class;
     1344  char * fmt;
     1345  int retval;
     1346
     1347  SL_ENTER(_("sh_error_mail"));
     1348
     1349  /* Returns pointer to (constant|thread-specific) static memory
     1350   */
     1351  fmt = /*@i@*/get_format (msg_id, &severity, &class);
     1352
     1353  if (!fmt)
     1354    {
     1355      SL_RET0(_("sh_error_mail"));
     1356    }
     1357
     1358  /* --- Override the catalogue severity. ---
     1359   */
     1360  if (sev != (-1))
     1361    severity = sev;
     1362
     1363  /* --- Build the message. ---
     1364   */
     1365  lmsg = (struct _log_t *) SH_ALLOC(sizeof(struct _log_t));
     1366  MLOCK( (char *) lmsg, sizeof(struct _log_t));
     1367  /*@i@*/lmsg->msg = NULL;
     1368
     1369  /*@i@*/(void) sl_strlcpy(lmsg->format, fmt, SH_PATHBUF);
     1370  (void) sl_strlcpy(lmsg->file, file, SH_PATHBUF);
     1371  lmsg->severity = severity;
     1372  lmsg->class    = (int) class;
     1373  lmsg->line     = line;
     1374  lmsg->status   = status;
     1375
     1376  /* Format the log message with timestamp etc.
     1377   * Allocate lmsg->msg
     1378   */
     1379  va_start (vl, msg_id);
     1380  (void) sh_error_string (lmsg, vl);
     1381  va_end (vl);
     1382
     1383  if ( (severity & SH_ERR_FATAL) == 0)
     1384    retval = sh_nmail_pushstack (severity, lmsg->msg, alias);
     1385  else
     1386    retval = sh_nmail_msg (severity, lmsg->msg, alias);
     1387 
     1388  if (retval == -2)
     1389    {
     1390      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_QUEUE_FULL,
     1391                       _("email"));
     1392    }
     1393  SL_RET0(_("sh_error_mail"));
     1394}
     1395#else
     1396void sh_error_mail (const char * alias, int sev,
     1397                    const char * file, long line,
     1398                    long status, unsigned long msg_id, ...)
     1399{
     1400  (void) alias;
     1401  (void) sev;
     1402  (void) file;
     1403  (void) line;
     1404  (void) status;
     1405  (void) msg_id;
     1406
     1407  return;
     1408}
     1409/* defined(SH_WITH_MAIL) */
     1410#endif
    13341411
    13351412/* ------------------------- 
Note: See TracChangeset for help on using the changeset viewer.