コード例 #1
0
ファイル: shell.c プロジェクト: mhbackes/sisop1
/**
Copia arquivo dentro do T2FS
Os parametros são:
    primeiro parametro => arquivo origem
    segundo parametro  => arquivo destino
*/
void cmdCp(void) {

    // Pega os nomes dos arquivos origem e destion
    char *src = strtok(NULL," \t");
    char *dst = strtok(NULL," \t");
    if (src==NULL || dst==NULL) {
        printf ("Missing parameter\n");
        return;
    }
    // Abre o arquivo origem, que deve existir
    FILE2 hSrc = open2 (src);
    if (hSrc<0) {
        printf ("Open source file error: %d\n", hSrc);
        return;
    }
    // Cria o arquivo de destino, que será resetado se existir
    FILE2 hDst = create2 (dst);
    if (hDst<0) {
        close2(hSrc);
        printf ("Create destination file error: %d\n", hDst);
        return;
    }
    // Copia os dados de source para destination
    char buffer[2];
    while( read2(hSrc, buffer, 1) == 1 ) {
        write2(hDst, buffer, 1);
    }
    // Fecha os arquicos
    close2(hSrc);
    close2(hDst);

    printf ("Files successfully copied\n");
}
コード例 #2
0
int main(){
	short i,a,b; int q; char opt;
	read(N);
	for(i=1;i<N;++i) read2(a,b),addEdge(V+a,V+b);
	for(i=1;i<=N;++i) read(V[i].w);
	V->top=V;
	V[1].BuildTree(V,1);
	MakeChain();
	scanf("%d\n",&q);
	while(q--)
		switch(opt=(getchar(),getchar()),read2(a,b),opt){
			case 'H':V[a].Modify(b);break;
			case 'M':writeln(Max(V+a,V+b));break;
			case 'S':writeln(Sum(V+a,V+b));
		}
}
コード例 #3
0
ファイル: P7.C プロジェクト: citrit/ECSE4750
main() {
  int val1, val2;

  read2( val1, val2 );
  int maxVal = max( val1, val2 );
  writeMax( maxVal );
  return 0;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: CCJY/coliru
void read2(int *arrayn,int size)
{
if(size+1)
{
    scanf("%d",arrayn);
    read2(++arrayn,--size);
}
else return;
}
コード例 #5
0
// opens old (readonly) books == old, bugfixed readbook function
void cBooks::openbook_old(UOXSOCKET s, P_ITEM pBook)
{
	unsigned char bookopen[10]="\x93\x40\x01\x02\x03\x00\x00\x00\x02"; //LB 7'th dec 1999, making it client 1.26 complaint
	unsigned char booktitle[61]="\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
	unsigned char bookauthor[31]="\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
	unsigned long loopexit=0;
	
	openscript("misc.scp");
	sprintf((char*)temp, "BOOK %i",	calcserial(pBook->more1, pBook->more2, pBook->more3, pBook->more4));
	if (!i_scripts[misc_script]->find((char*)temp))
	{
		closescript();
		return;
	}
	LongToCharPtr(pBook->serial, &bookopen[1]);
	do
	{
		read2();
	}
	while ( (strcmp((char*)script1, "PAGES")) && (++loopexit < MAXLOOPS) );
	bookopen[8] = (char) str2num(script2); // LB, bugfixing old code

	loopexit=0;
	do
	{
		read2();
	}
	while ( (strcmp((char*)script1, "TITLE")) && (++loopexit < MAXLOOPS) );

	strcpy((char*)(booktitle), script2);

	loopexit=0;
	do
	{
		read2();
	}
	while ( (strcmp((char*)script1, "AUTHOR")) && (++loopexit < MAXLOOPS) );

	strcpy((char*)(bookauthor), script2);
	Xsend(s, bookopen, 9); // LB, bugfixing of old code
	Xsend(s, booktitle, 60);
	Xsend(s, bookauthor, 30);
	closescript();
}
コード例 #6
0
ファイル: ps2drv.cpp プロジェクト: jscrane/r65emu
unsigned PS2Driver::read2() {
	if (head == tail)
		return 0;

	uint8_t i = tail+1;
	if (i == KBD_BUFFER) i = 0;
	tail = i;
	if (buffer[i] != 0xf0)
		return buffer[i];
	return 0xf000 | read2();
}
コード例 #7
0
int main(){
	read2(N,Q);
	for(base=1;base<N;base<<=1); --base;
	l=base+1,r=base+N;
	for(i=l;i<=r;++i) read(max[i]),min[i]=max[i];
	for(l>>=1,r>>=1;l&&r;l>>=1,r>>=1)
		for(i=r;i>=l;--i)
			max[i]=std::max(max[i<<1],max[i<<1^1]),
			min[i]=std::min(min[i<<1],min[i<<1^1]);
	int maxs,mins;
	while(Q--){
		read2(l,r);
		maxs=0;mins=0x7fffffff;
		for(l+=base-1,r+=base+1;l^r^1;l>>=1,r>>=1){
			if(!(l&1)) maxi(maxs,max[l^1]),mini(mins,min[l^1]);
			if(  r&1 ) maxi(maxs,max[r^1]),mini(mins,min[r^1]);
		}
		writeln(maxs-mins);
	}
}
コード例 #8
0
ファイル: mintchip.c プロジェクト: bramp/libmintchip
int mintchip_get_info(struct mintchip *chip, struct mintchip_info *info) {

	unsigned char in[] = {
		0x00, 0x00, 0x80, 0x00, 0x00, 0x1D, 0x00, 0x05, 0x98, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x13, 0x10, 0x00, 0x00, 0x00, 0x02, 0x03, 0x99, 0x01, 0x00, 0x27, 0x10, 0x00, 0x01, 0x00, 0x00,
		0x01, 0xF3, 0x01, 0xF4, 0x00, 0x27, 0x10, 0x00, 0x27, 0x10, 0x26, 0x90, 0x00, 0x00, 0x00, 0x00,
	};
	unsigned char *i = in;

	i = &in[16];
	memcpy(info->id, i, 8); i+=8;
	info->currency = *i++;

	info->balance        = read3(i); i+=3;
	info->creditLogCount = read2(i); i+=2;
	info->debitLogCount  = read2(i); i+=2;          // 14-16
	info->creditLogCountRemaining = read2(i); i+=2; // 16-18
	info->debitLogCountRemaining  = read2(i); i+=2; // 12-20
	info->maxCreditAllowed        = read3(i); i+=3; // 20-23
	info->maxDebitAllowed         = read3(i); i+=3; // 23-26
	info->version = *i++;  // 26

	return 0;
}
コード例 #9
0
ファイル: shell.c プロジェクト: mhbackes/sisop1
void cmdRead(void) {
    FILE2 handle;
    int size;

    // get first parameter => file handle
    char *token = strtok(NULL," \t");
    if (token==NULL) {
        printf ("Missing parameter\n");
        return;
    }
    if (sscanf(token, "%d", &handle)==0) {
        printf ("Invalid parameter\n");
        return;
    }

    // get second parameter => number of bytes
    token = strtok(NULL," \t");
    if (token==NULL) {
        printf ("Missing parameter\n");
        return;
    }
    if (sscanf(token, "%d", &size)==0) {
        printf ("Invalid parameter\n");
        return;
    }

    // Alloc buffer for reading file
    char *buffer = malloc(size);
    if (buffer==NULL) {
        printf ("Memory full\n");
        return;
    }

    // get file bytes
    int err = read2(handle, buffer, size);
    if (err<0) {
        printf ("Error: %d\n", err);
        return;
    }
    if (err==0) {
        printf ("Empty file\n");
        return;
    }

    // show bytes read
    dump(buffer, err);
    printf ("%d bytes read from file-handle %d\n", err, handle);
}
コード例 #10
0
ファイル: P12.C プロジェクト: citrit/ECSE4750
main() 
{
    int v1, v2;      // hold values from user

    read2( v1, v2 ); 

    cout << v1;
    if ( isOdd( v1 ) == 1 )
	cout << " is odd\n";
    else 
	cout << " is even\n";

    cout << v2; 
    if ( isOdd( v2 ) == 1 )
	cout << " is odd\n";
    else
	cout << " is even\n";

    return 0;
}
コード例 #11
0
ファイル: solution2.cpp プロジェクト: CVroland/seqan
int main(int argc, char const ** argv)
{
    if (argc != 2)
        return 1;  // Invalid number of arguments.

    // Open file and create RecordReader.
    std::fstream in(argv[1], std::ios::binary | std::ios::in);
    seqan::RecordReader<std::fstream, seqan::SinglePass<> > reader(in);

    // Read file in one pass.
    seqan::StringSet<seqan::CharString> ids;
    seqan::StringSet<seqan::CharString> seqs;
    seqan::StringSet<seqan::CharString> quals;
    if (read2(ids, seqs, quals, reader, seqan::Fastq()) != 0)
        return 1;  // Could not read file.

    for (unsigned i = 0; i < length(ids); ++i)
        std::cout << ids[i] << '\t' << seqs[i] << '\t' << quals[i] << '\n';
    
    return 0;
}
コード例 #12
0
ファイル: video.cpp プロジェクト: ext/slideshow
State* VideoState::action(bool &flip){
	if ( child_pid <= 0 ){
		return new SwitchState(this);
	}

	command("get_property filename\n");

	while ( true ){
		const char* ans = read2(child_stdout);

		if ( !ans ){
			continue;
		}

		if ( strcmp(ans, "ANS_ERROR=PROPERTY_UNAVAILABLE\n") == 0){
			return new SwitchState(this);
		}

		return this;
	}
}
コード例 #13
0
void cAccount::LoadAccounts( void )
{
	int b,c,ac, account,loopexit=0;
	char accnumb[64]; 		
	char acc[64];
	char *t;
	lastusedacctnum = 0;

	openscript("accounts.adm");
	acctlist.clear();
	do
	{
		read2();	
		if (!(strcmp((char*)script1, "SECTION")))
		{
			   
			c = strlen((char*)script2);
			for (b=0; b<9; b++) acc[b]=script2[b]; 
			for (b=8; b<c; b++) accnumb[b-8]=script2[b];
			accnumb[b-8]=0; acc[8]=0;		
			ac = strtol(accnumb, &t, 10);
			if (strlen(t)!=0) ac=-1;

			if (strcmp(acc,"ACCOUNT ") || ac < 0 )
			{
				clConsole.send("Error loading accounts, skipping invalid account entry!\n");

			} else {
			   account=ac;
			   LoadAccount(account);
			   if (account > lastusedacctnum)
				   lastusedacctnum = account;
			}
		}
	}
	while ( (strcmp((char*)script1, "EOF")) && (++loopexit < MAXLOOPS) );
	closescript();	
}
コード例 #14
0
void cAccount::LoadAccount( int acctnumb )
{
	unsigned long loopexit=0;
	account_st account;
	account.name.erase();
	account.pass.erase();
	account.ban = false;
	account.remoteadmin = false;
	account.number = acctnumb;
	do
	{
		read2();
		
		if (!strcmp((char*)script1, "NAME"))				account.name =  script2;
		else if (!strcmp((char*)script1, "PASS"))			account.pass = script2;
		else if (!strcmp((char*)script1, "BAN"))			account.ban = true;
		else if (!strcmp((char*)script1, "REMOTEADMIN"))	account.remoteadmin = true;
	}
	while ( (strcmp((char*)script1, "}")) && (strcmp((char*)script1, "EOF")) && (++loopexit < MAXLOOPS) );
	acctlist.insert(make_pair(account.name, account));
	acctnumbers_sp.insert(make_pair(account.number, account.name));
	lasttimecheck = uiCurrentTime;
}
コード例 #15
0
ファイル: video.cpp プロジェクト: ext/slideshow
void VideoState::poll(){
	if ( child_pid < 0 ){
		return;
	}

	int sigstate = kill(child_pid, 0);
	if ( sigstate != 0 ){ /* child process terminated */
		Log::fatal("mplayer process has gone away (for reasons unknown)");
		child_pid = -1;
	}

	int status;
	if ( waitpid(child_pid, &status, WNOHANG) != 0 ){
		if ( WIFEXITED(status) ){
			Log::fatal("mplayer process has gone away (exited with code %d)\n", WEXITSTATUS(status));
		} else {
			Log::fatal("mplayer process has gone away (terminated with signal %d)\n", WTERMSIG(status));
		}
		child_pid = -1;
	}

	read2(child_stdout);
}
コード例 #16
0
ファイル: jac0dim.c プロジェクト: alanctgardner/ampl-go
jac0dim_ASL(ASL *asl, char *stub, ftnlen stub_len)
#endif
{
	FILE *nl;
	int i, k, nlv;
	char *s, *se;
	const char *opfmt;
	EdRead ER, *R;

	if (!asl)
		badasl_ASL(asl,0,"jac0dim");
	fpinit_ASL();	/* get IEEE arithmetic, if possible */

	if (stub_len <= 0)
		for(i = 0; stub[i]; i++);
	else
		for(i = stub_len; stub[i-1] == ' ' && i > 0; --i);
	filename = (char *)M1alloc(i + 5);
	s = stub_end = filename + i;
	strncpy(filename, stub, i);
	strcpy(s, ".nl");
	nl = fopen(filename, "rb");
	if (!nl && i > 3 && !strncmp(s-3, ".nl", 3)) {
		*s = 0;
		stub_end = s - 3;
		nl = fopen(filename, "rb");
		}
	if (!nl) {
		if (return_nofile)
			return 0;
		fflush(stdout);
		what_prog();
		fprintf(Stderr, "can't open %s\n", filename);
		exit(1);
		}
	R = EdReadInit_ASL(&ER, asl, nl, 0);
	R->Line = 0;
	s = read_line(R);
	binary_nl = 0;
	opfmt = "%d";
	switch(*s) {
#ifdef DEPRECATED
		case 'E':	/* deprecated "-oe" format */
			{int ncsi = 0;
			k = Sscanf(s, "E%d %d %d %d %d %d", &n_var, &n_con,
				&n_obj, &maxrownamelen, &maxcolnamelen, &ncsi);
			if (k < 5)
				badints(R, k, 5);
			if (ncsi) {
				if (ncsi != 6) {
					badread(R);
					fprintf(Stderr,
					 "expected 6th integer to be 0 or 6, not %d\n",
						ncsi);
					exit(1);
					}
				s = read_line(R);
				k = Sscanf(s, " %d %d %d %d %d %d",
					&comb, &comc, &como, &comc1, &como1, &nfunc);
				if (k != 6)
					badints(R, k, 6);
				}
			}
			break;
#endif
		case 'z':
		case 'Z':
			opfmt = "%hd";
		case 'B':
		case 'b':
			binary_nl = 1;
			xscanf = bscanf;
			goto have_xscanf;
		case 'h':
		case 'H':
			opfmt = "%hd";
			binary_nl = 1;
			xscanf = hscanf;
			goto have_xscanf;
		case 'G':
		case 'g':
			xscanf = ascanf;
 have_xscanf:
			if ((k = ampl_options[0] = strtol(++s, &se, 10))) {
				if (k > 9) {
					fprintf(Stderr,
					"ampl_options = %d is too large\n", k);
					exit(1);
					}
				for(i = 1; i <= k && se > s; i++)
					ampl_options[i] = strtol(s = se,&se,10);
				if (ampl_options[2] == 3)
					ampl_vbtol = strtod(s = se, &se);
				}
			s = read_line(R);
			n_eqn = -1;
			k = Sscanf(s, " %d %d %d %d %d %d", &n_var, &n_con,
				&n_obj, &nranges, &n_eqn, &n_lcon);
			if (k < 3)
				badints(R,k,3);
			nclcon = n_con + n_lcon;

			/* formerly read2(R, &nlc, &nlo); */
			s = read_line(R);
			n_cc = nlcc = ndcc = nzlb = 0;
			k = Sscanf(s, " %d %d %d %d %d %d", &nlc, &nlo, &n_cc, &nlcc,
					&ndcc, &nzlb);
			if (k < 2)
				badints(R,k,2);
			if ((n_cc += nlcc) > 0 && k < 6)
				ndcc = -1; /* indicate unknown */

			read2(R, &nlnc, &lnc);
			nlvb = -1;
			s = read_line(R);
			k = Sscanf(s, " %d %d %d", &nlvc, &nlvo, &nlvb);
			if (k < 2)
				badints(R,k,2);

			/* read2(R, &nwv, &nfunc); */
			s = read_line(R);
			asl->i.flags = 0;
			k = Sscanf(s, " %d %d %d %d", &nwv, &nfunc, &i,
				&asl->i.flags);
			if (k < 2)
				badints(R,k,2);
			else if (k >= 3 && i != Arith_Kind_ASL && i) {
#ifdef Want_bswap
				if (i > 0 && i + Arith_Kind_ASL == 3) {
					asl->i.iadjfcn = asl->i.dadjfcn = bswap_ASL;
					binary_nl = i << 1;
					}
				else
#endif
					badfmt(R);
				}

			if (nlvb < 0)	/* ampl versions < 19930630 */
				read2(R, &nbv, &niv);
			else {
				s = read_line(R);
				k = Sscanf(s, " %d %d %d %d %d", &nbv, &niv,
					&nlvbi, &nlvci, &nlvoi);
				if (k != 5)
					badints(R,k,5);
				}
			/* formerly read2(R, &nzc, &nzo); */
			s = read_line(R);
			k = Sscanf(s, " %D %D", &nZc, &nZo);
			if (k != 2)
				badints(R, k, 2);
			nzc = nZc;
			nzo = nZo;
			read2(R, &maxrownamelen, &maxcolnamelen);
			s = read_line(R);
			k = Sscanf(s, " %d %d %d %d %d", &comb, &comc, &como,
					&comc1, &como1);
			if (k != 5)
				badints(R,k,5);
		}
	student_check_ASL(asl);
	if (n_con < 0 || n_var <= 0 || n_obj < 0) {
		what_prog();
		fprintf(Stderr,
		"jacdim: got M = %d, N = %d, NO = %d\n", n_con, n_var, n_obj);
		exit(1);
		}
	asl->i.opfmt = opfmt;
	asl->i.n_var0 = asl->i.n_var1 = n_var;
	asl->i.n_con0 = asl->i.n_con1 = n_con;
	if ((nlv = nlvc) < nlvo)
		nlv = nlvo;
	if (nlv <= 0)
		nlv = 1;
	x0len = nlv * sizeof(real);
	x0kind = ASL_first_x;
	n_conjac[0] = 0;
	n_conjac[1] = n_con;
	c_vars = o_vars = n_var;	/* confusion arises otherwise */
	return nl;
	}
コード例 #17
0
int MpoParser::parseFile(const wchar_t *path)
{
	static const unsigned short MARKER_SOI = 0xFFD8;
	static const unsigned short MARKER_APP1 = 0xFFE1;
	static const unsigned short MARKER_APP2 = 0xFFE2;
	static const unsigned short MARKER_DQT = 0xFFDB;
	static const unsigned short MARKER_DHT = 0xFFC4;
	static const unsigned short MARKER_DRI = 0xFFDD;
	static const unsigned short MARKER_SOF = 0xFFC0;
	static const unsigned short MARKER_SOS = 0xFFDA;
	static const unsigned short MARKER_EOI = 0xFFD9;
	static const unsigned int MP_LITTLE_ENDIAN = 0x49492A00;

	m_NumberOfImages = 0;
	for(int i=0; i<m_NumberOfImages; i++)
		safe_delete(m_datas[i]);

	FILE *r = _wfopen(path, L"rb");
	if (!r)
		return 0;

	unsigned short soi = read2(r, false);
	if (soi != MARKER_SOI)
	{
		fclose(r);
		return 0;
	}

	while (ftell(r) < fsize(r))
	{
		unsigned short marker = read2(r, false);
		unsigned short length = read2(r, false);

		if (marker == MARKER_APP2)
		{
			// Read APP2 block
			char identifier[5] = {0};
			fread(identifier, 1, 4, r);
			length -= 4;

			if (strcmp(identifier, "MPF\0") == 0)
			{
				// Read MP Extensions
				unsigned int startOfOffset = ftell(r);
				unsigned int mpEndian = read4(r, false);
				bool isLittleEndian = mpEndian == MP_LITTLE_ENDIAN;
				unsigned int offsetToFirstIFD = read4(r, isLittleEndian);
				fseek(r, startOfOffset + offsetToFirstIFD, SEEK_SET);

				unsigned short count = read2(r, isLittleEndian);

				// Read the MP Index IFD
				char version[5] = {0};
				m_NumberOfImages = 0;
				unsigned int mpEntry = 0;
				unsigned int imageUIDList = 0;
				unsigned int totalFrames = 0;
				for (int i = 0; i < count; i++)
				{
					unsigned short tag = read2(r, isLittleEndian);
					unsigned short type = read2(r, isLittleEndian);
					unsigned int count2 = read4(r, isLittleEndian);
					switch (tag)
					{
					case 0xB000:
						fread(version, 1, 4, r);
						break;
					case 0xB001:
						m_NumberOfImages = read4(r, isLittleEndian);
						break;
					case 0xB002:
						mpEntry = read4(r, isLittleEndian);
						break;
					case 0xB003:
						imageUIDList = read4(r, isLittleEndian);
						break;
					case 0xB004:
						totalFrames = read4(r, isLittleEndian);
						break;
					}
				}

				unsigned int offsetNext = read4(r, isLittleEndian);

				// Read the values of the MP Index IFD
				for (int i = 0; i < m_NumberOfImages; i++)
				{
					// var bytes = r.ReadBytes(16);
					unsigned int iattr = read4(r, isLittleEndian);
					unsigned int imageSize = read4(r, isLittleEndian);
					unsigned int dataOffset = read4(r, isLittleEndian);
					unsigned short d1EntryNo = read2(r, isLittleEndian);
					unsigned short d2EntryNo = read2(r, isLittleEndian);

					// Calculate offset from beginning of file
					long offset = i == 0 ? 0 : dataOffset + startOfOffset;

					// store the current position
					long o = ftell(r);

					// read the image
					fseek(r, offset, SEEK_SET);
					m_datas[i] = new char[imageSize];
					m_sizes[i] = imageSize;
					if (fread(m_datas[i], 1, imageSize, r) != imageSize)
						return (m_NumberOfImages=0);

					// restore the current position                                    
					fseek(r, o, SEEK_SET);
				}

				fclose(r);
				return m_NumberOfImages;
			}
		}
		fseek(r, length-2, SEEK_CUR);
	}

	fclose(r);
	return m_NumberOfImages;
}
コード例 #18
0
ファイル: tfmtodit.c プロジェクト: dank101/386BSD
int tfm::load(const char *file)
{
  FILE *fp = fopen(file, "r");
  if (!fp) {
    error("can't open `%1': %2", file, strerror(errno));
    return 0;
  }
  int c1 = getc(fp);
  int c2 = getc(fp);
  if (c1 == EOF || c2 == EOF) {
    fclose(fp);
    error("unexpected end of file on `%1'", file);
    return 0;
  }
  int lf = (c1 << 8) + c2;
  int toread = lf*4 - 2;
  unsigned char *buf = new unsigned char[toread];
  if (fread(buf, 1, toread, fp) != toread) {
    if (feof(fp))
      error("unexpected end of file on `%1'", file);
    else
      error("error on file `%1'", file);
    delete buf;
    fclose(fp);
    return 0;
  }
  fclose(fp);
  if (lf < 6) {
    error("bad tfm file `%1': impossibly short", file);
    delete buf;
    return 0;
  }
  unsigned char *ptr = buf;
  int lh = read2(ptr);
  bc = read2(ptr);
  ec = read2(ptr);
  nw = read2(ptr);
  nh = read2(ptr);
  nd = read2(ptr);
  ni = read2(ptr);
  nl = read2(ptr);
  nk = read2(ptr);
  int ne = read2(ptr);
  np = read2(ptr);
  if (6 + lh + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ne + np != lf) {
    error("bad tfm file `%1': lengths do not sum", file);
    delete buf;
    return 0;
  }
  if (lh < 2) {
    error("bad tfm file `%1': header too short", file);
    delete buf;
    return 0;
  }
  char_info = new char_info_word[ec - bc + 1];
  width = new int[nw];
  height = new int[nh];
  depth = new int[nd];
  italic = new int[ni];
  lig_kern = new lig_kern_command[nl];
  kern = new int[nk];
  param = new int[np];
  int i;
  cs = read4(ptr);
  ds = read4(ptr);
  ptr += (lh-2)*4;
  for (i = 0; i < ec - bc + 1; i++) {
    char_info[i].width_index = *ptr++;
    unsigned char tem = *ptr++;
    char_info[i].depth_index = tem & 0xf;
    char_info[i].height_index = tem >> 4;
    tem = *ptr++;
    char_info[i].italic_index = tem >> 2;
    char_info[i].tag = tem & 3;
    char_info[i].remainder = *ptr++;
  }
  for (i = 0; i < nw; i++)
    width[i] = read4(ptr);
  for (i = 0; i < nh; i++)
    height[i] = read4(ptr);
  for (i = 0; i < nd; i++)
    depth[i] = read4(ptr);
  for (i = 0; i < ni; i++)
    italic[i] = read4(ptr);
  for (i = 0; i < nl; i++) {
    lig_kern[i].skip_byte = *ptr++;
    lig_kern[i].next_char = *ptr++;
    lig_kern[i].op_byte = *ptr++;
    lig_kern[i].remainder = *ptr++;
  }
  for (i = 0; i < nk; i++)
    kern[i] = read4(ptr);
  ptr += ne*4;
  for (i = 0; i < np; i++)
    param[i] = read4(ptr);
  assert(ptr == buf + lf*4 - 2);
  delete buf;
  return 1;
}
コード例 #19
0
// old readbook function
void cBooks::readbook_readonly_old(UOXSOCKET s, P_ITEM pBook, int p)
{
	int x, y, pos, j;
	unsigned char bookpage[14]="\x66\x01\x02\x40\x01\x02\x03\x00\x01\x00\x01\x00\x01";
	unsigned long loopexit=0,loopexit2=0;
	
	openscript("misc.scp");
	sprintf((char*)temp, "BOOK %i", calcserial(pBook->more1, pBook->more2, pBook->more3, pBook->more4));
	if (!i_scripts[misc_script]->find((char*)temp))
	{
		closescript();
		return;
	}
	x=p;

	do
	{
		loopexit=0;
		do
		{
			read2();
		}
		while ( (strcmp((char*)script1, "PAGE")) && (++loopexit < MAXLOOPS) );
		x--;
	}
	while ( (x>0) && (++loopexit2 < 6666 ));

	closescript();
	openscript("misc.scp");
	sprintf((char*)temp, "PAGE %s", script2);
	if (!i_scripts[misc_script]->find((char*)temp))
	{
		closescript();
		return;
	}
	pos=ftell(scpfile);
	x=-1;
	y=-2;
	loopexit=0;
	do
	{
		read1();
		x++;
		y+=strlen((char*)script1)+1;
	}
	while ( (strcmp((char*)script1, "}")) && (++loopexit < MAXLOOPS) );
	y+=13;
	fseek(scpfile, pos, SEEK_SET);
	bookpage[1]=y>>8;
	bookpage[2]=y%256;
	LongToCharPtr(pBook->serial, &bookpage[3]);
	bookpage[9]=p>>8;
	bookpage[10]=p%256;
	bookpage[11]=x>>8;
	bookpage[12]=x%256;
	Xsend(s, bookpage, 13);
	for (j=0;j<x;j++)
	{
		read1();
		Xsend(s, script1, strlen((char*)script1)+1);
	}
	closescript();
}
コード例 #20
0
bool MeInfraredReceiver::buttonState()        // Not available in Switching mode
{
	return !read2();
}
コード例 #21
0
ファイル: dvdifo.c プロジェクト: cwittmer/dvdauthor
void TocGen(const struct workset *ws, const struct pgc *fpc, const char *fname)
  /* writes the IFO for a VMGM. */
  {
    static unsigned char buf[2048];
    int nextsector, offset, i, j, vtsstart;
    const bool forcemenus = needmenus(ws->menus);
    FILE *h;

    h = fopen(fname, "wb");

    memset(buf, 0, 2048);
    memcpy(buf, "DVDVIDEO-VMG", 12);
    buf[0x21] = 0x11; /* version number */
    buf[0x27] = 1; /* number of volumes */
    buf[0x29] = 1; /* volume number */
    buf[0x2a] = 1; /* side ID */
    write2(buf + 0x3e, ws->titlesets->numvts); /* number of title sets */
    strncpy((char *)(buf + 0x40), PACKAGE_STRING, 31); /* provider ID */
    buf[0x86] = 4; /* start address of FP_PGC = 0x400 */
    nextsector = 1;

    write4(buf + 0xc4, nextsector); /* sector pointer to TT_SRPT (table of titles) */
    nextsector += Create_TT_SRPT(0, ws->titlesets, 0);
      /* just to figure out how many sectors will be needed */

    if (jumppad || forcemenus)
      {
        write4(buf + 0xc8, nextsector); /* sector pointer to VMGM_PGCI_UT (menu PGC table) */
        nextsector += CreatePGC(0, ws, VTYPE_VMGM);
      } /*if*/

    write4(buf + 0xd0, nextsector);
      /* sector pointer to VMG_VTS_ATRT (copies of VTS audio/subpicture attrs) */
      /* I will output it immediately following IFO header */
    nextsector += (8 + ws->titlesets->numvts * 0x30c + 2047) / 2048;
      /* round up size of VMG_VTS_ATRT to whole sectors */

    if (jumppad || forcemenus)
      {
        write4(buf + 0xd8, nextsector);
          /* sector pointer to VMGM_C_ADT (menu cell address table) */
          /* I make it follow VMG_VTS_ATRT */
        nextsector += CreateCellAddressTable(0, ws->menus->vg); /* how much room it will need */

        write4(buf + 0xdc, nextsector);
          /* sector pointer to VMGM_VOBU_ADMAP (menu VOBU address map) */
        nextsector += numsectVOBUAD(ws->menus->vg);
      } /*if*/

    write4(buf + 0x1c, nextsector - 1); /* last sector of IFO */
    vtsstart = nextsector * 2; /* size of two copies of everything above including BUP */
    if (jumppad || forcemenus)
      {
        write4(buf + 0xc0, nextsector); /* start sector of menu VOB */
        vtsstart += getvoblen(ws->menus->vg);
      } /*if*/
    write4(buf + 0xc, vtsstart - 1); /* last sector of VMG set (last sector of BUP) */

    if (forcemenus)
        BuildAVInfo(buf + 256, ws->menus->vg);

  /* create FPC at 0x400 as promised */
    buf[0x407] = (getratedenom(ws->menus->vg) == 90090 ? 3 : 1) << 6;
      // only set frame rate XXX: should check titlesets if there is no VMGM menu
    buf[0x4e5] = 0xec; /* offset to command table, low byte */
    offset = 0x4f4; /* commands start here, after 8-byte header of command table */
    if (fpc)
      {
        unsigned char *pi;
        if (fpc->posti || fpc->numsources || fpc->numbuttons || fpc->entries)
          {
            fprintf(stderr,"ERR:  FPC can ONLY contain prei commands, nothing else\n");
            exit(1);
          } /*if*/
        if (ws->menus && ws->menus->numgroups)
            pi = vm_compile(buf + offset, buf + offset, ws, ws->menus->groups[0].pg, 0, fpc->prei, 2);
              // XXX: just use the first pgcgroup as a reference
        else
            pi = vm_compile(buf + offset, buf + offset, ws, 0, 0, fpc->prei, 2);
        if (!pi)
          {
            fprintf(stderr,"ERR:  in FPC\n");
            exit(1);
          } /*if*/
        offset = (pi - buf - offset) / 8; /* number of instructions */
        assert(offset <= 128);
        buf[0x4ed] = offset; /* number of pre commands, low byte */
      }
    else
      {
      /* generate default FPC */
        if (forcemenus)
          {
            buf[offset + 0] = 0x30; // jump to VMGM 1
            buf[offset + 1] = 0x06;
            buf[offset + 2] = 0x00;
            buf[offset + 3] = 0x00;
            buf[offset + 4] = 0x00;
            buf[offset + 5] = 0x42;
            buf[offset + 6] = 0x00;
            buf[offset + 7] = 0x00;
          }
        else if (ws->titlesets->numvts && ws->titlesets->vts[0].hasmenu)
          {
            buf[offset + 0] = 0x30; // jump to VTSM vts=1, ttn=1, menu=1
            buf[offset + 1] = 0x06;
            buf[offset + 2] = 0x00;
            buf[offset + 3] = 0x01;
            buf[offset + 4] = 0x01;
            buf[offset + 5] = 0x83;
            buf[offset + 6] = 0x00;
            buf[offset + 7] = 0x00;
          }
        else
          {
            buf[offset + 0] = 0x30; // jump to title 1
            buf[offset + 1] = 0x02;
            buf[offset + 2] = 0x00;
            buf[offset + 3] = 0x00;
            buf[offset + 4] = 0x00;
            buf[offset + 5] = 0x01;
            buf[offset + 6] = 0x00;
            buf[offset + 7] = 0x00;
          } /*if*/
        buf[0x4ed] = 1; /* number of pre commands, low byte */
      } /*if*/
    write2(buf + 0x4f2, 7 + buf[0x4ed] * 8); /* end address relative to command table */
    write2(buf + 0x82 /* end byte address, low word, of VMGI_MAT */, 0x4ec + read2(buf + 0x4f2));
    nfwrite(buf, 2048, h);

    Create_TT_SRPT(h, ws->titlesets, vtsstart); /* generate it for real */

    // PGC
    if (jumppad || forcemenus)
        CreatePGC(h, ws, VTYPE_VMGM);

  /* VMG_VTS_ATRT contains copies of menu and title attributes from all titlesets */
  /* output immediately following IFO header, as promised above */
    memset(buf, 0, 2048);
    j = 8 + ws->titlesets->numvts * 4;
    write2(buf, ws->titlesets->numvts); /* number of titlesets */
    write4(buf + 4, ws->titlesets->numvts * 0x30c + 8 - 1); /* end address (last byte of last VTS_ATRT) */
    for (i = 0; i < ws->titlesets->numvts; i++)
        write4(buf + 8 + i * 4, j + i * 0x308); /* offset to VTS_ATRT i */
    nfwrite(buf, j, h);
    for (i = 0; i < ws->titlesets->numvts; i++) /* output each VTS_ATRT */
      {
        write4(buf, 0x307); /* end address */
        memcpy(buf + 4, ws->titlesets->vts[i].vtscat, 4);
          /* VTS_CAT (copy of bytes 0x22 .. 0x25 of VTS IFO) */
        memcpy(buf + 8, ws->titlesets->vts[i].vtssummary, 0x300);
          /* copy of VTS attributes (bytes 0x100 onwards of VTS IFO) */
        nfwrite(buf, 0x308, h);
        j += 0x308;
      } /*for*/
    j = 2048 - (j & 2047);
    if (j < 2048)
      { /* pad to next whole sector */
        memset(buf, 0, j);
        nfwrite(buf, j, h);
      } /*if*/

    if (jumppad || forcemenus)
      {
        CreateCellAddressTable(h, ws->menus->vg); /* actually generate VMGM_C_ADT */
        CreateVOBUAD(h, ws->menus->vg); /* generate VMGM_VOBU_ADMAP */
      } /*if*/
    fflush(h);
    if (errno != 0)
      {
        fprintf(stderr, "\nERR:  Error %d -- %s -- flushing VMGM\n", errno, strerror(errno));
        exit(1);
      } /*if*/
    fclose(h);
  } /*TocGen*/
コード例 #22
0
ファイル: shell.c プロジェクト: mhbackes/sisop1
/**
Copia arquivo de um sistema de arquivos para o outro
Os parametros são:
    primeiro parametro => direção da copia
        -t copiar para o T2FS
        -f copiar para o FS do host
    segundo parametro => arquivo origem
    terceiro parametro  => arquivo destino
*/
void cmdFscp(void) {
    // Pega a direção e os nomes dos arquivos origem e destion
    char *direcao = strtok(NULL, " \t");
    char *src = strtok(NULL," \t");
    char *dst = strtok(NULL," \t");
    if (direcao==NULL || src==NULL || dst==NULL) {
        printf ("Missing parameter\n");
        return;
    }
    // Valida direção
    if (strncmp(direcao, "-t", 2)==0) {
        // src == host
        // dst == T2FS

        // Abre o arquivo origem, que deve existir
        FILE *hSrc = fopen(src, "r+");
        if (hSrc==NULL) {
            printf ("Open source file error\n");
            return;
        }
        // Cria o arquivo de destino, que será resetado se existir
        FILE2 hDst = create2 (dst);
        if (hDst<0) {
            fclose(hSrc);
            printf ("Create destination file error: %d\n", hDst);
            return;
        }
        // Copia os dados de source para destination
        char buffer[2];
        while( fread((void *)buffer, (size_t)1, (size_t)1, hSrc) == 1 ) {
            write2(hDst, buffer, 1);
        }
        // Fecha os arquicos
        fclose(hSrc);
        close2(hDst);
    }
    else if (strncmp(direcao, "-f", 2)==0) {
        // src == T2FS
        // dst == host

        // Abre o arquivo origem, que deve existir
        FILE2 hSrc = open2 (src);
        if (hSrc<0) {
            printf ("Open source file error: %d\n", hSrc);
            return;
        }
        // Cria o arquivo de destino, que será resetado se existir
        FILE *hDst = fopen(dst, "w+");
        if (hDst==NULL) {
            printf ("Open destination file error\n");
            return;
        }
        // Copia os dados de source para destination
        char buffer[2];
        while ( read2(hSrc, buffer, 1) == 1 ) {
            fwrite((void *)buffer, (size_t)1, (size_t)1, hDst);
        }
        // Fecha os arquicos
        close2(hSrc);
        fclose(hDst);
    }
    else {
        printf ("Invalid copy direction\n");
        return;
    }

    printf ("Files successfully copied\n");
}
コード例 #23
0
void advancementobjects(int s, int x, int allways)
{
	char sect[512];
	unsigned long loopexit=0;

	P_CHAR pc_s = MAKE_CHARREF_LR(s);

	int pos;
	if ((pc_s->advobj==0)||(allways==1))
	{
		staticeffect(s, 0x37, 0x3A, 0, 15);
		soundeffect2(s, 0x01, 0xE9);
		pc_s->advobj=x;
		openscript("advance.scp");
		sprintf(sect, "ADVANCEMENT %i", x);
		if (!i_scripts[advance_script]->find(sect))
		{
			closescript();
			clConsole.send("ADVANCEMENT OBJECT: Script section not found. Aborting.\n");
			pc_s->advobj=0;
			return;
		}
		else			
			do
			{
				read2();
				if (script1[0]!='}')
				{
					if ((!(strcmp("STR",(char*)script1)))||(!(strcmp("STRENGTH",(char*)script1))))
					{
						pc_s->st= getstatskillvalue((char*)script2);
						pc_s->st2 = pc_s->st;
					}
					if ((!(strcmp("DEX",(char*)script1)))||(!(strcmp("DEXTERITY",(char*)script1))))
					{
						pc_s->setDex(getstatskillvalue((char*)script2));
					}
					if ((!(strcmp("INT",(char*)script1)))||(!(strcmp("INTELLIGENCE",(char*)script1))))
					{
						pc_s->in= getstatskillvalue((char*)script2);
						pc_s->in2 = pc_s->in;
					}
					if ((!(strcmp("ALCHEMY",(char*)script1)))||(!(strcmp("SKILL0",(char*)script1)))) pc_s->baseskill[ALCHEMY] = getstatskillvalue((char*)script2);
					if ((!(strcmp("ANATOMY",(char*)script1)))||(!(strcmp("SKILL1",(char*)script1)))) pc_s->baseskill[ANATOMY] = getstatskillvalue((char*)script2);
					if ((!(strcmp("ANIMALLORE",(char*)script1)))||(!(strcmp("SKILL2",(char*)script1)))) pc_s->baseskill[ANIMALLORE] = getstatskillvalue((char*)script2);
					if ((!(strcmp("ITEMID",(char*)script1)))||(!(strcmp("SKILL3",(char*)script1)))) pc_s->baseskill[ITEMID] = getstatskillvalue((char*)script2);
					if ((!(strcmp("ARMSLORE",(char*)script1)))||(!(strcmp("SKILL4",(char*)script1)))) pc_s->baseskill[ARMSLORE] = getstatskillvalue((char*)script2);
					if ((!(strcmp("PARRYING",(char*)script1)))||(!(strcmp("SKILL5",(char*)script1)))) pc_s->baseskill[PARRYING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("BEGGING",(char*)script1)))||(!(strcmp("SKILL6",(char*)script1)))) pc_s->baseskill[BEGGING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("BLACKSMITHING",(char*)script1)))||(!(strcmp("SKILL7",(char*)script1)))) pc_s->baseskill[BLACKSMITHING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("BOWCRAFT",(char*)script1)))||(!(strcmp("SKILL8",(char*)script1)))) pc_s->baseskill[BOWCRAFT] = getstatskillvalue((char*)script2);
					if ((!(strcmp("PEACEMAKING",(char*)script1)))||(!(strcmp("SKILL9",(char*)script1)))) pc_s->baseskill[PEACEMAKING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("CAMPING",(char*)script1)))||(!(strcmp("SKILL10",(char*)script1)))) pc_s->baseskill[CAMPING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("CARPENTRY",(char*)script1)))||(!(strcmp("SKILL11",(char*)script1)))) pc_s->baseskill[CARPENTRY] = getstatskillvalue((char*)script2);
					if ((!(strcmp("CARTOGRAPHY",(char*)script1)))||(!(strcmp("SKILL12",(char*)script1)))) pc_s->baseskill[CARTOGRAPHY] = getstatskillvalue((char*)script2);
					if ((!(strcmp("COOKING",(char*)script1)))||(!(strcmp("SKILL13",(char*)script1)))) pc_s->baseskill[COOKING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("DETECTINGHIDDEN",(char*)script1)))||(!(strcmp("SKILL14",(char*)script1)))) pc_s->baseskill[DETECTINGHIDDEN] = getstatskillvalue((char*)script2);
					if ((!(strcmp("ENTICEMENT",(char*)script1)))||(!(strcmp("SKILL15",(char*)script1)))) pc_s->baseskill[ENTICEMENT] = getstatskillvalue((char*)script2);
					if ((!(strcmp("EVALUATINGINTEL",(char*)script1)))||(!(strcmp("SKILL16",(char*)script1)))) pc_s->baseskill[EVALUATINGINTEL] = getstatskillvalue((char*)script2);
					if ((!(strcmp("HEALING",(char*)script1)))||(!(strcmp("SKILL17",(char*)script1)))) pc_s->baseskill[HEALING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("FISHING",(char*)script1)))||(!(strcmp("SKILL18",(char*)script1)))) pc_s->baseskill[FISHING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("FORENSICS",(char*)script1)))||(!(strcmp("SKILL19",(char*)script1)))) pc_s->baseskill[FORENSICS] = getstatskillvalue((char*)script2);
					if ((!(strcmp("HERDING",(char*)script1)))||(!(strcmp("SKILL20",(char*)script1)))) pc_s->baseskill[HERDING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("HIDING",(char*)script1)))||(!(strcmp("SKILL21",(char*)script1)))) pc_s->baseskill[HIDING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("PROVOCATION",(char*)script1)))||(!(strcmp("SKILL22",(char*)script1)))) pc_s->baseskill[PROVOCATION] = getstatskillvalue((char*)script2);
					if ((!(strcmp("INSCRIPTION",(char*)script1)))||(!(strcmp("SKILL23",(char*)script1)))) pc_s->baseskill[INSCRIPTION] = getstatskillvalue((char*)script2);
					if ((!(strcmp("LOCKPICKING",(char*)script1)))||(!(strcmp("SKILL24",(char*)script1)))) pc_s->baseskill[LOCKPICKING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("MAGERY",(char*)script1)))||(!(strcmp("SKILL25",(char*)script1)))) pc_s->baseskill[MAGERY] = getstatskillvalue((char*)script2);
					if ((!(strcmp("MAGICRESISTANCE",(char*)script1)))||(!(strcmp("RESIST",(char*)script1)))||(!(strcmp("SKILL26",(char*)script1)))) pc_s->baseskill[MAGICRESISTANCE] = getstatskillvalue((char*)script2);
					if ((!(strcmp("TACTICS",(char*)script1)))||(!(strcmp("SKILL27",(char*)script1)))) pc_s->baseskill[TACTICS] = getstatskillvalue((char*)script2);
					if ((!(strcmp("SNOOPING",(char*)script1)))||(!(strcmp("SKILL28",(char*)script1)))) pc_s->baseskill[SNOOPING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("MUSICIANSHIP",(char*)script1)))||(!(strcmp("SKILL29",(char*)script1)))) pc_s->baseskill[MUSICIANSHIP] = getstatskillvalue((char*)script2);
					if ((!(strcmp("POISONING",(char*)script1)))||(!(strcmp("SKILL30",(char*)script1)))) pc_s->baseskill[POISONING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("ARCHERY",(char*)script1)))||(!(strcmp("SKILL31",(char*)script1)))) pc_s->baseskill[ARCHERY] = getstatskillvalue((char*)script2);
					if ((!(strcmp("SPIRITSPEAK",(char*)script1)))||(!(strcmp("SKILL32",(char*)script1)))) pc_s->baseskill[SPIRITSPEAK] = getstatskillvalue((char*)script2);
					if ((!(strcmp("STEALING",(char*)script1)))||(!(strcmp("SKILL33",(char*)script1)))) pc_s->baseskill[STEALING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("TAILORING",(char*)script1)))||(!(strcmp("SKILL34",(char*)script1)))) pc_s->baseskill[TAILORING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("TAMING",(char*)script1)))||(!(strcmp("SKILL35",(char*)script1)))) pc_s->baseskill[TAMING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("TASTEID",(char*)script1)))||(!(strcmp("SKILL36",(char*)script1)))) pc_s->baseskill[TASTEID] = getstatskillvalue((char*)script2);
					if ((!(strcmp("TINKERING",(char*)script1)))||(!(strcmp("SKILL37",(char*)script1)))) pc_s->baseskill[TINKERING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("TRACKING",(char*)script1)))||(!(strcmp("SKILL38",(char*)script1)))) pc_s->baseskill[TRACKING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("VETERINARY",(char*)script1)))||(!(strcmp("SKILL39",(char*)script1)))) pc_s->baseskill[VETERINARY] = getstatskillvalue((char*)script2);
					if ((!(strcmp("SWORDSMANSHIP",(char*)script1)))||(!(strcmp("SKILL40",(char*)script1)))) pc_s->baseskill[SWORDSMANSHIP] = getstatskillvalue((char*)script2);
					if ((!(strcmp("MACEFIGHTING",(char*)script1)))||(!(strcmp("SKILL41",(char*)script1)))) pc_s->baseskill[MACEFIGHTING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("FENCING",(char*)script1)))||(!(strcmp("SKILL42",(char*)script1)))) pc_s->baseskill[FENCING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("WRESTLING",(char*)script1)))||(!(strcmp("SKILL43",(char*)script1)))) pc_s->baseskill[WRESTLING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("LUMBERJACKING",(char*)script1)))||(!(strcmp("SKILL44",(char*)script1)))) pc_s->baseskill[LUMBERJACKING] = getstatskillvalue((char*)script2);
					if ((!(strcmp("MINING",(char*)script1)))||(!(strcmp("SKILL45",(char*)script1)))) pc_s->baseskill[MINING] = getstatskillvalue((char*)script2);

					// lb, new skills
					if ((!(strcmp("MEDITATION",(char*)script1)))||(!(strcmp("SKILL46",(char*)script1)))) pc_s->baseskill[MEDITATION] = getstatskillvalue((char*)script2);
					if ((!(strcmp("STEALTH",(char*)script1)))||(!(strcmp("SKILL47",(char*)script1)))) pc_s->baseskill[STEALTH] = getstatskillvalue((char*)script2);
					if ((!(strcmp("REMOVETRAPS",(char*)script1)))||(!(strcmp("SKILL48",(char*)script1)))) pc_s->baseskill[REMOVETRAPS] = getstatskillvalue((char*)script2);

					if ((!(strcmp("DYEHAIR",(char*)script1))))
					{
						unsigned int ci;
						vector<SERIAL> vecContainer = contsp.getData(pc_s->serial);
						P_ITEM pi_hair = NULL;
						for (ci = 0; ci < vecContainer.size(); ci++)
						{
							P_ITEM pi_temp = FindItemBySerial(vecContainer[ci]);
							if (pi_temp != NULL)
								if (pi_temp->layer == 0x0B)
								{
									pi_hair = pi_temp;
									break;
								}
						}
						if (pi_hair != NULL)
						{
							x=hex2num(script2);
							pi_hair->color1=x>>8;
							pi_hair->color2=x%256;
							RefreshItem(pi_hair);//AntiChrist
							teleport(DEREF_P_CHAR(pc_s));
						}
					}

					if ((!(strcmp("DYEBEARD",(char*)script1))))
					{
						int ci;
						P_ITEM pi_beard = NULL;
						vector<SERIAL> vecContainer = contsp.getData(pc_s->serial);
						for (ci = 0; ci < vecContainer.size();ci++)
						{
							P_ITEM pi_temp = FindItemBySerial(vecContainer[ci]);
							if (pi_temp != NULL)
								if (pi_temp->layer == 0x10)
								{
									pi_beard = pi_temp;
									break;
								}
						}
						if (pi_beard != NULL)
						{
							x=hex2num(script2);
							pi_beard->color1=x>>8;
							pi_beard->color2=x%256;
							RefreshItem(pi_beard);//AntiChrist
							teleport(DEREF_P_CHAR(pc_s));
						}
コード例 #24
0
ファイル: osgcluster.cpp プロジェクト: AnthonyYou/osg
 inline short readShort() { short c=0; read2((char*)&c); return c; }
コード例 #25
0
ファイル: osgcluster.cpp プロジェクト: AnthonyYou/osg
 inline unsigned short readUShort() { unsigned short c=0; read2((char*)&c); return c; }
コード例 #26
0
void newbieitems(CHARACTER c)
{
	int n, first, second, third, storeval, itemaddperskill, loopexit = 0;
	char sect[512];
	char whichsect[15];
	long int pos;
	int s;
	for (s = 0; s < now; s++)
	{
		if (c == currchar[s])
			break;
	}

	P_CHAR pc = MAKE_CHARREF_LR(c);
	first = bestskill(c);
	second = nextbestskill(c, first);
	third = nextbestskill(c, second);
	if (pc->baseskill[third] < 190)
		third = 46;

	for (itemaddperskill = 1; itemaddperskill <= 4; itemaddperskill++)
	{
		switch (itemaddperskill)
		{
			case 1: sprintf(whichsect, "BESTSKILL %i", first);	break;
			case 2: sprintf(whichsect, "BESTSKILL %i", second);	break;
			case 3: sprintf(whichsect, "BESTSKILL %i", third);	break;
			case 4: strcpy(whichsect, "DEFAULT");				break;
			default:
				clConsole.send("ERROR: Fallout of switch statement without default. newbie.cpp, newbieitems()/n"); // Morrolan
		}
		openscript("newbie.scp");
		sprintf(sect, whichsect);
		if (!i_scripts[newbie_script]->find(sect)) 
		{
			closescript();
			return;
		}
		do
		{
			read2();
			if (script1[0] != '}')
			{ 
				if (!(strcmp("PACKITEM", (char*)script1)))
				{
					storeval = str2num(script2);
					pos = ftell(scpfile);
					closescript();
					
					n = Items->SpawnItemBackpack2(s, storeval, 0); // Tauriel 11-24-98
					if (n!=-1)
						items[n].priv |= 0x02; // Mark as a newbie item
					strcpy((char*)script1, "DUMMY");
					openscript("newbie.scp");
					fseek(scpfile, pos, SEEK_SET);
				}
				else if (!strcmp("BANKITEM", (char*)script1))
				{
					storeval = str2num(script2);
					pos = ftell(scpfile);
					closescript();
				
					P_ITEM pi = Items->SpawnItemBank(c, storeval); // Tauriel 11-24-98
					if (pi != NULL)
						pi->priv |= 0x02; // Mark as a newbie item
					strcpy((char*)script1, "DUMMY");
					openscript("newbie.scp");
					fseek(scpfile, pos, SEEK_SET);
				}
			}  
		}	
		while ((script1[0] != '}') &&(++loopexit < MAXLOOPS));
	    closescript();
	}
}
コード例 #27
0
ファイル: cfi.c プロジェクト: klammerj/urjtag
int
urj_flash_cfi_detect (urj_bus_t *bus, uint32_t adr,
                      urj_flash_cfi_array_t **cfi_array)
{
    unsigned int bw;            /* bus width */
    unsigned int d;             /* data offset */
    size_t ba;                  /* bus width address multiplier */
    int ma;                     /* flash mode address multiplier */
    urj_bus_area_t area;

    if (!cfi_array || !bus)
    {
        urj_error_set (URJ_ERROR_INVALID, "cfi_array or bus");
        return URJ_STATUS_FAIL;
    }

    *cfi_array = calloc (1, sizeof (urj_flash_cfi_array_t));
    if (!*cfi_array)
    {
        urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
                       (size_t) 1, sizeof (urj_flash_cfi_array_t));
        return URJ_STATUS_FAIL;
    }

    (*cfi_array)->bus = bus;
    (*cfi_array)->address = adr;
    if (URJ_BUS_AREA (bus, adr, &area) != URJ_STATUS_OK)
        // retain error state
        return URJ_STATUS_FAIL;
    if (URJ_BUS_TYPE (bus) != URJ_BUS_TYPE_PARALLEL)
        return URJ_STATUS_FAIL;
    bw = area.width;
    if (bw != 8 && bw != 16 && bw != 32)
    {
        urj_error_set (URJ_ERROR_INVALID, "bus width = %d", bw);
        return URJ_STATUS_FAIL;
    }
    (*cfi_array)->bus_width = ba = bw / 8;
    (*cfi_array)->cfi_chips = calloc (ba, sizeof (urj_flash_cfi_chip_t *));
    if (!(*cfi_array)->cfi_chips)
    {
        urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
                       ba, sizeof (urj_flash_cfi_chip_t *));
        return URJ_STATUS_FAIL;
    }

    for (d = 0; d < bw; d += 8)
    {
#define A(off)                  (adr + (off) * ba * ma)
#define D(data)                 ((data) << d)
#define gD(data)                (((data) >> d) & 0xFF)
#define read1(off)              gD(URJ_BUS_READ( bus, A(off) ))
        // @@@@ RFHH check status of URJ_BUS_READ_START
#define read2(off)              (URJ_BUS_READ_START (bus, A(off)), gD (URJ_BUS_READ_NEXT (bus, A((off) + 1))) | gD (URJ_BUS_READ_END (bus)) << 8)
#define write1(off,data)        URJ_BUS_WRITE( bus, A(off), D(data) )

        urj_flash_cfi_query_structure_t *cfi;
        uint32_t tmp;
        int ret = -4;           /* CFI not detected (Q) */
        uint16_t pri_vendor_tbl_adr;

        /* detect CFI capable devices - see Table 1 in [1] */
        for (ma = 1; ma <= 4; ma *= 2)
        {
            write1 (CFI_CMD_QUERY_OFFSET, CFI_CMD_QUERY);

            if (read1 (CFI_QUERY_ID_OFFSET) == 'Q')
            {
                ret = -5;       /* CFI not detected (R) */
                if (read1 (CFI_QUERY_ID_OFFSET + 1) == 'R')
                    break;
            }

            write1 (0, CFI_CMD_READ_ARRAY1);
            write1 (0, CFI_CMD_READ_ARRAY2);
        }

        if (ma > 4)
        {
            if (ret == -4)
                urj_error_set (URJ_ERROR_FLASH, "CFI not detected (Q)");
            else
                urj_error_set (URJ_ERROR_FLASH, "CFI not detected (R)");
            return URJ_STATUS_FAIL;
        }

        if (read1 (CFI_QUERY_ID_OFFSET + 2) != 'Y')
        {
            write1 (0, CFI_CMD_READ_ARRAY1);
            write1 (0, CFI_CMD_READ_ARRAY2);
            urj_error_set (URJ_ERROR_FLASH, "CFI not detected (Y)");
            return URJ_STATUS_FAIL;
        }

        (*cfi_array)->cfi_chips[d / 8] = calloc (1,
                                                 sizeof (urj_flash_cfi_chip_t));
        if (!(*cfi_array)->cfi_chips[d / 8])
        {
            write1 (0, CFI_CMD_READ_ARRAY1);
            write1 (0, CFI_CMD_READ_ARRAY2);
            urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
                           (size_t) 1, sizeof (urj_flash_cfi_chip_t));
            return URJ_STATUS_FAIL;
        }
        cfi = &(*cfi_array)->cfi_chips[d / 8]->cfi;

        /* Identification string - see Table 6 in [1] */
        cfi->identification_string.pri_id_code = read2 (PRI_VENDOR_ID_OFFSET);
        cfi->identification_string.pri_vendor_tbl = NULL;
        cfi->identification_string.alt_id_code = read2 (ALT_VENDOR_ID_OFFSET);
        cfi->identification_string.alt_vendor_tbl = NULL;

        /* System interface information - see Table 7 in [1] */
        tmp = read1 (VCC_MIN_WEV_OFFSET);
        cfi->system_interface_info.vcc_min_wev =
            ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100;
        tmp = read1 (VCC_MAX_WEV_OFFSET);
        cfi->system_interface_info.vcc_max_wev =
            ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100;
        tmp = read1 (VPP_MIN_WEV_OFFSET);
        cfi->system_interface_info.vpp_min_wev =
            ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100;
        tmp = read1 (VPP_MAX_WEV_OFFSET);
        cfi->system_interface_info.vpp_max_wev =
            ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100;

        /* TODO: Add out of range checks for timeouts */
        tmp = read1 (TYP_SINGLE_WRITE_TIMEOUT_OFFSET);
        cfi->system_interface_info.typ_single_write_timeout =
            tmp ? (1 << tmp) : 0;

        tmp = read1 (TYP_BUFFER_WRITE_TIMEOUT_OFFSET);
        cfi->system_interface_info.typ_buffer_write_timeout =
            tmp ? (1 << tmp) : 0;

        tmp = read1 (TYP_BLOCK_ERASE_TIMEOUT_OFFSET);
        cfi->system_interface_info.typ_block_erase_timeout =
            tmp ? (1 << tmp) : 0;

        tmp = read1 (TYP_CHIP_ERASE_TIMEOUT_OFFSET);
        cfi->system_interface_info.typ_chip_erase_timeout =
            tmp ? (1 << tmp) : 0;

        tmp = read1 (MAX_SINGLE_WRITE_TIMEOUT_OFFSET);
        cfi->system_interface_info.max_single_write_timeout =
            (tmp ? (1 << tmp) : 0) *
            cfi->system_interface_info.typ_single_write_timeout;

        tmp = read1 (MAX_BUFFER_WRITE_TIMEOUT_OFFSET);
        cfi->system_interface_info.max_buffer_write_timeout =
            (tmp ? (1 << tmp) : 0) *
            cfi->system_interface_info.typ_buffer_write_timeout;

        tmp = read1 (MAX_BLOCK_ERASE_TIMEOUT_OFFSET);
        cfi->system_interface_info.max_block_erase_timeout =
            (tmp ? (1 << tmp) : 0) *
            cfi->system_interface_info.typ_block_erase_timeout;

        tmp = read1 (MAX_CHIP_ERASE_TIMEOUT_OFFSET);
        cfi->system_interface_info.max_chip_erase_timeout =
            (tmp ? (1 << tmp) : 0) *
            cfi->system_interface_info.typ_chip_erase_timeout;

        /* Device geometry - see Table 8 in [1] */
        /* TODO: Add out of range check */
        cfi->device_geometry.device_size = 1 << read1 (DEVICE_SIZE_OFFSET);

        cfi->device_geometry.device_interface =
            read2 (FLASH_DEVICE_INTERFACE_OFFSET);

        /* TODO: Add out of range check */
        cfi->device_geometry.max_bytes_write =
            1 << read2 (MAX_BYTES_WRITE_OFFSET);

        tmp = cfi->device_geometry.number_of_erase_regions =
            read1 (NUMBER_OF_ERASE_REGIONS_OFFSET);

        cfi->device_geometry.erase_block_regions =
            malloc (tmp * sizeof (urj_flash_cfi_erase_block_region_t));
        if (!cfi->device_geometry.erase_block_regions)
        {
            write1 (0, CFI_CMD_READ_ARRAY1);
            write1 (0, CFI_CMD_READ_ARRAY2);
            urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
                           (size_t) tmp
                           * sizeof (urj_flash_cfi_erase_block_region_t));
            return URJ_STATUS_FAIL;
        }

        {
            int a;
            int i;

            for (i = 0, a = ERASE_BLOCK_REGION_OFFSET; i < tmp; i++, a += 4)
            {
                uint32_t y = read2 (a);
                uint32_t z = read2 (a + 2) << 8;
                if (z == 0)
                    z = 128;
                cfi->device_geometry.erase_block_regions[i].erase_block_size =
                    z;
                cfi->device_geometry.erase_block_regions[i].
                    number_of_erase_blocks = y + 1;
            }
        }

        pri_vendor_tbl_adr = read2 (PRI_VENDOR_TABLE_ADR_OFFSET);

        /* AMD CFI Primary Vendor-Specific Extended Query Table - see [3] and [4] */
        if (cfi->identification_string.pri_id_code == CFI_VENDOR_AMD_SCS
            && pri_vendor_tbl_adr != 0)
        {
            urj_flash_cfi_amd_pri_extened_query_structure_t *pri_vendor_tbl;
            uint8_t major_version;
            uint8_t minor_version;
            uint8_t num_of_banks;
            int i;
#undef A
#define A(off)                  (adr + (pri_vendor_tbl_adr + (off)) * ba * ma)

            if (read1 (0) != 'P' || read1 (1) != 'R' || read1 (2) != 'I')
            {
                write1 (0, CFI_CMD_READ_ARRAY1);
                write1 (0, CFI_CMD_READ_ARRAY2);
                urj_error_set (URJ_ERROR_FLASH,
                               "CFI primary vendor table not detected");
                return URJ_STATUS_FAIL;
            }

            major_version = read1 (MAJOR_VERSION_OFFSET);
            minor_version = read1 (MINOR_VERSION_OFFSET);
            if (major_version > '1'
                || (major_version == '1' && minor_version >= '3'))
                num_of_banks = read1 (BANK_ORGANIZATION_OFFSET);
            else
                num_of_banks = 0;
            pri_vendor_tbl = calloc (1,
                    sizeof (urj_flash_cfi_amd_pri_extened_query_structure_t)
                            + num_of_banks * sizeof (uint8_t));
            if (!pri_vendor_tbl)
            {
                write1 (0, CFI_CMD_READ_ARRAY1);
                write1 (0, CFI_CMD_READ_ARRAY2);
                urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
                               (size_t) 1,
                               sizeof (urj_flash_cfi_amd_pri_extened_query_structure_t)
                                   + num_of_banks * sizeof (uint8_t));
                return URJ_STATUS_FAIL;
            }

            if (major_version > '1'
                || (major_version == '1' && minor_version >= '0'))
            {
                pri_vendor_tbl->major_version = major_version;
                pri_vendor_tbl->minor_version = minor_version;
                pri_vendor_tbl->address_sensitive_unlock =
                    read1 (ADDRESS_SENSITIVE_UNLOCK_OFFSET);
                pri_vendor_tbl->erase_suspend = read1 (ERASE_SUSPEND_OFFSET);
                pri_vendor_tbl->sector_protect = read1 (SECTOR_PROTECT_OFFSET);
                pri_vendor_tbl->sector_temporary_unprotect =
                    read1 (SECTOR_TEMPORARY_UNPROTECT_OFFSET);
                pri_vendor_tbl->sector_protect_scheme =
                    read1 (SECTOR_PROTECT_SCHEME_OFFSET);
                pri_vendor_tbl->simultaneous_operation =
                    read1 (SIMULTANEOUS_OPERATION_OFFSET);
                pri_vendor_tbl->burst_mode_type =
                    read1 (BURST_MODE_TYPE_OFFSET);
                pri_vendor_tbl->page_mode_type =
                    read1 (PAGE_MODE_TYPE_OFFSET);
            }
            if (major_version > '1'
                || (major_version == '1' && minor_version >= '1'))
            {
                tmp = read1 (ACC_MIN_OFFSET);
                pri_vendor_tbl->acc_min =
                    ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100;
                tmp = read1 (ACC_MAX_OFFSET);
                pri_vendor_tbl->acc_max =
                    ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100;
                pri_vendor_tbl->top_bottom_sector_flag =
                    read1 (TOP_BOTTOM_SECTOR_FLAG_OFFSET);
            }
            if (major_version > '1'
                || (major_version == '1' && minor_version >= '2'))
                pri_vendor_tbl->program_suspend =
                    read1 (PROGRAM_SUSPEND_OFFSET);
            if (major_version > '1'
                || (major_version == '1' && minor_version >= '3'))
            {
                if (pri_vendor_tbl->simultaneous_operation)
                    pri_vendor_tbl->bank_organization =
                        read1 (BANK_ORGANIZATION_OFFSET);
                else
                    pri_vendor_tbl->bank_organization = 0;
                for (i = 0; i < pri_vendor_tbl->bank_organization; i++)
                    pri_vendor_tbl->bank_region_info[i] =
                        read1 (BANK_REGION_INFO_OFFSET +
                               i * sizeof (uint8_t));
            }
            if (major_version > '1'
                || (major_version == '1' && minor_version >= '4'))
            {
                pri_vendor_tbl->unlock_bypass = read1 (UNLOCK_BYPASS_OFFSET);
                tmp = read1 (SECSI_SECTOR_SIZE_OFFSET);
                pri_vendor_tbl->secsi_sector_size = tmp ? (1 << tmp) : 0;
                tmp = read1 (EMBEDDED_HWRST_TIMEOUT_MAX_OFFSET);
                pri_vendor_tbl->embedded_hwrst_timeout_max =
                    tmp ? (1 << tmp) : 0;
                tmp = read1 (NON_EMBEDDED_HWRST_TIMEOUT_MAX_OFFSET);
                pri_vendor_tbl->non_embedded_hwrst_timeout_max =
                    tmp ? (1 << tmp) : 0;
                tmp = read1 (ERASE_SUSPEND_TIMEOUT_MAX_OFFSET);
                pri_vendor_tbl->erase_suspend_timeout_max =
                    tmp ? (1 << tmp) : 0;
                tmp = read1 (PROGRAM_SUSPEND_TIMEOUT_MAX_OFFSET);
                pri_vendor_tbl->program_suspend_timeout_max =
                    tmp ? (1 << tmp) : 0;
            }

            cfi->identification_string.pri_vendor_tbl = (void *) pri_vendor_tbl;

#undef A
#define A(off)                  (adr + (off) * ba * ma)

            /* Reverse the order of erase block region information for top boot devices.  */
            if ((major_version > '1'
                 || (major_version == '1' && minor_version >= '1'))
                && pri_vendor_tbl->top_bottom_sector_flag == 0x3)
            {
                uint32_t y, z;
                uint32_t n = cfi->device_geometry.number_of_erase_regions;

                for (i = 0; i < n / 2; i++)
                {
                    z = cfi->device_geometry.erase_block_regions[i].
                        erase_block_size;
                    y = cfi->device_geometry.erase_block_regions[i].
                        number_of_erase_blocks;
                    cfi->device_geometry.erase_block_regions[i].
                        erase_block_size =
                        cfi->device_geometry.erase_block_regions[n - i - 1].
                        erase_block_size;
                    cfi->device_geometry.erase_block_regions[i].
                        number_of_erase_blocks =
                        cfi->device_geometry.erase_block_regions[n - i - 1].
                        number_of_erase_blocks;
                    cfi->device_geometry.erase_block_regions[n - i - 1].
                        erase_block_size = z;
                    cfi->device_geometry.erase_block_regions[n - i - 1].
                        number_of_erase_blocks = y;
                }
            }
        }
コード例 #28
0
ファイル: RFile.cpp プロジェクト: MakiseKurisu/TextViewNG
DWORD RFile::read(void *buf)
{
    return read2(buf, BSZ);
}
コード例 #29
0
TVerdict CTestSyscalls::doTestStepL()
	{
	int err;
	if(TestStepName() == KCreat)
   		{
   		INFO_PRINTF1(_L("Creat():"));
   		err = Creat();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kopen1)
		{
		INFO_PRINTF1(_L("open1():"));
		err = open1();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
   	   	
	else if(TestStepName() == Kopen2)
		{
		INFO_PRINTF1(_L("open2():"));
		err = open2();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopen3)
		{
		INFO_PRINTF1(_L("open3():"));
		err = open3();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopen4)
		{
		INFO_PRINTF1(_L("open4():"));
		err = open4();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopen5)
		{
		INFO_PRINTF1(_L("open5():"));
		err = open5();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopen6)
		{
		INFO_PRINTF1(_L("open6():"));
		err = open6();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KOpenTruncate1)
		{
		INFO_PRINTF1(_L("OpenTruncate1:"));
		err = OpenTruncate1();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KOpenTruncate2)
		{
		INFO_PRINTF1(_L("OpenTruncate2:"));
		err = OpenTruncate2();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopen7)
   		{
   		INFO_PRINTF1(_L("open7():"));
   		err = open7();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KOpenInAppendMode)
   		{
   		INFO_PRINTF1(_L("OpenInAppendMode():"));
   		err = OpenInAppendMode();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kwrite1)
		{
   		INFO_PRINTF1(_L("write1():"));
		err = write1();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kwrite2)
   		{
   		INFO_PRINTF1(_L("write2():"));
   		err = write2();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kwrite3)
   		{
   		INFO_PRINTF1(_L("write3():"));
   		err = write3();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kwrite5)
		{
   		INFO_PRINTF1(_L("write5():"));
   		err = write5();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kread1)
   		{
   		INFO_PRINTF1(_L("read1():"));
   		err = read1();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kread2)
   		{
		INFO_PRINTF1(_L("read2():"));
   		err = read2();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kread3)
   		{
		INFO_PRINTF1(_L("read3():"));
   		err = read3();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kread4)
		{
		INFO_PRINTF1(_L("read4():"));
		err = read4();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == KOpendir)
   		{
   	   	INFO_PRINTF1(_L("Opendir():"));
   	   	err = Opendir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KClosedir)
   		{
   	   	INFO_PRINTF1(_L("Closedir():"));
   	   	err = Closedir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KReaddir)
   		{
   	   	INFO_PRINTF1(_L("Readdir():"));
   	   	err = Readdir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KLseek)
   		{
   	   	INFO_PRINTF1(_L("Lseek():"));
   	   	err = Lseek();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KLseek1)
   		{
   	   	INFO_PRINTF1(_L("Lseek1():"));
   	   	err = Lseek1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
    else if(TestStepName() == KAccess)
   		{
   	   	INFO_PRINTF1(_L("Access():"));
   	   	err = Access();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KAccess1)
   		{
   	   	INFO_PRINTF1(_L("Access1():"));
   	   	err = Access1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KDup)
   		{
   	   	INFO_PRINTF1(_L("Dup():"));
   	   	err = Dup();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KDup2)
   		{
   	   	INFO_PRINTF1(_L("Dup2():"));
   	   	err = Dup2();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRename)
   		{
   	   	INFO_PRINTF1(_L("Rename():"));
   	   	err = Rename();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRename1)
   		{
   	   	INFO_PRINTF1(_L("Rename1():"));
   	   	err = Rename1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KChmod)
   		{
   	   	INFO_PRINTF1(_L("Chmod():"));
   	   	err = Chmod();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KChmod1)
   		{
   	   	INFO_PRINTF1(_L("Chmod1():"));
   	   	err = Chmod1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
    else if(TestStepName() == KChmod_dir)
   		{
   	   	INFO_PRINTF1(_L("Chmod_dir():"));
   	   	err = Chmod_dir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KFChmod)
   		{
   	   	INFO_PRINTF1(_L("FChmod():"));
   	   	err = FChmod();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KFChmod_dir)
   		{
   	   	INFO_PRINTF1(_L("FChmod_dir():"));
   	   	err = FChmod_dir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KExit)
   		{
   	   	INFO_PRINTF1(_L("Exit():"));
   	   	err = Exit();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KClose)
   		{
   	   	INFO_PRINTF1(_L("Close():"));
   	   	err = Close();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KMkdir)
   		{
   	   	INFO_PRINTF1(_L("Mkdir():"));
   	   	err = Mkdir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KMk_dir)
   		{
   	   	INFO_PRINTF1(_L("Mk_dir():"));
   	   	err = Mk_dir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KRmdir)
   		{
   	   	INFO_PRINTF1(_L("Rmdir():"));
   	   	err = Rmdir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KRm_dir)
   		{
   	   	INFO_PRINTF1(_L("Rm_dir():"));
   	   	err = Rm_dir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
    else if(TestStepName() == KRmdir1)
   		{
   	   	INFO_PRINTF1(_L("Rmdir1():"));
   	   	err = Rmdir1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRmdir_Chdir)
   		{
   	   	INFO_PRINTF1(_L("Rmdir_Chdir():"));
   	   	err = Rmdir_Chdir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KFsync)
   		{
   	   	INFO_PRINTF1(_L("Fsync():"));
   	   	err = Fsync();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KUtimes)
   		{
   	   	INFO_PRINTF1(_L("Utimes():"));
   	   	err = Utimes();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
   	else if(TestStepName() == KUtime)
   		{
   	   	INFO_PRINTF1(_L("Utime():"));
   	   	err = Utime();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KChdir)
   		{
   	   	INFO_PRINTF1(_L("Chdir():"));
   	   	err = Chdir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KFcntl)
   		{
   	   	INFO_PRINTF1(_L("Fcntl():"));
   	   	err = Fcntl();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KIoctl)
   		{
   	   	INFO_PRINTF1(_L("Ioctl():"));
   	   	err = Ioctl();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KFstat)
   		{
   	   	INFO_PRINTF1(_L("Fstat():"));
   	   	err = Fstat();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KStat)
   		{
   	   	INFO_PRINTF1(_L("Stat():"));
   	   	err = Stat();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KStat1)
   		{
   	   	INFO_PRINTF1(_L("Stat1():"));
   	   	err = Stat1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KStat2)
   		{
   	   	INFO_PRINTF1(_L("Stat2():"));
   	   	err = Stat2();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KStat3)
   		{
   	   	INFO_PRINTF1(_L("Stat3():"));
   	   	err = Stat3();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KGetpid)
   		{
   	   	INFO_PRINTF1(_L("Getpid():"));
   	   	err = Getpid();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KClock)
   		{
   	   	INFO_PRINTF1(_L("Clock():"));
   	   	err = Clock();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KTime)
   		{
   	   	INFO_PRINTF1(_L("Time():"));
   	   	err = Time();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KWaitPid)
   		{
   	   	INFO_PRINTF1(_L("WaitPid():"));
   	   	err = WaitPid();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KReadV)
   		{
   	   	INFO_PRINTF1(_L("ReadV():"));
   	   	err = ReadV();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KWriteV)
   		{
   	   	INFO_PRINTF1(_L("WriteV():"));
   	   	err = WriteV();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KSleep)
   		{
   	   	INFO_PRINTF1(_L("Sleep():"));
   	   	err = Sleep();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KSeekDir)
   		{
   	   	INFO_PRINTF1(_L("SeekDir():"));
   	   	err = SeekDir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRewindDir)
   		{
   	   	INFO_PRINTF1(_L("RewindDir():"));
   	   	err = RewindDir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KTelldir)
   		{
   	   	INFO_PRINTF1(_L("Telldir():"));
   	   	err = Telldir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KTestClock)
   		{
   	   	INFO_PRINTF1(_L("TestClock():"));
   	   	err = TestClock();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KCreat2)
   		{
   		INFO_PRINTF1(_L("Creat2():"));
   		err = Creat2();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
   	else if(TestStepName() == Kopen8)
   		{
   		INFO_PRINTF1(_L("open8():"));
   		err = open8();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
   	else if(TestStepName() == KTestStat)
   		{
   		INFO_PRINTF1(_L("KTestStat():"));
   		err = TestStat();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KLseekttytest1)
   		{
   		INFO_PRINTF1(_L("Lseekttytest1():"));
   		err = Lseekttytest1();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KLseekttytest2)
   		{
   		INFO_PRINTF1(_L("Lseekttytest2():"));
   		err = Lseekttytest2();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KWaitPidtest)
   		{
   		INFO_PRINTF1(_L("WaitPidtest():"));
   		err = WaitPidtest();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KWaittest)
   		{
   		INFO_PRINTF1(_L("Waittest():"));
   		err = Waittest();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KOpen_FileDes_Test)
   		{
   		INFO_PRINTF1(_L("Open_FileDes_Test():"));
   		err = Open_FileDes_Test();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopenuid)
   		{
   		INFO_PRINTF1(_L("openuid():"));
   		err = openuid();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KMkdir1)
   		{
   	   	INFO_PRINTF1(_L("Mkdir1():"));
   	   	err = Mkdir1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KMkdir2)
   		{
   	   	INFO_PRINTF1(_L("Mkdir2():"));
   	   	err = Mkdir2();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KRename2)
   		{
   	   	INFO_PRINTF1(_L("Rename2():"));
   	   	err = Rename2();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == Ktestfsync)
   		{
   		INFO_PRINTF1(_L("testfsync():"));
   		err = testfsync();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Ktestrename)
   		{
   		INFO_PRINTF1(_L("testrename():"));
   		err = testrename();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Ktestopenvalidate)
   		{
   		INFO_PRINTF1(_L("testopenvalidate():"));
   		err = testopenvalidate();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Ksync_safe)
   		{
   		INFO_PRINTF1(_L("sync_safe():"));
   		err = sync_safe();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
   	else if(TestStepName() == KFstat1)
   		{
   	   	INFO_PRINTF1(_L("Fstat1():"));
   	   	err = Fstat1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KUtimes1)
   		{
   	   	INFO_PRINTF1(_L("Utimes1():"));
   	   	err = Utimes1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KMkdir_test1)
   		{
   	   	INFO_PRINTF1(_L("Mkdir_test1():"));
   	   	err = Mkdir_test1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KChmod_test)
   		{
   	   	INFO_PRINTF1(_L("Chmod_test():"));
   	   	err = Chmod_test();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KChdir1)
   		{
   	   	INFO_PRINTF1(_L("Chdir1():"));
   	   	err = Chdir1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}   
   	else if(TestStepName() == KRmdir2)
   		{
   	   	INFO_PRINTF1(_L("Rmdir2():"));
   	   	err = Rmdir2();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRename_test)
   		{
   	   	INFO_PRINTF1(_L("Rename_test():"));
   	   	err = Rename_test();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRename3)
   		{
   	   	INFO_PRINTF1(_L("Rename3():"));
   	   	err = Rename3();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KCreat1)
   		{
   		INFO_PRINTF1(_L("Creat1():"));
   		err = Creat1();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
   	else if(TestStepName() == KReadV1)
   		{
   	   	INFO_PRINTF1(_L("ReadV1():"));
   	   	err = ReadV1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
 	else if(TestStepName() == KUtimes2)
    		{
    	   	INFO_PRINTF1(_L("Utimes2():"));
    	   	err = Utimes2();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
 		}
 	else if(TestStepName() == KStat_test)
    		{
    	   	INFO_PRINTF1(_L("Stat_test():"));
    	   	err = Stat_test();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}
    	else if(TestStepName() == KMkdir_test2)
    		{
    	   	INFO_PRINTF1(_L("Mkdir_test2():"));
    	   	err = Mkdir_test2();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}
    	else if(TestStepName() == KChmod2)
    		{
    	   	INFO_PRINTF1(_L("Chmod2():"));
    	   	err = Chmod2();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}
    	else if(TestStepName() == KChdir2)
    		{
    	   	INFO_PRINTF1(_L("Chdir2():"));
    	   	err = Chdir2();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	} 
    	else if(TestStepName() == KRename4)
    		{
    	   	INFO_PRINTF1(_L("Rename4():"));
    	   	err = Rename4();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}
 	else if(TestStepName() == KRename5)
    		{
    	   	INFO_PRINTF1(_L("Rename5():"));
    	   	err = Rename5();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}  
 	else if(TestStepName() == KRmdir3)
    		{
    	   	INFO_PRINTF1(_L("Rmdir3():"));
    	   	err = Rmdir3();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}  
    	else if(TestStepName() == Kread5)
 		{
 		INFO_PRINTF1(_L("read5():"));
 		err = read5();
    		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    		} 	   	 
	return TestStepResult(); 
	}
コード例 #30
0
ファイル: RapMapMapper.cpp プロジェクト: COMBINE-lab/RapMap
int rapMapMap(int argc, char* argv[]) {
    std::cerr << "RapMap Mapper\n";

    std::string versionString = rapmap::version;
    TCLAP::CmdLine cmd(
            "RapMap Mapper",
            ' ',
            versionString);
    cmd.getProgramName() = "rapmap";

    TCLAP::ValueArg<std::string> index("i", "index", "The location of the pseudoindex", true, "", "path");
    TCLAP::ValueArg<std::string> read1("1", "leftMates", "The location of the left paired-end reads", false, "", "path");
    TCLAP::ValueArg<std::string> read2("2", "rightMates", "The location of the right paired-end reads", false, "", "path");
    TCLAP::ValueArg<std::string> unmatedReads("r", "unmatedReads", "The location of single-end reads", false, "", "path");
    TCLAP::ValueArg<uint32_t> numThreads("t", "numThreads", "Number of threads to use", false, 1, "positive integer");
    TCLAP::ValueArg<uint32_t> maxNumHits("m", "maxNumHits", "Reads mapping to more than this many loci are discarded", false, 200, "positive integer");
    TCLAP::ValueArg<std::string> outname("o", "output", "The output file (default: stdout)", false, "", "path");
    TCLAP::SwitchArg endCollectorSwitch("e", "endCollector", "Use the simpler (and faster) \"end\" collector as opposed to the more sophisticated \"skipping\" collector", false);
    TCLAP::SwitchArg noout("n", "noOutput", "Don't write out any alignments (for speed testing purposes)", false);
    cmd.add(index);
    cmd.add(noout);

    cmd.add(read1);
    cmd.add(read2);
    cmd.add(unmatedReads);
    cmd.add(outname);
    cmd.add(numThreads);
    cmd.add(maxNumHits);
    cmd.add(endCollectorSwitch);

    auto consoleSink = std::make_shared<spdlog::sinks::stderr_sink_mt>();
    auto consoleLog = spdlog::create("stderrLog", {consoleSink});

    try {

	cmd.parse(argc, argv);
	bool pairedEnd = (read1.isSet() or read2.isSet());
	if (pairedEnd and (read1.isSet() != read2.isSet())) {
	    consoleLog->error("You must set both the -1 and -2 arguments to align "
		    "paired end reads!");
	    std::exit(1);
	}

	if (pairedEnd and unmatedReads.isSet()) {
	    consoleLog->error("You cannot specify both paired-end and unmated "
		    "reads in the input!");
	    std::exit(1);
	}

	if (!pairedEnd and !unmatedReads.isSet()) {
	    consoleLog->error("You must specify input; either both paired-end "
			      "or unmated reads!");
	    std::exit(1);

	}

	std::string indexPrefix(index.getValue());
	if (indexPrefix.back() != '/') {
	    indexPrefix += "/";
	}

	if (!rapmap::fs::DirExists(indexPrefix.c_str())) {
	    consoleLog->error("It looks like the index you provided [{}] "
		    "doesn't exist", indexPrefix);
	    std::exit(1);
	}


	IndexHeader h;
	std::ifstream indexStream(indexPrefix + "header.json");
	{
		cereal::JSONInputArchive ar(indexStream);
		ar(h);
	}
	indexStream.close();

	if (h.indexType() != IndexType::PSEUDO) {
	    consoleLog->error("The index {} does not appear to be of the "
			    "appropriate type (pseudo)", indexPrefix);
	    std::exit(1);
	}

	RapMapIndex rmi;
	rmi.load(indexPrefix);

	std::cerr << "\n\n\n\n";

	// from: http://stackoverflow.com/questions/366955/obtain-a-stdostream-either-from-stdcout-or-stdofstreamfile
	// set either a file or cout as the output stream
	std::streambuf* outBuf;
	std::ofstream outFile;
	bool haveOutputFile{false};
	if (outname.getValue() == "") {
	    outBuf = std::cout.rdbuf();
	} else {
	    outFile.open(outname.getValue());
	    outBuf = outFile.rdbuf();
	    haveOutputFile = true;
	}
	// Now set the output stream to the buffer, which is
	// either std::cout, or a file.
	std::ostream outStream(outBuf);

	// Must be a power of 2
	size_t queueSize{268435456};
	spdlog::set_async_mode(queueSize);
	auto outputSink = std::make_shared<spdlog::sinks::ostream_sink_mt>(outStream);
	auto outLog = std::make_shared<spdlog::logger>("outLog", outputSink);
	outLog->set_pattern("%v");

	uint32_t nthread = numThreads.getValue();
	std::unique_ptr<paired_parser> pairParserPtr{nullptr};
	std::unique_ptr<single_parser> singleParserPtr{nullptr};

	if (!noout.getValue()) {
	    rapmap::utils::writeSAMHeader(rmi, outLog);
	}

	SpinLockT iomutex;
	{
	    ScopedTimer timer;
	    HitCounters hctrs;
	    consoleLog->info("mapping reads . . . \n\n\n");
	    if (pairedEnd) {
		std::vector<std::thread> threads;
		std::vector<std::string> read1Vec = rapmap::utils::tokenize(read1.getValue(), ',');
		std::vector<std::string> read2Vec = rapmap::utils::tokenize(read2.getValue(), ',');

		if (read1Vec.size() != read2Vec.size()) {
		    consoleLog->error("The number of provided files for "
			    "-1 and -2 must be the same!");
		    std::exit(1);
		}

		size_t numFiles = read1Vec.size() + read2Vec.size();
		char** pairFileList = new char*[numFiles];
		for (size_t i = 0; i < read1Vec.size(); ++i) {
		    pairFileList[2*i] = const_cast<char*>(read1Vec[i].c_str());
		    pairFileList[2*i+1] = const_cast<char*>(read2Vec[i].c_str());
		}
		size_t maxReadGroup{1000}; // Number of reads in each "job"
		size_t concurrentFile{2}; // Number of files to read simultaneously
		pairParserPtr.reset(new paired_parser(4 * nthread, maxReadGroup,
			    concurrentFile,
			    pairFileList, pairFileList+numFiles));

		/** Create the threads depending on the collector type **/
		if (endCollectorSwitch.getValue()) {
		    EndCollector endCollector(&rmi);
		    for (size_t i = 0; i < nthread; ++i) {
			threads.emplace_back(processReadsPair<EndCollector, SpinLockT>,
				pairParserPtr.get(),
				std::ref(rmi),
				std::ref(endCollector),
				&iomutex,
				outLog,
				std::ref(hctrs),
				maxNumHits.getValue(),
				noout.getValue());
		    }
		} else {
		    SkippingCollector skippingCollector(&rmi);
		    for (size_t i = 0; i < nthread; ++i) {
			threads.emplace_back(processReadsPair<SkippingCollector, SpinLockT>,
				pairParserPtr.get(),
				std::ref(rmi),
				std::ref(skippingCollector),
				&iomutex,
				outLog,
				std::ref(hctrs),
				maxNumHits.getValue(),
				noout.getValue());
		    }
		}

		for (auto& t : threads) { t.join(); }
		delete [] pairFileList;
	    } else {
		std::vector<std::thread> threads;
		std::vector<std::string> unmatedReadVec = rapmap::utils::tokenize(unmatedReads.getValue(), ',');
		size_t maxReadGroup{1000}; // Number of reads in each "job"
		size_t concurrentFile{1};
		stream_manager streams( unmatedReadVec.begin(), unmatedReadVec.end(),
			concurrentFile);
		singleParserPtr.reset(new single_parser(4 * nthread,
			    maxReadGroup,
			    concurrentFile,
			    streams));

		/** Create the threads depending on the collector type **/
		if (endCollectorSwitch.getValue()) {
		    EndCollector endCollector(&rmi);
		    for (size_t i = 0; i < nthread; ++i) {
			threads.emplace_back(processReadsSingle<EndCollector, SpinLockT>,
				singleParserPtr.get(),
				std::ref(rmi),
				std::ref(endCollector),
				&iomutex,
				outLog,
				std::ref(hctrs),
				maxNumHits.getValue(),
				noout.getValue());
		    }
		} else {
		    SkippingCollector skippingCollector(&rmi);
		    for (size_t i = 0; i < nthread; ++i) {
			threads.emplace_back(processReadsSingle<SkippingCollector, SpinLockT>,
				singleParserPtr.get(),
				std::ref(rmi),
				std::ref(skippingCollector),
				&iomutex,
				outLog,
				std::ref(hctrs),
				maxNumHits.getValue(),
				noout.getValue());
		    }
		}
		for (auto& t : threads) { t.join(); }
	    }
	    consoleLog->info("Done mapping reads.");
        consoleLog->info("In total saw {} reads.", hctrs.numReads);
        consoleLog->info("Final # hits per read = {}", hctrs.totHits / static_cast<float>(hctrs.numReads));
	    consoleLog->info("Discarded {} reads because they had > {} alignments",
		    hctrs.tooManyHits, maxNumHits.getValue());

	    consoleLog->info("flushing output");
	    outLog->flush();
	}

	if (haveOutputFile) {
	    outFile.close();
	}
	return 0;
    } catch (TCLAP::ArgException& e) {
	consoleLog->error("Exception [{}] when parsing argument {}", e.error(), e.argId());
	return 1;
    }

}