Esempio n. 1
0
void creature_t::shout(const char* what)
{
  if (strlen(what) == 0)
  {
    if (player.sees(this))
    {
      append_msg_log("%s shouts!", capitalize(get_full_name()).c_str());
    }
    else
    {
      append_msg_log("You hear a shout.");
    }
  }
  else
  {
    if (player.sees(this))
    {
      append_msg_log("%s shouts: \"%s\".", capitalize(get_full_name()).c_str(), what);
    }
    else
    {
      append_msg_log("You hear someone shout: \"%s\".", what);
    }
  }

  create_noise(pos.x, pos.y, SHOUT_RADIUS);
}
void
GIFFChunk::save(IFFByteStream & istr, bool use_trick)
{
  DEBUG_MSG("GIFFChunk::save(): saving chunk '" << get_full_name() << "'\n");
  DEBUG_MAKE_INDENT(3);

  if (is_container())
  {
    istr.put_chunk(get_full_name(), use_trick);
    if (chunks.size())
    {
      GPosition pos;
      for(pos=chunks;pos;++pos)
        if (chunks[pos]->get_type()=="PROP")
          chunks[pos]->save(istr);
      for(pos=chunks;pos;++pos)
        if (chunks[pos]->get_type()!="PROP")
          chunks[pos]->save(istr);
    } else
    {
      DEBUG_MSG("but it's empty => saving empty container.\n");
    }
    istr.close_chunk();
  } else
  {
    istr.put_chunk(get_name(), use_trick);
    istr.get_bytestream()->writall((const char *) data, data.size());
    istr.close_chunk();
  }
}
Esempio n. 3
0
int Student::compare_to(const Student& other)
{
    if(get_full_name() == other.get_full_name())
    {
        return ID - other.ID;
    }
    
    return get_full_name().compare(other.get_full_name());
}
Esempio n. 4
0
void creature_t::blink()
{
  std::vector<coord_t> valid_coords;

  for (int y = pos.y - FOV_RADIUS; y <= pos.y + FOV_RADIUS; y++)
  {
    for (int x = pos.x - FOV_RADIUS; x <= pos.x + FOV_RADIUS; x++)
    {
      if (sees(x, y) && place_free(current_dungeon, x, y, this))
      {
        valid_coords.push_back(coord_t {x, y});
      }
    }
  }

  if (valid_coords.size())
  {
    std::random_shuffle(valid_coords.begin(), valid_coords.end());

    if (identity == IDENT_PLAYER)
    {
      append_msg_log("You feel a wrenching sensation!");
    }

    cloud_create_translocation_effect(pos.x, pos.y);

    coord_t target = valid_coords.front();
    pos = target;

    if (identity != IDENT_PLAYER)
    {
      if (player.sees(this))
      {
        append_msg_log("%s blinks!", capitalize(get_full_name()).c_str());
      }
      else
      {
        append_msg_log("%s suddenly disappears!", capitalize(get_full_name()).c_str());
      }
    }
  }
  else
  {
    if (identity == IDENT_PLAYER)
    {
      append_msg_log("You shudder for a moment.");
    }
    else if (player.sees(this))
    {
      append_msg_log("%s shudders for a moment.", capitalize(get_full_name()).c_str());
    }
  }
}
Esempio n. 5
0
void add_to_list(GtkWidget *list, gchar *str)
{
	double file_size;
	char* fullname;
	GtkTreeIter iter;
	store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
	
	if(!g_file_test(str, G_FILE_TEST_IS_SYMLINK) && !g_file_test(str, G_FILE_TEST_IS_DIR) && g_file_test(str, G_FILE_TEST_IS_REGULAR))
	{
		fullname = get_full_name(str);
		file_size = get_file_size(str);
		
		printf("%s - %f - %s - %s\n", fullname, file_size, "Waiting...", str);
		
		gtk_list_store_append(GTK_LIST_STORE(store), &iter);
		gtk_list_store_set(GTK_LIST_STORE(store), &iter,
			COLUMN_NAME, fullname,
			COLUMN_SIZE, file_size,
			COLUMN_STATUS, "Waiting",
			COLUMN_PATH, str,
			-1);
		
		free(fullname);
	}
}
Esempio n. 6
0
HRESULT __cdecl SchRpcDelete(const WCHAR *path, DWORD flags)
{
    WCHAR *full_name;
    HRESULT hr = S_OK;

    TRACE("%s,%#x\n", debugstr_w(path), flags);

    if (flags) return E_INVALIDARG;

    while (*path == '\\' || *path == '/') path++;
    if (!*path) return E_ACCESSDENIED;

    full_name = get_full_name(path, NULL);
    if (!full_name) return E_OUTOFMEMORY;

    if (!RemoveDirectoryW(full_name))
    {
        hr = HRESULT_FROM_WIN32(GetLastError());
        if (hr == HRESULT_FROM_WIN32(ERROR_DIRECTORY))
            hr = DeleteFileW(full_name) ? S_OK : HRESULT_FROM_WIN32(GetLastError());
    }

    heap_free(full_name);
    return hr;
}
Esempio n. 7
0
HRESULT __cdecl SchRpcRegisterTask(const WCHAR *path, const WCHAR *xml, DWORD flags, const WCHAR *sddl,
                                   DWORD task_logon_type, DWORD n_creds, const TASK_USER_CRED *creds,
                                   WCHAR **actual_path, TASK_XML_ERROR_INFO **xml_error_info)
{
    WCHAR *full_name, *relative_path;
    DWORD disposition;
    HRESULT hr;

    WINE_TRACE("%s,%s,%#x,%s,%u,%u,%p,%p,%p\n", wine_dbgstr_w(path), wine_dbgstr_w(xml), flags,
            wine_dbgstr_w(sddl), task_logon_type, n_creds, creds, actual_path, xml_error_info);

    *actual_path = NULL;
    *xml_error_info = NULL;

    /* FIXME: assume that validation is performed on the client side */
    if (flags & TASK_VALIDATE_ONLY) return S_OK;

    full_name = get_full_name(path, &relative_path);
    if (!full_name) return E_OUTOFMEMORY;

    if (strchrW(path, '\\') || strchrW(path, '/'))
    {
        WCHAR *p = strrchrW(full_name, '/');
        if (!p) p = strrchrW(full_name, '\\');
        *p = 0;
        hr = create_directory(full_name);
        *p = '\\';
    }

    switch (flags & (TASK_CREATE | TASK_UPDATE))
    {
    default:
    case TASK_CREATE:
        disposition = CREATE_NEW;
        break;

    case TASK_UPDATE:
        disposition = OPEN_EXISTING;
        break;

    case (TASK_CREATE | TASK_UPDATE):
        disposition = OPEN_ALWAYS;
        break;
    }

    hr = write_xml_utf8(full_name, disposition, xml);
    if (hr == S_OK)
    {
        *actual_path = heap_strdupW(relative_path);
        schedsvc_auto_start();
    }

    heap_free(full_name);
    return hr;
}
Esempio n. 8
0
void creature_t::split_creature()
{
  std::vector<coord_t> valid_coords;

  for (int y = pos.y - 1; y <= pos.y + 1; y++)
  {
    for (int x = pos.x - 1; x <= pos.x + 1; x++)
    {
      if (place_free(current_dungeon, x, y, this))
      {
        valid_coords.push_back(coord_t { x, y });
      }
    }
  }

  if (valid_coords.size())
  {
    std::random_shuffle(valid_coords.begin(), valid_coords.end());
    coord_t pos = valid_coords.front();

    if (player.sees(this))
    {
      append_msg_log("%s multiplies!", capitalize(get_full_name()).c_str());
    }

    creature_t* new_creature = create_creature_by_name(name);
    new_creature->hp = hp;
    new_creature->challenge_rating = 0; // Award no exp for multiplied creature.
    add_creature_to_dungeon(current_dungeon, new_creature, pos.x, pos.y);
  }
  else
  {
    if (player.sees(this))
    {
      append_msg_log("%s jiggles.", capitalize(get_full_name()).c_str());
    }
  }
}
Esempio n. 9
0
 std::string get_display_name() const
 {
   std::string display_name;
   bool hasAlias = !(first_name.empty() && last_name.empty());
   if (hasAlias)
   {
     display_name = get_full_name();
     display_name += " <";
   }
   display_name += dac_id_string;
   if (hasAlias)
     display_name += '>';
   return display_name;
 }
int EditBoxCollection::opened(char *fname)
{
    char* _cname = get_full_name(fname);

    for(int i = 0; i < Count(); i++)
    {
        if(!__cstrcmp(GetBox(i)->get_name(), _cname))
        {
            delete _cname;
            return i;
        }
    }
    delete _cname;
    return -1;
}
Esempio n. 11
0
HRESULT __cdecl SchRpcRetrieveTask(const WCHAR *path, const WCHAR *languages, ULONG *n_languages, WCHAR **xml)
{
    WCHAR *full_name;
    HRESULT hr;

    TRACE("%s,%s,%p,%p\n", debugstr_w(path), debugstr_w(languages), n_languages, xml);

    full_name = get_full_name(path, NULL);
    if (!full_name) return E_OUTOFMEMORY;

    hr = read_xml(full_name, xml);
    if (hr != S_OK) *xml = NULL;

    heap_free(full_name);
    return hr;
}
Esempio n. 12
0
HRESULT __cdecl SchRpcCreateFolder(const WCHAR *path, const WCHAR *sddl, DWORD flags)
{
    WCHAR *full_name;
    HRESULT hr;

    TRACE("%s,%s,%#x\n", debugstr_w(path), debugstr_w(sddl), flags);

    if (flags) return E_INVALIDARG;

    full_name = get_full_name(path, NULL);
    if (!full_name) return E_OUTOFMEMORY;

    hr = create_directory(full_name);

    heap_free(full_name);
    return hr;
}
Esempio n. 13
0
HRESULT __cdecl SchRpcGetTaskInfo(const WCHAR *path, DWORD flags, DWORD *enabled, DWORD *task_state)
{
    WCHAR *full_name, *xml;
    HRESULT hr;

    FIXME("%s,%#x,%p,%p: stub\n", debugstr_w(path), flags, enabled, task_state);

    full_name = get_full_name(path, NULL);
    if (!full_name) return E_OUTOFMEMORY;

    hr = read_xml(full_name, &xml);
    heap_free(full_name);
    if (hr != S_OK) return hr;
    heap_free(xml);

    *enabled = 0;
    *task_state = (flags & SCH_FLAG_STATE) ? TASK_STATE_DISABLED : TASK_STATE_UNKNOWN;
    return S_OK;
}
Esempio n. 14
0
int roadmap_sound_list_add ( RoadMapSoundList list, const char *name )
{
  const char* full_name;
  if ( list->count == MAX_SOUND_LIST ) return SND_LIST_ERR_LIST_FULL;

  full_name = get_full_name( name );

  if ( !roadmap_file_exists( full_name, NULL ) )
  {
     roadmap_log( ROADMAP_ERROR, "File %s doesn't exist! Cannot add to the list.", full_name );
     return SND_LIST_ERR_NO_FILE;
  }

  strncpy (list->list[list->count], name, sizeof(list->list[0]));
  list->list[list->count][sizeof(list->list[0])-1] = '\0';
  list->count++;

  return list->count - 1;
}
Esempio n. 15
0
char* get_lib_spec(int i) {
  char* name;
  /*return get_full_name(i,0);*/

  if (win32) {
    return get_full_name(i,0);
  } else {
    if (strncmp(files[i].name,"lib",3)) {
      fprintf(stderr,"error: library name must begin with 'lib' (%s)\n",files[i].name);
      exit(1);
    }
    name = (char*) malloc(256);
    sprintf(name, "-L$(%s) -l%s",
	    files[i].path,
	    files[i].name + 3);
  }

  return name;
}
Esempio n. 16
0
/*************************************************************************************************
 * roadmap_sound_play_list()
 * Playing the sound files in the list by calling the JNI layer
 * FreeMapNativeSoundManager_PlaySoundFile utility
 */
int roadmap_sound_play_list( const RoadMapSoundList list )
{
	if ( sgInitialized )
	{
		int listSize = roadmap_sound_list_count( list );
		const char *full_name;
		int i;

		for( i = 0; i < roadmap_sound_list_count(list); i++ )
		{
			const char *name = roadmap_sound_list_get ( list, i );
			// !!!! Resources are not supported !!!!
			// RoadMapSound sound = (RoadMapSound) roadmap_res_get (RES_SOUND, RES_NOCREATE, name);

			// AGA NOTE :: TODO :: Temporary solution. All the resources are extracted now.
			// The unnecessary sounds should be cleared/not extracted (?)
             if ( (list->flags & SOUND_LIST_BUFFERS) == 0 )
             {
                 full_name = get_full_name( name );
                 // Calling the JNI layer
                 FreeMapNativeSoundManager_PlayFile( full_name );
             }
             else
             {
                /*
                 * Temporary solution - write the buffer to the file for further playing
                 * AGA
                 */
    //            FreeMapNativeSoundManager_PlayFile( roadmap_sound_list_get ( list, i ) );
             //			   FreeMapNativeSoundManager_PlayBuffer( list->buf_list[i], list->buf_list_sizes[i] );
    //            free( list->buf_list[i] );
             }
	}
	}
	// Deallocation
	if ( (list->flags & SOUND_LIST_NO_FREE) == 0x0 )
	{
		free (list);
	}
	return 0;
}
Esempio n. 17
0
void creature_t::make_angry()
{
  append_msg_log_ex(color_red, "%s gets angry!", capitalize(get_full_name()).c_str());

  if (flag & CF_NEUTRAL)
  {
    flag &= ~(CF_NEUTRAL);
  }

  if (identity == IDENT_SHOPKEEPER)
  {
    identity = IDENT_GENERIC_CREATURE;

    shopkeeper_anger_response(this);
  }

  if (flag & CF_PLAYER_ALLY)
  {
    flag &= ~(CF_PLAYER_ALLY);
  }
}
static void* create_instance(ServiceFunc* serviceFunc) {
    (void)serviceFunc;

    PluginData* data = malloc(sizeof(PluginData));
    memset(data, 0, sizeof(PluginData));

    get_full_name((char*)&data->temp_file_full, "temp/vice_mem_dump");

    data->state = PDDebugState_NoTarget;

    load_config(data, "data/c64_vice.cfg");

    MESSAGE_FUNCS = serviceFunc(PDMESSAGEFUNCS_GLOBAL);

    //TODO: non fixed size?

    data->breakpoints.data = (Breakpoint**)malloc(sizeof(Breakpoint*) * MAX_BREAKPOINT_COUNT);
    data->breakpoints.count = 0;

    return data;
}
Esempio n. 19
0
void Card::print_card() const
{
    output << get_full_name();
    // output is defined in poker_defs.h
}
Esempio n. 20
0
String GDMonoClass::get_full_name() const {
	return get_full_name(mono_class);
}
Esempio n. 21
0
std::string Student::to_string()
{
    std::string f;
    sprintf(f, "Name: %-20sID: %06d, GPA: %04.2f", get_full_name(), ID, gpa);
    return f;
}
Esempio n. 22
0
void emit_makefile(char* configuration_name)
{
  int i,j,k;
  FILE* f;
  char* base;
  char  name[256];

  /* create the configuration directory */

  if (variant)
    sprintf(name,"%s%c%s%s",configdir,pathsep,ostype,variant);
  else
    sprintf(name,"%s%c%s",  configdir,pathsep,ostype);

  if (win32) {
    mkdir(configdir);
    mkdir(name);
  }
  else {
    mkdir(configdir,0777);
    mkdir(name,0777);
  }

  /* now create the makefile */

  if (variant)
    sprintf(name,"%s%c%s%s%c%s",configdir,pathsep,ostype,variant,pathsep,makefile);
  else
    sprintf(name,"%s%c%s%c%s",  configdir,pathsep,ostype,pathsep,makefile);

  /* create an "alias" */
  f = fopen("makefile","w");
  if (!f) {
    fprintf(stderr,"error: could not open makefile <%s>\n",makefile);
    exit(1);
  }
  fprintf(f,"include %s\n",name);
  fclose(f);

  /* now create the real makefile */
  f = fopen(name,"w");
  if (!f) {
    fprintf(stderr,"error: could not open makefile <%s>\n",name);
    exit(1);
  }

  fprintf(f, "OSTYPE = %s\n", ostype );  
  if (variant)
    fprintf(f, "OSTYPE_VARIANT = %s\n", variant );  

  fprintf(f, "CONFIGURATION = %s\n", configuration_name);

  /*
  fprintf(f, "\n");
  if (!strcmp(platform,"win32")) {
    fprintf(f, "EXEOUT=/Fe\n" );
    fprintf(f, "OBJOUT=/Fe\n" );
    fprintf(f, "DEFFLG=/D\n"  );
    fprintf(f, "EXEEXT=.exe\n"  );
  } else {
    fprintf(f, "EXEOUT=-o\n" );
    fprintf(f, "OBJOUT=-o\n" );
    fprintf(f, "DEFFLG=-D\n"  );
    fprintf(f, "EXEEXT=\n"  );
  }
  */

  /*
  fprintf(f, "\n");
  for (i=0; paths[i].name; i++) {
    fprintf(f,"%s=%s\n",paths[i].name,get_path(paths[i].name));
  }
  */

  fprintf(f, "INCS = ");
  /*fprintf(f, "\\\n  %s",configfile);*/
  fprintf(f, "\\\n  %s%c%s%s%c%s",
	  configdir,pathsep,ostype,
	  variant?variant:"",pathsep,configfile);
  fprintf(f, "\\\n  %s%c%s%s%c%s",
	  configdir,pathsep,ostype,
	  variant?variant:"",pathsep,testfile);
  for (i=0; files[i].name; i++) {
    base = files[i].name;
    if (files[i].flags & hsource)
      fprintf(f,"\\\n  %s",get_full_name(i,0));
  }
  fprintf(f, "\n");

  fprintf(f, "CILKC=$(CC)\n");
  fprintf(f, "CILKFLAGS=$(CFLAGS)\n");
  fprintf(f, "CILKOUTFLG=$(COUTFLG)\n");
  fprintf(f, "\n");

  fprintf(f, "\n");
  if (win32) {
    fprintf(f, "include config%cwin32.mk\n", pathsep);
    if (variant)
      fprintf(f, "include config%cwin32%s.mk\n", pathsep,variant);
  } else {
    fprintf(f, "include config%c$(OSTYPE).mk\n", pathsep);
    if (variant)
      fprintf(f, "include config%c$(OSTYPE)$(OSTYPE_VARIANT).mk\n", pathsep);
  }
  fprintf(f,"\n");

  fprintf(f, "LIBS =");
  for (i=0; modules[i].name; i++)
    if (modules[i].state) 
      for (k=0; modules[i].extralib[k]; k++)
	fprintf(f," $(%s)",modules[i].extralib[k]);
  fprintf(f," $(%s)",f77_lib);
  fprintf(f," $(%s)",c_lib);
  fprintf(f,"\n");

  fprintf(f, "default: all\n" );  
  fprintf(f, "\n");

  fprintf(f, "include config%cstd.mk\n", pathsep);
  fprintf(f, "\n");

  fprintf(f, "%s%c%s%s%c%s: $(DIROBJ)exists.log",
	  configdir,pathsep,ostype,
	  variant?variant:"",pathsep,testfile);
  for (i=0; files[i].name; i++) {
    if (files[i].flags & test)
      fprintf(f, " %s",get_full_name(i,0));
  }
  fprintf(f, "\n");

  for (i=0; files[i].name; i++) {
    if ( ! (files[i].flags & test) ) {
      continue;
    }
    
    if (files[i].flags & csource) {
      fprintf(f, "\t- $(CC) -c $(CFLAGS) $(STDDEFS) $(STDINCS) \\\n");
      fprintf(f, "\t  %s \\\n",get_full_name(i,0));
      fprintf(f, "\t  $(COUTFLG)%s\n", get_full_name(i,object));
    }

    if (files[i].flags & cilksource) {
      fprintf(f, "\t- $(CILKC) -c $(CILKFLAGS) $(STDDEFS) $(STDINCS) \\\n");
      fprintf(f, "\t  %s \\\n",get_full_name(i,0));
      fprintf(f, "\t  $(CILKOUTFLG)%s\n", get_full_name(i,object));
    }
	 
    fprintf(f,"\t- $(LD) $(LDFLAGS) \\\n");
    fprintf(f,"\t  $(LOUTFLG)%s \\\n",get_full_name(i,executable));
    fprintf(f,"\t  %s $(LIBS)\n",get_full_name(i,object));
    
    fprintf(f,"\t- %s",get_full_name(i,executable));
    fprintf(f, " %s%c%s%s%c%s\n",
	    configdir,pathsep,ostype,
	    variant?variant:"",pathsep,testfile);
  }

  for (i=0; files[i].name; i++) {
    base = files[i].name;

    if ( ! files[i].state ) {
      /*printf(">>> state=0 for %s\n",base);*/
      continue;
    }

    if ( (files[i].flags & csource) 
	 || (files[i].flags & cilksource) ) {
      int generated = 0;
      for (j=0; number_types[j].flag; j++) {
	if ( ! (number_types[j].flag & build_flags) ) continue;
	if (files[i].flags & number_types[j].flag) {
	  generated = 1;

	  /*if ((build_flags & cilksource) && (files[i].flags & cilksource)) {*/
	  if (files[i].flags & cilksource) {
	    fprintf(f, "%s: %s $(INCS) $(STDDEPS)\n",
		    get_full_name(i,object | number_types[j].flag),
		    get_full_name(i,0));
	    /*	    
	    fprintf(f, "\t/bin/cp %s %s\n",get_full_name(i,0),get_full_name(i,cilksource));
	    fprintf(f, "\t$(CC) -c $(CFLAGS) $(STDDEFS) $(STDINCS) \\\n");
	    fprintf(f, "\t-D%s \\\n",number_types[j].define);
	    fprintf(f, "\t-DTAUCS_CORE_CILK \\\n");
	    fprintf(f, "\t%s \\\n",get_full_name(i,cilksource));
	    fprintf(f, "\t$(COUTFLG)%s\n",get_full_name(i,object | number_types[j].flag));
	    fprintf(f, "\t/bin/rm %s\n",get_full_name(i,cilksource));
	    */
	    fprintf(f, "\t$(CILKC) -c $(CILKFLAGS) $(STDDEFS) $(STDINCS) \\\n");
	    fprintf(f, "\t-D%s \\\n",number_types[j].define);
	    fprintf(f, "\t%s \\\n",get_full_name(i,0));
	    fprintf(f, "\t$(CILKOUTFLG)%s\n",get_full_name(i,object | number_types[j].flag));
	  } else {
	    fprintf(f, "%s: %s $(INCS) $(STDDEPS)\n",
		    get_full_name(i,object | number_types[j].flag),
		    get_full_name(i,0));
	    fprintf(f, "\t$(CC) -c $(CFLAGS) $(STDDEFS) $(STDINCS) \\\n");
	    fprintf(f, "\t-D%s \\\n",number_types[j].define);
	    fprintf(f, "\t%s \\\n",get_full_name(i,0));
	    fprintf(f, "\t$(COUTFLG)%s\n",get_full_name(i,object | number_types[j].flag));
	  }

	}
      }
      if (!generated) {
	/*if ((build_flags & cilksource) && (files[i].flags & cilksource)) {*/
	if (files[i].flags & cilksource) {
	  fprintf(f, "%s: %s $(INCS) $(STDDEPS)\n",
		  get_full_name(i,object),
		  get_full_name(i,0));
	  /*
	  fprintf(f, "\t/bin/cp %s %s\n",get_full_name(i,0),get_full_name(i,cilksource));
	  fprintf(f, "\t$(CC) -c $(CFLAGS) $(STDDEFS) $(STDINCS) \\\n");
	  fprintf(f, "\t-DTAUCS_CORE_CILK \\\n");
	  fprintf(f, "\t%s \\\n",get_full_name(i,cilksource));
	  fprintf(f, "\t$(COUTFLG)%s\n",
		  get_full_name(i,object));
	  fprintf(f, "\t/bin/rm %s\n",get_full_name(i,cilksource));
	  */
	  fprintf(f, "\t$(CILKC) -c $(CILKFLAGS) $(STDDEFS) $(STDINCS) \\\n");
	  fprintf(f, "\t%s \\\n",get_full_name(i,0));
	  fprintf(f, "\t$(CILKOUTFLG)%s\n",
		  get_full_name(i,object));
	} else {
	  fprintf(f, "%s: %s $(INCS) $(STDDEPS)\n",
		  get_full_name(i,object),
		  get_full_name(i,0));
	  fprintf(f, "\t$(CC) -c $(CFLAGS) $(STDDEFS) $(STDINCS) \\\n");
	  fprintf(f, "\t %s \\\n",get_full_name(i,0));
	  fprintf(f, "\t$(COUTFLG)%s\n",
		  get_full_name(i,object));
	}

      }
    }

    if (files[i].flags & fcsource) {
      fprintf(f, "%s: %s $(STDDEPS)\n",
	      get_full_name(i,object),
	      get_full_name(i,0));
      fprintf(f, "\t$(FC) -c $(FFLAGS) \\\n");
      fprintf(f, "\t%s \\\n",get_full_name(i,0));
      fprintf(f, "\t$(FOUTFLG)%s\n",get_full_name(i,object));
    }
  }

  for (i=0; files[i].name; i++) {
    base = files[i].name;

    if ( ! files[i].state ) {
      /*printf(">>> state=0 for %s\n",base);*/
      continue;
    }

    if ( (files[i].flags & lib) ) {
      fprintf(f, "%s_content = ",base);
      for (k=0; files[k].name; k++) {
	int   generated = 0;
	if (files[k].state != i) continue; /* this source does not contribute to this lib */
	for (j=0; number_types[j].flag; j++) {
	  if ( ! (number_types[j].flag & build_flags) ) continue;
	  if (files[k].flags & number_types[j].flag) {
	    generated = 1;
	    fprintf(f, "\\\n  %s ",get_full_name(k,object | number_types[j].flag));
	  }
	}
	if (!generated) {
	  fprintf(f, "\\\n  %s ",get_full_name(k,object));
	}
      }
      fprintf(f,"\n");

      fprintf(f, "%s: $(%s_content) $(STDDEPS)\n",get_full_name(i,0),base);
      fprintf(f,"\t- $(RM) %s\n",get_full_name(i,0));
      fprintf(f,"\t$(AR) $(AOUTFLG)%s $(%s_content)\n",get_full_name(i,0),base);
      fprintf(f,"\t$(RANLIB) %s\n",get_full_name(i,0));
    }

    if ( (files[i].flags & executable) ) {
      /*
      fprintf(f, "%s_content = ",base);
      for (k=0; files[k].name; k++) {
	if (files[k].state != i) continue;
	fprintf(f, "\\\n  %s ",get_full_name(k,object));
      }
      fprintf(f,"\n");
      */

      /*fprintf(f, "%s: $(%s_deps) $(%s)\n",get_full_name(i,0),base,files[i].path);*/

      fprintf(f, "%s: $(STDDEPS)",get_full_name(i,0));

      for (k=0; files[k].name; k++) {
	if (files[k].state != i) continue;
	fprintf(f, " %s",get_full_name(k,object));
      }
      for (k=0; files[k].name; k++) {
	if ( ! (files[k].flags & lib) ) continue; /* we assume an exe depends on all libs  */
	if ( ! (files[k].state) )       continue; /* except if the lib is not built at all */
	fprintf(f, " %s",get_full_name(k,0));
      }
      fprintf(f,"\n");

      fprintf(f,"\t$(LD) $(LDFLAGS) \\\n");
      fprintf(f,"\t$(LOUTFLG)%s \\\n",get_full_name(i,0));
      for (k=0; files[k].name; k++) {
	if (files[k].state != i) continue;
	fprintf(f, "\t%s \\\n",get_full_name(k,object));
      }
      /*fprintf(f,"\t$(%s_content) \\\n",base);*/
      for (k=0; files[k].name; k++) {
	if ( ! (files[k].flags & lib) ) continue; /* we assume an exe depends on all libs  */
	if ( ! (files[k].state) )       continue; /* except if the lib is not built at all */
	fprintf(f, "\t%s \\\n",get_lib_spec(k));
      }
      fprintf(f,"\t$(LIBS)\n");
    }
  }

  /* now emit the list of targets */

  fprintf(f,"all:");
  fprintf(f," $(STD_PRE_TARGETS)");
  for (i=0; files[i].name; i++) {
    if ( ! files[i].state ) continue;
    if (files[i].flags & target_types) {
      fprintf(f," %s",get_full_name(i,0));
    }
  }
  fprintf(f,"\n");

  fclose(f);
}
Esempio n. 23
0
void write_test_theta_file()
{
  // first: merge processes to have the right input files
  //merge_processes();

  TFile* of = new TFile("thetainput.root", "RECREATE");

  TString dir = string(".");
  vector<TString> fnames = vector<TString>();
  get_filenames(fnames);

  for (unsigned int i = 0;i < fnames.size();i++) {
    cout << "opening file " << fnames[i] << endl;
    TFile* f = new TFile(fnames[i], "READ");



    
    /*
    TH1D* h = f->Get("Chi2_BTag/M_ttbar_rec");
    of->cd();
    TH1D* wh = (TH1D*) h->Clone();
    TString name = get_full_name(fnames[i], "mu_btag_mttbar");
    wh->SetName(name);

    
    TH1D* h2 = f->Get("Chi2_NoBTag/M_ttbar_rec");
    of->cd();
    TH1D* wh2 = (TH1D*) h2->Clone();
    TString name = get_full_name(fnames[i], "mu_nobtag_mttbar");
    wh2->SetName(name);
    */
       
    TH1D* h = f->Get("t1__hyp_chi2min/M_ttbar_rec");
    of->cd();
    TH1D* wh = (TH1D*) h->Clone();
    TString name = get_full_name(fnames[i], "mu_toptag_mttbar");
       wh->SetName(name);

    
    TH1D* h2 = f->Get("t0b1__hyp_chi2min/M_ttbar_rec");
    of->cd();
    TH1D* wh2 = (TH1D*) h2->Clone();
    TString name = get_full_name(fnames[i], "mu_notoptagbtag_mttbar");
    //  name.ReplaceAll("mu_toptagsumbtag1_mttbar", "mu_1top1btag_mttbar");
    wh2->SetName(name);
    
    TH1D* h3 = f->Get("t0b0__hyp_chi2min/M_ttbar_rec");
    of->cd();
    TH1D* wh3 = (TH1D*) h3->Clone();
    TString name = get_full_name(fnames[i], "mu_notoptagnobtag_mttbar");
    //  name.ReplaceAll("mu_toptagsumbtag2_mttbar", "mu_1top2btag_mttbar");
    wh3->SetName(name);

    
    
    f->Close();
    delete f;
  }

  cout << "\nwrote file " << of->GetName() << endl;

  of->Write();
  of->Close();
  delete of;
  

}
Esempio n. 24
0
static void 
export_node( mol_device_node_t *dn, FILE *file, int ind )
{
	p_property_t *pr;
	char **ns, buf[256];
	int i;

	if( !dn )
		return;

	/* drop uninteresting nodes */
	for( ns=&drop_nodes[0]; *ns; ns++ )
		if( !strcmp((char *) node_name(dn), *ns) ) {
			export_node( dn->sibling, file, ind );
			return;
		}
	
	indprint(file, ind, "#\n");
	indprint(file, ind, "# **************** NODE %s ***************\n", node_name(dn) );
	indprint(file, ind, "# %s\n", get_full_name(dn, buf, sizeof(buf)) );
	indprint(file, ind, "#\n");
	indprint(file, ind, "{\n");
	ind += INDENT_VALUE;

	if( dn->unit_string && strlen( dn->unit_string ) )
		indprint(file, ind, "(unit_string %s )\n", dn->unit_string );

	if( (ulong)dn->node > PHANDLE_BASE )
		indprint(file, ind, "(mol_phandle 0x%08x )\n",(ulong)dn->node );
	
	/* properties */
	for( pr=dn->properties; pr; pr=pr->next ) {
		char **dp;

		/* drop uninteresting properties */
		for( dp=&drop_properties[0]; *dp; dp++ )
			if( pr->name && !strcmp(pr->name, *dp) )
				break;
		if( *dp )
			continue;

		/* skip all AAPL properties - probably a side effect of BootX 
		 * (hrm... some AAPL-properties seems to be non-generated)
		 */
		//if( pr->name && !strncmp(pr->name, "AAPL", 4) )
		//	continue;

		indprint(file, ind, "(property %-18s ", pr->name );

		if( !pr->length ) {
			fprintf(file, ")\n");
			continue;
		}

		/* detect likely strings/string arrays */
		for( i=0; i<pr->length ; i++ ) {
			char ch = pr->value[i];
			if( !ch && i && !pr->value[i-1] && i!=pr->length-1 )
				break;
			if( ch && !isgraph(ch) && !isspace(ch) )
				break;
		}
		if( i==pr->length && !pr->value[i-1] ) {
			fprintf(file, "<str>  \t");
			ind += INDENT_VALUE;
			for( i=0; i<pr->length; i += strlen((char *) &pr->value[i]) + 1 ) {
				if( i )
					fprintf(file, ", ");
				if( pr->length > 50 ) {
					fprintf(file, "\n");
					indprint(file, ind, "" );
				}
				fprintf(file, "\"%s\"", &pr->value[i] );
			}
			fprintf(file, " )\n");
			ind -= INDENT_VALUE;
			continue;
		}

		/* print long words */
		if( !(pr->length % 4) ) {
			int nw = 4;
			if( !(pr->length % (4*5)) )
				nw=5;
			else if( !(pr->length % (4*6)) )
				nw = 6;
			else if( (pr->length % (4*4)) )
				nw=2;
			fprintf(file, "<word> \t" );
			ind += INDENT_VALUE;
			for( i=0; i<pr->length; i+=4 ) {
				if( pr->length > 8 && !((i/4)%nw) ) {
					fprintf(file, "\n");
					indprint(file, ind, "");
				}
				fprintf(file, "0x%08lx ",*(ulong*)&pr->value[i] );
			}
			fprintf(file, " )\n" );
			ind -= INDENT_VALUE;
			continue;
		}

		/* assume byte */
		fprintf(file, "<byte> \t" );
		ind += INDENT_VALUE;
		for( i=0; i<pr->length; i++ ) {
			if( !(i%12) && pr->length > 8 ) {
				fprintf(file, "\n");
				indprint(file, ind, "");
			}
			fprintf(file, "0x%02x ", pr->value[i]);
		}
		ind -= INDENT_VALUE;
		fprintf(file, " )\n" );
	}

	if( dn->child ) {
		indprint(file, ind, "\n");
		export_node( dn->child, file, ind );
	}
	ind -= INDENT_VALUE;
	indprint(file, ind, "}\n" );

	export_node( dn->sibling, file, ind );
}
Esempio n. 25
0
HRESULT __cdecl SchRpcRegisterTask(const WCHAR *path, const WCHAR *xml, DWORD flags, const WCHAR *sddl,
                                   DWORD task_logon_type, DWORD n_creds, const TASK_USER_CRED *creds,
                                   WCHAR **actual_path, TASK_XML_ERROR_INFO **xml_error_info)
{
    WCHAR *full_name, *relative_path;
    DWORD disposition;
    HRESULT hr;

    TRACE("%s,%s,%#x,%s,%u,%u,%p,%p,%p\n", debugstr_w(path), debugstr_w(xml), flags,
          debugstr_w(sddl), task_logon_type, n_creds, creds, actual_path, xml_error_info);

    *actual_path = NULL;
    *xml_error_info = NULL;

    /* FIXME: assume that validation is performed on the client side */
    if (flags & TASK_VALIDATE_ONLY) return S_OK;

    if (path)
    {
        full_name = get_full_name(path, &relative_path);
        if (!full_name) return E_OUTOFMEMORY;

        if (strchrW(path, '\\') || strchrW(path, '/'))
        {
            WCHAR *p = strrchrW(full_name, '/');
            if (!p) p = strrchrW(full_name, '\\');
            *p = 0;
            hr = create_directory(full_name);
            if (hr != S_OK && hr != HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS))
            {
                heap_free(full_name);
                return hr;
            }
            *p = '\\';
        }
    }
    else
    {
        IID iid;
        WCHAR uuid_str[39];

        UuidCreate(&iid);
        StringFromGUID2(&iid, uuid_str, 39);

        full_name = get_full_name(uuid_str, &relative_path);
        if (!full_name) return E_OUTOFMEMORY;
        /* skip leading '\' */
        relative_path++;
    }

    switch (flags & (TASK_CREATE | TASK_UPDATE))
    {
    default:
    case TASK_CREATE:
        disposition = CREATE_NEW;
        break;

    case TASK_UPDATE:
        disposition = OPEN_EXISTING;
        break;

    case (TASK_CREATE | TASK_UPDATE):
        disposition = OPEN_ALWAYS;
        break;
    }

    hr = write_xml_utf8(full_name, disposition, xml);
    if (hr == S_OK)
    {
        *actual_path = heap_strdupW(relative_path);
        schedsvc_auto_start();
    }

    heap_free(full_name);
    return hr;
}
Esempio n. 26
0
static int
osip_prom_iface( int sel, int *args )
{
	int len, ph = args[1];
	mol_device_node_t *dn;
	char *p, *buf;
	char tmpbuf[256];
	unsigned char *pdata;
	
	if( args[0] == kPromClose ) {
		if( !debugger_enabled() )
			promif_cleanup();
		return 0;
	}
	
	if( !(dn=to_dn(ph)) && (args[0] != kPromPeer || ph) )
		return -1;
	
	switch( args[0] ) {
	case kPromPeer:
		if( !ph )
			return to_ph( prom_get_root() );
		return dn ? to_ph( dn->sibling ) : -1;
	case kPromChild:
		return to_ph( dn->child );
	case kPromParent:
		return to_ph( dn->parent );

	case kPromPackageToPath: /* ph, buf, size */
		if( !(p=transl_mphys(args[2])) )
			return -1;
		strncpy( p, get_full_name(dn,tmpbuf,sizeof(tmpbuf)), args[3] );
		return strlen( tmpbuf );

	case kPromGetPropLen: /* ph, name */
		if( !(p=transl_mphys(args[2])) )
			return -1;
		return prom_get_property(dn, p, &len) ? len : -1;

	case kPromGetProp: /* ph, name, buf, size */
		p = transl_mphys( args[2] );
		buf = transl_mphys( args[3] );
		if( !p || !buf )
			return -1;
		if( !(pdata=prom_get_property(dn, p, &len)) || args[4] < 0 )
			return -1;
		memcpy( buf, pdata, MIN(len,args[4]) );
		return len;

	case kPromNextProp: /* ph, prev, buf */
		p = transl_mphys( args[2] );
		buf = transl_mphys( args[3] );
		if( !p || !buf )
			return -1;
		if( !(p=prom_next_property(dn, p)) )
			return 0;
		strcpy( buf, p );
		return 1;

	case kPromSetProp: /* ph, name, buf, len */
		p = transl_mphys( args[2] );
		buf = transl_mphys( args[3] );
		if( !p || !buf || args[4] < 0 )
			return -1;
		if( args[4] > 0x1000 ) {
			printm("kPromSetProp: limit exceeded\n");
			return -1;
		}
		prom_add_property( dn, p, buf, args[4] );
		return args[4];

	case kPromChangePHandle: /* old_ph, new_ph */
		if( !prom_phandle_to_dn(args[2]) )
			dn->node = (void*)args[2];
		else if( dn->node != (void*)args[2] ) {
			printm("duplicate phandle\n");
			return -1;
		}
		return 0;
	default:
		printm("bad selector\n");
		return -1;
	}
	return -1;
}
Esempio n. 27
0
refalrts::FnResult CoreP_MFileSystemP_GetFileAttributes(refalrts::Iter arg_begin, refalrts::Iter arg_end) {
  refalrts::Iter bb_0 = arg_begin;
  refalrts::Iter be_0 = arg_end;
  refalrts::move_left( bb_0, be_0 );
  refalrts::move_left( bb_0, be_0 );
  refalrts::move_right( bb_0, be_0 );
  refalrts::Iter eFileName_b_1;
  refalrts::Iter eFileName_e_1;
  // e.FileName
  eFileName_b_1 = bb_0;
  refalrts::use( eFileName_b_1 );
  eFileName_e_1 = be_0;
  refalrts::use( eFileName_e_1 );

  std::vector<char> filename;

  refalrts::FnResult res =
    string_from_seq(filename, eFileName_b_1, eFileName_e_1);

  if( res == refalrts::cRecognitionImpossible ) {
    return refalrts::cRecognitionImpossible;
  }

  WIN32_FIND_DATA find_file_data;

  HANDLE hFind = FindFirstFile( & filename[0], & find_file_data );

  if( hFind == INVALID_HANDLE_VALUE ) {
    refalrts::reset_allocator();
    refalrts::Iter res = arg_begin;

    refalrts::Iter nSF = 0;
    if( ! refalrts::alloc_ident( nSF, & FailsL_<int>::name ) )
      return refalrts::cNoMemory;

    res = refalrts::splice_elem( res, nSF );
    refalrts::use( res );
    refalrts::splice_to_freelist( arg_begin, arg_end );

    return refalrts::cSuccess;
  } else {
    std::string full_name( find_file_data.cFileName );

    if( ! get_full_name( full_name ) ) {
      refalrts::reset_allocator();
      refalrts::Iter res = arg_begin;
    
      refalrts::Iter nSF = 0;
      if( ! refalrts::alloc_ident( nSF, & FailsL_<int>::name ) )
        return refalrts::cNoMemory;
    
      res = refalrts::splice_elem( res, nSF );
      refalrts::use( res );
      refalrts::splice_to_freelist( arg_begin, arg_end );
    
      return refalrts::cSuccess;
    } else {
      bool is_directory =
        ((find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);

      SYSTEMTIME file_system_time = { 0 };

      FileTimeToSystemTime(
        & find_file_data.ftLastWriteTime, & file_system_time
      );

      refalrts::reset_allocator();
      refalrts::Iter res = arg_begin;
      refalrts::Iter nSF = 0;
      if( ! refalrts::alloc_ident( nSF, & SuccessL_<int>::name ) )
        return refalrts::cNoMemory;
      refalrts::Iter n0 = 0;
      if( ! refalrts::alloc_open_bracket( n0 ) )
        return refalrts::cNoMemory;
      refalrts::Iter n1 = 0;
      if( ! refalrts::alloc_ident( n1, & DateTimeL_<int>::name ) )
        return refalrts::cNoMemory;
      refalrts::Iter n2 = 0;
      if( ! refalrts::alloc_number( n2, file_system_time.wYear ) )
        return refalrts::cNoMemory;
      refalrts::Iter n3 = 0;
      if( ! refalrts::alloc_number( n3, file_system_time.wMonth ) )
        return refalrts::cNoMemory;
      refalrts::Iter n4 = 0;
      if( ! refalrts::alloc_number( n4, file_system_time.wDay ) )
        return refalrts::cNoMemory;
      refalrts::Iter n5 = 0;
      if( ! refalrts::alloc_number( n5, file_system_time.wHour ) )
        return refalrts::cNoMemory;
      refalrts::Iter n6 = 0;
      if( ! refalrts::alloc_number( n6, file_system_time.wMinute ) )
        return refalrts::cNoMemory;
      refalrts::Iter n7 = 0;
      if( ! refalrts::alloc_number( n7, file_system_time.wSecond ) )
        return refalrts::cNoMemory;
      refalrts::Iter n8 = 0;
      if( ! refalrts::alloc_number( n8, file_system_time.wMilliseconds ) )
        return refalrts::cNoMemory;
      refalrts::Iter n9 = 0;
      if( ! refalrts::alloc_close_bracket( n9 ) )
        return refalrts::cNoMemory;
      refalrts::Iter n10 = 0;
      if( ! refalrts::alloc_open_bracket( n10 ) )
        return refalrts::cNoMemory;
      refalrts::Iter n11 = 0;
      if( ! refalrts::alloc_ident( n11, & SizeL_<int>::name ) )
        return refalrts::cNoMemory;
      refalrts::Iter n12 = 0;

      if( is_directory ) {
        if( ! refalrts::alloc_ident( n12, & DirL_<int>::name ) )
          return refalrts::cNoMemory;
      } else {
        if( ! refalrts::alloc_number( n12, 1000UL ) )
          return refalrts::cNoMemory;
      }

      refalrts::Iter n14 = 0;
      if( ! refalrts::alloc_close_bracket( n14 ) )
        return refalrts::cNoMemory;
      refalrts::Iter n15 = 0;
      if( ! refalrts::alloc_open_bracket( n15 ) )
        return refalrts::cNoMemory;
      refalrts::Iter n16 = 0;
      if( ! refalrts::alloc_ident( n16, & LongNameL_<int>::name ) )
        return refalrts::cNoMemory;

      refalrts::Iter fullname_b = 0;
      refalrts::Iter fullname_e = 0;

      bool name_allocated =
        refalrts::alloc_string( fullname_b, fullname_e, full_name.c_str() );

      if( ! name_allocated )
        return refalrts::cNoMemory;

      refalrts::Iter n26 = 0;
      if( ! refalrts::alloc_close_bracket( n26 ) )
        return refalrts::cNoMemory;

      refalrts::link_brackets( n15, n26 );
      res = refalrts::splice_elem( res, n26 );
      res = refalrts::splice_evar( res, fullname_b, fullname_e );
      res = refalrts::splice_elem( res, n16 );
      res = refalrts::splice_elem( res, n15 );
      refalrts::link_brackets( n10, n14 );
      res = refalrts::splice_elem( res, n14 );
      res = refalrts::splice_elem( res, n12 );
      res = refalrts::splice_elem( res, n11 );
      res = refalrts::splice_elem( res, n10 );
      refalrts::link_brackets( n0, n9 );
      res = refalrts::splice_elem( res, n9 );
      res = refalrts::splice_elem( res, n8 );
      res = refalrts::splice_elem( res, n7 );
      res = refalrts::splice_elem( res, n6 );
      res = refalrts::splice_elem( res, n5 );
      res = refalrts::splice_elem( res, n4 );
      res = refalrts::splice_elem( res, n3 );
      res = refalrts::splice_elem( res, n2 );
      res = refalrts::splice_elem( res, n1 );
      res = refalrts::splice_elem( res, n0 );
      res = refalrts::splice_elem( res, nSF );
      refalrts::use( res );
      refalrts::splice_to_freelist( arg_begin, arg_end );
  
      return refalrts::cSuccess;
    }
  }
}
Esempio n. 28
0
HRESULT __cdecl SchRpcEnumTasks(const WCHAR *path, DWORD flags, DWORD *start_index, DWORD n_requested,
                                DWORD *n_names, TASK_NAMES *names)
{
    static const WCHAR allW[] = {'\\','*',0};
    HRESULT hr = S_OK;
    WCHAR *full_name;
    WCHAR pathW[MAX_PATH];
    WIN32_FIND_DATAW data;
    HANDLE handle;
    DWORD allocated, count, index;
    TASK_NAMES list;

    TRACE("%s,%#x,%u,%u,%p,%p\n", debugstr_w(path), flags, *start_index, n_requested, n_names, names);

    *n_names = 0;
    *names = NULL;

    if (flags & ~TASK_ENUM_HIDDEN) return E_INVALIDARG;

    if (!n_requested) n_requested = ~0u;

    full_name = get_full_name(path, NULL);
    if (!full_name) return E_OUTOFMEMORY;

    if (strlenW(full_name) + 2 > MAX_PATH)
    {
        heap_free(full_name);
        return HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE);
    }

    strcpyW(pathW, full_name);
    strcatW(pathW, allW);

    heap_free(full_name);

    allocated = 64;
    list = heap_alloc(allocated * sizeof(list[0]));
    if (!list) return E_OUTOFMEMORY;

    index = count = 0;

    handle = FindFirstFileW(pathW, &data);
    if (handle == INVALID_HANDLE_VALUE)
    {
        heap_free(list);
        if (GetLastError() == ERROR_PATH_NOT_FOUND)
            return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
        return HRESULT_FROM_WIN32(GetLastError());
    }

    do
    {
        if (is_file(&data) && index++ >= *start_index)
        {
            if (count >= allocated)
            {
                TASK_NAMES new_list;
                allocated *= 2;
                new_list = heap_realloc(list, allocated * sizeof(list[0]));
                if (!new_list)
                {
                    hr = E_OUTOFMEMORY;
                    break;
                }
                list = new_list;
            }

            TRACE("adding %s\n", debugstr_w(data.cFileName));

            list[count] = heap_strdupW(data.cFileName);
            if (!list[count])
            {
                hr = E_OUTOFMEMORY;
                break;
            }

            count++;

            if (count >= n_requested)
            {
                hr = S_FALSE;
                break;
            }
        }
    } while (FindNextFileW(handle, &data));

    FindClose(handle);

    if (FAILED(hr))
    {
        free_list(list, count);
        return hr;
    }

    *n_names = count;

    if (count)
    {
        *names = list;
        *start_index = index;
        return hr;
    }

    heap_free(list);
    *names = NULL;
    return *start_index ? S_FALSE : S_OK;
}
Esempio n. 29
0
void WinRenderFrontend::RenderOptions (POVMSObjectPtr msg, POVMSObjectPtr, int)
{
  int                   l ;
  char                  dir [_MAX_PATH] ;
  char                  str [_MAX_PATH] ;
  char                  path [_MAX_PATH] ;
  char                  file [_MAX_PATH] ;
  POVMSBool             b ;
  ProcessRenderOptions  options ;

  if (!running_demo && !demo_mode)
  {
    WritePrivateProfileString ("LastRender", "SceneFile", "", EngineIniFileName) ;
    WritePrivateProfileString ("LastRender", "OutputFile", "", EngineIniFileName) ;
    WritePrivateProfileString ("LastRender", "HistogramFile", "", EngineIniFileName) ;
    WritePrivateProfileString ("LastRender", "IniOutputFile", "", EngineIniFileName) ;
  }

  GetCurrentDirectory (sizeof (dir), dir) ;
  WritePrivateProfileString ("LastRender", "CurrentDirectory", dir, EngineIniFileName) ;
  str [0] = '\0' ;
  l = sizeof (str) ;
  if (POVMSUtil_GetString (msg, kPOVAttrib_InputFile, str, &l) == kNoErr)
  {
    splitpath (str, path, file) ;
    if (!running_demo && !demo_mode)
      WritePrivateProfileString ("LastRender", "SourceFile", get_full_name (file), EngineIniFileName) ;
    sprintf (dir, "POV-Ray - parsing '%s'", file) ;
    SetWindowText (main_window, dir) ;
    splitfn (str, NULL, file, NULL) ;
    if (!running_demo && !demo_mode)
      WritePrivateProfileString ("LastRender", "SceneFile", file, EngineIniFileName) ;
  }
  if (POVMSUtil_GetBool (msg, kPOVAttrib_OutputToFile, &b) == kNoErr && b == true)
  {
    str [0] = '\0' ;
    if (POVMSUtil_GetString (msg, kPOVAttrib_OutputFile, str, &l) == kNoErr)
    {
      splitpath (str, path, NULL) ;
      if (path [0] == '\0')
      {
        l = sizeof (path) ;
        if (POVMSUtil_GetString (msg, kPOVAttrib_OutputPath, path, &l) != kNoErr)
          path [0] = '\0' ;
        if (path [0] != '\0')
        {
          // path is expected to end with a '\'
          strcpy (output_file_name, path) ;
          strcat (output_file_name, str) ;
        }
        else
          strcpy (output_file_name, get_full_name (str)) ;
      }
      else
        strcpy (output_file_name, str) ;
      if (!running_demo && !demo_mode)
        WritePrivateProfileString ("LastRender", "OutputFile", output_file_name, EngineIniFileName) ;
      output_to_file = str [0] != '\0' ;
    }
  }
  else
    output_to_file = false ;

  if (!running_demo && !demo_mode)
  {
    if (POVMSUtil_GetBool (msg, kPOVAttrib_CreateHistogram, &b) == kNoErr && b == true)
    {
      str [0] = '\0' ;
      l = sizeof (str) ;
      if (POVMSUtil_GetString (msg, kPOVAttrib_CreateHistogram, str, &l) == kNoErr)
        WritePrivateProfileString ("LastRender", "HistogramFile", get_full_name (str), EngineIniFileName) ;
    }

    str [0] = '\0' ;
    l = sizeof (str) ;
    if (POVMSUtil_GetString (msg, kPOVAttrib_CreateIni, str, &l) == kNoErr && str [0] != '\0')
      WritePrivateProfileString ("LastRender", "IniOutputFile", get_full_name (str), EngineIniFileName) ;

    write_rerun_information (msg, &options) ;
    PutPrivateProfileInt ("Statistics", "StartRender", time (NULL), CurrentRerunFileName) ;

    str [0] = '\0' ;
    l = sizeof (str) ;
    if (POVMSUtil_GetString (msg, kPOVAttrib_CreateIni, str, &l) == kNoErr && str [0] != '\0')
      options.WriteFile (str, msg) ;
  }
}
Esempio n. 30
0
int build_address(char *to, char *full_to)
{
	/** loop on all words in 'to' line...append to full_to as
	    we go along, until done or length > len.  Modified to
	    know that stuff in parens are comments...Returns non-zero
	    if it changed the information as it copied it across...
	**/

	int	i, j, k, l,
			in_parens = 0, a_in_parens,
			expanded_information = 0,
			eliminated = 0;
	int too_long = FALSE;
	int to_len;
	char word[SLEN], next_word[SLEN], *ptr;
	char elim_list[SLEN], word_a[SLEN], next_word_a[SLEN];
	char *gecos;

	full_to[0] = '\0';
	to_len = 0;

	elim_list[0] = '\0';

	i = get_word(to, 0, word, sizeof(word));

	/** Look for addresses to be eliminated from aliases **/
	while (i > 0) {

	  j = get_word(to, i, next_word, sizeof(next_word));

	  if(word[0] == '(')
	    in_parens++;

	  if (in_parens) {
	    if(word[strlen(word)-1] == ')')
	      in_parens--;
	  }

	  else if (word[0] == '-') {
	    for (k = 0; word[k] != '\0'; word[k] = word[k+1], k++);
	    if (elim_list[0] != '\0')
	      strcat(elim_list, " ");
	    /*  expand alias and eliminate all members */
	    if ((ptr = get_alias_address(word, TRUE, &too_long)) != NULL) {
	      /*  ignores overflow, like every bloody other place in elm */
	      strcat(elim_list, ptr);
	      too_long = FALSE;
	    } else
	      strcat(elim_list, word);
	  }

	  if ((i = j) > 0)
	    strcpy(word, next_word);
	}

	if (elim_list[0] != '\0')
	  eliminated++;

	i = get_word(to, 0, word, sizeof(word));

	while (i > 0) {

	  j = get_word(to, i, next_word, sizeof(next_word));

	  if(word[0] == '(')
	    in_parens++;

	  if (in_parens) {
	    if(word[strlen(word)-1] == ')')
	      in_parens--;
	    strcpy(full_to+to_len, " ");
	    strcpy(full_to+to_len+1, word);
	    to_len += strlen(word)+1;
	  }

	  else if (word[0] == '-') {
		; /* huh??? I don't understand this  (*FOO*) */
	  }

	  else if (qstrpbrk(word,"!@:") != NULL) {
	    if (to_len > 0) {
		(void) strcpy(full_to+to_len, ", ");
		to_len += 2;
	    }
	    (void) strcpy(full_to+to_len, word);
	    to_len += strlen(word);
	  }
	  else if ((ptr = get_alias_address(word, TRUE, &too_long)) != NULL) {

	    /** check aliases for addresses to be eliminated **/
	    if (eliminated) {
	      k = get_word(strip_commas(ptr), 0, word_a, sizeof(word_a));

	      while (k > 0) {
		l = get_word(ptr, k, next_word_a, sizeof(next_word_a));
		if (in_list(elim_list, word_a) == 0) {

		if (to_len > 0) {
		    (void) strcpy(full_to+to_len, ", ");
		    to_len += 2;
		}
		(void) strcpy(full_to+to_len, word_a);
		to_len += strlen(word_a);

		  /** copy possible () comment **/
		  if (next_word_a[0] == '(') {
		    a_in_parens = 0;

		    while (l > 0) {
		      if (to_len > 0) {
			(void) strcpy(full_to+to_len, " ");
			++to_len;
		      }
		      (void) strcpy(full_to+to_len, next_word_a);
		      to_len += strlen(next_word_a);
		      if (next_word_a[0] == '(')
			++a_in_parens;
		      if (next_word_a[strlen(next_word_a)-1] == ')')
			--a_in_parens;
		      l = get_word(ptr, l, next_word_a, sizeof(next_word_a));
		      if (! a_in_parens)
			break;
		    }
		  }
		}
		else {
		  /** skip possible () comment **/
                  if (next_word_a[0] == '(') {
                    a_in_parens = 0;

                    while (l > 0) {
                      if (next_word_a[0] == '(')
                        ++a_in_parens;
                      if (next_word_a[strlen(next_word_a)-1] == ')')
                        --a_in_parens;
                      l = get_word(ptr, l, next_word_a, sizeof(next_word_a));
                      if (! a_in_parens)
                        break;
                    }
                  }
		}

		if ((k = l) > 0)
		  strcpy(word_a, next_word_a);
	      }
	    } else {
	      if (to_len > 0) {
		  (void) strcpy(full_to+to_len, ", ");
		  to_len += 2;
	      }
	      (void) strcpy(full_to+to_len, ptr);
	      to_len += strlen(ptr);
	    }
	    expanded_information++;
	  }
	  else if (too_long) {
	 /*
	  *   We don't do any real work here.  But we need some
	  *   sort of test in this line of tests to make sure
	  *   that none of the other else's are tried if the
	  *   alias expansion failed because it was too long.
	  */
	      dprint(2,(debugfile,"Overflowed alias expansion for %s\n", word));
	  }
	  else if (word[0] != '\0') {
	    if (to_len > 0) {
	      (void) strcpy(full_to+to_len, ", ");
	      to_len += 2;
	    }
	    if (valid_name(word)) {
	      (void) strcpy(full_to+to_len, word);
	      to_len += strlen(word);

	      if (next_word[0] != '(')
		if ((gecos = get_full_name(word)) != NULL && *gecos != '\0') {
		  sprintf(full_to+to_len, " (%s)", gecos);
		  to_len += strlen(gecos)+3;
		}
	    } else {
	      (void) strcpy(full_to+to_len, word);
	      to_len += strlen(word);
	    }
	  }

	  if((i = j) > 0)
	    strcpy(word, next_word);
	}

	return( expanded_information > 0 ? 1 : 0 );
}