home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Src / qmgr / structs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  18.4 KB  |  789 lines

  1. /* structs.c: structure building routines */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Src/qmgr/RCS/structs.c,v 6.0 1991/12/18 20:27:38 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Src/qmgr/RCS/structs.c,v 6.0 1991/12/18 20:27:38 jpo Rel $
  9.  *
  10.  * $Log: structs.c,v $
  11.  * Revision 6.0  1991/12/18  20:27:38  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "util.h"
  19. #include "types.h"
  20. #include "Qmgr-ops.h"
  21. #include <isode/logger.h>
  22.  
  23. #define    STR2QB(str)    str2qb (str, strlen(str), 1)
  24. #define OOM()    PP_LOG(LLOG_EXCEPTIONS, ("out of memory"))
  25. struct type_Qmgr_PrioritisedChannel    *lpchan ();
  26. struct type_Qmgr_ChannelInfo        *lchani ();
  27. struct type_Qmgr_PrioritisedMta        *lpmta ();
  28. struct type_Qmgr_MtaInfo        *lmta ();
  29. struct type_Qmgr_ProcStatus        *lstatus ();
  30. struct type_UNIV_UTCTime        *ltime ();
  31. struct type_Qmgr_MsgStruct        *lmessage ();
  32. struct type_Qmgr_PerMessageInfo        *lmsginfo ();
  33. struct type_Qmgr_MPDUIdentifier    *lmpduiden ();
  34. struct type_Qmgr_EncodedInformationTypes*leit ();
  35. struct type_Qmgr_RecipientList        *lreciplist ();
  36. struct type_Qmgr_RecipientInfo        *lrecip ();
  37. struct type_Qmgr_ChannelList        *lchanlist ();
  38.  
  39. MsgStruct *newmsgstruct ();
  40. static Reciplist *newrecips ();
  41. static LIST_BPT *neweit ();
  42. static MPDUid *newmpduid ();
  43.  
  44. void    freerecips ();
  45. void    freempdu ();
  46.  
  47. struct type_Qmgr_ChannelInfo *lchani (clp)
  48. Chanlist    *clp;
  49. {
  50.     struct type_Qmgr_ChannelInfo    *ci;
  51.  
  52.     PP_DBG (("lchani ()"));
  53.  
  54.     ci = (struct type_Qmgr_ChannelInfo *)
  55.         calloc (1, sizeof (*ci));
  56.     if (ci == NULL) {
  57.         OOM ();
  58.         return NULL;
  59.     }
  60.  
  61.     ci -> channel = STR2QB (clp -> channame);
  62.     if (clp -> chan -> ch_show)
  63.         ci -> channelDescription = STR2QB (clp -> chan -> ch_show);
  64.     else
  65.         ci -> channelDescription = STR2QB (clp -> channame);
  66.     
  67.     ci -> oldestMessage = ltime (clp -> oldest);
  68.     ci -> numberMessages = clp -> num_msgs;
  69.     ci -> numberReports = clp -> num_drs;
  70.     ci -> volumeMessages = clp -> volume;
  71.     ci -> numberActiveProcesses = clp -> nactive;
  72.     ci -> status = lstatus (clp);
  73.     ci -> direction = pe_alloc (PE_CLASS_UNIV, PE_FORM_PRIM, PE_PRIM_BITS);
  74.     switch (clp -> chan -> ch_chan_type) {
  75.         case CH_IN:
  76.         bit_on (ci -> direction, bit_Qmgr_direction_inbound);
  77.         break;
  78.  
  79.         case CH_BOTH:
  80.         bit_on (ci -> direction, bit_Qmgr_direction_inbound);
  81.         /* fall */
  82.         case CH_OUT:
  83.         bit_on (ci -> direction, bit_Qmgr_direction_outbound);
  84.         break;
  85.     }
  86.     if (clp -> chan -> ch_access == CH_MTS)
  87.         ci -> chantype = int_Qmgr_chantype_mts;
  88.     else
  89.         switch (clp -> chan -> ch_chan_type) {
  90.             case CH_SHAPER:
  91.             case CH_WARNING:
  92.             case CH_DELETE:
  93.             case CH_QMGR_LOAD:
  94.             case CH_DEBRIS:
  95.             case CH_TIMEOUT:
  96.             ci -> chantype = int_Qmgr_chantype_internal;
  97.             break;
  98.  
  99.             default:
  100.             ci -> chantype = int_Qmgr_chantype_mta;
  101.             break;
  102.         }
  103.     ci -> maxprocs = clp -> chan -> ch_maxproc;
  104.     ci -> numberMtas = clp -> nmtas;
  105.     return ci;
  106. }
  107.  
  108. struct type_Qmgr_ProcStatus *lstatus (clp)
  109. Chanlist *clp;
  110. {
  111.     struct type_Qmgr_ProcStatus *ps;
  112.  
  113.     ps = (struct type_Qmgr_ProcStatus *) calloc (1, sizeof *ps);
  114.     if (ps == NULL) {
  115.         PP_SLOG (LLOG_EXCEPTIONS, "memory", ("out of"));
  116.         return NULL;
  117.     }
  118.  
  119.     ps -> enabled = clp -> chan_enabled;
  120.     if (clp -> lastattempt) {
  121.         if((ps -> lastAttempt = ltime (clp -> lastattempt)) == NULL) {
  122.             free_Qmgr_ProcStatus (ps);
  123.             return NULL;
  124.         }
  125.     }
  126.     if (clp -> lastsuccess)
  127.         ps -> lastSuccess = ltime (clp -> lastsuccess);
  128.     if (clp -> cache.cachetime > current_time) {
  129.         if ((ps -> cachedUntil = ltime (clp -> cache.cachetime))
  130.             == NULL) {
  131.             free_Qmgr_ProcStatus (ps);
  132.             return NULL;
  133.         }
  134.     }
  135.  
  136.     return ps;
  137. }
  138.  
  139. struct type_Qmgr_PrioritisedMta *lpmta (mlp, clp)
  140. Mtalist *mlp;
  141. Chanlist    *clp;
  142. {
  143.     struct type_Qmgr_PrioritisedMta *pmta;
  144.  
  145.     PP_DBG (("lpmta ()"));
  146.  
  147.     pmta = (struct type_Qmgr_PrioritisedMta *) calloc (1, sizeof (*pmta));
  148.     if (pmta == NULL) {
  149.         OOM ();
  150.         return NULL;
  151.     }
  152.  
  153.     pmta -> priority = (struct type_Qmgr_Priority *)
  154.         calloc (1, sizeof *pmta -> priority);
  155.     if (pmta -> priority == NULL) {
  156.         OOM ();
  157.         free_Qmgr_PrioritisedMta (pmta);
  158.         return NULL;
  159.     }
  160.  
  161.     pmta -> priority -> parm = 1;
  162.  
  163.     pmta -> mta = lmta (mlp, clp);
  164.     if (pmta -> mta == NULL) {
  165.         free_Qmgr_PrioritisedMta (pmta);
  166.         return NULL;
  167.     }
  168.  
  169.     return pmta;
  170. }
  171.  
  172. struct type_Qmgr_MtaInfo *lmta (mlp, clp)
  173. Mtalist *mlp;
  174. Chanlist *clp;
  175. {
  176.     struct type_Qmgr_MtaInfo *mta;
  177.  
  178.     mta = (struct type_Qmgr_MtaInfo *) calloc (1, sizeof *mta);
  179.     if (mta == NULL) {
  180.         OOM ();
  181.         return NULL;
  182.     }
  183.  
  184.     mta -> channel = STR2QB (clp -> channame);
  185.     mta -> mta = STR2QB (mlp -> mtaname);
  186.  
  187.     mta -> oldestMessage = ltime (mlp -> oldest);
  188.     mta -> numberMessage = mlp -> num_msgs;
  189.     mta -> numberDRs = mlp -> num_drs;
  190.     mta -> volumeMessages = mlp -> volume;
  191.  
  192.     mta -> status = (struct type_Qmgr_ProcStatus *)
  193.         calloc (1, sizeof *mta -> status);
  194.     if (mta -> status == NULL) {
  195.         OOM ();
  196.         free_Qmgr_MtaInfo (mta);
  197.         return NULL;
  198.     }
  199.  
  200.     mta -> status -> enabled = mlp -> mta_enabled;
  201.     if (mlp -> lastattempt)
  202.         mta -> status -> lastAttempt = ltime (mlp -> lastattempt);
  203.     if (mlp -> lastsuccess)
  204.         mta -> status -> lastSuccess = ltime (mlp -> lastsuccess);
  205.  
  206.     if (mlp -> cache.cachetime > current_time)
  207.         mta -> status -> cachedUntil = ltime (mlp -> cache.cachetime);
  208.     mta -> active = mlp -> nactive > 0;
  209.     if (mlp -> info)
  210.         mta -> info = STR2QB (mlp -> info);
  211.     else
  212.         mta -> info = NULL;
  213.     return mta;
  214. }
  215.  
  216.  struct type_UNIV_UTCTime *ltime (when)
  217. time_t    when;
  218. {
  219.     UTC    ut;
  220.     char    *str;
  221.     struct qbuf *qb;
  222.  
  223.     ut = time_t2utc (when);
  224.     str = utct2str (ut);
  225.     
  226.     qb = STR2QB (str);
  227.     free ((char *)ut);
  228.  
  229.     return qb;
  230. }
  231.  
  232.  
  233. struct type_Qmgr_PrioritisedChannel *lpchan (clp)
  234. Chanlist *clp;
  235. {
  236.     struct type_Qmgr_PrioritisedChannel *pc;
  237.  
  238.     PP_DBG (("lpchan ()"));
  239.  
  240.     pc = (struct type_Qmgr_PrioritisedChannel *)
  241.         calloc (1, sizeof *pc);
  242.     if (pc == NULL) {
  243.         OOM ();
  244.         return NULL;
  245.     }
  246.  
  247.     pc -> channel = lchani (clp);
  248.     pc -> priority = (struct type_Qmgr_Priority *)
  249.         calloc (1, sizeof *pc -> priority);
  250.     if (pc -> priority == NULL) {
  251.         OOM ();
  252.         free_Qmgr_PrioritisedChannel (pc);
  253.         return NULL;
  254.     }
  255.  
  256.     pc -> priority -> parm = int_Qmgr_Priority_normal;
  257.  
  258.     return pc;
  259. }
  260.  
  261. struct type_Qmgr_UserList *lusers (ml, check)
  262. Mlist    *ml;
  263. int    check;
  264. {
  265.     int    i;
  266.     struct type_Qmgr_UserList **upp, *upbase, *up;
  267.     Reciplist *rl;
  268.  
  269.     PP_TRACE (("lusers (ml, %d) %d", check, ml -> rcount));
  270.     upbase = NULL;
  271.     upp = &upbase;
  272.  
  273.     for (i = 0; i < ml -> rcount; i++) {
  274.         rl = ml -> recips[i];
  275.         if (check) {
  276.             if (rl -> msg_enabled == 0)
  277.                 continue;
  278.             if (rl -> cache.cachetime > current_time)
  279.                 continue;
  280.         }
  281.         *upp = (struct type_Qmgr_UserList *) calloc (1, sizeof *up);
  282.         up = *upp;
  283.         upp = &(*upp) -> next;
  284.         up -> RecipientId = (struct type_Qmgr_RecipientId *)
  285.             calloc (1, sizeof *up -> RecipientId);
  286.         up -> RecipientId -> parm = rl->id;
  287.         PP_DBG (("Adding user %d to list", rl->id));
  288.     }
  289.     return upbase;
  290. }
  291.  
  292. MsgStruct *newmsgstruct (msg)
  293. struct type_Qmgr_MsgStruct *msg;
  294. {
  295.     MsgStruct *ms;
  296.     struct type_Qmgr_PerMessageInfo *pmi;
  297.  
  298.     if ((ms = (MsgStruct *) malloc (sizeof *ms)) == NULLMS)
  299.         return ms;
  300.     bzero ((char *)ms, sizeof *ms);
  301.  
  302.     ms -> ms_forw = NULLMS;
  303.     ms -> count = 0;
  304.     pmi = msg -> messageinfo;
  305.  
  306.     ms -> queid = qb2str (pmi -> queueid);
  307.     ms -> mpduid = newmpduid (pmi -> mpduiden);
  308.     ms -> originator = qb2str (pmi -> originator);
  309.     if (pmi -> contenttype)
  310.         ms -> contenttype = qb2str (pmi -> contenttype);
  311.     else ms -> contenttype = NULLCP;
  312.     if (pmi -> eit)
  313.         ms -> eit = neweit (pmi -> eit);
  314.     else ms -> eit = NULL;
  315.     ms -> priority = pmi -> priority -> parm;
  316.     ms -> size = pmi -> size;
  317.     ms -> age = utcqb2time_t (pmi -> age);
  318.     ms -> warninterval = pmi -> warnInterval;
  319.     if (ms -> warninterval == 0)
  320.         ms -> warninterval = 24 * 60 * 60; /* default it */
  321.     else    ms -> warninterval *= 3600;
  322.     ms -> numberwarns = pmi -> numberWarningsSent;
  323.     ms -> expirytime = utcqb2time_t (pmi -> expiryTime);
  324.     if (pmi -> deferredTime)
  325.         ms -> defferedtime = utcqb2time_t (pmi -> deferredTime);
  326.     else     ms -> defferedtime = 0;
  327.     if ( pmi -> uaContentId)
  328.         ms -> uacontent = qb2str (pmi -> uaContentId);
  329.     else    ms -> uacontent = NULLCP;
  330.     if (pmi -> inChannel) {
  331.         char *p = qb2str (pmi -> inChannel);
  332.         ms -> inchan = ch_nm2struct (p);
  333.         free (p);
  334.     }
  335.     ms -> recips = newrecips (msg -> recipientlist);
  336.     ms -> m_locked = 0;
  337.     return ms;
  338. }
  339.  
  340. static Reciplist *newrecips (rlist)
  341. struct type_Qmgr_RecipientList *rlist;
  342. {
  343.     Reciplist *nr;
  344.     struct type_Qmgr_RecipientInfo *ri;
  345.     struct type_Qmgr_ChannelList *qclp;
  346.     LIST_RCHAN    *chan;
  347.     char    *p;
  348.     int    i;
  349.  
  350.     if (rlist == NULL)
  351.         return NULLRL;
  352.  
  353.     nr = (Reciplist *) smalloc (sizeof *nr);
  354.     bzero ((char *)nr, sizeof *nr);
  355.  
  356.     ri = rlist -> RecipientInfo;
  357.     nr -> status = ST_NORMAL;
  358.     nr -> id = ri -> id -> parm;
  359.     nr -> user = qb2str (ri -> user);
  360.     nr -> mta = qb2str (ri -> mta);
  361.     nr -> chans = NULL;
  362.     for (qclp = ri -> channelList; qclp; qclp = qclp -> next) {
  363.         chan = list_rchan_new (NULLCP, p = qb2str(qclp -> Channel));
  364.         free (p);
  365.         if (chan)
  366.             list_rchan_add (&nr -> chans, chan);
  367.     }
  368.     nr -> cchan = nr -> chans;
  369.     for (i = ri->channelsDone; i > 0; i--) {
  370.         if (nr -> cchan == NULL) {
  371.             PP_LOG (LLOG_EXCEPTIONS, ("Run out of channels"));
  372.             break;
  373.         }
  374.         nr -> cchan = nr -> cchan -> li_next;
  375.     }
  376.     nr -> msg_enabled = 1;
  377.  
  378.     nr -> rp_next = newrecips (rlist -> next);
  379.  
  380.     return nr;
  381. }
  382.  
  383. static LIST_BPT *neweit (eit)
  384. struct type_Qmgr_EncodedInformationTypes *eit;
  385. {
  386.     LIST_BPT    *bpt = NULLIST_BPT, *bp;
  387.     char    *p;
  388.  
  389.     for (; eit; eit = eit -> next) {
  390.         bp = list_bpt_new (p = qb2str (eit -> PrintableString));
  391.         if (bp)
  392.             list_bpt_add (&bpt, bp);
  393.         free (p);
  394.     }
  395.  
  396.     return bpt;
  397. }
  398.  
  399.             
  400. static MPDUid    *newmpduid (mpduiden)
  401. struct type_Qmgr_MPDUIdentifier *mpduiden;
  402. {
  403.     MPDUid    *mi;
  404.     struct type_Qmgr_GlobalDomainIdentifier *gdi =
  405.         mpduiden -> global;
  406.     struct type_Qmgr_CountryName *co = gdi -> country;
  407.     struct type_Qmgr_AdministrationDomainName *admd =
  408.         gdi -> admd;
  409.     struct type_Qmgr_PrivateDomainIdentifier *prmd =
  410.         gdi -> prmd;
  411.     GlobalDomId *gd;
  412.  
  413.     mi = (MPDUid *) malloc (sizeof *mi);
  414.  
  415.     mi -> mpduid_string = qb2str (mpduiden -> local);
  416.     gd = &mi -> mpduid_DomId;
  417.  
  418.     gd -> global_Country =
  419.         qb2str (co -> offset ==
  420.             type_Qmgr_CountryName_numeric ?
  421.             co -> un.numeric :
  422.             co -> un.printable);
  423.  
  424.     gd -> global_Admin =
  425.         qb2str (admd -> offset ==
  426.             type_Qmgr_AdministrationDomainName_numeric ?
  427.             admd -> un.numeric :
  428.             admd -> un.printable);
  429.  
  430.     if (prmd)
  431.         gd -> global_Private =
  432.             qb2str (prmd -> offset ==
  433.                 type_Qmgr_PrivateDomainIdentifier_numeric ?
  434.                 prmd -> un.numeric :
  435.                 prmd -> un.printable);
  436.     else    gd -> global_Private = NULLCP;
  437.     return mi;
  438. }
  439.  
  440. Filter    *newfilter (flp)
  441. struct type_Qmgr_FilterList *flp;
  442. {
  443.     Filter    *f;
  444.     struct type_Qmgr_Filter *fl;
  445.  
  446.     if (flp == NULL || flp -> Filter == NULL)
  447.         return NULL;
  448.         
  449.     f = (Filter *) calloc (1, sizeof *f);
  450.  
  451.     fl = flp -> Filter;
  452.  
  453.     if (fl -> contenttype)
  454.         f -> cont = qb2str (fl -> contenttype);
  455.     if (fl -> eit)
  456.         f -> eit = neweit (fl -> eit);
  457.     if (fl -> priority)
  458.         f -> priority = fl -> priority -> parm;
  459.     else    f -> priority = -1;
  460.  
  461.     if (fl -> moreRecentThan)
  462.         f -> morerecent = utcqb2time_t (fl -> moreRecentThan);
  463.     if (fl -> earlierThan)
  464.         f -> earlier = utcqb2time_t (fl -> earlierThan);
  465.     f -> maxsize = fl -> maxSize;
  466.     if (fl -> originator)
  467.         f -> orig = qb2str (fl -> originator);
  468.     if (fl -> recipient)
  469.         f -> recip = qb2str (fl -> recipient);
  470.     if (fl -> channel) {
  471.         char *p;
  472.  
  473.         f -> channel = ch_nm2struct(p = qb2str (fl -> channel));
  474.         free (p);
  475.     }
  476.     if (fl -> mta)
  477.         f -> mta = qb2str (fl -> mta);
  478.     if (fl -> queueid)
  479.         f -> queid = qb2str (fl -> queueid);
  480.     if (fl -> mpduiden)
  481.         f -> mpduid = newmpduid (fl -> mpduiden);
  482.     if (fl -> uaContentId)
  483.         f -> uacontent = qb2str (fl -> uaContentId);
  484.     if (flp -> next)
  485.         f -> next = newfilter (flp -> next);
  486.     return f;
  487. }
  488.  
  489.  
  490. struct type_Qmgr_MsgStruct *lmessage (ms)
  491. MsgStruct *ms;
  492. {
  493.     struct type_Qmgr_MsgStruct *qms;
  494.  
  495.     qms = (struct type_Qmgr_MsgStruct *) calloc (1, sizeof *qms);
  496.  
  497.     qms -> messageinfo = lmsginfo (ms);
  498.     qms -> recipientlist = lreciplist (ms -> recips, NULLCP);
  499.     return qms;
  500. }
  501.  
  502. struct type_Qmgr_MsgStruct *l_cm_message (ml)
  503. Mlist *ml;
  504. {
  505.     struct type_Qmgr_MsgStruct *qms;
  506.     struct type_Qmgr_RecipientList **rl;
  507.     int    i;
  508.  
  509.     qms = (struct type_Qmgr_MsgStruct *) calloc (1, sizeof *qms);
  510.  
  511.     qms -> messageinfo = lmsginfo (ml -> ms);
  512.     rl = &qms -> recipientlist;
  513.     *rl = (struct type_Qmgr_RecipientList *) smalloc (sizeof **rl);
  514.     (*rl) -> RecipientInfo = lrecip (ml -> ms -> recips,
  515.                      ml -> ms -> recips,
  516.                      NULLCP);
  517.     (*rl) -> next = NULL;
  518.     rl = &(*rl) -> next;
  519.     for ( i = 0; i < ml -> rcount; i++) {
  520.         *rl = (struct type_Qmgr_RecipientList *)
  521.             smalloc (sizeof **rl);
  522.         (*rl) -> RecipientInfo = lrecip (ml -> recips[i],
  523.                          ml -> ms -> recips,
  524.                          ml -> info);
  525.         (*rl) -> next = NULL;
  526.         rl = &(*rl) -> next;
  527.     }
  528.     return qms;
  529. }
  530.  
  531. struct type_Qmgr_PerMessageInfo *lmsginfo (ms)
  532. MsgStruct *ms;
  533. {
  534.     struct type_Qmgr_PerMessageInfo *pmi;
  535.  
  536.     pmi = (struct type_Qmgr_PerMessageInfo *) calloc (1, sizeof *pmi);
  537.  
  538.     pmi -> queueid = STR2QB (ms -> queid);
  539.     pmi -> mpduiden = lmpduiden (ms->mpduid);
  540.     pmi -> originator = STR2QB (ms -> originator);
  541.     if (ms -> contenttype)
  542.         pmi -> contenttype = STR2QB (ms -> contenttype);
  543.     if (ms -> eit)
  544.         pmi -> eit = leit (ms -> eit);
  545.     pmi -> priority = (struct type_Qmgr_Priority *)
  546.         calloc (1, sizeof *(pmi -> priority));
  547.     pmi -> priority -> parm = ms -> priority;
  548.     pmi -> size = ms -> size;
  549.     pmi -> age = ltime (ms->age);
  550.     pmi -> warnInterval = ms -> warninterval;
  551.     pmi -> numberWarningsSent = ms -> numberwarns;
  552.     pmi -> expiryTime = ltime (ms->expirytime);
  553.     if (ms -> defferedtime)
  554.         pmi -> deferredTime = ltime (ms -> defferedtime);
  555.     else    pmi -> deferredTime = NULL;
  556.     if (ms -> uacontent)
  557.         pmi -> uaContentId = STR2QB (ms -> uacontent);
  558.     else    pmi -> uaContentId = NULL;
  559.     pmi -> errorCount = ms -> nerrors;
  560.     pmi -> optionals |= opt_Qmgr_PerMessageInfo_errorCount;
  561.  
  562.     if (ms -> inchan)
  563.         pmi -> inChannel = STR2QB (ms -> inchan -> ch_name);
  564.     return pmi;
  565. }
  566.  
  567. struct type_Qmgr_MPDUIdentifier *lmpduiden (mpduid)
  568. MPDUid *mpduid;
  569. {
  570.     struct type_Qmgr_MPDUIdentifier *mp;
  571.     struct type_Qmgr_GlobalDomainIdentifier *gdi;
  572.     struct type_Qmgr_CountryName *co;
  573.     struct type_Qmgr_AdministrationDomainName *admd;
  574.     struct type_Qmgr_PrivateDomainIdentifier *prmd;
  575.  
  576.     mp = (struct type_Qmgr_MPDUIdentifier *) calloc (1, sizeof *mp);
  577.  
  578.     mp -> local = STR2QB (mpduid -> mpduid_string);
  579.  
  580.     gdi = mp -> global =
  581.         (struct type_Qmgr_GlobalDomainIdentifier *)
  582.             calloc (1, sizeof *gdi);
  583.     
  584.     co = gdi -> country =
  585.         (struct type_Qmgr_CountryName *) calloc (1, sizeof *co);
  586.     co -> offset = type_Qmgr_CountryName_printable;
  587.     co -> un.printable =
  588.         STR2QB (mpduid -> mpduid_DomId.global_Country);
  589.  
  590.     admd = gdi -> admd =
  591.         (struct type_Qmgr_AdministrationDomainName *)
  592.             calloc (1, sizeof *admd);
  593.     admd -> offset = type_Qmgr_AdministrationDomainName_printable;
  594.     admd -> un.printable =
  595.         STR2QB (mpduid -> mpduid_DomId.global_Admin);
  596.  
  597.     if (mpduid -> mpduid_DomId.global_Private) {
  598.         prmd = gdi -> prmd =
  599.             (struct type_Qmgr_PrivateDomainIdentifier *)
  600.                 calloc (1, sizeof *prmd);
  601.         prmd -> offset = type_Qmgr_PrivateDomainIdentifier_printable;
  602.         prmd -> un.printable =
  603.             STR2QB (mpduid -> mpduid_DomId.global_Private);
  604.     }
  605.     else
  606.         gdi -> prmd = NULL;
  607.  
  608.     return mp;;
  609. }
  610.  
  611. struct type_Qmgr_EncodedInformationTypes *leit (eit)
  612. LIST_BPT *eit;
  613. {
  614.     struct type_Qmgr_EncodedInformationTypes *et = NULL, *ep;
  615.     LIST_BPT *bp;
  616.  
  617.     for (bp = eit; bp; bp = bp -> li_next) {
  618.         ep = (struct type_Qmgr_EncodedInformationTypes *)
  619.             calloc (1, sizeof *eit);
  620.         if (et == NULL)
  621.             et = ep;
  622.         ep -> PrintableString = STR2QB (bp -> li_name);
  623.         ep = ep -> next;
  624.     }
  625.     return et;
  626. }
  627.  
  628. struct type_Qmgr_RecipientList *lreciplist (recips, info)
  629. Reciplist *recips;
  630. char    *info;
  631. {
  632.     struct type_Qmgr_RecipientList *rlbase = NULL, *rl = NULL;
  633.     Reciplist *rlp;
  634.  
  635.     for (rlp = recips; rlp != NULLRL; rlp = rlp -> rp_next) {
  636.         if (rlbase == NULL)
  637.             rlbase = rl = (struct type_Qmgr_RecipientList *)
  638.                 calloc (1, sizeof *rl);
  639.         else {
  640.             rl -> next = (struct type_Qmgr_RecipientList *)
  641.                 calloc (1, sizeof *rl);
  642.             rl = rl -> next;
  643.         }
  644.         rl -> RecipientInfo = lrecip (rlp, recips, info);
  645.     }
  646.     return rlbase;
  647. }
  648.  
  649. struct type_Qmgr_RecipientInfo *lrecip (rlp, rl0, info)
  650. Reciplist *rlp;
  651. Reciplist *rl0;
  652. char    *info;
  653. {
  654.     struct type_Qmgr_RecipientInfo *ri;
  655.  
  656.     ri = (struct type_Qmgr_RecipientInfo *) calloc (1, sizeof *ri);
  657.  
  658.     ri -> user = STR2QB (rlp -> user);
  659.     ri -> id = (struct type_Qmgr_RecipientId *)
  660.         calloc (1, sizeof *ri -> id);
  661.     ri -> id -> parm = rlp -> id;
  662.     ri -> mta = STR2QB (rlp -> mta);
  663.  
  664.     switch (rlp -> status) {
  665.         case ST_NORMAL:
  666.         {
  667.             LIST_RCHAN *lcp;
  668.  
  669.             ri -> channelsDone = 0;
  670.             ri -> channelList = lchanlist (rlp -> chans);
  671.             for (lcp = rlp -> chans; lcp && lcp != rlp -> cchan;
  672.                  lcp = lcp -> li_next)
  673.                 ri -> channelsDone ++;
  674.         }
  675.         break;
  676.  
  677.         case ST_DR:
  678.         ri -> channelsDone = 0;
  679.         ri -> channelList = lchanlist (rl0 -> chans);
  680.         break;
  681.  
  682.         case ST_DELETE:
  683.         ri -> channelsDone = 0;
  684.         ri -> channelList = (struct type_Qmgr_ChannelList *)
  685.             smalloc (sizeof *ri -> channelList);
  686.         ri -> channelList -> Channel =
  687.             STR2QB (delete_chan -> channame);
  688.         ri -> channelList -> next = NULL;
  689.         break;
  690.  
  691.         case ST_TIMEOUT:
  692.         ri -> channelsDone = 0;
  693.         ri -> channelList = (struct type_Qmgr_ChannelList *)
  694.             smalloc (sizeof *ri -> channelList);
  695.         ri -> channelList -> Channel =
  696.             STR2QB (timeout_chan -> channame);
  697.         ri -> channelList -> next = NULL;
  698.         break;
  699.     }
  700.  
  701.     ri -> procStatus = (struct type_Qmgr_ProcStatus *)
  702.         calloc (1, sizeof *ri -> procStatus);
  703.     ri -> procStatus -> enabled = rlp -> msg_enabled;
  704.     if (rlp -> cache.cachetime > current_time)
  705.         ri -> procStatus -> cachedUntil =
  706.             ltime (rlp -> cache.cachetime);
  707.     if (info)
  708.         ri -> info = STR2QB (info);
  709.     else    ri -> info = NULL;
  710.     return ri;
  711. }
  712.  
  713. struct type_Qmgr_ChannelList *lchanlist (chans)
  714. LIST_RCHAN *chans;
  715. {
  716.     struct type_Qmgr_ChannelList *clp;
  717.  
  718.     if (chans == NULL)
  719.         return NULL;
  720.  
  721.     clp = (struct type_Qmgr_ChannelList *) calloc (1, sizeof *clp);
  722.  
  723.     clp -> Channel = STR2QB (chans -> li_chan -> ch_name);
  724.     clp -> next = lchanlist (chans -> li_next);
  725.     return clp;
  726. }
  727.  
  728.     
  729. void freems (ms)
  730. MsgStruct *ms;
  731. {
  732.     freerecips (ms->recips);
  733.     if (ms -> uacontent)
  734.         free (ms -> uacontent);
  735.     list_bpt_free (ms -> eit);
  736.     if (ms -> contenttype)
  737.         free (ms -> contenttype);
  738.     if (ms -> originator)
  739.         free (ms -> originator);
  740.     freempdu (ms -> mpduid);
  741.     if (ms -> queid)
  742.         free (ms -> queid);
  743.     free ((char *)ms);
  744. }
  745.  
  746. void freerecips (rlist)
  747. Reciplist *rlist;
  748. {
  749.     if (rlist == NULLRL)
  750.         return;
  751.     freerecips (rlist -> rp_next);
  752.     list_rchan_free (rlist -> chans);
  753.     free (rlist -> mta);
  754.     free (rlist -> user);
  755.  
  756.     free ((char *)rlist);
  757. }
  758.  
  759. void freempdu (mp)
  760. MPDUid *mp;
  761. {
  762.     MPDUid_free (mp);
  763.     free ((char *)mp);
  764. }
  765.  
  766. void freefilter (f)
  767. Filter    *f;
  768. {
  769.     if (f -> cont)
  770.         free (f -> cont);
  771.     if (f -> eit)
  772.         list_bpt_free (f -> eit);
  773.     if (f -> orig)
  774.         free (f -> orig);
  775.     if (f -> recip)
  776.         free (f -> recip);
  777.     if (f -> mta)
  778.         free (f -> mta);
  779.     if (f -> queid)
  780.         free (f -> queid);
  781.     if (f -> mpduid)
  782.         freempdu (f -> mpduid);
  783.     if (f -> uacontent)
  784.         free (f -> uacontent);
  785.     if (f -> next)
  786.         freefilter (f -> next);
  787.     free ((char *)f);
  788. }
  789.