home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / c / c-niftp.zip / unix-niftp-5.6 / lib / mmdf / mmdf.h < prev    next >
C/C++ Source or Header  |  1990-08-01  |  8KB  |  213 lines

  1. /* unix-niftp lib/mmdf/mmdf.h $Revision: 5.5 $ $Date: 90/08/01 13:36:18 $ */
  2. /*
  3.  * $Log:    mmdf.h,v $
  4.  * Revision 5.5  90/08/01  13:36:18  pb
  5.  * Distribution of Aug90RealPP+sequent: Full PP release and support for Sequent X.25 board
  6.  * 
  7.  * Revision 5.2  89/01/13  14:48:44  pb
  8.  * Distribution of Jan89SuckMail: Support Sucking of mail
  9.  * 
  10.  * Revision 5.0  87/03/23  03:45:29  bin
  11.  * Merger of latest UCL and Nottingham versions together with
  12.  * an extensive spring clean.
  13.  * Now UNIX-NIFTP prerelease.
  14.  * 
  15.  */
  16. /*            Reply Codes for MMDF
  17.  
  18.  *  Based on: "Revised FTP Reply Codes", by Jon Postel & Nancy Neigus Arpanet
  19.  *      RFC 640 / NIC 30843, in the "Arpanet Protocol Handbook", E.  Feinler
  20.  *      and J. Postel (eds.), NIC 7104, Network Information Center, SRI
  21.  *      International:  Menlo Park, CA.  (NTIS AD-A0038901)
  22.  *
  23.  *  Actual values are different, but scheme is same.  Codes must fit into
  24.  *  8-bits (to pass on exit() calls); fields are packed 2-3-3 and interpreted
  25.  *  as octal numbers.
  26.  *
  27.  *  Basic format:
  28.  *
  29.  *      0yz: positive completion; entire action done
  30.  *      1yz: positive intermediate; only part done
  31.  *      2yz: Transient negative completion; may work later
  32.  *      3yz: Permanent negative completion; you lose forever
  33.  *
  34.  *      x0z: syntax
  35.  *      x1z: general; doesn't fit any other category
  36.  *      x2z: connections; truly transfer-related
  37.  *      x3z: user/authentication/account
  38.  *      x4x: mail
  39.  *      x5z: file system
  40.  *
  41.  *      3-bit z field is unique to the reply.  In the following,
  42.  *      the RP_xVAL defines are available for masking to obtain a field.
  43.  */
  44. /* **************  FIELD DEFINITIONS & BASIC VALUES  ***************** */
  45.  
  46. /*          Field 1:  Basic degree of success (2-bits)                  */
  47.  
  48. #define RP_BTYP '\200'            /* good vs. bad; on => bad            */
  49.  
  50. #define RP_BVAL '\300'            /* basic degree of success            */
  51.  
  52. #define RP_BOK  '\000'            /* went fine; all done                */
  53. #define RP_BPOK '\100'            /* only the first part got done       */
  54. #define RP_BTNO '\200'            /* temporary failure; try later       */
  55. #define RP_BNO  '\300'            /* not now, nor never; you lose       */
  56.  
  57. /*          Field 2:  Basic domain of discourse (3-bits)                */
  58.  
  59. #define RP_CVAL '\070'            /* basic category (domain) of reply   */
  60.  
  61. #define RP_CSYN '\000'            /* purely a matter of form            */
  62. #define RP_CGEN '\010'            /* couldn't find anywhere else for it */
  63. #define RP_CCON '\020'            /* data-transfer-related issue        */
  64. #define RP_CUSR '\030'            /* pertaining to the user             */
  65. #define RP_CMAI '\040'            /* specific to mail semantics         */
  66. #define RP_CFIL '\050'            /* file system                        */
  67. #define RP_CLIO '\060'            /* local i/o system                   */
  68.  
  69. /*          Field 3:  Specific value for this reply (3-bits)            */
  70.  
  71. #define RP_SVAL '\007'            /* specific value of reply            */
  72. /* ********************  SPECIFIC SUCCESS VALUES  ******************** */
  73.  
  74.  
  75. /*                        Complete Success                              */
  76.  
  77. #define RP_DONE (RP_BOK | RP_CGEN | '\000')
  78.                   /* done (e.g., w/transaction)         */
  79. #define RP_OK   (RP_BOK | RP_CGEN | '\001')
  80.                   /* general-purpose OK                 */
  81.  
  82. #define RP_MOK  (RP_BOK | RP_CMAI | '\000')
  83.                   /* message is accepted (w/text)       */
  84. #define RP_DOK  (RP_BOK | RP_CGEN | '\003')
  85.             /* accepted for the delayed submission channel  */
  86.  
  87.  
  88. /*                        Partial Success                               */
  89.  
  90. #define RP_MAST (RP_BPOK| RP_CGEN | '\000')
  91.                   /* you are the requestor              */
  92. #define RP_SLAV (RP_BPOK| RP_CGEN | '\001')
  93.                   /* you are the requestee              */
  94. #define RP_AOK  (RP_BPOK| RP_CMAI | '\000')
  95.                   /* message address is accepted        */
  96. #define RP_HOK  (RP_BPOK| RP_CMAI | '\001')
  97.                   /* host processing completed          */
  98. /* ********************  SPECIFIC FALURE VALUES  ********************* */
  99.  
  100.  
  101. /*                        Partial Failure                               */
  102.  
  103. #define RP_AGN  (RP_BTNO | RP_CGEN | '\000')
  104.                   /* not now; maybe later               */
  105. #define RP_TIME (RP_BTNO | RP_CGEN | '\001')
  106.                   /* timeout                            */
  107. #define RP_NOOP (RP_BTNO | RP_CGEN | '\002')
  108.                   /* no-op; nothing done, this time     */
  109. #define RP_EOF  (RP_BTNO | RP_CGEN | '\003')
  110.                   /* encountered an end of file         */
  111.  
  112. #define RP_NET  (RP_BTNO | RP_CCON | '\000')
  113.                   /* channel went bad                   */
  114. #define RP_BHST (RP_BTNO | RP_CCON | '\001')
  115.                   /* foreign host screwed up            */
  116. #define RP_DHST (RP_BTNO | RP_CCON | '\002')
  117.                   /* host went away                     */
  118. #define RP_NIO  (RP_BTNO | RP_CCON | '\004')
  119.                   /* general net i/o problem            */
  120. #define RP_NS    (RP_BTNO | RP_CCON | '\005')
  121.                   /* temporary nameserver failure    */
  122.  
  123. #define RP_FIO  (RP_BTNO | RP_CFIL | '\000')
  124.                   /* error reading/writing file         */
  125. #define RP_FCRT (RP_BTNO | RP_CFIL | '\001')
  126.                   /* unable to create file              */
  127. #define RP_FOPN (RP_BTNO | RP_CFIL | '\002')
  128.                   /* unable to open file                */
  129. #define RP_LIO  (RP_BTNO | RP_CLIO | '\000')
  130.                   /* general local i/o problem          */
  131. #define RP_LOCK (RP_BTNO | RP_CLIO | '\001')
  132.                   /* resource currently locked          */
  133.  
  134.  
  135. /*                       Complete Failure                               */
  136.  
  137. #define RP_MECH (RP_BNO | RP_CGEN | '\000')
  138.                   /* bad mechanism/path; try alternate? */
  139. #define RP_NO   (RP_BNO | RP_CGEN | '\001')
  140.                   /* general-purpose NO                 */
  141.  
  142. #define RP_PROT (RP_BNO | RP_CCON | '\000')
  143.                   /* general prototocol error           */
  144.  
  145. #define RP_RPLY (RP_BNO | RP_CCON | '\001')
  146.                   /* bad reply code (PERMANENT ERROR)   */
  147.  
  148. #define RP_NAUTH (RP_BNO | RP_CUSR  | '\001')
  149.                 /* bad authorisation                    */
  150.                 /* SEK this will be used for user checks*/
  151.  
  152. #define RP_NDEL (RP_BNO | RP_CMAI | '\000')
  153.                   /* couldn't deliver                   */
  154.  
  155. #define RP_HUH  (RP_BNO | RP_CSYN | '\000')
  156.                   /* couldn't parse the request         */
  157. #define RP_NCMD (RP_BNO | RP_CSYN | '\001')
  158.                   /* no such command defined            */
  159. #define RP_PARM (RP_BNO | RP_CSYN | '\002')
  160.                   /* bad parameter                      */
  161. #define RP_UCMD (RP_BNO | RP_CSYN | '\003')
  162.                   /* command not implemented            */
  163. #define RP_USER (RP_BNO | RP_CUSR | '\000')
  164.                   /* unknown user                       */
  165.  
  166.  
  167. /*                      STRUCTURE OF A REPLY STRING                     */
  168.  
  169. struct rp_construct               /* for constant reply conditions      */
  170. {
  171.     char    rp_cval;
  172.     char    rp_cline[50];
  173. };
  174.  
  175. struct rp_bufstruct               /* for reading reply strings          */
  176. {
  177.     char    rp_val;
  178.     char    rp_line[256];
  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.