Ejemplo n.º 1
0
void op_zmess(int4 errnum, ...)
{
	va_list		var;
	int4		status, cnt, faocnt;
	unsigned short	m_len;
	unsigned char	faostat[4];
	unsigned char	msgbuff[MAX_MSG_SIZE + 1];
	unsigned char	buff[FAO_BUFFER_SPACE];
	int4		fao[MAX_FAO_PARMS + 1];
	$DESCRIPTOR(d_sp, msgbuff);

	error_def(ERR_TPRETRY);

	VAR_START(var, errnum);
	va_count(cnt);
	cnt--;
	status = sys$getmsg(errnum, &m_len, &d_sp, 0, &faostat[0]);
	if ((status & 1) && m_len)
	{
		buff[m_len] = 0;
		memset(&fao[0], 0, SIZEOF(fao));
		faocnt = (cnt ? faostat[1] : cnt);
		faocnt = (faocnt > MAX_FAO_PARMS ? MAX_FAO_PARMS : faocnt);
		if (faocnt)
			faocnt = mval2fao(msgbuff, var, &fao[0], cnt, faocnt, buff, buff + SIZEOF(buff));
		va_end(var);
		if (faocnt != -1)
		{
			/* Currently there are a max of 20 fao parms (MAX_FAO_PARMS) allowed, hence passing upto fao_list[19].
			 * An assert is added to ensure this code is changed whenever the macro MAX_FAO_PARMS is changed.
			 * The # of arguments passed below should change accordingly.
			 */
			assert(MAX_FAO_PARMS == 20);
			if (ERR_TPRETRY == errnum)
			{	/* A TP restart is being signalled. Set t_fail_hist just like a TRESTART command would */
				op_trestart_set_cdb_code();
			}
			rts_error(VARLSTCNT(MAX_FAO_PARMS + 2) errnum, faocnt, fao[0], fao[1], fao[2], fao[3], fao[4], fao[5],
				fao[6], fao[7], fao[8], fao[9], fao[10], fao[11], fao[12], fao[13], fao[14], fao[15], fao[16],
				fao[17], fao[18], fao[19]);
		}
		return;
	} else
	{
		va_end(var);
		rts_error(VARLSTCNT(1) status);
	}
}
Ejemplo n.º 2
0
int zlninfo(int unit, char *key, char *format, int *maxlength,
			int *nelement, ...)			/*$$*/
{
   va_list params;
   int nargs;
   int status;

   va_start(params, nelement);

#if NARGS_AVAIL_OS
   va_count(nargs);
   nargs -= 5; /*$$*/	/* Adjust by the number of constant parameters */
#else
   nargs = -1;
#endif

/* Do the common preprocessing */

   status = p_xlninfo(unit);		/*$$*/
   if (status != SUCCESS) {
      v2_error_handler(unit, status);
      va_end(params);
      return status;
   }

   status = v2_process_optionals_c(unit, label_options, N_LABEL_TABLE_ENTRIES,
			        label_table[unit], label_default_table,
			        nargs, &params);
   if (status != SUCCESS) {
      v2_error_handler(unit, status);
      va_end(params);
      return status;
   }

/* Call the common routine */

   status = c_xlninfo(unit, key, format, maxlength, nelement);	/*$$*/
   va_end(params);
   if (status != SUCCESS) {
      v2_error_handler(unit, status);
      return status;
   }

   return SUCCESS;

}
Ejemplo n.º 3
0
int zlhinfo(int unit, char *tasks, int *instances, int *nhist, ...)	/*$$*/
{
   va_list params;
   int nargs;
   int status;

   va_start(params, nhist);		/*$$*/

#if NARGS_AVAIL_OS
   va_count(nargs);
   nargs -= 4; /*$$*/	/* Adjust by the number of constant parameters */
#else
   nargs = -1;
#endif

/* Do the common preprocessing */

   status = p_xlhinfo(unit);		/*$$*/
   if (status != SUCCESS) {
      v2_error_handler(unit, status);
      va_end(params);
      return status;
   }

   status = v2_process_optionals_c(unit, label_options, N_LABEL_TABLE_ENTRIES,
			     label_table[unit], label_default_table,
			     nargs, &params);
   if (status != SUCCESS) {
      v2_error_handler(unit, status);
      va_end(params);
      return status;
   }

/* Call the common routine */

   status = c_xlhinfo(unit, tasks, instances, nhist, LABEL_I_VALUE(ULEN));/*$$*/
   va_end(params);
   if (status != SUCCESS) {
      v2_error_handler(unit, status);
      return status;
   }

   return SUCCESS;

}
Ejemplo n.º 4
0
/*
**++
**  ROUTINE:	cat
**
**  FUNCTIONAL DESCRIPTION:
**
**	Concatenates strings, dynamically.  Arguments following the input
**  string (which must be a pointer of zero or to a null-terminated, malloc'd
**  string) must be a string, length pair.  If the length is -1, the string
**  is assumed to be null-terminated and the length taken from the string
**  with strlen.
**
**	There is a special case that if the last argument is odd (as int,
**  no length) it is assumed that the last string is already null-terminated
**  and the length is taken with strlen.
**
**  RETURNS:	pointer to char
**
**  PROTOTYPE:
**
**  	cat(char *in, [ char *, int , ... [ char *])
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**  	    0: memory allocation error
**  	non-0: pointer to the character
**
**  SIDE EFFECTS:   	Uses malloc/realloc to allocate all storage, the
**			caller needs to free this themselves using free.
**
**--
*/
char *cat(char *in, ...) {

    int actualcount;
    va_list ap;
    char *str, *out, *outp;
    int i, inlen, len, outlen;

    outlen = inlen = (in == (char *)0) ? 0 : strlen(in);
    va_count(actualcount);
    va_start(ap, in);
    i = 1;
    while (i < actualcount) {
	str = va_arg(ap, char *);
	if (++i < actualcount) {
	    i++;
	    len = va_arg(ap, int);
	    outlen += (len != -1) ? len : strlen(str);
	} else {
Ejemplo n.º 5
0
void op_zmess(int4 errnum, ...)
{
	va_list		var;
	int4		status, cnt, faocnt;
	unsigned short	m_len;
	unsigned char	faostat[4];
	unsigned char	msgbuff[MAX_MSG_SIZE + 1];
	unsigned char	buff[FAO_BUFFER_SPACE];
	int4		fao[MAX_FAO_PARMS];
	$DESCRIPTOR(d_sp, msgbuff);

	VAR_START(var, errnum);
	va_count(cnt);
	cnt--;
	assert(34 == MAX_FAO_PARMS);			/* Defined in fao_parm.h. */
	status = sys$getmsg(errnum, &m_len, &d_sp, 0, &faostat[0]);
	if ((status & 1) && m_len)
	{
		buff[m_len] = 0;
		memset(&fao[0], 0, SIZEOF(fao));
		faocnt = (cnt ? faostat[1] : cnt);
		faocnt = (faocnt > MAX_FAO_PARMS ? MAX_FAO_PARMS : faocnt);
		if (faocnt)
			faocnt = mval2fao(msgbuff, var, &fao[0], cnt, faocnt, buff, buff + SIZEOF(buff));
		va_end(var);
		if (faocnt != -1)
		{
			if (ERR_TPRETRY == errnum)
			{	/* A TP restart is being signalled. Set t_fail_hist just like a TRESTART command would */
				op_trestart_set_cdb_code();
			}
			rts_error_csa(CSA_ARG(NULL) VARLSTCNT(MAX_FAO_PARMS + 2) errnum, faocnt, fao[0], fao[1], fao[2], fao[3],
				fao[4], fao[5], fao[6], fao[7], fao[8], fao[9], fao[10], fao[11], fao[12], fao[13], fao[14],
				fao[15], fao[16], fao[17], fao[18], fao[19], fao[20], fao[21], fao[22], fao[23], fao[24], fao[25],
				fao[26], fao[27], fao[28], fao[29], fao[30], fao[31], fao[32], fao[33]);
		}
		return;
	} else
	{
		va_end(var);
		rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) status);
	}
}
Ejemplo n.º 6
0
void sgtm_putmsg(char *out_str, ...)
{
	va_list	var;
	int	arg_count, dummy, fao_actual, fao_count, fao_list[MAX_FAO_PARMS + 1], i, msg_id;
	char	msg_buffer[1024];
	mstr	msg_string;
	int	util_outbufflen;
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	VAR_START(var, out_str);
	va_count(arg_count);
	arg_count--;
	assert(arg_count > 0);
	util_out_print(NULL, RESET);

	for (;;)
	{
		msg_id = va_arg(var, int);
		--arg_count;

		msg_string.addr = msg_buffer;
		msg_string.len = SIZEOF(msg_buffer);
		gtm_getmsg(msg_id, &msg_string);

		if (arg_count > 0)
		{
			fao_actual = va_arg(var, int);
			--arg_count;

			fao_count = fao_actual;
			if (fao_count > MAX_FAO_PARMS)
			{
				assert(FALSE);
				fao_count = MAX_FAO_PARMS;
			}
		}
		else
Ejemplo n.º 7
0
void op_fnzcall(mval *dst, ...)
{
	va_list		var;
	mval 		*v;
	int4		n_mvals;	/* number of input parameters supplied in $ZCALL command */
	int		i;
	mval		*mvallist[256];
	zctabrtn	*zcrtn;
	unsigned char	*lastout;
	error_def	(ERR_ZCALLTABLE);
	error_def	(ERR_ZCRTENOTF);
	error_def	(ERR_ZCARGMSMTCH);


	VAR_START(var, dst);
	va_count(n_mvals);
	v = va_arg(var, mval *);
	MV_FORCE_STR(v);

	zcrtn = zctab;
	while (zcrtn < zctab_end)
	{
		if (!zcrtn->entry_length)
		{
			va_end(var);
			rts_error(VARLSTCNT(1) ERR_ZCALLTABLE);
		}
		if (zcrtn->callnamelen == 0)
		{
			va_end(var);
			rts_error(VARLSTCNT(1) ERR_ZCALLTABLE);
		}
		if ((zcrtn->callnamelen == v->str.len) &&
			!memcmp (zcrtn->callname, v->str.addr, v->str.len))
			break;
		zcrtn = (zctabrtn *) ((char *) zcrtn + zcrtn->entry_length);
	}

	if (zcrtn == zctab_end)
	{
		va_end(var);
		rts_error(VARLSTCNT(4) ERR_ZCRTENOTF, 2, v->str.len, v->str.addr);
	}

	n_mvals -= 2;
	if (n_mvals > zcrtn->n_inputs)
	{
		va_end(var);
		rts_error(VARLSTCNT(4) ERR_ZCARGMSMTCH, 2, n_mvals, zcrtn->n_inputs);
	}

	lastout = (unsigned char *) zcrtn
		  + ROUND_UP(SIZEOF(zctabrtn) + zcrtn->callnamelen - 1 + SIZEOF(zctabret), SIZEOF(int4))
		  + zcrtn->n_inputs * SIZEOF(zctabinput)
		  + zcrtn->n_outputs * SIZEOF(zctaboutput);

	if (ROUND_UP((int) lastout + 1, SIZEOF(int4)) != (unsigned char *) zcrtn + zcrtn->entry_length)
	{
		va_end(var);
		rts_error(VARLSTCNT(1) ERR_ZCALLTABLE);
	}

	for (i = 0;  i < n_mvals;  ++i)
		mvallist[i] = va_arg(var, mval *);
	va_end(var);

	zc_makespace (dst, 0, mvallist, &mvallist[n_mvals], zcrtn, *lastout);
	return;
}