コード例 #1
0
ファイル: str_trim.c プロジェクト: Rick33/freevms
/*************************************************************
 * str$trim
 *
 */
unsigned long str$trim(struct dsc$descriptor_s* destination_string,
	const struct dsc$descriptor_s* source_string,
	unsigned short* resultant_length)
{
	char* s2_ptr;				/* Pointer to string */
	unsigned short s2_length;		/* Length of string */
	unsigned long result;			/* Result */

	/*
	 * Look at the original string
	 */
	str$analyze_sdesc(source_string, &s2_length, &s2_ptr);

	/*
	 * Determine the end of the string
	 */
	while ((s2_length > 0) &&
		((s2_ptr[s2_length-1] == ' ') || (s2_ptr[s2_length-1] == '\t')))
	{
		s2_length--;
	}

	/*
	 * Now, copy that much to the destination
	 */
	result = str$copy_r(destination_string, &s2_length, s2_ptr);
	*resultant_length = s2_length;

	/*
	 * Done
	 */
	return result;
}
コード例 #2
0
ファイル: sp_mgr.c プロジェクト: SysMan-One/mmk
/*
**++
**  ROUTINE:	sp_receive
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Get some output from the subprocess, if any.  Uses IO$M_NOW modifier
**  so that if there isn't anything available, we return an error status
**  rather than blocking until something comes up.
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	sp_receive(SPHANDLE *ctxpp, struct dsc$descriptor *rcvstr,
**  	    	    	int *rcvlen)
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**  	    SS$_NORMAL:  normal successful completion
**  	    SS$_NONEXPR: subprocess doesn't exist any more
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int sp_receive (SPHANDLE *ctxpp, void *rcvstr, int *rcvlen) {

    SPHANDLE ctx;
    unsigned int status, efstate;

    ctx = *ctxpp;
    if (sys$readef(ctx->termefn, &efstate) != SS$_WASCLR) return SS$_NONEXPR;

    status = sys$qiow(0, ctx->outchn, IO$_READVBLK|IO$M_NOW, ctx->iosb,
    	    	0, 0, ctx->bufptr, ctx->bufsiz, 0, 0, 0, 0);
    if (OK(status)) status = ctx->iosb[0];
    if (OK(status)) {
    	str$copy_r(rcvstr, &ctx->iosb[1], ctx->bufptr);
    	if (rcvlen) *rcvlen = ctx->iosb[1];
    }

    return status;

} /* sp_receive */
コード例 #3
0
ファイル: netlib_ucx.c プロジェクト: SysMan-One/netlib
/*
**++
**  ROUTINE:	NETLIB_GET_HOSTNAME
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Obtains the local host name configured for this TCP/IP package.
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_get_hostname (void *bufdsc, unsigned short *retlenp) {

    char buf[256];
    unsigned int status;
    unsigned short retlen;
    int argc;

    SETARGCOUNT(argc);

    if (gethostname(buf, sizeof(buf)) < 0) return SS$_ABORT;
    retlen = strlen(buf);

    status = str$copy_r(bufdsc, &retlen, buf);
    if (!OK(status)) return status;
    if (argc > 1 && retlenp != 0) *retlenp = retlen;

    return SS$_NORMAL;

} /* netlib_get_hostname */
コード例 #4
0
ファイル: str_len_extr.c プロジェクト: rroart/freevms
/*************************************************************
 * str$len_extr
 *
 */
unsigned long str$len_extr(struct dsc$descriptor_s* destination_string,
                           const struct dsc$descriptor_s* source_string,
                           const long* start_position,
                           const long* longword_integer_length)
{
    char* s2_ptr;	 	 		/* Pointer to second string */
    unsigned short s2_length;	 	/* Length of second string */
    int final_length;			/* Signed final length */
    unsigned short real_final_length;	/* Usable final length */
    unsigned long result;			/* Result */
    unsigned long second_result = STR$_NORMAL; /* Another possible result */
    int start_offset = *start_position;	/* Real start character */

    /*
     * Validate input
     */
    if (start_offset <= 0)
    {
        start_offset = 1;
        second_result = STR$_STRTOOLON;
    }

    /*
     * Determine how much we can use
     */
    str$analyze_sdesc(source_string, &s2_length, &s2_ptr);
    if (*longword_integer_length < s2_length - (start_offset - 1))
    {
        final_length = *longword_integer_length;
    }
    else
    {
        final_length = s2_length - (start_offset - 1);
    }

    /*
     * Now validate the final; length
     */
    if (final_length < 0)
    {
        real_final_length = 0;
        second_result = STR$_STRTOOLON;
    }
    else
    {
        real_final_length = (unsigned short) final_length;
    }

    /*
     * Move over the left part of the string
     */
    s2_ptr += start_offset - 1;
    result = str$copy_r(destination_string,
                        &real_final_length, s2_ptr);

    /*
     * Done
     */
    if (result == STR$_NORMAL)
    {
        return second_result;
    }
    else
    {
        return result;
    }
}
コード例 #5
0
ファイル: netlib_ucx.c プロジェクト: SysMan-One/netlib
/*
**++
**  ROUTINE:	io_completion
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
static unsigned int io_completion (struct IOR *ior) {

    struct CTX *ctx = ior->ctx;

    ior->iorflags |= IOR_M_IO_COMPLETED;

    if (ior->iorflags & IOR_M_IO_TIMED) sys$cantim(ior, 0);

    if (ior->iosb.iosb_w_status == SS$_CANCEL && (ior->iorflags & IOR_M_IO_TIMEOUT))
    	ior->iosb.iosb_w_status = SS$_TIMEOUT;

    if (ior->iosbp != 0) netlib___cvt_iosb(ior->iosbp, &ior->iosb);


    if (ior->iorflags & IOR_M_COPY_LENGTH) {
    	if (OK(ior->iosb.iosb_w_status) && ior->spec_retlen != 0)
    	    	*(unsigned int *) ior->spec_retlen = ior->spec_length;
    	ior->iorflags &= ~IOR_M_COPY_LENGTH;
    }

    if (ior->iorflags & IOR_M_COPY_FROM) {
    	if (OK(ior->iosb.iosb_w_status) && ior->spec_userfrom != 0) {
    	    unsigned int len;
    	    len = ior->specior.fromlen;
    	    if (len > ior->spec_length) len = ior->spec_length;
    	    memcpy(ior->spec_userfrom, &ior->specior.from, len);
    	    if (ior->spec_retlen != 0) *(unsigned int *)ior->spec_retlen = len;
    	 }
    	 ior->iorflags &= ~IOR_M_COPY_FROM;
    }

    if (ior->iorflags & IOR_M_COPY_ADDRS) {
    	struct HOSTENT *h;

    	h = ior->spec_hostent;
    	if (OK(ior->iosb.iosb_w_status)) {
    	    char *base;
    	    unsigned int *offlst;
    	    int i;
    	    base = (char *) h;
    	    i = 0;
    	    if (h->addrlist_offset != 0) {
    	    	struct INADDRDEF *alist = ior->spec_useralist;
    	    	offlst = (unsigned int *) (base+h->addrlist_offset);
    	    	while (i < ior->spec_length && offlst[i] != 0) {
    	    	    alist[i] = *(struct INADDRDEF *) (base + offlst[i]);
    	    	    i++;
    	    	}
    	    }
    	    if (ior->spec_retlen != 0) *(unsigned int *)ior->spec_retlen = i;
    	}
    	lib$free_vm(&hostent_size, &h);
    	ior->iorflags &= ~IOR_M_COPY_ADDRS;
    }

    if (ior->iorflags & IOR_M_COPY_HOSTNAME) {
    	struct HOSTENT *h;
    	h = ior->spec_hostent;
    	if (OK(ior->iosb.iosb_w_status)) {
    	    str$copy_r(ior->spec_usrdsc, &ior->specior.fromlen,
    	    	    	    	    	h->buffer);
    	    if (ior->spec_retlen != 0)
    	    	*(unsigned short *)ior->spec_retlen =
    	    	    	    	    	    	ior->specior.fromlen;
    	}
    	lib$free_vm(&hostent_size, &h);
    	ior->iorflags &= ~IOR_M_COPY_HOSTNAME;
    }

    if (ior->iorflags & IOR_M_NEW_CONTEXT) {
    	if (OK(ior->iosb.iosb_w_status)) {
    	    *(struct CTX **) ior->spec_xnewctx = ior->spec_newctx;
    	} else {
    	    sys$dassgn(((struct CTX *)ior->spec_newctx)->chan);
    	    netlib___free_ctx((struct CTX *) ior->spec_newctx);
    	}
    	   ior->iorflags &= ~IOR_M_NEW_CONTEXT;
    }

    if (ior->astadr != 0) (*(ior->astadr))(ior->astprm);

    FREE_IOR(ior);

    return SS$_NORMAL;

} /* io_completion */
コード例 #6
0
ファイル: netlib_ucx.c プロジェクト: SysMan-One/netlib
/*
**++
**  ROUTINE:	netlib_address_to_name
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Uses the UCX IO$_ACPCONTROL $QIO function to translate an
**  IP address into a host name.
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	NETLIB_ADDRESS_TO_NAME  ctx, which, addr, addrsize, namdsc [,retlen] [,iosb] [,astadr] [,astprm]
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_address_to_name (struct CTX **xctx, unsigned int *whichp,
    	    	    	    struct INADDRDEF *addr,
    	    	    	    unsigned int *addrsize,
    	    	    	    struct dsc$descriptor *namdsc,
    	    	    	    unsigned short *retlen,
    	    	    	    struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {

    struct CTX *ctx;
    struct NETLIBIOSBDEF myiosb;
    ITMLST2 subfdsc, entdsc, adrdsc;
    unsigned int status, subfunction;
    char buf[1024];
#ifdef TCPWARE
    char tmp[64];
    struct dsc$descriptor tmpdsc;
#endif /* TCPWARE */
    unsigned short length;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (argc < 5) return SS$_INSFARG;

    if (addr == 0 || addrsize == 0 || namdsc == 0) return SS$_BADPARAM;
    if (*addrsize != sizeof(struct INADDRDEF)) return SS$_BADPARAM;

#ifdef TCPWARE
    INIT_SDESC (tmpdsc, sizeof(tmp), tmp);
    status = netlib_addrtostr(addr, &tmpdsc, &tmpdsc.dsc$w_length);
    if (!OK(status)) return status;
#else
    ITMLST2_INIT(adrdsc, 0, *addrsize, addr);
#endif /* TCPWARE */
    if (argc > 7 && astadr != 0) {
    	struct IOR *ior;
    	struct HOSTENT *h;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);
    	status = lib$get_vm(&hostent_size, &h);
    	if (!OK(status)) {
    	    FREE_IOR(ior);
    	    return status;
    	}
    	ior->spec_usrdsc = namdsc;
    	ior->spec_retlen = retlen;
    	ior->specior.subfunction =
#ifndef TCPWARE
    	    (INETACP$C_TRANS << 8) |
#endif /* not TCPWARE */
    	    INETACP_FUNC$C_GETHOSTBYADDR;

    	ITMLST2_INIT(subfdsc, 0, sizeof(ior->specior.subfunction),
    	    	    	    &ior->specior.subfunction);
    	ITMLST2_INIT(entdsc, 0, sizeof(h->buffer), h->buffer);
    	ior->spec_hostent = h;
    	ior->iorflags = IOR_M_COPY_HOSTNAME;
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_ACPCONTROL, &ior->iosb,
    	    	    	    io_completion, ior, &subfdsc,
#ifdef TCPWARE
    	    	    	    &tmpdsc,
#else
    	    	    	    &adrdsc,
#endif /* TCPWARE */
    	    	    	    &ior->specior.fromlen, &entdsc, 0, 0);
    	if (!OK(status)) FREE_IOR(ior);
    	return status;
    }

    subfunction =
#ifndef TCPWARE
    	    	  (INETACP$C_TRANS << 8) |
#endif
    	    	  INETACP_FUNC$C_GETHOSTBYADDR;

    ITMLST2_INIT(subfdsc, 0, sizeof(subfunction), &subfunction);
    ITMLST2_INIT(entdsc, 0, sizeof(buf), buf);
    status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_ACPCONTROL, &myiosb,
    	    	    	0, 0, &subfdsc,
#ifdef TCPWARE
    	    	    	&tmpdsc,
#else
    	    	    	&adrdsc,
#endif /* TCPWARE */
    	    	    	&length, &entdsc, 0, 0);
    if (OK(status)) status = netlib___cvt_status(&myiosb);
    if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    if (OK(status)) {
    	str$copy_r(namdsc, &length, buf);
    	if (argc > 5 && retlen != 0) *retlen = length;
    }

    return status;

} /* netlib_address_to_name */
コード例 #7
0
ファイル: strutil.c プロジェクト: Rick33/freevms
void str$$malloc_sd(struct dsc$descriptor_s *temp_sd, char *string)
{
int i;
unsigned short temp_len;
char	maxstring [MAXCSTR16], temp_string[5];

if ( strcmp(string,"NULL") == 0 )
{
	temp_sd->dsc$w_length  = 0;
	temp_sd->dsc$b_class   = DSC$K_CLASS_D;
	temp_sd->dsc$b_dtype   = DSC$K_DTYPE_T;
	temp_sd->dsc$a_pointer = NULL;
}
// make the largest number possible 65535 9's
else if ( strcmp(string,"MAXCSTR16") == 0 )
{
	for (i=0; i < MAXCSTR16; i++)
		maxstring[i] = '9';
	temp_sd->dsc$w_length  = 0;
	temp_sd->dsc$b_class   = DSC$K_CLASS_D;
	temp_sd->dsc$b_dtype   = DSC$K_DTYPE_T;
	temp_sd->dsc$a_pointer = NULL;
	
	temp_len = MAXCSTR16;
	str$get1_dx (&temp_len, temp_sd);
	str$copy_r  (temp_sd, &temp_len, maxstring);

}
else if ( strcmp(string,"BLANK") == 0 )
{
	temp_sd->dsc$w_length  = 0;
	temp_sd->dsc$b_class   = DSC$K_CLASS_D;
	temp_sd->dsc$b_dtype   = DSC$K_DTYPE_T;
	temp_sd->dsc$a_pointer = NULL;

	temp_len = 1;
	temp_string[0] = ' ';
	str$get1_dx (&temp_len, temp_sd);
	str$copy_r  (temp_sd, &temp_len,temp_string);
}
else if ( strcmp(string,"TAB") == 0 )
{
	temp_sd->dsc$w_length  = 0;
	temp_sd->dsc$b_class   = DSC$K_CLASS_D;
	temp_sd->dsc$b_dtype   = DSC$K_DTYPE_T;
	temp_sd->dsc$a_pointer = NULL;

	temp_len = 1;
	temp_string[0] = '\t';
	str$get1_dx (&temp_len, temp_sd);
	str$copy_r  (temp_sd, &temp_len,temp_string);
}
else
{
/*	default action copy string value in */
	temp_sd->dsc$w_length  = 0;
	temp_sd->dsc$b_class   = DSC$K_CLASS_D;
	temp_sd->dsc$b_dtype   = DSC$K_DTYPE_T;
	temp_sd->dsc$a_pointer = NULL;

	temp_len = strlen (string);
	str$get1_dx (&temp_len, temp_sd);
	str$copy_r  (temp_sd, &temp_len,string);
	
}
return;
}