Beispiel #1
0
int main(int argc, char **argv) {
	namelist nl=make_namelist();
	int i;
	char c='f';
	if(strcmp(argv[1],"-p")==0){
		i=3;
		c='t';
	}
	else i=1;
	while(i<argc){
		FILE *file=fopen(argv[i],"r");
		char name[64];
		while(!feof(file)){
			if (fgetname(name,64,file)!= NULL && res_name(name)!=1){
				if(c=='f'||(c=='t'&& (name[0])!=*argv[2]))
				      add_name(nl,name);
				
			}
			
		}
		fclose(file);
		i++;
	}
	qsort(nl->names,nl->size,sizeof(struct namestat),cmpfunc);
	print_list(nl);
	return 0;
} 
Beispiel #2
0
int32_t CodeBuilder::addop_name(Op opcode,std::string& name)
{
    int arg = add_name(name);
    if (arg < 0)
        return 0;
    return addop_i(opcode, arg);
}
Beispiel #3
0
      int main (int argc, char **argv){
      //varibales
      namelist nl = make_namelist();  
      FILE *stream; 
      char *fileName;
      char name[64];
      int FLAG = 0;
      int i = 1;
      int j = 0;     
      
      //upload files in a loop and gets the name to an array
    for (i=1;i!=argc;i++){//each file
     fileName = argv[i];//get the file
     stream = fopen(fileName, "r");//read the file
     
     while(fgetname(name, sizeof(name), stream)) {
       if(legalName(name)){
       printf("%s ", name);
	add_name(nl, name);
	//printf("\n");
	}
     }
     fclose(stream);
      }
      qsort(nl->names,nl->size,sizeof(struct namestat),compare);
  
  for(i=0;i<nl->size;i++){
    printf("%s %d\n",nl->names[i].name,nl->names[i].count);
  }
  
   
      return 0;
      }
Beispiel #4
0
/* flag the dll exports that link to an undefined symbol */
static void check_undefined_exports( DLLSPEC *spec )
{
    int i;

    for (i = 0; i < spec->nb_entry_points; i++)
    {
        ORDDEF *odp = &spec->entry_points[i];
        if (odp->type == TYPE_STUB || odp->type == TYPE_ABS || odp->type == TYPE_VARIABLE) continue;
        if (odp->flags & FLAG_FORWARD) continue;
        if (find_name( odp->link_name, &undef_symbols ))
        {
            switch(odp->type)
            {
            case TYPE_PASCAL:
            case TYPE_STDCALL:
            case TYPE_CDECL:
            case TYPE_VARARGS:
            case TYPE_THISCALL:
                if (link_ext_symbols)
                {
                    odp->flags |= FLAG_EXT_LINK;
                    add_name( &ext_link_imports, odp->link_name );
                }
                else error( "%s:%d: function '%s' not defined\n",
                            spec->src_name, odp->lineno, odp->link_name );
                break;
            default:
                error( "%s:%d: external symbol '%s' is not a function\n",
                       spec->src_name, odp->lineno, odp->link_name );
                break;
            }
        }
    }
}
Beispiel #5
0
/*
 * Called to initialize the driver
 */
isc_result_t
dlz_create(const char *dlzname, unsigned int argc, char *argv[],
	   void **dbdata, ...)
{
	struct dlz_example_data *state;
	const char *helper_name;
	va_list ap;
	char soa_data[200];

	UNUSED(dlzname);

	state = calloc(1, sizeof(struct dlz_example_data));
	if (state == NULL)
		return (ISC_R_NOMEMORY);

	/* Fill in the helper functions */
	va_start(ap, dbdata);
	while ((helper_name = va_arg(ap, const char *)) != NULL) {
		b9_add_helper(state, helper_name, va_arg(ap, void*));
	}
	va_end(ap);

	if (argc < 2) {
		state->log(ISC_LOG_ERROR,
			   "dlz_example: please specify a zone name");
		return (ISC_R_FAILURE);
	}

	state->zone_name = strdup(argv[1]);

	sprintf(soa_data, "%s hostmaster.%s 123 900 600 86400 3600",
		state->zone_name, state->zone_name);

	add_name(state, &state->current[0], state->zone_name,
		 "soa", 3600, soa_data);
	add_name(state, &state->current[0], state->zone_name,
		 "ns", 3600, state->zone_name);
	add_name(state, &state->current[0], state->zone_name,
		 "a", 1800, "10.53.0.1");

	state->log(ISC_LOG_INFO,
		   "dlz_example: started for zone %s",
		   state->zone_name);

	*dbdata = state;
	return (ISC_R_SUCCESS);
}
Beispiel #6
0
void checkTxt(namelist nl, char *filename)
{
    FILE *f1;
    f1 = fopen(filename,"r");
    char kw[32][10] = {"auto", "double", "int", "long", "break", "else", "long", "switch", "case", "enum", "register", "typedef", "char", "extern", "return", "union", "const", "float", "short", "unsigned", "continue", "for", "signed", "oid", "default", "goto", "sizeof", "volatile", "do", "if", "static", "while"};

    char  x;
    int wordi=0;
    
    if (ferror (f1))
	printf("error reading file - %s\n",filename );
   
    else
    {
	char word[NAMELEN]="";
	x=fgetc(f1);
	while (x != EOF)// not EOF  (!feof(f1)) 
	{
	  if ((isdigit(x)!=0 )|( isalpha(x)!=0 )) //INWORD proccessing
	  {
	    word[wordi]=x;
	    wordi++;
	    x =fgetc(f1);
	  }
	  else //if buffer full - wordi!=0  - save word ->> in namelist. else next char 
	  {
	    if (wordi!=0)  //not in word and buffer is full
	    {
	      
	      int j,flag=0;
	      word[wordi]='\0'; //NOTICE \0 at end of string	
	      //printf("%s \n",word);
	      for (j=0;j<32;j++)   //NOTICE check word is not keyword
	      {
		if (! strcmp(word,kw[j]))
		{
		  flag=1;
		  j=32;
		}
	      }
	      if (!flag) //add word
		add_name(nl, word);
	      else	//keyword, dont add it
		flag=0;
	      wordi=0; //c=fgetc(f1);
	    }
	    else  //not in word and buffer is empty = > get next char
	    {
	      //printf("else else else -not a word and word buffer is 0) \n");
	      x =fgetc(f1);  
	    }
	  }
	    
	}
    }


    fclose(f1);
}
Beispiel #7
0
void copy_name_list( NAME_LIST_HDR *header, const NAME_LIST *list )
{
    while (list)
    {
        add_name( header, &list->name[0] );
        list = list->next;
    }
}
Beispiel #8
0
static void
add_preproc_option(int key, const char *arg)
{
     char *opt = xmalloc(3 + strlen(arg));
     sprintf(opt, "-%c%s", key, arg);
     add_name(opt);
     preprocess_option = 1;
}
Beispiel #9
0
void MON_LABELS::add(u8 *address, char *name)
{
   if (n_pairs >= align_by(n_pairs, 1024))
      pairs = (MON_LABEL*)realloc(pairs, sizeof(MON_LABEL) * align_by(n_pairs+1, 1024));
   pairs[n_pairs].address = address;
   pairs[n_pairs].name_offs = add_name(name);
   n_pairs++;
}
Beispiel #10
0
static int
tty_rename(ARCHD *arcn)
{
	char tmpname[PAXPATHLEN+2];
	int res;

	/*
	 * prompt user for the replacement name for a file, keep trying until
	 * we get some reasonable input. Archives may have more than one file
	 * on them with the same name (from updates etc). We print verbose info
	 * on the file so the user knows what is up.
	 */
	tty_prnt("\nATTENTION: %s interactive file rename operation.\n", argv0);

	for (;;) {
		ls_tty(arcn);
		tty_prnt("Input new name, or a \".\" to keep the old name, ");
		tty_prnt("or a \"return\" to skip this file.\n");
		tty_prnt("Input > ");
		if (tty_read(tmpname, sizeof(tmpname)) < 0)
			return(-1);
		if (strcmp(tmpname, "..") == 0) {
			tty_prnt("Try again, illegal file name: ..\n");
			continue;
		}
		if (strlen(tmpname) > PAXPATHLEN) {
			tty_prnt("Try again, file name too long\n");
			continue;
		}
		break;
	}

	/*
	 * empty file name, skips this file. a "." leaves it alone
	 */
	if (tmpname[0] == '\0') {
		tty_prnt("Skipping file.\n");
		return(1);
	}
	if ((tmpname[0] == '.') && (tmpname[1] == '\0')) {
		tty_prnt("Processing continues, name unchanged.\n");
		return(0);
	}

	/*
	 * ok the name changed. We may run into links that point at this
	 * file later. we have to remember where the user sent the file
	 * in order to repair any links.
	 */
	tty_prnt("Processing continues, name changed to: %s\n", tmpname);
	res = add_name(arcn->name, arcn->nlen, tmpname);
	arcn->nlen = strlcpy(arcn->name, tmpname, sizeof(arcn->name));
	if (arcn->nlen >= sizeof(arcn->name))
		arcn->nlen = sizeof(arcn->name) - 1; /* XXX truncate? */
	if (res < 0)
		return(-1);
	return(0);
}
Beispiel #11
0
void
inbound_nameslist (server *serv, char *chan, char *names)
{
	session *sess;
	char name[NICKLEN];
	int pos = 0;

	sess = find_channel (serv, chan);
	if (!sess)
	{
		EMIT_SIGNAL (XP_TE_USERSONCHAN, serv->server_session, chan, names, NULL,
						 NULL, 0);
		return;
	}
	if (!sess->ignore_names)
		EMIT_SIGNAL (XP_TE_USERSONCHAN, sess, chan, names, NULL, NULL, 0);

	if (sess->end_of_names)
	{
		sess->end_of_names = FALSE;
		clear_user_list (sess);
	}

	while (1)
	{
		switch (*names)
		{
		case 0:
			name[pos] = 0;
			if (pos != 0)
				add_name (sess, name, 0);
			return;
		case ' ':
			name[pos] = 0;
			pos = 0;
			add_name (sess, name, 0);
			break;
		default:
			name[pos] = *names;
			if (pos < (NICKLEN-1))
				pos++;
		}
		names++;
	}
}
Beispiel #12
0
int main(int argc, char **argv) {
	if(argc == 1) {
		printf("please run this program with at least one argument.\n");
	}
	else{
		int i;
		char buffer[BUFLEN];
		char* saved_words[]= {"int","char","if","else","while","for","return",(char*)0};
		namelist file_words= make_namelist();
		for (i=1; i<argc; ++i){
		      FILE *fptr;
		      if ( (fptr = fopen(argv[i],"r")) == NULL)
			    printf ("file %s couldn't be opened\n",argv[i]);
		      else {
			    char word[BUFLEN];
			    int ich = 0;
			    int isaved = 0;
			    int inword = 0;
			    for(;;) {
				int ch = fgetc(fptr);
				if(feof(fptr))
				      break;
				if(inword) {
				      if(isalpha(ch)) {    // adding char to the word
					  word[ich] = ch;
					  ++ich;
				      } 
				      else{     // just finished reading a word
					  word[ich] = 0;
					  ich = 0;
					  inword = 0;
					  if (!find_word(saved_words,word)){
						add_name(file_words,word);
					  }
	
				      }
				}
		
				else {
				      if(isalpha(ch)) {        //for the first char of the word
					  ungetc(ch,fptr);
					  inword=1;
				      } 
				      if (ch == '\"'){
					  ch = fgetc(fptr);
					  while (ch != '\"')
						ch = fgetc(fptr);
				      }
				}
			    }
		      }
		}
		sort_words(file_words);
		print_words(file_words);
	}
	return 0;
}
Beispiel #13
0
static isc_result_t
modrdataset(struct dlz_example_data *state, const char *name,
	    const char *rdatastr, struct record *list)
{
	char *full_name, *dclass, *type, *data, *ttlstr, *buf;
	char absolute[1024];
	isc_result_t result;
#if defined(WIN32) || defined(_REENTRANT)
	char *saveptr = NULL;
#endif

	buf = strdup(rdatastr);
	if (buf == NULL)
		return (ISC_R_FAILURE);

	/*
	 * The format is:
	 * FULLNAME\tTTL\tDCLASS\tTYPE\tDATA
	 *
	 * The DATA field is space separated, and is in the data format
	 * for the type used by dig
	 */

	full_name = STRTOK_R(buf, "\t", &saveptr);
	if (full_name == NULL)
		goto error;

	ttlstr = STRTOK_R(NULL, "\t", &saveptr);
	if (ttlstr == NULL)
		goto error;

	dclass = STRTOK_R(NULL, "\t", &saveptr);
	if (dclass == NULL)
		goto error;

	type = STRTOK_R(NULL, "\t", &saveptr);
	if (type == NULL)
		goto error;

	data = STRTOK_R(NULL, "\t", &saveptr);
	if (data == NULL)
		goto error;

	if (name[strlen(name) - 1] != '.') {
		snprintf(absolute, sizeof(absolute), "%s.", name);
		name = absolute;
	}

	result = add_name(state, list, name, type,
			  strtoul(ttlstr, NULL, 10), data);
	free(buf);
	return (result);

 error:
	free(buf);
	return (ISC_R_FAILURE);
}
Beispiel #14
0
static void
add_hierarchy_to_namelist (char *path, dev_t device)
{
  char *buffer = get_directory_contents (path, device);

  {
    struct name *name;

    for (name = name_list_head; name; name = name->next)
      if (strcmp (name->name, path) == 0)
	  break;
    if (name)
      name->dir_contents = buffer ? buffer : "\0\0\0\0";
  }

  if (buffer)
    {
      size_t name_length = strlen (path);
      size_t allocated_length = (name_length >= NAME_FIELD_SIZE
				 ? name_length + NAME_FIELD_SIZE
				 : NAME_FIELD_SIZE);
      char *name_buffer = xmalloc (allocated_length + 1);
				/* FIXME: + 2 above?  */
      char *string;
      size_t string_length;

      strcpy (name_buffer, path);
      if (name_buffer[name_length - 1] != '/')
	{
	  name_buffer[name_length++] = '/';
	  name_buffer[name_length] = '\0';
	}

      for (string = buffer; *string; string += string_length + 1)
	{
	  string_length = strlen (string);
	  if (*string == 'D')
	    {
	      if (name_length + string_length >= allocated_length)
		{
		  while (name_length + string_length >= allocated_length)
		    allocated_length += NAME_FIELD_SIZE;
		  name_buffer = (char *)
		    xrealloc (name_buffer, allocated_length + 1);
		}
	      strcpy (name_buffer + name_length, string + 1);
	      add_name (name_buffer);
	      add_hierarchy_to_namelist (name_buffer, device);
	    }
	}

      free (name_buffer);
    }
}
Beispiel #15
0
void
inbound_join (server *serv, char *chan, char *user, char *ip)
{
	session *sess = find_channel (serv, chan);
	if (sess)
	{
		if (!sess->hide_join_part)
			EMIT_SIGNAL (XP_TE_JOIN, sess, user, chan, ip, NULL, 0);
		add_name (sess, user, ip);
	}
}
Beispiel #16
0
/*-------------------------------------------------------------------------*/
void
load_wiz_file (void)

/* Load the old wizlist from the wizlist file and add it's data to
 * the wizlist already in memory.
 *
 * This function is called at driver start up.
 * TODO: Since the wizlist is saved from the mudlib, this function
 * TODO:: should be implemented on mudlib level, too.
 */

{
    char buff[1000];
    FILE *f;

    if (wizlist_name[0] == '\0')
        return;

    f = fopen(wizlist_name, "r");
    if (f == NULL)
        return;

    while (fgets(buff, sizeof buff, f) != NULL)
    {
        char *p;
        uint32 score;

        p = strchr(buff, ' ');
        if (p == 0)
        {
            fprintf(stderr, "%s Bad WIZLIST file '%s'.\n"
                          , time_stamp(), wizlist_name);
            break;
        }
        *p = '\0';
        p++;
        if (*p == '\0')
        {
            fprintf(stderr, "%s Bad WIZLIST file '%s'.\n"
                          , time_stamp(), wizlist_name);
            break;
        }
        score = atoi(p);
        if (score > 0)
        {
            string_t * tmp;

            tmp = new_mstring(buff);
            add_name(tmp)->score += score;
            free_mstring(tmp);
        }
    }
    fclose(f);
} /* load_wiz_file() */
Beispiel #17
0
void
create_armour()
{
    set_name("forcefield");
    add_name("mag_shield_prot");
    set_adj("magic");
    set_long("A magical forcefield covering your whole body.\n");
    add_prop(OBJ_I_NO_DROP, 1);
    add_prop(OBJ_I_IS_MAGIC_ARMOUR, 1);
    add_prop(OBJ_S_WIZINFO, "A magical shield to protect the wearer. Will " +
        "out before to long\n");
    add_prop(MAGIC_AM_MAGIC, ({ 20, "abjured" }) );
Beispiel #18
0
forth_obj str_to_exp(char* str)
{
  int tmp = atoi(str);
  forth_obj ret;

  if((str[0] != '0') && (tmp == 0)){//string
    set_sym(&ret, add_name(str));
  }else{//num
    set_num(&ret, tmp);
  }
  return ret;
}
Beispiel #19
0
int main(int argc, char **argv) {
    FILE *ret;
    int j, i, isEqual=0;
    namelist ourList = make_namelist();


    char tempWord[64];
    char *saveWords[] = {"auto", "double", "int", "long", "break", "else", "long", "switch", "case", "enum", "register", 		"typedef" ,"char", "extern",
                         "return", "union", "const", "float", "short", "unsigned", "continue",
                         "for","signed", "void", "default", "goto", "sizeof" ,"volatile",
                         "do", "if" ,"static" ,"while"
                        };

    for (j=1; j < argc; ++j)
    {
        ret = fopen( argv[j], "r"); /*ret is a pointer to the file*/

        while( fgetname(tempWord, 64, ret)) {
            isEqual = 0;
            for(i=0; i<32; ++i) {


                if(strcmp(tempWord, saveWords[i])!=0) {
                    isEqual = isEqual+1;
                }
                if(isEqual==32) { /*tempWord not equal to any of the key words*/
                    add_name(ourList, tempWord);

                }
            }

        }

        fclose (ret);
    }

    qsort (ourList->names, ourList->size, sizeof(struct namestat), compare);

    for(i=0; i<ourList->size; ++i) {
        printf("%s ", ourList->names[i].name);
        printf("%d\n", ourList->names[i].count);
    }








    return 0;
}
Beispiel #20
0
/* add a library to the list of delayed imports */
void add_delayed_import( const char *name )
{
    struct import *imp;
    char *fullname = get_dll_name( name, NULL );

    add_name( &delayed_imports, fullname );
    if ((imp = is_already_imported( fullname )) && !imp->delay)
    {
        imp->delay = 1;
        nb_delayed++;
    }
    free( fullname );
}
Beispiel #21
0
void MON_LABELS::clear(u8 *start, unsigned size)
{
   unsigned dst = 0;
   for (unsigned src = 0; src < n_pairs; src++)
      if ((unsigned)(pairs[src].address - start) > size)
         pairs[dst++] = pairs[src];
   n_pairs = dst;
   // pack `names'
   char *pnames = names; names = 0; names_size = 0;
   for (unsigned l = 0; l < n_pairs; l++)
      pairs[l].name_offs = add_name(pnames + pairs[l].name_offs);
   free(pnames);
}
Beispiel #22
0
/*-------------------------------------------------------------------------*/
void
save_error (const char *msg, const char *file, int line)

/* A runtime error <msg> occured for object <file> in line number <line>.
 * Store this information in the wizlist so that the mudlib can handle
 * it later with the efun get_error_file().
 * TODO: A proper runtime error handling could put this into the mudlib
 * TODO:: completely.
 */

{
    wiz_list_t *wl;
    char *copy, *p;
    string_t *name;
    size_t len;

    /* Get the wizard name and the wizlist entry. */
    name = get_wiz_name(file);
    if (!name)
        return;
    wl = add_name(name);

    /* Set the file_name */
    if (wl->file_name)
        free_mstring(wl->file_name);

    len = strlen(file);
    copy = alloca(len + 4); /* May add .c plus the null byte, and / */
    *copy = '/';
    strcpy(copy+1, file);

    /* If it is a cloned object, we have to find out what the file
     * name is, and add '.c'.
     */
    if ( NULL != (p = strrchr(copy, '#'))
     || ((p = copy+len), *p++ != 'c') || p[-2] != '.' )
    {
        p[0] = '.';
        p[1] = 'c';
        p[2] = '\0';
    }
    wl->file_name = new_mstring(copy);

    /* Set the error_message */
    if (wl->error_message)
        free_mstring(wl->error_message);
    wl->error_message = new_mstring(msg);

    /* Set the line_number */
    wl->line_number = line;
} /* save_error() */
tlibc_error_code_t tlibc_read_field_begin(tlibc_abstract_reader_t *self, const char *var_name)
{
	tlibc_error_code_t ret;
	ret = add_name(self, var_name);
	if(ret != E_TLIBC_NOERROR)
	{
		return ret;
	}
	if(self->read_field_begin == NULL)
	{
		return E_TLIBC_NOERROR;
	}
	return self->read_field_begin(self, var_name);
}
Beispiel #24
0
void
do_components(
    void (*func)(void))
{
/**
Function: Handles COMPONENTS OF in an item
Procedure:
1. IF no next token OR it's not 'OF' OR no next token OR item is not in table
        OR it's imported, syntax error
   IF no function
        Add token as a child of classname
        Return
   Save current file position
2. Go to where item starts
   Read tokens until '{' is found
3. Call function
   Go back to saved place in file
   Keep reading until ',' or '}'
**/
    struct name_table *ntbp;
    long pos;
    if (tell_pos(streams.str) < real_start)
        return;
    if (!get_token(0, token) || /* step 1 */
        strcmp(token, of_w) || !get_token(0, token))
        syntax(components_w);
    if (!func)
    {
        add_child(token, add_name(classname, (long)0, 0), 0, (long)-1, 0);
        *itemname = 'x';        /* to make the test for no itemname fail */
        return;
    }
    if (!(ntbp = find_name(token))->name || !*ntbp->name || ntbp->pos < 0)
        syntax(components_w);
    pos = tell_pos(streams.str);
    curr_pos = ntbp->pos;
    fseek(streams.str, ntbp->pos, 0);   /* step 2 */
    for (*token = 0; get_token(0, token) && *token != '{';);
    if (*token != '{')
        syntax(components_w);
    state = SUB_ITEM;
    if (func)
        (*func)();                /* step 3 */
    curr_pos = pos;
    fseek(streams.str, pos, 0);
    state = IN_ITEM;
    for (*token = 0; *token != ',' && *token != '}'; get_token(0, token));
    end_item();
}
Beispiel #25
0
/*
 * End a transaction
 */
void
dlz_closeversion(const char *zone, isc_boolean_t commit,
		 void *dbdata, void **versionp)
{
	struct dlz_example_data *state = (struct dlz_example_data *)dbdata;

	if (!state->transaction_started) {
		state->log(ISC_LOG_INFO,
			   "dlz_example: transaction not started for zone %s",
			   zone);
		*versionp = NULL;
		return;
	}

	state->transaction_started = ISC_FALSE;

	*versionp = NULL;

	if (commit) {
		int i;
		state->log(ISC_LOG_INFO,
			   "dlz_example: committing transaction on zone %s",
			   zone);
		for (i = 0; i < MAX_RECORDS; i++) {
			if (strlen(state->adds[i].name) > 0U) {
				add_name(state, &state->current[0],
					 state->adds[i].name,
					 state->adds[i].type,
					 state->adds[i].ttl,
					 state->adds[i].data);
			}
		}
		for (i = 0; i < MAX_RECORDS; i++) {
			if (strlen(state->deletes[i].name) > 0U) {
				del_name(state, &state->current[0],
					 state->deletes[i].name,
					 state->deletes[i].type,
					 state->deletes[i].ttl,
					 state->deletes[i].data);
			}
		}
	} else {
		state->log(ISC_LOG_INFO,
			   "dlz_example: cancelling transaction on zone %s",
			   zone);
	}
	memset(state->adds, 0, sizeof(state->adds));
	memset(state->deletes, 0, sizeof(state->deletes));
}
Beispiel #26
0
int main(int argc, char **argv) {
	namelist nl = make_namelist();
	int checks = 0;
	int i;

	add_name(nl, "foo");
	add_name(nl, "bar");
	add_name(nl, "foo");

	for(i = 0; i!=nl->size; ++i) {
		if(!strcmp("foo", nl->names[i].name)) {
			assert(nl->names[i].count==2);
			checks|=1;
		} else if(!strcmp("bar", nl->names[i].name)) {
			assert(nl->names[i].count==1);
			checks|=2;
		} else {
			checks|=4;
		}
	}
	assert(checks==3);

	return 0;
}
Beispiel #27
0
static void load_directory_fonts(const SkString& directory, unsigned int* count) {
    SkOSFile::Iter  iter(directory.c_str(), ".ttf");
    SkString        name;

    while (iter.next(&name, false)) {
        SkString filename(directory);
        filename.append(name);

        bool isFixedWidth;
        SkString realname;
        SkTypeface::Style style = SkTypeface::kNormal; // avoid uninitialized warning

        if (!get_name_and_style(filename.c_str(), &realname, &style, &isFixedWidth)) {
            SkDebugf("------ can't load <%s> as a font\n", filename.c_str());
            continue;
        }

        FamilyRec* family = find_familyrec(realname.c_str());
        if (family && family->fFaces[style]) {
            continue;
        }

        // this constructor puts us into the global gFamilyHead llist
        FamilyTypeface* tf = SkNEW_ARGS(FileTypeface,
                                        (style,
                                         true,  // system-font (cannot delete)
                                         family, // what family to join
                                         filename.c_str(),
                                         isFixedWidth) // filename
                                        );

        if (NULL == family) {
            add_name(realname.c_str(), tf->getFamily());
        }
        *count += 1;
    }

    SkOSFile::Iter  dirIter(directory.c_str());
    while (dirIter.next(&name, true)) {
        if (name.startsWith(".")) {
            continue;
        }
        SkString dirname(directory);
        dirname.append(name);
        dirname.append(SK_FONT_FILE_DIR_SEPERATOR);
        load_directory_fonts(dirname, count);
    }
}
                		/* the rest of the pattern segments */
#endif /* ANSI_PROTOTYPES */
{
    char *saved_end = path_end;	/* saved to be resored */
    char *pat;			/* current pattern segment */
    struct stat st;		/* to check if file exists */

#ifdef GLOBDEBUG
    ffprintf(STDDBG,"do_glob: path = '%s', pat = '%s'\n", main_path, *gpat );
#endif

    for ( ; (pat = *gpat) != 0 && no_glob(pat); gpat++ )
    {
#ifdef GLOBDEBUG
	ffprintf(STDDBG,"no_glob: path = '%s', pat = '%s'\n", main_path, pat );
#endif
	*path_end = '/';
	(void)strcpy(path_end+1, pat);
	path_end += strlen(pat) + 1;

	if (GLOBSTAT(main_path, &st) != 0 )
	{
	    *saved_end = '\0';
	    return;
	}
    }
    if (pat)
	matchdir(path_end, gpat);
    else
	add_name();

    *saved_end = '\0';
    return;
}

static void
#ifndef ANSI_PROTOTYPES
matchdir(path_end, gpat)
    char *path_end;		/* ptr to end of main_path */
    char **gpat;		/* the rest of the pattern segments */
#else /* ANSI_PROTOTYPES */
matchdir(char *path_end, char **gpat)
                   		/* ptr to end of main_path */
                		/* the rest of the pattern segments */
#endif /* ANSI_PROTOTYPES */
{
    char *x;			/* scratch */
    VOIDDIR *dirp;		/* for directory reading */
    VOIDDIRENT *dp;		/* directory entry */
    struct stat st;		/* to determine files type */

#ifdef GLOBDEBUG
    ffprintf(STDDBG,"matchdir: path = '%s', pat = '%s'\n", main_path, *gpat );
#endif
    if ((dirp = OPENDIR(main_path)) == NULL)
	return;

    *path_end = '/';

    while ((dp = READDIR(dirp)) != NULL)
    {
	char *dirname;
	x = dirname = GETNAME(dp);	/* was dp->d_name */
	if (*x == '.' && (*++x == '\0' || (*x == '.' && *++x == '\0')))
	    continue;
	if (*dirname == '.' && **gpat != '.')
	    continue;

	(void)strcpy(path_end + 1, dirname);

	if (glob_match(*gpat, dirname))
	{   /* this is a match */
	    if ( *(gpat+1) == 0 )
	    {	/* and it is the last */
		add_name();	/* so eat it */
		continue;
	    }
	    if (GLOBSTAT(main_path, &st) == 0 /* else not the last */
		&& (st.st_mode & S_IFMT) == S_IFDIR)
		do_glob(path_end + strlen(dirname) + 1, gpat + 1);
	} 
    }

    (void)CLOSEDIR(dirp);

    *path_end = '\0';
}
Beispiel #29
0
// Step 1
static void find_names_types_use(painter_t* painter, reachable_types_t* types)
{
  assert(painter != NULL);
  assert(types != NULL);

  size_t i = HASHMAP_BEGIN;
  size_t typemap_index = 0;
  uint64_t typemap_mask = 1;
  reachable_type_t* type;

  while((type = reachable_types_next(types, &i)) != NULL)
  {
    assert(typemap_index < painter->typemap_size);
    size_t j = HASHMAP_BEGIN;
    reachable_method_name_t* mn;

    while((mn = reachable_method_names_next(&type->methods, &j)) != NULL)
    {
      size_t k = HASHMAP_BEGIN;
      reachable_method_t* method;

      while((method = reachable_methods_next(&mn->r_methods, &k)) != NULL)
      {
        const char* name = method->name;

        name_record_t* name_rec = find_name(painter, name);

        if(name_rec == NULL)  // This is the first use of this name
          name_rec = add_name(painter, name);

        // Mark this name as using the current type
        name_rec->type_map[typemap_index] |= typemap_mask;
      }
    }

    // Advance to next type bitmap entry
    typemap_mask <<= 1;

    if(typemap_mask == 0)
    {
      typemap_mask = 1;
      typemap_index++;
    }
  }
}
Beispiel #30
0
static isc_result_t
modrdataset(struct dlz_example_data *state, const char *name,
	    const char *rdatastr, struct record *list)
{
	char *full_name, *dclass, *type, *data, *ttlstr;
	char *buf = strdup(rdatastr);
	isc_result_t result;
#if defined(WIN32) || defined(_REENTRANT)
	char *saveptr = NULL;
#endif

	/*
	 * The format is:
	 * FULLNAME\tTTL\tDCLASS\tTYPE\tDATA
	 *
	 * The DATA field is space separated, and is in the data format
	 * for the type used by dig
	 */

	full_name = STRTOK_R(buf, "\t", &saveptr);
	if (full_name == NULL)
		return (ISC_R_FAILURE);

	ttlstr = STRTOK_R(NULL, "\t", &saveptr);
	if (ttlstr == NULL)
		return (ISC_R_FAILURE);

	dclass = STRTOK_R(NULL, "\t", &saveptr);
	if (dclass == NULL)
		return (ISC_R_FAILURE);

	type = STRTOK_R(NULL, "\t", &saveptr);
	if (type == NULL)
		return (ISC_R_FAILURE);

	data = STRTOK_R(NULL, "\t", &saveptr);
	if (data == NULL)
		return (ISC_R_FAILURE);

	result = add_name(state, list, name, type,
			  strtoul(ttlstr, NULL, 10), data);
	free(buf);
	return (result);
}