nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

errs.c (4189B)


      1 #include "mxf-remote.h"
      2 #include <stdlib.h>
      3 
      4 extern stralloc Host;
      5 extern buffer buffer_2_;
      6 #define _HSC	{
      7 
      8 void out(const char *s) _HSC
      9 	if (buffer_puts(&buffer_2_,s) == -1) _exit(0);
     10 	buffer_flush(&buffer_2_);
     11 }
     12 void zero() _HSC
     13 	if (buffer_put(&buffer_2_,"\0",1) == -1) _exit(0);
     14 }
     15 void _noreturn_ zerodie() _HSC
     16 	zero();
     17 	buffer_flush(&buffer_2_);
     18 	_exit(0);
     19 }
     20 void outsafe(stralloc *sa) _HSC
     21 	int i; char ch;
     22 	for (i = 0;i < sa->len;++i) {
     23 		ch = sa->s[i];
     24 		if (ch < 33) ch = '?';
     25 		if (ch > 126) ch = '?';
     26 		if (buffer_put(&buffer_2_,&ch,1) == -1) _exit(0);
     27 	}
     28 }
     29 
     30 void _noreturn_ temp_nomem() _HSC
     31 	out("Z4.3.0 Out of memory or limits exceeded.\n");
     32 	zerodie();
     33 }
     34 void _noreturn_ temp_fault() _HSC
     35 	out("Z4.3.0 General protection violation in iopause. Attempting to dump core now.\n");
     36 	zero();
     37 	buffer_flush(&buffer_2_);
     38 	abort();
     39 }
     40 void _noreturn_ temp_runfds() _HSC
     41 	out("Z4.3.0 run_fds called without any descriptors?\n");
     42 	zerodie();
     43 }
     44 void _noreturn_ temp_bug() _HSC
     45 	out("Z4.3.0 OS gave us EINVAL that we don't know what to do with. Attempting to dump core now.\n");
     46 	zero();
     47 	buffer_flush(&buffer_2_);
     48 	abort();
     49 }
     50 void _noreturn_ temp_intr() _HSC
     51 	out("Z4.3.0 Signal interruption in iopause.\n");
     52 	zerodie();
     53 }
     54 void _noreturn_ temp_oserr() _HSC
     55 	out("Z4.3.0 System resources temporarily unavailable.\n");
     56 	zerodie();
     57 }
     58 void _noreturn_ temp_hasherr() _HSC
     59 	out("Z4.3.0 mxf-remote HASH_ADD dup key. Attempting to dump core now.\n");
     60 	zero();
     61 	buffer_flush(&buffer_2_);
     62 	abort();
     63 }
     64 void _noreturn_ temp_finderr() _HSC
     65 	out("Z4.3.0 mxf-remote HASH_FIND no entry. Attempting to dump core now.\n");
     66 	zero();
     67 	buffer_flush(&buffer_2_);
     68 	abort();
     69 }
     70 void _noreturn_ temp_noconn() _HSC
     71 	out("Z4.4.1 Sorry, I wasn't able to establish a connection to the target mail exchanger.\n");
     72 	zerodie();
     73 }
     74 void _noreturn_ temp_dnsupd() _HSC
     75 	out("Z4.0.0 DNSUPD Sorry, selecting on my DNS resolver gave me an error: \"");
     76 	out(error_str(errno));
     77 	out("\"\n");
     78 	zerodie();
     79 }
     80 void _noreturn_ temp_wtf(char const *my) _HSC
     81 	out("Z4.0.0 WTF Sorry, "); out(my); out(" referred me to errno: \"");
     82 	out(error_str(errno));
     83 	out("\"");
     84 	zerodie();
     85 }
     86 void _noreturn_ temp_read() _HSC
     87 	out("Z4.3.0 Unable to read message.\n");
     88 	zerodie();
     89 }
     90 void _noreturn_ temp_dnscanon() _HSC
     91 	out("Z4.4.3 CNAME lookup failed temporarily.\n");
     92 	zerodie();
     93 }
     94 void _noreturn_ temp_dns() _HSC
     95 	out("Z4.1.2 Sorry, I couldn't find any host by that name.\n");
     96 	zerodie();
     97 }
     98 void _noreturn_ temp_chdir() _HSC
     99 	out("Z4.3.0 Unable to switch to home directory.\n");
    100 	zerodie();
    101 }
    102 void _noreturn_ temp_control() _HSC
    103 	out("Z4.3.0 Missing or malformed control files.\n");
    104 	zerodie();
    105 }
    106 // The next one belongs in -smtpc only, but is retained here.
    107 void _noreturn_ perm_partialline() _HSC
    108 	out("D5.6.2 SMTP cannot transfer messages with partial final lines.\n");
    109 	zerodie();
    110 }
    111 void _noreturn_ perm_usage() _HSC
    112 	out("D5.3.5 I (");
    113 	out(PROG);
    114 	out(") was invoked improperly. If this occurs in mxf-remote-qmtpc or mxf-remote-smtpc, that means there is a bug in mxf-remote - contact the developers to report this!\n");
    115 	zerodie();
    116 }
    117 void _noreturn_ perm_dns() _HSC
    118 	out("D5.1.2 Sorry, I couldn't find any host named ");
    119 	outsafe(&Host);
    120 	out(".\n");
    121 	zerodie();
    122 }
    123 void _noreturn_ perm_nomx() _HSC
    124 	out("D5.4.4 Sorry, I couldn't find a mail exchanger, SRV _smtp._tcp or IP address.\n");
    125 	zerodie();
    126 }
    127 void _noreturn_ perm_ambigmx() _HSC
    128 	out("D5.4.6 Sorry. Although I'm listed as a best-preference MX or A for that host,\n" // this is legal nowadays, so we do it fbo highlighters
    129 	    "it isn't in my control/locals file, so I don't treat it as local.\n");
    130 	zerodie();
    131 }
    132 #ifdef    REMOTEDEBUG
    133 void info_dbg(stralloc *info) _HSC
    134 	out("I");
    135 	buffer_put(&buffer_2_, info->s, info->len);
    136 	out("\n");
    137 	return;
    138 }
    139 void info_dbgs(const char *info) _HSC
    140 	out("I");
    141 	buffer_puts(&buffer_2_, info);
    142 	out("\n");
    143 	return;
    144 }
    145 void info_wtfs(const char *info) _HSC
    146 	out("I3.0.0 FYI: "); out(info); out(" referred me to errno: \"");
    147 	out(error_str(errno));
    148 	out("\"\n");
    149 	return;
    150 }
    151 #else
    152 void info_dbg(stralloc *info) _HSC
    153 	return;
    154 }
    155 void info_dbgs(const char *info) _HSC
    156 	return;
    157 }
    158 void info_wtfs(const char *info) _HSC
    159 	return;
    160 }
    161 #endif // RESOLVDEBUGC