home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Format / asn / f_gentxt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  2.4 KB  |  123 lines

  1. /* f_gentxt.c: General Text  Encoder/Decoder Function Routines */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Format/asn/RCS/f_gentxt.c,v 6.0 1991/12/18 20:15:43 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Format/asn/RCS/f_gentxt.c,v 6.0 1991/12/18 20:15:43 jpo Rel $
  9.  *
  10.  * $Log: f_gentxt.c,v $
  11.  * Revision 6.0  1991/12/18  20:15:43  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "head.h"
  19. #include "asn.h"
  20. #include "oid.h"
  21. #include "asn1/GenTxt-types.h"
  22.  
  23.  
  24.  
  25.  
  26. /* ------------------------  Start Routines --------------------------------- */
  27.  
  28.  
  29.  
  30.  
  31. decode_gentext(body)
  32. ASNBODY        **body;
  33. {
  34.     PE    pe;
  35.     PE    pe_prm = NULLPE;
  36.     PE    pe_data = NULLPE;
  37.     int    retval;
  38.     struct type_GenTxt_GenTxtData    *asndata;
  39.  
  40.     PP_TRACE (("decode_gentext()"));    
  41.  
  42.     pe = asn_rd_stdin (NULL);
  43.  
  44.     external2pe (pe, &pe_prm, &pe_data, GENERALTEXT);
  45.     pe_free (pe_prm);
  46.  
  47.     retval = decode_GenTxt_GenTxtData (pe_data, 1, NULLIP,
  48.                         NULLVP, &asndata);
  49.     if (retval == NOTOK)
  50.         pe_done (pe_data);
  51.  
  52.     pe_free (pe_data);
  53.  
  54.     /* -- set ASNBODY -- */
  55.     qbuf2body (asndata, body);
  56.  
  57.     free_GenTxt_GenTxtData (asndata);
  58. }
  59.  
  60.  
  61.  
  62.  
  63. encode_gentext(pe, body)
  64. PE    *pe;
  65. ASNBODY    *body;
  66. {
  67.     int                    retval = NOTOK;
  68.     PE                    pe_data = NULLPE;
  69.     PE                    pe_prm = NULLPE;
  70.     struct type_GenTxt_GenTxtBodyPart    *info = NULL;
  71.  
  72.     PP_TRACE (("encode_gentext()"));    
  73.  
  74.     /* -- set the Data structure -- */
  75.     set_gentext_data (&info, body);
  76.  
  77.     retval = encode_GenTxt_GenTxtParameters (&pe_prm, 1, NULLIP,
  78.                         NULLVP, info -> parameters);
  79.     if (retval == NOTOK)
  80.         pe_done (pe_prm);    /* -- exit -- */
  81.  
  82.     retval = encode_GenTxt_GenTxtData (&pe_data, 1, NULLIP,
  83.                         NULLVP, info -> data);
  84.     if (retval == NOTOK)
  85.         pe_done (pe_data);    /* -- exit -- */
  86.  
  87.     free_GenTxt_GenTxtBodyPart (info);
  88.     pe2external (pe, pe_prm, pe_data, GENERALTEXT); 
  89.     return OK;
  90. }
  91.  
  92.  
  93.  
  94.  
  95. /* -----------------------  Static  Routines  ------------------------------- */
  96.  
  97.  
  98.  
  99.  
  100. static set_gentext_data (dstruct, body)
  101. struct type_GenTxt_GenTxtBodyPart    **dstruct;
  102. ASNBODY        *body;
  103. {
  104.     struct type_GenTxt_GenTxtBodyPart    *tbptr;
  105.     struct type_GenTxt_GenTxtParameters    *parameters;
  106.  
  107.  
  108.     PP_TRACE (("set_gentext_data()"));
  109.  
  110.     /* -- malloc main structure -- */
  111.     tbptr = (struct type_GenTxt_GenTxtBodyPart *)
  112.         smalloc (sizeof *tbptr);
  113.     parameters = (struct type_GenTxt_GenTxtParameters *)
  114.         smalloc (sizeof *parameters);
  115.  
  116.     bzero (tbptr, sizeof *tbptr);
  117.     bzero (parameters, sizeof *parameters);
  118.  
  119.     tbptr -> parameters = parameters;
  120.     body2qbuf (body, &tbptr -> data);    
  121.     *dstruct = tbptr;
  122. }
  123.