// Return index of next level starting with specified string; if none exists, returns current index.
// If startingWith is only one character, the entry we're looking for could be behind us.  See tests
// for examples of this.
S32 ItemListSelectUserInterface::getIndexOfNext(const string &startingWithLc) const
{
   TNLAssert(startingWithLc.length() > 0, "Did not expect an empty string here!");
   TNLAssert(startingWithLc == lcase(startingWithLc), "Expected a lowercased string here");

   bool first = true;
   bool multiChar = startingWithLc.length() > 1;
   S32 offset = multiChar ? 0 : 1;

   // Loop until we hit the end of the list, or we hit an item that sorts > our startingString (meaning we overshot).
   // But we only care about overshoots in multiChar mode because there could well be single-char hits behind us in the list.
   while(true)
   {
      if(mSelectedIndex + offset >= getMenuItemCount())    // Hit end of list -- loop to beginning
         offset = -mSelectedIndex;

      string prospectiveItem = lcase(getMenuItem(mSelectedIndex + offset)->getValue());

      if(prospectiveItem.substr(0, startingWithLc.size()) == startingWithLc)
         return mSelectedIndex + offset;

      if(offset == 0 && !first)
         break;

      offset++;
      first = false;
   }

   // Found no match; return current index
   return mSelectedIndex;
}
bool ItemListSelectUserInterface::processMenuSpecificKeys(InputCode inputCode)
{
   string inputString = InputCodeManager::inputCodeToPrintableChar(inputCode);

   if(inputString == "")
      return false;
   
   mNameSoFar.append(inputString);

   string mNameSoFarLc = lcase(mNameSoFar);

   if(stringContainsAllTheSameCharacter(mNameSoFarLc))
   {
      mSelectedIndex = getIndexOfNext(mNameSoFarLc.substr(0, 1));

      if(mNameSoFar.size() > 1 && lcase(getMenuItem(mSelectedIndex)->getValue()).substr(0, mNameSoFar.length()) != mNameSoFarLc)
         mNameSoFar = mNameSoFar.substr(0, mNameSoFar.length() - 1);    // Remove final char, the one we just added above
   }
   else
      mSelectedIndex = getIndexOfNext(mNameSoFarLc);


   mStillTypingNameTimer.reset();
   mItemSelectedWithMouse = false;

   // Move the mouse to the new selection to make things "feel better"
   MenuItemSize size = getMenuItem(mFirstVisibleItem)->getSize();
   S32 y = getYStart();

   for(S32 j = mFirstVisibleItem; j < mSelectedIndex; j++)
   {
      size = getMenuItem(j)->getSize();
      y += getTextSize(size) + getGap(size);
   }

   y += getTextSize(size) / 2;

   // WarpMouse fires a mouse event, which will cause the cursor to become visible, which we don't want.  Therefore,
   // we must resort to the kind of gimicky/hacky method of setting a flag, telling us that we should ignore the
   // next mouse event that comes our way.  It might be better to handle this at the Event level, by creating a custom
   // method called WarpMouse that adds the suppression.  At this point, however, the only place we care about this
   // is here so...  well... this works.
   SDL_WarpMouseInWindow(DisplayManager::getScreenInfo()->sdlWindow, (S32)DisplayManager::getScreenInfo()->getMousePos()->x, y);

   Cursor::disableCursor();
   mIgnoreNextMouseEvent = true;
   playBoop();

   return true;
}
예제 #3
0
파일: test.c 프로젝트: pmhahn/cyrus-imapd
/* gets the header "head" from msg. */
static int getheader(void *v, const char *phead, const char ***body)
{
    message_data_t *m = (message_data_t *) v;
    strarray_t *contents;
    char *head;

    *body = NULL;

    if (!m->cache_full) {
	fill_cache(m);
    }

    /* copy header parameter so we can mangle it */
    head = xstrdup(phead);
    lcase(head);

    /* check the cache */
    contents = (strarray_t *)hash_lookup(head, &m->cache);
    if (contents)
	*body = (const char **) contents->data;

    free(head);

    if (*body) {
  	return SIEVE_OK;
    } else {
	return SIEVE_FAIL;
    }
}
예제 #4
0
char *Viterbi::viterbi( Inicio &ini, char * word) {
    int k;
    double pa[27];
    //char maxword[256];
    int mex;

    for ( k = 0; k < 27; k++ ) pa[k] = ini.transition[26][k];

    for ( k = 0; word[k] != '\0'; k++ ){
        char c = lcase(word[k]);
        for ( int i = 0; i < 27; i++ ){
            double max = 0;
            for ( int j = 0; j < 27; j++){
                ps[i][j] = pa[posMtr(c)]*ini.transition[posMtr(c)][i]*probTecla[i][posMtr(c)];
                max = (max < ps[i][j])? ps[i][j]:max;            
            }
            pa[i] = max;
        }

        double sum = 0.;
        mex = 0;
        for ( int n = 0; n < 27; n++ ) sum += pa[n];     //faz a soma para a normalização
        for ( int j = 0; j < 27; j++ ) {
            pa[j]/=sum;                                 //aqui está certo agora. Não precisa somar com EPS.
            mex = (pa[mex] < pa[j])? j : mex;          //seleciona o caracter que tem o máximo. Aqui que tem que mudar. Não pegar o máximo mais.
        }
        maxword[k] = Inicio::mapMtr(mex);               //Converte o máximo para um caracter e concatena na palavra
    }
    maxword[k] = '\0';

    //printf("%s >> Viterbi\n", maxword);

    return maxword;
}
예제 #5
0
파일: ip4_unix.c 프로젝트: vadz/panda-imap
void *ip_nametoaddr (char *name,size_t *len,int *family,char **canonical,
                     void **next,void **cleanup)
{
    char **adl,tmp[MAILTMPLEN];
    struct hostent *he;
    /* cleanup data never permitted */
    if (cleanup && *cleanup) abort ();
    if (name) {			/* first lookup? */
        /* yes, do case-independent lookup */
        if ((strlen (name) < MAILTMPLEN) &&
                (he = gethostbyname (lcase (strcpy (tmp,name))))) {
            adl = he->h_addr_list;
            if (len) *len = he->h_length;
            if (family) *family = he->h_addrtype;
            if (canonical) *canonical = cpystr ((char *) he->h_name);
            if (next) *next = (void *) adl;
        }
        else {			/* error */
            adl = NIL;
            if (len) *len = 0;
            if (family) *family = 0;
            if (canonical) *canonical = NIL;
            if (next) *next = NIL;
        }
    }
    /* return next in series */
    else if (next && (adl = (char **) *next)) *next = ++adl;
    else adl = NIL;		/* failure */
    return adl ? (void *) *adl : NIL;
}
예제 #6
0
/*----------------------------------------------------------------------
       Return canonical form of host name ala c-client (UNIX version).

   Args: host      -- The host name

 Result: Canonical form, or input argument (worst case)

 You can call it twice without worrying about copying
 the results, but not more than twice.
 ----*/
char *
canonical_name(char *host)
{
    struct hostent *hent;
    char tmp[MAILTMPLEN];
    static int  whichbuf = 0;
    static char buf[2][NETMAXHOST+1];
    char       *b;

    whichbuf = (whichbuf + 1) % 2;
    b = buf[whichbuf];

                                /* domain literal is easy */
    if (host[0] == '[' && host[(strlen (host))-1] == ']')
      strncpy(b, host, NETMAXHOST);
    else{
	strncpy(tmp, host, sizeof(tmp)-1);
	tmp[sizeof(tmp)-1] = '\0';

	hent = gethostbyname((char *) lcase((unsigned char *) tmp));
	if(hent && hent->h_name)
	  strncpy(b, hent->h_name, NETMAXHOST);
	else
	  strncpy(b, host, NETMAXHOST);
    }

    b[NETMAXHOST] = '\0';
    return(b);
}
예제 #7
0
void Config_Backing_Store::loadActivators ()
{
  ACE_Configuration_Section_Key root;
  int err =
    config_.open_section (config_.root_section (), ACTIVATORS_ROOT_KEY, 0, root);
  if (err == 0)
    {
      int index = 0;
      ACE_TString name;
      while (config_.enumerate_sections (root, index, name) == 0)
        {
          ACE_CString ior;
          u_int token;

          ACE_Configuration_Section_Key key;

          // Can't fail, because we're enumerating
          config_.open_section (root, name.c_str(), 0, key);

          config_.get_string_value (key, IOR, ior);
          config_.get_integer_value (key, TOKEN, token);

          Activator_Info* ai;
          ACE_NEW (ai, Activator_Info (name, token, ior));

          Activator_Info_Ptr info (ai);
          activators ().bind (lcase (name), info);
          ++index;
        }
    }
}
예제 #8
0
int
Locator_Repository::remove_activator (const ACE_CString& name)
{
  int err = sync_load ();
  if (err != 0)
    {
      return err;
    }

  int ret = activators().unbind (lcase(name));
  if (ret != 0)
    {
      return ret;
    }

  Locator_Repository::SIMap::ENTRY* sientry = 0;
  Locator_Repository::SIMap::ITERATOR siit (servers ());
  for (; siit.next (sientry); siit.advance() )
  {
    Server_Info *info = sientry->int_id_->active_info ();

    if (info->death_notify && info->activator == name)
      {
        info->death_notify = false;
      }
  }

  return persistent_remove(name, true);
}
void cElementManager::handleClosingTag (const string &name)
{
  string n = lcase (name);
  if (!elementDefined (n))
  {
    results->addToList (results->createError ("Received unknown closing tag </" + n + ">!"));
    return;
  }
  if (emptyElement (n))
  {
    results->addToList (results->createError ("Received closing tag for tag " + n +
        ", which doesn't need a closing tag!"));
    return;
  }
  if (internalElement (n))
  {
    //if the name is an alias for another tag, change the name
    if (aliases.count (n))
      n = aliases[n];
    state->gotClosingTag (n);
  }
  else
  {
    //send closing flag, if needed
    if (!elements[n]->flag.empty())
      state->gotFlag (false, elements[n]->flag);
    
    //expand the closing tag...
    list<string>::iterator cit;
    for (cit = elements[n]->closingseq.begin(); cit != elements[n]->closingseq.end(); ++cit)
      handleClosingTag (*cit);
  }
}
예제 #10
0
litehtml::media_query_list::ptr litehtml::media_query_list::create_from_string(const tstring& str, const std::shared_ptr<document>& doc)
{
	media_query_list::ptr list = std::make_shared<media_query_list>();

	string_vector tokens;
	split_string(str, tokens, _t(","));

	for(string_vector::iterator tok = tokens.begin(); tok != tokens.end(); tok++)
	{
		trim(*tok);
		lcase(*tok);

		litehtml::media_query::ptr query = media_query::create_from_string(*tok, doc);
		if(query)
		{
			list->m_queries.push_back(query);
		}
	}
	if(list->m_queries.empty())
	{
		list = 0;
	}

	return list;
}
예제 #11
0
EXPORTED const char *config_getoverflowstring(const char *key, const char *def)
{
    char buf[256];
    char *ret = NULL;

    if (!config_filename) return 0;

    /* First lookup <ident>_key, to see if we have a service-specific
     * override */

    if (config_ident) {
        if (snprintf(buf,sizeof(buf),"%s_%s",config_ident,key) == -1)
            fatal("key too long in config_getoverflowstring", EC_TEMPFAIL);

        lcase(buf);
        ret = hash_lookup(buf, &confighash);
    }

    /* No service-specific override, check the actual key */
    if (!ret)
        ret = hash_lookup(key, &confighash);

    /* Return what we got or the default */
    return ret ? ret : def;
}
예제 #12
0
void LoadAtmosphere() {
	if (!(gfstate & GFS_UIATMOSPHERE))
		return;
	atmosactive = true;
	char buf[512];
	int i = 0, tmp;
	LPCHANNEL lpChannel;
	FILE *file = fopen("channels.atm", "r");
	if (file) {
		while (!feof(file)) {
			fgets(buf, sizeof(buf), file);
			tmp = strlen(buf) - 1;
			if (buf[tmp] == 0x0A) 
				buf[tmp] = 0; 
			if (buf[0] && buf[0] != '#') {
				if (!i) {
					lpChannel = (LPCHANNEL)malloc(sizeof(CHANNEL));
					strncpy(lpChannel->channelname, buf, 64);
					lcase(lpChannel->channelname);
				} else {
					strncpy((char *)lpChannel + 64 + ((i - 1) * 128), buf, 128);
				}
				i++;
				if (i == 4) {
					i = 0;
					InsertValue(lpChannel->channelname, lpChannel, channels, TABLESIZE_CHANNELS);
				}
			}
		}
		fclose(file);
	}
}
예제 #13
0
파일: fstype.c 프로젝트: halgandd/bacula
bool fstype(const char *fname, char *fs, int fslen)
{
   DWORD componentlength;
   DWORD fsflags;
   CHAR rootpath[4];
   UINT oldmode;
   BOOL result;

   /* Copy Drive Letter, colon, and backslash to rootpath */
   bstrncpy(rootpath, fname, sizeof(rootpath));

   /* We don't want any popups if there isn't any media in the drive */
   oldmode = SetErrorMode(SEM_FAILCRITICALERRORS);

   result = GetVolumeInformation(rootpath, NULL, 0, NULL, &componentlength, &fsflags, fs, fslen);

   SetErrorMode(oldmode);

   if (result) {
      /* Windows returns NTFS, FAT, etc.  Make it lowercase to be consistent with other OSes */
      lcase(fs);
   } else {
      Dmsg2(10, "GetVolumeInformation() failed for \"%s\", Error = %d.\n", rootpath, GetLastError());
   }

   return result != 0;
}
예제 #14
0
/*
 * Add iCalendar recur-rule-parts to a structured element.
 */
void icalrecurrencetype_add_as_xxx(struct icalrecurrencetype *recur, void *obj,
                                   void (*add_int)(void *, const char *, int),
                                   void (*add_str)(void *, const char *,
                                           const char *))
{
    char *rrule, *rpart;
    tok_t rparts;

    /* generate an iCal RRULE string */
    rrule = icalrecurrencetype_as_string_r(recur);

    /* split string into rparts & values */
    tok_initm(&rparts, rrule, "=;", TOK_TRIMLEFT|TOK_TRIMRIGHT);
    while ((rpart = tok_next(&rparts))) {
        if (!strcmp(rpart, "UNTIL")) {
            /* need to translate date format to ISO */
            struct icaltimetype until = icaltime_from_string(tok_next(&rparts));

            add_str(obj, "until", icaltime_as_iso_string(until));
        }
        else {
            /* assume the rpart has multiple values - split them */
            tok_t vlist;
            char *val, *p;

            tok_init(&vlist, tok_next(&rparts), ",",
                     TOK_TRIMLEFT|TOK_TRIMRIGHT);
            while ((val = tok_next(&vlist))) {
                if (add_int) {
                    /* try converting value to integer */
                    int n = strtol(val, &p, 10);

                    if (n && !*p) {
                        add_int(obj, lcase(rpart), n);
                        continue;
                    }
                }

                add_str(obj, lcase(rpart), val);
            }
            tok_fini(&vlist);
        }
    }
    tok_fini(&rparts);

    free(rrule);
}
예제 #15
0
Activator_Info_Ptr
Locator_Repository::get_activator (const ACE_CString& name)
{
  sync_load ();

  Activator_Info_Ptr activator (0);
  activators ().find (lcase (name), activator);
  return activator;
}
예제 #16
0
void litehtml::el_before_after_base::add_function( const tstring& fnc, const tstring& params )
{
	int idx = value_index(fnc.c_str(), _t("attr;counter;url"));
	switch(idx)
	{
	// attr
	case 0:
		{
			tstring p_name = params;
			trim(p_name);
			lcase(p_name);
			element::ptr el_parent = parent();
			if (el_parent)
			{
				const tchar_t* attr_value = el_parent->get_attr(p_name.c_str());
				if (attr_value)
				{
					add_text(attr_value);
				}
			}
		}
		break;
	// counter
	case 1:
		break;
	// url
	case 2:
		{
			tstring p_url = params;
			trim(p_url);
			if(!p_url.empty())
			{
				if(p_url.at(0) == _t('\'') || p_url.at(0) == _t('\"'))
				{
					p_url.erase(0, 1);
				}
			}
			if(!p_url.empty())
			{
				if(p_url.at(p_url.length() - 1) == _t('\'') || p_url.at(p_url.length() - 1) == _t('\"'))
				{
					p_url.erase(p_url.length() - 1, 1);
				}
			}
			if(!p_url.empty())
			{
				element::ptr el = std::make_shared<el_image>(get_document());
				el->set_attr(_t("src"), p_url.c_str());
				el->set_attr(_t("style"), _t("display:inline-block"));
				el->set_tagName(_t("img"));
				appendChild(el);
				el->parse_attributes();
			}
		}
		break;
	}
}
예제 #17
0
파일: jcal.c 프로젝트: JensErat/cyrus-imapd
/*
 * Construct a JSON array for an iCalendar component.
 */
static json_t *icalcomponent_as_json_array(icalcomponent *comp)
{
    icalcomponent *c;
    icalproperty *p;
    icalcomponent_kind kind;
    const char* kind_string;
    json_t *jcomp, *jprops, *jsubs;

    if (!comp) return NULL;

    kind = icalcomponent_isa(comp);
    switch (kind) {
    case ICAL_NO_COMPONENT:
        return NULL;
        break;

    case ICAL_X_COMPONENT:
        kind_string = ""; //comp->x_name;
        break;

    default:
        kind_string = icalcomponent_kind_to_string(kind);
    }


    /* Create component array */
    jcomp = json_array();


    /* Add component name */
    json_array_append_new(jcomp,
        json_string(lcase(icalmemory_tmp_copy(kind_string))));


    /* Add properties */
    jprops = json_array();
    for (p = icalcomponent_get_first_property(comp, ICAL_ANY_PROPERTY);
         p;
         p = icalcomponent_get_next_property(comp, ICAL_ANY_PROPERTY)) {

        json_array_append_new(jprops, icalproperty_as_json_array(p));
    }
    json_array_append_new(jcomp, jprops);


    /* Add sub-components */
    jsubs = json_array();
    for (c = icalcomponent_get_first_component(comp, ICAL_ANY_COMPONENT);
         c;
         c = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT)) {

        json_array_append_new(jsubs, icalcomponent_as_json_array(c));
    }
    json_array_append_new(jcomp, jsubs);

    return jcomp;
}
예제 #18
0
/*
 * Construct a XML element for an iCalendar component.
 */
static xmlNodePtr icalcomponent_as_xml_element(icalcomponent *comp)
{
    icalcomponent *c;
    icalproperty *p;
    icalcomponent_kind kind;
    const char* kind_string;
    xmlNodePtr xcomp, xprops = NULL, xsubs = NULL;

    if (!comp) return NULL;

    kind = icalcomponent_isa(comp);
    switch (kind) {
    case ICAL_NO_COMPONENT:
        return NULL;
        break;

    case ICAL_X_COMPONENT:
        kind_string = ""; //comp->x_name;
        break;

    default:
        kind_string = icalcomponent_kind_to_string(kind);
    }


    /* Create component */
    xcomp = xmlNewNode(NULL,
                       BAD_CAST lcase(icalmemory_tmp_copy(kind_string)));


    /* Add properties */
    for (p = icalcomponent_get_first_property(comp, ICAL_ANY_PROPERTY);
            p;
            p = icalcomponent_get_next_property(comp, ICAL_ANY_PROPERTY)) {

        if (!xprops)
            xprops = xmlNewChild(xcomp, NULL, BAD_CAST "properties", NULL);

        xmlAddChild(xprops, icalproperty_as_xml_element(p));
    }


    /* Add sub-components */
    for (c = icalcomponent_get_first_component(comp, ICAL_ANY_COMPONENT);
            c;
            c = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT)) {

        if (!xsubs)
            xsubs = xmlNewChild(xcomp, NULL, BAD_CAST "components", NULL);

        xmlAddChild(xsubs, icalcomponent_as_xml_element(c));
    }

    return xcomp;
}
예제 #19
0
char *tcp_canonical (char *name)
{
  char host[MAILTMPLEN];
  struct hostent *he;
				/* look like domain literal? */
  if (name[0] == '[' && name[strlen (name) - 1] == ']')
    return cpystr (name);
				/* note that Unix requires lowercase! */
  else return cpystr ((he = gethostbyname (lcase (strcpy (host,name)))) ?
		      he->h_name : name);
}
예제 #20
0
파일: os_os2.c 프로젝트: Distrotech/imap
long lookuphost (char **host,struct sockaddr_in *sin)
{
  long ret = -1;
  char tmp[MAILTMPLEN];
  struct hostent *hn = gethostbyname (lcase (strcpy (tmp,*host)));
  if (!hn) return NIL;		/* got a host name? */
  *host = cpystr (hn->h_name);	/* set official name */
				/* copy host addresses */
  memcpy (&sin->sin_addr,hn->h_addr,hn->h_length);
  return T;
}
예제 #21
0
char question(const char *question_str,char pos, char neg)
{
	char answer=0;
	flushall();
	flushall();
	printf(question_str);
	
	answer = getchar();

	return (lcase(answer));
}
예제 #22
0
char *address_get_domain(const struct address *a, int canon_domain)
{
    char *s = NULL;

    if (a->domain) {
	s = xstrdup(a->domain);
	if (canon_domain)
	    lcase(s);
    }

    return s;
}
예제 #23
0
int
ngram_model_casefold(ngram_model_t * model, int kase)
{
    int writable, i;
    hash_table_t *new_wid;

    /* Were word strings already allocated? */
    writable = model->writable;
    /* Either way, we are going to allocate some word strings. */
    model->writable = TRUE;

    /* And, don't forget, we need to rebuild the word to unigram ID
     * mapping. */
    new_wid = hash_table_new(model->n_words, FALSE);
    for (i = 0; i < model->n_words; ++i) {
        char *outstr;
        if (writable) {
            outstr = model->word_str[i];
        }
        else {
            outstr = ckd_salloc(model->word_str[i]);
        }
        /* Don't case-fold <tags> or [classes] */
        if (outstr[0] == '<' || outstr[0] == '[') {
        }
        else {
            switch (kase) {
            case NGRAM_UPPER:
                ucase(outstr);
                break;
            case NGRAM_LOWER:
                lcase(outstr);
                break;
            default:
                ;
            }
        }
        model->word_str[i] = outstr;

        /* Now update the hash table.  We might have terrible
         * collisions here, so warn about them. */
        if (hash_table_enter_int32(new_wid, model->word_str[i], i) != i) {
            E_WARN("Duplicate word in dictionary after conversion: %s\n",
                   model->word_str[i]);
        }
    }
    /* Swap out the hash table. */
    hash_table_free(model->wid);
    model->wid = new_wid;
    return 0;
}
예제 #24
0
/** Method: avtGGCMFileFormat::GetVar
 * Gets a scalar variable associated with this file.  Although VTK has
 * support for many different types, the best bet is vtkFloatArray, since
 * that is supported everywhere through VisIt.
 * @param timestate The index of the timestate.  If GetNTimesteps returned
 *                  'N' time steps, this is guaranteed to be between 0 and N-1.
 * @param varname   The name of the variable requested.
 * Programmer: tfogal -- generated by xml2avt
 * Mark C. Miller, Wed Aug 22, 2012: Fix leak of gse_scalar */
vtkDataArray *
avtGGCMFileFormat::GetVar(int timestate, const char *varname)
{
    /* C `libggcm' implementation */
    char *field[2];
    field[0] = lcase(strdup(varname));
    field[1] = NULL;

    debug1 << "avtGGCMFileFormat::GetVar(" << timestate << ", " << field[0]
           << ")" << std::endl;

    MHDdata *data;
    data = ggcm_read_mhd(this->GetFilename(), (const char **)field);

    debug1 << "\t... data read in" << std::endl;

    float ***scalar;
    scalar = ggcm_field_matrix(data, this->dim[0], this->dim[1], this->dim[2],
                               const_cast<char*>(field[0]));

    ggcm_free_data(data);

    float ***gse_scalar;
    gse_scalar = (float***) m_alloc(this->dim[0], this->dim[1], this->dim[2]);
    ggcm_mhd_gse(scalar, gse_scalar, this->dim[0], this->dim[1], this->dim[2],
                 const_cast<char*>(field[0]));
    m_free(scalar);

    free(field[0]);

    debug1 << "\t... converted to GSE coordinates" << std::endl;

    unsigned int i,j,k, idx=0;
    vtkFloatArray *var = vtkFloatArray::New();

    var->SetName(varname); /* will VisIt do this for me?  can't hurt... */
    var->SetNumberOfComponents(1);
    var->SetNumberOfValues(this->dim[0] * this->dim[1] * this->dim[2]);

    for(k=0; k < dim[2]; ++k) {
        for(j=0; j < dim[1]; ++j) {
            for(i=0; i < dim[0]; ++i) {
                var->InsertTuple(idx++, &gse_scalar[i][j][k]);
         }
      }
   }
    debug1 << "\t... " << idx << " values in VTK array" << std::endl;
   m_free(gse_scalar);

    return var;
}
예제 #25
0
파일: common.cpp 프로젝트: Nitaym/zodengine
void parse_filelist(vector<string> &filelist, string extension)
{
	lcase(extension);

	for(vector<string>::iterator i=filelist.begin(); i!=filelist.end();)
	{
		string cur_filename;
		int pos;
		int good_pos;

		cur_filename = *i;

		lcase(cur_filename);

		pos = cur_filename.rfind(extension);
		good_pos = cur_filename.size() - extension.size();

		if(pos == string::npos || pos != good_pos)
			i = filelist.erase(i);
		else
			++i;
	}
}
예제 #26
0
char *address_get_all(const struct address *a, int canon_domain)
{
    char *s = NULL;

    if (a->mailbox || a->domain) {
	const char *m = a->mailbox ? a->mailbox : unknown_user;
	const char *d = a->domain ? a->domain : unspecified_domain;
	s = strconcat(m, "@", d, (char *)NULL);
	if (canon_domain)
	    lcase(s + strlen(m) + 1);
    }

    return s;
}
예제 #27
0
파일: pronerr.c 프로젝트: 10v/cmusphinx
static void pronerr_output (char *id, s3wid_t *ref, int32 nref,
			    wseg_t *wseg, s3cipid_t *ap, int8 *ap_err,
			    int32 ws, int32 we, int32 ps, int32 pe)
{
    int32 j;
    s3wid_t rcwid, lcwid;
    char str[4096];
    
    /* Word sequence for region in error */
    sprintf (str, "%s", dict_wordstr (dict, dict_basewid(dict, ref[ws])));
    for (j = ws+1; j <= we; j++) {
	strcat (str, " ");
	strcat (str, dict_wordstr (dict, dict_basewid(dict, ref[j])));
    }
    printf ("%-22s\t=>\t", str);

    /* Print left context phone */
    /*lcwid = ((wseg[ws].s < 0) && (ws > 0) && IS_WID(ref[ws-1])) ? ref[ws-1] : BAD_WID;*/
    lcwid = (ws > 0) ? ref[ws-1] : BAD_WID;
    if (IS_WID(lcwid)) {
	j = dict->word[lcwid].pronlen - 1;
	sprintf (str, "(%s)", mdef_ciphone_str (mdef, dict->word[lcwid].ciphone[j]));
    } else
	strcpy (str, "()");
    printf ("%-5s", str);
    
    /* Phone sequence for region in error */
    for (j = ps; j <= pe; j++) {
	strcpy (str, mdef_ciphone_str (mdef, ap[j]));
	if (ap_err[j])
	    ucase (str);
	else
	    lcase (str);
	
	printf (" %s", str);
    }
    
    /* Right context if ending in error */
    /* rcwid = ((wseg[we].e < 0) && IS_WID(ref[we+1])) ? ref[we+1] : BAD_WID; */
    rcwid = ref[we+1];
    if (IS_WID(rcwid))
	printf ("\t(%s)", mdef_ciphone_str (mdef, dict->word[rcwid].ciphone[0]));
    else
	printf ("\t()");

    printf (" ( %s )\n", id);
}
예제 #28
0
void cElementManager::identifyFlags (const map<string, string> &attdefault,
    list<sParam> &args)
{
  list<sParam>::iterator it;
  for (it = args.begin(); it != args.end(); ++it)
    if ((*it).name.empty())
    {
      string s = lcase ((*it).value);
      if ((attdefault.count (s) != 0) && (attdefault.find(s)->second == ""))
      {
        //this one is a flag
        (*it).name = s;
        (*it).value = "";
        (*it).flag = true;
      }
    }
}
예제 #29
0
파일: os_os2.c 프로젝트: Distrotech/imap
char *mylocalhost (void)
{
  if (!myLocalHost) {		/* known yet? */
    char *s,tmp[MAILTMPLEN];
    struct hostent *he;
				/* could we get local id? */
    gethostname (tmp,MAILTMPLEN-1);
    if (he = gethostbyname (lcase (tmp))) {
      if (he->h_name) s = he->h_name;
      else sprintf (s = tmp,"[%i.%i.%i.%i]",he->h_addr[0],he->h_addr[1],
		    he->h_addr[2],he->h_addr[3]);
    }
    else s = "random-pc";
    myLocalHost = cpystr (s);	/* record for subsequent use */
  }
  return myLocalHost;
}
예제 #30
0
/*
 * Construct an XML element for an iCalendar property.
 */
static xmlNodePtr icalproperty_as_xml_element(icalproperty *prop)
{
    icalproperty_kind prop_kind;
    const char *x_name, *property_name = NULL;
    icalparameter *param;
    xmlNodePtr xprop, xparams = NULL;

    if (!prop) return NULL;

    prop_kind = icalproperty_isa(prop);
    x_name = icalproperty_get_x_name(prop);

    if (prop_kind == ICAL_X_PROPERTY && x_name)
        property_name = x_name;
    else
        property_name = icalproperty_kind_to_string(prop_kind);

    if (!property_name) {
        icalerror_warn("Got a property of an unknown kind.");
        return NULL;
    }

    /* Create property */
    xprop = xmlNewNode(NULL,
                       BAD_CAST lcase(icalmemory_tmp_copy(property_name)));


    /* Add parameters */
    for (param = icalproperty_get_first_parameter(prop, ICAL_ANY_PARAMETER);
            param != 0;
            param = icalproperty_get_next_parameter(prop, ICAL_ANY_PARAMETER)) {

        if (icalparameter_isa(param) == ICAL_VALUE_PARAMETER) continue;

        if (!xparams)
            xparams = xmlNewChild(xprop, NULL, BAD_CAST "parameters", NULL);

        xmlAddChild(xparams, icalparameter_as_xml_element(param));
    }


    /* Add value */
    icalproperty_add_value_as_xml_element(xprop, prop);

    return xprop;
}