Пример #1
0
 PrimeTable(T limit) {
     limit = (limit+31) / 32 * 32;
     array.resize(limit / 32, -1);
     setf(0); setf(1); T d, n;
     for (d=2; d*d<limit; ++d) if(isPrime(d)) {
         for (n=d+d; n<limit; n+=d) {setf(n);}
     }
     plist.push_back(0); for (n=1; n<limit; ++n) {
         if (isPrime(n)) {plist.push_back(n);}
     }
 }
Пример #2
0
 inline void set_timezone(timezone tz)
 {
   if (tz == timezone::local)
     setf(uses_local);
   else
     unsetf(uses_local);
 }
void Shape_GetCenter(avm *vm)
{
    word w;
    long off = newtable(vm, ZEN_INITIALTABLESIZE);
    long tindex = TOTinsert(vm, off);
    ctable* tbl = (ctable*)getdata(vm->hp.heap, off);
    word index, source;
    sets(&index, newstring(vm, "X"));
    setf(&source, sfShape_GetCenterX(getint(vm, 0)));
    IA(vm, tbl, tindex, &index, &source);
    sets(&index, newstring(vm, "Y"));
    setf(&source, sfShape_GetCenterY(getint(vm, 0)));
    IA(vm, tbl, tindex, &index, &source);
    sett(&w, tindex);
    returnv(vm, &w);
}
Пример #4
0
 inline void set_duration_style(duration_style style)
 {
   if (style == duration_style::symbol)
     setf(uses_symbol);
   else
     unsetf(uses_symbol);
 }
Пример #5
0
MyAVIError::MyAVIError(const char *s, uint32 avierr) {
	const char *err = "(Unknown)";

	switch(avierr) {
	case AVIERR_UNSUPPORTED:		err = "unsupported"; break;
	case AVIERR_BADFORMAT:			err = "bad format"; break;
	case AVIERR_MEMORY:				err = "out of memory"; break;
	case AVIERR_INTERNAL:			err = "internal error"; break;
	case AVIERR_BADFLAGS:			err = "bad flags"; break;
	case AVIERR_BADPARAM:			err = "bad parameters"; break;
	case AVIERR_BADSIZE:			err = "bad size"; break;
	case AVIERR_BADHANDLE:			err = "bad AVIFile handle"; break;
	case AVIERR_FILEREAD:			err = "file read error"; break;
	case AVIERR_FILEWRITE:			err = "file write error"; break;
	case AVIERR_FILEOPEN:			err = "file open error"; break;
	case AVIERR_COMPRESSOR:			err = "compressor error"; break;
	case AVIERR_NOCOMPRESSOR:		err = "compressor not available"; break;
	case AVIERR_READONLY:			err = "file marked read-only"; break;
	case AVIERR_NODATA:				err = "no data (?)"; break;
	case AVIERR_BUFFERTOOSMALL:		err = "buffer too small"; break;
	case AVIERR_CANTCOMPRESS:		err = "can't compress (?)"; break;
	case AVIERR_USERABORT:			err = "aborted by user"; break;
	case AVIERR_ERROR:				err = "error (?)"; break;
	}

	setf("%s error: %s (%08lx)", s, err, avierr);
}
Пример #6
0
void abstract_broker::init_broker() {
  CAF_LOG_TRACE("");
  setf(is_initialized_flag);
  // launch backends now, because user-defined initialization
  // might call functions like add_connection
  for (auto& kvp : doormen_)
    kvp.second->launch();

}
void Shape_GetPointPosition(avm *vm)
{
    float X, Y;
    sfShape_GetPointPosition(getint(vm, 0), getint(vm, 1), &X, &Y);
    word w;
    long off = newtable(vm, ZEN_INITIALTABLESIZE);
    long tindex = TOTinsert(vm, off);
    ctable* tbl = (ctable*)getdata(vm->hp.heap, off);
    word index, source;
    sets(&index, newstring(vm, "X"));
    setf(&source, X);
    IA(vm, tbl, tindex, &index, &source);
    sets(&index, newstring(vm, "Y"));
    setf(&source, Y);
    IA(vm, tbl, tindex, &index, &source);
    sett(&w, tindex);
    returnv(vm, &w);
}
Пример #8
0
R_API void r_anal_hint_del (RAnal *a, ut64 addr, int size) {
	char key[128];
	if (size>1) {
		eprintf ("TODO: r_anal_hint_del: in range\n");
	} else {
		setf (key, "hint.0x%08"PFMT64x, addr);
		sdb_unset (a->sdb_hints, key, 0);
	}
}
Пример #9
0
R_API RAnalHint *r_anal_hint_get(RAnal *a, ut64 addr) {
	char key[64];
	setf (key, "hint.0x%08"PFMT64x, addr);
	const char *s = sdb_const_get (DB, key, 0);
	if (!s) {
		return NULL;
	}
	return r_anal_hint_from_string (a, addr, s);
}
Пример #10
0
void Foam::functionObjects::writeFile::writeHeader
(
    Ostream& os,
    const string& str
) const
{
    os  << setw(1) << "#" << setw(1) << ' '
        << setf(ios_base::left) << setw(charWidth() - 2) << str.c_str() << nl;
}
Пример #11
0
iostream::iostream( streambuf *sb ) {
/***********************************/
// Public constructor, making an iostream with a streambuf attached.
// No point in calling non-default constructors since there are
// multiply-inherited derived classes that will only call the default
// constructors anyway.

    ios::init( sb );
    setf( ios::skipws );
}
Пример #12
0
static void unsetHint(RAnal *a, const char *type, ut64 addr) {
	int idx;
	char key[128];
	setf (key, "hint.0x%08"PFMT64x, addr);
	idx = sdb_array_indexof (DB, key, type, 0);
	if (idx != -1) {
		sdb_array_delete (DB, key, idx, 0);
		sdb_array_delete (DB, key, idx, 0);
	}
}
Пример #13
0
MyICError::MyICError(uint32 icErr, const char *format, ...) {
	char tmpbuf[1024];

	va_list val;
	va_start(val, format);
	tmpbuf[(sizeof tmpbuf) - 1] = 0;
	_vsnprintf(tmpbuf, (sizeof tmpbuf) - 1, format, val);
	va_end(val);

	setf(tmpbuf, GetVCMErrorString(icErr));
}
Пример #14
0
MyInternalError::MyInternalError(const char *format, ...) {
	char buf[1024];
	va_list val;

	va_start(val, format);
	_vsnprintf(buf, (sizeof buf) - 1, format, val);
	buf[1023] = 0;
	va_end(val);

	setf("Internal error: %s", buf);
}
Пример #15
0
void Foam::functionObjects::writeFile::writeHeaderValue
(
    Ostream& os,
    const string& property,
    const Type& value
) const
{
    os  << setw(1) << '#' << setw(1) << ' '
        << setf(ios_base::left) << setw(charWidth() - 2) << property.c_str()
        << setw(1) << ':' << setw(1) << ' ' << value << nl;
}
Пример #16
0
R_API RAnalHint *r_anal_hint_get(RAnal *a, ut64 addr) {
	char key[128];
	const char *s;
	RAnalHint *hint;

	setf (key, "hint.0x%"PFMT64x, addr);
	s = sdb_const_get (DB, key, 0);
	if (!s) {
		return NULL;
	}
	hint = r_anal_hint_from_string (a, addr, s);
	return hint;
}
Пример #17
0
TimeF::TimeF(
    const t_longf time
,   const t_longf secondsPerCycle)
:   m_timer(new osg::Timer())
,   m_secondsPerCycle(secondsPerCycle)
,   m_mode(M_Pausing)
,   m_offset(0.f)
,   m_lastModeChangeTime(0.f)
,   m_utcOffset(0)
{
    initialize();
    setf(time, true);
}
Пример #18
0
static void setHint (RAnal *a, const char *type, ut64 addr, const char *s, ut64 ptr) {
	int idx;
	char key[128], val[128], *nval = NULL;
	setf (key, "hint.0x%"PFMT64x, addr);
	idx = sdb_array_indexof (DB, key, type, 0);
	if (s) nval = sdb_encode ((const ut8*)s, -1);
	else nval = sdb_itoa (ptr, val, 16);
	if (idx != -1) {
		if (!s) nval = sdb_itoa (ptr, val, 16);
		sdb_array_set (DB, key, idx+1, nval, 0);
	} else {
		sdb_array_push (DB, key, nval, 0);
		sdb_array_push (DB, key, type, 0);
	}
	if (s) free (nval);
}
Пример #19
0
Foam::ensightFile::ensightFile
(
    const fileName& pathname,
    IOstream::streamFormat format
)
:
    OFstream(pathname, format)
{
    // ascii formatting specs
    setf
    (
        ios_base::scientific,
        ios_base::floatfield
    );
    precision(5);
}
Пример #20
0
MyCrashError::MyCrashError(const char *format, uint32 dwExceptionCode) {
	const char *s = "(Unknown Exception)";

	switch(dwExceptionCode) {
	case EXCEPTION_ACCESS_VIOLATION:
		s = "Access Violation";
		break;
	case EXCEPTION_PRIV_INSTRUCTION:
		s = "Privileged Instruction";
		break;
	case EXCEPTION_INT_DIVIDE_BY_ZERO:
		s = "Integer Divide By Zero";
		break;
	case EXCEPTION_BREAKPOINT:
		s = "User Breakpoint";
		break;
	}

	setf(format, s);
}
Пример #21
0
int main(){
    int n;
    for(int i=1;i<=n;i++)
        for(int m=1;m<=5;m++)
            scanf("%d",stu[i][m]);
    for(int k=1;k<=5;k++){
        for(int i=1;i<=9;i++){
            int cnt=1;
            int equ[1001];
            for(int m=1;m<=n;m++){
                    if(stu[m][k]==i) {
                      equ[cnt++]=k;
                    }
            }
            setf(equ);
        }
    }
    cntf();



}
Пример #22
0
MyMMIOError::MyMMIOError(const char *s, uint32 mmioerr) {
	const char *err = "(Unknown)";

	switch(mmioerr) {
	case MMIOERR_FILENOTFOUND:		err = "file not found"; break;
	case MMIOERR_OUTOFMEMORY:		err = "out of memory"; break;
	case MMIOERR_CANNOTOPEN:		err = "couldn't open"; break;
	case MMIOERR_CANNOTCLOSE:		err = "couldn't close"; break;
	case MMIOERR_CANNOTREAD:		err = "couldn't read"; break;
	case MMIOERR_CANNOTWRITE:		err = "couldn't write"; break;
	case MMIOERR_CANNOTSEEK:		err = "couldn't seek"; break;
	case MMIOERR_CANNOTEXPAND:		err = "couldn't expand"; break;
	case MMIOERR_CHUNKNOTFOUND:		err = "chunk not found"; break;
	case MMIOERR_UNBUFFERED:		err = "unbuffered"; break;
	case MMIOERR_PATHNOTFOUND:		err = "path not found"; break;
	case MMIOERR_ACCESSDENIED:		err = "access denied"; break;
	case MMIOERR_SHARINGVIOLATION:	err = "sharing violation"; break;
	case MMIOERR_NETWORKERROR:		err = "network error"; break;
	case MMIOERR_TOOMANYOPENFILES:	err = "too many open files"; break;
	case MMIOERR_INVALIDFILE:		err = "invalid file"; break;
	}

	setf("%s error: %s (%ld)", s, err, mmioerr);
}
Пример #23
0
 iostream::iostream() {
   setf( ios::skipws );
 }
Пример #24
0
MyICError::MyICError(const char *s, uint32 icErr) {
	setf("%s error: %s (error code %ld)", s, GetVCMErrorString(icErr), icErr);
}
Пример #25
0
MyWin32Error::MyWin32Error(const char *format, uint32 err, ...)
	: mWin32Error(err)
{
	char szError[1024];
	char szTemp[1024];
	va_list val;

	va_start(val, err);
	szError[(sizeof szError)-1] = 0;
	_vsnprintf(szError, (sizeof szError)-1, format, val);
	va_end(val);

	// Determine the position of the last %s, and escape everything else. This doesn't
	// track escaped % signs properly, but it works for the strings that we receive (and at
	// worst just produces a funny message).
	const char *keep = strstr(szError, "%s");
	if (keep) {
		for(;;) {
			const char *test = strstr(keep + 1, "%s");

			if (!test)
				break;

			keep = test;
		}
	}

	char *t = szTemp;
	char *end = szTemp + (sizeof szTemp) - 1;
	const char *s = szError;

	while(char c = *s++) {
		if (c == '%') {
			// We allow one %s to go through. Everything else gets escaped.
			if (s-1 != keep) {
				if (t >= end)
					break;

				*t++ = '%';
			}
		}

		if (t >= end)
			break;

		*t++ = c;
	}

	*t = 0;

	if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
			0,
			err,
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
			szError,
			sizeof szError,
			NULL))
	{
		szError[0] = 0;
	}

	if (szError[0]) {
		long l = strlen(szError);

		if (l>1 && szError[l-2] == '\r')
			szError[l-2] = 0;
		else if (szError[l-1] == '\n')
			szError[l-1] = 0;
	}

	setf(szTemp, szError);
}
Пример #26
0
 PSR& operator=(uint32 data) {
   setf(data), sets(data), setx(data), setc(data);
   return *this;
 }
Пример #27
0
static int
copen(int startfd, char *fname, int filemode, int createmode)
{
	struct pathname pn;
	vnode_t *vp, *sdvp;
	file_t *fp, *startfp;
	enum vtype type;
	int error;
	int fd, dupfd;
	vnode_t *startvp;
	proc_t *p = curproc;

	if (startfd == AT_FDCWD) {
		/*
		 * Regular open()
		 */
		startvp = NULL;
	} else {
		/*
		 * We're here via openat()
		 */
		char startchar;

		if (copyin(fname, &startchar, sizeof (char)))
			return (set_errno(EFAULT));

		/*
		 * if startchar is / then startfd is ignored
		 */
		if (startchar == '/')
			startvp = NULL;
		else {
			if ((startfp = getf(startfd)) == NULL)
				return (set_errno(EBADF));
			startvp = startfp->f_vnode;
			VN_HOLD(startvp);
			releasef(startfd);
		}
	}

	if (filemode & FXATTR) {

		/*
		 * Make sure we have a valid request.
		 * We must either have a real fd or AT_FDCWD
		 */

		if (startfd != AT_FDCWD && startvp == NULL) {
			error = EINVAL;
			goto out;
		}

		if (error = pn_get(fname, UIO_USERSPACE, &pn)) {
			goto out;
		}

		if (startfd == AT_FDCWD) {
			mutex_enter(&p->p_lock);
			startvp = PTOU(p)->u_cdir;
			VN_HOLD(startvp);
			mutex_exit(&p->p_lock);
		}

		/*
		 * Verify permission to put attributes on file
		 */

		if ((VOP_ACCESS(startvp, VREAD, 0, CRED()) != 0) &&
		    (VOP_ACCESS(startvp, VWRITE, 0, CRED()) != 0) &&
		    (VOP_ACCESS(startvp, VEXEC, 0, CRED()) != 0)) {
			error = EACCES;
			pn_free(&pn);
			goto out;
		}

		if ((startvp->v_vfsp->vfs_flag & VFS_XATTR) != 0) {
			error = VOP_LOOKUP(startvp, "", &sdvp, &pn,
			    LOOKUP_XATTR|CREATE_XATTR_DIR, rootvp, CRED());
		} else {
			error = EINVAL;
		}
		pn_free(&pn);
		if (error != 0)
			goto out;

		VN_RELE(startvp);
		startvp = sdvp;
	}

	if ((filemode & (FREAD|FWRITE)) != 0) {
		if ((filemode & (FNONBLOCK|FNDELAY)) == (FNONBLOCK|FNDELAY))
			filemode &= ~FNDELAY;
		error = falloc((vnode_t *)NULL, filemode, &fp, &fd);
		if (error == 0) {
#ifdef C2_AUDIT
			if (audit_active)
				audit_setfsat_path(1);
#endif /* C2_AUDIT */
			/*
			 * Last arg is a don't-care term if
			 * !(filemode & FCREAT).
			 */
			error = vn_openat(fname, UIO_USERSPACE, filemode,
			    (int)(createmode & MODEMASK), &vp, CRCREAT,
			    u.u_cmask, startvp);

			if (startvp != NULL)
				VN_RELE(startvp);
			if (error == 0) {
#ifdef C2_AUDIT
				if (audit_active)
					audit_copen(fd, fp, vp);
#endif /* C2_AUDIT */
				if ((vp->v_flag & VDUP) == 0) {
					fp->f_vnode = vp;
					mutex_exit(&fp->f_tlock);
					/*
					 * We must now fill in the slot
					 * falloc reserved.
					 */
					setf(fd, fp);
					return (fd);
				} else {
					/*
					 * Special handling for /dev/fd.
					 * Give up the file pointer
					 * and dup the indicated file descriptor
					 * (in v_rdev). This is ugly, but I've
					 * seen worse.
					 */
					unfalloc(fp);
					dupfd = getminor(vp->v_rdev);
					type = vp->v_type;
					mutex_enter(&vp->v_lock);
					vp->v_flag &= ~VDUP;
					mutex_exit(&vp->v_lock);
					VN_RELE(vp);
					if (type != VCHR)
						return (set_errno(EINVAL));
					if ((fp = getf(dupfd)) == NULL) {
						setf(fd, NULL);
						return (set_errno(EBADF));
					}
					mutex_enter(&fp->f_tlock);
					fp->f_count++;
					mutex_exit(&fp->f_tlock);
					setf(fd, fp);
					releasef(dupfd);
				}
				return (fd);
			} else {
				setf(fd, NULL);
				unfalloc(fp);
				return (set_errno(error));
			}
		}
	} else {
		error = EINVAL;
	}
out:
	if (startvp != NULL)
		VN_RELE(startvp);
	return (set_errno(error));
}
Пример #28
0
 String      (F64 value)                             { setf("%g", value); }
Пример #29
0
 String      (S32 value)                             { setf("%d", value); }
Пример #30
0
void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
{
    Info<< "Mesh stats" << nl
        << "    points:           "
        << returnReduce(mesh.points().size(), sumOp<label>()) << nl;

    label nInternalPoints = returnReduce
    (
        mesh.nInternalPoints(),
        sumOp<label>()
    );

    if (nInternalPoints != -Pstream::nProcs())
    {
        Info<< "    internal points:  " << nInternalPoints << nl;

        if (returnReduce(mesh.nInternalPoints(), minOp<label>()) == -1)
        {
            WarningIn("Foam::printMeshStats(const polyMesh&, const bool)")
                << "Some processors have their points sorted into internal"
                << " and external and some do not." << endl
                << "This can cause problems later on." << endl;
        }
    }

    if (allTopology && nInternalPoints != -Pstream::nProcs())
    {
        label nEdges = returnReduce(mesh.nEdges(), sumOp<label>());
        label nInternalEdges = returnReduce
        (
            mesh.nInternalEdges(),
            sumOp<label>()
        );
        label nInternal1Edges = returnReduce
        (
            mesh.nInternal1Edges(),
            sumOp<label>()
        );
        label nInternal0Edges = returnReduce
        (
            mesh.nInternal0Edges(),
            sumOp<label>()
        );

        Info<< "    edges:            " << nEdges << nl
            << "    internal edges:   " << nInternalEdges << nl
            << "    internal edges using one boundary point:   "
            << nInternal1Edges-nInternal0Edges << nl
            << "    internal edges using two boundary points:  "
            << nInternalEdges-nInternal1Edges << nl;
    }

    label nFaces = returnReduce(mesh.faces().size(), sumOp<label>());
    label nIntFaces = returnReduce(mesh.faceNeighbour().size(), sumOp<label>());
    label nCells = returnReduce(mesh.cells().size(), sumOp<label>());

    Info<< "    faces:            " << nFaces << nl
        << "    internal faces:   " << nIntFaces << nl
        << "    cells:            " << nCells << nl
        << "    faces per cell:   "
        << scalar(nFaces + nIntFaces)/max(1, nCells) << nl
        << "    boundary patches: " << mesh.boundaryMesh().size() << nl
        << "    point zones:      " << mesh.pointZones().size() << nl
        << "    face zones:       " << mesh.faceZones().size() << nl
        << "    cell zones:       " << mesh.cellZones().size() << nl
        << endl;

    // Construct shape recognizers
    hexMatcher hex;
    prismMatcher prism;
    wedgeMatcher wedge;
    pyrMatcher pyr;
    tetWedgeMatcher tetWedge;
    tetMatcher tet;

    // Counters for different cell types
    label nHex = 0;
    label nWedge = 0;
    label nPrism = 0;
    label nPyr = 0;
    label nTet = 0;
    label nTetWedge = 0;
    label nUnknown = 0;

    Map<label> polyhedralFaces;

    for (label cellI = 0; cellI < mesh.nCells(); cellI++)
    {
        if (hex.isA(mesh, cellI))
        {
            nHex++;
        }
        else if (tet.isA(mesh, cellI))
        {
            nTet++;
        }
        else if (pyr.isA(mesh, cellI))
        {
            nPyr++;
        }
        else if (prism.isA(mesh, cellI))
        {
            nPrism++;
        }
        else if (wedge.isA(mesh, cellI))
        {
            nWedge++;
        }
        else if (tetWedge.isA(mesh, cellI))
        {
            nTetWedge++;
        }
        else
        {
            nUnknown++;
            polyhedralFaces(mesh.cells()[cellI].size())++;
        }
    }

    reduce(nHex,sumOp<label>());
    reduce(nPrism,sumOp<label>());
    reduce(nWedge,sumOp<label>());
    reduce(nPyr,sumOp<label>());
    reduce(nTetWedge,sumOp<label>());
    reduce(nTet,sumOp<label>());
    reduce(nUnknown,sumOp<label>());

    Info<< "Overall number of cells of each type:" << nl
        << "    hexahedra:     " << nHex << nl
        << "    prisms:        " << nPrism << nl
        << "    wedges:        " << nWedge << nl
        << "    pyramids:      " << nPyr << nl
        << "    tet wedges:    " << nTetWedge << nl
        << "    tetrahedra:    " << nTet << nl
        << "    polyhedra:     " << nUnknown
        << endl;

    if (nUnknown > 0)
    {
        Pstream::mapCombineGather(polyhedralFaces, plusEqOp<label>());

        Info<< "    Breakdown of polyhedra by number of faces:" << nl
            << "        faces" << "   number of cells" << endl;

        const labelList sortedKeys = polyhedralFaces.sortedToc();

        forAll(sortedKeys, keyI)
        {
            const label nFaces = sortedKeys[keyI];

            Info<< setf(std::ios::right) << setw(13)
                << nFaces << "   " << polyhedralFaces[nFaces] << nl;
        }
    }