Example #1
0
/*{
** Name: CXnode_name_from_id	- Get node name given a machine ID
**
** Description:
**
**	This gets the node name given a machine ID.
**
** Inputs:
**      node_id		- Numeric identifier given to a machine
**			  (on VMS clusters, the CSID)
**
** Outputs:
**	node_name	- Ptr to buffer to fill in with nodename
**
**	Returns:
**		none
**		
**	Exceptions:
**	    none
**
** Side Effects:
**	    none.
**
** History:
**	21-feb-2008 (joea)
**	    Created.
*/
void
CXnode_name_from_id(u_i4 node_id, char *node_name)
{
    bool		found = FALSE;
#if defined(VMS)
    CX_NODE_CB		*sms = CX_Proc_CB.cx_ncb;
    CX_NODE_INFO	*pnode;
    i4			i;

    /* special case for the local node */
    if (node_id == sms->cxvms_csids[0])
    {
	STcopy(CXhost_name(), node_name);
	return;
    }
    for (i = 1; i < sizeof(sms->cxvms_csids); ++i)
    {
	if (node_id == sms->cxvms_csids[i])
	{
	    pnode = &CX_Proc_CB.cx_ni->cx_nodes[i - 1];
	    STcopy(pnode->cx_host_name, node_name);
	    found = TRUE;
	}
    }
#endif
    if (!found)
	STcopy("Unknown", node_name);
}
Example #2
0
static i4
line_get( char *prompt, 
	      char *def_line, i4  wild_flag, char *in_line ) 
{
	char    line[MAXLINE];
	char	ret = '\n';
	char	*p;
	i4	status = EOF;

	for(;;)
	{
		STATUS s;

		SIprintf(prompt);
		SIprintf( *def_line ? "(%s): " : ": ", def_line );

/* This is somewhat unusuall but does force the SIflush to work */
		SIflush(stdout);

	        s = ocfg_getrec( line, (i4)MAXLINE );

		if( s != OK || line[0] == '\033' )
			break;

		if (p = STindex(line, &ret, MAXLINE))
			*p = EOS;

		if( *def_line && !*line )
		{
			STcopy( def_line, in_line );
			SIprintf("\t\tDefault value: %s\n",in_line);
		}
		else
		{
			STcopy(line,in_line);
		}

	        STzapblank(in_line,in_line);

		if( !*in_line )
		{
			SIprintf("\t\tValue required, enter <ESC> to exit.\n");
			continue;
		}

		if(!STbcompare( in_line, 0, "*",0, TRUE ) )
		{
			if( !wild_flag )
			{
				SIprintf("\t\tValue required, enter <ESC> to exit.\n");
				continue;
			}
			in_line[0] = EOS;
		}

		status = OK;
		break;		/* There is valid data */
	}	/* end of FOR loop */
	return status;
}
Example #3
0
static VOID
seedToDigits(
    DB_TAB_ID	*seed,
    char	*digitString,
    QEF_RCB	*qef_rcb
)
{
    i4		leadingZeroes;
    i4		firstStringLength;
    i4		secondStringLength;
    char	firstString[ DIGITS_IN_I4 + 1 ];
    char	secondString[ DIGITS_IN_I4 + 1 ];

    CVlx( seed->db_tab_base, firstString );
    firstString[ DIGITS_IN_I4 ] = 0;	/* just in case */
    firstStringLength = STlength( firstString );

    CVlx( seed->db_tab_index, secondString );
    secondString[ DIGITS_IN_I4 ] = 0;	/* just in case */
    secondStringLength = STlength( secondString );

    leadingZeroes = DIGITS_IN_I4 - firstStringLength;
    STmove( "", '0', leadingZeroes, digitString );
    STcopy( firstString, &digitString[ leadingZeroes ] );

    leadingZeroes = DIGITS_IN_I4 - secondStringLength;
    STmove( "", '0', leadingZeroes, &digitString[ DIGITS_IN_I4 ] );
    STcopy( secondString, &digitString[ DIGITS_IN_I4 + leadingZeroes ] );
}
Example #4
0
STATUS
SIeqinit()
{
# if defined (UNIX) || defined (NT_GENERIC)
	
	/* Just verify the environment is normal */
	if (!SIisopen(stdin))
	    return(INCHAN_ERR);
	if (!SIisopen(stdout))
	    return(OUTCHAN_ERR);
	if (!SIisopen(stderr))
	    return(ERRCHAN_ERR);
	return(OK);

# endif
# ifdef VMS
	LOCATION		loc;
	FILE			*fp;
	char			buf[MAX_LOC +1];
	/*
	** If stdin cannot be opened, attempt to open stdout, stderr for
	** possible error messages.
	*/
	STATUS			in_status, out_status, err_status;

	if (SIisopen(stdin))
		return (OK);

	STcopy("SYS$INPUT", buf);
	LOfroms(PATH & FILENAME, buf, &loc);
	in_status = SIopen(&loc, "r", &fp);

	STcopy("SYS$OUTPUT", buf);
	LOfroms(PATH & FILENAME, buf, &loc);
	out_status = SIopen(&loc, "w", &fp);

	STcopy("SYS$ERROR", buf);
	LOfroms(PATH & FILENAME, buf, &loc);
	err_status = SIopen(&loc, "w", &fp);

	if (in_status != OK){
		if (in_status == iicl__siopen)
			return(INCHAN_ERR);
		else
			return (in_status);
	}
	if (out_status != OK){
		if (out_status == iicl__siopen)
			return(OUTCHAN_ERR);
		else
			return (out_status);
	}
	if (err_status == iicl__siopen)
		return(ERRCHAN_ERR);
	else
		return (err_status);		/* OK or a real status */
# endif
}
Example #5
0
bool
ask_for_conditional(WINDOW *askW,char edCAns)
{
    char                   cond_exp ;

    cond_exp  = EOS;
    if (conditional_str == NULL)
	conditional_str = SEP_MEalloc(SEP_ME_TAG_NODEL, TEST_LINE+1, TRUE,
				      (STATUS *) NULL);
    if (conditional_old == NULL)
	conditional_old = SEP_MEalloc(SEP_ME_TAG_NODEL, TEST_LINE+1, TRUE,
				      (STATUS *) NULL);
    if (conditional_prompt == NULL)
	conditional_prompt = SEP_MEalloc(SEP_ME_TAG_NODEL, TEST_LINE+1, TRUE,
					 (STATUS *) NULL);

    if ((*conditional_str == EOS) && (SEP_IF_EXPRESSION != NULL) &&
        (*SEP_IF_EXPRESSION != EOS))
	STcopy(SEP_IF_EXPRESSION, conditional_str);

    STcopy(conditional_str, conditional_old);
#ifdef NT_GENERIC
    STprintf(conditional_prompt,ERx(" IF (%s) >"),conditional_str);
#else
    STprintf(conditional_prompt,ERx("%s%s%s%s%s IF (%s) >%s"),REG_CHAR,
	     ATTR_OFF, PROMPT_POS, DEL_EOL, REV_VIDEO, conditional_str,
	     ATTR_OFF);
#endif

    if (edCAns == EOS)
	get_string(askW, conditional_prompt, conditional_str);

    if ((conditional_str == NULL) || (*conditional_str == EOS))
    {
	if (*conditional_old == EOS)
	{
	    if (edCAns == EOS)
		put_message(askW,
			    ERx("No conditional expression for this Canon."));
	    return (FALSE);
	}
	else
	{
	    STcopy(conditional_old, conditional_str);
	}
    }
    else if (STskipblank(conditional_str, STlength(conditional_str)) == NULL)
    {
	*conditional_str = EOS;
	*conditional_old = EOS;
	if (edCAns == EOS)
	    put_message(askW, ERx("No conditional expression for this Canon."));
	return (FALSE);
    }

    STpolycat(3, ERx(" IF ("), conditional_str, ERx(") "), conditional_prompt);
    return (TRUE);
}
Example #6
0
char *
xfaddpath(char *filename, i4  in_or_out)
{
    auto char	*wholename;

    if (filename == NULL)
    {
	wholename = NULL;
    }
    else if (in_or_out == XF_INTOFILE && Xf_into_path != NULL)
    {
	STcopy(Xf_into_path, Whole_name);

# ifdef UNIX
	if (Whole_name[STlength(Whole_name)-1] != '/')
	    STcat(Whole_name, ERx("/"));
# else 
# ifdef DESKTOP
	if (Whole_name[STlength(Whole_name)] != '\\')
	    STcat(Whole_name, ERx("\\"));
# endif /* DESKTOP */
# endif

	wholename = STcat(Whole_name, filename);
    }
    else if (in_or_out == XF_FROMFILE && Xf_from_path != NULL)
    {
	STcopy(Xf_from_path, Whole_name);

# ifdef UNIX
	if (Whole_name[STlength(Whole_name)-1] != '/') 
	    STcat(Whole_name, ERx("/"));
# else
# ifdef DESKTOP
	if (Whole_name[STlength(Whole_name)] != '\\')
	    STcat(Whole_name, ERx("\\"));
# endif /* DESKTOP */
# endif
	wholename = STcat(Whole_name, filename);
    }
    else
    {
	LOcopy(&Xf_dir, Tmppath_buf, &Tmppath);

	/* add the file name to location */
	LOfstfile(filename, &Tmppath);

	LOtos(&Tmppath, &wholename);
    }
# ifdef NT_GENERIC
    xlate_backslash(wholename);
# endif /* NT_GENERIC */
    return (wholename);
}
Example #7
0
static bool
checkArgs (char *arg, i4 argc, char **argv, char *altPath, 
    char * drvMgr)
{
    i4 i;
    
    for ( i = 1; i < argc; i++ )
    {
        if ( !STbcompare( arg, 0, argv[i], 0, TRUE ) && 
             !STbcompare( arg, 0, "-p", 0, TRUE ) && i < (argc - 1) )
        {
	    i++;
            STcopy( argv[i], altPath );
            return TRUE; 
        }
        if ( !STbcompare( arg, 0, argv[i], 0, TRUE ) && 
             !STbcompare( arg, 0, "-m", 0, TRUE ) && i < (argc - 1) )
        {
	    i++;
            if ( !STbcompare( MGR_STR_UNIX_ODBC, 0, argv[i], 0, TRUE ) )
            {				  
                STcopy( argv[i], drvMgr );
                return TRUE; 
            }
            else if ( !STbcompare( MGR_STR_CAI_PT, 0, argv[i], 0, TRUE ) )
            {				  
                STcopy( argv[i], drvMgr );
                return TRUE; 
            }
            else
            {
                display_help();
		PCexit(FAIL);
            }
        }
        if ( !STbcompare( arg, 0, argv[i], 0, TRUE ) &&
            !STbcompare ( arg, 0, "-r", 0, TRUE ) )
            return TRUE;
        if ( !STbcompare( arg, 0, argv[i], 0, TRUE ) &&
            !STbcompare ( arg, 0, "-rmpkg", 0, TRUE ) )
            return TRUE;
        if ( !STbcompare( arg, 0, argv[i], 0, TRUE ) &&
            !STbcompare ( arg, 0, "-batch", 0, TRUE ) )
            return TRUE;
        if ( !STbcompare( arg, 0, argv[i], 0, TRUE ) &&
            !STbcompare ( arg, 0, "-h", 0, TRUE ) )
            return TRUE;
        if ( !STbcompare( arg, 0, argv[i], 0, TRUE ) &&
            !STbcompare ( arg, 0, "-help", 0, TRUE ) )
            return TRUE;
    }
    return FALSE;
}
Example #8
0
VOID
save_em()
{
	/* start of routine */

	STcopy(Ctype,type);
	sequence = Csequence;
	STcopy(Csection,section);
	STcopy(Cattid,attid);
	STcopy(Ctext,text);

	return;
}
Example #9
0
VOID
get_em()
{
	/* start of routine */

	STcopy(type,Ctype);
	Csequence = sequence;
	STcopy(section,Csection);
	STcopy(attid,Cattid);
	STcopy(text,Ctext);

	return;
}
Example #10
0
/*{
** Name:	open_outfile	- creates or appends to an output file
**
** Description:
**	Creates or opens (for append) a file in a directory and sets a
**	LOCATION structure.
**
** Inputs:
**	out_filename	- output file name
**	out_dir		- output directory
**	create_or_append - create a new file or append to existing file
**	uniq		- make a unique filename
**
** Outputs:
**	loc_name	- output file path
**
** Returns:
**	NULL	- open failed
**	FILE *	- file pointer
*/
FILE *
open_outfile(
char	*out_filename,
char	*out_dir,
char	*create_or_append,
char	*loc_name,
bool	uniq)
{
	FILE	*out_file;
	char	*p;
	char	filename[MAX_LOC+1];
	LOCATION	loc;

	if (loc_name == NULL)
		return (NULL);

	if (CMcmpcase(create_or_append, ERx("c")) == 0)
	{
		STcopy(out_dir, filename);
		LOfroms(PATH, filename, &loc);

		/* if uniq is 1, create a unique filename */
		if (uniq == 1)
			LOuniq(out_filename, ERx(""), &loc);
		else
			LOfstfile(out_filename, &loc);

		if (SIfopen(&loc, ERx("w"), SI_TXT, SI_MAX_TXT_REC, &out_file)
			!= OK)
		{
			IIUGerr(E_RM00F2_Err_open_outfile, UG_ERR_ERROR, 1,
				out_filename);
			return (NULL);
		}
		LOtos(&loc, &p);
		STcopy(p, loc_name);
	}
	else
	{
		LOfroms(PATH & FILENAME, loc_name, &loc);
		if (SIfopen(&loc, ERx("a"), SI_TXT, SI_MAX_TXT_REC, &out_file)
			!= OK)
		{
			IIUGerr(E_RM00F2_Err_open_outfile, UG_ERR_ERROR, 1,
				out_filename);
			return (NULL);
		}
	}
	return (out_file);
}
Example #11
0
/*
** Name: WTSOpenUpLoad() -
**
** Description:
**
** Inputs:
**      contentType
**      session
**
** Outputs:
**
** Returns:
**	GSTATUS	:	GSTAT_OK
**
** Exceptions:
**	None
**
** Side Effects:
**	None
**
** History:
*/
GSTATUS
WTSOpenUpLoad(
    char        *contentType,
    WTS_SESSION *session)
{
    GSTATUS     err;
    i4          length = STlength(MULTIPART);
    PWTS_UPLOAD load = NULL;
    char*       bound;
    i4          blen;

    if (contentType != NULL &&
        STscompare(contentType, length, MULTIPART, length) == 0)
    {
        session->status = UPLOAD;
        if ((err = GAlloc ((char**)&load, sizeof(WTS_UPLOAD),
            FALSE)) == GSTAT_OK)
        {
            session->load = load;
            bound = STindex (contentType, BOUNDARY, 0) + STlength(BOUNDARY);
            blen  = STlength (bound);

            /*
            ** Allocate space for a start boundary and and en boundary
            ** each having the delimiters and null terminator.
            */
            if (((err = GAlloc (&load->start, blen + 3, FALSE)) == GSTAT_OK) &&
                ((err = GAlloc (&load->end, blen + 5, FALSE)) == GSTAT_OK))
            {
                STcopy ("--",load->start);
                STlcopy (bound, load->start + 2, blen);
                STcopy (load->start, load->end);
                STcat (load->end, "--");
            }
            load->state = US_BEGIN;
        }
    }
    else
    {
        session->status = NO_UPLOAD;
        session->load   = NULL;
    }
    session->list = NULL;
    session->variable = NULL;
    session->vlen = 0;

    return(GSTAT_OK);
}
Example #12
0
newdirec()
{
	register char	*direc;
	FUNC_EXTERN char	*getfilenm();
	LOCATION	loc;
	char		locbuf[MAX_LOC+1];
	i4		status;
	char		errbuf[ER_MAX_LEN];

	direc = getfilenm();
	/* if the directory is not specified, don't do anything. */
	if (!*direc)
		return;
	STcopy(direc, locbuf);
	if (status = LOfroms(PATH, locbuf, &loc))
	{
		ERreport(status, errbuf);
		putprintf(ERget(F_MO0027_Error_in_path_name), errbuf);
		return;
	}
	if (status = LOchange(&loc))
	{
		ERreport(status, errbuf);
		putprintf(ERget(F_MO0028_Cannot_change_dir), direc, errbuf);
	}
}
Example #13
0
STATUS
MOlongout( STATUS errstat, i8 val, i4  destlen, char *dest )
{
    char bufa[ MO_MAX_NUM_BUF ];
    char bufb[ MO_MAX_NUM_BUF ];
    char *p;
    char *q;
    i4  padlen;
    
    bufa[0] = EOS;

    /* Ignore errors in CVla8 -- force to 0 */
    (void)CVla8( val, bufa );
    padlen = MAX_I8_DIGITS_AND_SIGN - (i4)STlength( bufa );

    p = bufb;
    q = bufa;
    /* put sign first, before pad */
    if( bufa[0] == '-' )
	*p++ = *q++;
    while( padlen-- > 0 )
	*p++ = '0';
    STcopy( q, p );
	
    return( MOstrout( errstat, bufb, destlen, dest ) );
}
Example #14
0
/* ---------------------------------------------------------------------------
**  SAXImportHandlers: Constructors and Destructor
** ---------------------------------------------------------------------------
*/
SAXImportHandlers::SAXImportHandlers( const   char* const encodingName, 
				 const 	XMLFormatter::UnRepFlags unRepFlags, 
				 char 	*currentTagName) :

    fFormatter
    (
        encodingName, 0
        , this
        , XMLFormatter::NoEscapes
        , unRepFlags
    )
{
    /*
    **  Go ahead and output an XML Decl with our known encoding. This
    **  is not the best answer, but its the best we can do until we
    **  have SAX2 support.
    */

    /* initialize the tablist and the indlist and xmlData */
    tablist = NULL;
    indlist = NULL;
    xmlData = NULL;	
    isMetaInfoSet = FALSE;	
    dataval = (char *)MEreqmem(0, DB_MAXSTRING + 32, TRUE, NULL);

    if (currentTagName)
    STcopy(currentTagName, currentTag);

}
Example #15
0
/*
** Name: GetMSroot
**
** Description:
**      Display the home HTML directory for MS IIS
**
** Inputs:
**      conf        pointer to the MS config structure.
**      regkey      generated registry key.
**
** Outputs:
**      docpath     contains the HTML root path
**
** Returns:
**      none
**
** History:
**      09-Oct-98 (fanra01)
**          Created.
**      20-Nov-1998 (fanra01)
**          Add docpath.
**      24-Mar-1999 (fanra01)
**          Store error return from RegQueryValueEx and retry on not found
**          or not exist errors.
*/
STATUS
GetMSroot (PW3CONF conf, char* regkey, char** docpath)
{
    STATUS  status = FAIL;
    i4      i =0;
    DWORD   dwstat = 0;
    char    val[10];
    HKEY    key;
    char    regval[256];
    DWORD   valtype;
    DWORD   valsize = sizeof(regval);


    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey, 0, KEY_QUERY_VALUE,
        &key) == ERROR_SUCCESS)
    {
        /*
        ** Need this loop as microsoft annoyingly adds a comma to the key name
        ** when any HTTP paths have been updated.
        */
        for (i = 0; i < 2; i++)
        {
            STcopy (httpsrv[enumwebsrv].val, val);
            if (i == 1) STcat (val, ",");
            if ((dwstat = RegQueryValueEx (key, val, NULL,
                &valtype, regval, &valsize)) == ERROR_SUCCESS)
            {
                char* p;

                if ((p = STindex (regval, ",", 0)) != NULL)
                    *p = EOS;
                *docpath = STalloc (regval);
                status = OK;
            }
            else
            {
                switch (dwstat)
                {
                    case ERROR_FILE_NOT_FOUND:
                    case ERROR_CLASS_DOES_NOT_EXIST:
                    case ERROR_ENVVAR_NOT_FOUND:
                        /*
                        ** Can't find? Try again with a comma
                        */
                        break;
                    default:
                        SIprintf ("Error : %d Retrieving value %s. Info %d\n",
                            dwstat, val, GetLastError());
                        i = 2; /* terminate loop */
                        break;
                }
            }
        }
    }
    else
    {
        DISPERROR(errflg)("Error : No Microsoft servers found\n");
    }
    return (status);
}
Example #16
0
/*
** Name: apiprompt_func		For prompt Messages
**
** Description:
** 	Prompt callback function
**
** History:
**      03-Feb-99 (rajus01)
**          Created.
*/
static II_VOID 
apiprompt_func( IIAPI_PROMPTPARM *promptParm )
{

    SIfprintf( outputf, "\t===== Prompt Message =====\n" );

    STcopy(password, promptParm->pd_reply);
    promptParm->pd_rep_len = STlength( promptParm->pd_reply );
    promptParm->pd_rep_flags = 0;

    if ( verboseLevel > 1 )
    {
        SIfprintf( outputf, "\tpd_envHandle\t= 0x%lx\n",
					promptParm->pd_envHandle ); 
        SIfprintf( outputf, "\tpd_connHandle\t= 0x%lx\n",
					promptParm->pd_connHandle ); 
    }
    
    if( promptParm->pd_flags & IIAPI_PR_NOECHO )
 	SIfprintf( outputf, "\tpd_flags\t= IIAPI_PR_NOECHO \n" );
    if( promptParm->pd_flags & IIAPI_PR_TIMEOUT )
    {
 	SIfprintf( outputf, "\tpd_flags\t= IIAPI_PR_TIMEOUT \n" );
 	SIfprintf( outputf, "\tpd_timeout\t= %d\n", promptParm->pd_timeout );
    }

    SIfprintf( outputf, "\tpd_msg_len\t= %d\n", promptParm->pd_msg_len );
    SIfprintf( outputf, "\tpd_message\t= %s\n", promptParm->pd_message );
    SIfprintf( outputf, "\tpd_max_reply\t= %d\n", promptParm->pd_max_reply );

    SIfprintf( outputf, "\t=========================\n" );

    return;   
}
Example #17
0
void
scs_scan_scbs( SCS_SCAN_FUNC *func, PTR arg )
{
    char classbuf[ 80 ];
    char instbuf[ 80 ];
    char valbuf[ 80 ];
    i4	lval;
    PTR	ptr;
    SCD_SCB *scb;
    i4	operms;
    
    instbuf[0] = EOS;
    STcopy( "exp.scf.scs.scb_ptr", classbuf );
    for( lval = sizeof(valbuf);
	OK == MOgetnext( ~0, sizeof(classbuf), sizeof(instbuf),
			classbuf, instbuf, &lval, valbuf, &operms ) &&
	STequal( "exp.scf.scs.scb_ptr", classbuf );
	lval = sizeof(valbuf) )
    {
	CVaptr( instbuf, &ptr );
	scb = (SCD_SCB *)ptr;
	if( OK != (*func)( scb, arg ) )
	    break;
    }
}
Example #18
0
void
main(int argc, char *argv[])
{
    char	buf[256];
    char	*bufptr = (char *)buf;
    int		iarg;

    /*
    ** Put the program name and its parameters in the buffer.
    */
    STcopy("ntrcpst", bufptr);
    for (iarg = 1; iarg<argc; iarg++)
    {
	STcat(bufptr, " ");
	STcat(bufptr, argv[iarg]);
    }

    /*
    ** Execute the command.
    */
    if( PCexec_suid(&buf) != OK )
	PCexit(FAIL);

    PCexit(OK);
}
Example #19
0
/*{
** Name: CS_destroy_serv_segment() - Destroy the server segment.
**
** Description:
**      Destroy the server shared memory segment.  This should be called when
**      server is shut down (ie. should be put into the last chance exception
**      handler of CS).
**
**      Eventually the abnormal exit code must take care of cleaning up this
**      shared memory segment.
**
**      This call is internal to CS is meant only to be called by CS, and may
**      only exist on unix systems supporting shared memory.
**
** Inputs:
**      id                              id of server segment.
**
** Outputs:
**      address                         on success, set to point to segment
**      err_code                        system dependent error information.
**
**      Returns:
**          E_DB_OK
**
**      Exceptions:
**          none
**
** Side Effects:
**          none
**
** History:
**      08-sep-88 (mmm)
**          First Version
**      12-jun-89 (rogerk)
**          Changed MEsmdestroy to take character memory key, not LOCATION ptr.
*/
STATUS
CS_destroy_serv_segment(u_i4 serv_seg_num, CL_ERR_DESC *err_code)
{
    STATUS      status = OK;
    char        segname[48];

    STcopy("server.", segname);
    CVna((i4)serv_seg_num, segname+STlength(segname));

#ifdef xCL_NEED_SEM_CLEANUP
        CS_cp_sem_cleanup(segname,err_code);
#endif
    status = MEsmdestroy(segname, err_code);
    if (status)
    {
        /* Unable to attach allocated shared memory segment. */
        status = FAIL;
    }

    Cs_sm_cb->css_servinfo[serv_seg_num].csi_in_use = FALSE;

    /* FIX ME - probably add code to update system control stuctures to
    ** keep track of when a shared memory segment is mapped.
    */

    return(status);
}
Example #20
0
i4
gcu_words( char *buff, char *dest, char **words, i4  delim, i4  size )
{
    char **pv = words;

    if ( ! buff  ||  ! *buff )  return( 0 );

    if ( dest )
    {
	STcopy( buff, dest );
	buff = dest;
    }

    while( size-- )
    {
	*pv++ = buff;

	while( *buff != delim )
	    if ( ! *buff++ )  return( (i4)(pv - words) );

	*buff++ = 0;
    }

    return( (i4)(pv - words) );
}
Example #21
0
/*{
** Name:	open_infile	- open a template file
**
** Description:
**	Opens a template file from a directory.
**
** Inputs:
**	directory		- template directory
**	template_filename	- input template file name
**
** Outputs:
**	none
**
** Returns:
**	NULL	- open failed
**	FILE *	- file pointer
*/
FILE *
open_infile(
char	*directory,
char	*template_filename)
{
	FILE	*in_file;
	char	*p;
	char	filename[MAX_LOC+1];
	LOCATION	loc;

	if (template_filename == NULL || *template_filename == EOS)
	{
		IIUGerr(E_RM00EE_Null_empty_arg, UG_ERR_ERROR, 1,
			ERx("open_infile"));
		return (NULL);
	}

	STcopy(directory, filename);
	LOfroms(PATH, filename, &loc);
	LOfstfile(template_filename, &loc);
	if (SIfopen(&loc, ERx("r"), SI_TXT, SI_MAX_TXT_REC, &in_file) != OK)
	{
		LOtos(&loc, &p);
		IIUGerr(E_RM00F1_Err_open_template, UG_ERR_ERROR, 1, p);
		return (NULL);
	}

	return (in_file);
}
Example #22
0
void
yyinit( void )
{
	char *name, *value, *map_path;

	/* zero the line counter */
	yylineno = 0;

	if( rulemap_path == NULL )
	{
		NMloc( FILES, FILENAME, ERx( "default.rfm" ), &loc );
		LOcopy( &loc, file_name, &loc );	
		LOtos( &loc, &map_path );
	}
	else
	{
		STcopy( rulemap_path, file_name );
		LOfroms( FILENAME, file_name, &loc );
		map_path = rulemap_path;
	}

	(void) PMmInit( &rulemap );
	if( PMmLoad( rulemap, &loc, PMerror ) != OK )
		PCexit( FAIL );

	/* initiate scan of rule map */
	if( PMmScan( rulemap, ERx( ".*" ), &rfm_scan, NULL, &name, &value )
		!= OK )
	{
		F_ERROR( "Rule file map %s is empty.", map_path );
	}

	/* set up LOCATION of first rule file */
	STcopy( value, file_name );
	NMloc( FILES, FILENAME, file_name, &loc );
	LOcopy( &loc, file_name, &loc );	

	/* initialize input pointer */
	yyp = &dummy;

	/* open rule file */
	if( SIfopen( &loc, ERx( "r" ), SI_TXT, SI_MAX_TXT_REC, &yyin )
		!= OK && yywrap() )
	{
		ERROR( "No configuration rule files were found." );
	}
}
Example #23
0
DB_STATUS
qel_c5_ldbid_long(
QEF_RCB		    *v_qer_p,
QEC_LINK	    *v_lnk_p )
{
    DB_STATUS	    status;
    QES_DDB_SES	    *dds_p = & v_qer_p->qef_cb->qef_c2_ddb_ses;
    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;

    QEQ_1CAN_QRY    *sel_p = v_lnk_p->qec_6_select_p;
    QEC_D5_LONG_LDBNAMES
		    *long_p = v_lnk_p->qec_8_longnames_p;


    /* 1.  set up for accessing IIDD_DDB_LDB_LONGNAMES */

    sel_p->qeq_c3_ptr_u.d5_long_ldbnames_p = long_p; 
    sel_p->qeq_c4_ldb_p = cdb_p;
    sel_p->qeq_c5_eod_b = FALSE;
    sel_p->qeq_c6_col_cnt = 0;

    qed_u0_trimtail(
	ldb_p->dd_l3_ldb_name,
	(u_i4) DD_256_MAXDBNAME,
	long_p->d5_1_ldb_name);

    /* 3.  retrieve the LDB's 32-char alias if it exists */

    sel_p->qeq_c1_can_id = SEL_014_DD_DDB_LONG_LDBNAMES;

    status = qel_s4_prepare(v_qer_p, v_lnk_p);
    if (status)
	return(status);

    if (! sel_p->qeq_c5_eod_b)	    
    {
	/* no data */
    
	status = qel_s3_flush(v_qer_p, v_lnk_p);
	if (status) 
	    return(status);

	/* generate alias */

	STcopy(IIQE_30_alias_prefix, v_lnk_p->qec_5_ldb_alias);   /* prefix */
	CVla(v_lnk_p->qec_2_tableinfo_p->d9_1_obj_id.db_tab_base,
	     &v_lnk_p->qec_5_ldb_alias[QEK_5_SIZE_OF_PREFIX]);

	return(E_DB_OK);
    }

    /* 4.  send SELECT query to retrieve ldb id if it exists */

    status = qel_c4_ldbid_short(TRUE, v_qer_p, v_lnk_p);
						/* TRUE for using alias */
    return(status);
}
Example #24
0
static char *
er_decode( STATUS msg_id )
{
    STATUS old_err;
    STATUS errstat;
    CL_ERR_DESC err_code;
    i4  ret_len;
    char lbuf[ sizeof(ERbuf) ];

    if( msg_id == OK )
    {
	errstat = OK;
	STcopy( "OK", ERbuf );
    }
    else if ((errstat = ERslookup(msg_id,		/* msg num */
			    NULL,		/* input cl err */
			    0,			/* flags */
			    (char *) NULL,	/* sqlstate */
			    ERbuf,		/* buf */
			    sizeof(ERbuf),	/* sizeof buf */
			    -1,			/* language */
			    &ret_len,		/* msg len */
			    &err_code,		/* output err */
			    0,			/* num params */
			    NULL)		/* params */
	 ) != OK)
    {
	/* Recurse to decode ER error.  If we were processing error
	   already, give up to halt recursion */

	old_err = ERstat;	/* OK first time in */
	ERstat = errstat;	/* now not OK second time through */

	if( old_err == OK )
	    STcopy( lbuf, er_decode( errstat ) );
	else
	    STprintf(ERbuf, "ER err 0x%x", errstat );

	STprintf( ERbuf, "0x%x not found: %s", msg_id, lbuf ); 
    }

    /* Clear recursion check */
    ERstat = OK;

    return( ERbuf );
}
Example #25
0
/*{
** Name: CXset_context	- Set the CX node "context".
**
** Description:
**
**	If configured for clusters, the CX "context" determines
**	what node the calling utility is bound to.   That is,
**	what directory is used when mapping shared segments, how
**	file names are "decorated", and It determines the default
**	PM hostname, and if running NUMA clusters, the host name
**	override.
**
** Inputs:
**	host	- Node name or host name for the context.
**		  If NULL, value from PHhost is used.
**	rad	- If running NUMA clusters, 1st argument must be the host
**		  name, (or NULL), and a node name is constructed from
**		  the hostname(PMhost)/rad pair as "R<radid>_<hostname>"
**		  If not running NUMA clusters, this must be zero.
**
** Outputs:
**	none.
**
**	Returns:
**		OK				- Context was set.
**		E_CL2C2F_CX_E_BADRAD		- Rad value out of range.
**		E_CL2C42_CX_E_NOT_CONFIGURED	- Node or RAD not configured
**						  as part of the cluster.
**		
**	Exceptions:
**	    none
**
** Side Effects:
**	    Important & plentyful, see description.
**
** History:
**	16-sep-2002 (devjo01)
**	    Created.
*/
STATUS
CXset_context( char * host, i4 rad )
{
#   define HOST_PM_IDX	 1

    STATUS		 status = OK;
    CX_NODE_INFO        *pni;
    char		 namebuf[ CX_MAX_NODE_NAME_LEN + 1 ];

    do
    {
	if ( !host )
	{
	    host = CXhost_name();
	}

	if ( CXcluster_configured() )
	{
	    pni = CXnode_info( host, rad );
	    if ( NULL == pni )
	    {
		status = E_CL2C42_CX_E_NOT_CONFIGURED;
		break;
	    }

	    namebuf[CX_MAX_NODE_NAME_LEN] = '\0';
	    STlcopy( pni->cx_node_name, namebuf, CX_MAX_NODE_NAME_LEN );
	    CVlower( namebuf );
	    STcopy(namebuf, cx_saved_node_name);

	    if ( pni->cx_host_name_l &&
		 ( pni->cx_host_name_l != pni->cx_node_name_l ||
		   0 != STxcompare( pni->cx_node_name, pni->cx_node_name_l,
				    pni->cx_host_name, pni->cx_host_name_l,
				    TRUE, FALSE ) ) )
	    {
		STlcopy( pni->cx_host_name, namebuf, CX_MAX_NODE_NAME_LEN );
		CVlower( namebuf );
		PMsetDefault( HOST_PM_IDX, namebuf );
	    }
	    else
	    {
		PMsetDefault( HOST_PM_IDX, namebuf );
	    }
	    if ( 0 != pni->cx_rad_id )
		CX_Proc_CB.cx_numa_user_rad = pni->cx_rad_id;
	    CX_Proc_CB.cx_numa_cluster_rad = pni->cx_rad_id;
	}
	else
	{
	    PMsetDefault( HOST_PM_IDX, host );
	    if ( 0 != rad )
		CX_Proc_CB.cx_numa_user_rad = rad;
	}
    } while (0);
    return status;
} /* CXset_context */
Example #26
0
/*{
** Name:	RSblob_gcCallback - IIapi_getColumns callback for blobs
**
** Description:
**	If the blob is smaller than DB_MAXTUP-2 bytes, set the blob size and
**	return.  Otherwise, open a temporary file in II_TEMPORARY and write the
**	blob segments to it.
**
** Inputs:
**	closure		- closure (unused)
**	parmBlock	- IIAPI_GETCOLPARM parameter block
**
** Outputs:
**	RS_BLOB buffer is updated.
**
** Returns:
**	none
*/
II_VOID II_FAR II_CALLBACK
RSblob_gcCallback(
II_PTR	closure,
II_PTR	parmBlock)
{
	IIAPI_GETCOLPARM	*gcolParm = (IIAPI_GETCOLPARM *)parmBlock;
	RS_BLOB			*blob =
				(RS_BLOB *)gcolParm->gc_columnData[0].dv_value;
	LOCATION		loc;
	char			*p;
	i4			cnt;

	if (!blob->fp && !blob->size)
	{
		/*
		** If this is the only segment, just set the size from the
		** length.
		*/
		if (!gcolParm->gc_moreSegments)
		{
			blob->size = blob->len;
			return;
		}
		/*
		** If there are more segments and the file hasn't been opened,
		** create a new temporary file.
		*/
		NMloc(TEMP, PATH, NULL, &loc);
		LOuniq(ERx("bl"), ERx("tmp"), &loc);
		LOtos(&loc, &p);
		STcopy(p, blob->filename);
		if (SIfopen(&loc, ERx("w"), SI_VAR, sizeof blob->buf, &blob->fp)
			!= OK)
		{
			gcolParm->gc_genParm.gp_status = IIAPI_ST_OUT_OF_MEMORY;
			return;
		}
	}
	/* write the current segment to a file and add to the size */
	if (SIwrite((i4)blob->len, blob->buf, &cnt, blob->fp) != OK)
	{
		gcolParm->gc_genParm.gp_status = IIAPI_ST_OUT_OF_MEMORY;
		return;
	}
	blob->size += blob->len;
	/* if this is the last segment, close the temporary file */
	if (!gcolParm->gc_moreSegments)
	{
		if (SIclose(blob->fp) != OK)
		{
			gcolParm->gc_genParm.gp_status = IIAPI_ST_OUT_OF_MEMORY;
			return;
		}
		blob->fp = NULL;
	}
}
Example #27
0
/*
** Name: sc0a_qrytext_param(), write query text parameters in one or more 
**	segments to the audit log.
**
** Description:
**	This routine is an interface to SXF to write audit records
**	from SCF. 
**
** Inputs:
**	scb		SCB
**
**	name		Name of data
**
**	name_len	Length of data
**
**	qrydata		query data to be audited
**
** Outputs:
**	Returns:
**	    E_DB_OK
**	    E_DB_ERROR
**	Exceptions:
**	    none
**
** Side Effects:
**	    none
**
** History:
**	6-jul-93 (robf)
**	     Created.
**	30-dec-93 (robf)
**           Add support for LONG BIT, and include name length in
**	     size calculation.
**	22-mar-94 (robf)
**           Some formats may include extra trim, so allow for this
**	     in the formatting. 
*/
DB_STATUS
sc0a_qrytext_param(
	SCD_SCB *scb,
	char	*name,
	i4	name_len,
	DB_DATA_VALUE *qrydata
)
{
	DB_STATUS  status=E_DB_OK;
	char	   qrytext[256];
	i4	   bdt;
	
	if (!(Sc_main_cb->sc_capabilities & SC_C_C2SECURE))
	{
		/*
		**	This is not a C2 server so can just return
		*/
		return E_DB_OK;
	}
	if (!(scb->scb_sscb.sscb_facility & (1 << DB_SXF_ID)))
	{
		/*
		**	SXF not initialized yet so quietly return,
		*/
		return E_DB_OK;
	}
	if (!(scb->scb_sscb.sscb_ics.ics_rustat&DU_UAUDIT_QRYTEXT))
	{
		/*
		** Session doesn't have query text auditing so don't audit
		*/
		return E_DB_OK;
	}

	/* Format data as name:value */
	status=sc0a_qrytext(scb, name, name_len, SC0A_QT_NEWREC);
	status=sc0a_qrytext(scb, ":", 1, SC0A_QT_MORE);

	bdt=abs(qrydata->db_datatype); /* Allow for nullable types */

	if(bdt==DB_LVCH_TYPE || bdt==DB_LBYTE_TYPE  || bdt==DB_GEOM_TYPE  ||
	   bdt==DB_POINT_TYPE || bdt==DB_MPOINT_TYPE || bdt==DB_LINE_TYPE ||
	   bdt==DB_MLINE_TYPE || bdt==DB_POLY_TYPE || bdt==DB_MPOLY_TYPE ||
	   bdt==DB_LBIT_TYPE  || bdt==DB_GEOMC_TYPE
	   || qrydata->db_length+name_len+15>sizeof(qrytext))
	{
		STcopy("Long Varchar/Byte/Bit Value", qrytext);
	}
	else
	{
		adu_prvalarg(STprintf, qrytext, qrydata);
	}
	status=sc0a_qrytext(scb, qrytext, STlength(qrytext), SC0A_QT_MORE);
	return status;
}
Example #28
0
/*{
** Name: adu_cpn_dump	- Dump the value of a coupon
**
** Description:
**      This routine simply dumps the current value of a particular ADP_COUPON
**	structure.  The information is provided as ADF knows it -- tag & length
**	are labelled, the coupon itself is just a bunch of numbers. 
**
** Inputs:
**      adf_scb                         Session Control Block.
**      cpn_dv                          Ptr to DB_DATA_VALUE describing the
**					coupon to be printed
**      res_dv                          Ptr to DB_DATA_VALUE describing the
**					result area.
**
** Outputs:
**      *res_dv->db_data                Filled in.
**
**	Returns:
**	    DB_STATUS
**	Exceptions:
**	    none
**
** Side Effects:
**	    none
**
** History:
**      01-feb-1990 (fred)
**          Created.
[@history_template@]...
*/
DB_STATUS
adu_cpn_dump(
ADF_CB             *adf_scb,
DB_DATA_VALUE      *cpn_dv,
DB_DATA_VALUE      *res_dv)
{
    DB_DT_ID		dtid = abs(cpn_dv->db_datatype);
    ADP_PERIPHERAL	*p = (ADP_PERIPHERAL *) cpn_dv->db_data;
    DB_TEXT_STRING	*result = (DB_TEXT_STRING *) res_dv->db_data;
    ADP_PERIPHERAL	peripheral;
    
    if ((Adf_globs->Adi_dtptrs[dtid]->adi_dtstat_bits & AD_PERIPHERAL) == 0)
    {
	STcopy("<Not a peripheral>", (char *)result->db_t_text);
	result->db_t_count = STlength((char *)result->db_t_text);
    }
    else if (cpn_dv->db_length < sizeof(ADP_PERIPHERAL))
    {
	STcopy("<Too short to be a coupon>", (char *)result->db_t_text);
	result->db_t_count = STlength((char *)result->db_t_text);
    }
    else if (res_dv->db_length < 100)
    {
	STcopy("<Result too short>", (char *)result->db_t_text);
	result->db_t_count = STlength((char *)result->db_t_text);
    }
    else
    {
	MECOPY_CONST_MACRO((PTR)p, sizeof(peripheral), (PTR)&peripheral);
	p = &peripheral;
	TRformat(adu_finish_format, result, result->db_t_text,
			    (res_dv->db_length - sizeof(result->db_t_count)),
		    "Tag: %d., Length: %8x%8x, Cpn: <%#.#{%8x %}>",
		    p->per_tag, p->per_length0, p->per_length1,
			(sizeof(p->per_value.val_coupon) /
			    sizeof(p->per_value.val_coupon.cpn_id[0])),
			sizeof(p->per_value.val_coupon.cpn_id[0]),
			p->per_value.val_coupon.cpn_id, 0);
    }
    
    return(E_DB_OK);
}
Example #29
0
static char *
ns_value( API_PARSE *parse, i4 buflen, char *buffer )
{
    char	*parms[ API_FIELD_MAX ];
    char	*value;
    i4		len, fld, fld_cnt;
    STATUS	status;

    /*
    ** Get each (possibly optional) parameter
    ** and determine the size of the final
    ** combined value.
    */
    fld_cnt = max( 0, parse->parms->parm_max - API_FIELD_PARM );

    for( fld = len = 0; fld < fld_cnt; fld++ )
    {
	parms[ fld ] = ns_resolve_param( parse, fld + API_FIELD_PARM, 
					 (parse->opcode != API_KW_ADD) );
	len += STlength( parms[ fld ] );
    }

    len += fld_cnt;		/* Allow room for EOS and separating ',' */
    if ( ! len )  len++;

    /*
    ** Use passed in buffer if large enough.
    ** Otherwise, allocate temp buffer.
    */
    value = (len <= buflen) ? buffer
			    : (char *)MEreqmem( 0, len, FALSE, &status );
    if ( ! value )
    {
	IIAPI_TRACE( IIAPI_TR_FATAL )
	    ( "ns_value: can't allocate value buffer\n" );
	return( NULL );
    }

    /*
    ** Build the comma separated list of parameters.
    */
    if ( fld_cnt )
	STcopy( parms[ 0 ], value );
    else
	*value = EOS;

    for( fld = 1; fld < fld_cnt; fld++ )
    {
	STcat( value, "," );
	STcat( value, parms[ fld ] );
    }

    return( value );
}
Example #30
0
static void
yyputline( char *outtext)
{
	char token_buf[MAX_LINE+1];
	char token_val[MAX_LINE+1];
	char *p = token_buf;
	static char *symc = ERx( 
	   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_$");
	i4 symc_l = STlength(symc);
	i4 defidx;
	static i4  iterate_level = 0;

	/* Check to make sure we don't have runaway recursion */
	if (iterate_level++ > MAX_ITERATION)
	{
		SIfprintf( stderr, E_YAPP006 );
		yydump();
	}

	/* Break up the string into tokens and try to resolve symbols */
	while (*outtext != EOS)
	{
		p = token_buf;
		while (STindex(symc, outtext, symc_l) != NULL) {
			STlcopy(outtext, p, 1);
			CMnext(outtext);
			CMnext(p);
		}

		/* Found a token that may be defined as a symbol */
		if (p != token_buf)
		{
			/* If the token is defined then translate the */
			/* value of the substituted text, otherwise just */
			/* output the untranslated text. */
			STcopy(ERx(""), p);
			if (OK == is_defined(token_buf, token_val)) 
				yyputline( token_val );
			else 
				SIprintf("%s", token_buf);
		}

		/* The text being processed at this point is whitespace, */
		/* operators, or some other characters that are not */
		/* valid for tokens. */
		else 
		{
			SIputc(*outtext, stdout);
			CMnext(outtext);
		}
	}
	iterate_level--;
}