コード例 #1
0
ファイル: undo.cpp プロジェクト: BackupTheBerlios/eu07-svn
void Undo::perform()
{
     if ( ! ( button_undo && button_record ) )
     {
          Publisher::warn("Code bud:\nUndo button enabled before init call");
          return;
     }

    if ( najmlodszy - najstarszy < 0 )
    {
         Publisher::warn("Code bug:\nUndo button clicked when no tmp files were available");
         return;
    }

    printf ( "Odczyt z %s\n", tmp_name(najmlodszy).c_str() );
    if ( ! ( Editor::instance()->loadFromFile(tmp_name(najmlodszy).c_str()) ) )
    {
         Publisher::err ( std::string("") + 
                          "Could not load temporary file, current scenery is damaged\n" +
                          "check the log for details,\n" +
                          "look for earlier temporary files in " +
                          TMP_DIR_NAME + "directory,\n" +
                          "copy them if may be invaluable,\n"
                          "click OK to exit"
                          );
    }

    najmlodszy--;

    if ( najmlodszy - najstarszy < 0 )
       gtk_widget_set_sensitive(button_undo,FALSE);
}
コード例 #2
0
ファイル: undo.cpp プロジェクト: BackupTheBerlios/eu07-svn
void Undo::store()
{
     if ( ! ( button_undo && button_record ) )
     {
          Publisher::warn("Code bug:\nStore button enabled before init call");
          return;
     }

     if ( najmlodszy - najstarszy + 1 >= MAX_FILES )
     { // skasowac najstarszy
       printf("Kasujemy %s\n",tmp_name(najstarszy).c_str());
        if ( remove ( tmp_name(najstarszy).c_str() ) )
           Publisher::warn ( std::string("Temporary file (undo) removing problem:\n")
                             + sys_errlist[errno] );
        najstarszy++;
     }

     if ( Editor::instance()->saveToFile(tmp_name(najmlodszy+1).c_str()) )
     {
        printf ( "Zapis do %s\n", tmp_name(najmlodszy+1).c_str() );
        najmlodszy++;
        gtk_widget_set_sensitive(button_undo,TRUE);
     }
     else
        Publisher::warn("Store failed,\ncould not save temporary file (undo),\ncheck the log for details");
}
コード例 #3
0
ファイル: htm_lex.cpp プロジェクト: prestocore/browser
OP_STATUS LogdocXmlName::SetName(const uni_char *qname, unsigned int qname_len, BOOL is_xml)
{
	if (!is_xml)
	{
		XMLCompleteNameN tmp_name(NULL, 0, NULL, 0, qname, qname_len);
		return m_name.Set(tmp_name);
	}

	XMLCompleteNameN tmp_name(qname, qname_len);
	return m_name.Set(tmp_name);
}
コード例 #4
0
ファイル: tmp2.c プロジェクト: chmod644/practical_c
int main(void)
{
	char *tmp_name(void);
	char name1[100];
	char name2[100];

	strcpy(name1, tmp_name());
	strcpy(name2, tmp_name());

	printf("Name: %s\n", name1);
	printf("Name: %s\n", name2);
	return 0;
}
コード例 #5
0
ファイル: productivity.c プロジェクト: priyancka/caps
/*-------------------------------------------------------------------------*
 *  Get All DAta
 *-------------------------------------------------------------------------*/
store_all()
{
  register long i, found;

  tmp_name(temp_file);                    /* get a temporary file name       */
  fp = fopen(temp_file, "w+");

  if (fp == 0)
  {
    krash("store_data", "open tmp", 1);
  }
  found = 0;

  for (i = 0; i < pr->pr_picklines; i++)
  {
    if (!pl[i].pl_pl) continue;
    if (pickline && pickline != i+1) continue;
    
    if (found)                             /* after first pickline           */
    {
      fprintf(fp, "%79c\n", 0x20);
      if (!summary)
      {
        fprintf(fp, "%79c\n", 0x20);
        fprintf(fp, "%79c\n", 0x20);
        fprintf(fp, "%79c\n", 0x20);
      }
    }
    store_data(i);                         /* store one pickline             */
    found = 1;
  }
  if (!found) eh_post(ERR_PROD, 0);

  return found;
}
コード例 #6
0
void HistogramManager::createBJetSummedHistograms3D(DataType::value type) {
	for (unsigned short jetbinSum = 0; jetbinSum < BJetBinSummed::NUMBER_OF_SUMMED_BJET_BINS; ++jetbinSum) {
		for (unordered_map<std::string, TH3Array>::iterator iter = collection3D.begin(); iter != collection3D.end();
				++iter) {
			string collectionName = iter->first;
			TH3CollectionRef coll = iter->second[type];
			unordered_map<std::string, TH3Ptr> histMap = coll->getAllHistograms();

			for (unordered_map<std::string, TH3Ptr>::const_iterator histIter = histMap.begin();
					histIter != histMap.end(); ++histIter) {
				string name = histIter->first;
				//check if it is a Bjet-binned histogram
				if (!boost::algorithm::ends_with(name, BJetBin::names[jetbinSum]))
					continue;

				string tmp_name(name);
				boost::algorithm::replace_last(tmp_name, BJetBin::names[jetbinSum], BJetBinSummed::names[jetbinSum]);
				TH3Ptr hist((TH3*) histIter->second->Clone(tmp_name.c_str()));
				string title(hist->GetTitle());
				boost::algorithm::replace_last(title, BJetBin::names[jetbinSum], BJetBinSummed::names[jetbinSum]);
				hist->SetTitle(title.c_str());

				for (unsigned short jetbin = jetbinSum + 1; jetbin < BJetBin::NUMBER_OF_BJET_BINS; ++jetbin) {
					string histName = name;
					//replace the suffix of the current <base> histogram with the value in the loop.
					boost::algorithm::replace_last(histName, BJetBin::names[jetbinSum], BJetBin::names[jetbin]);

					hist->Add(collection3D[collectionName][type]->get(histName).get());
				}
				collection3D[collectionName][type]->add(tmp_name, hist);
			}
		}
	}
}
コード例 #7
0
ファイル: 13_2.c プロジェクト: lastcat/CRenshuu
int main(){
  char *tmp_name(void);
  //char *name1;
  //char *name2;
  char name1[5];
  char name2[5];
//ptrとして同じ場所を刺してしまっているので、両方tmp2になる(後の変更が適用される)
  //name1 = tmp_name();
  //name2 = tmp_name();
  //配列として宣言してstrcpyすればよい。
  strcpy(name1, tmp_name());
  strcpy(name2, tmp_name());

  printf("Name1: %s\n", name1);
  printf("Name2: %s\n", name2);
  return (0);
}
コード例 #8
0
ファイル: tmp-name.c プロジェクト: rumidier/bestpractice
int
main (int argc, char *argv[])
{
  char *tmp_name (void);  /* 임시 파일명 얻기 */

  printf ("Name: %s\n", tmp_name());

  return 0;
}
コード例 #9
0
ファイル: SubjectNameFlat.cpp プロジェクト: neilgroves/MlbDev
// ////////////////////////////////////////////////////////////////////////////
bool SubjectNameFlat::IsPatternSubjectName(const char *subject_name)
{
	try {
		SubjectNameFlat tmp_name(subject_name);
		return(tmp_name.IsPattern());
	}
	catch (...) {
	}

	return(false);
}
コード例 #10
0
ファイル: SubjectNameFlat.cpp プロジェクト: neilgroves/MlbDev
// ////////////////////////////////////////////////////////////////////////////
bool SubjectNameFlat::IsFullNameSubjectName(const char *subject_name)
{
	try {
		SubjectNameFlat tmp_name(subject_name);
		return(tmp_name.IsFullName());
	}
	catch (const std::exception &) {
	}

	return(false);
}
コード例 #11
0
static bool
ConfirmDeleteProfile(const TCHAR *name)
{
  StaticString<256> tmp;
  StaticString<256> tmp_name(name);
  if (tmp_name.length() > 4)
    tmp_name.Truncate(tmp_name.length() - 4);

  tmp.Format(_("Delete \"%s\"?"),
             tmp_name.c_str());
  return ShowMessageBox(tmp, _("Delete"), MB_YESNO) == IDYES;
}
コード例 #12
0
void fr_pp_frags(FILE *out)
{
    list_t p;

    fprintf(out, "STRING FRAGMENTS:\n");
    for (p = _string_frags; p; p = p->next)
    {
        fr_frag_t frag = p->data;
        fprintf(out, "    %s: \"%s\"\n", tmp_name(frag->u.string.label), frag->u.string.string);
    }
    fprintf(out, "\n");
}
コード例 #13
0
ファイル: PlaneListDialog.cpp プロジェクト: CnZoom/XcSoarPull
inline void
PlaneListWidget::DeleteClicked()
{
  assert(GetList().GetCursorIndex() < list.size());

  StaticString<256> tmp;
  StaticString<256> tmp_name(list[GetList().GetCursorIndex()].name.c_str());
  if (tmp_name.length() > 4)
    tmp_name.Truncate(tmp_name.length() - 4);

  tmp.Format(_("Delete plane \"%s\"?"),
             tmp_name.c_str());
  if (ShowMessageBox(tmp, _("Delete"), MB_YESNO) != IDYES)
    return;

  File::Delete(list[GetList().GetCursorIndex()].path);
  UpdateList();
}
コード例 #14
0
ファイル: DllLoader.cpp プロジェクト: mlbrock/MlbDev
// ////////////////////////////////////////////////////////////////////////////
void DllLoader::LoadDll()
{
	if (IsLoaded())
		return;

	HMODULE                     this_handle;
	MLB::Utility::VersionNumber this_version;

	if ((this_handle = OS_GetModuleHandle(dll_name_, false)) != NULL) {
		if (!(dll_load_flags_ & PassIfAlreadyLoaded))
			MLB::Utility::ThrowException("Unable to load dll '" + dll_name_ +
				"' because it is already loaded into this process's address "
				"space.");
		try {
			std::string                 tmp_name(OS_GetModuleFileName(this_handle));
			MLB::Utility::VersionNumber tmp_version(
				DetermineProductVersion(tmp_name));
			this_version = tmp_version;
			if (!dll_predicate_ptr_->IsVersionMatch(tmp_name))
				MLB::Utility::ThrowException("The matching predicate reports that "
					"the loaded dll (product version " + tmp_version.ToString() +
					") is not compatible (" +
					dll_predicate_ptr_->DescribePredicate() + ").");
		}
		catch (const std::exception &except) {
			MLB::Utility::Rethrow(except, "Unable to load dll '" + dll_name_ +
				"' which is already loaded into this process's address space: " +
				std::string(except.what()));
		}
	}
	else if ((this_handle = ResolveAndLoadDll(dll_name_, *dll_predicate_ptr_,
		dll_full_name_)) == NULL)
		MLB::Utility::ThrowException("Unable to load dll '" + dll_name_ +
			"' because it could not be located (a total of " +
			MLB::Utility::AnyToString(dll_predicate_ptr_->candidate_list_.size()) +
			" potential candidate(s) were found, with the highest version number "
			"being " + dll_predicate_ptr_->GetBestMatchVersion().ToString() +
			").");
	else
		this_version = dll_predicate_ptr_->GetBestMatchVersion();

	dll_handle_  = this_handle;
	dll_version_ = this_version;
}
コード例 #15
0
ファイル: test_filters.cpp プロジェクト: lanurmi/botan
      Test::Result test_data_src_sink_flush()
      {
          Test::Result result("DataSinkFlush");

#if defined(BOTAN_HAS_CODEC_FILTERS)
          std::string tmp_name("botan_test_data_src_sink_flush.tmp");
          std::ofstream outfile(tmp_name);

          Botan::Pipe pipe(new Botan::Hex_Decoder, new Botan::DataSink_Stream(outfile));

          Botan::DataSource_Memory input_mem("65666768");
          pipe.process_msg(input_mem);

          std::ifstream outfile_read(tmp_name);
          std::stringstream ss;
          ss << outfile_read.rdbuf();
          std::string foo = ss.str();

          result.test_eq("output string", ss.str(), "efgh");

          std::remove(tmp_name.c_str());
#endif
          return result;
      }
コード例 #16
0
ファイル: check_logins.c プロジェクト: priyancka/caps
main()
{
  FILE *td;
  unsigned short int k       = 0,
                     results = 0;
  struct zone_item *z;
  char kernel_check[12],
       command[80],
       tmpname[16];

  memset(kernel_check, 0x0, 12);
  memset(command, 0x0, 80);
  memset(tmpname, 0x0, 16);

  putenv("_=check_caps");                  /* name to environ   */
  chdir(getenv("HOME"));                   /* to home directory  */

  tmp_name(tmpname);
  sprintf(command, "%s > %s",
          "ps -ef|grep -v grep|grep ' bin/kernel'|cut -c54-63",
          tmpname);
  system(command);

  td = fopen(tmpname, "r");
  if (td == 0)
     {
       exit(-1);
     }

  fgets(kernel_check, 11, td);

  if (td)
     {
       fclose(td);
       unlink(tmpname);
     }

  if (strcmp(kernel_check, KERNELNAME) != 0)
     {
       printf("System not started\n");
       exit(4);
     }

  ss_open();
  co_open();

  if (sp->sp_config_status != 'y')
     {
       printf("System is not configured\n");
       close_all();
       exit(4);
     }
  else
     {
       if (sp->sp_in_process_status != 'x')
          {
            printf("System is Busy\n");
            close_all();
            exit(-1);
          }

       results = 0;

       for (k = 0; k < coh->co_zone_cnt; k++)
           {
             z = &zone[k];

             if (z->zt_picker)
                {
                  results = 1;
                  break;
                }
           } /* end of for loop to check each configured zone */

       if (results)
          {
            printf("Picker ID %ld is logged in at zone %d\n",
                   z->zt_picker, z->zt_zone);
            close_all();
            exit(1);
          }
       else
          {
            printf("No logins present\n");
            close_all();
            exit(0);
          }
     }
} /* end of main() */
コード例 #17
0
ファイル: WriteGMV.cpp プロジェクト: chrismullins/moab
ErrorCode WriteGMV::local_write_mesh(const char *file_name,
                                       const EntityHandle output_set,
                                       const int user_dimension,
                                       const bool mesh,
                                       const bool poly_mesh)
{
  std::ofstream ofile;
  ErrorCode result;

  if (mesh) {
      // need to insert ".gmv"
    std::string tmp_name(file_name);
    tmp_name += ".gmv";
    ofile.open(tmp_name.c_str());
  }
  else if (poly_mesh) {
      // need to insert ".poly.gmv"
    std::string tmp_name(file_name);
    tmp_name += ".poly.gmv";
    ofile.open(tmp_name.c_str());
  }

  ofile << "gmvinput ascii" << std::endl;
  
    // get elements to be output
  Range dum_range, elements, all_verts;
  EntityType otype;
  if (poly_mesh) {
    result = mbImpl->get_entities_by_type(output_set, MBPOLYGON, elements, true);
    if (MB_SUCCESS != result) return result;
  }
  else {
    for (otype = CN::TypeDimensionMap[user_dimension].first;
         otype <= CN::TypeDimensionMap[user_dimension].second; otype++) {
      if (otype == MBPOLYGON || otype == MBPOLYHEDRON) continue;
      dum_range.clear();
      result = mbImpl->get_entities_by_type(output_set, otype, dum_range, true);
      if (MB_SUCCESS != result) return result;

      std::copy(dum_range.begin(), dum_range.end(), range_inserter(elements));
    }
  }
  
    // gather the vertices in these elements
  result = mbImpl->get_adjacencies(elements, 0, false, all_verts, Interface::UNION);
  if (MB_SUCCESS != result) return result;
  
  int num_verts = all_verts.size();
  
    // allocate coordinate arrays and put pointers to them in a list
  double *xcoord = new double[num_verts];
  double *ycoord = new double[num_verts];
  double *zcoord = new double[num_verts];
  std::vector<double*> coord_arrays;
  coord_arrays.push_back(xcoord);
  coord_arrays.push_back(ycoord);
  coord_arrays.push_back(zcoord);
  
    // fill them in, writing id tags at the same time
  result = mWriteIface->get_node_coords(3, num_verts, all_verts, mGlobalIdTag, 1, coord_arrays);
  if (MB_SUCCESS != result) return result;

  int i, j;
  
    //========================================
    // WRITE COORDINATE DATA TO FILE HERE

  ofile << "nodev " << num_verts << std::endl;
  for (i = 0; i < num_verts; i++) 
    ofile << xcoord[i] << " " << ycoord[i] << " " << zcoord[i] << std::endl;
  

    //========================================

  delete [] xcoord;
  delete [] ycoord;
  delete [] zcoord;

    // iterate over types in selected dimension

  std::vector<int> connect;
  std::vector<EntityHandle> connecth;

  if (mesh) {
    Range sub_range;
    
    ofile << "cells " << elements.size() << std::endl;
  
    for (otype = CN::TypeDimensionMap[user_dimension].first;
         otype <= CN::TypeDimensionMap[user_dimension].second; otype++) {

      if (otype == MBPOLYGON || otype == MBPOLYHEDRON) continue;
      
        // get the first element of this type in the range, and one past the last
      Range::iterator lower =
        Range::lower_bound(elements.begin(),
                             elements.end(),
                             CREATE_HANDLE(otype, MB_START_ID, i));
      Range::iterator upper =
        Range::lower_bound(elements.begin(),
                             elements.end(),
                             CREATE_HANDLE(otype+1, MB_START_ID, i));
      
      if (lower == upper) continue;
    
        // copy these elements into a subrange
      sub_range.clear();
      std::copy(lower, upper, range_inserter(sub_range));

        // make sure the connectivity array is big enough
      int verts_per = CN::VerticesPerEntity(otype);
      if (connect.size() < verts_per*sub_range.size())
        connect.reserve(verts_per*sub_range.size());
    
        // get the connectivity
      result = mWriteIface->get_element_connect(sub_range.size(),
                                              verts_per,
                                              mGlobalIdTag, sub_range,
                                              mGlobalIdTag, 1, &connect[0]);
      if (MB_SUCCESS != result) return result;

        //========================================
        // WRITE CONNECTIVITY DATA TO FILE HERE

      for (i = 0; i < (int) sub_range.size(); i++) {
        ofile << gmvTypeNames[otype] << " " << verts_per << std::endl;
        for (j = i*verts_per; j < (int) (i+1)*verts_per; j++)
          ofile << connect[j] << " ";
        ofile << std::endl;
      }

        //========================================
    }
  }
  
  else if (poly_mesh) {
  
      // write polygons/hedra, if any
    Range polygons, polyhedra;
    result = mbImpl->get_entities_by_type(output_set, MBPOLYGON, polygons, true);
    if (MB_SUCCESS != result) return result;
  
    result = mbImpl->get_entities_by_type(output_set, MBPOLYHEDRON, polyhedra, true);
    if (MB_SUCCESS != result) return result;

    if (polygons.size() == 0) return result;
  
      // mark polyhedra with global ids
    result = mWriteIface->assign_ids(polyhedra, mGlobalIdTag, 1);
    if (MB_SUCCESS != result) return result;

    ofile << "faces " << polygons.size() << " " << polyhedra.size() << std::endl;

    for (Range::iterator rit = polygons.begin(); rit != polygons.end(); rit++) {
        // get the vertices
      connecth.clear();
      result = mbImpl->get_connectivity(&(*rit), 1, connecth, true);
      if (MB_SUCCESS != result) return result;

      if (0 == connecth.size()) continue;
    
        // get the polyhedra, if any
      if (user_dimension == 3) {
        polyhedra.clear();
        result = mbImpl->get_adjacencies(Range(*rit, *rit), 3, false, polyhedra);
        if (MB_SUCCESS != result) return result;
    
          // put them in the connect array
        connecth.push_back((polyhedra.size() > 0 ? *polyhedra.begin() : 0));
        connecth.push_back((polyhedra.size() > 1 ? *polyhedra.rbegin() : 0));
      }
    
        // replace handles with ids
      connect.reserve(connecth.size());

        // pre-set polyhedra ids in case there aren't any
      connect[connecth.size()] = 0;
      connect[connecth.size()+1] = 0;
      result = mbImpl->tag_get_data(mGlobalIdTag, &connecth[0], 
                                    connecth.size()-2+polyhedra.size(),
                                    &connect[0]);
      if (MB_SUCCESS != result) return result;
    
        // write the data
      ofile << connecth.size()-2;
    
      for (i = 0; i < (int)connecth.size(); i++)
        ofile << " " << connect[i];

      ofile << std::endl;
    }
  }

  ofile << std::endl << "endgmv" << std::endl;
  
  ofile.close();
  
  return MB_SUCCESS;
}
コード例 #18
0
ファイル: orphan_picks.c プロジェクト: priyancka/caps
main()
{
  register struct pw_item *i;
  register struct st_item *s;
  register long k, errors;
  long pid, status;
  char command[80];
  
  putenv("_=orphan_picks");
  chdir(getenv("HOME"));
  
  database_open();

  ss_open();
  co_open();
  oc_open();
  od_open();
  
  if (sp->sp_sku_support == 'n') leave(0);
  
  errors = 0;
  tmp_name(fd_name);
  
  fd = fopen(fd_name, "w");
  if (fd == 0) krash("main", "open temp", 1);
  
  if (sp->sp_sku_support == 'y')           /* only when sku support          */
  {
    for (k = 0, i = pw; k < coh->co_prod_cnt; k++, i++)
    {
      if (i->pw_lines_to_go <= 0) continue;  /* has no picks                 */
  
      s = mod_lookup(k + 1);               /* find in sku table              */
      if (s) continue;                     /* module has a sku               */
    
      fprintf(fd, "No SKU Assigned To Module %d Has %d Picks\n", 
        k + 1, i->pw_lines_to_go);

      errors++;
    }
  }
#ifdef DEBUG
  fprintf(stderr, "errors=%d\n", errors);
#endif

  fprintf(fd, "\n\n");
  pick_setkey(1);
  
  begin_work();
  while (!pick_next(op_rec, NOLOCK))
  {
#ifdef DEBUG
  fprintf(stderr, "pl=%d  on=%d  mod=%d  flag=%x\n",
    op_rec->pi_pl, op_rec->pi_on, op_rec->pi_mod, op_rec->pi_flags);
#endif

    commit_work();
    begin_work();
    
    if (op_rec->pi_flags & VALIDATED) continue;
  
    fprintf(fd, 
      "Pickline: %2d  Order: %7.*d  Mod: %5d  SKU: %-15.15s  Quan: %3d\n",

      op_rec->pi_pl, rf->rf_on, op_rec->pi_on, op_rec->pi_mod,
      op_rec->pi_sku, op_rec->pi_ordered);

    errors++;
  }
  commit_work();
  fclose(fd);

  if (errors)
  {
    tmp_name(ed_name);

    if (fork() == 0)
    {
      execlp("prft", "prft", fd_name, ed_name, "sys/report/orphan_picks.h", 0);
      krash("main", "load prft", 1);
    }
    pid = wait(&status);
    if (!pid || status) krash("main", "prft failed", 1);
   
    sprintf(command, "%s %s", getenv("LPR"), fd_name);
  }
  else unlink(fd_name);
  leave(0);
}
コード例 #19
0
ファイル: symex_other.cpp プロジェクト: esbmc/esbmc
void goto_symext::symex_other()
{
  const goto_programt::instructiont &instruction = *cur_state->source.pc;

  expr2tc code2 = instruction.code;

  if(is_code_expression2t(code2))
  {
    // Represents an expression that gets evaluated, but does not have any
    // other effect on execution, i.e. doesn't contain a call or assignment.
    // This can, however, cause the program to fail if it dereferences an
    // invalid pointer. Therefore, dereference it.
    const code_expression2t &expr = to_code_expression2t(code2);
    expr2tc operand = expr.operand;
    dereference(operand, dereferencet::READ);
  }
  else if(is_code_cpp_del_array2t(code2) || is_code_cpp_delete2t(code2))
  {
    expr2tc deref_code(code2);

    replace_dynamic_allocation(deref_code);
    replace_nondet(deref_code);
    dereference(deref_code, dereferencet::READ);

    symex_cpp_delete(deref_code);
  }
  else if(is_code_free2t(code2))
  {
    symex_free(code2);
  }
  else if(is_code_printf2t(code2))
  {
    replace_dynamic_allocation(code2);
    replace_nondet(code2);
    dereference(code2, dereferencet::READ);
    symex_printf(expr2tc(), code2);
  }
  else if(is_code_decl2t(code2))
  {
    replace_dynamic_allocation(code2);
    replace_nondet(code2);
    dereference(code2, dereferencet::READ);

    const code_decl2t &decl_code = to_code_decl2t(code2);

    // just do the L2 renaming to preseve locality
    const irep_idt &identifier = decl_code.value;

    // Generate dummy symbol as a vehicle for renaming.
    symbol2tc l1_sym(get_empty_type(), identifier);

    cur_state->top().level1.get_ident_name(l1_sym);
    symbol2t &l1_symbol = to_symbol2t(l1_sym);

    // increase the frame if we have seen this declaration before
    while(cur_state->top().declaration_history.find(
            renaming::level2t::name_record(l1_symbol)) !=
          cur_state->top().declaration_history.end())
    {
      unsigned &index = cur_state->variable_instance_nums[identifier];
      cur_state->top().level1.rename(l1_sym, ++index);
      l1_symbol.level1_num = index;
    }

    renaming::level2t::name_record tmp_name(l1_symbol);
    cur_state->top().declaration_history.insert(tmp_name);
    cur_state->top().local_variables.insert(tmp_name);

    // seen it before?
    // it should get a fresh value
    if(cur_state->level2.current_number(l1_sym) != 0)
    {
      // Dummy assignment - blank constant value isn't considered for const
      // propagation, variable number will be bumped to result in a new free
      // variable. Invalidates l1_symbol reference?
      cur_state->level2.make_assignment(l1_sym, expr2tc(), expr2tc());
    }
  }
  else if(is_code_asm2t(code2))
  {
    // Assembly statement -> do nothing.
    return;
  }
  else
    throw "goto_symext: unexpected statement: " + get_expr_id(code2);
}
コード例 #20
0
ファイル: hw_dump.c プロジェクト: priyancka/caps
main()
{
  FILE *td;
  short j    = 0,
        hwix = 0;
  char kernel_check[12],
       command[80],
       h_type[4],
       tmpname[16];

  memset(kernel_check, 0x0, 12);
  memset(command, 0x0, 80);
  memset(tmpname, 0x0, 16);

  putenv("_=hw_dump");                  /* name to environ   */
  chdir(getenv("HOME"));                /* to home directory  */

  tmp_name(tmpname);
  sprintf(command, "%s > %s",
          "ps -ef|grep -v grep|grep ' bin/kernel'|cut -c54-63",
          tmpname);
  system(command);

  td = fopen(tmpname, "r");
  if (td == 0)
     {
       exit(-1);
     }

  fgets(kernel_check, 11, td);

  if (td)
     {
       fclose(td);
       unlink(tmpname);
     }

  if (strcmp(kernel_check, KERNELNAME) != 0)
     {
       printf("System not started.\n");
       exit(4);
     }

  ss_open();
  co_open();

  if (sp->sp_config_status != 'y')
     {
       printf("System is running.\n");
       close_all();
       exit(2);
     }

  hwf = fopen(DUMPFILE, "w");

  if (hwf == 0)
     {
       printf("Cannot open sql/hw_dump.dat for writing.\n");
       close_all();
       exit(3);
     }

  for (j = 0; j < coh->co_light_cnt; j++)
      {
         memset(h_type, 0x0, 4);

         switch (hw[j].hw_type)
                {
                   case BL:   strcpy(h_type, "BL");
                              break;

                   case ZC:   strcpy(h_type, "ZC");
                              break;

                   case PM:   strcpy(h_type, "PM");
                              break;

                   case PI:   strcpy(h_type, "PI");
                              break;

                   case ZC2:  strcpy(h_type, "ZC2");
                              break;

                   case PM2:  strcpy(h_type, "PM2");
                              break;

                   case PM4:  strcpy(h_type, "PM4");
                              break;

                   case PM6:  strcpy(h_type, "PM6");
                              break;

                   case BF:   strcpy(h_type, "BF");
                              break;

                   case IO:   strcpy(h_type, "IO");
                              break;

                   default:   break;
                }  /* end of switch statement for hardware type */

         hwix = j + 1;

         fprintf(hwf, "%d|%d|%d|%d|%d|%d|%s|\n",
                 j,
                 hwix,
                 hw[j].hw_mod,
                 hw[j].hw_mod_address,
                 hw[j].hw_bay,
                 hw[j].hw_controller,
                 h_type);
         fflush(hwf);

      }  /* end of for loop to read hw table */

  fclose(hwf);

  memset(command, 0x0, 80);

  sprintf(command, "%s%s",
          "/u/mfc/script/ld_hw_dump_file ",
          "1>/u/mfc/dat/log/ld_hdf.log 2>&1");

  system(command);

  sleep(5);

  unlink(DUMPFILE);

  close_all();

  exit(0);
} /* end of main() */
コード例 #21
0
ファイル: SubjectNameFlat.cpp プロジェクト: neilgroves/MlbDev
// ////////////////////////////////////////////////////////////////////////////
void SubjectNameFlat::CheckReplySubjectName(const char *subject_name)
{
	SubjectNameFlat tmp_name(subject_name);

	tmp_name.CheckReplyName();
}
コード例 #22
0
ファイル: printer_control.c プロジェクト: sqqqrly/caps
main()
{
  short rm;
  short ret;
  unsigned char t;
  char buf[NUM_PROMPTS][BUF_SIZE];        /* array of buffers                */

  short i;
  short n;

  putenv("_=printer_control");
  chdir(getenv("HOME"));

  open_all();

  while(1)                                /* begin massive loop              */
  {
    fix(berkeley_control);
    sd_screen_off();
    sd_clear_screen();                    /* clear screen                    */
    sd_text(berkeley_control);
    sd_screen_on();

                /* clear input buffers */

    for(i = 0; i < NUM_PROMPTS; i++)
    for(n = 0; n < BUF_SIZE; n++)
    buf[i][n] = 0;


                /* main loop to get code */

    while(1)
    {
      t = sd_input(&fld[0],sd_prompt(&fld[0],0),&rm,buf[0],0);

      if (t == EXIT) leave();
      if (t == UP_CURSOR) continue;

      *buf[0] = tolower(*buf[0]);      
      
      if (*buf[0] == 'a' || *buf[0] == 'c' || 
          *buf[0] == 'k' || *buf[0] == 's' || 
          *buf[0] == 'r' || *buf[0] == 'd')  break;
      
      eh_post(ERR_CODE, buf[0]);
    }
    if (*buf[0] == 'c')
    {
      t = sd_input(&fld1, sd_prompt(&fld1, 0), 0, op_printer, 0);
      if (t == EXIT) leave();
      if (t == UP_CURSOR) continue;
      
      message_put(sd_server, ChangePrinterEvent, op_printer, 
        strlen(op_printer));

      sprintf(printer, "PRINTER=%s", op_printer);
      putenv(printer);
      continue;
    }
                /* code entered. display second prompt */

    if(buf[0][0] != 'd')                  /* not display                     */
    {
      while (*buf[0] == 'k')
      {
        sd_prompt(&fld[1],0);
        t = sd_input(&fld[1],0,&rm,buf[1],0);
        if(t == EXIT) leave();
        else if(t == RETURN) break;
      }
      switch(buf[0][0])    
      {
        case 'a':                         /* abort current print job         */
        
          sd_wait();
          sd_cursor(0, 18, 27);
          sd_text(".");
          sprintf(command, "cancel %s", op_printer);
          system(command);
          sleep(2);
          break;

        case 'k':                         /* kill print file                 */
          
          sd_wait();
          sd_cursor(0, 18, 27);
          sd_text(".");
          sprintf(command, "cancel %s-%s", op_printer, buf[1]);
          system(command);
          sleep(2);
          break;
          
        case 's':                         /* stop print file                 */
          
          sd_wait();
          sd_cursor(0, 18, 27);
          sd_text(".");
          sprintf(command, "disable %s", op_printer);
          system(command);
          sleep(2);
          break;
          
        case 'r':                         /* restart printing                */
          
          sd_wait();
          sd_cursor(0, 18, 27);
          sd_text(".");
          sprintf(command, "enable %s", op_printer);
          system(command);
          sleep(2);
          break;
      }
      continue;
    }
    else                                  /* display request                 */
    {
      sd_cursor(0,16,2);
      sd_text("Job ID                  Operator          Size   Date");
    }
/*
 *  Get Printer Queue Data
 */
    tmp_name(tname);                      /* get temp name                   */
    sprintf(command, "lpstat -o %s >%s", op_printer, tname);
    system(command);

    t_fd = fopen(tname, "r");
    if (t_fd == 0) continue;              /* open failed                     */
    
    memset(x, 0, sizeof(x));
    
    for (max = 0; max < 25; max++)
    {
      if (!fgets(x[max], 80, t_fd)) break;
      n = strlen(x[max]) - 1;
      x[max][n] = 0;
    }
    n = 0;

    fclose(t_fd);
    unlink(tname);

    while(1)
    {
      sd_cursor(0, 17, 1);
      sd_clear_rest();

      for (i = 0; i < 5 && n + i < max; i++)
      {
        sd_cursor(0, 17 + i, 2);
        sd_text(x[i + n]);
      }
      sd_cursor(0,23,23);
      sd_text("(Exit, Forward, or Backward)");
      sd_prompt(&fld[2],0);

      t = sd_input(&fld[2],0,&rm,buf[2],0);

      ret = sd_more(t, code_to_caps(buf[2][0]));  /* F041897 */
                        
      if (ret == 0) leave();               /* exit                           */
      
      else if (ret == 1)                  /* forward                         */
      {
        if (n + 5 < max) n += 5;
      }
      else if (ret == 2)                  /* backward                        */
      {
        if (n > 0) n -= 5;
      }
      else if (ret == 3) break;           /* quit display                    */
    }
  }                                       /* end massive while(1)loop        */

}
コード例 #23
0
ファイル: search.cpp プロジェクト: Beastion01/ACE3
        bool search::generate_pbo_list() {
            NTSTATUS status;
            PSYSTEM_HANDLE_INFORMATION handleInfo;
            ULONG handleInfoSize = 0x10000;
            ULONG pid;
            HANDLE processHandle;
            ULONG i;

            _NtQuerySystemInformation NtQuerySystemInformation =
                (_NtQuerySystemInformation)GetLibraryProcAddress("ntdll.dll", "NtQuerySystemInformation");
            _NtDuplicateObject NtDuplicateObject =
                (_NtDuplicateObject)GetLibraryProcAddress("ntdll.dll", "NtDuplicateObject");
            _NtQueryObject NtQueryObject =
                (_NtQueryObject)GetLibraryProcAddress("ntdll.dll", "NtQueryObject");

            if (!NtQuerySystemInformation || !NtDuplicateObject || !NtQueryObject)
                return false;

            pid = GetCurrentProcessId();
            processHandle = GetCurrentProcess();

            handleInfo = (PSYSTEM_HANDLE_INFORMATION)malloc(handleInfoSize);

            while ((status = NtQuerySystemInformation(
                SystemHandleInformation,
                handleInfo,
                handleInfoSize,
                NULL
                )) == STATUS_INFO_LENGTH_MISMATCH)
                handleInfo = (PSYSTEM_HANDLE_INFORMATION)realloc(handleInfo, handleInfoSize *= 2);

            /* NtQuerySystemInformation stopped giving us STATUS_INFO_LENGTH_MISMATCH. */
            if (!NT_SUCCESS(status))
            {
                LOG(ERROR) << "Error opening object for pbo search";
                free(handleInfo);
                return false;
            }

            for (i = 0; i < handleInfo->HandleCount; i++)
            {
                SYSTEM_HANDLE handle = handleInfo->Handles[i];
                HANDLE dupHandle = NULL;
                POBJECT_TYPE_INFORMATION objectTypeInfo;
                PVOID objectNameInfo;
                UNICODE_STRING objectName;
                ULONG returnLength;

                /* Check if this handle belongs to the PID the user specified. */
                if (handle.ProcessId != pid)
                    continue;

                /* Duplicate the handle so we can query it. */
                if (!NT_SUCCESS(NtDuplicateObject(
                    processHandle,
                    (HANDLE)handle.Handle,
                    GetCurrentProcess(),
                    &dupHandle,
                    0,
                    0,
                    0
                    )))
                {
                    continue;
                }

                /* Query the object type. */
                objectTypeInfo = (POBJECT_TYPE_INFORMATION)malloc(0x1000);
                if (!NT_SUCCESS(NtQueryObject(
                    dupHandle,
                    ObjectTypeInformation,
                    objectTypeInfo,
                    0x1000,
                    NULL
                    )))
                {
                    CloseHandle(dupHandle);
                    continue;
                }

                /* Query the object name (unless it has an access of
                0x0012019f, on which NtQueryObject could hang. */
                if (handle.GrantedAccess == 0x0012019f)
                {

                    free(objectTypeInfo);
                    CloseHandle(dupHandle);
                    continue;
                }

                objectNameInfo = malloc(0x1000);
                if (!NT_SUCCESS(NtQueryObject(
                    dupHandle,
                    ObjectNameInformation,
                    objectNameInfo,
                    0x1000,
                    &returnLength
                    )))
                {
                    /* Reallocate the buffer and try again. */
                    objectNameInfo = realloc(objectNameInfo, returnLength);
                    if (!NT_SUCCESS(NtQueryObject(
                        dupHandle,
                        ObjectNameInformation,
                        objectNameInfo,
                        returnLength,
                        NULL
                        )))
                    {
                        free(objectTypeInfo);
                        free(objectNameInfo);
                        CloseHandle(dupHandle);
                        continue;
                    }
                }

                /* Cast our buffer into an UNICODE_STRING. */
                objectName = *(PUNICODE_STRING)objectNameInfo;
               
                

                /* Print the information! */
                if (objectName.Length)
                {
                    std::wstring tmp_type(objectTypeInfo->Name.Buffer);
                    std::wstring tmp_name(objectName.Buffer);
                    
                    std::string object_type(tmp_type.begin(), tmp_type.end());
                    std::string object_name(tmp_name.begin(), tmp_name.end());
                    if (object_type == "File" && object_name.find(".pbo") != object_name.npos) {
                        char buffer[MAX_PATH];
                        GetFinalPathNameByHandle(dupHandle, buffer, sizeof(buffer), VOLUME_NAME_DOS);

                        LOG(DEBUG) << "Pbo: " << buffer;
                        _active_pbo_list.push_back(std::string(buffer));
                    }
                }              

                free(objectTypeInfo);
                free(objectNameInfo);
                CloseHandle(dupHandle);
            }

            free(handleInfo);

            return true;
        }
コード例 #24
0
ファイル: check_caps.c プロジェクト: priyancka/caps
main()
{
    FILE *td;
    char kernel_check[12],
         command[80],
         tmpname[16];

    memset(kernel_check, 0x0, 12);
    memset(command, 0x0, 80);
    memset(tmpname, 0x0, 16);

    putenv("_=check_caps");                  /* name to environ   */
    chdir(getenv("HOME"));                  /* to home directory  */

    tmp_name(tmpname);
    sprintf(command, "%s > %s",
            "ps -ef|grep -v grep|grep ' bin/kernel'|cut -c54-63",
            tmpname);
    system(command);

    td = fopen(tmpname, "r");
    if (td == 0)
    {
        exit(-1);
    }

    fgets(kernel_check, 11, td);

    if (td)
    {
        fclose(td);
        unlink(tmpname);
    }

    if (strcmp(kernel_check, KERNELNAME) != 0)
    {
        printf("System not started\n");
        exit(4);
    }

    ss_open();

    if (sp->sp_running_status == 'n')
    {
        printf("Markplace\n");
        close_all();
        exit(3);
    }
    else
    {
        if (sp->sp_in_process_status != 'x')
        {
            printf("System is Busy\n");
            close_all();
            exit(1);
        }
        else
        {
            if (sp->sp_config_status == 'y')
            {
                printf("System is running\n");
                close_all();
                exit(2);
            }
        }
    }

    close_all();

    exit(0);
} /* end of main() */
コード例 #25
0
bool MConfig::readFile( const WFileName& filename, bool reqd )
{
    WTokenFile fil;
    WFileName tmp_name( filename );

    _ok = false;
    if( tmp_name.addPath( _include_path ) ) {
        _ok = fil.open( tmp_name, OStyleRead );
    }
    if( !_ok ) {
        _ok = fil.open( filename, "PATH" );
    }
    if( !_ok ) {
        _ok = !reqd;
        if( !_ok ) {
            _errMsg.printf( "Unable to open '%s'", (const char*)filename );
        }
    } else {
        _filename = fil.filename();
        WString tok;
        fil.token( tok );
        for(; !fil.eof(); ) {
            if( tok == "Tool" ) {
                _tools.add( new MTool( fil, tok ) );
            } else if( tok == "Rule" ) {
                _rules.add( new MRule( fil, tok ) );
            } else if( tok == "Project" ) {
                configProject( fil, tok );
            } else if( tok == "MsgLog" ) {
                configMsgLog( fil, tok );
            } else if( tok == "IncludeFile" ) {
                WFileName fn;
                fil.token( fn );
                if( !readFile( fn, false ) ) break;
                fil.token( tok );
            } else if( tok == "HostMask" ) {
                fil.token( _hostMask );
                fil.token( tok );
            } else if( tok == "Version" ) {
                _version = (int)fil.token( tok );
                if( _version > CUR_CFG_VERSION ) {
                    _ok = false;
                    _errMsg.printf( "Configuration file '%s' format is too new.  "
                                    "you must use a newer version of the IDE.",
                                    (const char*)filename );
                    break;
                }
                fil.token( tok );
            } else if( tok == "rem" ) {
                fil.flushLine( tok );
                fil.token( tok );
            } else if( _version < 5 && tok == "Compat" ) {
                WString good;
                WString bad;
                fil.token( good );
                fil.token( bad );
                AddTypo( good, bad );
                fil.token( tok );
            } else {
                _ok = false;
                _errMsg.printf( "Error in '%s', line %d, at '%s'", (const char*)filename, fil.lineCount(), (const char*)tok );
                break;
            }
        }
        fil.close();
    }
    buildTargetOSList();
    return( _ok );
}