Esempio n. 1
0
File: soa.c Progetto: jelu/validns
static struct rr* soa_parse(char *name, long ttl, int type, char *s)
{
    struct rr_soa *rr = getmem(sizeof(*rr));
    long long i;

    rr->mname = extract_name(&s, "mname", 0);
    if (!rr->mname) return NULL;
    rr->rname = extract_name(&s, "rname", 0);
    if (!rr->rname) return NULL;
    i = extract_integer(&s, "serial", NULL);
    if (i < 0) return NULL;
    if (i > 4294967295UL) return bitch("serial is out of range");
    rr->serial = i;
    rr->refresh = extract_timevalue(&s, "refresh");
    if (rr->refresh < 0) return NULL;
    rr->retry = extract_timevalue(&s, "retry");
    if (rr->retry < 0) return NULL;
    rr->expire = extract_timevalue(&s, "expire");
    if (rr->expire < 0) return NULL;
    rr->minimum = extract_timevalue(&s, "minimum");
    if (rr->minimum < 0) return NULL;
    if (ttl < 0 && G.opt.soa_minttl_as_default_ttl) {
        ttl = rr->minimum;
    }
    if (*s) {
        return bitch("garbage after valid SOA data");
    }
    return store_record(type, name, ttl, rr);
}
Esempio n. 2
0
File: lua.c Progetto: Monits/ctags
static void findLuaTags (void)
{
	vString *name = vStringNew ();
	const unsigned char *line;

	while ((line = fileReadLine ()) != NULL)
	{
		const char *p, *q;

		if (! is_a_code_line (line))
			continue;

		p = (const char*) strstr ((const char*) line, "function");
		if (p == NULL)
			continue;

		q = strchr ((const char*) line, '=');
		
		if (q == NULL) {
			p = p + 9;  /* skip the `function' word */
			q = strchr ((const char*) p, '(');
			extract_name (p, q, name);
		} else {
			p = (const char*) &line[0];
			extract_name (p, q, name);
		}
	}
	vStringDelete (name);
}
Esempio n. 3
0
TestInfo::TestInfo(unsigned int i, const char *libsuffix, const char *ilabel) :
   index(i),
   serialize_enable(false),
   label(ilabel),
   mutator(NULL),
   disabled(false),
   limit_disabled(false),
   enabled(false),
   result_reported(false)
{
   name = extract_name("test: ", label);
   mutator_name = extract_name("mutator: ", label);

   char *temp_soname = (char *) malloc(strlen(mutator_name) + strlen(libsuffix) + 1);
   strcpy(temp_soname, mutator_name);
   strcat(temp_soname, libsuffix);
   soname = temp_soname;
   assert(name);
   assert(mutator_name);
   assert(label);
   assert(soname);

   for (unsigned i=0; i<NUM_RUNSTATES; i++)
   {
      results[i] = UNKNOWN;
   }
}
Esempio n. 4
0
int onExport_Map()
{
    if(Map.getCurrMap()>=Map.getMapCount())
        return D_O_K;
        
    if(!getname("Export Map (.map)","map",NULL,datapath,false))
        return D_O_K;
        
    int ret = Map.save(temppath);
    char buf[80],buf2[80],name[13];
    extract_name(temppath,name,FILENAME8_3);
    
    if(!ret)
    {
        sprintf(buf,"ZQuest");
        sprintf(buf2,"Saved %s",name);
    }
    else
    {
        sprintf(buf,"Error");
        sprintf(buf2,"Error saving %s",name);
    }
    
    jwin_alert(buf,buf2,NULL,NULL,"O&K",NULL,'k',0,lfont);
    return D_O_K;
}
Esempio n. 5
0
int onExport_Subscreen()
{
    if(!getname("Export Subscreen (.sub)","sub",NULL,datapath,false))
        return D_O_K;
        
    bool cancel;
    char buf[80],buf2[80],name[13];
    extract_name(temppath,name,FILENAME8_3);
    
    if(save_subscreen(temppath, &cancel))
    {
        if(!cancel)
        {
            sprintf(buf,"ZQuest");
            sprintf(buf2,"Saved %s",name);
        }
        else
        {
            sprintf(buf,"ZQuest");
            sprintf(buf2,"Did not save %s",name);
        }
    }
    else
    {
        sprintf(buf,"Error");
        sprintf(buf2,"Error saving %s",name);
    }
    
    jwin_alert(buf,buf2,NULL,NULL,"O&K",NULL,'k',0,lfont);
    return D_O_K;
}
Esempio n. 6
0
int onImport_UnencodedQuest()
{
    if(!getname("Import Unencoded Quest (.qsu)","qsu",NULL,datapath,false))
        return D_O_K;
        
    saved=false;
    // usetiles=true;
    int ret = load_quest(temppath,false,false);
    
    if(ret != qe_OK && ret != qe_cancel)
    {
        char buf[80],name[13];
        extract_name(temppath,name,FILENAME8_3);
        sprintf(buf,"Unable to load %s",name);
        jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,lfont);
    }
    
    register_blank_tiles();
    loadlvlpal(Color);
    setup_combo_animations();
    setup_combo_animations2();
    Map.setCurrMap(Map.getCurrMap());                         // for bound checking
    refresh(rALL);
    refresh_pal();
    return D_O_K;
}
Esempio n. 7
0
/* Return bytes of canonicalised rdata, when the return value is zero, the remaining 
   data, pointed to by *p, should be used raw. */
static int get_rdata(struct dns_header *header, size_t plen, unsigned char *end, char *buff, 
		     unsigned char **p, u16 **desc)
{
  int d = **desc;
  
  (*desc)++;
  
  /* No more data needs mangling */
  if (d == (u16)-1)
    return 0;
  
  if (d == 0 && extract_name(header, plen, p, buff, 1, 0))
    /* domain-name, canonicalise */
    return to_wire(buff);
  else
    { 
      /* plain data preceding a domain-name, don't run off the end of the data */
      if ((end - *p) < d)
	d = end - *p;
      
      if (d != 0)
	{
	  memcpy(buff, *p, d);
	  *p += d;
	}
      
      return d;
    }
}
Esempio n. 8
0
int onImport_Tiles()
{
    int ret=getnumber("Import Start Page",0);
    
    if(cancelgetnum)
    {
        return D_O_K;
    }
    
    bound(ret,0,TILE_PAGES-1);
    
    if(!getname("Import Tiles (.til)","til",NULL,datapath,false))
        return D_O_K;
        
    saved=false;
    
    // usetiles=true;
    if(!load_tiles(temppath, ret*TILES_PER_PAGE))
    {
        char buf[80],name[13];
        extract_name(temppath,name,FILENAME8_3);
        sprintf(buf,"Unable to load %s",name);
        jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,lfont);
    }
    
    refresh(rALL);
    return D_O_K;
}
Esempio n. 9
0
int onImport_Combos()
{
    int ret=getnumber("Import Start Page",0);
    
    if(cancelgetnum)
    {
        return D_O_K;
    }
    
    bound(ret,0,COMBO_PAGES-1);
    
    if(!getname("Import Combo Table (.cmb)","cmb",NULL,datapath,false))
        return D_O_K;
        
    if(!load_combos(temppath, ret*COMBOS_PER_PAGE))
    {
        // if(!load_combos(temppath)) {
        char buf[80],name[13];
        extract_name(temppath,name,FILENAME8_3);
        sprintf(buf,"Unable to load %s",name);
        jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,lfont);
    }
    else
        saved=false;
        
    refresh(rALL);
    return D_O_K;
}
Esempio n. 10
0
int onImport_Map()
{
    if(Map.getCurrMap()>=Map.getMapCount())
        return D_O_K;
        
    if(get_import_map_bias()==-1)
    {
        return D_O_K;
    }
    
    if(!getname("Import Map (.map)","map",NULL,datapath,false))
        return D_O_K;
        
    saved=false;
    int ret=Map.load(temppath);
    
    if(ret)
    {
        char buf[80],name[13];
        extract_name(temppath,name,FILENAME8_3);
        sprintf(buf,"Unable to load %s",name);
        jwin_alert("Error",buf,loaderror[ret],NULL,"O&K",NULL,'k',0,lfont);
        
        if(ret>1)
            Map.clearmap(false);
    }
    else
    {
        bool willaffectlayers=false;
        
        for(int i=0; i<MAPSCRS; i++)
        {
            for(int j=0; !willaffectlayers && j<6; j++)
            {
                if(TheMaps[Map.getCurrMap()*MAPSCRS+i].layermap[j]>Map.getMapCount())
                {
                    willaffectlayers=true;
                    break;
                }
            }
            
            fix_layers(&TheMaps[Map.getCurrMap()*MAPSCRS+i], false);
        }
        
        if(willaffectlayers)
        {
            jwin_alert("Layers Changed",
                       "One or more screens in the imported map had",
                       "layers on maps that do not exist. The map numbers",
                       "of the affected layers will be reset to 0.",
                       "&OK", NULL, 'o', 0, lfont);
        }
    }
    
    refresh(rSCRMAP+rMAP+rMENU);
    return D_O_K;
}
Esempio n. 11
0
static struct rr *minfo_parse(char *name, long ttl, int type, char *s)
{
	struct rr_minfo *rr = getmem(sizeof(*rr));

	rr->rmailbx = extract_name(&s, "rmailbx", 0);
	if (!rr->rmailbx)
		return NULL;

	rr->emailbx = extract_name(&s, "emailbx", 0);
	if (!rr->emailbx)
		return NULL;

	if (*s) {
		return bitch("garbage after valid MINFO data");
	}

	return store_record(type, name, ttl, rr);
}
Esempio n. 12
0
/* Match a ".label" style label. */
static void match_dot_label (char const *p)
{
	if (*p == '.')
	{
		vString *name = vStringNew ();
		extract_name (p + 1, name);
		makeSimpleTag (name, BasicKinds, K_LABEL);
		vStringDelete (name);
	}
}
Esempio n. 13
0
/*
 * Add a new user
 */
void add_user(user_chat_box_t *users, char *buf, int server_fd)
{
	/***** Insert YOUR code *******/
	
	/* 
	 * Check if user limit reached.
	 *
	 * If limit is okay, add user, set up non-blocking pipes and
	 * notify on server shell
	 *
	 * NOTE: You may want to remove any newline characters from the name string 
	 * before adding it. This will help in future name-based search.
	 */
	int i;
	pid_t pid;
	char* user_name = extract_name(ADD_USER, buf);
	char msg[MSG_SIZE];
	char arg1[MSG_SIZE];
	char arg2[MSG_SIZE];
	if (find_user_index(users, user_name) != -1){
		printf("%s already exists.\n", user_name);
		return;
	}
	else
	{
		if ((i = find_empty_slot(users)) == -1)
		{
			printf("Users are full.\n");
			return;
		}
		else
		{
			sprintf(msg, "Adding %s...\n", user_name);
			users[i].status = SLOT_FULL;
			strcpy(users[i].name, user_name);
			pipe(users[i].ptoc);
			pipe(users[i].ctop);
			fcntl(users[i].ptoc[0],F_SETFL, O_NONBLOCK);
			fcntl(users[i].ctop[0],F_SETFL, O_NONBLOCK);
			if (write(server_fd, msg, strlen(msg) + 1) < 0)
				perror("Writing to server shell");
		}
	}
	//Fork a child process to execute added user's Xterm
	if ((users[i].pid = fork()) < 0)
		perror("Add_user fork error");
	else if (users[i].pid == 0)
	{
		sprintf(arg1, "%d", users[i].ptoc[0]);
		sprintf(arg2, "%d", users[i].ctop[1]);
		execl(XTERM_PATH, XTERM, "+hold", "-e", "./shell", arg1, arg2, user_name, (char *)0);
	} 
	return;
}
Esempio n. 14
0
static void*
__acquire_category(const char* &name, char *buf, _Locale_name_hint* hint,
                   loc_extract_name_func_t extract_name,
                   loc_create_func_t create_obj, loc_default_name_func_t default_name,
                   Category_Map ** M, int *__err_code) {
  typedef Category_Map::iterator Category_iterator;
  pair<Category_iterator, bool> result;

  *__err_code = _STLP_LOC_UNDEFINED;

  // Find what name to look for. Be careful if user requests the default.
  if (name[0] == 0) {
    name = default_name(buf);
    if (name == 0 || name[0] == 0)
      name = "C";
  }
  else {
    const char* cname = extract_name(name, buf, hint, __err_code);
    if (cname == 0) {
      return 0;
    }
    name = cname;
  }

  Category_Map::value_type __e(name, pair<void*,size_t>((void*)0,size_t(0)));

  _STLP_auto_lock sentry(category_hash_mutex());

  if (!*M)
    *M = new Category_Map();

  // Look for an existing entry with that name.
  result = (*M)->insert_noresize(__e);

  if (result.second) {
    // There was no entry in the map already.  Create the category.
    (*result.first).second.first = create_obj(name, hint, __err_code);
    if (!(*result.first).second.first) {
      (*M)->erase(result.first);
#if defined (_STLP_LEAKS_PEDANTIC)
      if ((*M)->empty()) {
        delete *M;
        *M = 0;
      }
#endif
      return 0;
    }
  }

  // Increment the reference count.
  ++((*result.first).second.second);

  return (*result.first).second.first;
}
Esempio n. 15
0
static int on_config_header_unset(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
    h2o_iovec_t *name;

    if (extract_name(node->data.scalar, strlen(node->data.scalar), &name) != 0) {
        h2o_configurator_errprintf(cmd, node, "invalid header name");
        return -1;
    }
    if (add_cmd(cmd, node, H2O_HEADERS_CMD_UNSET, name, (h2o_iovec_t){}) != 0)
        return -1;
    return 0;
}
Esempio n. 16
0
QString true_name(const QString & name, const QString & decl)
{
    int index;
    QString n;

    n = ((index = name.indexOf(" ")) == -1)
        ? name
        : name.left(index);

    QString s = extract_name(decl);

    return (s.isEmpty()) ? n : s.replace(s.indexOf("${name}"), 7, n);
}
Esempio n. 17
0
File: mr.c Progetto: MikeAT/validns
static struct rr *mr_parse(char *name, long ttl, int type, char *s)
{
	struct rr_mr *rr = getmem(sizeof(*rr));

	rr->newname = extract_name(&s, "newname", 0);
	if (!rr->newname)
		return NULL;
	if (*s) {
		return bitch("garbage after valid MR data");
	}

	return store_record(type, name, ttl, rr);
}
Esempio n. 18
0
static struct rr *px_parse(char *name, long ttl, int type, char *s)
{
	struct rr_px *rr = getmem(sizeof(*rr));

	rr->preference = extract_integer(&s, "PX preference", NULL);
	if (rr->preference < 0)
		return NULL;

	rr->map822 = extract_name(&s, "map822", 0);
	if (!rr->map822)
		return NULL;

	rr->mapx400 = extract_name(&s, "mapx400", 0);
	if (!rr->mapx400)
		return NULL;

	if (*s) {
		return bitch("garbage after valid KX data");
	}

	return store_record(type, name, ttl, rr);
}
Esempio n. 19
0
/*
 * Send personal message. Print error on the user shell if user not found.
 */
void send_p2p_msg(int idx, user_chat_box_t *users, char *buf)
{
	/* get the target user by name (hint: call (extract_name() and send message */
	
	char *target_name;
	int target_idx;
	char *s;
	char text[MSG_SIZE];
	target_name = extract_name(P2P, buf);
	target_idx = find_user_index(users, target_name);
	s = strtok(NULL, SH_DELIMS); //extract the messege
	sprintf(text, "%s : %s", users[idx].name, s);
	write(users[target_idx].ptoc[1], text, strlen(text) + 1);
}
Esempio n. 20
0
static struct rr *naptr_parse(char *name, long ttl, int type, char *s)
{
	struct rr_naptr *rr = getmem(sizeof(*rr));
	int i;
	struct binary_data text;

	i = extract_integer(&s, "order");
	if (i < 0)
		return NULL;
	if (i >= 65536)
		return bitch("order range is not valid");
	rr->order = i;

	i = extract_integer(&s, "preference");
	if (i < 0)
		return NULL;
	if (i >= 65536)
		return bitch("preference range is not valid");
	rr->preference = i;

	text = extract_text(&s, "flags");
	if (text.length < 0)
		return NULL;
	for (i = 0; i < text.length; i++) {
		if (!isalnum(text.data[i])) {
			return bitch("flags contains illegal characters");
		}
	}
	rr->flags = text;

	text = extract_text(&s, "services");
	if (text.length < 0)
		return NULL;
	rr->services = text;

	text = extract_text(&s, "regexp");
	if (text.length < 0)
		return NULL;
	rr->regexp = text;

	rr->replacement = extract_name(&s, "replacement");
	if (!rr->replacement)
		return NULL;

	if (*s) {
		return bitch("garbage after valid NAPTR data");
	}

	return store_record(type, name, ttl, rr);
}
Esempio n. 21
0
int onSaveAs()
{
    if(disable_saving)
    {
        jwin_alert("ZQuest","Saving is","disabled in this version.",NULL,"O&K",NULL,'k',0,lfont);
        return D_O_K;
    }
    
    if(!getname("Save Quest As (.qst)","qst",NULL,filepath,true))
        return D_O_K;
        
    if(exists(temppath))
    {
        if(OverwriteProtection)
        {
            jwin_alert("ZQuest","Overwriting quests is disabled.","Change this in the options dialog.",NULL,"O&K",NULL,'k',0,lfont);
            return D_O_K;
        }
        
        if(jwin_alert("Confirm Overwrite",temppath,"already exists.","Write over existing file?","&Yes","&No",'y','n',lfont)==2)
        {
            return D_O_K;
        }
    }
    
    int ret = save_quest(temppath, false);
    char buf[1024],name[13];
    extract_name(temppath,name,FILENAME8_3);
    
    if(!ret)
    {
        strcpy(filepath,temppath);
        sprintf(buf,"ZQuest - [%s]", get_filename(filepath));
        set_window_title(buf);
        sprintf(buf,"Saved %s",name);
        jwin_alert("ZQuest",buf,NULL,NULL,"O&K",NULL,'k',0,lfont);
        saved=true;
        first_save=true;
        header.dirty_password=false;
    }
    else
    {
        sprintf(buf,"Error saving %s",name);
        jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,lfont);
    }
    
    refresh(rMENU);
    last_timed_save[0]=0;
    return D_O_K;
}
Esempio n. 22
0
static void*
__acquire_category(const char* name, _Locale_name_hint* hint,
                   loc_extract_name_func_t extract_name,
                   loc_create_func_t create_obj, loc_default_name_func_t default_obj,
                   Category_Map ** M) {
#if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x564)
  typedef Category_Map::iterator Category_iterator;
  pair<Category_iterator, bool> result;
#else
#  if !defined(_STLP_DEBUG)
  pair<_Ht_iterator<_Slist_iterator<pair<const string,pair<void *,unsigned int> >,_Nonconst_traits<pair<const string,pair<void *,unsigned int> > > >,_NonLocalHashMapTraitsT<pair<const string,pair<void *,unsigned int> > > >, bool> result;
#  else
  pair<_DBG_iter<_NonDbg_hashtable<pair<const string,pair<void *,unsigned int> >,string,hash<string>,_HashMapTraitsT<pair<const string,pair<void *,unsigned int> > >,_Select1st<pair<const string,pair<void *,unsigned int> > >,_DbgEqual<string,equal_to<string> >,allocator<pair<const string,pair<void *,unsigned int> > > >,_DbgTraits<_NonLocalHashMapTraitsT<pair<const string,pair<void *,unsigned int> > > > >, bool> result;
#  endif
#endif

  // Find what name to look for. Be careful if user requests the default.
  const char *cname;
  char buf[_Locale_MAX_SIMPLE_NAME];
  if (name == 0 || name[0] == 0) {
    cname = default_obj(buf);
    if (cname == 0 || cname[0] == 0)
      cname = "C";
  }
  else {
    cname = extract_name(name, buf, hint);
    if (cname == 0) {
      return 0;
    }
  }

  Category_Map::value_type __e(cname, pair<void*,size_t>((void*)0,size_t(0)));

  _STLP_auto_lock sentry(__category_hash_lock);

  if (!*M)
    *M = new Category_Map();

  // Look for an existing entry with that name.
  result = (*M)->insert_noresize(__e);

  // There was no entry in the map already.  Create the category.
  if (result.second)
    (*result.first).second.first = create_obj(cname, hint);

  // Increment the reference count.
  ++((*result.first).second.second);

  return (*result.first).second.first;
}
Esempio n. 23
0
static int extract_name_value(const char *src, h2o_iovec_t **name, h2o_iovec_t *value)
{
    const char *colon = strchr(src, ':');

    if (colon == NULL)
        return -1;

    if (extract_name(src, colon - src, name) != 0)
        return -1;
    *value = h2o_str_stripws(colon + 1, strlen(colon + 1));
    *value = h2o_strdup(NULL, value->base, value->len);

    return 0;
}
Esempio n. 24
0
int onImport_ComboAlias()
{
    if(!getname("Import Combo Alias (.zca)","zca",NULL,datapath,false))
        return D_O_K;
        
    if(!load_combo_alias(temppath))
    {
        char buf[80],name[13];
        extract_name(temppath,name,FILENAME8_3);
        sprintf(buf,"Unable to load %s",name);
        jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,lfont);
    }
    
    refresh(rALL);
    return D_O_K;
}
Esempio n. 25
0
File: mx.c Progetto: umq/validns
static struct rr *mx_parse(char *name, long ttl, int type, char *s)
{
	struct rr_mx *rr = getmem(sizeof(*rr));

	rr->preference = extract_integer(&s, "MX preference");
	if (rr->preference < 0)
		return NULL;
	/* XXX preference range check */
	rr->exchange = extract_name(&s, "MX exchange", 0);
	if (!rr->exchange)
		return NULL;
	if (*s) {
		return bitch("garbage after valid MX data");
	}

	return store_record(type, name, ttl, rr);
}
Esempio n. 26
0
File: rt.c Progetto: jelu/validns
static struct rr *rt_parse(char *name, long ttl, int type, char *s)
{
    struct rr_rt *rr = getmem(sizeof(*rr));

    rr->preference = extract_integer(&s, "RT preference", NULL);
    if (rr->preference < 0)
        return NULL;

    rr->intermediate_host = extract_name(&s, "intermediate-host", 0);
    if (!rr->intermediate_host)
        return NULL;
    if (*s) {
        return bitch("garbage after valid RT data");
    }

    return store_record(type, name, ttl, rr);
}
Esempio n. 27
0
int onImport_Msgs()
{
    if(!getname("Import String Table (.zqs)","zqs",NULL,datapath,false))
        return D_O_K;
        
    saved=false;
    
    if(!load_msgstrs(temppath,0))
    {
        char buf[80],name[13];
        extract_name(temppath,name,FILENAME8_3);
        sprintf(buf,"Unable to load %s",name);
        jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,lfont);
    }
    
    return D_O_K;
}
Esempio n. 28
0
int read_file(char* name, char* password)
{
   FILE* fp;
   char* line = NULL;
   char* line_tmp = NULL;
   char* cred_concat = NULL;
   size_t len = 0;
   ssize_t read;

   // test_space(name);
   // test_space(password);

   

   fp = fopen("users.csv", "r");
   if (fp == NULL){
      printf("exit can't open file\n");
     exit(EXIT_FAILURE);
   }
   char* t = NULL;
   while ((read = getline(&line, &len, fp)) != -1) {
      //printf("Retrieved line of length %zu :\n", read);
      printf("%s\n", line);
      
      
      
      
      if(
      (test_credential_password(extract_password(line), password) == 0) &&      
      (test_credential_name(extract_name(line), name)) == 0)
      {
         //good login and password
         //printf("good %s : %s\n", name, password );
         fclose(fp);
         if (line)
            free(line);
         free(cred_concat); 
         return 0;
      }     
   }
   fclose(fp);
   if (line)
      free(line);
   free(cred_concat); 
   return 1; 
}
static void*
__acquire_category(const char* name, loc_extract_name_func_t extract_name,
                   loc_create_func_t create_obj, loc_default_name_func_t default_obj, 
                   Category_Map ** M) {
  typedef Category_Map::iterator Category_iterator;
  pair<Category_iterator, bool> result;
  
  // Find what name to look for. Be careful if user requests the default.
  const char *cname;
  char buf[_Locale_MAX_SIMPLE_NAME];
  if (name == 0 || name[0] == 0) {
    cname = default_obj(buf);
    if (cname == 0 || cname[0] == 0)
      cname = "C";
  }
  else {
    cname = extract_name(name, buf);
    if (cname == 0) {
      return 0;
    }
  }

  Category_Map::value_type __e(cname, pair<void*,size_t>((void*)0,size_t(0)));

  _STLP_auto_lock sentry(__category_hash_lock);

  if (!*M)
    *M = new Category_Map();

#if defined(__SC__)    //*TY 06/01/2000 - added workaround for SCpp
  if(!*M) delete *M;  //*TY 06/01/2000 - it forgets to generate dtor for Category_Map class. This fake code forces to generate one.
#endif          //*TY 06/01/2000 - 

  // Look for an existing entry with that name.
  result = (*M)->insert_noresize(__e);

  // There was no entry in the map already.  Create the category.
  if (result.second) 
    (*result.first).second.first = create_obj(cname);

  // Increment the reference count.
  ++((*result.first).second.second);

  return (*result.first).second.first;
}
Esempio n. 30
0
int onImport_DMaps()
{
    if(!getname("Import DMaps (.dmp)","dmp",NULL,datapath,false))
        return D_O_K;
        
    saved=false;
    
    if(!load_dmaps(temppath,0))
    {
        char buf[80],name[13];
        extract_name(temppath,name,FILENAME8_3);
        sprintf(buf,"Unable to load %s",name);
        jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,lfont);
    }
    else
    {
        int maxMap=0;
        for(int i=0; i<MAXDMAPS; i++)
        {
            if(DMaps[i].map>maxMap)
                maxMap=DMaps[i].map;
        }
        
        if(maxMap>map_count)
        {
            int ret=jwin_alert("Not enough maps",
                               "The imported DMaps use more maps than are",
                               " currently available. Do you want to add",
                               "more maps or change the DMaps' settings?",
                               "&Add maps","&Modify DMaps",'a','m',lfont);
            if(ret==1)
                setMapCount2(maxMap+1);
            else
            {
                for(int i=0; i<MAXDMAPS; i++)
                {
                    if(DMaps[i].map>=map_count)
                        DMaps[i].map=0;
                }
            }
        }
    }
    
    return D_O_K;
}