示例#1
0
static void
map_funny(char *str)
{
    register char	*from = str;
    register char	*to = str;

    /*
    **	Fix 9005: using wrong test, wasn't mapping Kanji chars, so VMS 
    **		filenames were bad.
    **	WARNING: this means we won't support Kanji filenames!
    **		Also, this doesn't solve the problem of 8-bit chars in the
    **		European character sets.  We need a CMlegal_filename_char
    **		routine.
    */

    /* map any funny bytes to underscores. */
    while (*from != EOS)
    {
	i4	cnt = CMbytecnt(from);

	if ( (!CMalpha(from) && !CMdigit(from)) || CMdbl1st(from) )
	    *to++ = '_';
	else
	    *to++ = *from;
	from += cnt;
    }
    *to = EOS;
}
示例#2
0
STATUS
s_srem_set()
{
    char	*s;
    char	*send;
    i4		pos;
    i4		n;
    char	short_remark[OOSHORTREMSIZE+1];

    if (St_sr_given)
    {
	s_error(0x3A8, NONFATAL, NULL);
	s_cmd_skip();
	return FAIL;
    }
    if (Cact_ren == NULL)
    {
	    s_error(0x38A, FATAL, NULL);
    }

    St_sr_given = TRUE;

    Tokchar++;
    while (CMspace(Tokchar) || *Tokchar == '\t')
    {
	CMnext(Tokchar);
    }

    s = short_remark;
    send = s + OOSHORTREMSIZE;
    while (*Tokchar != '\n' && *Tokchar != EOS)
    {
        if (s <= send-CMbytecnt(Tokchar))
	{
	    if (*Tokchar == '\t')
	    {
		/* if tab, replace it with the one blank */
		*s = ' ';
		s++;
		Tokchar++;
	    }
	    else
	    {
		CMcpyinc(Tokchar, s);
	    }
	}
	else
	{
	    CMnext(Tokchar);
	}
    }

    *s = EOS;
    Cact_ren->ren_shortrem = STalloc(short_remark);

    return OK;
}
示例#3
0
VOID
s_cmd_skip()
{
	i4	type;
	i4     rtn_char;               /* dummy variable for sgskip */

	type = s_g_skip(FALSE, &rtn_char);
	while (!((type == TK_PERIOD && CMalpha(Tokchar+CMbytecnt(Tokchar))) ||
		 type == TK_ENDFILE))
	{
		type = s_g_skip(TRUE, &rtn_char);
	}
}
示例#4
0
文件: wtsupld.c 项目: akdh/Ingres
/*
** Name: Disp_Form
**
** Decription:
**      Disposition: form-data; recevied with no filename.  Implies a page
**      variable name.
**      Extract the variable and store it in the upload structure for use
**      later.
**
** Inputs:
**      sess        ice session structure
**      line        pointer to the current line
**      linelen     length of the line
**
** Outputs:
**      pos         number of characters handled.
**
** Return:
**      GSTAT_OK    success
**      other       failure
**
** History:
**      23-Oct-98 (fanra01)
**          Created.
*/
static GSTATUS
Disp_Form (WTS_SESSION* sess, char* line, i4  linelen, i4 * pos)
{
    GSTATUS     err = GSTAT_OK;
    PWTS_UPLOAD load= sess->load;
    char*       p = line + *pos;
    char*       varname;
    i4          remain = linelen - *pos;
    i4          i = 0;
    i4          j = 0;

    if (STbcompare ("name", 4, p, 0, TRUE) == 0)
    {
        /*
        ** Find the first quote after name
        */
        while ((*p != '\"') && (i < remain))
        {
            CMbyteinc(i,p);
            CMnext(p);
        }
        CMbyteinc(i,p);     /* skip the quote */
        CMnext(p);
        varname= p;
        while ((*p != '\"') && (i < remain))
        {
            j+=CMbytecnt(p);
            CMbyteinc(i,p);
            CMnext(p);
        }
        CMbyteinc(i,p);     /* skip the quote */
        CMnext(p);
        /*
        ** Allocate space for the variable name a '=' character and an EOS
        */
        if ((err = GAlloc (&load->varname, j+2, FALSE)) == GSTAT_OK)
        {
            MEfill (j+2, 0, load->varname);
            MECOPY_VAR_MACRO (varname, j, load->varname);
            STcat (load->varname, "=");
        }
        *pos += i;
        load->state = US_VAL;
    }
    else
    {
        HandlerException (sess, line, linelen, pos);
    }
    return (err);
}
示例#5
0
/* Name: CM_UTF8_twidth - Finds the width of a UTF8 string when
**			  displayed on a UTF8 termainal.
**
** Description:
**
**     This routine takes in a UTF8 character and calculates the 
**     terminal width it occupies.
**
** Input:
**		strstart 	Pointer to the start of the UTF8 
**			        character, whose width we need to
**				compute. 
**		strend	 	Pointer to the end of the UTF8 
**			        character, whose width we need to
**				compute. This ensures that we do
**				have access to the complete sequence
**				of a multibyte UTF8 character.
**
** Output			Width occupied by the UTF8 character
**				on a fixed width UTF8 compatible terminal. 
**				Typically East asian characters will 
**				occupy two spaces and European characters
**				will occupy one space. 
**		
** Returns:			width if ok
**				-1 Other wise.
**
** Note: This is an approximate value and may not work for all kinds of 
**	 characters and all terminals. (see note above)
**
** Usage: Typically this routine would be used to calculate the difference 
** 	  in length of the UTF8 character in bytes and the width of the 
**	  character expressed in number of spaces occupied by this character. 
** 	  on a fixed width UTF8 enabled terminal. This diffence can be used to
**	  compensate for the dis-alignment that occurs when the bytes shrink
**	  on rendering this character.
**
**        if ((utf8wid = CM_UTF8_twidth(str_start, str_end)) > 0)
**        {
**	    diff = CMbytecnt(str_start) - utf8wid;
**	
** History:
**	17-Nov-2008 (gupsh01)
**	    Added.
*/
i4
CM_UTF8_twidth (char *strstart, char *strend)
{
        i4      i, n;
        ConversionResult result;
        UTF32   utf32_buf[2];
        UTF8    utf8_buf[5];
        UTF8    *utf8SourceStart;
        UTF32   *utf32TargetStart;
	i4	width = 0;
	i4	incnt = CMbytecnt(strstart);

	if (strstart + incnt > strend)
          return (-1);

        utf32_buf[0] = 0; utf32_buf[1] = 0;

        for (n = 0; n < incnt; n++)
          utf8_buf[n] = strstart[n];

        utf8SourceStart = utf8_buf;
        utf32TargetStart = utf32_buf;

        if ((result = CM_ConvertUTF8toUTF32( (const UTF8 **) &utf8SourceStart,
                    		             &(utf8_buf[incnt]), 
				             &utf32TargetStart,
                     		             &(utf32_buf[1]), 0)) !=  conversionOK)
        {
          return (-1);
        }

        if ((width = CM_mk_wcwidth(utf32_buf[0])) < 0)
          return -1;
        else
	  return (width);
}
示例#6
0
i4
STxcompare(
	char	*a_ptr,
	size_t	a_len,
	char	*b_ptr,
	size_t	b_len,
	bool	ic,
	bool	sb)
{
	unsigned char		*ap;
	unsigned char		*bp;
	register size_t	al;
	register size_t	bl;
	i4		ret_val = -2;
	i4		cmp;


	ap = (unsigned char *) a_ptr;
	bp = (unsigned char *) b_ptr;
	al = a_len;

	if (al == 0)
		al = MAXI2;

	bl = b_len;

	if (bl == 0)
		bl = MAXI2;

	if (CMGETDBL)
	{
	    while (ret_val == -2)
	    {
		/* supress blanks in both strings */

		if (sb)
		{
			while (al > 0 && CMspace(ap))
			{
				al -= CMbytecnt(ap);
				CMnext(ap);
			}

			while (bl > 0 && CMspace(bp))
			{
				bl -= CMbytecnt(bp);
				CMnext(bp);
			}
		}


		if (al <= 0)
			ap = (unsigned char *) "";

		if (bl <= 0)
			bp = (unsigned char *) "";

		/* do inequality tests */

		if (ic)
			cmp = CMcmpnocase(ap,bp);
		else
			cmp = CMcmpcase(ap,bp);

		if (cmp < 0)
			ret_val = -1;
		else if (cmp > 0)
			ret_val = 1;
		else if (*ap == '\0')
			ret_val = 0;
		else
		{
			/* go on to the next character */

			al -= CMbytecnt(ap);
			CMnext(ap);
			bl -= CMbytecnt(bp);
			CMnext(bp);
		}
	    }
	}
	else
	{
	    while (ret_val == -2)
	    {
		/* supress blanks in both strings */

		if (sb)
		{
			while (al > 0 && CMspace_SB(ap))
			{
				al -= CMbytecnt_SB(ap);
				CMnext_SB(ap);
			}

			while (bl > 0 && CMspace_SB(bp))
			{
				bl -= CMbytecnt_SB(bp);
				CMnext_SB(bp);
			}
		}


		if (al <= 0)
			ap = (unsigned char *) "";

		if (bl <= 0)
			bp = (unsigned char *) "";

		/* do inequality tests */

		if (ic)
			cmp = CMcmpnocase_SB(ap,bp);
		else
			cmp = CMcmpcase_SB(ap,bp);

		if (cmp < 0)
			ret_val = -1;
		else if (cmp > 0)
			ret_val = 1;
		else if (*ap == '\0')
			ret_val = 0;
		else
		{
			/* go on to the next character */

			al -= CMbytecnt_SB(ap);
			CMnext_SB(ap);
			bl -= CMbytecnt_SB(bp);
			CMnext_SB(bp);
		}
	    }
	}

	return(ret_val);
}
示例#7
0
/*{
** Name: rms_movestring - moves a string into a DB_DATA_VALUE.
**
** Description:
**        Moves a "C" string into a DB_DATA_VALUE padding the DB_DATA_VALUE
**	string appropriately.  If the DB_DATA_VALUE string has INGRES type c,
**	any non-printing characters will be mapped to blanks.  If the string
**	has INGRES type text, then null characters are converted to blanks.
**
** Inputs:
**      source                          The source "C" string.
**      sourcelen                       The length of the source string.
**      dest	                        Ptr to the destination DB_DATA_VALUE.
**	    .db_datatype		Datatype of the DB_DATA_VALUE.
**	    .db_length			Length of the result DB_DATA_VALUE.
**
** Outputs:
**      dest                            Ptr to the destination DB_DATA_VALUE.
**	    .db_data			Ptr to memory where string is moved to.
**	Returns:
**	    E_DB_OK
**
**	Exceptions:
**	    none
**
** Side Effects:
**	    none
**
** History:
**	12-apr-90 (jrb)
**	    Created.
*/
DB_STATUS
rms_movestring
(
    register u_char	   *source,
    register i4		   sourcelen,
    register DB_DATA_VALUE *dest
)
{
    DB_STATUS           db_stat;
    char		*cptr;
    u_char		*endsource;
    register u_char     *outstring;
    register i4		outlength;
    u_char		*endout;

    if (db_stat = rms_straddr(dest, &cptr) != E_DB_OK)
	return (db_stat);
    outstring = (u_char *)cptr;

    switch (dest->db_datatype)
    {
      case DB_CHA_TYPE:
      case DB_CHR_TYPE:
      case DB_BYTE_TYPE:
      case DB_LBYTE_TYPE:
        outlength = dest->db_length;
        break;

      case DB_TXT_TYPE:
      case DB_VCH_TYPE:
      case DB_VBYTE_TYPE:
        outlength = dest->db_length - DB_CNTSIZE;
        break;
       
    }

    endsource = source + sourcelen;
    endout    = outstring + outlength;
    
    if (dest->db_datatype == DB_CHR_TYPE)
    {
        while (source < endsource  &&  outstring + CMbytecnt(source) <= endout)
        {
	    /*
	    ** The characters that are allowed as part of a string of type
	    ** c are the printable characters(alpha, numeric, 
	    ** punctuation), blanks, IIMAX_CHAR_VALUE, or the pattern matching
	    ** characters.  NOTE: other whitespace (tab, etc.) is not
	    ** allowed.
	    */
            if (!CMprint(source) && (*source) != ' ' 
		&& (*source) != IIMAX_CHAR_VALUE
		&& (*source) != DB_PAT_ANY && (*source) != DB_PAT_ONE
		&& (*source) != DB_PAT_LBRAC && (*source) != DB_PAT_RBRAC)
            {
                *outstring++ = ' ';
		CMnext(source);
            }
	    else
	    {
		CMcpyinc(source, outstring);
	    }
        }
    }
    else if (dest->db_datatype == DB_TXT_TYPE)
    {
	while (source < endsource  &&  outstring + CMbytecnt(source) <= endout)
        {
	    /* NULLCHARs get cvt'ed to blank for text */
	    if (*source == NULLCHAR)
	    {
                *outstring++ = ' ';
		CMnext(source);
	    }
	    else
	    {
		CMcpyinc(source, outstring);
	    }
	}
    }
    else
    {
	while (source < endsource  &&  outstring + CMbytecnt(source) <= endout)
	    CMcpyinc(source, outstring);
    }

    switch (dest->db_datatype)
    {
      case DB_CHA_TYPE:
      case DB_CHR_TYPE:
	while (outstring < endout)
	    *outstring++ = ' ';
        break;

      case DB_VCH_TYPE:
      case DB_TXT_TYPE:
	((DB_TEXT_STRING *)dest->db_data)->db_t_count =
						    outstring - (u_char *)cptr;
	break;
    }
    
    return (E_DB_OK);
}
示例#8
0
STATUS
s_lrem_set()
{
    char	*b;
    char	*bend;
    i4		pos;
    i4		n;
    i4		length;
    # ifdef UNIX
    char	word[OOLONGREMSIZE+1]; 
    # else
    char        word[MAXCMD+1];
    # endif
    i4		code;
    i4		count;
    char	*save_Tokchar;
    char	long_remark[OOLONGREMSIZE+1];
    i4          rtn_char;               /* dummy variable for sgskip */

    if (St_lr_given)
    {
	s_error(0x3A9, NONFATAL, NULL);
	s_cmd_skip();
	return FAIL;
    }
    if (Cact_ren == NULL)
    {
	    s_error(0x38A, FATAL, NULL);
    }
    St_lr_given = TRUE;

    /* skip leading white space */

    s_g_skip(TRUE, &rtn_char);

    /* handle rest of remark up to the .ENDREMARK */

    code = S_ERROR;
    b = long_remark;
    bend = b + OOLONGREMSIZE;

    for (;;)
    {
	while (*Tokchar != '\n' && *Tokchar != EOS)
	{
	    if (*Tokchar == '.' && CMalpha(Tokchar+1))
	    {
		/* check for .ENDREMARK */

		save_Tokchar = Tokchar;
		Tokchar++;
		r_gt_word(word);
		CVlower(word);
		code = s_get_scode(word);
		if (code == S_ENDREMARK)
		{
		    break;
		}
		else
		{
		    Tokchar = save_Tokchar;
		}
	    }

	    if (b <= bend-CMbytecnt(Tokchar))
	    {
		if (*Tokchar == '\t')
		{
			/* if tab, replace it with the one blank */
			*b = ' ';
			b++;
			Tokchar++;
		}
		else
		{
		    CMcpyinc(Tokchar, b);
		}
	    }
	    else
	    {
		CMnext(Tokchar);
	    }
	}

	if (code == S_ENDREMARK)
	{
	    *b = EOS;
	    Cact_ren->ren_longrem = STalloc(long_remark);
	    break;
	}
	else
	{
	    if (b < bend)
	    {
	        *b++ = ' ';
	    }
	    count = s_next_line();
	    if (count == 0)
	    {
		/* ERROR: EOF in middle of remark */
		s_error(0x3A3, FATAL, NULL);
		break;
	    }
	}
    }

    return OK;
}
示例#9
0
/*{
** Name: PSQ_TCNVT	- convert db_data_value to text form
**
** Description:
**      This routine takes any user supplied db_data_value and converts
**  it to the value's textual representation.  This is required for the
**  iiqrytext catalog.  It is assumed that all datavalues can be written
**  into a character representation. 
**
** Inputs:
**	sess_cb				session control block
**	    .pss_adfcb			adf session control block for output
**					arguments.
**      header                          Pointer to chain header
**	dbval				db_data_value
**	result				Place to put pointer to new piece
**	err_blk				Filled in if an error happens
**
** Outputs:
**      result                          Filled in with pointer to chain element
**	err_blk				Filled in if an error happens
**	Returns:
**	    E_DB_OK			Success
**	    E_DB_ERROR			Non-catastrophic failure
**	    E_DB_FATAL			Catastrophic failure
**	Exceptions:
**	    none
**
** Side Effects:
**	    Allocates memory
**
** History:
**      29-jun-87 (daved)
**          written
**	28-jan-91 (andre)
**	    fix bug 35446: size of a new piece should include quotes, if they
**	    were added.
**	18-nov-91 (rog)
**	    Fixed bug 40869, et alia: the above fix missed adding the quotes
**	    to the total size and not just the piece size.
**	23-Sep-2009 (kiria01) b122578
**	    Initialise the ADF_FN_BLK .adf_fi_desc and adf_dv_n members.
**	19-Aug-2010 (kschendel) b124282
**	    Make sure fi-desc is always set to something.
*/
DB_STATUS
psq_tcnvt(
	PSS_SESBLK	   *sess_cb,
	PTR                header,
	DB_DATA_VALUE	   *dbval,
	PTR		   *result,
	DB_ERROR	   *err_blk)
{
    PSQ_THEAD           *hp;
    PSQ_TEXT		*tp;
    i4		err_code;
    DB_STATUS		status;
    ADF_CB		*adf_cb;
    ADF_FN_BLK		adffn;
    i4			dv_size;
    i4			count;
    char		*cptr;
    char		*quote_char;
    DB_TEXT_STRING      *string;
    ADI_DT_NAME		dt_fname;
    ADI_DT_NAME		dt_tname;
    char		f4_style;
    char		f8_style;
    i4			f4_width;
    i4			f8_width;
    i4			f4_prec;
    i4			f8_prec;
    i4			totype;
    i4			is_string;

    hp	    = (PSQ_THEAD *) header;
    adf_cb  = (ADF_CB *) sess_cb->pss_adfcb;
    status  = E_DB_OK;
    totype  = (DB_DT_ID) DB_LTXT_TYPE;

    adffn.adf_r_dv.db_datatype = totype;
    if (dbval->db_datatype == totype)
	dv_size = dbval->db_length;
    else
	dv_size = 0;

    /* JRBCMT -- PSF is not allowed to know this!!  First of all, date is   */
    /* missing from the list below and decimal will soon need to be on it.  */
    /* But also, we need to fix this code so that it doesn't make	    */
    /* assumptions about what types exist.  I think the proper approach is  */
    /* to quote all non-intrinsic types, but this should be investigated.   */

    /* are we dealing with a string type (incoming). */
    if (abs(dbval->db_datatype) == DB_INT_TYPE ||
        abs(dbval->db_datatype) == DB_FLT_TYPE ||
	abs(dbval->db_datatype) == DB_MNY_TYPE ||
	abs(dbval->db_datatype) == DB_BOO_TYPE)
    {
	is_string = FALSE;
	quote_char = (char *) NULL;
    }
    else
    {
	is_string = TRUE;
	quote_char = (sess_cb->pss_lang == DB_SQL) ? "\'" : "\"";
    }
    

    /* set the floating point conversion display */
    f4_style = adf_cb->adf_outarg.ad_f4style;
    f8_style = adf_cb->adf_outarg.ad_f8style;
    f4_width = adf_cb->adf_outarg.ad_f4width;
    f8_width = adf_cb->adf_outarg.ad_f8width;
    f4_prec  = adf_cb->adf_outarg.ad_f4prec;
    f8_prec  = adf_cb->adf_outarg.ad_f8prec;

    adf_cb->adf_outarg.ad_f4style = 'n';
    adf_cb->adf_outarg.ad_f8style = 'n';
    adf_cb->adf_outarg.ad_f4width = 20;
    adf_cb->adf_outarg.ad_f8width = 20;
    adf_cb->adf_outarg.ad_f4prec  = 10;
    adf_cb->adf_outarg.ad_f8prec  = 10;

    /* get the function instance id for this conversion */
    status = adi_ficoerce(adf_cb, dbval->db_datatype, totype, &adffn.adf_fi_id);
    if (status != E_DB_OK)
    {
	goto exit;
    }         

    /* determine the result size. */
    status = adi_fidesc(adf_cb, adffn.adf_fi_id, &adffn.adf_fi_desc);
    if (status != E_DB_OK)
    {
	goto exit;
    }
    if (!dv_size)
    {
	/* Now lets fill in the datatype length info and allocate space for the 
	** data.
	*/
	status = adi_0calclen(adf_cb, &adffn.adf_fi_desc->adi_lenspec, 1, &dbval, 
		&adffn.adf_r_dv);
	dv_size = adffn.adf_r_dv.db_length;

	if (status != E_DB_OK)
	{
	     goto exit;
	}
    }
    /* if string, add room for quotes */
    if (is_string)
	dv_size += 2 * CMbytecnt(quote_char);

    /* Allocate enough space for PSQ_TEXT structure containing piece */
    hp->psq_tmem.ulm_psize = dv_size + sizeof(PSQ_TEXT) - 1;
    status = ulm_palloc(&hp->psq_tmem);
    if (status != E_DB_OK)
    {
	if (hp->psq_tmem.ulm_error.err_code == E_UL0005_NOMEM)
	{
	    psf_error(E_PS0F02_MEMORY_FULL, 0L, PSF_CALLERR, 
		&err_code, err_blk, 0);
	}
	else
	    (VOID) psf_error(E_PS0371_ALLOC_TEXT_CHAIN,
		hp->psq_tmem.ulm_error.err_code, PSF_INTERR,
		&err_code, err_blk, 0);
	return (status);
    }
    *result = hp->psq_tmem.ulm_pptr;
    tp	    = (PSQ_TEXT*) *result;

    string	  = (DB_TEXT_STRING*) tp->psq_tval;
    /* Fill in text piece */
    adffn.adf_r_dv.db_length	= dv_size;
    adffn.adf_r_dv.db_data	= (PTR) string;
    adffn.adf_dv_n		= 1;
    STRUCT_ASSIGN_MACRO(*dbval, adffn.adf_1_dv);
    adffn.adf_pat_flags		= AD_PAT_DOESNT_APPLY;
    if ((status = adf_func(adf_cb, &adffn)) != E_DB_OK)
    {
	goto exit;
    }
    /* CAUTION: entering tricky code.
    ** string is a variable containing a text datatype. We want to convert
    ** to a C datatype.  We also want to add quote characters if the datatype
    ** was a string type.  We grab the count from the string variable first.
    ** we can then use the 2 byte count for character data.
    */
    count = string->db_t_count;
    cptr = (char *)  string;
    if (is_string)
    {
	/*
	** for strings, copy the opening quote (" or ', depending on language)
	*/ 
	CMcpychar(quote_char, cptr);
	cptr += CMbytecnt(quote_char);
    }
    MEcopy((PTR) string->db_t_text, count, (PTR) cptr);
    cptr += count;
    if (is_string)
    {
	/*
	** for strings, copy the closing quote (" or ', depending on language)
	*/ 
	CMcpychar(quote_char, cptr);
    }

    /* if storing a string, do not forget to account for quotes (bug 35446) */
    tp->psq_psize = (is_string) ? count + 2 * CMbytecnt(quote_char) : count;

    /* Hook it up to the chain */
    tp->psq_next = (PSQ_TEXT *) NULL;
    if (hp->psq_last != (PSQ_TEXT *) NULL)
    {
	hp->psq_last->psq_next = tp;
	tp->psq_prev = hp->psq_last;
    }
    else
    {
	tp->psq_prev = NULL;
    }
    hp->psq_last = tp;
    if (hp->psq_first == (PSQ_TEXT *) NULL)
	hp->psq_first = tp;

    /* Add in the length to the total for the chain */
    hp->psq_tsize += tp->psq_psize;

exit:
    /* set the floating point conversion display */
    adf_cb->adf_outarg.ad_f4style = f4_style;
    adf_cb->adf_outarg.ad_f8style = f8_style;
    adf_cb->adf_outarg.ad_f4width = f4_width;
    adf_cb->adf_outarg.ad_f8width = f8_width;
    adf_cb->adf_outarg.ad_f4prec  = f4_prec;
    adf_cb->adf_outarg.ad_f8prec  = f8_prec;

    if (status != E_DB_OK)
    {
	(VOID) adi_tyname(adf_cb, dbval->db_datatype, &dt_fname);
	(VOID) adi_tyname(adf_cb, totype, &dt_tname);
	(VOID) psf_error(2911L, 0L, PSF_USERERR,
	    &err_code, err_blk, 3, sizeof (sess_cb->pss_lineno),
	    &sess_cb->pss_lineno, 
	    psf_trmwhite(sizeof(dt_fname), (char *) &dt_fname), &dt_fname, 
	    psf_trmwhite(sizeof (dt_tname), (char *) &dt_tname), &dt_tname);
        return (E_DB_ERROR);    
    }
    return (status);
}
示例#10
0
/*{
** Name: psq_rptqry_text - add a piece of text to the text chain for a repeat
**			   query
**
** Description: Add a piece of text to the text chain for a repeat query.  It is
**		imperative that text of all repeat queries be stored in a
**		uniform fashion so that comparing two stored query texts would
**		serve as a reliable indicator of their sameness.  Each piece
**		will be preceeded with a blank except for a PERIOD.  Neither the
**		piece consisting of PERIOD nor the following piece will be
**		preceeded with a blank.
**
** Inputs:
**      header                          Pointer to chain header
**	piece				Pointer to piece of text
**	size				Size of piece
**	result				Place to put pointer to new piece
**	err_blk				Filled in if an error happens
**
** Outputs:
**      result                          Filled in with pointer to chain element
**	err_blk				Filled in if an error happens
**	Returns:
**	    E_DB_OK			Success
**	    E_DB_ERROR			Non-catastrophic failure
**	    E_DB_FATAL			Catastrophic failure
**	Exceptions:
**	    none
**
** Side Effects:
**	    Allocates memory
**
** History:
**      24-jan-90 (andre)
**          Plagiarized from psq_tadd().
**	28-jan-91 (andre)
**	    Do not insert a space if a piece is immediately following a piece
**	    consisting of a $.
*/
DB_STATUS
psq_rptqry_text(
	PTR                header,
	u_char		   *piece,
	i4		   size,
	PTR		   *result,
	DB_ERROR	   *err_blk)
{
    PSQ_THEAD           *hp = (PSQ_THEAD *) header;
    PSQ_TEXT		*tp;
    i4		err_code;
    bool		leading_blank;
    char		*txt;
    DB_STATUS		status;

    /*
    ** Allocate enough space for PSQ_TEXT structure containing piece:
    ** all pieces will be preceeded with a blank with the following exceptions:
    **	- piece consisting of PERIOD will not be preceeeded with a blank;
    **	- piece which immediately follows a piece consisting of PERIOD;
    **	- piece starting with a "white" character will not be preceeded with a
    **	  blank;
    **	- piece which immediately follows a piece consisting of $ (preceeded by
    **	  a blank which was inserted by this function)
    */

    if (   size == CMbytecnt(".") && !CMcmpcase(piece, ".")
	|| CMwhite(piece))
    {
	/*
	** piece consists of a period or starts with a "white" character - no
	** leading blanks will be added
	*/
	leading_blank = FALSE;
    }
    else if (   hp->psq_last != (PSQ_TEXT *) NULL
	     && ((   hp->psq_last->psq_psize == CMbytecnt(".")
		  && !CMcmpcase(hp->psq_last->psq_tval, ".")
		 )
		 ||
		 (   hp->psq_last->psq_psize == CMbytecnt(" ") + CMbytecnt("$")
		  && !CMcmpcase(hp->psq_last->psq_tval, " ")
		  && !CMcmpcase((hp->psq_last->psq_tval + CMbytecnt(" ")), "$")
		 )
	        )
	    )
    {
	/*
	** previous piece consists of a period or of a $ preceeded by a blank
	** inserted by this function - no leading blanks will be added
	*/
	leading_blank = FALSE;
    }
    else
    {
	/* insert a blank before the piece */
	leading_blank = TRUE;
    }

    hp->psq_tmem.ulm_psize = (leading_blank)
	? size + sizeof(PSQ_TEXT) - 1 + CMbytecnt(" ")
	: size + sizeof(PSQ_TEXT) - 1;

    if ((status = ulm_palloc(&hp->psq_tmem)) != E_DB_OK)
    {
	if (hp->psq_tmem.ulm_error.err_code == E_UL0005_NOMEM)
	{
	    (VOID) psf_error(E_PS0F02_MEMORY_FULL, 0L, PSF_CALLERR, 
		&err_code, err_blk, 0);
	}
	else
	{
	    (VOID) psf_error(E_PS0371_ALLOC_TEXT_CHAIN,
		hp->psq_tmem.ulm_error.err_code, PSF_INTERR, &err_code, err_blk,
		0);
	}

	return (status);
    }

    *result = hp->psq_tmem.ulm_pptr;
    tp	    = (PSQ_TEXT*) *result;

    /* Fill in text piece */
    txt = (char *) tp->psq_tval;

    /* insert a leading blank if necessary */
    if (leading_blank)
    {
	CMcpychar(" ", txt);
	txt += CMbytecnt(" ");
    }
	
    MEcopy((char *) piece, size, txt);
    tp->psq_psize = (leading_blank) ? size + CMbytecnt(" ") : size;

    /* Hook it up to the chain */
    tp->psq_next = (PSQ_TEXT *) NULL;
    if (hp->psq_last != (PSQ_TEXT *) NULL)
    {
	hp->psq_last->psq_next = tp;
	tp->psq_prev = hp->psq_last;
    }
    else
    {
	tp->psq_prev = NULL;
    }
    hp->psq_last = tp;
    if (hp->psq_first == (PSQ_TEXT *) NULL)
	hp->psq_first = tp;

    /* Add in the length to the total for the chain */
    hp->psq_tsize += tp->psq_psize;

    return (E_DB_OK);
}
示例#11
0
文件: wtsupld.c 项目: akdh/Ingres
/*
** Name: Disp_Fname
**
** Decription:
**      Takes the string
**        content-disposition: form-data; name="xxxx" filename="yyyy"
**      opens an ice temporary file and sets items in the variable string
**      as xxxx=icetempfile.
**
** Inputs:
**      sess        ice session structure
**      line        pointer to the current line
**      linelen     length of the line
**
** Outputs:
**      pos         number of characters handled.
**
** Return:
**      GSTAT_OK    success
**      other       failure
**
** History:
**      23-Oct-98 (fanra01)
**          Created.
*/
static GSTATUS
Disp_Fname (WTS_SESSION* sess, char* line, i4  linelen, i4 * pos)
{
    GSTATUS         err = GSTAT_OK;
    PWTS_UPLOAD     load= sess->load;
    char*           p = line + *pos;
    char*           name;
    i4              remain = linelen - *pos;
    i4              i = 0;
    i4              j = 0;
    UPLOADED_FILE*  upload;

    if (STbcompare ("name", 4, p, 0, TRUE) == 0)
    {
        /*
        ** Find the first quote after name
        */
        while ((*p != '\"') && (i < remain))
        {
            CMbyteinc(i,p);
            CMnext(p);
        }
        CMbyteinc(i,p);     /* skip the quote */
        CMnext(p);
        name= p;
        while ((*p != '\"') && (i < remain))
        {
            j+=CMbytecnt(p);
            CMbyteinc(i,p);
            CMnext(p);
        }
        CMbyteinc(i,p);
        CMnext(p);          /* skip the quote */
        while ((*p != ';') && (i < remain))
        {
            CMbyteinc(i,p);
            CMnext(p);
        }
        CMbyteinc(i,p);
        CMnext(p);          /* skip the semi colon */
        /*
        ** Allocate space for the variable name a '=' character and an EOS
        */
        if ((err = GAlloc (&load->varname, j+2, FALSE)) == GSTAT_OK)
        {
            MEfill (j+2, 0, load->varname);
            MECOPY_VAR_MACRO (name, j, load->varname);
            STcat (load->varname, "=");
        }
        while (CMwhite(p) && (i < remain))
        {
            CMbyteinc(i, p);
            CMnext(p);
        }
        if (STbcompare ("filename", 8, p, 0, TRUE) == 0)
        {
            /*
            ** Find the first quote after filename
            */
            while ((*p != '\"') && (i < remain))
            {
                CMbyteinc(i,p);
                CMnext(p);
            }
            CMbyteinc(i,p);
            CMnext(p);          /* skip the quote */
            name= p;
            while ((*p != '\"') && (i < remain))
            {
                j+=CMbytecnt(p);
                CMbyteinc(i,p);
                CMnext(p);
            }
            CMbyteinc(i,p);
            CMnext(p);          /* skip the quote */
            /*
            ** Allocate space for the filename and an EOS
            */
            if ((err = GAlloc (&load->filename, j+1, FALSE)) == GSTAT_OK)
            {
                MEfill (j+1, 0, load->filename);
                MECOPY_VAR_MACRO (name, j, load->filename);
                asct_trace( ASCT_LOG )( ASCT_TRACE_PARAMS,
                    "Upload session=%s file=%s",
                    ((sess->act_session != NULL) ?
                        ((sess->act_session->user_session) ?
                            sess->act_session->user_session->name : "None")
                    : "None"),
                    load->filename );
            }
            *pos += i;
            err = G_ME_REQ_MEM(0, upload, UPLOADED_FILE, 1);
            if (err == GSTAT_OK)
            {
                bool status;

                err = WCSRequest( 0, NULL, SYSTEM_ID, NULL, WSF_ICE_SUFFIX,
                    &upload->file, &status);
                if (err == GSTAT_OK)
                {
                    CLEAR_STATUS(WCSLoaded(upload->file, TRUE));
                    err = WCSOpen (upload->file, "w", SI_BIN, 0);
                    if (err == GSTAT_OK)
                    {
                        i4  nlen = STlength (load->varname);
                        i4  flen = STlength(upload->file->info->path);

                        err = GAlloc(&load->icefname, flen + 1, FALSE);
                        if (err == GSTAT_OK)
                        {

                            MECOPY_VAR_MACRO( upload->file->info->path, flen,
                                load->icefname);

                            err = GAlloc((PTR*)&sess->variable,
                                sess->vlen + nlen + flen + 2, TRUE);
                            if (err == GSTAT_OK && sess->variable != NULL)
                            {
                                if (sess->vlen > 0)
                                {
                                    sess->variable[sess->vlen++] = '&';
                                }
                                MECOPY_VAR_MACRO(load->varname, nlen,
                                    sess->variable + sess->vlen);
                                sess->vlen += nlen;
                                if (flen)
                                {
                                    MECOPY_VAR_MACRO(load->icefname, flen,
                                        sess->variable + sess->vlen);
                                    sess->vlen += flen;
                                    upload->next = sess->list;
                                    sess->list = upload;
                                }
                                sess->variable[sess->vlen] = EOS;
                            }
                        }
                    }
                    else
                    {
                        CLEAR_STATUS(WCSRelease(&upload->file));
                    }
                }
            }
            load->state = US_FILE;
        }
        else
        {
            HandlerException (sess, line, linelen, pos);
        }
    }
    else
    {
        HandlerException (sess, line, linelen, pos);
    }
    return (err);
}
示例#12
0
DB_STATUS
qel_32_tables(
QEF_RCB		*i_qer_p,
QEC_LINK	*v_lnk_p )
{
    DB_STATUS	    status;
    QES_DDB_SES	    *dds_p = & i_qer_p->qef_cb->qef_c2_ddb_ses;
    QED_DDL_INFO    *ddl_p = v_lnk_p->qec_1_ddl_info_p;
    DD_2LDB_TAB_INFO
		    *tabinfo_p = ddl_p->qed_d6_tab_info_p;
    QEC_L16_TABLES  *tables_p = v_lnk_p->qec_9_tables_p;
    QEQ_1CAN_QRY    *sel_p = v_lnk_p->qec_6_select_p,
		    *ins_p = v_lnk_p->qec_22_insert_p;
						/* working structure */
    DD_LDB_DESC	    *cdb_p = 
			& dds_p->qes_d4_ddb_p->dd_d3_cdb_info.dd_i1_ldb_desc,
		    *ldb_p = v_lnk_p->qec_19_ldb_p;
    u_i4	    l_obj;


    if (v_lnk_p->qec_10_haves & QEC_08_NO_IITABLES)
	return(E_DB_OK);

    /* 1.  set up to retrieve from IITABLES */

    qed_u0_trimtail( tabinfo_p->dd_t1_tab_name, (u_i4) DB_TAB_MAXNAME,
		    tables_p->l16_1_tab_name);
    qed_u0_trimtail( tabinfo_p->dd_t2_tab_owner, (u_i4) DB_OWN_MAXNAME,
		    tables_p->l16_2_tab_owner);

    sel_p->qeq_c1_can_id = SEL_117_II_TABLES;
    sel_p->qeq_c3_ptr_u.l16_tables_p = tables_p;
    sel_p->qeq_c4_ldb_p = ldb_p;
    sel_p->qeq_c2_rqf_bind_p = v_lnk_p->qec_20_rqf_bind_p;

    /* 2.  send SELECT query and fetch first tuple */

    status = qel_s4_prepare(i_qer_p, v_lnk_p);
    if (status)
	return(status);
        
    if (! sel_p->qeq_c5_eod_b)
    {
	status = qel_s3_flush(i_qer_p, v_lnk_p);
	if (status)
	    return(status);
    }

    if (v_lnk_p->qec_27_select_cnt != 1)
    {
	status = qed_u1_gen_interr(& i_qer_p->error);
	return(status);
    }

    if (v_lnk_p->qec_10_haves & QEC_10_USE_PHY_SRC)
    {
	/* 3.  read remaining information from the LDB's IIPHYSICAL_TABLES */

	sel_p->qeq_c1_can_id = SEL_113_II_PHYSICAL_TABLES;

	/* 3.1  send SELECT query and fetch first tuple */

	status = qel_s4_prepare(i_qer_p, v_lnk_p);
	if (status)
	    return(status);
        
	if (! sel_p->qeq_c5_eod_b)
	{
	    status = qel_s3_flush(i_qer_p, v_lnk_p);
	    if (status)
		return(status);
	}

	if (v_lnk_p->qec_27_select_cnt != 1)
	{
	    status = qed_u1_gen_interr(& i_qer_p->error);
	    return(status);
	}
    }

    if (v_lnk_p->qec_10_haves & QEC_11_LDB_DIFF_ARCH)
    {
	/* binary statistics data cannot be propagated for use due to 
	** different LDB architecture */

	tables_p->l16_9_stats[0] = 'N';		/* declare no statistics */
    }
    else if (!
	(
	(tables_p->l16_9_stats[0] == 'N')
	||
	(tables_p->l16_9_stats[0] == 'n')
	))
	v_lnk_p->qec_10_haves |= QEC_05_STATS;

    if (!
	(
	(tables_p->l16_10_indexes[0] == 'N')
	||
	(tables_p->l16_10_indexes[0] == 'n')
	))
	v_lnk_p->qec_10_haves |= QEC_02_INDEXES;

    /* 3.  set up tuple for insertion */

    l_obj = (u_i4)qed_u0_trimtail( ddl_p->qed_d1_obj_name, (u_i4)DB_OBJ_MAXNAME,
		tables_p->l16_1_tab_name);

    qed_u0_trimtail( ddl_p->qed_d2_obj_owner, (u_i4) DB_OWN_MAXNAME,
		tables_p->l16_2_tab_owner);

    STcopy(v_lnk_p->qec_24_cur_time, 
	    tables_p->l16_3_cre_date);
    STcopy(v_lnk_p->qec_24_cur_time, 
	    tables_p->l16_4_alt_date);

    if (tabinfo_p->dd_t3_tab_type == DD_2OBJ_TABLE)
	tables_p->l16_5_tab_type[0] = 'T';	/* local table */
    else if (tabinfo_p->dd_t3_tab_type == DD_3OBJ_VIEW)
	tables_p->l16_5_tab_type[0] = 'V';	/* local view */
    else if (tabinfo_p->dd_t3_tab_type == DD_4OBJ_INDEX)
	tables_p->l16_5_tab_type[0] = 'I';	/* local index */
    else 
    {
	status = qed_u2_set_interr(E_QE0018_BAD_PARAM_IN_CB,
		    & i_qer_p->error);
	return(status);
    }
    tables_p->l16_5_tab_type[1] = EOS;		/* null terminate */

    if (ddl_p->qed_d8_obj_type == DD_1OBJ_LINK)
   	tables_p->l16_6_sub_type[0] = 'L';	/* DDB link */
    else if (ddl_p->qed_d8_obj_type == DD_2OBJ_TABLE
	     ||
	     ddl_p->qed_d8_obj_type == DD_3OBJ_VIEW)
	tables_p->l16_6_sub_type[0] = 'N';	/* DDB native */
    else
    {
	status = qed_u2_set_interr(E_QE0018_BAD_PARAM_IN_CB,
		    & i_qer_p->error);
	return(status);
    }
    tables_p->l16_6_sub_type[1] = EOS;		/* null terminate */

    STcopy(IIQE_42_ing_60, tables_p->l16_7_version);

    if (dds_p->qes_d9_ctl_info & QES_05CTL_SYSCAT_USER)
    {
	char *ch2 = ddl_p->qed_d1_obj_name + CMbytecnt(ddl_p->qed_d1_obj_name);

	if( ( l_obj >= 2 ) &&
	    (CMcmpnocase(ddl_p->qed_d1_obj_name, "i") == 0 ) &&
	    (CMcmpnocase(ch2, "i") == 0 ))
	{
	    tables_p->l16_8_sys_use[0] = 'S';	/* system object */

	}
	else
	    tables_p->l16_8_sys_use[0] = 'U';	/* user object */
    }
    else
	tables_p->l16_8_sys_use[0] = 'U';	/* user object */
    tables_p->l16_8_sys_use[1] = EOS;		/* null terminate */

    if (! (v_lnk_p->qec_10_haves & QEC_03_INGRES) )
    {
	/* index information NOT propagated for gateways */
	tables_p->l16_10_indexes[0] = 'N';	/* N */
	tables_p->l16_10_indexes[1] = EOS;	/* null terminate */
    }
    tables_p->l16_23_integrities[0] = 'N';	/* always N */
    tables_p->l16_23_integrities[1] = EOS;	/* null terminate */

    tables_p->l16_24_permits[0] = 'N';		/* always N */
    tables_p->l16_24_permits[1] = EOS;	/* null terminate */

    if (tabinfo_p->dd_t3_tab_type == DD_4OBJ_INDEX)
	tables_p->l16_25_all_to_all[0] = 'N';	/* always N if an index */
    else
	tables_p->l16_25_all_to_all[0] = 'Y';	/* always Y otherwise */
    tables_p->l16_25_all_to_all[1] = EOS;	/* null terminate */

    /* 4.  insert into IIDD_TABLES */

    ins_p->qeq_c1_can_id = INS_631_DD_TABLES;	
    ins_p->qeq_c3_ptr_u.l16_tables_p = tables_p;	
    ins_p->qeq_c4_ldb_p = cdb_p;
    status = qel_i1_insert(i_qer_p, v_lnk_p);

    return(status);
}