Exemplo n.º 1
0
unsigned long SysAddRexxMacro(unsigned char *name,
                           unsigned long numargs,
                           RXSTRING args[],
                           char *queuename,
                           RXSTRING *retstr)
{
    unsigned long position;              /* added position             */

    if (numargs < 2 || numargs > 3 ||    /* wrong number?              */
        !RXVALIDSTRING(args[0]) ||       /* first is omitted           */
        !RXVALIDSTRING(args[1]))         /* second is omitted          */
      return INVALID_ROUTINE;            /* raise error condition      */

    position = RXMACRO_SEARCH_BEFORE;    /* set default search position*/

    if (numargs == 3) {                  /* have an option?            */
        if (RXZEROLENSTRING(args[2])) return INVALID_ROUTINE;
        else if (toupper(args[2].strptr[0]) == 'B') position = RXMACRO_SEARCH_BEFORE;
        else if (toupper(args[2].strptr[0]) == 'A') position = RXMACRO_SEARCH_AFTER;
        else return INVALID_ROUTINE;   /* raise an error             */
    }
    /* try to add the macro       */

    RETVAL(RexxAddMacro(args[0].strptr, args[1].strptr, position))
}
Exemplo n.º 2
0
/*
 * GCI_migrateRxString converts a RXSTRING into a GCI_str. No further memory
 * allocation is done and it is STRONGLY forbidden to use GCI_strfree.
 * The return value shall be used for further operations.
 */
static const GCI_str *GCI_migrateRxString( GCI_str *str,
                                           const RXSTRING *string )
{
   if ( !RXVALIDSTRING( *string ) && !RXZEROLENSTRING( *string ) )
   {
      str->val = NULL;
      str->used = str->max = 0;
   }
   else
   {
      str->val = (char *) RXSTRPTR( *string );
      str->used = str->max = (int) RXSTRLEN( *string );
   }
   return str;
}
Exemplo n.º 3
0
unsigned long SysReorderRexxMacro(unsigned char *name,
                           unsigned long numargs,
                           RXSTRING args[],
                           char *queuename,
                           RXSTRING *retstr)
{
    unsigned long position;                /* added position             */

    if (numargs != 2 || !RXVALIDSTRING(args[0]) || RXZEROLENSTRING(args[1]))
        return INVALID_ROUTINE;            /* raise error condition      */

    /* 'B'efore?                  */
    if (toupper(args[1].strptr[0]) == 'B') position = RXMACRO_SEARCH_BEFORE;
    else if (toupper(args[1].strptr[0]) == 'A') position = RXMACRO_SEARCH_AFTER;
    else return INVALID_ROUTINE;

    /* try to add the macro       */
    RETVAL(RexxReorderMacro(args[0].strptr, position))
}
Exemplo n.º 4
0
ULONG RxDllFunc1(CHAR *name,      /* User Routine name */
	ULONG numargs,      /* Number of arguments */
	RXSTRING args[],    /* Null-terminated RXSTRINGs array*/
	CHAR *queuename,    /* Current external data queue name */
	RXSTRING *retstr)   /* return RXSTRING  */
{
	CHAR string[255];    /*local scratch buffers*/
	CHAR buff[255];
	ULONG i,j,k;         /*local counters*/

/* Example Function: accessing arguments */
/* This function returns # of args passed and the length of each argument*/

#ifdef ArgCount1  /*if defined, check for correct # of arguments*/
	if (numargs != ArgCount1) { return FUNC_FAILED;}  /*return error code(40) if bad*/
#endif
	ultoa(numargs,string,10);            /*number of arguments passed*/
	i = 0;
	while (i<numargs){                   /*step thru arguments*/
		strlcat(string," ",sizeof(string));          /*spacer*/
		if (RXNULLSTRING(args[i])) { strcat(string,"N");} /*null arg, return N*/
		else {
			if (RXZEROLENSTRING(args[i])) { strlcat(string,"0",sizeof(string));}              /*null string, return 0*/
			else {                                                                            /*non-null string passed*/

				/*accesse the actual parameter and protects the buffer from overrun*/
				strlcpy(buff,args[i].strptr,min(args[i].strlength+1,sizeof(buff)));       /* copy to buff as a C-string*/

				/*convert the arg length to a string and append to the buffer*/
				utoa(args[i].strlength,buff,10); strlcat(string,buff,sizeof(string));     /*return size: note: buff gets wacked!*/
			}
		}
		i++;    /*next arg*/
	}
	strlcpy(retstr->strptr,string,255);            /*trim string if over default return string length*/
	retstr->strlength = strlen(retstr->strptr);    /*return actual length*/
	return FUNC_OK;                                /*successful return code(0)*/
}