示例#1
0
/*
 * This routine changes the address of obj. Be careful not to call it
 * when there might be pointers around in unknown places. For now: only
 * when obj is in the inventory.
 */
static void do_oname(struct obj *obj)
{
	char buf[BUFSZ], qbuf[QBUFSZ];
	const char *aname;
	short objtyp;

	sprintf(qbuf, "What do you want to name %s %s?",
		is_plural(obj) ? "these" : "this", xname(obj));
	getlin(qbuf, buf);
	if (!*buf || *buf == '\033')	return;
	/* strip leading and trailing spaces; unnames item if all spaces */
	mungspaces(buf);

	/* relax restrictions over proper capitalization for artifacts */
	if ((aname = artifact_name(buf, &objtyp)) != 0 && objtyp == obj->otyp)
		strcpy(buf, aname);

	if (obj->oartifact) {
		pline("The artifact seems to resist the attempt.");
		return;
	} else if (restrict_name(obj, buf) || exist_artifact(obj->otyp, buf)) {
		int n = rn2((int)strlen(buf));
		char c1, c2;

		c1 = lowc(buf[n]);
		do c2 = 'a' + rn2('z'-'a'); while (c1 == c2);
		buf[n] = (buf[n] == c1) ? c2 : highc(c2);  /* keep same case */
		pline("While engraving your %s slips.", body_part(HAND));
		win_pause_output(P_MESSAGE);
		pline("You engrave: \"%s\".",buf);
	}
	oname(obj, buf);
}
示例#2
0
bool BatchCommands::RenameChain(const wxString & oldchain, const wxString & newchain)
{
   // Build the filenames
   wxFileName oname(FileNames::ChainDir(), oldchain, wxT("txt"));
   wxFileName nname(FileNames::ChainDir(), newchain, wxT("txt"));

   // Rename it...wxRenameFile will display errors
   return wxRenameFile(oname.GetFullPath(), nname.GetFullPath());
}
示例#3
0
文件: mkobj.c 项目: DanielT/NitroHack
/* make a new corpse or statue, uninitialized if a statue (i.e. no books) */
struct obj *mk_named_object(int objtype,	/* CORPSE or STATUE */
			    const struct permonst *ptr,
			    int x, int y,
			    const char *nm)
{
	struct obj *otmp;

	otmp = mkcorpstat(objtype, NULL, ptr,
				level, x, y, (boolean)(objtype != STATUE));
	if (nm)
		otmp = oname(otmp, nm);
	return otmp;
}
示例#4
0
文件: do_name.c 项目: FredrIQ/nhfourk
/*
 * This routine changes the address of obj. Be careful not to call it
 * when there might be pointers around in unknown places. For now: only
 * when obj is in the inventory.
 */
int
do_oname(const struct nh_cmd_arg *arg)
{
    const char *qbuf, *buf;
    const char *aname;
    short objtyp;
    struct obj *obj;

    obj = getargobj(arg, nameable, "name");
    if (!obj)
        return 0;

    qbuf = msgprintf("What do you want to name %s %s?",
                     is_plural(obj) ? "these" : "this",
                     safe_qbuf("", sizeof("What do you want to name these ?"),
                               xname(obj), simple_typename(obj->otyp),
                               is_plural(obj) ? "things" : "thing"));
    buf = getarglin(arg, qbuf);
    if (!*buf || *buf == '\033')
        return 0;
    /* strip leading and trailing spaces; unnames item if all spaces */
    buf = msgmungspaces(buf);

    /* relax restrictions over proper capitalization for artifacts */
    if ((aname = artifact_name(buf, &objtyp)) != 0 && objtyp == obj->otyp)
        buf = aname;

    char slipbuf[strlen(buf) + 1];
    if (obj->oartifact) {
        pline("The artifact seems to resist the attempt.");
        return 0;
    } else if (restrict_name(obj, buf) || exist_artifact(obj->otyp, buf)) {
        int n = rn2((int)strlen(buf));
        char c1, c2;
        strcpy(slipbuf, buf);

        c1 = lowc(buf[n]);
        do
            c2 = 'a' + rn2('z' - 'a' + 1);
        while (c1 == c2);

        slipbuf[n] = (slipbuf[n] == c1) ? c2 : highc(c2);   /* keep same case */
        pline("While engraving your %s slips.", body_part(HAND));
        win_pause_output(P_MESSAGE);
        pline("You engrave: \"%s\".", slipbuf);
        buf = slipbuf;
    }
    oname(obj, buf);
    return 0;
}
示例#5
0
/* make a new corpse or statue, uninitialized if a statue (i.e. no books) */
struct obj *
mk_named_object(int objtype, struct permonst *ptr, int x, int y, const char *nm)
            	/* CORPSE or STATUE */
                     
         
               
{
    struct obj *otmp;

    otmp = mkcorpstat(objtype, (struct monst *)0, ptr,
                      x, y, (boolean)(objtype != STATUE));
    if (nm)
        otmp = oname(otmp, nm);
    return(otmp);
}
示例#6
0
/*ARGSUSED*/
STATIC_OVL void
newmail(struct mail_info *info)
{
    struct monst *md;
    coord start, stop;
    boolean message_seen = FALSE;

    /* Try to find good starting and stopping places. */
    if (!md_start(&start) || !md_stop(&stop,&start)) goto give_up;

    /* Make the daemon.  Have it rush towards the hero. */
    if (!(md = makemon(&mons[PM_MAIL_DAEMON], start.x, start.y, NO_MM_FLAGS)))
        goto give_up;
    if (!md_rush(md, stop.x, stop.y)) goto go_back;

    message_seen = TRUE;
    verbalize("%s, %s!  %s.", Hello(md), plname, info->display_txt);

    if (info->message_typ) {
        struct obj *obj = mksobj(SCR_MAIL, FALSE, FALSE);
        if (info->message_typ == MSG_HINT) obj->spe = MAIL_HINT;
        if (distu(md->mx,md->my) > 2)
            verbalize("Catch!");
        display_nhwindow(WIN_MESSAGE, FALSE);
        if (info->object_nam) {
            obj = oname(obj, info->object_nam);
            if (info->response_cmd) {	/*(hide extension of the obj name)*/
                int namelth = info->response_cmd - info->object_nam - 1;
                if ( namelth <= 0 || namelth >= (int) obj->onamelth )
                    warning("mail delivery screwed up");
                else
                    *(ONAME(obj) + namelth) = '\0';
                /* Note: renaming object will discard the hidden command. */
            }
        }
        obj = hold_another_object(obj, "Oops!",
                                  (const char *)0, (const char *)0);
    }

    /* zip back to starting location */
go_back:
    (void) md_rush(md, start.x, start.y);
    mongone(md);
    /* deliver some classes of messages even if no daemon ever shows up */
give_up:
    if (!message_seen && info->message_typ == MSG_OTHER)
        pline("Hark!  \"%s.\"", info->display_txt);
}
RemoteDevice::~RemoteDevice()
{
	DBus::SignalMessage sig("DeviceOutOfRange");

	const char* name = oname().c_str();

	sig.append
	(
		DBUS_TYPE_STRING, &(name),
		DBUS_TYPE_INVALID
	);
	_parent->emit_signal(sig);


//	delete _services;
}
示例#8
0
文件: kdvi.cpp 项目: xwizard/kde1
void kdvi::openFile( QString name)
{
    if ( name.isEmpty() )
        return;
    QString oname( name );
    name.detach();
    if ( ! QFileInfo( name ).isReadable() )
        name.append( ".dvi" );
    if ( ! QFileInfo( name ).isReadable() )
    {
        QMessageBox::information( this, i18n("Notice"),
                                  QString(i18n("Can't read file:\n")) +
                                  oname, i18n("OK"));
        return;
    }
    QDir::setCurrent( QFileInfo( name ).dirPath() );
    dviName = name.copy();
    message( i18n("Opening ") + name + " ...");

    makeStatusBar( dviName );
    applyShowStatusbar();
    dviwin->setFile( name );
    dviwin->repaint();
    setCaption( QString()+kapp->getCaption()+": "+name );
    setPage();
    shrinkChanged( dviwin->shrink() );
    if (-1==recent.find(name))
    {
        recent.insert(0,name);
        if (recent.count()>(unsigned)recentmax)
            recent.removeLast();
        config->setGroup("RecentFiles");
        int i=recent.count();
        while ( i-->0 )
            config->writeEntry(QString().setNum(i),
                               recent.at(i));
        config->setGroup( "kdvi" );
        recentmenu->clear();
        for (int n=recent.count(); n-->0;)
            recentmenu->insertItem( recent.at(n), n, 0 );
    }
    updateMarklist();
    message( i18n("Opened ") + name );
}
RemoteDevice::RemoteDevice( Device* parent, Hci::RemoteInfo& info )
:	HciRemote(parent,info),
	SdpBrowser(parent->addr(),info.addr),
	DBus::LocalObject(_gen_rem_name(parent,info.addr), DBus::Connection::SystemBus()),

	_parent(parent)
{
//	_services = new ServiceDatabase( this->oname(), std::string(""));

	DBus::SignalMessage sig("DeviceInRange");

	const char* name = oname().c_str();

	sig.append
	(
		DBUS_TYPE_STRING, &(name),
		DBUS_TYPE_INVALID
	);
	_parent->emit_signal(sig);
}
示例#10
0
/*
   Make an artifact.  If a specific alignment is specified, then an object of
   the appropriate alignment is created from scratch, or 0 is returned if
   none is available.  (If at least one aligned artifact has already been
   given, then unaligned ones also become eligible for this.)
   If no alignment is given, then 'otmp' is converted
   into an artifact of matching type, or returned as-is if that's not possible.
   For the 2nd case, caller should use ``obj = mk_artifact(obj, A_NONE);''
   for the 1st, ``obj = mk_artifact(NULL, some_alignment);''.
 */
struct obj *mk_artifact(
    struct obj *otmp,	/* existing object; ignored if alignment specified */
    aligntyp alignment	/* target alignment, or A_NONE */
    )
{
	const struct artifact *a;
	int n, m;
	boolean by_align = (alignment != A_NONE);
	short o_typ = (by_align || !otmp) ? 0 : otmp->otyp;
	boolean unique = !by_align && otmp && objects[o_typ].oc_unique;
	short eligible[NROFARTIFACTS];

	/* gather eligible artifacts */
	for (n = 0, a = artilist+1, m = 1; a->otyp; a++, m++)
	    if ((!by_align ? a->otyp == o_typ :
		    (a->alignment == alignment ||
			(a->alignment == A_NONE && u.ugifts > 0))) &&
		(!(a->spfx & SPFX_NOGEN) || unique) && !artiexist[m]) {
		if (by_align && a->race != NON_PM && race_hostile(&mons[a->race]))
		    continue;	/* skip enemies' equipment */
		else if (by_align && Role_if (a->role))
		    goto make_artif;	/* 'a' points to the desired one */
		else
		    eligible[n++] = m;
	    }

	if (n) {		/* found at least one candidate */
	    m = eligible[rn2(n)];	/* [0..n-1] */
	    a = &artilist[m];

	    /* make an appropriate object if necessary, then christen it */
make_artif: if (by_align) otmp = mksobj(level, (int)a->otyp, TRUE, FALSE);
	    otmp = oname(otmp, a->name);
	    otmp->oartifact = m;
	    artiexist[m] = TRUE;
	} else {
	    /* nothing appropriate could be found; return the original object */
	    if (by_align) otmp = 0;	/* (there was no original object) */
	}
	return otmp;
}
示例#11
0
/*
 * Get a random player name and class from the high score list,
 * and attach them to an object (for statues or morgue corpses).
 */
struct obj *
tt_oname(struct obj *otmp)
{
    int rank, fd;
    struct toptenentry *toptenlist, *tt;

    if (!otmp)
        return NULL;

    fd = open_datafile(RECORD, O_RDONLY, SCOREPREFIX);
    toptenlist = read_topten(fd, 100);  /* load the top 100 scores */
    close(fd);

    /* try to find a valid entry, reducing the value range for rank each time */
    rank = rn2(100);
    while (!validentry(toptenlist[rank]) && rank)
        rank = rn2(rank);

    tt = &toptenlist[rank];

    if (!validentry(toptenlist[rank]))
        otmp = NULL;    /* the topten list is empty */
    else {
        /* reset timer in case corpse started out as lizard or troll */
        if (otmp->otyp == CORPSE)
            obj_stop_timers(otmp);
        otmp->corpsenm = classmon(tt->plrole, (tt->plgend[0] == 'F'));
        otmp->owt = weight(otmp);
        otmp = oname(otmp, tt->name);
        if (otmp->otyp == CORPSE)
            start_corpse_timeout(otmp);
    }

    free(toptenlist);
    return otmp;
}
示例#12
0
// ######################################################################
FfmpegEncoder::FfmpegEncoder(const std::string& fname,
                             const std::string& codecname,
                             const int bitrate,
                             const int framerate,
                             const int frameratebase,
                             const Dims& dims,
                             const int bufsz,
                             const bool useFormatContext)
  :
  itsFile(0),
  itsContext(),
  itsFormatContext(0),
  itsFrameNumber(0),
  itsOutbufSize(bufsz),
  itsFrameSizeRange(),
  itsUseFormatContext(useFormatContext)
{
  GVX_TRACE(__PRETTY_FUNCTION__);

  // no need to guard these functions for being called multiple times;
  // they all have internal guards
  av_register_all();
  avcodec_init();
  avcodec_register_all();

  AVOutputFormat* oformat = NULL;

#if LIBAVCODEC_VERSION_MAJOR >= 53 && LIBAVCODEC_VERSION_MINOR >= 21

	if (codecname.compare("List") == 0) { // list available codecs
      LINFO("##### Available output codecs (not all may work for video):");
      AVOutputFormat* f = av_oformat_next(NULL);
      while(f) {
        LINFO("%s: %s %d", f->name, f->long_name, f->flags);
        f = av_oformat_next(f);
      }
      LFATAL("Please select a codec from this list");
	} else { // format is given
      // no av_find_output_format()?? let's do it by hand...
      AVOutputFormat* f = av_oformat_next(NULL);
      while(f) {
        if (codecname.compare(f->name) == 0) { oformat = f; break; }
        f = av_oformat_next(f);
      }
	}

#else
  if (codecname.compare("List") == 0) { // list available codecs
    LINFO("##### Available output codecs (not all may work for video):");
    for(AVOutputFormat* f = first_oformat; f != NULL; f = f->next)
      LINFO("%s: %s %d", f->name, f->long_name, f->flags);
    LFATAL("Please select a codec from this list");
  } else { // format is given
    // no av_find_output_format()?? let's do it by hand...
    for(AVOutputFormat* f = first_oformat; f != NULL; f = f->next)
      if (codecname.compare(f->name) == 0)
        { oformat = f; break; }
  }
#endif

  if (oformat == 0)
    LFATAL("No such video codec '%s';\n"
           "try re-running with --output-codec=List to see a list\n"
           "of available codecs", codecname.c_str());

  char ext[100]; ext[0] = '.'; uint i;
  for (i = 0; i < strlen(oformat->extensions); i ++)
    if (oformat->extensions[i] == ',') break;
    else ext[i+1] = oformat->extensions[i];
  ext[i+1] = '\0';
  LINFO("Using output format '%s' (%s), extension %s", oformat->name,
        oformat->long_name, ext);

  std::string oname(fname);
  std::string::size_type idx1 = oname.rfind('/', oname.npos);
  std::string::size_type idx2 = oname.rfind('.', oname.npos);
  // must check that idx2 is valid; otherwise if we do
  // oname.erase(idx2) with e.g. idx2==npos then we will get a
  // std::out_of_range exception
  if (idx2 < oname.size() && idx2 > idx1)
    oname.erase(idx2, oname.npos);
  oname.append(ext);
  LINFO("Output file: %s", oname.c_str());

        if (itsUseFormatContext)
        {
#ifdef INVT_FFMPEG_HAS_FORMATCONTEXT_FUNCTIONS
                LINFO("Using FormatContext to output data");
#ifdef AVMEDIA_TYPE_VIDEO
		itsFormatContext = avformat_alloc_context();
#else
                itsFormatContext = av_alloc_format_context();
#endif

                if (!itsFormatContext)
                        LFATAL("Cannot allocate format context");
                itsFormatContext->oformat = oformat;

                itsAVStream = av_new_stream(itsFormatContext, 0);
                if (!itsAVStream)
                        LFATAL("Can not allocate AVStream");
#else
    LFATAL("Need a new version of ffmpeg libs for this option");
    itsFormatContext = NULL;
#endif
        }

  AVCodec* const codec = avcodec_find_encoder(oformat->video_codec);
  if (codec == NULL)  LFATAL("codec not found");

#if defined(INVT_FFMPEG_HAS_DEFAULTS_FUNCTIONS)
  avcodec_get_context_defaults(&itsContext);
#else
  {
    AVCodecContext* const tmp = avcodec_alloc_context();
    memcpy(&itsContext, tmp, sizeof(AVCodecContext));
    free(tmp);
  }
#endif

  itsContext.bit_rate = bitrate;

  // Be sure to set itsContext.pix_fmt -- it may occasionally
  // appear to work to leave pix_fmt unset, because the value we want,
  // PIX_FMT_YUV420P, has the enum value of 0, so if the uninitialized
  // memory for pix_fmt happens to have the value 0, then we'll slip
  // through without setting it explicitly.
  itsContext.pix_fmt = PIX_FMT_YUV420P;

  /* resolution must be a multiple of two */
  itsContext.width = dims.w();
  itsContext.height = dims.h();
#if defined(INVT_FFMPEG_AVCODECCONTEXT_HAS_TIME_BASE)
  AVRational time_base = { frameratebase, framerate };
  itsContext.time_base = time_base;
  const int frb = frameratebase;
#elif LIBAVCODEC_VERSION_INT >= 0x000406 && LIBAVCODEC_BUILD > 4665
  itsContext.frame_rate = framerate;
  const int frb = frameratebase;
  itsContext.frame_rate_base = frb;
#else
  itsContext.frame_rate = framerate;
  const int frb = FRAME_RATE_BASE;
#endif
  itsContext.gop_size = 10; /* emit one intra frame every ten frames */

  if(codec->id != CODEC_ID_MPEG4 &&
     codec->id != CODEC_ID_MPEG1VIDEO &&
     codec->id != CODEC_ID_MPEG2VIDEO)
    itsContext.max_b_frames = 0;
  else
    itsContext.max_b_frames = 1;

  itsFrameNumber = 0;

  LINFO("using max_b_frames=%i bitrate=%u width=%u height=%u framerate=%u frameratebase=%u",
        itsContext.max_b_frames, itsContext.bit_rate, itsContext.width, itsContext.height, framerate, frb);

  if (avcodec_open(&itsContext, codec) < 0)
    LFATAL("could not open codec\n");

        if (itsUseFormatContext)
        {
#ifdef INVT_FFMPEG_HAS_FORMATCONTEXT_FUNCTIONS
                AVCodecContext *c = itsAVStream->codec;
                c->codec_id = itsContext.codec_id;
#ifdef CODEC_TYPE_VIDEO
                c->codec_type = CODEC_TYPE_VIDEO;
#else
#ifdef AVMEDIA_TYPE_VIDEO
                c->codec_type = AVMEDIA_TYPE_VIDEO;
#endif
#endif



                /* put sample parameters */
                c->bit_rate = itsContext.bit_rate;
                /* resolution must be a multiple of two */
                c->width = itsContext.width;
                c->height = itsContext.height;
                /* time base: this is the fundamental unit of time (in seconds) in terms
                         of which frame timestamps are represented. for fixed-fps content,
                         timebase should be 1/framerate and timestamp increments should be
                         identically 1. */
#if defined(INVT_FFMPEG_AVCODECCONTEXT_HAS_TIME_BASE)
                c->time_base.den = itsContext.time_base.den;
                c->time_base.num = itsContext.time_base.num;
#endif
                c->gop_size = 12; /* emit one intra frame every twelve frames at most */
                c->pix_fmt = itsContext.pix_fmt;

                /* set the output parameters (must be done even if no
                         parameters). */
                if (av_set_parameters(itsFormatContext, NULL) < 0)
                        LFATAL("Invalid output format parameters");

#if defined(INVT_FFMPEG_URL_OPEN_FUNC_TAKES_SINGLE_POINTER)

#if defined(INVT_FFMPEG_AVFORMATCONTEXT_BYTEIO_ISPOINTER)
                if (url_fopen(itsFormatContext->pb, oname.c_str(), URL_WRONLY) < 0)
                        LFATAL("Could not open '%s'", oname.c_str());
#else
                if (url_fopen(&itsFormatContext->pb, oname.c_str(), URL_WRONLY) < 0)
                        LFATAL("Could not open '%s'", oname.c_str());
#endif

#else

#if defined(INVT_FFMPEG_AVFORMATCONTEXT_BYTEIO_ISPOINTER)
                if (url_fopen(&itsFormatContext->pb, oname.c_str(), URL_WRONLY) < 0)
                        LFATAL("Could not open '%s'", oname.c_str());
#else
                        LFATAL("Could not open '%s' ffmpeg version mismatch", oname.c_str());
#endif

#endif //INVT_FFMPEG_URL_OPEN_FUNC_TAKES_SINGLE_POINTER)



                /* write the stream header, if any */
                av_write_header(itsFormatContext);
#else
    LFATAL("Need a new version of FFMPEG for this option");
#endif
        } else {
                itsFile = fopen(oname.c_str(), "w");
                if (itsFile==NULL)
                  LFATAL("could not open file! %s", oname.c_str());
        }

  LINFO("EnCoder Inited");
}
示例#13
0
STDMETHODIMP CUUEngine::Encode(
BSTR i_iname, BSTR i_oname, BSTR i_nameinfile, 
long encoding, long lines, long headers, 
VARIANT destvar, VARIANT fromvar, VARIANT subjectvar, 
long *retVal)
{
	FILE *outf;
	int rc, partno;
	char *onp, *extp, *partname;
	const char *dest, *from, *subject;
	MString deststr, fromstr, subjstr;
	MString iname(i_iname), oname(i_oname), nameinfile(i_nameinfile);

	dest = (const char *) destvar.bstrVal;
	if (destvar.vt != VT_BSTR || *dest == EOS)
		dest = NULL;
	else {
		deststr = destvar.bstrVal;
		dest = (const char *) deststr;
		}

	from = (const char *) fromvar.bstrVal;
	if (fromvar.vt != VT_BSTR || *from == EOS)
		from = NULL;
	else {
		fromstr = fromvar.bstrVal;
		from = (const char *) fromstr;
		}

	subject = (const char *) subjectvar.bstrVal;
	if (subjectvar.vt != VT_BSTR || *subject == EOS)
		subject = NULL;
	else {
		subjstr = subjectvar.bstrVal;
		subject = (const char *) subjstr;
		}

	if (nameinfile != NULL && nameinfile[0] != EOS)
		onp = nameinfile.GetBuffer();				// Caller has specified a name
	else {								// Generate our own
		if ((onp = strrchr(iname, '\\')) == NULL) {		// Look for last slash
			if ((onp = strrchr(iname, ':')) == NULL)
				onp = iname.GetBuffer();			// No colons, either
			else
				onp++;					// Point just past colon
			}
		else
			onp++;						// Point just past last slash
		}

	if (lines == 0 && (extp = strrchr(oname, '.')) != NULL) 	// Set single-part extension
		ue.UUSetOption(UUOPT_ENCEXT, 0, extp+1);

	if (headers) {							// User wants headers
		if (lines == 0) {					// Single file
			if (!OWriteOK && FExist(oname)) {		// Can't overwrite output file
				MessageHandler("Output file exists", UUMSG_ERROR);
				*retVal = UURET_EXISTS;
				return(S_OK);
				}

			if ((outf = fopen(oname, "w")) == NULL) {
				MessageHandler("Could not open output file", 1);
				*retVal = UURET_IOERR;
				return(S_OK);
				}

			NewStep();					// Warn the owner

			if (headers == UUVBE_SIMPLE)
				rc = ue.UUEncodeMulti(outf, NULL, iname.GetBuffer(), encoding, onp, NULL, 0);
			else
				rc = ue.UUE_PrepSingle(outf, NULL, iname.GetBuffer(), encoding, onp, 0,
					(char *) dest, (char *) from, (char *) subject, (headers == UUVBE_MAIL));

			fclose(outf);
			}
		else {								// Multi part
			MString partlocal(oname);		// Copy the output name
			partname = partlocal.GetBuffer(strlen(oname) + 10);		// Grab the buffer

			if ((extp = strrchr(partname, '.')) == NULL) {	// No extension?  Add one...
				extp = partname + strlen(partname);
				*extp++ = '.';
				}
			else
				extp++;						// Just past the last period

			partno = 1;						// First part

			do {							// Always have at least one...
				sprintf(extp, "%03d", partno);

				if (!OWriteOK && FExist(partname)) {		// Can't overwrite output file
					MessageHandler("Output file exists", UUMSG_ERROR);
					*retVal = UURET_EXISTS;
					return(S_OK);
					}

				if ((outf = fopen(partname, "w")) == NULL) 
				{
					MessageHandler("Error opening output file.", 1);
					*retVal = UURET_IOERR;
					return(S_OK);
				}

				NewStep();					// Warn the owner

				crc32_t lcr = 0;

				if (headers == UUVBE_SIMPLE)
					rc = ue.UUEncodePartial(outf, NULL, iname.GetBuffer(), encoding, onp, NULL,
						0, partno++, (int) lines, &lcr);
				else
					rc = ue.UUE_PrepPartial(outf, NULL, iname.GetBuffer(), encoding, onp, 0,
						partno++, (int) lines, 0, (char *) dest, (char *) from, (char *) subject,
						(headers == UUVBE_MAIL));

				fclose(outf);
				} while (rc == UURET_CONT);

			}
		}
	else {
		NewStep();					// Warn the owner
		rc = ue.UUEncodeToFile(NULL, iname.GetBuffer(), encoding, 
			onp, oname.GetBuffer(), (int) lines);
		}

	*retVal = rc;

	return S_OK;
}
示例#14
0
文件: QDwfBuilder.cpp 项目: jyamu/qmc
bool QDwfBuilder::put(xmlNodePtr cur)
{
    typedef DiracDeterminant<SPOSet_t> DDet_t;
    typedef SlaterDeterminant<SPOSet_t> SDet_t;
    map<string,QDwf*> qdwfs;
    int nbasis=0;
    SDet_t* sdet = new SDet_t;
    cur = cur->xmlChildrenNode;         /// cur->name = DeterminantSet
    while(cur!=NULL)
    {
        string cname((const char*)(cur->name));
        if(cname =="SlaterDeterminant")
        {
            int first = 0;
            xmlNodePtr tcur = cur->xmlChildrenNode;
            while(tcur != NULL)
            {
                string cname2((const char*)(tcur->name));
                if(cname2 == "Determinant")
                {
                    SPOSet_t* swfs = new SPOSet_t;
                    int norb
                        =atoi((const char*)(xmlGetProp(tcur, (const xmlChar *)"orbitals"))) ;
                    XMLReport("The number of orbitals for a Dirac Determinant " << norb)
                    xmlNodePtr t = tcur->xmlChildrenNode;
                    while(t != NULL)
                    {
                        string oname((const char*)(t->name));
                        if(oname == "Orbital")
                        {
                            string
                            orbname((const char*)(xmlGetProp(t, (const xmlChar *)"name")));
                            map<string,QDwf*>::iterator it = qdwfs.find(orbname);
                            if(it  == qdwfs.end())
                            {
                                XMLReport("Adding a new orbital " << orbname)
                                QDwf *neworb = new QDwf();
                                neworb->put(t,wfs_ref.VarList);
                                swfs->add(neworb);
                                qdwfs[oname] = neworb;
                            }
                            else
                            {
                                XMLReport("Using an existing " << orbname)
                                swfs->add((*it).second);
                            }
                        }
                        t = t->next;
                    }
                    XMLReport("The number of basis functions " << swfs->size())
                    DDet_t* ddet = new DDet_t(*swfs,first);
                    ddet->set(first,swfs->size());
                    XMLReport("Adding a determinant to the SlaterDeterminant of size "
                              << swfs->size() << " begining with orbital " << first)
                    first += swfs->size();
                    sdet->add(ddet);
                } //dirac-determinant
                tcur = tcur->next;
            }
        }//slater-determinant
        cur = cur->next;
    }
    wfs_ref.add(sdet);
    return true;
}
示例#15
0
int PhysicalSideworks::addFixedConection(const graph_t::vertex_descriptor& u,const graph_t::vertex_descriptor& v,const std::string& o,const std::string& i){
	int width = fuList[v]->getInputPort(i)->getWidth();
	std::string oname(o + std::to_string(width));
	fuList[u]->addOutputPort(oname,width);
	return addConection(u,v,oname,i);
}