home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / h / mmdf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-28  |  8.0 KB  |  215 lines

  1. #
  2. /*  NOTE:   h/util.h must be included BEFORE mmdf.h, in the source
  3.  *          file.  It is not simply included, here, because some
  4.  *          C compilers cannot handle enough levels of #include
  5.  *          nesting. (sigh.)
  6.  */
  7.  
  8. #include "ll_log.h"               /* file-logging package               */
  9. #include "conf.h"                 /* mmdf site-specific general info    */
  10.  
  11. extern    int    domsg;        /* verbose reporting to controlling tty */
  12. #define printx if (domsg) printf
  13.  
  14. /*                      Reply Codes for MMDF
  15.  
  16.  *  Based on: "Revised FTP Reply Codes", by Jon Postel & Nancy Neigus Arpanet
  17.  *      RFC 640 / NIC 30843, in the "Arpanet Protocol Handbook", E.  Feinler
  18.  *      and J. Postel (eds.), NIC 7104, Network Information Center, SRI
  19.  *      International:  Menlo Park, CA.  (NTIS AD-A0038901)
  20.  *
  21.  *  Actual values are different, but scheme is same.  Codes must fit into
  22.  *  8-bits (to pass on exit() calls); fields are packed 2-3-3 and interpreted
  23.  *  as octal numbers.
  24.  *
  25.  *  Basic format:
  26.  *
  27.  *      0yz: positive completion; entire action done
  28.  *      1yz: positive intermediate; only part done
  29.  *      2yz: Transient negative completion; may work later
  30.  *      3yz: Permanent negative completion; you lose forever
  31.  *
  32.  *      x0z: syntax
  33.  *      x1z: general; doesn't fit any other category
  34.  *      x2z: connections; truly transfer-related
  35.  *      x3z: user/authentication/account
  36.  *      x4x: mail
  37.  *      x5z: file system
  38.  *
  39.  *      3-bit z field is unique to the reply.  In the following,
  40.  *      the RP_xVAL defines are available for masking to obtain a field.
  41.  */
  42. /* **************  FIELD DEFINITIONS & BASIC VALUES  ***************** */
  43.  
  44. /*          Field 1:  Basic degree of success (2-bits)                  */
  45.  
  46. #define RP_BTYP '\200'            /* good vs. bad; on => bad            */
  47.  
  48. #define RP_BVAL '\300'            /* basic degree of success            */
  49.  
  50. #define RP_BOK  '\000'            /* went fine; all done                */
  51. #define RP_BPOK '\100'            /* only the first part got done       */
  52. #define RP_BTNO '\200'            /* temporary failure; try later       */
  53. #define RP_BNO  '\300'            /* not now, nor never; you lose       */
  54.  
  55. /*          Field 2:  Basic domain of discourse (3-bits)                */
  56.  
  57. #define RP_CVAL '\070'            /* basic category (domain) of reply   */
  58.  
  59. #define RP_CSYN '\000'            /* purely a matter of form            */
  60. #define RP_CGEN '\010'            /* couldn't find anywhere else for it */
  61. #define RP_CCON '\020'            /* data-transfer-related issue        */
  62. #define RP_CUSR '\030'            /* pertaining to the user             */
  63. #define RP_CMAI '\040'            /* specific to mail semantics         */
  64. #define RP_CFIL '\050'            /* file system                        */
  65. #define RP_CLIO '\060'            /* local i/o system                   */
  66.  
  67. /*          Field 3:  Specific value for this reply (3-bits)            */
  68.  
  69. #define RP_SVAL '\007'            /* specific value of reply            */
  70. /* ********************  SPECIFIC SUCCESS VALUES  ******************** */
  71.  
  72.  
  73. /*                        Complete Success                              */
  74.  
  75. #define RP_DONE (RP_BOK | RP_CGEN | '\000')
  76.                   /* done (e.g., w/transaction)         */
  77. #define RP_OK   (RP_BOK | RP_CGEN | '\001')
  78.                   /* general-purpose OK                 */
  79.  
  80. #define RP_MOK  (RP_BOK | RP_CMAI | '\000')
  81.                   /* message is accepted (w/text)       */
  82. #define RP_DOK  (RP_BOK | RP_CGEN | '\003')
  83.             /* accepted for the delayed submission channel  */
  84.  
  85.  
  86. /*                        Partial Success                               */
  87.  
  88. #define RP_MAST (RP_BPOK| RP_CGEN | '\000')
  89.                   /* you are the requestor              */
  90. #define RP_SLAV (RP_BPOK| RP_CGEN | '\001')
  91.                   /* you are the requestee              */
  92. #define RP_AOK  (RP_BPOK| RP_CMAI | '\000')
  93.                   /* message address is accepted        */
  94. #define RP_HOK  (RP_BPOK| RP_CMAI | '\001')
  95.                   /* host processing completed          */
  96. /* ********************  SPECIFIC FALURE VALUES  ********************* */
  97.  
  98.  
  99. /*                        Partial Failure                               */
  100.  
  101. #define RP_AGN  (RP_BTNO | RP_CGEN | '\000')
  102.                   /* not now; maybe later               */
  103. #define RP_TIME (RP_BTNO | RP_CGEN | '\001')
  104.                   /* timeout                            */
  105. #define RP_NOOP (RP_BTNO | RP_CGEN | '\002')
  106.                   /* no-op; nothing done, this time     */
  107. #define RP_EOF  (RP_BTNO | RP_CGEN | '\003')
  108.                   /* encountered an end of file         */
  109.  
  110. #define RP_NET  (RP_BTNO | RP_CCON | '\000')
  111.                   /* channel went bad                   */
  112. #define RP_BHST (RP_BTNO | RP_CCON | '\001')
  113.                   /* foreign host screwed up            */
  114. #define RP_DHST (RP_BTNO | RP_CCON | '\002')
  115.                   /* host went away                     */
  116. #define RP_NIO  (RP_BTNO | RP_CCON | '\004')
  117.                   /* general net i/o problem            */
  118. #define RP_NS    (RP_BTNO | RP_CCON | '\005')
  119.                   /* temporary nameserver failure    */
  120.  
  121. #define RP_FIO  (RP_BTNO | RP_CFIL | '\000')
  122.                   /* error reading/writing file         */
  123. #define RP_FCRT (RP_BTNO | RP_CFIL | '\001')
  124.                   /* unable to create file              */
  125. #define RP_FOPN (RP_BTNO | RP_CFIL | '\002')
  126.                   /* unable to open file                */
  127. #define RP_LIO  (RP_BTNO | RP_CLIO | '\000')
  128.                   /* general local i/o problem          */
  129. #define RP_LOCK (RP_BTNO | RP_CLIO | '\001')
  130.                   /* resource currently locked          */
  131.  
  132.  
  133. /*                       Complete Failure                               */
  134.  
  135. #define RP_MECH (RP_BNO | RP_CGEN | '\000')
  136.                   /* bad mechanism/path; try alternate? */
  137. #define RP_NO   (RP_BNO | RP_CGEN | '\001')
  138.                   /* general-purpose NO                 */
  139.  
  140. #define RP_PROT (RP_BNO | RP_CCON | '\000')
  141.                   /* general prototocol error           */
  142.  
  143. #define RP_RPLY (RP_BNO | RP_CCON | '\001')
  144.                   /* bad reply code (PERMANENT ERROR)   */
  145.  
  146. #define RP_NAUTH (RP_BNO | RP_CUSR  | '\001')
  147.                 /* bad authorisation                    */
  148.                 /* SEK this will be used for user checks*/
  149.  
  150. #define RP_NDEL (RP_BNO | RP_CMAI | '\000')
  151.                   /* couldn't deliver                   */
  152.  
  153. #define RP_HUH  (RP_BNO | RP_CSYN | '\000')
  154.                   /* couldn't parse the request         */
  155. #define RP_NCMD (RP_BNO | RP_CSYN | '\001')
  156.                   /* no such command defined            */
  157. #define RP_PARM (RP_BNO | RP_CSYN | '\002')
  158.                   /* bad parameter                      */
  159. #define RP_UCMD (RP_BNO | RP_CSYN | '\003')
  160.                   /* command not implemented            */
  161. #define RP_USER (RP_BNO | RP_CUSR | '\000')
  162.                   /* unknown user                       */
  163.  
  164.  
  165. /*                      STRUCTURE OF A REPLY STRING                     */
  166.  
  167. struct rp_construct               /* for constant reply conditions      */
  168. {
  169.     char    rp_cval;
  170.     char    rp_cline[50];
  171. };
  172.  
  173. #define RP_LINEBUF_MAX 256
  174.  
  175. struct rp_bufstruct               /* for reading reply strings          */
  176. {
  177.     char    rp_val;
  178.     char    rp_line[RP_LINEBUF_MAX];
  179. };
  180.  
  181. typedef struct rp_bufstruct RP_Buf;
  182.  
  183. #define rp_conlen(bufnam) (strlen (bufnam.rp_cline) + sizeof (bufnam.rp_cval))
  184.  
  185. /*              PSEUDO-FUNCTIONS TO ACCESS REPLY INFO                   */
  186.  
  187. #define rp_gval(val)    ((char) (val))
  188.                   /* get the entire return value        */
  189.  
  190. /*  The next three give the field's bits, within the whole value        */
  191.  
  192. #define rp_gbval(val)   (rp_gval (val) & RP_BVAL)
  193.                   /* get the basic part of return value */
  194. #define rp_gcval(val)   (rp_gval (val) & RP_CVAL)
  195.                   /* get the domain part of value       */
  196. #define rp_gsval(val)   (rp_gval (val) & RP_SVAL)
  197.                   /* get the specific part of value     */
  198.  
  199. /*  The next three give the numeric value withing the field             */
  200.  
  201. #define rp_gbbit(val)   ((rp_gval (val) >> 6) & 03)
  202.                   /* get the basic part right-shifted   */
  203. #define rp_gcbit(val)   ((rp_gval (val) >> 3 ) & 07)
  204.                   /* get the domain part right-shifted  */
  205. #define rp_gsbit(val)   (rp_gval (val) & 07)
  206.                   /* get the specific part right-shifted */
  207.  
  208. /*  The following works with SIGNED or UNSIGNED chars!  */
  209. #define rp_isgood(val)  (! rp_isbad(val))
  210.                   /* is return value positive?          */
  211. #define rp_isbad(val)   (rp_gval(val) & 0200)
  212.                   /* is return value negative?          */
  213.  
  214. extern char *rp_valstr ();
  215.