Example #1
0
/*
** Name: LOmkingpath	- make INGRES location's area path
**
** Description:
**	Makes missing subdirectories in a location's area path.
**
** Inputs:
**	area	"device" that the location is on
**	what	path to db, ckp, dmp, work, jnl
**	loc	set to full path of location
**	
** Outputs:
**	none
**
** Returns:
**	LO_NULL_ARG	area or what were NULL or empty
**	LO_NO_SUCH	required path component does not exist
**
** History:
**	03-dec-2003 (abbjo03)
**	    Created.
*/
STATUS
LOmkingpath(
char		*area,		/* "device" that the database is on */
char		*what,		/* path to db, ckp, dmp, work, or jnl */
LOCATION	*loc)		/* set to full path of location */
{
    STATUS	status;
    char	path[MAX_LOC+1];
    i4		flags;
    LOINFORMATION	info;

    /* check for legal arguments */
    if (area == NULL || *area == EOS || STtrmwhite(area) == 0 ||
		what == NULL || *what == EOS)
	return LO_NULL_ARG;

    LOdev_to_root(area, path);
    if ((status = LOfroms(PATH, path, loc)) != OK)
	return status;
    flags = LO_I_TYPE;
    if (LOinfo(loc, &flags, &info))
	return LO_NO_SUCH;
    if ((flags & LO_I_TYPE) == 0 || info.li_type != LO_IS_DIR)
	return LO_NO_SUCH;

    LOfaddpath(loc, SystemLocationSubdirectory, loc);
    if ((status = LOfroms(PATH, path, loc)) != OK)
	return status;
    flags = LO_I_TYPE;
    if (LOinfo(loc, &flags, &info))
    {
	if ((status = LOcreate(loc)) != OK)
	    return status;
    }
    /* Set protections */
    if (setperms(loc, PROT_SRWE_ORWE_G_WRE) != OK)
	return FAIL;
	
    LOfaddpath(loc, what, loc);
    if ((status = LOfroms(PATH, path, loc)) != OK)
	return status;
    flags = LO_I_TYPE;
    if (LOinfo(loc, &flags, &info))
    {
	if ((status = LOcreate(loc)) != OK)
	    return status;
    }
    if (setperms(loc, PROT_SRWE_ORWE_G_WRE) != OK)
	return FAIL;

    flags = LO_I_PERMS;
    if ((status = LOinfo(loc, &flags, &info)) == OK &&
		(info.li_perms & LO_P_WRITE) == 0)
	status = LO_NO_PERM;

    return status;
}
Example #2
0
bool
ascs_chk_priv( char *user_name, char *priv_name )
{
	char	pmsym[128], userbuf[DB_OWN_MAXNAME+1], *value, *valueptr ;
	char	*strbuf = 0;
	int	priv_len;

        /* 
        ** privileges entries are of the form
        **   ii.<host>.*.privilege.<user>:   SERVER_CONTROL,NET_ADMIN,...
	**
	** Currently known privs are:  SERVER_CONTROL,NET_ADMIN,
	**  	    MONITOR,TRUSTED
        */

	STlcopy( user_name, userbuf, DB_OWN_MAXNAME );
	STtrmwhite( userbuf );
	STprintf(pmsym, "$.$.privileges.user.%s", userbuf);
	
	/* check to see if entry for given user */
	/* Assumes PMinit() and PMload() have already been called */

	if( PMget(pmsym, &value) != OK )
	    return FALSE;
	
	valueptr = value ;
	priv_len = STlength(priv_name) ;

	/*
	** STindex the PM value string and compare each individual string
	** with priv_name
	*/
	while ( *valueptr != EOS && (strbuf=STindex(valueptr, "," , 0)))
	{
	    if (!STscompare(valueptr, priv_len, priv_name, priv_len))
		return TRUE ;

	    /* skip blank characters after the ','*/	
	    valueptr = STskipblank(strbuf+1, 10); 
	}

	/* we're now at the last or only (or NULL) word in the string */
	if ( *valueptr != EOS  && 
              !STscompare(valueptr, priv_len, priv_name, priv_len))
		return TRUE ;

	return FALSE;
}
Example #3
0
static STATUS
gcn_decrypt( char *key, char *pbuff, char *passwd )
{
    CI_KS	ksch;
    char	kbuff[ CRYPT_SIZE + 1 ];
    i4		len;

    /*
    ** Validate input.
    */
    if ( key == NULL  ||  passwd == NULL )  return( FAIL );

    if ( pbuff == NULL  || *pbuff == EOS )  
    {
	*passwd = EOS;
	return( OK );
    }

    /*
    ** Adjust key to CRYPT_SIZE by padding/truncation.
    */
    for( len = 0; len < CRYPT_SIZE; len++ )  kbuff[len] = *key ? *key++ : ' ';
    kbuff[ CRYPT_SIZE ] = EOS;
    CIsetkey( kbuff, ksch );

    /*
    ** Password is passed as text, convert back to encoded 
    ** binary.  Encoded password should be of correct size.
    ** Decrypt password.
    */
    CItobin( pbuff, &len, (u_char *)passwd );
    if ( len % CRYPT_SIZE )  return( FAIL );
    CIdecode( passwd, len, ksch, passwd );

    /*
    ** Cleanup password by removing trailing
    ** spaces and the end marker.
    */
    passwd[ len ] = EOS;
    len = STtrmwhite( passwd );
    if ( passwd[ --len ] != GCN_PASSWD_END )  return( FAIL );
    passwd[ len ] = EOS;

    return( OK );
}
Example #4
0
/*{
** Name: xffileinput      - get input files
**
** Description:
**      This routine will make input from the command line, transparent
**      from input from a file name.  This will be done by reading
**      the input file and building an argv,argc parameter from the
**      file specification.
**
**
** Inputs:
**	paramfile		Name of the parameter file 
**				which is passed in
**										to this routine.
**      argv                    ptr to command line parameters
**                              which may point to a file name
**                              containing input specifications
**      argc                    ptr to number of command line parameters
**
** Outputs:
**      argv                    ptr to command line parameters
**                              which may have been created from
**                              an input file specification
**      argc                    ptr to number of command line parameters
**
**      Returns:
**          OK  : if successful.
**	    FAIL: if failed 
**      Exceptions:
**          none
**
** Side Effects:
**          none
**
** History:
**      31-oct-01 (gupsh01)
**          Created.(Based on fileinput:opqutils.sc.)
**
*/
STATUS
xffileinput(
char 		   *paramfile,
char               ***argv,
i4                 *argc)
{
    FILE        *inf;
    STATUS      stat = FAIL;
    LOCATION    inf_loc;

   /* create argv and argc to simulate a "long" command input line */
   /* open the file containing the specifications */

   inf = NULL;

   if (
      ((stat =LOfroms(PATH & FILENAME, paramfile, &inf_loc)) != OK)
       ||
       ((stat = SIopen(&inf_loc, "r", &inf)) != OK)
       ||
       (inf == NULL)
      )
   {   /* report error dereferencing or opening file */
        char        buf[ER_MAX_LEN];
        if ((ERreport(stat, buf)) != OK) buf[0] = '\0';
	IIUGerr(E_XF0007_Cannot_open_param, UG_ERR_ERROR, 1, paramfile);
	return (FAIL);
    }  

    {
        char  buf[XF_MAXBUFLEN]; /* buffer used to read lines 
				 ** from the command file */
	/* ptr to current parameter to be copied from temp buffer */
        char            **targv=(char **)NULL; 
        i4              targc   ;/* number of parameters 
				 ** which have been copied */
        SIZE_TYPE       len;	/* size of dyn.mem. to be allocated. */
        i4              argcount = XF_MAXARGLEN;

        /* get room for maxarglen args */
        len = XF_MAXARGLEN * sizeof(char *);
	targv = (char **)NULL;
	targv = (char **)XF_REQMEM(len, FALSE);

        targc           = 1;
        buf[XF_MAXBUFLEN-1]= 0;

        while ((stat = SIgetrec((PTR)&buf[0], (i4)(XF_MAXBUFLEN-1), inf))
                == OK)
        {
            char *cp = &buf[0];
            do
            {
                if (targc >= argcount)
                {
                    i4  i;
                    char **targv1 = NULL;

                   /* Allocate another vector, 
		   ** twice the size of the prev. */
	           targv = (char **)XF_REQMEM((i4)
			     (argcount * 2 * sizeof(char *)), FALSE);
                    /* Copy previous into current. */
                    for (i = 0; i < argcount; i++)
                        targv1[i] = targv[i];
                    targv = targv1;
                    argcount += argcount;
                }

                {
                    char *tp = (char *) NULL;
                    i4  arglen = STlength(cp);
                    tp = (char *)XF_REQMEM (arglen, FALSE);
                    targv[targc++] = tp;
		    {
                        i4 len = STlength(cp);
                        cp[len - 1] = EOS; 
                        STskipblank(cp,(len -1));
                        STtrmwhite(cp);
                        STcopy(cp, tp);
                        cp = &cp[len - 1];
                    }
                }
            }
            while (*cp);
        }

        if (stat != ENDFILE)
        { 
	    /* report error unable to read line from the file */
	    char        buf[ER_MAX_LEN];
	    if ((ERreport(stat, buf)) != OK) buf[0] = '\0';
	    IIUGerr(E_XF0008_Cannot_read_param, UG_ERR_ERROR, 1, paramfile);
	    return (FAIL);
        }
        *argv = targv;
        *argc = targc;
    }

    /* Close input file */
    stat = SIclose(inf);
    if (stat != OK)
    {   /* report error closing file */
	char        buf[ER_MAX_LEN];
	if ((ERreport(stat, buf)) != OK) buf[0] = '\0';
	IIUGerr(E_XF0025_Cannot_close_param, UG_ERR_ERROR, 1, paramfile);
	return (FAIL);
    }   
    return OK;
}
Example #5
0
static u_i4 
pp_directive( FILE *input, STACK_FRAME *stack , bool ifdef )
{
	i4 n, len;
	char *words[ MAX_LINE / 2 ], *temp, *p;
	char *parse_val, *parse_end;
	STACK_FRAME stack_frame;
	bool def_dir;
	u_i4 rtn = NONE;

	stack_frame.prev = stack;
	stack_frame.display_mode = TRUE;

	p = temp = STalloc( infile->yytext );
	CMnext( p );
	n = sizeof( words );
	STgetwords( p, &n, words ); 

	/* process the directive, watch out for the empty directive */
	if (n == 0)
	{
		;       /* empty directive */
	}
	else if( STequal( words[ 0 ], ERx( "define" ) ) != 0 )
	{
		/* If a symbol was specified look for the value to give it */
		if (n > 1) 
		{
			/* Scan for the 'define' keyword */
			parse_val = infile->yytext;
			CMnext(parse_val);         /* Skip over the '#' */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan past the 'define' keyword */
			while (!CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan over white space separating 'define' */
			/* keyword and the specified symbol name */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* Skip over the symbol name */
			while (!CMwhite(parse_val))
				CMnext(parse_val);

			/* Skip over white space after the symbol name */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* At this point we have scanned to the beginning */
			/* of the defined value for the symbol, Trim off */
			/* any trailing white space */
			STtrmwhite(parse_val);

			/* Define value found, could be the empty string, "" */
			if( active( &stack_frame ) )
			{
				define( words[ 1 ], parse_val, FALSE );
			}
		}
		rtn = DEFINE;
	}

	else if( active( &stack_frame ) &&
		STequal( words[ 0 ], ERx( "undef" ) ) != 0 )
	{
		if (n > 1)
		{
			undefine( words[ 1 ] );
		}
		rtn = UNDEF;
	}

	else if( STequal( words[ 0 ], ERx( "if" ) ) != 0 )
	{
		/* If an expression was specified look for its evaluation */
		if (n > 1) 
		{
			/* Scan for the 'if' keyword */
			parse_val = infile->yytext;
			CMnext(parse_val);         /* Skip over the '#' */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan past the 'if' keyword */
			while (!CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan over white space separating 'if' */
			/* keyword and the expression */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* At this point we have scanned to the beginning */
			/* of the expression.*/
			if( active( &stack_frame ) )
			{
				/* Evaluate boolean expression found */
				stack_frame.display_mode = 
					pp_eval_boolexp( &parse_val, ERx("") );
			}
			(void) pp_input( input, &stack_frame, TRUE );
		}
		rtn = IF;
	}

	else if( STequal( words[ 0 ], ERx( "ifdef" ) ) != 0 )
	{
		if( active(&stack_frame) && is_defined(words[1], NULL) == OK)
		{
			stack_frame.display_mode = TRUE;
		}
		else
			stack_frame.display_mode = FALSE;
		(void) pp_input( input, &stack_frame, TRUE );
		rtn = IFDEF;
	}

	else if( STequal( words[ 0 ], ERx( "ifndef" ) ) != 0 )
	{
		if( active(&stack_frame) && is_defined(words[1], NULL) != OK)
		{
			stack_frame.display_mode = TRUE;
		}
		else
			stack_frame.display_mode = FALSE;
		(void) pp_input( input, &stack_frame, TRUE );
		rtn = IFNDEF;
	}

	else if( STequal( words[ 0 ], ERx( "else" ) ) != 0 )
	{
		if( !ifdef )
		{
			SIfprintf( stderr, E_YAPP007 );
			yydump();
		}
		stack_frame.prev->display_mode =
			( stack_frame.prev->display_mode == TRUE ) ?
			FALSE : TRUE;
		rtn = ELSE;
	}

	else if( STequal( words[ 0 ], ERx( "endif" ) ) != 0 )
	{
		rtn = ENDIF;
	}

	else if( STequal( words[ 0 ], ERx( "include" ) ) != 0 )
	{
		/* Look for the include filename */
		if (n > 1) 
		{
			/* Scan for the 'include' keyword */
			parse_val = infile->yytext;
			CMnext(parse_val);         /* Skip over the '#' */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan past the include keyword */
			while (!CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan over white space separating 'include' */
			/* keyword and the specified filename */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* At this point were expecting "file" or <file> */
			/* remember the character which ends the filename */
			def_dir = TRUE;
			if (CMcmpcase(parse_val, ERx("\"")) == 0)
			{
				parse_end = ERx("\"");
			}
			else if (CMcmpcase(parse_val, ERx("<")) == 0)
			{
				parse_end = ERx(">");
				def_dir = FALSE;
			}
			else
			{
				parse_end = ERx("");
			}

			/* Save the include file name in the temp string. */
			/* Note, this overwrites the parsed words of the  */
			/* record since but these are no longer needed.   */
			p = temp;
			CMnext(parse_val);
			while (*parse_val != EOS)
			{
				if (CMcmpcase(parse_val, parse_end) == 0) 
				{
					/* Terminate the file name and call */
					/* pp_file to process the file. */
					STcopy(ERx(""), p);
					pp_file(stack, temp, def_dir);
					break;
				}
				CMcpychar(parse_val, p);
				CMnext(parse_val);
				CMnext(p);
			}
		}
		rtn = DEFINE;
	}

	/* display everthing but legal directives */ 
	if (rtn == NONE && active( &stack_frame ) )
		yyputline( infile->yytext );

	MEfree( temp );
	return( rtn );
}
Example #6
0
STATUS
append_sepfile(SEPFILE	*sepptr)
{
    STATUS                 ioerr ;
    char                   buffer [SCR_LINE] ;
    FILE                  *fptr = sepptr->_fptr ;
    char                  *endptr, prev_char=EOS ;
    i4                     count, i ;
#ifdef NT_GENERIC
    char                  *ptr = NULL;
    i4                     buffCount, count2;
    bool                   more_found;
#endif

    SEPrewind(sepptr, FALSE);

/*
**  special case if dealing with diff output because
**  (a) lines are padded with spaces to TEST_LINE
**  (b) do not have `\n'
**  (c) first character of last line is SEPENDFILE
**      because of the skewing of the canon & result files
**      especially when special characters are found in those
**      files, the SEPENDFILE character may NOT appear in the
**      second character of a line after the slash '\'.
*/

    if (sepptr == sepDiffer)
    {
	for (;;)
	{
	    ioerr = SIread(fptr, TEST_LINE, &count, buffer);
#ifdef VMS
	    if (ioerr != OK)
		break;
#endif
#ifdef UNIX
	    if (ioerr != OK && ioerr != ENDFILE)
		break;

	    /* Detect EOF if we miss the trailing '\',0xFF */
	    if( count == 0 )
	    {
		ioerr = ENDFILE;
		break;
	    }

#endif
#ifdef NT_GENERIC
	    if (ioerr != OK && ioerr != ENDFILE)
		break;

	    ptr = buffer;
	    i = count = 0;
	    count2 = TEST_LINE;
	    more_found = TRUE;
	    while ((more_found == TRUE) && (ioerr == OK || ioerr == ENDFILE))
	    {
	      count2 = count2 + count;
	      buffCount = 0;
	      while (i != count2)
	      {
		if (buffer[i] == SEP_ESCAPE)
		{
		  CMnext(ptr);
		  i++;
		  if (i == count2)
		  {
		    if (fptr->_ptr[0] == SEP_ESCAPE)
		      buffCount++;
		  }
		  else
		    if (buffer[i] == SEP_ESCAPE)
		      buffCount++;
		}
		if (i != count2)
		{
		  i++;
		  CMnext(ptr);
		}
	      }

	      if (buffCount > 0)
	        ioerr = SIread(fptr, buffCount, &count, ptr);
	      else
		more_found = FALSE;
	    }
	    if (ioerr != OK && ioerr != ENDFILE)
		break;
#endif

	    /* Detect EOF if '\', 0xFF split across two reads */
	    if( buffer[0] == SEPENDFILE &&  prev_char == '\\' )
	    {
		ioerr = ENDFILE;
		break;
	    }
	    prev_char = buffer[81];
	    /* Detect EOF if '\', 0xFF are in consecutive bytes in the buffer */
	    for(i=0, endptr=buffer; i < TEST_LINE; ++i, ++endptr)
	    {
		if( i > 0 && *endptr == SEPENDFILE && *(endptr-1) == '\\' )
			break;
	    }
	    if( i > 0 && *endptr == SEPENDFILE && *(endptr-1) == '\\' )
	    {
		ioerr = ENDFILE;
		break;
	    }
	    buffer[TEST_LINE] = '\0';
 	    SEPtranslate(buffer, SCR_LINE);
	    STtrmwhite(buffer);
	    append_line(buffer, 1);
	}
    }
    else
    {
	while ((ioerr = SEPgetrec(buffer, sepptr)) == OK)
	    append_line(buffer, 0);
    }
    return(ioerr == ENDFILE ? OK : FAIL);

}
Example #7
0
VOID
r_rep_load ()
{
	char    *outname;
	char    *tempname;


	/* start of routine */

	r_open_db();		/* open database. If not there, abort */

	STtrmwhite(En_report);

	/* start object-oriented facility for retrieving reports */
	IIOOinit((OO_OBJECT **)NULL);

	En_rid = -1;

	/* set up report environment. */
	if (St_style==RS_NULL && (St_ispec || r_env_set()))
	{	/* report found.  Read in report specifications */
		if (!St_silent)
		{
			SIprintf(ERget(F_RW0005_Reading_report_spec));
			SIflush(stdout);
		}

		r_rco_set();	/* read in the RCOMMANDS table into core */
	}
	else
	{	/* no report found.  Use report name */
		if (St_repspec)
		{	/* error because report does not exist */
			r_error(0x3F7, FATAL, En_report, NULL);
		}
		En_rtype = RT_DEFAULT;
		En_ferslv.name = En_report;
		if  ((En_ferslv.name_dest = (char *)FEreqmem((u_i4)Rst4_tag,
		     (u_i4)(FE_MAXNAME+1),TRUE,(STATUS *)NULL)) == NULL)
		{
			IIUGbmaBadMemoryAllocation(
					ERx("r_rep_loadld - name_dest"));
		}

		if  ((En_ferslv.owner_dest = (char *)FEreqmem((u_i4)Rst4_tag,
		     (u_i4)(FE_MAXNAME+1),TRUE,(STATUS *)NULL)) == NULL)
		{
			IIUGbmaBadMemoryAllocation(
					ERx("r_rep_loadld - owner_dest"));
		}
		/*
		** If the server supports delimited identifiers, then
		** ensure that .DELIMID is enabled since we're doing a report
		** based upon a table, and it may require such services.
		*/
		if  (IIUIdlmcase() != UI_UNDEFCASE)
		{
			St_xns_given = TRUE;
		}
	}

	/*
	** set up (and maybe prompt for) declared variables
	*/
	r_dcl_set(TRUE);

        if ((En_qlang == FEDMLSQL) && (IIUIdbdata()->firstAutoCom == FALSE))
	{
		IIUIautocommit(UI_AC_OFF);
	}

	if( r_sc_qry(Ptr_set_top) == FAIL )
	{
		return;
	}
    
	IIUIdlmcase();          /* Hack for bug 96801 ingcbt198 */

	if(!r_chk_dat())		/* check for a valid data relation */
	{
		return;
	}


	if( !r_sendqry())/* send the query to the backend */
	{
		return;
	}
	

	if (!r_att_dflt())	/* set up ATT structures for each */
	{			/* attribute in the data relation */
		return;
	}


	if (En_rtype == RT_DEFAULT)
	{	/* set up the default report */
		if (!St_silent)
		{
			SIprintf(ERget(F_RW0006_Setting_up_default));
			SIflush(stdout);
		}

		/* Set up first column as a sort column */

		if  (!r_m_dsort())
		{
			r_error(0x416,NONFATAL,NULL);
			return;
		}
	}

	if (!r_srt_set())		/* set up the SORT data structures */
	{	/* bad RSORT */
		r_error(0x0C, FATAL, NULL);
	}
	/* set up the BRK data structures
	** for each sort attribute with a
	** RACTION tuple defined for it
	*/
	if( !r_brk_set())	
	{
		return;
	}


	/* 
	** If there is a .PAGEWIDTH command and no -l flag has been specified 
	** on the commandline, then reset En_lmax. (The -l flag overrides the 
	** .PAGEWIDTH command). (#129, #588)
	*/
        if( STlength(En_pg_width) > 0 && !St_lspec)
	{
		/* If the pagewidth value is preceded by
		* a dollar, evaluate it as a parameter
		*/
		r_g_set(En_pg_width);
		if( r_g_skip() == TK_DOLLAR )
		{
			CMnext(Tokchar);
			outname = r_g_name();
			if( (tempname = r_par_get(outname)) == NULL )
			{
				r_error(0x3F0, FATAL, outname, NULL);
			}
			STcopy(tempname, En_pg_width);
		}
		/* need to convert to a number and set it to En_lmax */
		if (CVan(En_pg_width, &En_lmax) != OK)
		{
			/* Unable to convert so ignore input */
			r_error(0x403, NONFATAL, outname, NULL);
		}
	}
		
	if (En_rtype == RT_DEFAULT)
	{	/* set up default report */
		r_m_rprt();
	}
	else
	{
		Tcmd_tag = FEbegintag();
		r_tcmd_set();		/* set up the tcmd data structures */
		FEendtag();
	}


	r_lnk_agg();		/* set up the CLR and OP structures for
				** fast processing of aggregates.
				*/

	return;
}
Example #8
0
/*
** NOTE: in SQL grammar target_list of a subselect is processed BEFORE the
**	 from_list; consequently, data types of target list elements are not
**	 known when we build RESDOM nodes for the target list elements of form
**	 [<corr_name>.]<col_name>.  In psl_p_tlist(), we revisit the prototype
**	 tree and fill in the newly available information (type, length,
**	 precision, etc.)
**
**	 When making changes to pst_adresdom(), please take time to understand
**	 the effect these changes may have on the processing of prototype trees.
*/
DB_STATUS
pst_adresdom(
	char               *attname,
	PST_QNODE	   *left,
	PST_QNODE	   *right,
	PSS_SESBLK	   *cb,
	PSQ_CB		   *psq_cb,
	PST_QNODE	   **newnode)
{
    DB_STATUS           status;
    DMT_ATT_ENTRY	*coldesc;
    DMT_ATT_ENTRY	column;
    PSS_RNGTAB		*resrange;
    char		colname[sizeof(DB_ATT_NAME) + 1];   /* null term. */
    PST_RSDM_NODE	resdom;
    i4		err_code;
    PSC_RESCOL		*rescol;
    ADF_CB	*adf_scb;
    i2          null_adjust = 0;
    i4			temp_collID;

    /* Convert column name to a null-terminated string. */
    (VOID) MEcopy((PTR) attname, sizeof(DB_ATT_NAME), (PTR) colname);
    colname[sizeof(DB_ATT_NAME)] = '\0';
    (VOID) STtrmwhite(colname);

    /* For these operations, the result domain comes from the result table */
    if (psq_cb->psq_mode == PSQ_APPEND || psq_cb->psq_mode == PSQ_PROT)
    {
	/* Get the result range variable */
	if (psq_cb->psq_qlang == DB_SQL)
	{
	    resrange = &cb->pss_auxrng.pss_rsrng;
	}
	else
	{
	    resrange = &cb->pss_usrrange.pss_rsrng;
	}

	/* "tid" result column not allowed with these operations */
	if (!STcasecmp(((*cb->pss_dbxlate & CUI_ID_REG_U) ? "TID" : "tid"),
			colname ))
	{
	    psf_error(2100L, 0L, PSF_USERERR, &err_code, &psq_cb->psq_error, 4,
		(i4) sizeof(cb->pss_lineno), &cb->pss_lineno, 
		psf_trmwhite(sizeof(DB_TAB_NAME), 
		    (char *) &resrange->pss_tabname),
		&resrange->pss_tabname,
		psf_trmwhite(sizeof(DB_OWN_NAME), 
		    (char *) &resrange->pss_ownname),
		&resrange->pss_ownname,
		psf_trmwhite(sizeof(DB_ATT_NAME), attname), attname);
	    return (E_DB_ERROR);
	}

	/* Get the column description */
	coldesc = pst_coldesc(resrange, (DB_ATT_NAME *) attname);
	if (coldesc == (DMT_ATT_ENTRY *) NULL)
	{
	    psf_error(2100L, 0L, PSF_USERERR, &err_code, &psq_cb->psq_error, 4,
		(i4) sizeof(cb->pss_lineno), &cb->pss_lineno,
		psf_trmwhite(sizeof(DB_TAB_NAME), 
		    (char *) &resrange->pss_tabname),
		&resrange->pss_tabname,
		psf_trmwhite(sizeof(DB_OWN_NAME), 
		    (char *) &resrange->pss_ownname),
		&resrange->pss_ownname,
		psf_trmwhite(sizeof(DB_ATT_NAME), attname), attname);
	    return (E_DB_ERROR);
	}
	if (coldesc->att_flags & DMU_F_SYS_MAINTAINED)
	{
	    psf_error(E_US1900_6400_UPD_LOGKEY, 0L, PSF_USERERR, 
		&err_code, &psq_cb->psq_error, 4,
		(i4) sizeof(cb->pss_lineno), &cb->pss_lineno,
		psf_trmwhite(sizeof(DB_TAB_NAME), 
		    (char *) &resrange->pss_tabname),
		&resrange->pss_tabname,
		psf_trmwhite(sizeof(DB_OWN_NAME), 
		    (char *) &resrange->pss_ownname),
		&resrange->pss_ownname,
		psf_trmwhite(sizeof(DB_ATT_NAME), attname), attname);

	    return (E_DB_ERROR);
	}
    }
    else if (psq_cb->psq_mode == PSQ_REPLACE)
    {
	/*
	** For the "replace" command, use the result range variable that's
	** in the normal user range table, not the special slot that's
	** reserved for the result table in the append command.
	*/
	/* Get the result range variable */
	resrange = cb->pss_resrng;

	/* "tid" result column not allowed with these operations */
	if (!STcasecmp(((*cb->pss_dbxlate & CUI_ID_REG_U) ? "TID" : "tid"),
			colname))
	{
	    psf_error(2100L, 0L, PSF_USERERR, &err_code, &psq_cb->psq_error, 4,
		(i4) sizeof(cb->pss_lineno), &cb->pss_lineno,
		psf_trmwhite(sizeof(DB_TAB_NAME), 
		    (char *) &resrange->pss_tabname),
		&resrange->pss_tabname,
		psf_trmwhite(sizeof(DB_OWN_NAME), 
		    (char *) &resrange->pss_ownname),
		&resrange->pss_ownname,
		psf_trmwhite(sizeof(DB_ATT_NAME), attname), attname);
	    return (E_DB_ERROR);
	}

	/* Get the column description */
	coldesc = pst_coldesc(resrange, (DB_ATT_NAME *) attname);
	if (coldesc == (DMT_ATT_ENTRY *) NULL)
	{
	    psf_error(2100L, 0L, PSF_USERERR, &err_code, &psq_cb->psq_error, 4,
		(i4) sizeof(cb->pss_lineno), &cb->pss_lineno,
		psf_trmwhite(sizeof(DB_TAB_NAME), 
		    (char *) &resrange->pss_tabname),
		&resrange->pss_tabname,
		psf_trmwhite(sizeof(DB_OWN_NAME), 
		    (char *) &resrange->pss_ownname),
		&resrange->pss_ownname,
		psf_trmwhite(sizeof(DB_ATT_NAME), attname), attname);
	    return (E_DB_ERROR);
	}

	if (coldesc->att_flags & DMU_F_SYS_MAINTAINED)
	{
	    psf_error(E_US1900_6400_UPD_LOGKEY, 0L, PSF_USERERR, 
		&err_code, &psq_cb->psq_error, 4,
		(i4) sizeof(cb->pss_lineno), &cb->pss_lineno,
		psf_trmwhite(sizeof(DB_TAB_NAME), 
		    (char *) &resrange->pss_tabname),
		&resrange->pss_tabname,
		psf_trmwhite(sizeof(DB_OWN_NAME), 
		    (char *) &resrange->pss_ownname),
		&resrange->pss_ownname,
		psf_trmwhite(sizeof(DB_ATT_NAME), attname), attname);

	    return (E_DB_ERROR);
	}
    }
    else if (psq_cb->psq_mode == PSQ_REPCURS)
    {
	/*
	** For the "replace cursor" command, the info comes from the cursor 
	** control block. Cursor column list and update map should always 
	** specify same column set, so the second if statemnt (BTtest) could,
	** perhaps, be removed.
	*/
	rescol = psq_ccol(cb->pss_crsr, (DB_ATT_NAME *) attname);
	if (rescol == (PSC_RESCOL *) NULL)
	{
	    psf_error(2207L, 0L, PSF_USERERR, &err_code, &psq_cb->psq_error, 3,
		sizeof(cb->pss_lineno), &cb->pss_lineno,
		psf_trmwhite(DB_CURSOR_MAXNAME,
			cb->pss_crsr->psc_blkid.db_cur_name),
		cb->pss_crsr->psc_blkid.db_cur_name,
		psf_trmwhite(sizeof(DB_ATT_NAME), attname), attname);
	    return (E_DB_ERROR);
	}

	/* Make sure the column was declared "for update" */
	if (!BTtest((i4) rescol->psc_attid.db_att_id,
	    (char *) &cb->pss_crsr->psc_updmap))
	{
	    psf_error(2207L, 0L, PSF_USERERR, &err_code, &psq_cb->psq_error, 3,
		sizeof(cb->pss_lineno), &cb->pss_lineno,
		psf_trmwhite(DB_CURSOR_MAXNAME, 
			cb->pss_crsr->psc_blkid.db_cur_name),
		cb->pss_crsr->psc_blkid.db_cur_name,
		psf_trmwhite(sizeof(DB_ATT_NAME), attname), attname);
	    return (E_DB_ERROR);
	}

	/* Set up column descriptor */
	coldesc = &column;
	MEcopy((char *) attname, sizeof(DB_ATT_NAME),
	    (char *) &coldesc->att_name);

#ifdef NO
	/*
	** Count columns.  Give error if too many.  One extra for tid.
	*/
	cb->pss_rsdmno++;
	if (cb->pss_rsdmno > (DB_MAX_COLS + 1))
	{
	    psf_error(2130L, 0L, PSF_USERERR, &err_code,
		&psq_cb->psq_error, 1, (i4) sizeof(cb->pss_lineno),
		&cb->pss_lineno);
	    return (E_DB_ERROR);
	}
	coldesc->att_number = cb->pss_rsdmno;
#endif

	coldesc->att_number	= rescol->psc_attid.db_att_id;
	coldesc->att_type	= rescol->psc_type;
	coldesc->att_width	= rescol->psc_len;
	coldesc->att_prec	= rescol->psc_prec;
	coldesc->att_collID	= -1;
	coldesc->att_geomtype = -1;
	coldesc->att_srid = -1;
	coldesc->att_encflags = 0;
	coldesc->att_encwid = 0;
    }
    else
    {
	/*
	** In all other cases, just take the datatype info
	** from the right child.
	*/
	coldesc = &column;
	MEcopy((char *) attname, sizeof(DB_ATT_NAME),
	    (char *) &coldesc->att_name);

	/*
	** Count columns.  Give error if too many.  One extra for tid.
	*/
	cb->pss_rsdmno++;
	if (cb->pss_rsdmno > (DB_MAX_COLS + 1))
	{
	    psf_error(2130L, 0L, PSF_USERERR, &err_code,
		&psq_cb->psq_error, 1, (i4) sizeof(cb->pss_lineno),
		&cb->pss_lineno);
	    return (E_DB_ERROR);
	}
	coldesc->att_number = cb->pss_rsdmno;

	status = pst_rsdm_dt_resolve(right, coldesc, cb, psq_cb);
	if (DB_FAILURE_MACRO(status))
	    return(status);
    }

    /* Copy attribute information into PST_RSDM_NODE */
    resdom.pst_rsno = coldesc->att_number;
    /* The two fields below are initialized for a common case.
    ** They are context sensitive and in many cases may have to be
    ** modified by the caller of this routine.
    */
    resdom.pst_ntargno = resdom.pst_rsno;
    resdom.pst_ttargtype = PST_USER;
    resdom.pst_dmuflags  = 0;
    /* Don't bother with the conversion id for now */
    /* Not for update until we know otherwise */
    resdom.pst_rsupdt = FALSE;
    resdom.pst_rsflags = PST_RS_PRINT;
    MEcopy((char *) &coldesc->att_name, sizeof(DB_ATT_NAME),
	(char *) resdom.pst_rsname);
    temp_collID = coldesc->att_collID;

    /* If client can not handle i8 INTs downgrade to i4 */
    adf_scb = (ADF_CB *) cb->pss_adfcb;
    if ( !(adf_scb->adf_proto_level & AD_I8_PROTO) && (abs(coldesc->att_type) == DB_INT_TYPE) )
    {
        if(coldesc->att_type < 0)
        {
            null_adjust = 1;
        }
        if((coldesc->att_width - null_adjust) == sizeof(i8))
        {
            coldesc->att_width -= sizeof(i4);
        }
    }

    /* Now allocate the node */
    status = pst_node(cb, &cb->pss_ostream, left, right, PST_RESDOM,
	(char *) &resdom, sizeof(PST_RSDM_NODE), (DB_DT_ID) coldesc->att_type,
	(i2) coldesc->att_prec, (i4) coldesc->att_width, (DB_ANYTYPE *) NULL,
	newnode, &psq_cb->psq_error, (i4) 0);
    if (status != E_DB_OK)
    {
	return (status);
    }

    (*newnode)->pst_sym.pst_dataval.db_collID = temp_collID;
    /* Remember the last result domain produced */
    cb->pss_tlist = *newnode;
    return (E_DB_OK);
}
Example #9
0
/*{
** Name: psy_print	- Format query text to send to user
**
** Description:
**      This function decodes query text that comes from the iiqrytext relation
**	and formats it to send to the user.  It is useful for the "help permit",
**	"help integrity", and "help view" commands.
**
**	Query text stored in the iiqrytext relation consists of human-readable
**	text and special symbols.  Some of these special symbols are numbers
**	and strings sent from EQUEL or ESQL programs.  Others stand for table
**	names, range variables, and column numbers.  This functio decodes all
**	this stuff, and puts the result into a chain of PSY_QTEXT blocks to be
**	sent back to the user.
**
** Inputs:
**	mstream				Memory stream to allocate blocks from
**	map				map of range var numbers to those
**					in rngtab.
**	block				Current query text block
**      text                            Pointer to the query text
**	length				Length of the query text
**	rngtab				The range table (used for decoding the
**					special symbol standing for range
**					variable numbers, and column numbers).
**					The result range variable should stand
**					for the table we're getting help on.
**	err_blk				Filled in if an error happens
**
** Outputs:
**      err_blk                         Filled in if an error happened
**	Returns:
**	    E_DB_OK			Success
**	    E_DB_ERROR			Non-catastrophic failure
**	    E_DB_FATAL			Catastrophic failure
**	Exceptions:
**	    none
**
** Side Effects:
**	    Sends query text to user
**
** History:
**      15-jul-86 (jeff)
**          written
**	14-jul-93 (ed)
**	    replacing <dbms.h> by <gl.h> <sl.h> <iicommon.h> <dbdbms.h>
*/
DB_STATUS
psy_print(
	PSF_MSTREAM	   *mstream,
	i4		    map[],
	PSY_QTEXT	   **block,
	u_char             *text,
	i4		   length,
	PSS_USRRANGE	   *rngtab,
	DB_ERROR	   *err_blk)
{
    char                buf[1024 + DB_TAB_MAXNAME];
    i4                  i4align;
    i2                  i2align;
    f8                  f8align;
    register u_char	*p;
    register i4	j;
    register i4	i;
    PSS_RNGTAB		*lastvar = (PSS_RNGTAB *) NULL;
    DB_STATUS		status;
    i4			slength;

    /* Put out range statements */
    for (i = 0; i < PST_NUMVARS; i++)
    {
	/* Only look at range vars that are being used */
	if (!rngtab->pss_rngtab[i].pss_used ||
	    rngtab->pss_rngtab[i].pss_rgno < 0)
	{
	    continue;
	}

	status = psy_put(mstream, (char*) "range of ", 
	    (i4) sizeof("range of ") - 1, block, 
	    err_blk);
	if (DB_FAILURE_MACRO(status))
	    return (status);

	/* NULL terminate and trim blanks from range variable name */
	MEcopy(rngtab->pss_rngtab[i].pss_rgname, DB_TAB_MAXNAME, buf);
	buf[DB_TAB_MAXNAME] = '\0';
	slength = STtrmwhite(buf);
	status = psy_put(mstream, buf, slength, block, err_blk);
	if (DB_FAILURE_MACRO(status))
	    return (status);
	status = psy_put(mstream, " is ", (i4) sizeof(" is ") - 1,
	     block, err_blk);
	if (DB_FAILURE_MACRO(status))
	    return (status);

	/* NULL terminate and trim blanks from table name */
	MEcopy((char *) &rngtab->pss_rngtab[i].pss_tabname, DB_TAB_MAXNAME, buf);
	buf[DB_TAB_MAXNAME] = '\0';
	slength = STtrmwhite(buf);
	status = psy_put(mstream, buf, slength, block, err_blk);
	if (DB_FAILURE_MACRO(status))
	    return (status);

	/* Newline after every range statement */
	status = psy_put(mstream, (char*) "\n", (i4) 1, block, err_blk);
	if (DB_FAILURE_MACRO(status))
	    return (status);
    }

    for (p = text; p < (u_char*) text + length;)
    {
	switch (*p++)
	{
	case PSQ_HVSTR:	    /* String sent from user program */
	    slength = STlength((char*) p);

	    /* Emit opening quote */
	    status = psy_put(mstream, (char *) "\"", 1, block, err_blk);
	    if (DB_FAILURE_MACRO(status))
		return (status);

	    for (j = slength; j > 0; j--, p++)
	    {
		if (*p == '"')
		{
		    /* Escape any quote characters */
		    status = psy_put(mstream, "\\\"", 2, block, err_blk);
		    if (DB_FAILURE_MACRO(status))
			return (status);
		}
		else if (!CMprint(p))
		{
		    /* Non-printing characters show up as escape sequence */
		    STprintf(buf, "\\%o", *p);
		    status = psy_put(mstream, buf, (i4) STlength(buf),
			block, err_blk);
		    if (DB_FAILURE_MACRO(status))
			return (status);
		}
		else
		{
		    status = psy_put(mstream, (char*) p, 1, block, err_blk);
		    if (DB_FAILURE_MACRO(status))
			return (status);
		}
	    }
	    break;

	case PSQ_HVF8:	    /* f8 sent from user program */
	    MEcopy((char *) p, sizeof(f8align), (char *) &f8align);
	    STprintf(buf, "%f", f8align);
	    status = psy_put(mstream, buf, (i4) STlength(buf), block, err_blk);
	    if (DB_FAILURE_MACRO(status))
		return (status);
	    p += sizeof(f8align);
	    break;

	case PSQ_HVI4:	    /* i4 sent from user program */
	    MEcopy((char *) p, sizeof(i4align), (char *) &i4align);
	    CVla(i4align, buf);
	    status = psy_put(mstream, buf, (i4) STlength(buf), block, err_blk);
	    if (DB_FAILURE_MACRO(status))
		return (status);
	    p += sizeof(i4align);
	    break;

	case PSQ_HVI2:	    /* i2 sent from user program */
	    MEcopy((char *) p, sizeof(i2align), (char *) &i2align);
	    CVla((i4) i2align, buf);
	    status = psy_put(mstream, buf, (i4) STlength(buf), block, err_blk);
	    if (DB_FAILURE_MACRO(status))
		return (status);
	    p += sizeof(i2align);
	    break;

	case DB_INTRO_CHAR: /* Intro char for special sequence */
	    switch (*p++)
	    {
	    case DB_RNG_VAR:
		/* Put a blank before the table name */
		status = psy_put(mstream, " ", 1, block, err_blk);
		if (DB_FAILURE_MACRO(status))
		    return (status);

		/* Get the range variable number */
		MEcopy((char *) p, sizeof(i4align), (char *) &i4align);
		p += sizeof(i4align);

		i4align = map[i4align];
		/* Look up range variable number */
		for (j = 0; j < PST_NUMVARS; j++)
		{
		    if (rngtab->pss_rngtab[j].pss_used &&
			rngtab->pss_rngtab[j].pss_rgno == i4align)
		    {
			break;
		    }
		}

		/* If found, give variable name, otherwise question marks */
		if (j < PST_NUMVARS)
		{
		    /* trim trailing blanks and NULL terminate */
		    MEcopy(rngtab->pss_rngtab[j].pss_rgname, DB_TAB_MAXNAME, buf);
		    buf[DB_TAB_MAXNAME] = '\0';
		    slength = STtrmwhite(buf);
		    status = psy_put(mstream, buf, slength, block, err_blk);
		    if (DB_FAILURE_MACRO(status))
			return (status);
		    /* Remember the range variable for when we get the colnum */
		    lastvar = &rngtab->pss_rngtab[j];
		}
		else
		{
		    lastvar = (PSS_RNGTAB*) 0;
		    /* Put question marks if not found */
		    status = psy_put(mstream, "???", 3, block, err_blk);
		    if (DB_FAILURE_MACRO(status))
			return (status);
		}
		break;

	    case DB_COL_NUM:	    /* Column number for a range var */

		/* Get the column number */
		MEcopy((char *) p, sizeof(i4align), (char *) &i4align);
		p += sizeof(i4align);

		/* If there was no range variable, put question marks */
		if (lastvar != (PSS_RNGTAB *) NULL)
		{
		    status = psy_put(mstream, 
			lastvar->pss_attdesc[i4align]->att_nmstr,
			lastvar->pss_attdesc[i4align]->att_nmlen,
			block, err_blk);
		    if (DB_FAILURE_MACRO(status))
			return (status);
		}
		else
		{
		    /* Don't know column name, just give question marks */
		    status = psy_put(mstream, "???", 3, block, err_blk);
		    if (DB_FAILURE_MACRO(status))
			return (status);
		}

		/* Put a blank after the column name */
		status = psy_put(mstream, " ", 1, block, err_blk);
		if (DB_FAILURE_MACRO(status))
		    return (status);

		break;

	    case DB_TBL_NM:
		/* The table name is in the result slot of the range table */

		/* Put a blank before the table name */
		status = psy_put(mstream, " ", 1, block, err_blk);
		if (DB_FAILURE_MACRO(status))
		    return (status);

		/* NULL terminate and trim blanks from the table name */
		MEcopy((char *) &rngtab->pss_rsrng.pss_tabname,
		    sizeof(DB_TAB_NAME), buf);
		buf[DB_TAB_MAXNAME] = '\0';
		slength = STtrmwhite(buf);
		status = psy_put(mstream, buf, slength, block, err_blk);
		if (DB_FAILURE_MACRO(status))
		    return (status);

		/* Put a blank after the table name */
		status = psy_put(mstream, " ", 1, block, err_blk);
		if (DB_FAILURE_MACRO(status))
		    return (status);

		break;

	    case DB_RES_COL:	/* Result column: column in result table */
		/* Put a blank before the column name */
		status = psy_put(mstream, " ", 1, block, err_blk);
		if (DB_FAILURE_MACRO(status))
		    return (status);

		/* Get the column number for the result column */
		MEcopy((char *) p, sizeof(i4align), (char *) &i4align);
		p += sizeof(i4align);

		/* Get the column name from the result range variable */
		lastvar = &rngtab->pss_rsrng;
		status = psy_put(mstream,
			lastvar->pss_attdesc[i4align]->att_nmstr,
			lastvar->pss_attdesc[i4align]->att_nmlen,
			block, err_blk);
		if (DB_FAILURE_MACRO(status))
		    return (status);

		/* Put a blank after the column name */
		status = psy_put(mstream, " ", 1, block, err_blk);
		if (DB_FAILURE_MACRO(status))
		    return (status);
		break;

	    default:
		/* Unknown special sequence: just put out as it came in */
		status = psy_put(mstream, (char*) p - 1, 2, block, err_blk);
		if (DB_FAILURE_MACRO(status))
		    return (status);
		break;
	    }
	    break;
	default:
	    /* No special case, just put the char */
	    status = psy_put(mstream, (char*) p - 1, 1, block, err_blk);
	    break;
	}
    }

    /* Put a newline just after the statement */
    status = psy_put(mstream, "\n", 1, block, err_blk);
    return (status);
}
Example #10
0
/*{
** Name: pst_adparm	- Add a parameter node to a query tree.
**
** Description:
**      This function adds a parameterized constant node to a query tree.
**	It takes a parameter number and a format, translates the format to
**	a datatype and length, and creates a constant node containing the
**	datatype, length, and parameter number.
**
**	Valid formats are:
**	    c
**	    i1
**	    i2
**	    i4
**	    f4
**	    f8
**
** Inputs:
**	sess_cb				Session control block
**	psq_cb				Query control block
**      stream                          The memory stream for allocating the
**					node
**	parmno				The parameter number
**	format				The format string
**	newnode				Place to put pointer to new node
**	highparm			Pointer to the highest parm number found
**					so far.
**
** Outputs:
**      newnode                         Filled in with pointer to new node
**	highparm			Filled in with new parm number, if
**					higher than previous value.
**	psq_cb				Query control block
**	    .psq_error			filled in, if an error happens
**	Returns:
**	    E_DB_OK			Success
**	    E_DB_ERROR			Non-catastrophic error
**	    E_DB_FATAL			Catastrophic error
**	Exceptions:
**	    none
**
** Side Effects:
**	    Allocates memory
**
** History:
**	01-may-86 (jeff)
**          written
**	29-jul-87 (daved)
**	    set VLUP (strings) to have length of ADE_LEN_UNKNOWN
**	18-feb-88 (stec)
**	    Change initialization of pst_pmspec (must not be PST_PMMAYBE).
**	07-jun-88 (stec)
**	    Initialize pst_tparmtype in the constant node.
**	03-nov-88 (stec)
**	    Correct a bug found by lint.
**	30-mar-89 (jrb)
**	    Changed datalen to an i4 (to match pst_node's input type) and added
**	    dataprec for decimal project.
**	12-jan-93 (andre)
**	    pass 0 as precision to pst_node()
**	10-aug-93 (andre)
**	    fixed cause of compiler warning
*/
DB_STATUS
pst_adparm(
	PSS_SESBLK	   *sess_cb,
	PSQ_CB		   *psq_cb,
	PSF_MSTREAM        *stream,
	i2		   parmno,
	char		   *format,
	PST_QNODE	   **newnode,
	i4		   *highparm)
{
    DB_STATUS		status;
    register i4         first_char = format[0];
    register i4	second_char = format[1];
    register i4	third_char = format[2];
    DB_DT_ID		datatype;
    i4			datalen;
    PST_CNST_NODE	const_node;
    bool		legal_format = TRUE;
    i4		err_code;

    if (first_char == 'c')
    {
        if (!second_char)
        {
            const_node.pst_pmspec = PST_PMMAYBE;
            datatype = DB_TXT_TYPE;
            datalen = ADE_LEN_UNKNOWN;
	}
	else
	{
	    legal_format = FALSE;
        }
    }
    else if (first_char == 'i' && third_char == 0)
    {
        const_node.pst_pmspec  = PST_PMNOTUSED;
        datatype = DB_INT_TYPE;
        if (second_char == '1')
	    datalen = 1;
        else if (second_char == '2')
	    datalen = 2;
        else if (second_char == '4')
	    datalen = 4;
        else
	    legal_format = FALSE;
    }
    else if (first_char == 'f' && third_char == 0)
    {
        const_node.pst_pmspec  = PST_PMNOTUSED;
        datatype = DB_FLT_TYPE;
        if (second_char == '4')
	    datalen = 4;
        else if (second_char == '8')
            datalen = 8;
        else
	    legal_format = FALSE;
    }
    else
    {
        legal_format = FALSE;
    }

    if (legal_format)
    {
	/* Allocate the constant node */
	const_node.pst_tparmtype = PST_RQPARAMNO;
	const_node.pst_parm_no = parmno;
	const_node.pst_cqlang = sess_cb->pss_lang;
	const_node.pst_origtxt = (char *) NULL;

	status = pst_node(sess_cb, stream, (PST_QNODE *) NULL,
	    (PST_QNODE *) NULL, PST_CONST, (PTR) &const_node,
	    sizeof(const_node), datatype, (i2) 0, datalen,
	    (DB_ANYTYPE *) NULL, newnode, &psq_cb->psq_error, (i4) 0);

	/* Remember the highest parameter number */
	if (*highparm < parmno)
	    *highparm = parmno;
	return (status);
    }
    else
    {
        (VOID) psf_error(200L, 0L, PSF_USERERR,
	    &err_code, &psq_cb->psq_error, 1, STtrmwhite(format), format);
        return (E_DB_ERROR);
    }
}
Example #11
0
VOID
do_crack_cmd(i4 argc, char **argv)
{
	i4	i;
	i4	argc_remain;
	i4	obj_params;
	bool	rn_params;
	bool	bogus_param;
	bool	all_param;
	OOID	del_obj_type;
	STATUS	c;
	char	*with_ptr;
	char	*user_flag;
	char	*group_flag;
	char	*pwd_flag;
	char	*tmp_ptr;
	FE_DEL	*fd;
	FE_DEL	*prev_fd;
	char	pr_buf[256];		/* Holds any current prompt */


	/*
	** Default to no wildcard expansion and no specified object type.
	** Indicate no names seen yet on command line, and no bogus
	** parameters.  Indicate no object type specifications (there
	** should never be more than one).
	** Track remaining command line parameters.
	*/
	Dobj_wildcard = FALSE;
	del_obj_type = OC_UNDEFINED;
	obj_params = 0;
	rn_params = FALSE;
	bogus_param = FALSE;
	all_param = FALSE;
	argc_remain = argc - 1;	/* Bypass argv[0] - the program name!	*/
	Dobj_database = NULL;   /* assume no database name b66456       */

	i = 1;			/* First pull out any flags	*/
	while (i < argc)
	{
		if  (*(argv[i]) == '-')	/* Flag found. Set and clear out */
		{
			switch(*(argv[i] + 1))
			{
			case('r'):
			case('R'):
				CVlower((argv[i] + 1));
				if  (STcompare((argv[i] + 1),DO_RPT_FLAG) == 0)
				{
					del_obj_type = OC_REPORT;
					Dobj_pr_str = ERget(F_DE0008_Rep);
					obj_params++;
				}
				else
				{
					bogus_param = TRUE;
				}
				break;
			case('f'):
			case('F'):
				CVlower((argv[i] + 1));
				if  (STcompare((argv[i] + 1),DO_FORM_FLAG) == 0)
				{
					del_obj_type = OC_FORM;
					Dobj_pr_str = ERget(F_DE0004_Form);
					obj_params++;
				}
				else
				{
					bogus_param = TRUE;
				}
				break;
			case('j'):
			case('J'):
				CVlower((argv[i] + 1));
				if  (STcompare((argv[i] + 1),DO_JD_FLAG) == 0)
				{
					del_obj_type = OC_JOINDEF;
					Dobj_pr_str = ERget(F_DE0006_Jdef);
					obj_params++;
				}
				else
				{
					bogus_param = TRUE;
				}
				break;
			case('g'):
			case('G'):
				tmp_ptr = STalloc(argv[i]);
				CVlower((tmp_ptr + 1));
				if  (STcompare((tmp_ptr + 1),DO_GRAF_FLAG) == 0)
				{
					del_obj_type = OC_GRAPH;
					Dobj_pr_str = ERget(F_DE0005_Graph);
					obj_params++;
				}
				else if (*(argv[i] + 1) == 'G')
				{
					Dobj_gidflag = argv[i];	
				}
				else
				{
					bogus_param = TRUE;
				}
				MEfree((PTR)tmp_ptr);
				break;
			case('a'):
			case('A'):
				CVlower((argv[i] + 1));
				if  (STcompare((argv[i] + 1),DO_APPL_FLAG) == 0)
				{
					del_obj_type = OC_APPL;
					Dobj_pr_str = ERget(F_DE0003_App);
					obj_params++;
				}
				else if  (STcompare((argv[i] + 1),
						    DO_ALL_FLAG) == 0)
				{
					del_obj_type = OC_OBJECT;
					/*
					** No prompt string for -all
					*/
					Dobj_pr_str = ERget(F_DE0009_Dobj_O);
					all_param = TRUE;
				}
				else
				{
					bogus_param = TRUE;
				}
				break;
			case('q'):
			case('Q'):
				CVlower((argv[i] + 1));
				if  (STcompare((argv[i] + 1),DO_QBF_FLAG) == 0)
				{
					del_obj_type = OC_QBFNAME;
					Dobj_pr_str = ERget(F_DE0007_Qbfnm);
					obj_params++;
				}
				else
				{
					bogus_param = TRUE;
				}
				break;
			case('i'):
			case('I'):
				CVlower((argv[i] + 1));
				if  (STcompare((argv[i] + 1),DO_INCL_FLAG) == 0)
				{
					/*
					** Clear out the flag so we don't see
					** it when we look for DB and FE object
					** names.
					*/
					argv[i] = NULL;
					i++;
					if  (i >= argc)
					{
						IIUGerr(E_DE000B_Dobj_no_file,
							UG_ERR_ERROR,0);
						FEexits(ERx(""));
						PCexit(FAIL);
						break;
					}
					Dobj_dfile = argv[i];
				}
				else
				{
					bogus_param = TRUE;
				}
				break;
			case('s'):
			case('S'):
				CVlower((argv[i] + 1));
				if  (STcompare((argv[i] + 1),DO_QT_FLAG) == 0)
				{
					Dobj_silent = TRUE;
				}
				else
				{
					bogus_param = TRUE;
				}
				break;
			case('u'):
			case('U'):
				Dobj_uflag = argv[i];
				break;
			case('w'):
			case('W'):
				CVlower((argv[i] + 1));
				if  (STcompare((argv[i] + 1),DO_WILD_FLAG) == 0)
				{
					Dobj_wildcard = TRUE;
				}
				else
				{
					bogus_param = TRUE;
				}
				break;
			case('P'):	/* -P (password) flag set	*/
				Dobj_passflag = argv[i];	
				break;
			default:
				bogus_param = TRUE;
				break;
			}
			if  (bogus_param)
			{
				IIUGerr(E_DE000A_Dobj_bad_flag,
					UG_ERR_ERROR,2,argv[i],
					ERget(E_DE0014_Dobj_syntax));
				FEexits(ERx(""));
				PCexit(FAIL);
			}
			/*
			** Clear out the flag so we don't see it when
			** we look for DB and FE object names.
			*/
			argv[i] = NULL;
			argc_remain--;
		}
		i++;
	}


# ifdef DGC_AOS
	with_ptr = STalloc(ERx("dgc_mode='reading'");
	IIUIswc_SetWithClause(with_ptr);
# else
	with_ptr = ERx("");
# endif

	/*
	** If -all was specified, then we can't have -wildcard, -include,
	** object type specifications, or objects names as well.  argc_remain
	** should at most reflect a database name.
	*/
	if  ((all_param) &&
	     ((Dobj_wildcard) || (Dobj_dfile != NULL) ||
	      (obj_params > 0) || (argc_remain > 1)))
	{
		IIUGerr(E_DE0012_Dobj_badall,UG_ERR_ERROR,1,
			ERget(E_DE0014_Dobj_syntax));
		FEexits(ERx(""));
		PCexit(FAIL);
	}

	/*
	** If multiple object types were specified, then abort!
	*/
	if  (obj_params > 1)
	{
		IIUGerr(E_DE0015_Dobj_multype,UG_ERR_ERROR,1,
			ERget(E_DE0014_Dobj_syntax));
		FEexits(ERx(""));
		PCexit(FAIL);
	}
	/*
	** If no object type was specified, then abort!
	*/
	if  (del_obj_type == OC_UNDEFINED)
	{
		IIUGerr(E_DE0013_Dobj_notype,UG_ERR_ERROR,1,
			ERget(E_DE0014_Dobj_syntax));
		FEexits(ERx(""));
		PCexit(FAIL);
	}

	/*
	** Check to see that the database name was specified.
	** If so, it will be the first non-flag parameter.
	** If not, ask for one:
	*/
	i = 1;
	while (i < argc)
	{
		if  (argv[i] == NULL)
		{
		/*
		** If we reached a used option,
		**   then the database name is missing.  b66456
		*/
			break;
			/* i++; */
			/* continue; */
		}

		/*
		** If we reached an option then, no dbname  b66456
		*/
		if (*argv[i] == '-')
		  break;

		Dobj_database = argv[i++];
		break;
	}

	if  (Dobj_database == NULL)
	{
		c = FEprompt(ERget(FE_Database),TRUE,(sizeof(pr_buf) - 1),
			     &pr_buf[0]);
		Dobj_database = STalloc(&pr_buf[0]);
	}

	/*
	** If the '-P' flag has been set, prompt for the password
	*/
	if  (Dobj_passflag != NULL)
	{
		/*
		** If there is something wrong with the '-P' flag, such as the
		** user has specified the password on the command line,
		** IIUIpassword() will return NULL.  In such cases bail out.
		*/
		if  ((Dobj_passflag = IIUIpassword(Dobj_passflag)) == NULL)
		{
			IIUGerr(E_DE000A_Dobj_bad_flag,UG_ERR_ERROR,2,
				ERx("-P"),ERget(E_DE0014_Dobj_syntax));
			FEexits(ERx(""));
			PCexit(FAIL);
		}
	}

	/*
	** Open the database, will abort on FAIL.  We do it here because we
	** need to establish the invoking user name before we process the FE
	** object names.  We use "user" since owners of FE objects are always
	** stored in the FE catalogs as lower case.  This will have to change
	** to suser when we fully support authorization identifiers as
	** delimited identifiers, which can be other than lower case
	** (specifically FIPS which is UI_MIXED_CASE).
	*/
	user_flag = ERx("");
	group_flag = ERx("");
	pwd_flag = ERx("");
	if  (Dobj_uflag != NULL)
	{
		user_flag = Dobj_uflag;
	}
	if  (Dobj_gidflag != NULL)
	{
		group_flag = Dobj_gidflag;
	}
	if  (Dobj_passflag != NULL)
	{
		pwd_flag = Dobj_passflag;
	}
	if  (FEingres(Dobj_database,user_flag,group_flag,pwd_flag,NULL) != OK)
	{
		IIUGerr(E_DE0004_NoOpen,UG_ERR_ERROR,0);
		FEexits(ERx(""));
		PCexit(FAIL);
	}

	/*
	** If -all was specified, force a wildcard expansion of "%".
	** do_expand_name() will recognize del_obj_type == OC_OBJECT
	** as being special.
	*/
	if  (del_obj_type == OC_OBJECT)
	{
		Dobj_wildcard = TRUE;
		fd = (FE_DEL *)MEreqmem(0,sizeof(FE_DEL),TRUE,NULL);
		Ptr_fd_top = fd;
		prev_fd = (FE_DEL *)NULL;
		Cact_fd = fd;
		Cact_fd->fd_name_info = (FE_RSLV_NAME *)MEreqmem(0,
						sizeof(FE_RSLV_NAME),TRUE,NULL);
		Cact_fd->fd_name_info->name = STalloc(ERx("%"));
		Cact_fd->fd_below = (FE_DEL *)NULL;
		Cact_fd = do_expand_name(Cact_fd,&prev_fd,del_obj_type);
		return;
	}

	/*
	** The rest of the parameters will be FE object names.
	*/
	while (i < argc)
	{
		if  (argv[i] == NULL)
		{
			i++;
			continue;
		}
		rn_params = TRUE;
		fd = (FE_DEL *)MEreqmem(0,sizeof(FE_DEL),TRUE,NULL);
		if  (Ptr_fd_top == (FE_DEL *)NULL)
		{
			Ptr_fd_top = fd;
			prev_fd = (FE_DEL *)NULL;
		}
		else
		{
			Cact_fd->fd_below = fd;
			prev_fd = Cact_fd;
		}
		Cact_fd = fd;
		Cact_fd->fd_name_info = (FE_RSLV_NAME *)MEreqmem(0,
						sizeof(FE_RSLV_NAME),TRUE,NULL);
		Cact_fd->fd_name_info->name = STalloc(argv[i]);
		Cact_fd->fd_below = (FE_DEL *)NULL;
		Cact_fd = do_expand_name(Cact_fd,&prev_fd,del_obj_type);
		/*
		** Returns ptr to current end of FE_DEL chain, which may be
		** NULL if (still) 1st and no match.  If no match, the FE_DEL
		** and its name will have been de-allocated, and prev_fd and
		** Ptr_fd_top will have been be altered as required.
		*/
		i++;
	}

	if  (Dobj_dfile != NULL)
	{
		do_ifile_parse(Dobj_dfile,del_obj_type);
	}	

	/*
	** If we found anything, then we're all done
	*/
	if  (Ptr_fd_top != (FE_DEL *)NULL)
	{
		return;
	}

	/*
	** If we had FE object names either on the command line or in a
	** file but they all failed expansion/resolution, then don't prompt
	** for any names!
	*/
	if  ((rn_params) || (Dobj_dfile != NULL))
	{
		IIUGerr(E_DE000C_Dobj_no_input,UG_ERR_ERROR,1,
			Dobj_pr_str);
		FEexits(ERx(""));
		PCexit(FAIL);
	}

	/*
	** Prompt for no FE object name - either on
	** the command line or in a -list file.  Note that
	** we ignore any Dobj_silent in this instance.
	*/
	while (TRUE)
	{
		c = FEprompt(Dobj_pr_str,FALSE,(sizeof(pr_buf) - 1),&pr_buf[0]);
		if  ((c != OK) || (STtrmwhite(&pr_buf[0]) == 0))
		{
			/*
			** When NULL string entered (or error), all done
			*/
			break;
		}
		fd = (FE_DEL *)MEreqmem(0,sizeof(FE_DEL),TRUE,NULL);
		if  (Ptr_fd_top == (FE_DEL *)NULL)
		{
			Ptr_fd_top = fd;
			prev_fd = (FE_DEL *)NULL;
		}
		else
		{
			Cact_fd->fd_below = fd;
			prev_fd = Cact_fd;
		}
		Cact_fd = fd;
		Cact_fd->fd_name_info = (FE_RSLV_NAME *)MEreqmem(0,
						sizeof(FE_RSLV_NAME),TRUE,NULL);
		Cact_fd->fd_name_info->name = STalloc(&pr_buf[0]);
		Cact_fd->fd_below = (FE_DEL *)NULL;
		Cact_fd = do_expand_name(Cact_fd,&prev_fd,del_obj_type);
	}

	if  (Ptr_fd_top == (FE_DEL *)NULL)
	{
		IIUGerr(E_DE000C_Dobj_no_input,UG_ERR_ERROR,1,Dobj_pr_str);
		FEexits(ERx(""));
		PCexit(FAIL);
	}

	return;
}
Example #12
0
/*
** Name: main			-main routine.
**
** Description:
**	This routine is the main control routine for iirundbms. Starting an
**	iidbms server consists of:
**	    1) Opening and reading the PM data
**	    2) Validating server arguments, converting to VMS internal format.
**	    3) Creating mailbox for communication with server.
**	    4) creating server processing.
**	    5) Sending server process its commands.
**	    6) Checking whether server startup succeeded or not.
**
**	iirundbms command line format is:
**	    iirundbms <server type> <server flavor>
**	where server type is something like "dbms", "recovery", "star", and
**	server flavor is something like "public", "nonames", "benchmark".
**
** Inputs:
**	argc			- number of arguments (should be 1, 2 or 3)
**	argv			- argument array.
**
** Outputs:
**	None
**
** Returns:
**	a VMS status code is returned.
**
** History:
**	31-jan-1994 (bryanp)
**	    Added comment header.
**      21-Jan-1998 (horda03) Bug 68559
**          For GCC servers where a server flavour has been specified,
**          command line to start the server must specify the server
**          flavour in the form; "-instance=<server_flavor>" in order
**          for the GCC to pickup the correct configuration details.
**      22-feb-1998 (chash01)
**          RMCMD (Visual DBA backend server) startup takes two VMS CREPRC
**          calls, one ihere, one in rmcmd.exe.  When RMCMD server starts
**          the PID returned by CREPRC in this module is no longer valid.
**          WE have to first decode pid in the t_user_data field returned by
**          RMCMD server in termination  mailbox before print PID and 
**          server name to terminal.
**      31-Aug-2007 (ashco01) Bug #113490 & Bug #119021.
**          Corrected detection of 'instance name' for GCB & GCD.
**      05-Dec-2007 (ashco01) Bug #119561.
**          Ensure that all Ingres back-end detached processes define the 
**          SYS$SCRATCH logical as this is referenced via II_TEMPORARY
**          when placing temporary DCL files.
**      10-Dec-2007 (ashco01) Bug #119561
**          Define SYS$SCRATCH within all detached processes.
*/
main( int argc, char **argv )
{
    static $DESCALLOC( prcnam );
    unsigned int pqlcnt = 0;
    $DESCALLOC( uicdsc );
    char *param;
    char prcbuf[16];
    ACCDEF2 accmsg;
    unsigned int pid;
    unsigned short chan;
    unsigned short term;
    unsigned int mbxunt;
    int dviitem;
    char buf[128], tmp[128];
    II_VMS_MASK_LONGWORD  efc_state;
    char	*log_start_commands;
    IOSB	iosb;
    ER_ARGUMENT dummy_arg;
    i4		i;
    STATUS status;
    i4          gcc = 0;
    i4          gcc_instance = 0;
    i4          gcb = 0;
    i4          gcb_instance = 0;
    i4          gcd = 0;
    i4          gcd_instance = 0;

	/*
	** setup the type and server_flavor parameters
	*/
    if ( argc >= 2 )
    {
	server_type = argv[1];

        /* Are we starting a GCB, GCC or GCD ? */

        if (STbcompare( server_type, 3, "gcc", 3, TRUE ) == 0) gcc++;
        if (STbcompare( server_type, 3, "gcb", 3, TRUE ) == 0) gcb++;
        if (STbcompare( server_type, 3, "gcd", 3, TRUE ) == 0) gcd++;
    }

    if ( argc >= 3 )
    {
	server_flavor = argv[2];

        /* Need to precede server_flavor with "-instance="
        ** if we're starting a GCB, GCC or GCD.
        */
        gcc_instance = gcc;
        gcb_instance = gcb;
        gcd_instance = gcd;
    }

	/*
	** initialize PM routines and setup the default
	** search parameters for config.dat
	*/
    status = PMinit( );
    if (status)
    {
	pmerr_func(status, 0, &dummy_arg);
	return (status);
    }

    switch( status = PMload((LOCATION *)NULL, pmerr_func) )
    {
	case OK:
	    /* Loaded sucessfully */
	    break;

	case PM_FILE_BAD:
	    /* syntax error */
	    if (status != FAIL)	/* As of Nov 1993, PM.H defines PM_FILE_BAD 1 */
		pmerr_func(status, (i4)0, &dummy_arg);
	    return (status);

	default: 
	    /* unable to open file */
	    if (status != FAIL)	/* FAIL is a useless status to report... */
		pmerr_func(status, (i4)0, &dummy_arg);
	    return (status);
    }

#ifdef EDBC
    PMsetDefault( 0, ERx( "ed" ) );
#else
    PMsetDefault( 0, ERx( "ii" ) );
#endif
    PMsetDefault( 1, PMhost( ) );
    PMsetDefault( 2, server_type );
    PMsetDefault( 3, server_flavor );

	/* read and process pm parameters
	 */
    for ( i = 0; pm_option[i].PM_name != NULL; i++ )
    {
	status = PMget( pm_option[i].PM_name, &param );
	if ( status != OK )
	    continue;

	switch ( pm_option[i].type )
	{
	    unsigned int *target;

	    case TYPE_CLRFLG:
		if ( STbcompare(param, 0, "off", 0, TRUE) != 0 &&
		     STbcompare(param, 0, "on", 0, TRUE)  != 0 )
		{
		    SIprintf("IIRUNDBMS: %s value must be ON or OFF\n",
				pm_option[i].PM_name);
		    SIflush(stdout);
		    log_errmsg( "Must be ON or OFF", SS$_BADPARAM, 1 );
		    return (SS$_BADPARAM);
		}

		target = (unsigned int *)pm_option[i].target;

		if ( STbcompare(param, 0, pm_option[i].keyword, 0, TRUE) == 0)
		     *target &= ~(int)pm_option[i].parameter;

		if ( msg_echo && (STscompare( pm_option[i].PM_name, 0, echo, 0 ) == 0) )
		     ERoptlog( pm_option[i].PM_name, param );

		break;

	    case TYPE_SETFLG:
		if ( STbcompare(param, 0, "off", 0, TRUE) != 0 &&
		     STbcompare(param, 0, "on", 0, TRUE)  != 0 )
		{
		    SIprintf("IIRUNDBMS: %s value must be ON or OFF\n",
				pm_option[i].PM_name);
		    SIflush(stdout);
		    log_errmsg( "Must be ON or OFF", SS$_BADPARAM, 1 );
		    return (SS$_BADPARAM);
		}

		target = (unsigned int *)pm_option[i].target;

		if ( STbcompare(param, 0, pm_option[i].keyword, 0, TRUE) == 0)
		     *target |= (int)pm_option[i].parameter;

		if ( msg_echo )
		     ERoptlog( pm_option[i].PM_name, param );

		break;

	    case TYPE_INT:
		target = (unsigned int *)pm_option[i].target;

		status = CVal( param, target );
		if (status)
		{
		    SIprintf("IIRUNDBMS: %s value must be an integer\n",
				pm_option[i].PM_name);
		    SIflush(stdout);
		    pmerr_func(status, 0, &dummy_arg);
		    return (SS$_BADPARAM);
		}

		if ( msg_echo )
		{
		    STprintf( buf, "%d", *target );
		    ERoptlog( pm_option[i].PM_name, buf );
		}

		break;

	    case TYPE_UIC:
	    {
		$DESCINIT( uicdsc, param );

		status = iics_cvtuic( &uicdsc, (char *)pm_option[i].target );

		if ( !(status & 1) )
		{
		    log_errmsg( "vms_uic invalid", status, 1 );
		    return (status);				/* B56811 */
		}

		if ( msg_echo )
		{
		    if ( *(unsigned int *)(pm_option[i].target) != 0 )
		    {
			STprintf( buf, "%s [%o,%o]", param,
				  ((uic >> 16) & 0xffff), (uic & 0xffff) );
			ERoptlog( pm_option[i].PM_name, buf );
		    }
		}

		break;
            }

	    case TYPE_STR:
		 if (STlength(param) > MAX_STRING_OPTION_LENGTH)
		 {
		    SIprintf("IIRUNDBMS: Max length for %s is %d\n",
				pm_option[i].PM_name, MAX_STRING_OPTION_LENGTH);
		    SIflush(stdout);
		    return (SS$_BADPARAM);
		 }

		 STcopy( param, (char *)pm_option[i].target );

		 if ( msg_echo )
		    ERoptlog( pm_option[i].PM_name, param );

	         break;

	    case TYPE_PQL:
		    /*
		    ** build VMS process quota block
		    */
		quota[pqlcnt].name = (char)pm_option[i].parameter;

		status = CVal( param, &quota[pqlcnt].value );
		if (status)
		{
		    SIprintf("IIRUNDBMS: %s value must be an integer\n",
				pm_option[i].PM_name);
		    SIflush(stdout);
		    pmerr_func(status, 0, &dummy_arg);
		    return (SS$_BADPARAM);
		}

		pqlcnt++;

		if ( msg_echo )
		    ERoptlog( pm_option[i].PM_name, param );

		break;

	    case TYPE_PRIV:
	    {
		char prvbuf[512];
		char *p, *q;
		i4 j;

		    /*
		    ** Remove white space then
		    ** convert the string to upper case, then 
		    ** remove leading and trailing parens
		    */
		if (STlength(param) >= sizeof(prvbuf))
		{
		    SIprintf("IIRUNDBMS: vms_privileges are too long\n");
		    SIprintf("    Actual length (%d) exceeds maximum (%d)\n",
				STlength(param), sizeof(prvbuf));
		    SIflush(stdout);
		    return (SS$_BADPARAM);
		}

		STcopy( param, prvbuf);
		STtrmwhite( prvbuf );
		CVupper( prvbuf );

		    /*
		    ** Scan the comma seperated privilege list and set the
		    ** privileges for each privileges keywork in the list.
		    */
		for ( p = prvbuf; p != 0 && *p != 0; p = q )
		{
		    if ( (q = STindex( p, ERx( "," ), 0 )) != NULL )
			*q++ = '\0';
		    else if ( (q = STindex( p, ERx( ")" ), 0 )) != NULL )
			*q++ = '\0';

		    if ( *p == '(' )
			p++;

		    for ( j = 0; prv_table[j].prv_name != NULL; j++ )
		    {
			if ( STscompare( p, 4, prv_table[j].prv_name, 4 ) == 0 )
			{
			    prvadr[0] |= prv_table[j].prv_code_low;
			    prvadr[1] |= prv_table[j].prv_code_hi;
			    if ( msg_echo )
				ERoptlog( pm_option[i].PM_name, prv_table[j].prv_name );
			    break;
			}
		    }
		    if (prv_table[j].prv_name == NULL)
		    {
			/*
			** We failed to find privilege "p" in our table
			*/
			SIprintf("IIRUNDBMS: Syntax error in privilege list\n");
			SIprintf("    Error near byte %d of string %s",
				    p - prvbuf, param);
			SIflush(stdout);
			ERoptlog("Unrecognized privilege:", p);
			return (SS$_BADPARAM);
		    }
		}

		break;
	    }

	    default:
		break;
	}
    }
Example #13
0
/*
** Name: makeutable - make unicode collation element table
**
** Descrription:
**	Reads input collation element text file and compiles a table.
**	also reads the Unicode character database and adds attributes for 
**	each character found. Currently we only take note of canonical
**	decomposition for normalization.
**
** Inputs:
**	desfile	- collation element description file
**
** Outputs:
**	None
**
** Returns:
**	utbl - collation element table
**
** History:
**	14-mar-2001 (stephenb)
**	    Created
**	5-apr-2001 (stephenb)
**	    Add code to read unciode character database.
**	17-may-2001 (stephenb)
**	    Read in combining class from character database.
**	24-dec-2001 (somsa01)
**	    Modified such that the varsize which is placed in the Unicode
**	    table is now a SIZE_TYPE rather than an i4.
**	12-dec-2001 (devjo01)
**	    Make sure 1st overflow entry is properly aligned.
**	    Add messages to report if files cannot be opened.
**	17-jul-2001 (gupsh01)
**	    Modified the placing of the decomposition enty to 
**	    decomp structure in the file, to be the first entry. 
**      04-Mar-2005 (hanje04)
**          Add support for reverse hybrid builds, i.e. 64bit exe needs to
**          call 32bit version.
**	17-May-2007 (gupsh01)
**	    Added support for reverse sorting of the accented characters.
**	    This is done to support @backwards tag in custom collation file. 
**	08-Aug-2007 (kiria01) b118917
**	    Detect lines relating to conditional special caseing and ignore them.
**	08-Aug-2007 (gupsh01)
**	    Fixed the typo for CASE_IGNORABLE setting. Also fixed the 
**	    handling of Final_Sigma in the special_casing.txt.
**	08-Aug-2007 (gupsh01)
**	    Fixed the decomposition mapping which were not being set for 
**	    composite characters.
**	24-Nov-2008 (gupsh01)
**	    When alloating the memory for recombination table make sure
**	    we initialize the buffer. 
*/
static	ADUUCETAB *
makeutable(
	   char		*desfile)
{
    char     		buf[MAX_UCOL_REC];
    FILE      		*fp;
    FILE		*dfp;
    LOCATION   		loc;
    char		table_vers[MAX_UVERS] = "";
    i4			lno = 0;
    char		*recptr;
    char		*separator;
    ADUUCETAB		*tab = &w.utab;
    i4			num_rvals = 0;
    ADUUCETAB		*epointer = (ADUUCETAB *)w.buff; /* entries first */
    /* then instructions */    
    char		*ipointer; 
    SIZE_TYPE		*varsize;
    char		*tptr;
    ADU_UCEFILE		*rrec = NULL;
    ADU_UCEFILE		*cerec = NULL;
    char		csval[7];
    char		svalue[21];
    char		*ceptr;
    char		*comment;
    u_i4		cval;
    i4			numce;
    bool		combent;
    i4			i;
    /* Stuff to track the size of the recomb_tbl entries */
    u_i2        	**recomb_def2d;
    u_i2        	*recomb_def1d;
    char        	*recombtbl;
    char        	*tracker;
    SIZE_TYPE		*recomb_tbl_size;
    i4          	tr = 0;
    i4          	j = 0;
    STATUS		stat;
    i4			rcbufsz;
    char		*tempbuf;
    i4			current_bytes;
    char		*upperval;
    char		*lowerval;
    char		*titleval;
    char		*endval;
    i4 			bts = 0;
    i4 			lcnt = 0;
    i4 			tcnt = 0;
    i4 			ucnt = 0;
    i4 			row = 0;
    i4 			col = 0;
    bool		backward_set = FALSE;

    /* open file */
    STcopy(desfile, buf);
    LOfroms(FILENAME, buf, &loc);
    if (SIopen(&loc, "r", &fp) != OK)
    {
	SIprintf("aducompile: Unable to open input file \"%s\".\n",
		 loc.string );
        return NULL;    
    }

    varsize = (SIZE_TYPE *)(w.buff + ENTRY_SIZE);
    recomb_tbl_size = (SIZE_TYPE *)(varsize + 1);
    ipointer = (char*)(recomb_tbl_size + 1);
    ipointer = ME_ALIGN_MACRO(ipointer, sizeof(PTR));

    /* this is a sparse table, make sure we initialize it */
    MEfill(INSTRUCTION_SIZE + ENTRY_SIZE, 0, w.buff);
    *varsize = 0;

    /* read data */
    while (SIgetrec(buf, sizeof(buf), fp) != ENDFILE)
    {
	lno++;
	if (buf[0] == '#')
	    /* comment line */
	    continue;
	(VOID)STtrmwhite(buf);
	if (STcompare(buf, "") == 0)
	    /* blank line */
	    continue;
	/* should first find version */
	if (table_vers[0] == EOS)
	{
	    if (STbcompare(buf, 8, "@version", 8, TRUE) == 0)
	    {
		/* we don't parse the version string, maybe we should */
		STlcopy(buf+9, table_vers, MAX_UVERS);
		continue;
	    }
	    else
	    {
		SIprintf("Syntax error on line %d, version line must be first \
non-comment line in the file, ignored\n", lno);
		continue;
	    }
	}
	/* then alternate weights (optional), currently un-supported */
	if (STbcompare(buf, 10, "@alternate", 10, TRUE) == 0)
	{
	    SIprintf("Syntax error on line %d, alternate weights are not \
currently supported, ignored\n", lno);
	    continue;
	}

	/* now backwards lines (also not currently supported) */
	if (STbcompare(buf, 10, "@backwards", 10, TRUE) == 0)
	{ 
    	    backward_set = TRUE;
	    continue;
	}

	/* and rearrange lines */
	if (STbcompare(buf, 10, "@rearrange", 10, TRUE) == 0)
	{
	    bool	strend = FALSE;
	    u_i4	rval;

	    for (recptr = buf + 10;;)
	    {
		/* skip blanks */
		if ((recptr = STskipblank(recptr, STlength(recptr))) == NULL)
		{
		    /* blank string, ignore */
		    SIprintf("Syntax error on line %d, no characters in \
rearrange list, ignoring\n", lno);
		    strend = TRUE;
		    break;
		}
		/* find next comma separator */
		if ((separator = STindex(recptr, ",", 0)) == NULL)
		{
		    strend = TRUE;
		    separator = recptr + 4;
		}
		if (separator - recptr != 4)
		{
		    SIprintf("Syntax error on line %d, characters in a rearrange\
line must be a comma separated list of 4 digit hex values, ABORTING\n", lno);
		    tab = NULL;
		    break;
		}