コード例 #1
0
ファイル: hi1.c プロジェクト: suvarna46/hypothetical-machine
int main()
{
    char filename[25];
    int j,ch,c,addr=0X0;
    printf("\n Insert the input file:");
    gets(filename);
    do
    {
     printf("\n Enter your choice:\n 1.Symbol table\n 2.Program length\n 3.Object program\n 4.Rellocate\n 5.Exit");
     fflush(stdin);
     scanf("%d",&ch);
    switch(ch)
    {
      case 1:
              pass1(filename,addr);
              printf("\n The SYMTAB is as follows:\n\n\n\t\t\n");
              printf("\tLABEL\t\tADDRESS\n");
              printf("\t-----\t\t-------\n");
              for(j=0;j<s;j++)
              {
                printf("\t%s\t\t%X\n",symbol[j].symbol_name,symbol[j].symbol_addr);
              }
              printf("\t\t\n");
              break;
      case 2:
              pass1(filename,addr);
              printf("\n The PROGRAM LENGTH is=%X\n",length);
              break;
      case 3:
              pass1(filename,addr);
              pass2();
              break;
      case 4:
              printf("\n Enter the address");
              scanf("%X",&addr);
              pass1(filename,addr);
              printf("\n The SYMTAB is as follows:\n\n\n\t\t\n");
              printf("\tLABEL\t\tADDRESS\n");
              printf("\t-----\t\t-------\n");
              for(j=0;j<s;j++)
              {
                printf("\t%s\t\t%X\n",symbol[j].symbol_name,symbol[j].symbol_addr);
              }
              printf("\t\t\n");
              printf("\n The PROGRAM LENGTH is=%X\n",length);
              pass2();
              break;
      case 5:
              exit(0);
      default:
             printf("\n wrong choice");
    }
    }while(ch!=5);
    return(0);
}
コード例 #2
0
ファイル: PrefWidget.cpp プロジェクト: aygerim/geo2tag
void PrefWidget::onChangeClicked()
{
  std::string pass1(password1->text().toUTF8());
  std::string pass2(password2->text().toUTF8());
  if (pass1 != pass2)
  {
    errorText->show();
  }
  else
  {
    errorText->hide();

    QSharedPointer<std::vector<QSharedPointer<common::User> > > users =
      common::DbSession::getInstance().getUsers();

    for (int i = 0; i < users->size(); i++)
    {
      QSharedPointer<loader::User> user = users->at(i).
        dynamicCast<loader::User>();

      std::string token = user->getToken();
      if (m_token == token)
      {
        user->setPassword(pass1);
        common::DbSession::getInstance().storeUser(user);
        break;
      }
    }
    password1->setText("");
    password2->setText("");
  }
}
コード例 #3
0
ファイル: LightSolver.cpp プロジェクト: Zyrst/Fallen-Stars
//Renderfunctions
void LightSolver::render(sf::RenderTarget& target)
{
	fullScreenBuffer.clear(sf::Color(100, 100, 200, 255));
	colorBuffer.clear(sf::Color::Transparent);

	sf::View originalView = fullScreenBuffer.getView();
	const sf::View& view = target.getView();
	fullScreenBuffer.setView(view);
	colorBuffer.setView(view);

	//First pass calculates the lights based on the occluders
	//and writes their colors to the color buffer
	pass1();

	//Restore the original view.
	fullScreenBuffer.setView(originalView);
	colorBuffer.setView(originalView);

	//Second pass merges the color buffer with the fullscreen buffer.
	pass2();

	sf::Sprite sprite = sf::Sprite(getResult());
	sf::Vector2f pos = sf::Vector2f(view.getCenter().x - view.getSize().x / 2.0f, view.getCenter().y - view.getSize().y / 2.0f);
	sprite.setPosition(pos);
	target.draw(sprite, sf::BlendMultiply);

	sprite.setTexture(colorBuffer.getTexture());
	target.draw(sprite, sf::BlendAdd);
}
コード例 #4
0
void main()
{
	FILE *fp,*mnt,*mdt,*ic,*ec;
	struct Instruction in;
	clrscr();
	fp=fopen("./MACRO/COD1.TXT","r");
	mnt=fopen("./MACRO/MNT.TXT","w+");
	mdt=fopen("./MACRO/MDT.TXT","w+");
	ic=fopen("./MACRO/IC.TXT","w+");
	ec=fopen("./MACRO/EC.TXT","w+");
	printf("\n Source Code :\n");
	while(fscanf(fp,"%s%s%s%s",in.lbl,in.mnem,in.op1,in.op2)!=EOF)
	{
		printf("%s %s %s %s\n",in.lbl,in.mnem,in.op1,in.op2);
	}
	getch();
	clrscr();
	pass1(fp,mnt,mdt,ic);
	getch();
	pass2(mnt,mdt,ic,ec);
	fclose(mnt);
	fclose(mdt);
	fclose(ic);
	fclose(fp);
	fclose(ec);
	getch();
}
コード例 #5
0
ファイル: z80amain.c プロジェクト: pauloscustodio/z80pack
int main(int argc, char *argv[])
{
	int len;

	init();
	options(argc, argv);
	printf("Z80 - Assembler Release %s, %s\n", REL, COPYR);
	pass1();
	pass2();
	if (list_flag) {
		switch (sym_flag) {
		case 0:		/* no symbol table */
			break;
		case 1:		/* unsorted symbol table */
			lst_sym();
			break;
		case 2:		/* symbol table sorted by name */
			len = copy_sym();
			n_sort_sym(len);
			lst_sort_sym(len);
			break;
		case 3:		/* symbol table sorted by address */
			len = copy_sym();
			a_sort_sym(len);
			lst_sort_sym(len);
			break;
		default:
			break;
		}
		fclose(lstfp);
	}
	return(errors);
}
コード例 #6
0
ファイル: RenderEngine.cpp プロジェクト: Idix/Terrain3
void RenderEngine::render(double elapsed)
{
    m_Framebuffer->bind();
    pass1(elapsed);
    m_Framebuffer->unbind();
    pass2(elapsed);

    glfwSwapBuffers();
}
コード例 #7
0
ファイル: asm.c プロジェクト: ccckmit/Nand2Tetris
void assemble(string file) {
  char inFile[100], outFile[100];
  sprintf(inFile, "%s.asm", file);
  sprintf(outFile, "%s.my.hack", file);
  symDump(symTable, symTop);
  pass1(inFile);
  symDump(symTable, symTop);
  pass2(inFile, outFile);
}
コード例 #8
0
ファイル: cn_set_str.c プロジェクト: nu4nu/sobun
int cn_set_str(cn_t cn, const char *str){
  int ret;

  ret = pass1(cn, str);
  if(ret != CN_OK){
    return ret;
  }
  return pass2(cn, str);
}
コード例 #9
0
ファイル: get_flag.c プロジェクト: zined/CTF-Workshop
void pass1(char *input)
{
   if(!strncmp(input,"iamahacker",10))
   {
        pass2(input); 
   }
   else
       puts("try again");
}
コード例 #10
0
ファイル: Assembler.c プロジェクト: nityabhatt/nityaswati2
int main()
{
    pass1();                  //addressing
    printf("\n\n");
    pass2();                  //obj code
    printf("\n\n");
    t_record();                  //record
    return 0;
}
コード例 #11
0
ファイル: ncheck.c プロジェクト: MartinGeisse/vshg01
void check(char *file)
{
	int i, j;
	ino_t mino;

	fi = open(file, 0);
	if(fi < 0) {
		fprintf(stderr, "ncheck: cannot open %s\n", file);
		nerror++;
		return;
	}
	nhent = 0;
	printf("%s:\n", file);
	sync();
	bread((daddr_t)1, (char *)&sblock, sizeof(sblock));
	mino = sblock.s_isize * INOPB;
	ino = 0;
	for(i=2;; i+=NI) {
		if(ino >= mino)
			break;
		bread((daddr_t)i, (char *)itab, sizeof(itab));
		for(j=0; j<INOPB*NI; j++) {
			if(ino >= mino)
				break;
			pass1(&itab[j]);
			ino++;
		}
	}
	ilist[nxfile+1] = 0;
	ino = 0;
	for(i=2;; i+=NI) {
		if(ino >= mino)
			break;
		bread((daddr_t)i, (char *)itab, sizeof(itab));
		for(j=0; j<INOPB*NI; j++) {
			if(ino >= mino)
				break;
			pass2(&itab[j]);
			ino++;
		}
	}
	ino = 0;
	for(i=2;; i+=NI) {
		if(ino >= mino)
			break;
		bread((daddr_t)i, (char *)itab, sizeof(itab));
		for(j=0; j<INOPB*NI; j++) {
			if(ino >= mino)
				break;
			pass3(&itab[j]);
			ino++;
		}
	}
}
コード例 #12
0
int main()
{     char a[20],b[10],pname[50];
 int d[60],size;
	 FILE *fp1 = fopen("sym.txt", "w");
      FILE *fp2 = fopen("int.txt", "w");
    FILE *f = fopen("input4.txt", "r");
     pass1( a,b,d,pname,fp1,fp2,f,&size);
      fp1 = fopen("sym.txt", "r");
       f = fopen("int.txt", "r");
     fp2 = fopen("object.txt", "w");
     pass2( a,b,d,fp1,fp2,f);
     objprog(pname,d,size);   
	 	
}
コード例 #13
0
ファイル: dcheck.c プロジェクト: MartinGeisse/vshg01
void check(char *file)
{
	int i;
	int j;

	fi = open(file, 0);
	if(fi < 0) {
		printf("cannot open %s\n", file);
		nerror++;
		return;
	}
	headpr = 0;
	printf("%s:\n", file);
	sync();
	bread((daddr_t)1, (char *)&sblock, sizeof(sblock));
	nfiles = sblock.s_isize*INOPB;
	ecount = malloc(nfiles);
	if (ecount==NULL) {
		printf("Not enough core\n");
		exit(04);
	}
	for (i=0; i<nfiles; i++)
		ecount[i] = 0;
	ino = 0;
	for(i=2;; i+=NI) {
		if(ino >= nfiles)
			break;
		bread((daddr_t)i, (char *)itab, sizeof(itab));
		for(j=0; j<INOPB*NI; j++) {
			if(ino >= nfiles)
				break;
			pass1(&itab[j]);
			ino++;
		}
	}
	ino = 0;
	for(i=2;; i+=NI) {
		if(ino >= nfiles)
			break;
		bread((daddr_t)i, (char *)itab, sizeof(itab));
		for(j=0; j<INOPB*NI; j++) {
			if(ino >= nfiles)
				break;
			pass2(&itab[j]);
			ino++;
		}
	}
	free(ecount);
}
コード例 #14
0
ファイル: pfopt.c プロジェクト: 0919061/PX4NuttX
void optFinalize(poffHandle_t poffHandle, poffProgHandle_t poffProgHandle)
{
  /* Build label / line number reference table */

  pass1(poffHandle, poffProgHandle);

  /* Reset for next pass */

  insn_ResetOpCodeRead(poffHandle);
  insn_ResetTmpOpCodeWrite(poffProgHandle);

  /* Now process all of the symbols */

  pass2(poffHandle, poffProgHandle);

  /* We do not use the debug function information so we do not bother
   * to fixup the label references.  Just discard this information.
   */

  poffDiscardDebugFuncInfo(poffHandle);

  /* Reset for next pass */

  insn_ResetOpCodeRead(poffHandle);

  /* Generate relocation information and replace all label references
   * in the code with actual program section data offsets.
   */

  pass3(poffHandle, poffProgHandle);

  /* Reset for next pass */

  insn_ResetOpCodeRead(poffHandle);
  insn_ResetTmpOpCodeWrite(poffProgHandle);

  /* Finally, replace file header entry point with the I-space offset */

  pass4(poffHandle);

  /* Clean up after ourselves */

  poffReleaseLabelReferences();
}
コード例 #15
0
ファイル: myfsck.c プロジェクト: Vvnesaa/fsck
int main(int argc, char *argv[]) {
	int fsck = 0;
	int opt;
	opterr = 0;
	while ((opt = getopt(argc, argv, "f:p:i:")) != -1) {
		switch (opt) {
			case 'f':
				fsck = 1;
			case 'p':
				theParNum = atoi(optarg);
				break;
			case 'i':
				diskFileName = optarg;
				break;
			default:
				break;
		}
	}
	if (diskFileName == 0) {
		printf("Argument error\n");
		return 0;
	}
//	printf("%d %d %s\n", fsck, pNum, diskFileName);
	
	printPartitionInfo(fsck);
	if (fsck) {
		int i;
//		printf("%d\n", pNum);
		for (i = 1; i <= pNum; ++i)
			if (par[i].type == EXT2_TYPE && (theParNum == 0 || theParNum == i)) {
			init(i, par[i].start);
			pass1();
			pass2();
			pass3();
			pass4();
			cleanup();
		}
	}
//	ext2fsutilTest(par[1].start, par[1].length);
	
	return 0;
}
コード例 #16
0
void MyWindow::render()
{
    if(!isVisible() || !isExposed())
        return;

    if (!mContext->makeCurrent(this))
        return;

    static bool initialized = false;
    if (!initialized) {
        initialize();
        initialized = true;
    }

    if (mUpdateSize) {
        glViewport(0, 0, size().width(), size().height());
        mUpdateSize = false;
    }

    float deltaT = currentTimeS - tPrev;
    if(tPrev == 0.0f) deltaT = 0.0f;
    tPrev = currentTimeS;
    angle += 0.25f * deltaT;
    if (angle > TwoPI) angle -= TwoPI;

    static float EvolvingVal = 0;
    EvolvingVal += 0.1f;

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBindFramebuffer(GL_FRAMEBUFFER, mFBOHandle);
    pass1();

    glBindFramebuffer(GL_FRAMEBUFFER, intermediateFBO);
    pass2();

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    pass3();

    mContext->swapBuffers(this);
}
コード例 #17
0
int main(void){
	
	/* do PASS 1 */
	if(!(source_file = fopen("source_code.txt", "r"))){
		printf("SOURCE CODE OPENED ERROR.\n");
		exit(1);
	}
	
	if(!(intermediate_file = fopen("intermediate_file.txt", "w"))){
		printf("INTERMEDIATE FILE CREATED ERROR.\n");
		exit(1);
	}
	
	init_Func();     // Initialization
	
	pass1();
	fclose(source_file);
	fclose(intermediate_file);
	printf("\n\n======================= PASS 1 finished. =======================\n\n\n");
	/* PASS 1 END */
	
	/* do PASS 2 */
	if(!(intermediate_file = fopen("intermediate_file.txt", "r"))){
		printf("INTERMEDIATE FILE OPENED ERROR.\n");
		exit(1);
	}
	
	if(!(object_file = fopen("object_file.txt", "w"))){
		printf("OBJECT FILE CAN NOT BE CREATED.\n");
		exit(1);
	}
	
	pass2();
	
	fclose(intermediate_file);
	fclose(object_file);
	/* PASS 2 END */
	printf("\n\n======================= PASS 2 finished. =======================\n\n\n");
	
	system("PAUSE");
	return 0;
}
コード例 #18
0
ファイル: importmxml.cpp プロジェクト: CammyVee/MuseScore
Score::FileError importMusicXMLfromBuffer(Score* score, const QString& /*name*/, QIODevice* dev)
      {
      //qDebug("importMusicXMLfromBuffer(score %p, name '%s', dev %p)",
      //       score, qPrintable(name), dev);

      MxmlLogger logger;
      logger.setLoggingLevel(MxmlLogger::Level::MXML_INFO);
      //logger.setLoggingLevel(MxmlLogger::Level::MXML_TRACE); // also include tracing

      // pass 1
      dev->seek(0);
      MusicXMLParserPass1 pass1(score, &logger);
      Score::FileError res = pass1.parse(dev);
      if (res != Score::FileError::FILE_NO_ERROR)
            return res;

      // pass 2
      dev->seek(0);
      MusicXMLParserPass2 pass2(score, pass1, &logger);
      return pass2.parse(dev);
      }
コード例 #19
0
		void UserPasswordUpdateAction::_setFromParametersMap(const ParametersMap& map)
		{
			try
			{
				_user = UserTableSync::GetEditable(
					map.get<RegistryKeyType>(PARAMETER_USER_ID),
					*_env
				);

				_password = map.get<string>(PARAMETER_PASS1, false);

				string pass2(map.getDefault<string>(PARAMETER_PASS2, string(), false));
				if (pass2 != _password)
					throw ActionException("Les mots de passe entrés ne sont pas identiques");

				if(_password.empty())
					throw ActionException("Le mot de passe ne peut pas être vide");
			}
			catch (ObjectNotFoundException<User>)
			{
				throw ActionException("Utilisateur introuvable");
			}
		}
コード例 #20
0
int main()
{
    pass1();
    pass2();
    return(0);
}
コード例 #21
0
ファイル: MAIN.C プロジェクト: akreddysoft/CollegeCode
int main(int argc,char **argv)
{

	char ofile[255];
	int j,res;

	if(argc==1)
	{
		printf("\nUse:asm85 [option] <filename>");
		printf("\noptions:");
		printf("\n-o <file> - Give the output filename");
		printf("\n-s  Show the machine opcode table");
		printf("\n-i  Enter opcodes into opcode table");
		printf("\nDefault mot file is mot.dat");
		printf("\n");
		return EXIT_SUCCESS;
	}

	if(argc>=2)
	{
		int flag=1;
		j=strcmp(*(argv+1),"-o");
		if(j==0)
		{
			flag=0;
			if(*(argv+2)==NULL)
			{
				printf("\nYou must specify an output file");
				return EXIT_SUCCESS;
			}
			else
				strcpy(ofile,*(argv+2));
			if(*(argv+3)==NULL)
			{
				printf("\nasm85: no input files specified");
				return EXIT_SUCCESS;
			}
			strcpy(filename,*(argv+3));
		}
		j=strcmp(*(argv+1),"-s");
		if(j==0)
		{
			char *file[]={"sdf","mot.dat"};
			flag=0;
			disp(2,&file);
			exit(EXIT_SUCCESS);
		}
		j=strcmp(*(argv+1),"-i");
		if(j==0)
		{
			char *file[]={"df","mot.dat"};
			flag=0;
			input(2,&file);
			exit(EXIT_SUCCESS);
		}

		if(flag)
		{
			strcpy(filename,*(argv+1));
			strcpy(ofile,"c:\\outfile.txt");
		}
	}

	else
	{
		strcpy(filename,*(argv+1));
		strcpy(ofile,"c:\\outfile.txt");
	}


	pass1();

	pass2();

	/*ASSEMBLING DONE, WRITE THE OUPUT FILES */
	res=writeoutfile(ofile);
	if(res==1)
	{
		fprintf(stderr,"\nAn error occur while writing to output file");
		return EXIT_FAILURE;
	}
	else
		printf("\nOutput written to %s",ofile);


	return EXIT_SUCCESS;
}
コード例 #22
0
bool MultiBootPatcher::Impl::patchZip()
{
    std::unordered_set<std::string> excludeFromPass1;

    for (auto const &item : info->patchInfo()->autoPatchers()) {
        auto args = info->patchInfo()->autoPatcherArgs(item);

        auto *ap = pc->createAutoPatcher(item, info, args);
        if (!ap) {
            error = PatcherError::createPatcherCreationError(
                    ErrorCode::AutoPatcherCreateError, item);
            return false;
        }

        // TODO: AutoPatcher::newFiles() is not supported yet

        std::vector<std::string> existingFiles = ap->existingFiles();
        if (existingFiles.empty()) {
            pc->destroyAutoPatcher(ap);
            continue;
        }

        autoPatchers.push_back(ap);

        // AutoPatcher files should be excluded from the first pass
        for (auto const &file : existingFiles) {
            excludeFromPass1.insert(file);
        }
    }

    // Unlike the old patcher, we'll write directly to the new file
    if (!openOutputArchive()) {
        return false;
    }

    if (cancelled) return false;

    FileUtils::ArchiveStats stats;
    auto result = FileUtils::mzArchiveStats(info->filename(), &stats,
                                            std::vector<std::string>());
    if (!result) {
        error = result;
        return false;
    }

    maxBytes = stats.totalSize;

    if (cancelled) return false;

    // +1 for mbtool_recovery (update-binary)
    // +1 for bb-wrapper.sh
    // +1 for info.prop
    maxFiles = stats.files + 3;
    updateFiles(files, maxFiles);

    if (!openInputArchive()) {
        return false;
    }

    // Create temporary dir for extracted files for autopatchers
    std::string tempDir = FileUtils::createTemporaryDir(pc->tempDirectory());

    if (!pass1(zOutput, tempDir, excludeFromPass1)) {
        boost::filesystem::remove_all(tempDir);
        return false;
    }

    if (cancelled) return false;

    // On the second pass, run the autopatchers on the rest of the files

    if (!pass2(zOutput, tempDir, excludeFromPass1)) {
        boost::filesystem::remove_all(tempDir);
        return false;
    }

    boost::filesystem::remove_all(tempDir);

    if (cancelled) return false;

    updateFiles(++files, maxFiles);
    updateDetails("META-INF/com/google/android/update-binary");

    // Add mbtool_recovery
    result = FileUtils::mzAddFile(
            zOutput, "META-INF/com/google/android/update-binary",
            pc->dataDirectory() + "/binaries/android/"
                    + info->device()->architecture() + "/mbtool_recovery");
    if (!result) {
        error = result;
        return false;
    }

    if (cancelled) return false;

    updateFiles(++files, maxFiles);
    updateDetails("multiboot/bb-wrapper.sh");

    // Add bb-wrapper.sh
    result = FileUtils::mzAddFile(
        zOutput, "multiboot/bb-wrapper.sh",
        pc->dataDirectory() + "/scripts/bb-wrapper.sh");
    if (!result) {
        error = result;
        return false;
    }

    if (cancelled) return false;

    updateFiles(++files, maxFiles);
    updateDetails("multiboot/info.prop");

    const std::string infoProp = createInfoProp();
    result = FileUtils::mzAddFile(
            zOutput, "multiboot/info.prop",
            std::vector<unsigned char>(infoProp.begin(), infoProp.end()));
    if (!result) {
        error = result;
        return false;
    }

    if (cancelled) return false;

    return true;
}
コード例 #23
0
ファイル: StmtNodes.cpp プロジェクト: andrewleech/firebird
DmlNode* DmlNode::pass2(thread_db* tdbb, CompilerScratch* csb, jrd_nod* aNode)
{
	node = aNode;
	return pass2(tdbb, csb);
}
コード例 #24
0
//function to display the menu
void menu()
{
	int choice,ret;

	printf("\n\n\tAssembler to Our ISA::\n");
	printf("\tThe menu is:\n");
	printf("\t1.Display Assembly Language Code.\n"); // displays the code you have typed.
	printf("\t2.Display Machine Code.\n");  // displays the machine code generated on the console itself.
	printf("\t3.Display Symbol Table.\n"); // displays only the symbol table and no machine code is generated.
	printf("\t4.Generate Machine Code.\n"); // generates all the files symbol table file and machine code file but not displayed on console.
	printf("\t5.ISA Help.\n"); // to display the isa help
	printf("\t6.Exit.\n"); // to exit from file
	printf("\n\nEnter your choice?\n");
	scanf("%d",&choice);
	switch(choice)
	{
		
		case 1:

				printf("\n\tThe Assembly Language Code is:\n");
				displaycode();
				menu();
				break;
		
		case 2:
				ret=pass1();
				if(ret!=0)
				{
					printf("\n%d Errors in code.Please check the program.!\n",ret);
					menu();
				}
				else
				{
					pass2(); // pass2 function generates the machine code.
					displaymachinecode();
					menu();
				}
				break;
		case 3:
			
				ret=pass1();
				if(ret!=0)
				{
					printf("Cannot Display Symbol Table.\n");
					printf("\n%d Errors in code.Please check the program.!\n",ret);
					menu();
				}
				else
				{
					printf("The symbol Table is as follows::\n\n");
					displaysymboltable(); //displays the symbol table
					menu();
				}
				break;

		case 4:

				ret=pass1();
				if(ret!=0)
				{
					printf("\n%d Errors in code.Please check the program.!\n",ret);
					menu();
				}
				else
				{
					pass2(); // pass2 function generates the machine code.
					menu();
				}
				break;

		case 5:
				
				printf("The help is as follows::\n\n");
				help(); // displays the isa help.
				menu();
				break;

		case 6:

				exit(0);
				break;
		
		default:

				printf("Wrong Choice.Enter again..!!");
				menu();
	
	}
}
コード例 #25
0
ファイル: pmlogcheck.c プロジェクト: DundalkIT/pcp
int
main(int argc, char *argv[])
{
    int			c;
    int			sts;
    int			ctx;
    int			i;
    int			lflag = 0;	/* no label by default */
    int			nfile;
    int			n;
    char		*p;
    struct dirent	**namelist;
    __pmContext		*ctxp;
    char		*archpathname;	/* from the command line */
    char		*archdirname;	/* after dirname() */
    char		archname[MAXPATHLEN];	/* full pathname to base of archive name */

    while ((c = pmGetOptions(argc, argv, &opts)) != EOF) {
	switch (c) {
	case 'l':	/* display the archive label */
	    lflag = 1;
	    break;
	case 'v':	/* bump verbosity */
	    vflag++;
	    break;
	}
    }

    if (!opts.errors && opts.optind >= argc) {
	pmprintf("Error: no archive specified\n\n");
	opts.errors++;
    }

    if (opts.errors) {
	pmUsageMessage(&opts);
	exit(EXIT_FAILURE);
    }

    sep = __pmPathSeparator();
    setlinebuf(stderr);

    __pmAddOptArchive(&opts, argv[opts.optind]);
    opts.flags &= ~PM_OPTFLAG_DONE;
    __pmEndOptions(&opts);

    archpathname = argv[opts.optind];
    archbasename = strdup(basename(strdup(archpathname)));
    /*
     * treat foo, foo.index, foo.meta, foo.NNN as all equivalent
     * to "foo"
     */
    p = strrchr(archbasename, '.');
    if (p != NULL) {
	if (strcmp(p, ".index") == 0 || strcmp(p, ".meta") == 0)
	    *p = '\0';
	else {
	    char	*q = p;
	    q++;
	    if (isdigit(*q)) {
		/*
		 * foo.<digit> ... if archpathname does exist, then
		 * safe to strip digits, else leave as is for the
		 * case of, e.g. archive-20150415.041154 which is the
		 * pmmgr basename for an archive with a first volume
		 * named archive-20150415.041154.0
		 */
		if (access(archpathname, F_OK) == 0) {
		    q++;
		    while (*q && isdigit(*q))
			q++;
		    if (*q == '\0')
			*p = '\0';
		}
	    }
	}
    }
    archdirname = dirname(strdup(archpathname));
    if (vflag)
	fprintf(stderr, "Scanning for components of archive \"%s\"\n", archpathname);
    nfile = scandir(archdirname, &namelist, filter, NULL);
    if (nfile < 1) {
	fprintf(stderr, "%s: no PCP archive files match \"%s\"\n", pmProgname, archpathname);
	exit(EXIT_FAILURE);
    }

    /*
     * Pass 0 for data, metadata and index files ... check physical
     * archive record structure, then label record
     */
    sts = STS_OK;
    for (i = 0; i < nfile; i++) {
	char	path[MAXPATHLEN];
	if (strcmp(archdirname, ".") == 0) {
	    /* skip ./ prefix */
	    strncpy(path, namelist[i]->d_name, sizeof(path));
	}
	else {
	    snprintf(path, sizeof(path), "%s%c%s", archdirname, sep, namelist[i]->d_name);
	}
	if (pass0(path) == STS_FATAL)
	    /* unrepairable or unrepaired error */
	    sts = STS_FATAL;
    }
    if (meta_state == STATE_MISSING) {
	fprintf(stderr, "%s%c%s.meta: missing metadata file\n", archdirname, sep, archbasename);
	sts = STS_FATAL;
    }
    if (log_state == STATE_MISSING) {
	fprintf(stderr, "%s%c%s.0 (or similar): missing log file \n", archdirname, sep, archbasename);
	sts = STS_FATAL;
    }

    if (sts == STS_FATAL) {
	if (vflag) fprintf(stderr, "Due to earlier errors, cannot continue ... bye\n");
	exit(EXIT_FAILURE);
    }

    if ((sts = ctx = pmNewContext(PM_CONTEXT_ARCHIVE, archpathname)) < 0) {
	fprintf(stderr, "%s: cannot open archive \"%s\": %s\n", pmProgname, archpathname, pmErrStr(sts));
	fprintf(stderr, "Checking abandoned.\n");
	exit(EXIT_FAILURE);
    }

    if (pmGetContextOptions(ctx, &opts) < 0) {
        pmflush();      /* runtime errors only at this stage */
        exit(EXIT_FAILURE);
    }

    if (lflag)
	dumpLabel();

    /*
     * Note: ctxp->c_lock remains locked throughout ... __pmHandleToPtr()
     *       is only called once, and a single context is used throughout
     *       ... so there is no PM_UNLOCK(ctxp->c_lock) anywhere in the
     *       pmchecklog code.
     *       This works because ctxp->c_lock is a recursive lock and
     *       pmchecklog is single-threaded.
     */
    if ((n = pmWhichContext()) >= 0) {
	if ((ctxp = __pmHandleToPtr(n)) == NULL) {
	    fprintf(stderr, "%s: botch: __pmHandleToPtr(%d) returns NULL!\n", pmProgname, n);
	    exit(EXIT_FAILURE);
	}
    }
    else {
	fprintf(stderr, "%s: botch: %s!\n", pmProgname, pmErrStr(PM_ERR_NOCONTEXT));
	exit(EXIT_FAILURE);
    }

    if (strcmp(archdirname, ".") == 0)
	/* skip ./ prefix */
	strncpy(archname, archbasename, sizeof(archname) - 1);
    else
	snprintf(archname, sizeof(archname), "%s%c%s", archdirname, sep, archbasename);

    sts = pass1(ctxp, archname);

    if (index_state == STATE_BAD) {
	/* prevent subsequent use of bad temporal index */
	ctxp->c_archctl->ac_log->l_numti = 0;
    }

    sts = pass2(ctxp, archname);

    sts = pass3(ctxp, archname, &opts);

    if (vflag) {
	if (result_count > 0)
	    fprintf(stderr, "Processed %d pmResult records\n", result_count);
	if (mark_count > 0)
	    fprintf(stderr, "Processed %d <mark> records\n", mark_count);
    }

    return 0;
}
コード例 #26
0
ファイル: fsck.c プロジェクト: NoSuchProcess/FUZIX
int main(int argc, char **argv)
{
    char *buf;
    char *op;

    if(argc != 2){
        fprintf(stderr, "syntax: fsck [devfile][:offset]\n");
        return 1;
    }
    
    op = strchr(argv[1], ':');
    if (op) {
        *op++ = 0;
        offset = atol(op);
    }

    if(fd_open(argv[1])){
        printf("Cannot open file\n");
        return -1;
    }

    buf = daread(1);
    bcopy(buf, (char *) &superblock, sizeof(struct filesys));

    /* Verify the fsize and isize parameters */
    if (superblock.s_mounted == SMOUNTED_WRONGENDIAN) {
        swizzling = 1;
        printf("Checking file system with reversed byte order.\n");
    }

    if (swizzle16(superblock.s_mounted) != SMOUNTED) {
        printf("Device %d has invalid magic number %d. Fix? ", dev, superblock.s_mounted);
        if (!yes())
            exit(-1);
        superblock.s_mounted = swizzle16(SMOUNTED);
        dwrite((blkno_t) 1, (char *) &superblock);
    }
    printf("Device %d has fsize = %d and isize = %d. Continue? ",
            dev, swizzle16(superblock.s_fsize), swizzle16(superblock.s_isize));
    if (!yes())
        exit(-1);

    bitmap = calloc(swizzle16(superblock.s_fsize), sizeof(char));
    linkmap = (int16_t *) calloc(8 * swizzle16(superblock.s_isize), sizeof(int16_t));

    if (!bitmap || !linkmap) {
        fprintf(stderr, "Not enough memory.\n");
        exit(-1);
    }

    printf("Pass 1: Checking inodes...\n");
    pass1();

    printf("Pass 2: Rebuilding free list...\n");
    pass2();

    printf("Pass 3: Checking block allocation...\n");
    pass3();

    printf("Pass 4: Checking directory entries...\n");
    pass4();

    printf("Pass 5: Checking link counts...\n");
    pass5();

    printf("Done.\n");

    exit(0);
}
コード例 #27
0
ファイル: as0m.c プロジェクト: cccnqu1/cccwd
int main(int argc, char *argv[]) {
  char *filename=argv[1];
  pass1(filename);
  pass2(filename);
}
コード例 #28
0
ファイル: ncheck.c プロジェクト: AlainODea/illumos-gate
void
check(char *file)
{
	int i, j, c;

	fi = open64(file, 0);
	if (fi < 0) {
		(void) fprintf(stderr, "ncheck: cannot open %s\n", file);
		nerror++;
		return;
	}
	nhent = 0;
	(void) printf("%s:\n", file);
	sync();
	bread((diskaddr_t)SBLOCK, (char *)&sblock, SBSIZE);
	if ((sblock.fs_magic != FS_MAGIC) &&
	    (sblock.fs_magic != MTB_UFS_MAGIC)) {
		(void) printf("%s: not a ufs file system\n", file);
		nerror++;
		return;
	}

	if ((sblock.fs_magic == FS_MAGIC) &&
	    ((sblock.fs_version != UFS_EFISTYLE4NONEFI_VERSION_2) &&
	    (sblock.fs_version != UFS_VERSION_MIN))) {
		(void) printf("%s: unrecognized ufs version number %d\n",
		    file, sblock.fs_version);
		nerror++;
		return;
	}

	if ((sblock.fs_magic == MTB_UFS_MAGIC) &&
	    ((sblock.fs_version > MTB_UFS_VERSION_1) ||
	    (sblock.fs_version < MTB_UFS_VERSION_MIN))) {
		(void) printf("%s: unrecognized ufs version number %d\n",
		    file, sblock.fs_version);
		nerror++;
		return;
	}

	/* If fs is logged, roll the log. */
	if (sblock.fs_logbno) {
		switch (rl_roll_log(file)) {
		case RL_SUCCESS:
			/*
			 * Reread the superblock.  Rolling the log may have
			 * changed it.
			 */
			bread((diskaddr_t)SBLOCK, (char *)&sblock, SBSIZE);
			break;
		case RL_SYSERR:
			(void) printf("Warning: cannot roll log for %s.  %s\n",
				file, strerror(errno));
			break;
		default:
			(void) printf("Warning: cannot roll log for %s.\n",
				file);
			break;
		}
	}

	itab = (struct dinode *)extend_tbl((uchar_t *)itab, &itab_size,
		(unsigned)(sblock.fs_ipg * sizeof (struct dinode)));
	if (itab == 0) {
		(void) fprintf(stderr,
			"ncheck: not enough memory for itab table\n");
		nerror++;
		return;
	}

	hsize = sblock.fs_ipg * sblock.fs_ncg - sblock.fs_cstotal.cs_nifree + 1;

	htab = (struct htab *)extend_tbl((uchar_t *)htab, &htab_size,
		(unsigned)(hsize * sizeof (struct htab)));
	if (htab == 0) {
		(void) fprintf(stderr,
			"ncheck: not enough memory for htab table\n");
		nerror++;
		return;
	}

	if (!extend_strngtab(AVG_PATH_LEN * hsize)) {
		(void) printf("not enough memory to allocate tables\n");
		nerror++;
		return;
	}
	strngloc = 0;

	ino = 0;
	for (c = 0; c < sblock.fs_ncg; c++) {
		bread(fsbtodb(&sblock, cgimin(&sblock, c)), (char *)itab,
		    (int)(sblock.fs_ipg * sizeof (struct dinode)));
		for (j = 0; j < sblock.fs_ipg; j++) {
			if (itab[j].di_smode != 0) {
				itab[j].di_mode = itab[j].di_smode;
				if (itab[j].di_suid != UID_LONG)
					itab[j].di_uid = itab[j].di_suid;
				if (itab[j].di_sgid != GID_LONG)
					itab[j].di_gid = itab[j].di_sgid;
				pass1(&itab[j]);
			}
			ino++;
		}
	}
	ilist[ilist_index++].ino = 0;
	if (ilist_index > MAX_ILIST_INDEX())
		extend_ilist();
	ino = 0;
	for (c = 0; c < sblock.fs_ncg; c++) {
		bread(fsbtodb(&sblock, cgimin(&sblock, c)), (char *)itab,
		    (int)(sblock.fs_ipg * sizeof (struct dinode)));
		for (j = 0; j < sblock.fs_ipg; j++) {

			if (itab[j].di_smode != 0) {
				itab[j].di_mode = itab[j].di_smode;
				pass2(&itab[j]);
			}
			ino++;
		}
	}
	ino = 0;
	for (c = 0; c < sblock.fs_ncg; c++) {
		bread(fsbtodb(&sblock, cgimin(&sblock, c)), (char *)itab,
		    (int)(sblock.fs_ipg * sizeof (struct dinode)));
		for (j = 0; j < sblock.fs_ipg; j++) {
			if (itab[j].di_smode != 0) {
				itab[j].di_mode = itab[j].di_smode;
				pass3(&itab[j]);
			}
			ino++;
		}
	}
	(void) close(fi);

	/*
	 * Clear those elements after inodes specified by "-i" out of
	 * ilist.
	 */
	for (i = iflg; i < ilist_index; i++) {
		ilist[i].ino = 0;
	}
	ilist_index = iflg;
}
コード例 #29
0
int main()
{FILE *fp,*fpn,*fpo;
fpa=fopen("ALA.dil","wb+");
fclose(fpa);
fpa=fopen("ALA2.dil","wb+");
fclose(fpa);
char stu[15];//For storing the operand so that endl value is not passed along with it
int i;
  fpo=fopen("Output.txt","w+");
  fclose(fpo);
fpm=fopen("MDT.dil","wb+");
fclose(fpm);//For initialising the needed files
int flag=0;
fp=fopen("Input.txt","r");
while(!feof(fp))
{
            fscanf(fp,"%s",label);
fscanf(fp,"%s",op);
fscanf(fp,"%s",operand);

if(flag==1)
macro();//If a macro definetion is found pass-1 is called

if(strcmp(op,"MACRO")==0)
flag=1; //Macro definetion found, flag is set so that from next step on, it can be stored in MDT


  if(strcmp(op,"MEND")==0)
  {
                            flag=0;s=0;
                         fseek(fpm,0,SEEK_END);   //For appending in the last, can be prevented if "a" attribute is used during the opening of file
  fwrite(&m,sizeof(m),1,fpm);
  fclose(fpm);
            }
            }

            rewind(fp);
             fpn=fopen("Input2.txt","w+");//creating the macro definetions free input for pass-2
             flag=0;
             i=0;
        while(!feof(fp))
{
            fscanf(fp,"%s",label);
fscanf(fp,"%s",op);
fscanf(fp,"%s",operand);

if(flag==1)
{if(strcmp(op,"MACRO")!=0)//If after MEND, MACRO is not found, that is the end of macro definetions
flag=2;
else
flag=0;}

if(flag==2)//After all the definetions ended we can set the flag to 2, and copy the remaining contents into new file
{fprintf(fpn,"%s\t%s\t%s\n",label,op,operand);
i++;
}

if(strcmp(op,"MEND")==0)
flag=1;//Checking whether MEND occurs
}

fclose(fpn);
fclose(fp);

          printf("Pass-1 is over\nThe definetions stored in MDT are:\n");
            fpm=fopen("MDT.dil","r");
            while(fread(&m,sizeof(m),1,fpm)==1)
            printf("%s\t\t\t\t\t\t%s",m.name,m.def);
            fclose(fpm);
            fpn=fopen("Input2.txt","r");


            ct=0;
             while(!feof(fpn))
             {


                   fscanf(fpn,"%s",label);
fscanf(fpn,"%s",op);
fscanf(fpn,"%s",operand);

                             pass2();
                           i--;
                           if(i==0)//To prevent the extra space of endl
                           break;

                             }
                              printf("The arguements stored in ALA are:\n");
            fpm=fopen("ALA2.dil","r");
            while(fread(&a1,sizeof(a1),1,fpm)==1)
            printf("%s\t%s\n",a1.hash,a1.arg);
            fclose(fpm);
                             printf("Pass-2 is over\n");
            getche();//To wait, so that screen is not closed abruptly


            }
コード例 #30
0
int main(int argc,char *argv[])
{
     int er=1,i;
     signed char *s=NULL;
     char *tmpp;

     int mifiles = 5;
     int nifiles = 0;
     int verbose = 0;
     int oldfile = 0;
     int no_link = 0;

     char **ifiles;
     char *ofile;
     char *efile;
     char *lfile;
     char *ifile;
     
     char old_e[MAXLINE];
     char old_l[MAXLINE];
     char old_o[MAXLINE];

     tim1=time(NULL);
     
     ncmos=0;
     n65816=0;
     cmosfl=1;
     w65816=0;	/* default: 6502 only */

     altppchar = '#' ; /* i.e., NO alternate char */

     if((tmpp = strrchr(argv[0],'/'))) {
	tmpp++;
     } else {
	tmpp = argv[0];
     }
     if( (!strcmp(tmpp,"xa65816"))
	|| (!strcmp(tmpp,"XA65816"))
	|| (!strcmp(tmpp,"xa816"))
	|| (!strcmp(tmpp,"XA816"))
	) {
	w65816 = 1;	/* allow 65816 per default */
     }

     /* default output charset for strings in quotes */
     set_charset("ASCII");

     ifiles = malloc(mifiles*sizeof(char*));

     afile = alloc_file();

     if (argc <= 1) {
          usage(w65816, stderr);
          exit(1);
     }

     if (strstr(argv[1], "--help")) {
          usage(w65816, stdout);
	  exit(0);
     }

     if (strstr(argv[1], "--version")) {
          version(programname, progversion, authors, copyright);
	  exit(0);
     }

     ofile="a.o65";
     efile=NULL;
     lfile=NULL;

     if(pp_init()) {
       logout("fatal: pp: no memory!");
       return 1;
     }
     if(b_init()) {
       logout("fatal: b: no memory!");
       return 1;
     }
     if(l_init()) {
       logout("fatal: l: no memory!");
       return 1;
     }

     i=1;
     while(i<argc) {
	if(argv[i][0]=='-') {
	  switch(argv[i][1]) {
	  case 'p':
		/* intentionally not allowing an argument to follow with a
			space to avoid - being seen as the alternate
			preprocessor char! */
		if (argv[i][2] == '\0') {
			fprintf(stderr, "-p requires a character argument\n");
			exit(1);
		}
		if (argv[i][2] == '#')
			fprintf(stderr,
				"using -p# is evidence of stupidity\n");
		altppchar = argv[i][2];
		if (argv[i][3] != '\0')
			fprintf(stderr,
				"warning: extra characters to -p ignored\n");
		break;
	  case 'M':
		masm = 1;	/* MASM compatibility mode */
		break;
	  case 'O':		/* output charset */
		{
		  char *name = NULL;
		  if (argv[i][2] == 0) { 
		    name = argv[++i]; 
		  } else {
		    name = argv[i]+2;
		  }
		  if (set_charset(name) < 0) {
		    fprintf(stderr, "Output charset name '%s' unknown - ignoring! (check case?)\n", name);
		  }
		}
		break;
	  case 'A':		/* make text segment start so that text relocation
				   is not necessary when _file_ starts at adr */
		romable = 2;
		if(argv[i][2]==0) romaddr = atoi(argv[++i]);
		else romaddr = atoi(argv[i]+2);
		break;
	  case 'G':
		noglob = 1;
		break;
	  case 'L':		/* define global label */
		if(argv[i][2]) lg_set(argv[i]+2);
		break;
	  case 'r':
		crossref = 1;
		break;
	  case 'R':
		relmode = 1;
		break;
	  case 'D':
		s = (signed char*)strstr(argv[i]+2,"=");
		if(s) *s = ' ';
		pp_define(argv[i]+2);
		break;
	  case 'c':
		no_link = 1;
		fmode |= FM_OBJ;
		break;
	  case 'v':
		verbose = 1;
		break;
	  case 'C':
		cmosfl = 0;
		break;
          case 'W':
                w65816 = 0;
                break;
          case 'w':
                w65816 = 1;
                break;
	  case 'B':
		showblk = 1;
		break;
	  case 'x':		/* old filename behaviour */
		oldfile = 1;
		fprintf(stderr, "Warning: -x is now deprecated and may disappear in future versions!\n");
		break;
	  case 'I':
		if(argv[i][2]==0) {
		  reg_include(argv[++i]);
		} else {
		  reg_include(argv[i]+2);
		}
		break;
	  case 'o':
		if(argv[i][2]==0) {
		  ofile=argv[++i];
		} else {
		  ofile=argv[i]+2;
		}
		break;
	  case 'l':
		if(argv[i][2]==0) {
		  lfile=argv[++i];
		} else {
		  lfile=argv[i]+2;
		}
		break;
	  case 'e':
		if(argv[i][2]==0) {
		  efile=argv[++i];
		} else {
		  efile=argv[i]+2;
		}
		break;
	  case 'b':			/* set segment base addresses */
		switch(argv[i][2]) {
		case 't':
			if(argv[i][3]==0) tbase = atoi(argv[++i]);
			else tbase = atoi(argv[i]+3);
			break;
		case 'd':
			if(argv[i][3]==0) dbase = atoi(argv[++i]);
			else dbase = atoi(argv[i]+3);
			break;
		case 'b':
			if(argv[i][3]==0) bbase = atoi(argv[++i]);
			else bbase = atoi(argv[i]+3);
			break;
		case 'z':
			if(argv[i][3]==0) zbase = atoi(argv[++i]);
			else zbase = atoi(argv[i]+3);
			break;
		default:
			fprintf(stderr,"unknown segment type '%c' - ignoring!\n",
								argv[i][2]);
			break;
		}
		break;
	  case 0:
		fprintf(stderr, "Single dash '-' on command line - ignoring!\n");
		break;
	  default:
		fprintf(stderr, "Unknown option '%c' - ignoring!\n",argv[i][1]);
		break;
	  }
	} else {		/* no option -> filename */
	  ifiles[nifiles++] = argv[i];
	  if(nifiles>=mifiles) {
	    mifiles += 5;
	    ifiles=realloc(ifiles, mifiles*sizeof(char*));
	    if(!ifiles) {
		fprintf(stderr, "Oops: couldn't alloc enough mem for filelist table..!\n");
		exit(1);
	    }
	  }
	}
	i++;
     }
     if(!nifiles) {
	fprintf(stderr, "No input files given!\n");
	exit(0);
     }

     if(oldfile) {
	strcpy(old_e, ifiles[0]);
	strcpy(old_o, ifiles[0]);
	strcpy(old_l, ifiles[0]);

	if(setfext(old_e,".err")==0) efile = old_e;
	if(setfext(old_o,".obj")==0) ofile = old_o;
	if(setfext(old_l,".lab")==0) lfile = old_l;
     }

     fplab= lfile ? xfopen(lfile,"w") : NULL;
     fperr= efile ? xfopen(efile,"w") : NULL;
     if(!strcmp(ofile,"-")) {
	ofile=NULL;
        fpout = stdout;
     } else {
        fpout= xfopen(ofile,"wb");
     }
     if(!fpout) {
	fprintf(stderr, "Couldn't open output file!\n");
	exit(1);
     }

     if(verbose) fprintf(stderr, "%s\n",copyright);

     if(1 /*!m_init()*/)
     {
       if(1 /*!b_init()*/)
       {
         if(1 /*!l_init()*/)
         {
           /*if(!pp_init())*/
           {
             if(!x_init())
             {
	       if(fperr) fprintf(fperr,"%s\n",copyright);
	       if(verbose) logout(ctime(&tim1));

	       /* Pass 1 */

               pc[SEG_ABS]= 0;		/* abs addressing */
	       seg_start(fmode, tbase, dbase, bbase, zbase, 0, relmode);

	       if(relmode) {
		 r_mode(RMODE_RELOC);
		 segment = SEG_TEXT;
	       } else {
		 r_mode(RMODE_ABS);
	       }

	       nolink = no_link;

               for (i=0; i<nifiles; i++)
               {
		 ifile = ifiles[i];

                 sprintf(out,"xAss65: Pass 1: %s\n",ifile);
                 if(verbose) logout(out);

                 er=pp_open(ifile);
                    puttmp(0);
                    puttmp(T_FILE);
                    puttmp(0);
                    puttmp(0);
                    puttmps((signed char*)&ifile, sizeof(filep->fname));

                 if(!er) {
                   er=pass1();
                   pp_close();
                 } else {
		   sprintf(out, "Couldn't open source file '%s'!\n", ifile);
		   logout(out);
                 }
               }           

	       if((er=b_depth())) {
		 sprintf(out,"Still %d blocks open at end of file!\n",er);
		 logout(out);
	       }

	       if(tbase & (align-1)) {
		   sprintf(out,"Warning: text segment ($%04x) start address doesn't align to %d!\n", tbase, align);
		   logout(out);
	       }
	       if(dbase & (align-1)) {
		   sprintf(out,"Warning: data segment ($%04x) start address doesn't align to %d!\n", dbase, align);
		   logout(out);
	       }
	       if(bbase & (align-1)) {
		   sprintf(out,"Warning: bss segment ($%04x) start address doesn't align to %d!\n", bbase, align);
		   logout(out);
	       }
	       if(zbase & (align-1)) {
		   sprintf(out,"Warning: zero segment ($%04x) start address doesn't align to %d!\n", zbase, align);
		   logout(out);
	       }
               if (n65816>0)
                   fmode |= 0x8000;
	       switch(align) {
		case 1: break;
		case 2: fmode |= 1; break;
		case 4: fmode |= 2; break;
		case 256: fmode |=3; break;
	       }
	       
	       if((!er) && relmode) 
			h_write(fpout, fmode, tlen, dlen, blen, zlen, 0);


               if(!er)
               {
                    if(verbose) logout("xAss65: Pass 2:\n");

		    seg_pass2();

	            if(!relmode) {
	              r_mode(RMODE_ABS);
	            } else {
	              r_mode(RMODE_RELOC);
		      segment = SEG_TEXT;
	            }
                    er=pass2();
               } 

               if(fplab) printllist(fplab);
               tim2=time(NULL);
	       if(verbose) printstat();

	       if((!er) && relmode) seg_end(fpout);	/* write reloc/label info */
			                              
               if(fperr) fclose(fperr);
               if(fplab) fclose(fplab);
               if(fpout) fclose(fpout);

             } else {
               logout("fatal: x: no memory!\n");
             }
             pp_end();
/*           } else {
             logout("fatal: pp: no memory!");*/
           }
         } else {
          logout("fatal: l: no memory!\n");
         }
       } else {
          logout("fatal: b: no memory!\n");
       }
       /*m_exit();*/
     } else { 
          logout("Not enough memory available!\n");
     }

     if(ner || er)
     {
          fprintf(stderr, "Break after %d error%c\n",ner,ner?'s':0);
	  /*unlink();*/
	  if(ofile) {
	    unlink(ofile);
	  }
     }

     free(ifiles);

     return( (er || ner) ? 1 : 0 );
}