/* SUBPROC.C */

#include <p_std.h>
#include <p_gen.h>
#include <p_math.h>
#include <epoc.h>
#include "subproc.h"

GLREF_C TEXT *DatCommandPtr;


GLDEF_C INT main(VOID)
    {
    TEXT *pb;
    SUBPROC_CL *pcl;
    UWORD answer;
    WORD logstat;

    pb=DatCommandPtr+p_slen(DatCommandPtr)+1;
    if (*pb!=sizeof(SUBPROC_CL))
        return(E_GEN_ARG);
    pcl=(SUBPROC_CL *)(pb+1);
    if (!p_logona(pcl->pid,&logstat))
        {
        answer=(UWORD)(p_randl(&pcl->data)%(2*60*32));
        p_sleept(answer);
        if (logstat<0)
            p_pcpyto(pcl->pid,pcl->poff,&answer,sizeof(UWORD));
        }
    return(0);
    }
