예제 #1
0
static void
define(char *symbol, char *value, bool hist)
{
	SYMBOL **symptr_anchor;
	SYMBOL *symptr_new;
	STATUS sts;	
	char *buf;

	/* Locate the last defined symbol in the list */
	for (symptr_anchor = &symtab.head;
		*symptr_anchor != NULL; 
		symptr_anchor = &((*symptr_anchor)->next) )
		continue; 

	/* Allocate memory for the new symbol structure */
	symptr_new = (SYMBOL *)MEreqmem(0, sizeof(SYMBOL), FALSE, &sts);
	if (symptr_new == NULL || sts != OK)
	{
		SIfprintf( stderr, E_YAPP008 );
		yydump();
	}

	/* 
	** Anchor the new symbol structure and fill it in 
	*/

	*symptr_anchor = symptr_new;
	symptr_new->name = STalloc( symbol );
	symptr_new->value = STalloc( value );
	symptr_new->hist_flag = hist;
	symptr_new->next = NULL;
	symtab.nsym++;
}
예제 #2
0
static char *
saveloc(char	*path)
{
    char	*rval = NULL;
    char	ptmp[MAX_PATH_LEN + 2];

    if (STlength(path) > MAX_PATH_LEN)
    {
	i4 maxl = MAX_PATH_LEN;

	IIUGmsg(ERget(E_XF0130_Path_Too_Long), FALSE, 2, path, &maxl);

	/* Truncate and save */
	(void) STlcopy(path, ptmp, MAX_PATH_LEN);
	rval = STalloc(ptmp);
    }
    else
    {
	rval = STalloc(path);
    }

    /* Truncate and save */
    (void) STlcopy(path, ptmp, MAX_PATH_LEN);
    rval = STalloc(ptmp);

    return (rval);
}
예제 #3
0
bool
gcn_can_auth( GCN_RESOLVE_CB *grcb )
{
    /*
    ** If the installation password has already
    ** been processed, just use it.  Otherwise,
    ** check if there is an installation password.
    ** (check for reserved internal login).
    */
    if ( grcb->flags & GCN_RSLV_IP )
    {
	grcb->pwd = grcb->ip;
	grcb->flags &= ~GCN_RSLV_PWD_ENC;
    }
    else  if ( *grcb->vnode  &&  ! STcompare( grcb->usr, GCN_NOUSER )  &&
	       STcompare( grcb->pwd, GCN_NOPASS ) )
    {
	/*
	** Save installation password.  Flag the fact that 
	** the installation password has been decoded in 
	** case we come through here again.
	*/
	if ( grcb->ip )  MEfree( (PTR)grcb->ip );	/* Should not happen */
	grcb->ip = STalloc( grcb->pwd );
	grcb->pwd = grcb->ip;
	grcb->flags |= GCN_RSLV_IP;
    }

    return( ((grcb->flags & GCN_RSLV_IP) != 0) );
}
예제 #4
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);
}
예제 #5
0
void
FEapply_null(ADF_CB *cb, char *null)
{
    if ( (cb->adf_nullstr.nlst_string = STalloc(null)) == NULL )
    {
	EXsignal(EXFEBUG, 1, ERx("FEadfcb(alloc2)"));
    }
    cb->adf_nullstr.nlst_length = STlength(null);	    
}
예제 #6
0
STATUS
s_srem_set()
{
    char	*s;
    char	*send;
    i4		pos;
    i4		n;
    char	short_remark[OOSHORTREMSIZE+1];

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

    St_sr_given = TRUE;

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

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

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

    return OK;
}
예제 #7
0
/*
**   DO_IF_NAME - Allocate an FE_DEL structure for the current word and call
**		  do_expand_name() to process it.
**
** Parameters:
**	fd		file descriptor of file to read.
**	buf_ptr		buffer to hold text string from file line.
**	maxchar		maximum number of characters to return.
**
** Returns:
**	Number of characters read.  This may be zero for empty lines.
**	The terminating LF or FF is NEVER returned.
**		-1	indicates EOF or an error.
**
** History:
**	12-jan-1993 (rdrane)
**		Created.
*/
static
VOID
do_if_name(char *wrd_ptr,OOID del_obj_type)
{
	FE_DEL	*fd;
	FE_DEL	*prev_fd;


	/*
	** Allocate a new FE_DEL for this FE object name
	*/
	fd = (FE_DEL *)MEreqmem(0,sizeof(FE_DEL),TRUE,NULL);

	/*
	** If Ptr_fd_top is NULL, then there were no FE object
	** names on the command line, so start the FE_DEL chain
	** here.  Otherwise, chain on to whatever currently exists.
	*/
	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;
	}

	/*
	** Make this the new current FE_DEL
	*/
	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(wrd_ptr);
	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 1st and no match.  If no match, the
	** FE_DEL and its name will have been de-allocated,
	** and prev_fd and and Ptr_fd_top will be altered as
	** required.
	*/

	return;
}
예제 #8
0
bool
gcd_build_qdata( QDATA *qd1, QDATA *qd2, QDATA *qd3 )
{
    IIAPI_DESCRIPTOR	*src_desc, *dst_desc;
    u_i2		i, count = 0;

    /*
    ** Count the number of non-tuple columns
    ** in the two source descriptors.
    */
    for( 
	 i = 0, src_desc = (IIAPI_DESCRIPTOR *)qd1->desc;
	 i < qd1->max_cols; 
	 i++, src_desc++
       )
	if ( src_desc->ds_columnType != IIAPI_COL_TUPLE )  
	    count++;

    for( 
	 i = 0, src_desc = (IIAPI_DESCRIPTOR *)qd2->desc;
	 i < qd2->max_cols; 
	 i++, src_desc++
       )
	if ( src_desc->ds_columnType != IIAPI_COL_TUPLE )  
	    count++;

    /*
    ** Allocate a new descriptor and data array
    ** (but not the data buffers).
    */
    if ( ! gcd_alloc_qdesc( qd3, count, NULL )  ||
         ! alloc_qdata( qd3, 1, FALSE ) )  
	return( FALSE );

    /*
    ** Copy source descriptors.
    */
    dst_desc = (IIAPI_DESCRIPTOR *)qd3->desc;

    for( 
	 i = 0, src_desc = (IIAPI_DESCRIPTOR *)qd1->desc;
	 i < qd1->max_cols; 
	 i++, src_desc++
       )
	if ( src_desc->ds_columnType != IIAPI_COL_TUPLE )  
	{
	    if ( dst_desc->ds_columnName )  
		MEfree( (PTR)dst_desc->ds_columnName );

	    STRUCT_ASSIGN_MACRO( *src_desc, *dst_desc );
	    if ( src_desc->ds_columnName )
		dst_desc->ds_columnName = STalloc( src_desc->ds_columnName );
	    dst_desc++;
	}

    for( 
	 i = 0, src_desc = (IIAPI_DESCRIPTOR *)qd2->desc;
	 i < qd2->max_cols; 
	 i++, src_desc++
       )
	if ( src_desc->ds_columnType != IIAPI_COL_TUPLE )  
	{
	    if ( dst_desc->ds_columnName )  
		MEfree( (PTR)dst_desc->ds_columnName );

	    STRUCT_ASSIGN_MACRO( *src_desc, *dst_desc );
	    if ( src_desc->ds_columnName )
		dst_desc->ds_columnName = STalloc( src_desc->ds_columnName );
	    dst_desc++;
	}

    return( TRUE );
}
예제 #9
0
/*
** Name: GClanman_listen
** Description:
**	This is the listen thread for lanman.  It runs a syncronous accept()
**	on the listen socket.  When complete it Q's the completetion to
**	the completed event Q.  When accept completes, this thread returns.
**	A new one will be created when GClanman() gets the request to
**	repost the listen.
** History:
**	11-nov-93 (edg)
**	    created.
**	29-jun-2000 (somsa01)
**	    Use GCc_listen_port for the ncb_name.
**	16-mar-2001 (somsa01)
**	    Set node_id to ncb_callname.
**      06-Aug-2009 (Bruce Lunsford) Sir 122426
**          Convert GCC completion queue mutex to a critical section
**          to improve performance (less overhead).
**	    Since _beginthreadex() is now used to start this thread,
**	    use _endthreadex() to end it.
*/
VOID
GClanman_listen( VOID *parms )
{
    GCC_P_PLIST		*parm_list = (GCC_P_PLIST *)parms;
    PCB			*pcb;
    STATUS		status = OK;
    REQUEST_Q		*rq;
    SECURITY_ATTRIBUTES	sa;

    iimksec (&sa);

    /*
    ** Initialize the listen node_id to NULL.
    */
    parm_list->function_parms.listen.node_id = NULL;

    /*
    ** Initialize fields of the Listen_Ncb
    */
    memset( &Listen_Ncb, 0, sizeof(NCB) );
    Listen_Ncb.ncb_buffer = parm_list->buffer_ptr;
    Listen_Ncb.ncb_length = (USHORT)parm_list->buffer_lng;
    Listen_Ncb.ncb_command = NCBLISTEN;
    Listen_Ncb.ncb_lana_num = lana_num;
    *Listen_Ncb.ncb_callname = (unsigned char)NULL;
    STmove( "*", ' ', NCBNAMSZ, Listen_Ncb.ncb_callname );
    *Listen_Ncb.ncb_name = (unsigned char)NULL;
    STcopy( GCc_listen_port, Listen_Ncb.ncb_name );


    /*
    ** Now we can do the NCBLISTEN request.  Block until it completes.
    */
    Netbios( &Listen_Ncb );
    if ( Listen_Ncb.ncb_retcode != NRC_GOODRET )
    {
	status = (int)Listen_Ncb.ncb_retcode;
	goto sys_err;
    }

    /*
    ** Allocate Protcol Control Block specific to this driver and put into
    ** parm list
    */
    pcb = (PCB *) malloc( sizeof(PCB) );
    if (pcb == NULL) 
    {
	status = errno;
	goto sys_err;
    }
    memset( pcb, 0, sizeof( *pcb ) );
    parm_list->pcb = (char *)pcb;

    /*
    ** Set node_id to the node name of the partner.
    */
    parm_list->function_parms.listen.node_id = STalloc(Listen_Ncb.ncb_callname);

    /*
    ** Now assign the pcb's send and receive NCB's the local session number
    ** returned by listen for further communications.
    */
    pcb->s_ncb.ncb_lsn = pcb->r_ncb.ncb_lsn = Listen_Ncb.ncb_lsn;

    /*
    ** Now create handles for the read and write event handles in the
    ** NCB.  These are created with manual reset as cautioned by the 
    ** programmer's guide so a ResetEvent MUST be done on them.
    */
    if ((pcb->s_ncb.ncb_event = CreateEvent( &sa, TRUE, FALSE, NULL ))== NULL)
    {
        status = GetLastError();
	goto sys_err;
    }
    if ((pcb->r_ncb.ncb_event = CreateEvent( &sa, TRUE, FALSE, NULL ))== NULL)
    {
        status = GetLastError();
	CloseHandle( pcb->s_ncb.ncb_event );
	pcb->s_ncb.ncb_event = NULL;
	goto sys_err;
    }

sys_err:
    if (status != OK) 
    {
        SETWIN32ERR(&parm_list->system_status, status, ER_create);
	parm_list->generic_status = GC_LISTEN_FAIL;
    }

    /*
    ** Now allocate a request q structure, stick it into complete q, and
    ** raise the GCC_COMPLETE event.
    */
    if ( (rq = (REQUEST_Q *)MEreqmem(0, sizeof(*rq), TRUE, NULL ) ) != NULL )
    {
        rq->plist = parm_list;
	/*
	** Get critical section for completion Q.
	*/
	EnterCriticalSection( &GccCompleteQCritSect );

	/*
	** Now insert the completed request into the completed Q.
	*/
	QUinsert( &rq->req_q, &IIGCc_proto_threads.completed_head );

	/*
	** Exit/leave critical section for completion Q
	*/
	LeaveCriticalSection( &GccCompleteQCritSect );

	/*
	** raise the completion event to wake up GCexec.
	*/
	if ( !SetEvent( hAsyncEvents[GCC_COMPLETE] ) )
	{
	   /*
	   ** ruh roh.  We're screwed if this event can't be signaled.
	   */
	   status = GetLastError();
	   GCTRACE(1)("GClanman_listen, SetEvent error = %d\n", status );
	}

    }
    else
    {
        /*
	** ruh-roh.  MEreqmem failed.  Selious tlouble.  Not sure what to
	** do about it at this point since if it failed we can't notify
	** the completion routine.  For now, just return (exit thread)
	** which will probably have the effect of blocking all incoming
	** connections.
	*/
    }
    _endthreadex(0);
}
예제 #10
0
STATUS
s_lrem_set()
{
    char	*b;
    char	*bend;
    i4		pos;
    i4		n;
    i4		length;
    # ifdef UNIX
    char	word[OOLONGREMSIZE+1]; 
    # else
    char        word[MAXCMD+1];
    # endif
    i4		code;
    i4		count;
    char	*save_Tokchar;
    char	long_remark[OOLONGREMSIZE+1];
    i4          rtn_char;               /* dummy variable for sgskip */

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

    /* skip leading white space */

    s_g_skip(TRUE, &rtn_char);

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

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

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

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

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

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

    return OK;
}
예제 #11
0
static STATUS
initialize( i4 argc, char **argv )
{
    CL_ERR_DESC	cl_err;
    char	*instance = ERx("*");
    char	*env;
    char	name[ 16 ];
    i4		i;

    GCD_global.language = 1;
    MHsrand( TMsecs() );

    for( i = 1; i < argc; i++ )
	if ( ! STbcompare( argv[i], 0, ERx("-instance"), 9, TRUE ) )
	{
	    if ( argv[i][9] == ERx('=')  &&  argv[i][10] != EOS )
		instance = &argv[i][10];
	    else  if ( argv[i][9] == EOS  &&  (i + 1) < argc )
		instance = argv[++i];
	    break;
	}

    NMgtAt( ERx("II_INSTALLATION"), &env );
    STprintf( name, ERx("II_CHARSET%s"), (env  &&  *env) ? env : "" );
    NMgtAt( name, &env );

    if ( ! env  ||  ! *env || STlength(env) > CM_MAXATTRNAME)
    {
	switch( CMgetDefCS() )
	{
#if ( !defined(UNIX) && !defined(VMS) )
	case CM_IBM :	    env = "IBMPC850";	break;
#endif
	case CM_DECMULTI :  env = "DECMULTI";	break;
	default :	    env = "ISO88591";	break;
	}
    }

    GCD_global.charset = STalloc( env );
    CVupper( GCD_global.charset );
    gcu_read_cset( gcd_cset_id );

    if ( CMset_attr( GCD_global.charset, &cl_err) != OK )
    {
	gcu_erlog( 0, GCD_global.language, 
		    E_GC0105_GCN_CHAR_INIT, NULL, 0, NULL );
	return( E_GC0105_GCN_CHAR_INIT );
    }

    PMinit();

    switch( PMload( (LOCATION *)NULL, (PM_ERR_FUNC *)NULL ) )
    {
	case OK: break;

	case PM_FILE_BAD:
	    gcu_erlog( 0, GCD_global.language, 
			E_GC003D_BAD_PMFILE, NULL, 0, NULL );
	    return( E_GC003D_BAD_PMFILE );
	    break;

	default:
	    gcu_erlog( 0, GCD_global.language, 
			E_GC003E_PMLOAD_ERR, NULL, 0, NULL );
	    return( E_GC003E_PMLOAD_ERR );
	    break;
    }

    PMsetDefault( 0, SystemCfgPrefix );
    PMsetDefault( 1, PMhost() );
    PMsetDefault( 2, ERx("gcd") );
    PMsetDefault( 3, instance );

    gcd_tl_services[0] = &gcd_dmtl_service;
    gcd_tl_services[1] = &gcd_jctl_service;
    GCD_global.tl_services = gcd_tl_services;
    GCD_global.tl_srvc_cnt = ARR_SIZE( gcd_tl_services );

    QUinit( &GCD_global.pib_q );
    QUinit( &GCD_global.rcb_q );
    QUinit( &GCD_global.ccb_q );
    QUinit( &GCD_global.ccb_free );
    for( i = 0; i < ARR_SIZE( GCD_global.cib_free ); i++ )  
	QUinit( &GCD_global.cib_free[ i ] );

    env = NULL;
    gcu_get_tracesym( NULL, ERx("!.client_max"), &env );
    if ( env  &&  *env )
    {
	i4 count;

	if ( CVal( env, &count ) == OK  &&  count > 0 )
	    GCD_global.client_max = count;
    }

    env = NULL;
    gcu_get_tracesym( NULL, ERx("!.client_timeout"), &env );
    if ( env  &&  *env )  
    {
	i4 timeout;

	if ( CVal( env, &timeout ) == OK  &&  timeout > 0 )
	    GCD_global.client_idle_limit = timeout * 60; /* Cnvt to seconds */
    }

    env = NULL;
    gcu_get_tracesym( NULL, ERx("!.connect_pool_status"), &env );
    if ( env  &&  *env )
    {
	if ( ! STbcompare( env, 0, "optional", 0, TRUE ) )
	    GCD_global.client_pooling = TRUE;

	if ( GCD_global.client_pooling  ||
	     ! STbcompare( env, 0, "on", 0, TRUE ) )
	{
	    env = NULL;
	    gcu_get_tracesym( NULL, ERx("!.connect_pool_size"), &env );
	    if ( env  &&  *env )  CVal( env, &GCD_global.pool_max );

	    env = NULL;
	    gcu_get_tracesym( NULL, ERx("!.connect_pool_expire"), &env );
	    if ( env  &&  *env )  
	    {
		i4 limit;

		if ( CVal( env, &limit ) == OK  &&  limit > 0 )
		    GCD_global.pool_idle_limit = limit * 60; /* Seconds */
	    }
	}
    }

    env = NULL;
    gcu_get_tracesym( "II_GCD_TRACE", ERx("!.gcd_trace_level"), &env );
    if ( env  &&  *env )  CVal( env, &GCD_global.gcd_trace_level );

    env = NULL;
    gcu_get_tracesym( "II_GCD_LOG", ERx("!.gcd_trace_log"), &env );
    if ( env  &&  *env ) 
	TRset_file( TR_F_OPEN, env, (i4)STlength( env ), &cl_err );

    return( OK );
}
예제 #12
0
static VOID
IILQgtfGcaTraceFile( II_LBQ_CB *IIlbqcb, i4  action )
{
    IILQ_TRACE		*msgtrc = &IIglbcb->iigl_msgtrc;
    FILE		*trace_file = (FILE *)msgtrc->ii_tr_file;
    char		*title = ERx("off");
    SYSTIME		now;
    char		nowbuf[100];
    i4			nowend;

    /*
    ** Check to see that we actually need to open
    ** or close the trace file.
    */
    if ( (action == IITRC_ON  &&  trace_file)    ||
	 (action == IITRC_OFF  &&  ! trace_file)  ||
	 (action == IITRC_SWITCH  &&  ! trace_file) )
	return;

    if ( action == IITRC_SWITCH )  title = ERx("switched");

    if ( action == IITRC_ON )
    {
	LOCATION	trace_loc;
	STATUS		stat;

	/*
	** If trace file name not provided, use default.
	*/
	if ( ! msgtrc->ii_tr_fname )
	    msgtrc->ii_tr_fname = STalloc( GCTRACEFILE );

	LOfroms(FILENAME, msgtrc->ii_tr_fname, &trace_loc );
# ifdef hp9_mpe
	if ( msgtrc->ii_tr_flags & II_TR_APPEND )
	    stat = SIfopen(&trace_loc, ERx("a"), SI_TXT, 252, &trace_file);
	else
	    stat = SIfopen(&trace_loc, ERx("w"), SI_TXT, 252, &trace_file);
# else
	if ( msgtrc->ii_tr_flags & II_TR_APPEND )
	    stat = SIopen(&trace_loc, ERx("a"), &trace_file);
	else
	    stat = SIopen(&trace_loc, ERx("w"), &trace_file);
# endif
	if (stat != OK)
	{
	    /* Simplest error path; don't want IIlocerr functionality */
	    IIUGerr(E_LQ0007_PRINTQRY, 0, 1, msgtrc->ii_tr_fname);

	    /*
	    ** We can't call IILQgstGcaSetTrace() because
	    ** of possible conflicts with the tracing
	    ** semaphore, so just turn off tracing here.
	    */
	    msgtrc->ii_tr_flags &= ~II_TR_FILE;
	    if ( ! (msgtrc->ii_tr_flags & II_TR_HDLR) )
		IIcgct1_set_trace( IIlbqcb->ii_lq_gca, 0, NULL, NULL );
	    return;
	}

	msgtrc->ii_tr_file = (PTR)trace_file;
	title = ERx("on ");
    }

    /* Get time stamp */
    TMnow(&now);
    TMstr(&now, nowbuf);
    nowend = STlength( nowbuf );
    if ( nowbuf[ nowend - 1 ] == '\n' )  nowbuf[ nowend - 1 ] = EOS;

    SIfprintf( trace_file, ERx("---- printgca = %s session %d (%s) ---\n\n"),
	       title, IIlbqcb->ii_lq_sid, nowbuf );
    SIflush( trace_file );

    if ( action != IITRC_OFF )
	msgtrc->ii_tr_sid = IIlbqcb->ii_lq_sid;
    else
    {
	SIclose( trace_file );
	msgtrc->ii_tr_file = NULL;
	msgtrc->ii_tr_sid = 0;
	msgtrc->ii_tr_flags |= II_TR_APPEND;  /* Don't overwrite if reopened */
    }

    return;
} /* IILQgtfGcaTraceFile */
예제 #13
0
i4
yylex()
{
	bool pattern;
	bool component;
	bool keyword;
	char *keyhead;
	char yytext[ SI_MAX_TXT_REC + 1 ];
	i4 yyleng;

	/* skip whitespace and comments */
	while( CMwhite( yyp ) || *yyp == EOS || *yyp == '-' )
	{
		/* check for comment */
		if( *yyp == '-' )
		{
			if( STbcompare( yyp, 2, ERx( "--" ), 2, FALSE ) == 0 )
			{
				while( *yyp != EOS )
					CMnext( yyp );
			}
			else
				break;
		}

		if( *yyp == EOS )
		{
			if( SIgetrec( yybuf, sizeof( yybuf ), yyin ) != OK &&
				yywrap() )
			{
				return( 0 );
			}
			else
			{
				yyp = yybuf;
				++yylineno;
			}
		}
		else
			CMnext( yyp );
	}

	/* check for a SYMBOL, PATTERN or keyword */
	yyleng = 0;
	pattern = FALSE;
	keyword = TRUE;
	keyhead = yyp;
	while( CMalpha( yyp ) || *yyp == '%' || *yyp == '$' || *yyp == '*' )
	{
		/* check for component of legal SYMBOL or PATTERN */ 
		component = FALSE;

		/* check for single-character component */
		switch( *yyp )
		{
			case '%':
				pattern = TRUE;
			case '*':
			case '$':
				component = TRUE;
				++yyleng;
				CMnext( yyp );
				if( *yyp == '.' )
				{
					++yyleng;
					CMnext( yyp );
					keyword = FALSE;
					continue;
				}
				else if( CMalpha( yyp ) )
					yyerror(); 
				continue;
		}

		while( CMalpha( yyp ) || CMdigit( yyp ) ||
			*yyp == '_' || *yyp == '-' )
		{
			++yyleng;
			CMnext( yyp );
			component = TRUE;
		}
		if( component )
		{
			if( *yyp == '.' )
			{
				++yyleng;
				CMnext( yyp );
				keyword = FALSE;
				continue;
			}
			continue;
		}
	}

	/* check for uneaten '.' */
	if( *yyp == '.' )
		yyerror();

	if( yyleng > 0 )
	{
		/* A keyword, SYMBOL or PATTERN was scanned */
		char *p;
		i4 i;

		/* put NULL-terminated copy in yytext */
		STlcopy( keyhead, yytext, yyleng );	
		for( p = yytext, i = 0; i <= yyleng; CMnext( p ), i++ );
		*p = EOS;	

		/* check for keywords */
		if( CMalpha( keyhead) && keyword )
		{
			if( STequal( ERx( "IF" ), yytext ) != 0 )
				return( IF );

			if( STequal( ERx( "ELSE" ), yytext ) != 0 )
				return( ELSE );

			if( STequal( ERx( "ELSEIF" ), yytext ) != 0 )
				return( ELSEIF );

			if( STequal( ERx( "ENDIF" ), yytext ) != 0 )
				return( ENDIF );

			if( STequal( ERx( "MIN" ), yytext ) != 0 )
				return( MIN );

			if( STequal( ERx( "MAX" ), yytext ) != 0 )
				return( MAX );

			if( STequal( ERx( "VALID" ), yytext ) != 0 )
				return( VALID );

			if( STequal( ERx( "PRIME" ), yytext ) != 0 )
				return( PRIME );

			if( STequal( ERx( "SIGNED_INT" ), yytext ) != 0 )
				return( SIGNED_INT );

			if( STequal( ERx( "DECIMAL" ), yytext ) != 0 )
				return( DECIMAL );

			if( STequal( ERx( "SIZETYPE" ), yytext ) != 0 )
				return( SIZETYPE );

			if( STequal( ERx( "POWER2" ), yytext ) != 0 )
				return( POWER2 );

			if( STequal( ERx( "REQUIRES" ), yytext ) != 0 )
				return( REQUIRES );

			if( STequal( ERx( "UNDEFINED" ), yytext ) != 0 )
				return( UNDEFINED );

			if( STequal( ERx( "SUM" ), yytext ) != 0 )
			{
				yylval.integer = SUM;
				return( SUM );
			}

			if( STequal( ERx( "ON" ), yytext ) != 0 )
			{
				yylval.real = 1;
				return( BOOL_CON );
			}

			if( STequal( ERx( "OFF" ), yytext ) != 0 )
			{
				yylval.real = 0;
				return( BOOL_CON );
			}

			if( STequal( ERx( "IS" ), yytext ) != 0 )
			{
				yylval.string = STalloc( yytext );
				return( COMPARE_OP );
			}

			if( STequal( ERx( "DIRECTORY" ), yytext ) != 0 )
				return( DIRECTORY );

			if( STequal( ERx( "FILE" ), yytext ) != 0 )
				return( FILESPEC );

		}
		/* valid SYMBOL or PATTERN */
		yylval.string = STalloc( yytext );
		if( pattern )
			return( PATTERN );
		/* don't accept a single '*' as SYMBOL */
		if( yyleng != 1 || *yytext != '*' )
			return( SYMBOL );

		/* push '*' back onto the input stream */
		CMprev( yyp, yybuf );
	}

	/* check for EXEC_TEXT, STR_CON, or EXEC_TEXT_STR */
	if( *yyp == '`' || *yyp == '"' )
	{
		int exec_str = 0;
		char *initstr = yyp;
		char *p = yyp, *text, *yyprev;

		if ( *yyp == '"' )
		{
			CMnext( yyp );
			if ( *yyp == '`' )
			{
				CMnext( p );
				exec_str = 1;
			}
			else
				yyp = p;
		}
		for( yyleng = 0, CMnext( yyp ), yyprev = ERx( "" );
			*yyp != *p || *yyprev == '\\';
			yyprev = ( *yyprev == EOS ) ? yyp : CMnext( yyprev ),
			CMnext( yyp ), ++yyleng )
		{
			if( *yyp == *p && *yyprev == '\\' )
			{
				/* remove escape character */
				char *p1, *p2;

				for( p1 = p2 = yyprev, CMprev( p1, p );
					p1 >= p; CMprev( p1, p ),
					CMprev( p2, p ) )
				{
					CMcpychar( p1, p2 );
				}
				--yyleng;
				CMnext( p );
			}

			if( *yyp == EOS )
				yyerror();
		}
		CMnext( yyp );
		if ( exec_str )
		{
			if ( *yyp == '"' )
				CMnext( yyp );
			else
			{
				/* keep scanning to final '"' */
				p = initstr;
				exec_str = 0;
				yyleng++;
				for( ; *yyp != *p || *yyprev == '\\';
					yyprev = ( *yyprev == EOS ) ? yyp : 
					CMnext( yyprev ),
					CMnext( yyp ), ++yyleng )
				{
					if( *yyp == EOS )
						yyerror();
				}
			}
		}
		text = p;
		CMnext( text );
		STlcopy( text, yytext, yyleng );
		yytext[ yyleng ] = EOS;
		yylval.string = STalloc( yytext );
		if( *p == '`' )
		{
			if ( exec_str )
				return( EXEC_TEXT_STR );
			return( EXEC_TEXT );
		}
		return( STR_CON );
	}

	/* check for NUM_CON */
	yyleng = 0;
	if( *yyp == '-' || CMdigit( yyp ) )
	{
		f8 factor;
		char *p = yyp;

		if( *yyp == '-' )
		{
			++yyleng;
			factor = -1;
			CMnext( yyp );
		}
		else
			factor = 1;
		
		if( !CMdigit( yyp ) )
			CMprev( yyp, yybuf );
		else
		{
			if( *yyp == '-' )
			{
				CMnext( yyp );	
				
			}
			else
				factor = 1;

			while( CMdigit( yyp ) )
			{
				++yyleng;
				CMnext( yyp );
			}

			if( *yyp == '.' )
			{
				++yyleng;
				CMnext( yyp );
				if( !CMdigit( yyp ) )
					yyerror();
				while( CMdigit( yyp ) )
				{
					++yyleng;
					CMnext( yyp );
				}
			}
			else if( *yyp == 'K' || *yyp == 'M' )
			{
				++yyleng;
				CMnext( yyp );
			}

			STlcopy( p, yytext, yyleng ); 
			yytext[ yyleng ] = EOS;

			if( yytext[ yyleng - 1 ] == 'K' )
			{
				factor = 1024;
				yytext[ yyleng - 1 ] = EOS;
			}
			else if( yytext[ yyleng - 1 ] == 'M' )
			{
				factor = 1048576;
				yytext[ yyleng - 1 ] = EOS;
			}
			CVaf( yytext, ERx( '.' ), &yylval.real );
			yylval.real *= factor;
			return( NUM_CON );
		}
	}

	if( STbcompare( yyp, 2, ERx( ">=" ), 2, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( ">=" ) );
		CMnext( yyp );
		CMnext( yyp );
		return( COMPARE_OP );
	}
	if( STbcompare( yyp, 2, ERx( "<=" ), 2, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( "<=" ) );
		CMnext( yyp );
		CMnext( yyp );
		return( COMPARE_OP );
	}
	/* check for COMPARE_OP */
	if( STbcompare( yyp, 1, ERx( "<" ), 1, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( "<" ) );
		CMnext( yyp );
		return( COMPARE_OP );
	}
	if( STbcompare( yyp, 1, ERx( ">" ), 1, FALSE ) == 0 ) 
	{
		yylval.string = STalloc( ERx( ">" ) );
		CMnext( yyp );
		return( COMPARE_OP );
	}
	if( STbcompare( yyp, 2, ERx( "==" ), 2, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( "==" ) );
		CMnext( yyp );
		CMnext( yyp );
		return( COMPARE_OP );
	}

	/* check for characters which get passed directly */
	switch( *yyp )
	{
		char *p;

		case '(':
		case ')':
		case '[':
		case ']':
		case '{':
		case '}':
		case ':':
		case ';':
		case ',':
		case '=':
			p = yyp;
			CMnext( yyp );
			return( *p );	

		case '+':
			yylval.string = STalloc( ERx( "+" ) );
			CMnext( yyp );
			return( *yylval.string );

		case '-':
			yylval.string = STalloc( ERx( "-" ) );
			CMnext( yyp );
			return( *yylval.string );

		case '*':
			yylval.string = STalloc( ERx( "*" ) );
			CMnext( yyp );
			return( *yylval.string );

		case '/':
			yylval.string = STalloc( ERx( "/" ) );
			CMnext( yyp );
			return( *yylval.string );
	}

	/* check for LOGIC_OP */
	if( STbcompare( yyp, 3, ERx( "&&" ), 3, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( "&&" ) );
		CMnext( yyp );
		CMnext( yyp );
		return( LOGIC_OP );
	}
	if( STbcompare( yyp, 3, ERx( "||" ), 3, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( "||" ) );
		CMnext( yyp );
		CMnext( yyp );
		return( LOGIC_OP );
	}

	/* anything else is an error */
	yyerror();

}
예제 #14
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;
}
예제 #15
0
II_EXTERN II_VOID II_FAR II_EXPORT
IIapi_batch( IIAPI_BATCHPARM II_FAR *batchParm )
{
    IIAPI_CONNHNDL	*connHndl;
    IIAPI_TRANHNDL	*tranHndl;
    IIAPI_STMTHNDL	*stmtHndl;
    IIAPI_HNDL		*handle;
    
    IIAPI_TRACE( IIAPI_TR_TRACE )( "IIapi_batch: adding a batch query\n" );
    
    /*
    ** Validate Input parameters
    */
    if ( ! batchParm )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_batch: null batch parameters\n" );
	return;
    }
    
    batchParm->ba_genParm.gp_completed = FALSE;
    batchParm->ba_genParm.gp_status = IIAPI_ST_SUCCESS;
    batchParm->ba_genParm.gp_errorHandle = NULL;
    connHndl = (IIAPI_CONNHNDL *)batchParm->ba_connHandle;
    handle = (IIAPI_HNDL *)batchParm->ba_tranHandle;
    stmtHndl = (IIAPI_STMTHNDL *)batchParm->ba_stmtHandle;
    
    /*
    ** Make sure API is initialized
    */
    if ( ! IIapi_initialized() )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_batch: API is not initialized\n" );
	IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			   IIAPI_ST_NOT_INITIALIZED );
	return;
    }
    
    /*
    ** Validate connection handle.
    */
    if ( ! IIapi_isConnHndl( connHndl )  ||  IIAPI_STALE_HANDLE( connHndl ) )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_batch: invalid connHndl %p\n", connHndl );
	IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			   IIAPI_ST_INVALID_HANDLE );
	return;
    }
    
    /*
    ** Validate transaction handle.
    */
    if ( handle  &&  ! IIapi_isTranName( (IIAPI_TRANNAME *)handle )  &&
                    (! IIapi_isTranHndl( (IIAPI_TRANHNDL *)handle )  ||
	             IIAPI_STALE_HANDLE( handle )) )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_batch: invalid tranHndl %p\n", handle );
	IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			   IIAPI_ST_INVALID_HANDLE );
	return;
    }

    /*
    ** Validate statement handle.
    */
    if ( stmtHndl )
    {
    	if ( ! IIapi_isStmtHndl( (IIAPI_STMTHNDL *)stmtHndl )  ||
	     IIAPI_STALE_HANDLE( stmtHndl ) )
	{
	    IIAPI_TRACE( IIAPI_TR_ERROR )
		( "IIapi_batch: invalid stmtHndl %p\n", stmtHndl );
	    IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			       IIAPI_ST_INVALID_HANDLE );
	    return;
	}

	if ( ! handle  ||  IIapi_isTranName( (IIAPI_TRANNAME *)handle) )
	{
	    IIAPI_TRACE( IIAPI_TR_ERROR )
		( "IIapi_batch: transaction handle required\n" );
	    IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			       IIAPI_ST_INVALID_HANDLE );
	    return;
	}

    	if ( handle != (IIAPI_HNDL *)stmtHndl->sh_tranHndl )
	{
	    IIAPI_TRACE( IIAPI_TR_ERROR )
		( "IIapi_batch: wrong tranHndl %p for stmtHndl %p\n",
		  handle, stmtHndl );
	    IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			       IIAPI_ST_INVALID_HANDLE );
	    return;
	}

	if ( connHndl != IIapi_getConnHndl( (IIAPI_HNDL *)stmtHndl ) )
	{
	    IIAPI_TRACE( IIAPI_TR_ERROR )
		( "IIapi_batch: wrong connHndl %p for stmtHndl %p\n",
		  connHndl, stmtHndl );
	    IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			       IIAPI_ST_INVALID_HANDLE );
	    return;
	}
    }

    IIAPI_TRACE( IIAPI_TR_INFO )
	( "IIapi_batch: connHndl = %p, tranHndl = %p, stmtHndl = %p, queryType = %d\n",
	  batchParm->ba_connHandle, batchParm->ba_tranHandle,
	  batchParm->ba_stmtHandle, batchParm->ba_queryType );
    
    IIAPI_TRACE( IIAPI_TR_INFO )
	( "IIapi_batch: queryText = %s\n",
	  batchParm->ba_queryText ? batchParm->ba_queryText : "<NULL>" );
    
    IIapi_clearAllErrors( stmtHndl ? (IIAPI_HNDL *)stmtHndl :
	( (handle && IIapi_isTranHndl( (IIAPI_TRANHNDL *)handle ))
	  ? handle : (IIAPI_HNDL *)connHndl ) );
    
    /*
    ** Check that batch processing is supported on the connection.
    */
    if ( connHndl->ch_partnerProtocol < GCA_PROTOCOL_LEVEL_68 )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_batch: batch not supported at protocol level %d\n", 
	      connHndl->ch_partnerProtocol );

	if ( ! IIapi_localError( (IIAPI_HNDL *)connHndl, 
				 E_AP001F_BATCH_UNSUPPORTED, 
				 II_SS50008_UNSUPPORTED_STMT,
				 IIAPI_ST_FAILURE ) )
	    IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			       IIAPI_ST_OUT_OF_MEMORY );
	else
	    IIapi_appCallback( &batchParm->ba_genParm, 
			       (IIAPI_HNDL *)connHndl, IIAPI_ST_FAILURE );
	return;
    }

    /*
    ** Check restrictions on query type and associated info.
    */
    if ( connHndl->ch_type != IIAPI_SMT_SQL  ||
	 (batchParm->ba_queryType != IIAPI_QT_QUERY  &&
	  batchParm->ba_queryType != IIAPI_QT_EXEC   &&
	  batchParm->ba_queryType != IIAPI_QT_EXEC_PROCEDURE) )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_batch: invalid query type %d for connection type %d\n", 
	      batchParm->ba_queryType, connHndl->ch_type );

	if ( ! IIapi_localError( (IIAPI_HNDL *)connHndl, 
				 E_AP0011_INVALID_PARAM_VALUE, 
				 II_SS50008_UNSUPPORTED_STMT,
				 IIAPI_ST_FAILURE ) )
	    IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			       IIAPI_ST_OUT_OF_MEMORY );
	else
	    IIapi_appCallback( &batchParm->ba_genParm, 
			       (IIAPI_HNDL *)connHndl, IIAPI_ST_FAILURE );
	return;
    }

    if ( batchParm->ba_queryType != IIAPI_QT_EXEC_PROCEDURE  &&
         ! batchParm->ba_queryText )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_batch: query requires query text\n" );

	if ( ! IIapi_localError( (IIAPI_HNDL *)connHndl, 
				 E_AP0011_INVALID_PARAM_VALUE, 
				 II_SS5000R_RUN_TIME_LOGICAL_ERROR,
				 IIAPI_ST_FAILURE ) )
	    IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			       IIAPI_ST_OUT_OF_MEMORY );
	else
	    IIapi_appCallback( &batchParm->ba_genParm, 
			       (IIAPI_HNDL *)connHndl, IIAPI_ST_FAILURE );
	return;
    }

    if ( batchParm->ba_queryType == IIAPI_QT_EXEC_PROCEDURE  &&
         ! batchParm->ba_parameters )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_batch: query requires parameters, none indicated\n" );

	if ( ! IIapi_localError( (IIAPI_HNDL *)connHndl, 
				 E_AP0011_INVALID_PARAM_VALUE, 
				 II_SS5000R_RUN_TIME_LOGICAL_ERROR,
				 IIAPI_ST_FAILURE ) )
	    IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			       IIAPI_ST_OUT_OF_MEMORY );
	else
	    IIapi_appCallback( &batchParm->ba_genParm, 
			       (IIAPI_HNDL *)connHndl, IIAPI_ST_FAILURE );
	return;
    }

    /*
    ** Allocate a transaction handle if one was not provided.
    */
    if ( ! handle  ||  IIapi_isTranName( (IIAPI_TRANNAME *)handle ) )
    {
	/*
	** Check to see if there is an active transaction.
	*/
	if ( ! IIapi_isQueEmpty( (QUEUE *)&connHndl->ch_tranHndlList ) )
	{
	    IIAPI_TRACE( IIAPI_TR_ERROR )
		("IIapi_batch: connection has active transaction.\n");

	    if ( ! IIapi_localError( (IIAPI_HNDL *)connHndl, 
				     E_AP0003_ACTIVE_TRANSACTIONS, 
				     II_SS25000_INV_XACT_STATE,
				     IIAPI_ST_FAILURE ) )
		IIapi_appCallback( &batchParm->ba_genParm, NULL, 
				   IIAPI_ST_OUT_OF_MEMORY );
	    else
		IIapi_appCallback( &batchParm->ba_genParm, 
				   (IIAPI_HNDL *)connHndl, IIAPI_ST_FAILURE );
	    return;
	}

	if ( ! ( tranHndl = IIapi_createTranHndl(
				(IIAPI_TRANNAME *)batchParm->ba_tranHandle,
				(IIAPI_CONNHNDL *)batchParm->ba_connHandle ) ) )
	{
	    IIAPI_TRACE( IIAPI_TR_ERROR )
		( "IIapi_batch: createTranHndl failed\n" );
	    IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			       IIAPI_ST_OUT_OF_MEMORY );
	    return;
	}
    }
    else
    {
	/*
	** Use existing transaction handle.
	*/
	tranHndl = (IIAPI_TRANHNDL *)handle;
	IIapi_clearAllErrors( (IIAPI_HNDL *)tranHndl );
    }
    
    /*
    ** Allocate a new statement handle or initialize existing handle.
    */
    if ( stmtHndl )
	initStmtHndl( stmtHndl );
    else  if ( ! (stmtHndl = IIapi_createStmtHndl( connHndl, tranHndl )) )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_batch: createStmtHndl failed\n" );

	IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			   IIAPI_ST_OUT_OF_MEMORY );
	goto freeTranHandle;
    }

    /*
    ** Update statement handle with batch query information.
    */
    if ( batchParm->ba_queryText  &&
	 ! (stmtHndl->sh_queryText = STalloc( batchParm->ba_queryText )) )
    {
	IIAPI_TRACE( IIAPI_TR_FATAL )
	    ( "IIapi_batch: can't alloc query text\n" );

	IIapi_appCallback( &batchParm->ba_genParm, NULL, 
			   IIAPI_ST_OUT_OF_MEMORY );
	goto freeStmtHandle;
    }
    
    stmtHndl->sh_queryType = batchParm->ba_queryType;
    if ( batchParm->ba_parameters )  stmtHndl->sh_flags |= IIAPI_SH_PARAMETERS;

    /*
    ** The current set of external batch/query flags
    ** are not applicable to batch processing, but
    ** we pass them along anyway.
    */
    stmtHndl->sh_flags |= batchParm->ba_flags & IIAPI_QF_ALL_FLAGS;

    batchParm->ba_stmtHandle = (II_PTR)stmtHndl;
    batchParm->ba_tranHandle = (II_PTR)tranHndl;
    
    IIapi_uiDispatch( IIAPI_EV_BATCH_FUNC, 
		      (IIAPI_HNDL *)stmtHndl, (II_PTR)batchParm );
    return;

  freeStmtHandle:

    /*
    ** If the statement handle is not the input handle,
    ** then we allocated a new handle above and we must
    ** now delete it.
    */
    if ( stmtHndl != (IIAPI_STMTHNDL *)batchParm->ba_stmtHandle )
	IIapi_deleteStmtHndl( stmtHndl );

  freeTranHandle:

    /*
    ** If the transaction handle is not the input handle,
    ** then we allocated a new handle above and we must
    ** now delete it.
    */
    if ( tranHndl != (IIAPI_TRANHNDL *)batchParm->ba_tranHandle )
	IIapi_deleteTranHndl( tranHndl );

    return;
}
예제 #16
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 );
}
예제 #17
0
II_EXTERN IIAPI_STATUS
IIapi_getNSDescriptor( IIAPI_STMTHNDL *stmtHndl )
{
    API_PARSE		*parse = (API_PARSE *)stmtHndl->sh_queryText;
    IIAPI_DESCRIPTOR	*desc1, *desc2;
    STATUS		status;
    i4			count;

    switch( parse->object )
    {
	case API_KW_NODE :
	    desc1 = ns_node_desc;
	    count = ARRAY_SIZE( ns_node_desc );
	    break;

	case API_KW_LOGIN :
	    desc1 = ns_login_desc;
	    count = ARRAY_SIZE( ns_login_desc );
	    break;

	case API_KW_ATTR :
	    desc1 = ns_attr_desc;
	    count = ARRAY_SIZE( ns_attr_desc );
	    break;

	case API_KW_SERVER :
	    desc1 = ns_server_desc;
	    count = ARRAY_SIZE( ns_server_desc );
	    break;

	default :
	    /*
	    ** Should not happen!
	    */
	    IIAPI_TRACE( IIAPI_TR_TRACE )
		( "IIapi_getNSDescriptor: invalid object.\n" );
	    return( IIAPI_ST_FAILURE );
	    break;
    }

    stmtHndl->sh_colDescriptor = (IIAPI_DESCRIPTOR *)
	MEreqmem( 0, sizeof(IIAPI_DESCRIPTOR) * count, FALSE, &status );

    if ( ! stmtHndl->sh_colDescriptor )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_getNSDescriptor: error allocating descriptor.\n" );

	return( IIAPI_ST_OUT_OF_MEMORY );
    }

    for( 
	 stmtHndl->sh_colCount = 0, desc2 = stmtHndl->sh_colDescriptor; 
	 stmtHndl->sh_colCount < count; 
	 stmtHndl->sh_colCount++, desc1++, desc2++
       )
    {
	STRUCT_ASSIGN_MACRO( *desc1, *desc2 );
	desc2->ds_columnName = STalloc( desc1->ds_columnName );

	if ( ! desc2->ds_columnName )
	{
	    IIAPI_TRACE( IIAPI_TR_ERROR )
		( "IIapi_getNSDescriptor: error allocating column name.\n" );

	    /*
	    ** Since all the entries are valid
	    ** upto sh_colCount, we'll leave the
	    ** descriptor to be freed when the
	    ** statement handle is freed.
	    */
	    return( IIAPI_ST_OUT_OF_MEMORY );
	}
    }

    return( IIAPI_ST_SUCCESS );
}
예제 #18
0
BOOL CWinstartApp::InitInstance()
{
    char	*ii_installation;
    HWND	hWnd;
    CString	csWindow;

    NMgtAt(ERx( "II_INSTALLATION" ), &ii_installation);
    if (ii_installation == NULL || *ii_installation == EOS)
        ii_installation = ERx("II");
    else
        ii_installation = STalloc(ii_installation);
    csSemaphore.Format("IngresII_Winstart_%s", ii_installation);
    csWindow.Format(IDS_CAPTIONTEXT,(LPCTSTR)ii_installation);

    hSemaphore = OpenSemaphore( SEMAPHORE_ALL_ACCESS, FALSE,
                                (LPCTSTR)csSemaphore );
    if (hSemaphore)
    {
        /*
        ** We've already got a WINSTART running for this installation.
        ** Attempt to find it and change focus to it.
        */
        CloseHandle(hSemaphore);
        hWnd = FindWindow(NULL, csWindow);
        if(hWnd)
        {
            SetForegroundWindow(hWnd);
            ShowWindow(hWnd, SW_RESTORE);
            exit(0);
        }
    }

    hSemaphore = CreateSemaphore(NULL, cMax, cMax, (LPCTSTR)csSemaphore);

    /*
    ** Standard initialization
    ** If you are not using these features and wish to reduce the size
    ** of your final executable, you should remove from the following
    ** the specific initialization routines you do not need.
    */
    InitCommonControls();
    CWinApp::InitInstance();

    AfxEnableControlContainer ();

    /* Load standard INI file options (including MRU) */
    LoadStdProfileSettings();

    CWinstartDlg dlg;
    m_pMainWnd = &dlg;

    CString strCmdLine="";
    if (m_lpCmdLine)
        strCmdLine = m_lpCmdLine;

    strCmdLine.MakeLower();

    if (strCmdLine.Find("/start") != -1)
        dlg.m_bStartFlag = TRUE;
    else
        dlg.m_bStartFlag = FALSE;

    if (strCmdLine.Find("/stop") != -1)
        dlg.m_bStopFlag = TRUE;
    else
        dlg.m_bStopFlag = FALSE;

    int i, iPos, iLen, iLeft, iChars=0;
    TCHAR p;
    dlg.m_strParam="";

    iPos = strCmdLine.Find("/param=\"");
    if (iPos != -1)
    {
        dlg.m_bParamFlag = TRUE;
        iLen = strCmdLine.GetLength();
        iLeft = iPos + 8;
        for (i=iLeft; i<iLen; i++)
        {
            p = strCmdLine.GetAt(i);
            if (p == '\"')
                break;
            iChars++;
        }

        dlg.m_strParam=strCmdLine.Mid(iLeft, iChars);
    }
    else
        dlg.m_bParamFlag = FALSE;

    dlg.DoModal();
    /*
    ** Since the dialog has been closed, return FALSE so that we exit the
    ** application, rather than start the application's message pump.
    */
    return FALSE;
}