Esempio n. 1
0
void GGPROTO::dccconnect(uin_t uin)
{
	struct gg_dcc *local_dcc;
	HANDLE hContact = getcontact(uin, 0, 0, NULL);
	DWORD ip, myuin; WORD port;

	debugLogA("dccconnect(): Connecting to uin %d.", uin);

	// If unknown user or not on list ignore
	if (!hContact) return;

	// Read user IP and port
	ip = swap32(getDword(hContact, GG_KEY_CLIENTIP, 0));
	port = getWord(hContact, GG_KEY_CLIENTPORT, 0);
	myuin = getDword(GG_KEY_UIN, 0);

	// If not port nor ip nor my uin (?) specified
	if (!ip || !port || !uin) return;

	if (!(local_dcc = gg_dcc_get_file(ip, port, myuin, uin)))
		return;

	// Add client dcc to watches
	gg_EnterCriticalSection(&ft_mutex, "dccconnect", 36, "ft_mutex", 1);
	list_add(&watches, local_dcc, 0);
	gg_LeaveCriticalSection(&ft_mutex, "dccconnect", 36, 1, "ft_mutex", 1);
}
static int16_t
compressLine(uint8_t *s, int16_t length, int16_t *pGroupTop) {
    int16_t start, limit, token, groupTop=*pGroupTop;

    start=0;
    do {
        /* write any "noise" characters */
        limit=skipNoise((char *)s, start, length);
        while(start<limit) {
            groupStore[groupTop++]=s[start++];
        }

        if(start==length) {
            break;
        }

        /* write a word, as token or directly */
        limit=getWord((char *)s, start, length);
        if(limit-start==1) {
            groupStore[groupTop++]=s[start++];
        } else {
            token=findToken(s+start, (int16_t)(limit-start));
            if(token!=-1) {
                if(token>0xff) {
                    groupStore[groupTop++]=(uint8_t)(token>>8);
                }
                groupStore[groupTop++]=(uint8_t)token;
                start=limit;
            } else {
                while(start<limit) {
                    groupStore[groupTop++]=s[start++];
                }
            }
Esempio n. 3
0
int main() {
	char* word = NULL;
	int size = 0;
	occurance_t* occ_class = NULL;
	while(strcmp(word = getWord(), "vsmisal")) {
		int tmp;
		if((tmp = compare_signature(occ_class, size, hash(word))) != 0)
			occ_class[tmp].times++;
		else {
			occurance_t temp;
			temp.hash = hash(word);
			temp.times = 1;
			occ_class = add_signature(occ_class, temp);
			size++;
		}
	}

	int tmp = 0;

	for(int i = 0; i < size; i++) {
		if(occ_class[i].times > tmp && occ_class[i].times != 1)
			tmp = i;
	}

	printf("%d %ld", occ_class[tmp].times, occ_class[tmp].hash);

	free(word);
	free(occ_class);

	return 0;
}
Esempio n. 4
0
Word ThRightNormalForm::getShortWord( ) const
{
  Word result;
  Permutation omega = Permutation::getHalfTwistPermutation( getRank( ) );
  int power = getPower( );

  if( power<0 ) {

    const list< Permutation >& decomp = getDecomposition( );
    list<Permutation>:: const_iterator it = decomp.begin( );
    for( int j=0 ; it!=decomp.end( ) ; ++it, ++j ) {
      int n = j - decomp.size( ) - power;
      if( n<0 ) {
	vector< int > gd = (*it).geodesic();
	for( size_t t=0 ; t<gd.size() ; ++t )
	  result.push_back( gd[t]+1 );
      } else {
	
	Permutation p = ( n%2 == 1 ? (*it).inverse() * omega : omega * (*it).inverse() );
	
	vector<int> gd = p.geodesic();
	for( int t=gd.size( )-1 ; t>=0 ; --t )
	  result.push_back( -gd[t]-1 );
      }
    }
    Word omega_w = Word(omega.geodesicWord( ));
    omega_w = -omega_w;
    for( int j=decomp.size( ) ; j<-power ; ++j )
      result = omega_w*result;
  } else
    result = getWord( );
  
  return result;
}
Esempio n. 5
0
static int getWLenBufPtr(const uint8_t **ppCur, uint32_t *pdwLeft, const uint8_t **ppBuf, uint16_t *pwBufLen, int iNetByteOrder)
{
	//assert((ppCur && *ppCur));
	//assert((ppBuf && pwBufLen));

	const uint8_t * pTmp = *ppCur;
	const uint32_t dwTmp = (pdwLeft ? *pdwLeft : 0);
	uint16_t wLen = 0;

	int iRet = getWord(ppCur, pdwLeft, &wLen, iNetByteOrder);
	if (0 == iRet) {
		if (!pdwLeft || (pdwLeft && wLen <= *pdwLeft)) {
			*ppBuf = *ppCur;
			*ppCur += wLen;
			*pwBufLen = wLen;
			if (pdwLeft) {
				*pdwLeft -= wLen;
			}
		} else {
			iRet = E_OVERFLOW;
		}
	}

	if (0 != iRet) {
		*ppCur = pTmp;
		if (pdwLeft) {
			*pdwLeft = dwTmp;
		}
	}

	return iRet;
}
Esempio n. 6
0
int main(int argc, char	**argv){
	char buf[WORD_LEN_MAX];
	FILE *file;
	if(argc == 1){
		file = stdin;
	}else{
		file =fopen(argv[1], "r");
		if(file == NULL){
			fprintf(stderr,"%s %s can not open",argv[0],argv[1]);
			exit(1);
		}
	}
	/* 单词管理模块初始化*/ 
	word_initialize();
	
	while(getWord(buf, WORD_LEN_MAX, file) != EOF){
		add_word(buf);
	}
	
	dump_word(stdout);
	
	word_finalize();
	
	return 0;
}
Esempio n. 7
0
void CVkProto::AddFeedSpecialUser()
{
	bool bSpecialContact = m_bNewsEnabled || m_bNotificationsEnabled || m_bSpecialContactAlwaysEnabled;
	
	MCONTACT hContact = FindUser(VK_FEED_USER);
	if (!bSpecialContact) {
		if (hContact)
			CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact);
		return;
	}
	
	if (!hContact) {
		hContact = FindUser(VK_FEED_USER, true);

		setTString(hContact, "Nick", TranslateT("VKontakte"));
		CMString tszUrl = _T("https://vk.com/press/Simple.png");
		SetAvatarUrl(hContact, tszUrl);
		ReloadAvatarInfo(hContact);

		setTString(hContact, "domain", _T("feed"));
		setTString(hContact, "Homepage", _T("https://vk.com/feed"));
	} 
	
	if (getWord(hContact, "Status") != ID_STATUS_ONLINE)
		setWord(hContact, "Status", ID_STATUS_ONLINE);
	SetMirVer(hContact, 7);

}
Esempio n. 8
0
char getWord(int i)
{
    int page = i/PAGESIZE;
    if(table[page].valid)
    {
        return RAM[table[page].adress+(i%PAGESIZE)];
    }
    else
    {
        if(p==PAGESIZE*RAMSIZE) p=0;
        fseek(fp,i,SEEK_SET);
            fread(buffer,1,PAGESIZE,fp);

            if(RAMtable[p/PAGESIZE]!=0)
                table[RAMtable[p/PAGESIZE]].valid=0;

            RAMtable[p/PAGESIZE]=page;

            table[page].valid=1;
            table[page].adress=p;

            int j=0;
            for(;j<PAGESIZE;j++)
                RAM[p+j]=buffer[j];

            //printf("%c%c%c%c\n",RAM[p],RAM[p+1],RAM[p+2],RAM[p+3]);
            p+=PAGESIZE;
            return getWord(i);
        }
    }
Esempio n. 9
0
MCONTACT CIrcProto::CList_AddContact(CONTACT *user, bool InList, bool SetOnline)
{
	if (user->name == NULL)
		return 0;

	MCONTACT hContact = CList_FindContact(user);
	if (hContact) {
		if (InList)
			db_unset(hContact, "CList", "NotOnList");
		setTString(hContact, "Nick", user->name);
		db_unset(hContact, "CList", "Hidden");
		if (SetOnline && getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
			setWord(hContact, "Status", ID_STATUS_ONLINE);
		return hContact;
	}

	// here we create a new one since no one is to be found
	hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
	if (hContact) {
		CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName);

		if (InList)
			db_unset(hContact, "CList", "NotOnList");
		else
			db_set_b(hContact, "CList", "NotOnList", 1);
		db_unset(hContact, "CList", "Hidden");
		setTString(hContact, "Nick", user->name);
		setTString(hContact, "Default", user->name);
		setWord(hContact, "Status", SetOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
		if (!InList && getByte("MirVerAutoRequestTemp", 0))
			PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), user->name);
		return hContact;
	}
	return false;
}
int main() {
    int getWord(FILE *, char[]);
    int binarySearch(int, int, char [], int max, char [][max]);
    void addToList(char[], int max, char [][max], int[], int, int);
    void printResults(FILE *, int max, char [][max], int[], int);
    char wordList[MaxWords][MaxWordBuffer], word[MaxWordBuffer];
    int frequency[MaxWords], numWords = 0;

    FILE * in = fopen("passage.txt", "r");
    if (in == NULL) {
        printf("Cannot find file\n");
        exit(1);
    }

    FILE * out = fopen("output.txt", "w");
    if (out == NULL) {
        printf("Cannot create output file\n");
        exit(2);
    }

    for (int h = 1; h <= MaxWords ; h++) frequency[h] = 0;

    while (getWord(in, word) != 0) {
        int loc = binarySearch (0, numWords-1, word, MaxWordBuffer, wordList);
        if (strcmp(word, wordList[loc]) == 0) ++frequency[loc]; //word found
        else //this is a new word
            if (numWords < MaxWords) { //if table is not full
                addToList(word, MaxWordBuffer, wordList, frequency, loc, numWords-1);
                ++numWords;
            }
            else fprintf(out, "'%s' not added to table\n", word);
    }
    printResults(out, MaxWordBuffer, wordList, frequency, numWords);
} // end main
Esempio n. 11
0
int CMraProto::SetApparentMode(HANDLE hContact, int mode)
{
	if (!m_bLoggedIn || !hContact)
		return 1;

	// Only 3 modes are supported
	if (hContact && (mode == 0 || mode == ID_STATUS_ONLINE || mode == ID_STATUS_OFFLINE)) {
		DWORD dwOldMode = getWord(hContact, "ApparentMode", 0);

		// Dont send redundant updates
		if (mode != dwOldMode) {
			DWORD dwContactFlag = 0;

			switch (mode) {
			case ID_STATUS_OFFLINE:
				dwContactFlag |= CONTACT_FLAG_INVISIBLE;
				break;
			case ID_STATUS_ONLINE:
				dwContactFlag |= CONTACT_FLAG_VISIBLE;
				break;
			}

			if ( MraModifyContact(hContact, 0, &dwContactFlag)) {
				SetContactBasicInfoW(hContact, 0, SCBIF_FLAG, 0, 0, dwContactFlag, 0, 0, 0, 0, 0);
				return 0; // Success
			}
		}
	}

	return 1;
}
Esempio n. 12
0
/*
* if line0 < line1
*       return a negative value
* else if line0 == line1
*       return 0
* else
*       return a positive value
*/
static int lineCompare(LineListPtr line0,LineListPtr line1)
{
        int i,j,minNumWords,minLine;

        if (LSNumWords(line0->lineNum) < LSNumWords(line1->lineNum))
                minNumWords = LSNumWords(line0->lineNum);
        else
                minNumWords = LSNumWords(line1->lineNum);
        for (i = 0; i < minNumWords; i++) {
                j = strcmp(getWord(line0,i),getWord(line1,i));
                if (j != 0)
                        return j;
        }
        /* assert: line0 and line1 are equal for the first min words */
        return LSNumWords(line0->lineNum) - LSNumWords(line1->lineNum);
}
Esempio n. 13
0
void CSItemsList::saveItems(char *protoName)
{
	unsigned int i;
	char dbSetting[32];
	mir_snprintf(dbSetting, "%s_ItemsCount", protoName);
	unsigned int oldItemsCount = getWord(dbSetting, DEFAULT_ITEMS_COUNT);

	for (i = 1; i <= m_list->getCount(); i++)
	{
		StatusItem* item = m_list->get(i - 1);
		mir_snprintf(dbSetting, "%s_Item%dIcon", protoName, i);
		setByte(dbSetting, item->m_iIcon);
		mir_snprintf(dbSetting, "%s_Item%dTitle", protoName, i);
		setWString(dbSetting, item->m_tszTitle);
		mir_snprintf(dbSetting, "%s_Item%dMessage", protoName, i);
		setWString(dbSetting, item->m_tszMessage);
		mir_snprintf(dbSetting, "%s_Item%dFavourite", protoName, i);
		setByte(dbSetting, item->m_bFavourite);
	}

	mir_snprintf(dbSetting, "%s_ItemsCount", protoName);
	setWord(dbSetting, m_list->getCount());

	for (; i <= oldItemsCount; i++)
	{
		mir_snprintf(dbSetting, "%s_Item%dIcon", protoName, i);
		deleteSetting(dbSetting);
		mir_snprintf(dbSetting, "%s_Item%dTitle", protoName, i);
		deleteSetting(dbSetting);
		mir_snprintf(dbSetting, "%s_Item%dMessage", protoName, i);
		deleteSetting(dbSetting);
		mir_snprintf(dbSetting, "%s_Item%dFavourite", protoName, i);
		deleteSetting(dbSetting);
	}
}
Esempio n. 14
0
void CSItemsList::loadItems(char *protoName)
{
	char dbSetting[32];
	mir_snprintf(dbSetting, "%s_ItemsCount", protoName);
	unsigned int itemsCount = getWord(dbSetting, DEFAULT_ITEMS_COUNT);

	for (unsigned int i = 1; i <= itemsCount; i++) {
		StatusItem* item = new StatusItem();
		DBVARIANT dbv;
		mir_snprintf(dbSetting, "%s_Item%dIcon", protoName, i);
		item->m_iIcon = getByte(dbSetting, DEFAULT_ITEM_ICON);

		mir_snprintf(dbSetting, "%s_Item%dTitle", protoName, i);
		if (!getWString(dbSetting, &dbv)) {
			mir_wstrcpy(item->m_tszTitle, dbv.ptszVal);
			db_free(&dbv);
		}
		else item->m_tszTitle[0] = 0;

		mir_snprintf(dbSetting, "%s_Item%dMessage", protoName, i);
		if (!getWString(dbSetting, &dbv)) {
			mir_wstrcpy(item->m_tszMessage, dbv.ptszVal);
			db_free(&dbv);
		}
		else item->m_tszMessage[0] = 0;

		mir_snprintf(dbSetting, "%s_Item%dFavourite", protoName, i);
		item->m_bFavourite = (BOOL)getByte(dbSetting, DEFAULT_ITEM_IS_FAVOURITE);

		m_list->add(item);
	}
}
Esempio n. 15
0
void loader(const char *programName)
{

	FILE *file_ptr;
	char c;
	char *dataSegment;
	file_ptr = fopen(programName, "r");
	reset();
	while ( (c = fgetc(file_ptr)) != EOF )
	{
		while ( isspace( ( c = fgetc(file_ptr) ) ) );

		if ( c == '.' )
		{
			
			dataSegment = getWord(file_ptr);   

			if ( !strcmp(dataSegment, "data") )
			{
				getDataSegment(file_ptr);
				putchar('\n');//print new line after printing datas.
				return;

			}
			else if ( !strcmp(dataSegment, "text") )
			{
				getTextSegment(file_ptr);
				return;
			}
			else if ( !strcmp(dataSegment, "end") )  // end of main 			{
				return;
			}
		}
		else if ( c == '#' )
Esempio n. 16
0
 bool wordPattern(string pattern, string str) {
     int p;
     int s;
     string word;
     unordered_map<char,string> hashmap1;
     unordered_map<string,char> hashmap2;
     for(p=0,s=0;p<pattern.length()&&s<str.length();p++)
     {
         word = getWord(str,s);
         cout<<"word: "<<word<<";"<<endl;
         if(hashmap1.find(pattern[p])==hashmap1.end()&&hashmap2.find(word)==hashmap2.end())
         {
             hashmap1.insert({pattern[p],word});
             hashmap2.insert({word,pattern[p]});
         }
         else if(hashmap1[pattern[p]]!=word||hashmap2[word]!=pattern[p])
             return false;
         s += word.length();
         while(s<str.length()&&str[s]==' ')
             s++;   
     }
     cout<<"p = "<<p<<" s = "<<s<<endl;
     if(p==pattern.length()&&s==str.length())
         return true;
     else
         return false;
 }
Esempio n. 17
0
bool CSentence::GetWSLemmaString(Wtroka& sLemmas, const CWordSequence& ws, bool bLem) const
{
    sLemmas = ws.GetCapitalizedLemma();

    if (bLem)
        return !sLemmas.empty();

    if (sLemmas.empty())
        for (int j = ws.FirstWord(); j <= ws.LastWord(); j++) {
            if (!sLemmas.empty())
                sLemmas += ' ';
            sLemmas += getWord(j)->GetOriginalText();
        }

    static const Wtroka trim_chars = CharToWide(" \"\'");
    TWtringBuf res = sLemmas;
    while (!res.empty() && trim_chars.find(res[0]) != TWtringBuf::npos)
        res.Skip(1);
    while (!res.empty() && trim_chars.find(res.back()) != TWtringBuf::npos)
        res.Chop(1);

    if (sLemmas.size() != res.size())
        sLemmas = ::ToWtring(res);

    return true;
}
Esempio n. 18
0
int __cdecl CYahooProto::SendMsg( HANDLE hContact, int flags, const char* pszSrc )
{
	if (!m_bLoggedIn) {/* don't send message if we not connected! */
		ForkThread( &CYahooProto::im_sendackfail, hContact );
		return 1;
	}

	ptrA msg;
	if (flags & PREF_UNICODE) /* convert to utf8 */
		msg = mir_utf8encodeW(( wchar_t* )&pszSrc[ strlen(pszSrc)+1 ] );
	else if ( flags & PREF_UTF )
		msg = mir_strdup(pszSrc);
	else
		msg = mir_utf8encode(pszSrc);

	if (lstrlenA(msg) > 800) {
		ForkThread( &CYahooProto::im_sendackfail_longmsg, hContact );
		return 1;
	}

	DBVARIANT dbv;
	if (!getString( hContact, YAHOO_LOGINID, &dbv)) {
		send_msg(dbv.pszVal, getWord( hContact, "yprotoid", 0), msg, 1);

		ForkThread( &CYahooProto::im_sendacksuccess, hContact );

		db_free(&dbv);
		return 1;
	}

	return 0;
}
Esempio n. 19
0
int main(int argc, char** argv) {
  char msg[SIZE];
		int len=0;
		int start=0;
		int *pstart=&start; 
		int end=0;
		int *pend=&end;
		int count=0;
		// read in every line of the tweets
  while ((len = readMsg(msg)) != EOF) {
    // get every word in the current line
    *pstart=0;
				*pend=0;
    while (getWord(msg,len,pstart,pend)) {
      // turn the word to small case
//	printf("start %d\n", *pend - *pstart);
//	printf("end %d\n", *pend);
      count = *pstart;
						while(count <= *pend) {
							unCapitalize(msg+count);
							count++;
      }
      // check and process the word
	printf("word %s\n",(msg+*pstart));
      checkWord((msg+*pstart),*pend-*pstart,argv,argc); 
    		
	}
    // output the processed message
    for(count=0;count<len;count++) {
   // putchar(*(msg+count));
    }
  }
  return 0;
}
Esempio n. 20
0
/* Parse and a word config line option. A word is a consequtive
 * sequence of non-whitespace characters. pVal must be
 * a pointer to a string which is to receive the option
 * value. The returned string must be freed by the caller.
 * rgerhards, 2007-09-07
 * To facilitate multiple instances of the same command line
 * directive, doGetWord() now checks if pVal is already a
 * non-NULL pointer. If so, we assume it was created by a previous
 * incarnation and is automatically freed. This happens only when
 * no custom handler is defined. If it is, the customer handler
 * must do the cleanup. I have checked and this was al also memory
 * leak with some code. Obviously, not a large one. -- rgerhards, 2007-12-20
 * Just to clarify: if pVal is parsed to a custom handler, this handler
 * is responsible for freeing pVal. -- rgerhards, 2008-03-20
 */
static rsRetVal doGetWord(uchar **pp, rsRetVal (*pSetHdlr)(void*, uchar*), void *pVal)
{
	DEFiRet;
	cstr_t *pStrB = NULL;
	uchar *pNewVal;

	ASSERT(pp != NULL);
	ASSERT(*pp != NULL);

	CHKiRet(getWord(pp, &pStrB));
	CHKiRet(cstrConvSzStrAndDestruct(&pStrB, &pNewVal, 0));

	DBGPRINTF("doGetWord: get newval '%s' (len %d), hdlr %p\n",
		  pNewVal, (int) ustrlen(pNewVal), pSetHdlr);
	/* we got the word, now set it */
	if(pSetHdlr == NULL) {
		/* we should set value directly to var */
		if(*((uchar**)pVal) != NULL)
			free(*((uchar**)pVal)); /* free previous entry */
		*((uchar**)pVal) = pNewVal; /* set new one */
	} else {
		/* we set value via a set function */
		CHKiRet(pSetHdlr(pVal, pNewVal));
	}

	skipWhiteSpace(pp); /* skip over any whitespace */

finalize_it:
	if(iRet != RS_RET_OK) {
		if(pStrB != NULL)
			cstrDestruct(&pStrB);
	}

	RETiRet;
}
Esempio n. 21
0
void loadDictionary(FILE* file, struct hashMap* ht)
{
  /* You will write this*/

    //open dictionary file
    printf( "//TESTING: OPENING DICTIONARY\n");


    file = fopen ("dictionary.txt", "r");    //open the file (r: read from file)
    //assert (file != 0);


    while(file != 0)                         //ensure it's open
    {
        char * word = getWord(file);
        printf("//TESTING Word: %s \n", word);
        while(word)
        {

                printf( "//TESTING: INSERTING\n");
                insertMap(ht, word, 1);
                printf( "//TESTING: INSERTED\n");


        }
    }
    if (file == 0)
    {
        printf( "%s doesn't exist or is protected.\n", "dictionary.txt");
    }

    fclose(file);


}
Esempio n. 22
0
int main_keyword_counting(int argc, char **argv) {

	char word[MAX_WORD];
	int ind;

	while ((getWord(word, MAX_WORD)) != EOF) {
		if (isalpha(word[0])) {
			printf("searching for: %s\n", word);

			if ((ind = binarySearch(keytab, word)) >= 0) {
				keytab[ind].count ++;
			}
		}
	}

	//print
	int i;
	for (i = 0; i < NKEYS; i ++) {
		if (keytab[i].count > 0) {
			printf("%s: %d\n", keytab[i].word, keytab[i].count);
		}

	}

	return 0;
}
Esempio n. 23
0
static int getWLenBuf(const uint8_t **ppCur, uint32_t *pdwLeft, uint8_t *pBuf, uint16_t *pwBufLen, int iNetByteOrder)
{
	//assert((ppCur && *ppCur));

	const uint8_t *pTmp = *ppCur;
	const uint32_t dwTmp = pdwLeft ? *pdwLeft : 0;
	uint16_t wLen = 0;

	int iRet = getWord(ppCur, pdwLeft, &wLen, iNetByteOrder);
	if (0 == iRet) {
		if (!pwBufLen) {
			iRet = GetBuf(ppCur, pdwLeft, 0, wLen);
		} else if (wLen <= *pwBufLen) {
			iRet = GetBuf(ppCur, pdwLeft, pBuf, wLen);
		} else {
			iRet = E_OVERFLOW;
		}
	}

	if (0 == iRet) {
		if (pwBufLen) {
			*pwBufLen = wLen;
		}
	} else {
		*ppCur = pTmp;
		if (pdwLeft) {
			*pdwLeft = dwTmp;
		}
	}

	return iRet;
}
Esempio n. 24
0
/* parse a syslog name from the string. This is the generic code that is
 * called by the facility/severity functions. Note that we do not check the
 * validity of numerical values, something that should probably change over
 * time (TODO). -- rgerhards, 2008-02-14
 */
static rsRetVal
doSyslogName(uchar **pp, rsRetVal (*pSetHdlr)(void*, int),
	  	    void *pVal, syslogName_t *pNameTable)
{
	DEFiRet;
	cstr_t *pStrB;
	int iNewVal;

	ASSERT(pp != NULL);
	ASSERT(*pp != NULL);

	CHKiRet(getWord(pp, &pStrB)); /* get word */
	iNewVal = decodeSyslogName(cstrGetSzStr(pStrB), pNameTable);

	if(pSetHdlr == NULL) {
		/* we should set value directly to var */
		*((int*)pVal) = iNewVal; /* set new one */
	} else {
		/* we set value via a set function */
		CHKiRet(pSetHdlr(pVal, iNewVal));
	}

	skipWhiteSpace(pp); /* skip over any whitespace */

finalize_it:
	if(pStrB != NULL)
		rsCStrDestruct(&pStrB);

	RETiRet;
}
Esempio n. 25
0
//=======================================================
//Contact deletion event
//=======================================================
int __cdecl CYahooProto::OnContactDeleted(WPARAM hContact, LPARAM)
{
	debugLogA("[YahooContactDeleted]");

	if (!m_bLoggedIn) {//should never happen for Yahoo contacts
		debugLogA("[YahooContactDeleted] We are not Logged On!!!");
		return 0;
	}

	// he is not a permanent contact!
	if (db_get_b(hContact, "CList", "NotOnList") != 0) {
		debugLogA("[YahooContactDeleted] Not a permanent buddy!!!");
		return 0;
	}

	DBVARIANT dbv;
	if (!getString(hContact, YAHOO_LOGINID, &dbv)) {
		debugLogA("[YahooContactDeleted] Removing %s", dbv.pszVal);
		remove_buddy(dbv.pszVal, getWord(hContact, "yprotoid", 0));

		db_free(&dbv);
	}
	else debugLogA("[YahooContactDeleted] Can't retrieve contact Yahoo ID");

	return 0;
}
Esempio n. 26
0
File: tests.c Progetto: cilix/art
void wordBench (Art* d, int argc, char** argv) {
  FILE* in = fopen(argv[1], "r");
  byte_t* word, *val;
  size_t actual = 0;
  int wc = 0;
  double end, start;
  srand(time(NULL));
  start = (float)clock()/CLOCKS_PER_SEC;
  while ((word = getWord(in))) {
    int l = strlen((char *)word);
    wc++;
    
    val = malloc(l + 5);
    memset(val, 0, l + 5);
    strncpy((char *)val, (char *)word, l);
    strncat((char *)val, "-val", 4);
    val[l + 4] = 0;
    
    actual += l;
    artPut(d, (byte_t*)word, l, (word_t)val);
    free(word);
    word = NULL;
  }
  end = (float)clock()/CLOCKS_PER_SEC;
  printf("Inserted %d words.\n", wc);
  printf("Total: %lu bytes.\n", bytes);
  printf("Overhead per key: %lu bytes.\n", (bytes - actual)/wc);
  printf("Actual: %lu bytes.\n", actual);
  printf("Finshed in %f.\n", end-start);
  fclose(in);
}
Esempio n. 27
0
void getToken(void) {

	skipBlanks();
	tokenp = tokenString;

	switch (calcCharCode(curChar)) {
		case CHR_LETTER:
			getWord();
			break;
		case CHR_DIGIT:
			getNumber();
			break;
		case CHR_DQUOTE:
			getString();
			break;
		case CHR_EOF:
			curToken = TKN_EOF;
			break;
		default:
			getSpecial();
			break;
	}

	if (blockFlag)
		crunchToken();
}
Esempio n. 28
0
    string numberToWords(int num) 
    {
        if (num == 0)
        {
            return "Zero";
        }
        vector<string>result;
        int count = 0;
        while (num > 0)
        {
            int temp = num % 1000;
            string str = getWord(temp);
            if (str != "Zero")
            {
                if (count > 0)
                {
                    str += " " + digit2[count];
                }
                result.push_back(str);
            }
 
            num = num / 1000;
            ++count;
        }
        string ret;
        for (int i = result.size() - 1; i >= 0; i--)
        {
            ret += result[i];
            ret.push_back(' ');
        }
        ret.pop_back();
        return ret;
        
    }
Esempio n. 29
0
int CYahooProto::Authorize( HANDLE hdbe )
{
	debugLogA("[YahooAuthAllow]");
	if ( !m_bLoggedIn ) {
		debugLogA("[YahooAuthAllow] Not Logged In!");
		return 1;
	}

	DBEVENTINFO dbei = { sizeof(dbei) };
	if (( dbei.cbBlob = db_event_getBlobSize(hdbe)) == -1 )
		return 1;

	dbei.pBlob = ( PBYTE )_alloca( dbei.cbBlob );
	if (db_event_get(hdbe, &dbei))
		return 1;

	if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
		return 1;

	if ( strcmp(dbei.szModule, m_szModuleName))
		return 1;

	/* Need to remove the buddy from our Miranda Lists */
	HANDLE hContact = DbGetAuthEventContact(&dbei);
	if (hContact != NULL) {
		ptrA who( getStringA(hContact, YAHOO_LOGINID));
		if (who) {
			ptrA myid( getStringA(hContact, "MyIdentity"));
			debugLogA("Accepting buddy:%s", who);
			accept(myid, who, getWord(hContact, "yprotoid", 0));
		}
	}

	return 0;
}
Esempio n. 30
0
Word ThLeftNormalForm::getReducedWord() const {
  if (theOmegaPower >= 0 || theDecomposition.size() == 0)
    return getWord();

  const auto p = -theOmegaPower;
  const auto d = theDecomposition.size();
  const auto a = p < d ? p : d;

  Word result;

  // 1. Process omega
  const Permutation omega = Permutation::getHalfTwistPermutation(theRank);
  Word omegaWord = Word(omega.geodesicWord());
  omegaWord = -omegaWord;
  result = omegaWord.power(p - a);

  // 2. Cancel omega^-1 with positive permutations
  auto it = theDecomposition.begin();
  for (int i = 0; i < a; ++i, ++it) {
    auto perm = (-(*it)) * omega;
    if ((a - i - 1) % 2 != 0)
      perm = perm.flip();
    result *= -Word(perm.geodesicWord());
  }
  // 3. process the rest of positive permutations
  for (; it != theDecomposition.end(); ++it) {
    result *= Word((*it).geodesicWord());
  }

  return result;
}