コード例 #1
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);
	}
}
コード例 #2
0
ファイル: csphil.c プロジェクト: saqibjamil/Ingres
void
logger(
i4 errnum, i4 arg1, i4 arg2)
{
    char buf[ ER_MAX_LEN ];
#ifdef EX_DEBUG
    EX_CONTEXT context;

    if (EXdeclare(ex_handler, &context) != OK) {
	/* some exception was raised */
	Psem( &SIsem );
	SIfprintf( stderr,"Error: unexpected exception in logger()...");
	Vsem( &SIsem );

	EXdelete();
	return;
    }
#endif

    Psem( &SIsem );
    if( ERreport( errnum, buf ) == OK )
    	SIfprintf(stderr, "%s\n", buf);
    else
	SIfprintf(stderr, "ERROR %d (%x), %s %d\n", 
		errnum, errnum, arg1, arg2 );
    Vsem( &SIsem );

#ifdef EX_DEBUG
    EXdelete();
#endif
    if(errnum != E_CS0018_NORMAL_SHUTDOWN)
	PCexit(FAIL);
    PCexit(OK);
}
コード例 #3
0
static void
display_err(char *etxt, STATUS status)
{
    if (OK != ERreport(status, &etxt[STlength(etxt)]))
        STprintf(&etxt[STlength(etxt)],
	    "(Reason unknown)", status);
    SIprintf("%s\n",etxt);
}
コード例 #4
0
static STATUS
MEerror(
	STATUS	error_status)
{
    char	ME_err_buf[ER_MAX_LEN];

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

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

   inf = NULL;

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

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

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

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

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

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

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

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

    /* Close input file */
    stat = SIclose(inf);
    if (stat != OK)
    {   /* report error closing file */
	char        buf[ER_MAX_LEN];
	if ((ERreport(stat, buf)) != OK) buf[0] = '\0';
	IIUGerr(E_XF0025_Cannot_close_param, UG_ERR_ERROR, 1, paramfile);
	return (FAIL);
    }   
    return OK;
}
コード例 #6
0
edit()
{
	register char		*p;
	LOCATION		t_loc,
				loc;
	FILE			*fp;
	char			errbuf[ER_MAX_LEN + 1];
	char			input[MAX_LOC + 1];
	char			*editfile;
	char			*ingedit;
	i4			rflag;
	STATUS			status;
	i4			c;
#ifdef CMS
	i4			Notempty = 1;
#endif /* CMS */

	GLOBALREF	char	*IIMOildInitLnDraw;

	FUNC_EXTERN 	char		*getfilenm();
	FUNC_EXTERN 	char		*macro();


	if (!Newline)
	{
		q_putc(Qryiop, '\n');
		Newline = TRUE;
	}

	Autoclear	= 0;
	editfile	= getfilenm();
	rflag		= 0;

	if (*editfile == '\0')
	{
		rflag	 = 1;
		input[0] = EOS;


		if ((status = NMloc( TEMP, PATH, (char *)NULL, &t_loc)) ||
		    (status = LOuniq( ERx( "query" ), ERx( "edt" ), &t_loc)))
		{
			STcopy( ERx( "queryXXX" ), input );
		}
		else
		{
			LOcopy( &t_loc, input, &loc );
		}

		status = SIfopen( &loc, ERx( "w" ), (i4)SI_TXT,
				  (i4)SI_MAX_TXT_REC, &fp );
	}
	else
	{
		/* use the path and file name the user gave you */

		STcopy(editfile, input);

		if (!(status = LOfroms(PATH & FILENAME, input, &loc)))
			status = SIfopen( &loc, ERx("w"), (i4)SI_TXT,
					  (i4)SI_MAX_TXT_REC, &fp );
	}

	if (status)
	{
		if (status == FAIL)
			errbuf[0] = '\0';
		else
			ERreport(status, errbuf);

		putprintf(ERget(F_MO000C_Cant_create_qry_file),
				input, errbuf);

		cgprompt();
		return(0);
	}

	if (q_ropen(Qryiop, 'r') == (struct qbuf *)NULL)
		/* edit: q_ropen 1 */
		ipanic(E_MO0044_1500400);

	while ((c = (i4)q_getc(Qryiop)) > 0)
		SIputc((char)c, fp);

	SIclose(fp);

	if (Nodayfile >= 0)
	{
		putprintf(ERget(F_MO000D_editor_prompt));
		SIflush(stdout);
	}

	/*
	**	macro returns NULL if undefined, UTedit uses
	**		default editor if passed NULL.
	*/

	/* Bug 4875	-	Use editor defined by environment variable
		ING_EDIT. If that is not set then use the macro(editor). 
	*/

	NMgtAt((ERx("ING_EDIT")), &ingedit);
	if ( ingedit != NULL && *ingedit != EOS )
		p = ingedit;
	else

		p = macro(ERx("{editor}"));

	if (status = UTedit(p, &loc))
	{
		ERreport(status, errbuf);
		putprintf(ERget(F_MO000E_Can_t_start_up_editor), errbuf);

		cgprompt();
		return(0);
	}

	if (!rflag)
	{
		if (q_ropen(Qryiop, 'a') == (struct qbuf *)NULL)
			/* edit: q_ropen 2 */
			ipanic(E_MO0045_1500401);
	}
	else
	{
		if (q_ropen(Qryiop, 'w') == (struct qbuf *)NULL)
			/* edit: q_ropen 3 */
			ipanic(E_MO0046_1500402);

		if (status = SIfopen( &loc, ERx("r"), (i4)SI_TXT,
				      (i4)SI_MAX_TXT_REC, &fp ))
#ifdef CMS
		{
			Notempty = 0;
		}
#else
		{
			ERreport(status, errbuf);
			/* can't reopen editfile %s: %s\n */
			ipanic(E_MO0047_1500403,
				editfile, errbuf);
		}
#endif /* CMS */

#ifdef CMS
		if (Notempty)
		{
#endif /* CMS */
		Notnull = 0;

		while ((c = SIgetc(fp)) != EOF)
		{
			if (status)
			{
				ERreport(status, errbuf);
				/* Error reading edit file: %s\n */
				ipanic(E_MO0048_1500404, errbuf);
			}

			Notnull = 1;

			q_putc(Qryiop, (char)c);
		}

		SIclose(fp);


		if (status = LOpurge(&loc, 0))
		{
			ERreport(status, errbuf);
			putprintf(ERget(F_MO000F_Cant_delete_file), editfile, errbuf);
		}
#ifdef CMS
		} /* endif Notempty */
#endif /* CMS */
	}

#ifndef FT3270
	/* Re-Initialize IT line drawing */
	{
	    if (Outisterm && IIMOildInitLnDraw != NULL)
		SIprintf(ERx("%s"), IIMOildInitLnDraw);
	}
#endif

	cgprompt();

	return(0);
}