Пример #1
0
std::string function_algebra_distance::write_code_eval(::std::ostream& out, int& vnum, 
                                                       ::std::string const& var) const
{
  ::std::string r(makename("dist2hyp",vnum++));
  ::std::string nrm(makename("n",vnum++));
#ifdef GRAL_HAS_SSTREAM
  ::std::ostringstream coords; 
#else
  ::std::ostrstream coords; 
#endif
  coords << normal;
  int dim = normal.dim();
  out << "coord_type "  << nrm << "(makepoint(" << dim << "," << '"' << coords.str() << '"' << "));\n"
      << "double " << r << "( " << nrm << " * " << var << " - " << dist << ");\n"; 
  return r;
}
Пример #2
0
/*
 * dofile:
 *	yank a file into a buffer and execute it
 *	if there are no errors, delete the buffer on exit
 *
 * char *fname;		file name to execute
 */
int dofile(char *fname)
{
	struct buffer *bp;	/* buffer to place file to exeute */
	struct buffer *cb;	/* temp to hold current buf while we read */
	int status;	/* results of various calls */
	char bname[NBUFN];	/* name of buffer */

	makename(bname, fname);	/* derive the name of the buffer */
	unqname(bname);		/* make sure we don't stomp things */
	if ((bp = bfind(bname, TRUE, 0)) == NULL)	/* get the needed buffer */
		return FALSE;

	bp->b_mode = MDVIEW;	/* mark the buffer as read only */
	cb = curbp;		/* save the old buffer */
	curbp = bp;		/* make this one current */
	/* and try to read in the file to execute */
	if ((status = readin(fname)) != TRUE) {
		curbp = cb;	/* restore the current buffer */
		return status;
	}

	/* go execute it! */
	curbp = cb;		/* restore the current buffer */
	if ((status = dobuf(bp)) != TRUE)
		return status;

	/* if not displayed, remove the now unneeded buffer and exit */
	if (bp->b_nwnd == 0)
		zotbuf(bp);
	return TRUE;
}
Пример #3
0
/*  Add a CU name to the current compiler entry, specified by the
    'current_compiler'; the name is added to the 'compilers_detected'
    table and is printed if the '-P' option is specified in the
    command line. */
void
add_cu_name_compiler_target(char *name)
{
    a_name_chain *cu_last = 0;
    a_name_chain *nc = 0;
    Compiler *pCompiler = 0;

    if (current_compiler < 1) {
        fprintf(stderr,"Current  compiler set to %d, cannot add "
            "Compilation unit name.  Giving up.",current_compiler);
        exit(FAILED);
    }
    pCompiler = &compilers_detected[current_compiler];
    cu_last = pCompiler->cu_last;
    /* Record current cu name */
    nc = (a_name_chain *)malloc(sizeof(a_name_chain));
    nc->item = makename(name);
    nc->next = NULL;
    if (cu_last) {
        cu_last->next = nc;
    } else {
        pCompiler->cu_list = nc;
    }
    pCompiler->cu_last = nc;
}
Пример #4
0
std::string function_algebra_hermite::write_code_eval(::std::ostream& out, int& vnum, 
                                                      ::std::string const& var) const
{ 
  ::std::string r(makename("herm",vnum++));
  out << "double " << r << "( hermite(" << a << "," << b << "," << var << "));\n";
  return r;
}
Пример #5
0
void doload(bc *bc, char *text)
{
char filename[128];
int fd;
int len;
	gettoken(filename, sizeof(filename), &text);
	if(!filename[0])
	{
		missing_parameter(bc, "Must specify filename");
		return;
	}
	makename(filename, sizeof(filename));
	fd=open(filename, O_RDONLY);
	if(fd<0)
	{
		error(bc, "Can't open file '%s' for reading.", filename);
		return;
	}
	len=read(fd, bc->program, sizeof(bc->program)-1);
	close(fd);
	if(len>=0)
		bc->program[len]=0;
	tprintf(bc, "Loaded %d bytes from file '%s'\n", len, filename);
	snprintf(bc->filename, sizeof(bc->filename), "%s", filename);
}
Пример #6
0
void dosave(bc *bc, char *text)
{
char filename[128];
int fd;
int len;
	gettoken(filename, sizeof(filename), &text);
	if(!filename[0])
	{
		strncpy(filename, bc->filename, sizeof(filename));
		if(!filename[0])
		{
			missing_parameter(bc, "Must specify filename");
			return;
		}
	}
	makename(filename, sizeof(filename));

	fd=open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
	if(fd<0)
	{
		error(bc, "Can't open file '%s' for writing.", filename);
		return;
	}
	len=write(fd, bc->program, strlen(bc->program));
	close(fd);
	if(len!=strlen(bc->program))
		error(bc, "ERROR: Short write, the entire program wasn't saved.");
	strncpy(bc->filename, filename, sizeof(bc->filename));
}
Пример #7
0
std::string function_algebra_polynomial1D::write_code_eval(::std::ostream& out, int& vnum, 
                                                           ::std::string const& var) const
{
  ::std::string bk(makename("bk",vnum++));
  ::std::string x1(makename("xtmp",vnum));
  ::std::string r(makename("poly",vnum));

  int n = degree();
  out << "double " << bk << "(" << coeffs[n+1] << ");\n"
      << "double " << x1 << "(" << var << ");\n"; 
  for(int k =1;k<=degree();k++){
    out << bk << " *= " << x1 << ";  " 
	<< bk << " += " << coeffs[n+1-k] << ";\n";
  }
  out << "double " << r << "(" << bk << ");\n";
  return r;
}
Пример #8
0
std::string function_algebra_hermite::write_code_derive(::std::ostream& out, int& vnum, 
                                                        ::std::string const& varx, 
                                                        ::std::string const& varh) const
{
  ::std::string r(makename("d_herm",vnum++));
  out << "double " << r << "( d_hermite(" << a << "," << b << "," << varx << ") * " << varh << ");\n";
  return r;
}
Пример #9
0
QString DummyEngineFactory::managerName() const
{
#ifdef DUMMYPLUGINNAME
    return QString(makename(DUMMYPLUGINNAME));
#else
    return QString();
#endif
}
Пример #10
0
static int xerrorhandler(Display* display, XErrorEvent* event) {
  char msg[80] = "";
  HXGetErrorText(display, event->error_code, msg, sizeof(msg));
  fprintf(stderr, "Xerror: %s\n", msg);
  if (x2 <= CEILexecs) {
    makename((B*)"Xdisconnect", x1); ATTR(x1) = ACTIVE;
    FREEexecs = x1;
  }
  return 0;
}
Пример #11
0
int PreProcessFile(char *nm)
{
	static char outname[1000];
	static char sysbuf[1000];

	strcpy(outname, nm);
	makename(outname,".fpp");
	sprintf(sysbuf, "fpp %s %s", nm, outname);
	return system(sysbuf);
}
Пример #12
0
int PreProcessFile(char *nm)
{
	static char outname[1000];
	static char sysbuf[500];

	strcpy_s(outname, sizeof(outname), nm);
	makename(outname,".fpp");
	snprintf(sysbuf, sizeof(sysbuf), "fpp -b %s %s", nm, outname);
	return system(sysbuf);
}
Пример #13
0
void dump2file (int signum) {
	static char filename[1024];
	if (!activevents) goto end;
	makename(filename);
	E("creat", creat(filename, 0666));
	// TODO I think creat() will always return 1 here.  Be sure.
	writefile();
	close(1);
	activevents = 0; // Removes all events.
 end:
	alarm(timeout);
	signal(SIGALRM, dump2file); }
Пример #14
0
std::string RFunction::write_code_derive(::std::ostream& out, int& vnum, 
                                         ::std::string const& varx, 
                                         ::std::string const& varh) const
{
  ::std::string r(ff->write_code_derive(out,vnum,varx,varh));
  if(a != 1.0){
    ::std::string rr(makename("tmp",vnum++));
    ::std::string rtype( (dIm() == 1? "double" : "coord_type"));
    out << rtype << " " << rr << "(" << r << ");\n";
    out << rr << " *= " << a << ";\n";
    return rr;
  }
  return r;
}
Пример #15
0
int filenext(f,n)
{	int s;
	extern int gargi,gargc;
	extern char **gargv;

	if (filesave(f,n) == FALSE)	/* save current file		*/
		return FALSE;
	if (gargi < gargc)		/* if more files on command line */
	{
		s = readin(gargv[gargi]);
		gargi++;
	}
	else				/* get file name from user	*/
		s = fileread(f,n);
	makename(curbp->b_bname,curbp->b_fname);
	return s;
}
Пример #16
0
void fixredir(union node *n, const char *text, int err)
{
	TRACE(("Fix redir %s %d\n", text, err));
	if (!err)
		n->ndup.vname = NULL;

	if (is_digit(text[0]) && text[1] == '\0')
		n->ndup.dupfd = digit_val(text[0]);
	else if (text[0] == '-' && text[1] == '\0')
		n->ndup.dupfd = -1;
	else {

		if (err)
			synerror("Bad fd number");
		else
			n->ndup.vname = makename();
	}
}
Пример #17
0
int
pico_file_drop(int x, int y, char *filename)
{
    /*
     * if current buffer is unchanged
     * *or* "new buffer" and no current text
     */
    if(((curwp->w_bufp->b_flag & BFCHG) == 0)
       || (curwp->w_bufp->b_fname[0] == '\0'
	   && curwp->w_bufp->b_linep == lforw(curwp->w_bufp->b_linep)
	   && curwp->w_doto == 0)){
	register BUFFER *bp = curwp->w_bufp;
	char     bname[NBUFN];

	makename(bname, filename);
	strncpy(bp->b_bname, bname, sizeof(bp->b_bname));
	bp->b_bname[sizeof(bp->b_bname)-1] = '\0';
	strncpy(bp->b_fname, filename, sizeof(bp->b_fname));
	bp->b_fname[sizeof(bp->b_fname)-1] = '\0';
	bp->b_flag &= ~BFCHG;	/* turn off change bit */
	if (readin(filename, 1, 1) == ABORT) {
	    strncpy(bp->b_bname, "", sizeof(bp->b_bname));
	    bp->b_bname[sizeof(bp->b_bname)-1] = '\0';
	    strncpy(bp->b_fname, "", sizeof(bp->b_fname));
	    bp->b_fname[sizeof(bp->b_fname)-1] = '\0';
	}

	bp->b_dotp = bp->b_linep;
	bp->b_doto = 0;
    }
    else{
	EML eml;

	ifile(filename);
	curwp->w_flag |= WFHARD;
	update();
	eml.s = filename;
	emlwrite("Inserted dropped file \"%s\"", &eml);
    }

    curwp->w_flag |= WFHARD;
    update();			/* restore cursor */
    return(1);
}
Пример #18
0
/****************** socketdead ************************
 * ... bool socket | --
 * 
 * Default socket dead. If bool is true, then ... is the
 *  stack for an error. Overridden by startup files.
 */
P op_socketdead(void) {
  P retc;

  if (o_2 < FLOORopds) return DEAD_SOCKET;
  if (CLASS(o_2) != BOOL) return DEAD_SOCKET;

  if ((retc = op_disconnect())) return retc;

  FREEopds = o_1;
  if (BOOL_VAL(o1)) {
    if (x1 >= CEILexecs) return EXECS_OVF;
    makename((B*) "error", x1);
    ATTR(x1) |= ACTIVE;
    FREEexecs = x2;
    return OK;
  }

  return DEAD_SOCKET;
}
Пример #19
0
std::string RFunction::write_code_eval(::std::ostream& out, int& vnum, 
                                       ::std::string const& var) const
{
  ::std::string r(ff->write_code_eval(out,vnum,var));
  if(a!= 1.0 || ! IsNullvector(b)){
    ::std::string rr(makename("tmp",vnum++));
    ::std::string rtype( (dIm() == 1? "double" : "coord_type"));
    out << rtype << " " << rr << "(" << r << ");\n";
    if (a!= 1.0)
      out << rr << " *= " << a << ";\n";
    for (int i =1;i<= b.dim();i++)
      if( b[i] != 0)
	if(dIm() == 1)
	  out << rr << " += " << b[i] << ";\n";
	else
	  out << rr << "[" << i << "] += " << b[i] << ";\n";
    return rr;
  }
  else
    return  r;
}
Пример #20
0
void scan_readdir(char *dir_path, int readdir_flag) 
{
    DIR *pDir;
    struct dirent *pDentry;
   
    if ((pDir = opendir(dir_path)) == NULL) {
        printf("[%s] ERROR: opendir(%s) - [%s]\n", __func__,
               dir_path, strerror(errno));
        exit(EXIT_FAILURE);
    }
    else {
        for (;;) {
            if ((pDentry = readdir(pDir)) == NULL) {
                printf("[%s] ERROR: during readdir(%s) - [%s]\n", __func__,
                       dir_path, strerror(errno));
                break;
            }

            if (readdir_flag == DO_GETATTR) {
                struct stat sb;
                if (stat(makename(dir_path, pDentry->d_name), &sb) == -1) {
                    printf("[%s] ERR: stat(%s) in dir(%s) - [%s]\n", __func__, 
                            pDentry->d_name, dir_path, strerror(errno));
                    exit(EXIT_FAILURE);
                }
            }

        }
    }
    
    if (closedir(pDir) < 0) {
        printf("[%s] ERROR: closedir(%s) - [%s]\n", __func__,
                dir_path, strerror(errno));
        exit(EXIT_FAILURE);
    }

    return;
}
Пример #21
0
static const char *
ellipname(int res, int val_in, const char *v,const char *ty,int printonerr)
{
#ifndef TRIVIAL_NAMING
    if (check_dwarf_constants && checking_this_compiler()) {
        DWARF_CHECK_COUNT(dwarf_constants_result,1);
    }
#endif
    if(res != DW_DLV_OK) {
        char buf[100];
        char *n;
        snprintf(buf,sizeof(buf),"<Unknown %s value 0x%x>",ty,val_in);
        /* Capture any name error in DWARF constants */
#ifndef TRIVIAL_NAMING
        if(printonerr && check_dwarf_constants && checking_this_compiler()) {
            if (check_verbose_mode) {
                fprintf(stderr,"%s of %d (0x%x) is unknown to dwarfdump. "
                    "Continuing. \n",ty,val_in,val_in );
            }
            DWARF_ERROR_COUNT(dwarf_constants_result,1);
            DWARF_CHECK_ERROR_PRINT_CU();
        }
#else
        /* This is for the tree-generation, not dwarfdump itself. */
        if(printonerr) {
            fprintf(stderr,"%s of %d (0x%x) is unknown to dwarfdump. "
                "Continuing. \n",ty,val_in,val_in );
        }
#endif
        n = makename(buf);
        return n;
    }
    if(ellipsis) {
        return skipunder(v);
    }
    return v;
}
Пример #22
0
STATIC void
parsefname(void)
{
	union node *n = redirnode;

	if (readtoken() != TWORD)
		synexpect(-1);
	if (n->type == NHERE) {
		struct heredoc *here = heredoc;
		struct heredoc *p;
		int i;

		if (quoteflag == 0)
			n->type = NXHERE;
		TRACE(("Here document %d\n", n->type));
		if (here->striptabs) {
			while (*wordtext == '\t')
				wordtext++;
		}
		if (! noexpand(wordtext) || (i = strlen(wordtext)) == 0 || i > EOFMARKLEN)
			synerror("Illegal eof marker for << redirection");
		rmescapes(wordtext);
		here->eofmark = wordtext;
		here->next = NULL;
		if (heredoclist == NULL)
			heredoclist = here;
		else {
			for (p = heredoclist ; p->next ; p = p->next);
			p->next = here;
		}
	} else if (n->type == NTOFD || n->type == NFROMFD) {
		fixredir(n, wordtext, 0);
	} else {
		n->nfile.fname = makename();
	}
}
Пример #23
0
QTM_BEGIN_NAMESPACE
/*!
  \class QContactManager
  \brief The QContactManager class provides an interface which allows clients with access to contact information stored in a particular backend.
  \inmodule QtContacts
   \since 1.0

  \ingroup contacts-main

  This class provides an abstraction of a datastore or aggregation of datastores which contains contact information.
  It provides methods to retrieve and manipulate contact information, contact relationship information, and
  supported schema definitions.  It also provides metadata and error information reporting.

  The functions provided by QContactManager are purely synchronous; to access the same functionality in an
  asynchronous manner, clients should use the use-case-specific classes derived from QContactAbstractRequest.

  Some functionality provided by QContactManager directly is not accessible using the asynchronous API; see
  the \l{Contacts Synchronous API}{synchronous} and \l{Contacts Asynchronous API}{asynchronous} API
  information from the \l{Contacts}{contacts module} API documentation.
 */

/*!
  \fn QContactManager::dataChanged()
  This signal is emitted by the manager if its internal state changes, and it is unable to determine the changes
  which occurred, or if the manager considers the changes to be radical enough to require clients to reload all data.
  If this signal is emitted, no other signals will be emitted for the associated changes.
  \since 1.0
 */

/*!
  \fn QContactManager::contactsAdded(const QList<QContactLocalId>& contactIds)
  This signal is emitted at some point once the contacts identified by \a contactIds have been added to a datastore managed by this manager.
  This signal must not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.0
 */

/*!
  \fn QContactManager::contactsChanged(const QList<QContactLocalId>& contactIds)
  This signal is emitted at some point once the contacts identified by \a contactIds have been modified in a datastore managed by this manager.
  This signal must not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.0
 */

/*!
  \fn QContactManager::contactsRemoved(const QList<QContactLocalId>& contactIds)
  This signal is emitted at some point once the contacts identified by \a contactIds have been removed from a datastore managed by this manager.
  This signal must not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.0
 */

/*!
  \fn QContactManager::relationshipsAdded(const QList<QContactLocalId>& affectedContactIds)
  This signal is emitted at some point after relationships have been added to the manager which involve the contacts identified by \a affectedContactIds.
  This signal must not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.0
 */

/*!
  \fn QContactManager::relationshipsRemoved(const QList<QContactLocalId>& affectedContactIds)
  This signal is emitted at some point after relationships have eben removed from the manager which involve the contacts identified by \a affectedContactIds.
  This signal must not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.0
 */

/*!
  \fn QContactManager::selfContactIdChanged(const QContactLocalId& oldId, const QContactLocalId& newId)
  This signal is emitted at some point after the id of the self-contact is changed from \a oldId to \a newId in the manager.
  If the \a newId is the invalid, zero id, then the self contact was deleted or no self contact exists.
  This signal must not be emitted if the dataChanged() signal was previously emitted for this change.
  \since 1.0
 */



#define makestr(x) (#x)
#define makename(x) makestr(x)

/*!
    Returns a list of available manager ids that can be used when constructing
    a QContactManager.  If an empty id is specified to the constructor, the
    first value in this list will be used instead.
    \since 1.0
  */
QStringList QContactManager::availableManagers()
{
    QStringList ret;
    ret << QLatin1String("memory") << QLatin1String("invalid");
#ifdef QT_SIMULATOR
    ret << QLatin1String("simulator");
#endif
    QContactManagerData::loadFactories();
    ret.append(QContactManagerData::m_engines.keys());

    // now swizzle the default engine to pole position
#if defined(Q_CONTACTS_DEFAULT_ENGINE)
    if (ret.removeAll(QLatin1String(makename(Q_CONTACTS_DEFAULT_ENGINE)))) {
        ret.prepend(QLatin1String(makename(Q_CONTACTS_DEFAULT_ENGINE)));
    }
#endif

    return ret;
}
Пример #24
0
QTM_BEGIN_NAMESPACE

/*!
  \class QOrganizerManager
  \brief The QOrganizerManager class provides an interface which allows clients with access to organizer item information stored in a particular backend.
  \since 1.1

  \inmodule QtOrganizer
  \ingroup organizer-main

  This class provides an abstraction of a datastore or aggregation of datastores which contains organizer item information.
  It provides methods to retrieve and manipulate organizer item information, collection information and supported schema definitions.
  It also provides metadata and error information reporting.

  The functions provided by QOrganizerManager are purely synchronous; to access the same functionality in an
  asynchronous manner, clients should use the use-case-specific classes derived from QOrganizerAbstractRequest.

  Some functionality provided by QOrganizerManager directly is not accessible using the asynchronous API; see
  the \l{Organizer Synchronous API}{synchronous} and \l{Organizer Asynchronous API}{asynchronous} API
  information from the \l{Organizer}{organizer module} API documentation.
 */

/*!
  \fn QOrganizerManager::dataChanged()
  This signal is emitted by the manager if its internal state changes, and it is unable to determine the changes
  which occurred, or if the manager considers the changes to be radical enough to require clients to reload all data.
  If this signal is emitted, no other signals will be emitted for the associated changes.
  \since 1.1
 */

/*!
  \fn QOrganizerManager::itemsAdded(const QList<QOrganizerItemId>& itemIds)
  This signal is emitted at some point once the items identified by \a itemIds have been added to a datastore managed by this manager.
  This signal will not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.1
 */

/*!
  \fn QOrganizerManager::itemsChanged(const QList<QOrganizerItemId>& itemIds)
  This signal is emitted at some point once the items identified by \a itemIds have been modified in a datastore managed by this manager.
  This signal will not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.1
 */

/*!
  \fn QOrganizerManager::itemsRemoved(const QList<QOrganizerItemId>& itemIds)
  This signal is emitted at some point once the items identified by \a itemIds have been removed from a datastore managed by this manager.
  This signal will not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.1
 */

/*!
  \fn QOrganizerManager::collectionsAdded(const QList<QOrganizerCollectionId>& collectionIds)
  This signal is emitted at some point once the collections identified by \a collectionIds have been added to a datastore managed by this manager.
  This signal will not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.1
 */

/*!
  \fn QOrganizerManager::collectionsChanged(const QList<QOrganizerCollectionId>& collectionIds)
  This signal is emitted at some point once the metadata for the collections identified by \a collectionIds have been modified in a datastore managed by this manager.
  This signal is not emitted if one of the items in this collection has changed - itemsChanged() will be emitted instead.
  This signal will not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.1
 */

/*!
  \fn QOrganizerManager::collectionsRemoved(const QList<QOrganizerCollectionId>& collectionIds)
  This signal is emitted at some point once the collections identified by \a collectionIds have been removed from a datastore managed by this manager.
  This signal will not be emitted if the dataChanged() signal was previously emitted for these changes.
  \since 1.1
 */



#define makestr(x) (#x)
#define makename(x) makestr(x)

/*!
    Returns a list of available manager ids that can be used when constructing
    a QOrganizerManager.  If an empty id is specified to the constructor, the
    first value in this list will be used instead.
    \since 1.1
  */
QStringList QOrganizerManager::availableManagers()
{
    QStringList ret;
    ret << QLatin1String("memory") << QLatin1String("invalid");
    QOrganizerManagerData::loadFactories();
    ret.append(QOrganizerManagerData::m_engines.keys());

    // now swizzle the default engine to pole position
#if defined(Q_ORGANIZER_DEFAULT_ENGINE)
    if (ret.removeAll(QLatin1String(makename(Q_ORGANIZER_DEFAULT_ENGINE)))) {
        ret.prepend(QLatin1String(makename(Q_ORGANIZER_DEFAULT_ENGINE)));
    }
#endif

    return ret;
}
Пример #25
0
int openfiles(char *s)
{
	char *p;
        strcpy_s(infile,sizeof(infile),s);
        strcpy_s(listfile,sizeof(listfile),s);
        strcpy_s(outfile,sizeof(outfile),s);
  dbgfile = s;

		//strcpy(outfileG,s);
		_splitpath(s,NULL,NULL,nmspace[0],NULL);
//		strcpy(nmspace[0],basename(s));
		p = strrchr(nmspace[0],'.');
		if (p)
			*p = '\0';
		makename(infile,".fpp");
        makename(listfile,".lis");
        makename(outfile,".s");
    dbgfile += ".xml";
		ifs = new std::ifstream();
		ifs->open(infile,std::ios::in);
/*
        if( (input = fopen(infile,"r")) == 0) {
				i = errno;
                printf(" cant open %s\n",infile);
                return 0;
                }
*/
/*
        ofl = creat(outfile,-1);
        if( ofl < 0 )
                {
                printf(" cant create %s\n",outfile);
                fclose(input);
                return 0;
                }
*/
        //oflg = _creat(outfileG,-1);
        //if( oflg < 0 )
        //        {
        //        printf(" cant create %s\n",outfileG);
        //        fclose(input);
        //        return 0;
        //        }
		ofs.open(outfile,std::ios::out|std::ios::trunc);
		dfs.open(dbgfile.c_str(),std::ios::out|std::ios::trunc);
		dfs.level = 1;
		dfs.puts("<title>C64D Compiler debug file</title>\n");
		dfs.level = 1;
		lfs.level = 1;
		ofs.level = 1;
/*
        if( (output = fdopen(ofl,"w")) == 0) {
                printf(" cant open %s\n",outfile);
                fclose(input);
                return 0;
                }
*/
        //if( (outputG = _fdopen(oflg,"w")) == 0) {
        //        printf(" cant open %s\n",outfileG);
        //        fclose(input);
        //        fclose(output);
        //        return 0;
        //        }
		lfs.open(listfile,std::ios::out|std::ios::trunc);
/*
        if( (list = fopen(listfile,"w")) == 0) {
                printf(" cant open %s\n",listfile);
                fclose(input);
                fclose(output);
                //fclose(outputG);
                return 0;
                }
*/
        return 1;
}
Пример #26
0
Файл: atoms.c Проект: RSATom/Qt
char *xcb_atom_name_by_resource(const char *base, uint32_t resource)
{
	return makename("%s_R%08X", base, resource);
}
Пример #27
0
Файл: atoms.c Проект: RSATom/Qt
char *xcb_atom_name_by_screen(const char *base, uint8_t screen)
{
	return makename("%s_S%u", base, screen);
}
Пример #28
0
int     openfiles(char *s)
{
	int     ofl,oflg;
	int i;
	char *p;
        strcpy(infile,s);
        strcpy(listfile,s);
        strcpy(outfile,s);
		//strcpy(outfileG,s);
		_splitpath(s,NULL,NULL,nmspace[0],NULL);
//		strcpy(nmspace[0],basename(s));
		p = strrchr(nmspace[0],'.');
		if (p)
			*p = '\0';
		makename(infile,".fpp");
        makename(listfile,".lis");
        makename(outfile,".s");
		ifs = new std::ifstream();
		ifs->open(infile,std::ios::in);
/*
        if( (input = fopen(infile,"r")) == 0) {
				i = errno;
                printf(" cant open %s\n",infile);
                return 0;
                }
*/
/*
        ofl = creat(outfile,-1);
        if( ofl < 0 )
                {
                printf(" cant create %s\n",outfile);
                fclose(input);
                return 0;
                }
*/
        //oflg = _creat(outfileG,-1);
        //if( oflg < 0 )
        //        {
        //        printf(" cant create %s\n",outfileG);
        //        fclose(input);
        //        return 0;
        //        }
		ofs.open(outfile,std::ios::out|std::ios::trunc);
/*
        if( (output = fdopen(ofl,"w")) == 0) {
                printf(" cant open %s\n",outfile);
                fclose(input);
                return 0;
                }
*/
        //if( (outputG = _fdopen(oflg,"w")) == 0) {
        //        printf(" cant open %s\n",outfileG);
        //        fclose(input);
        //        fclose(output);
        //        return 0;
        //        }
		lfs.open(listfile,std::ios::out|std::ios::trunc);
/*
        if( (list = fopen(listfile,"w")) == 0) {
                printf(" cant open %s\n",listfile);
                fclose(input);
                fclose(output);
                //fclose(outputG);
                return 0;
                }
*/
        return 1;
}
Пример #29
0
int main (int argc, char *argv[])
{
  BUFFER *bp;
  char bname[NBUFN];		/* buffer name of file to read */
  int c, f, n;
  int ffile;			/* first file flag */
  int carg;			/* current arg to scan */

  if (argc == 2 && 0 == strcmp("--version", argv[1]))
  {
     printf("%s\n", version);
     exit(0);
  }


  /* initialize the editor and process the startup file */
  getwinsize();			/* find out the "real" screen size */
  strncpy (bname, "*scratch*", 10);	/* default buffer name */
  edinit (bname);		/* Buffers, windows */
  vtinit ();			/* Displays */
  ffile = TRUE;			/* no file to edit yet */
  update ();			/* let the user know we are here */

  /* scan through the command line and get the files to edit */
  for (carg = 1; carg < argc; ++carg)
    {
      /* set up a buffer for this file */
      makename (bname, argv[carg]);

      /* if this is the first file, read it in */
      if (ffile)
	{
	  bp = curbp;
	  makename (bname, argv[carg]);
	  strncpy (bp->b_bname, bname, NBUFN);
	  strncpy (bp->b_fname, argv[carg], NFILEN);
	  if (readin (argv[carg]) == ABORT)
	    {
	      strncpy (bp->b_bname, "main", 5);
	      strncpy (bp->b_fname, "", 1);
	    }
	  bp->b_dotp = bp->b_linep;
	  bp->b_doto = 0;
	  ffile = FALSE;
	}
      else
	{
	  /* set this to inactive */
	  bp = bfind (bname, TRUE, 0);
	  strncpy (bp->b_fname, argv[carg], NFILEN);
	  bp->b_active = FALSE;
	}
    }

  /* setup to process commands */
  lastflag = 0;			/* Fake last flags */
  curwp->w_flag |= WFMODE;	/* and force an update */

 loop:
  update ();			/* Fix up the screen */
  c = getkey (TRUE);

  if (mpresf != FALSE)
    {
      mlerase ();
      update ();
    }
  f = FALSE;
  n = 1;

  if (c == (CTRL | 'X'))       /* ^X is a prefix */
    c = CTLX | getctl ();
  if (kbdmip != NULL)
    {				 /* Save macro strokes */
      if (c != (CTLX | ')') && kbdmip > &kbdm[NKBDM - 6])
	{
	  ctrlg (FALSE, 0);
	  goto loop;
	}
      if (f != FALSE)
	{
	  *kbdmip++ = (CTRL | 'U');
	  *kbdmip++ = n;
	}
      *kbdmip++ = c;
    }
  execute (c, f, n);	       /* Do it */
  goto loop;
}
Пример #30
0
void
dirsrch(char *name)
{
DIR *dirf;
struct dirhd *dirp;
time_t dirt, objt;
int dirused, hasparen;
char *dirname, *lastslash;
char *fullname, *filepart, *fileend, *s;
struct dirent *dptr;

lastslash = NULL;
hasparen = NO;

for(s=name; *s; ++s)
	if(*s == '/')
		lastslash = s;
	else if(*s=='(' || *s==')')
		hasparen = YES;

if(hasparen)
	{
	if(objt = lookarch(name))
		makename(name)->modtime = objt;
	return;
	}

if(lastslash)
	{
	dirname = name;
	*lastslash = '\0';
	}
else
	dirname = ".";

dirused = NO;
dirp = opdir(dirname, NO);
dirf = dirp->dirfc;
if(dirp->dirok || !dirf)
	goto ret;
dirt = exists(dirname);
if(dirp->dirtime == dirt)
	goto ret;

dirp->dirok = YES;
dirp->dirtime = dirt;
dirused = YES;

/* allocate buffer to hold full file name */
if(lastslash)
	{
	fullname = (char *) ckalloc(strlen(dirname)+MAXNAMLEN+2);
	concat(dirname, "/", fullname);
	filepart = fullname + strlen(fullname);
	}
else
	filepart = fullname = (char *) ckalloc(MAXNAMLEN+1);


fileend = filepart + MAXNAMLEN;
*fileend = '\0';
for(dptr = readdir(dirf) ; dptr ; dptr = readdir(dirf) )
	{
	char *p1, *p2;
	p1 = dptr->d_name;
	p2 = filepart;
	while( (p2<fileend) && (*p2++ = *p1++)!='\0')
		;
	if( ! srchname(fullname) )
		(void) makename(copys(fullname));
	}

free(fullname);

ret:
	cldir(dirp, dirused);
	if(lastslash)
		*lastslash = '/';
}