Example #1
0
int _tmain(int argc, _TCHAR* argv[])
{
	char* smol = "qwertyuiopasdfghjklzxcvbnm";
	FILE* fp = 0;
	fopen_s(&fp, "XD_fail.txt", "r");
	char output[51];
	char** aw = new char*[100];
	int nw = 0, ni = 0;//ni число слов содержащие не только маленькие буквы буквы
	do{
		fgets(output, 50, fp);
		if (feof(fp)) break;  //Истинный выход
		if (output[strlen(output) - 1] == '\n')    	output[strlen(output) - 1] = '\0';
		char* next_p;
		char p = strtok_s(output, " ,.-?!()#[]<>{};*=", &next_p);
		while (p){
				//	cout << p << endl;
			aw[nw] = new char[strlen(p)];
			for (int i = 0; i <= strlen(p); ++i)
				aw[nw][i] = p[i];
			nw++;
			int a=0, b=0;
			for (int i = 0; i < strlen(p); i++)
			{
				char* SmolCh = copyStr(p, i, 1);
				if (strstr(smol, SmolCh))a++; else b++;
			}
			if ((a != 0)&(b != 0)) ni++;
				p = strtok_s(0, " ,.-?!()#[]<>{};*=", &next_p);
		}
	} while (true);
	
	fclose(fp);
	cout << "**** Result ****" << endl;
	_itoa_s(ni, output, 50, 10);
	aw[nw] = output;
	for (int i = 0; i < nw; ++i) cout << aw[i] << endl;
	fp = 0;
	
	fopen_s(&fp, "XD_fail.txt", "a");
fputs(aw[nw], fp); fputs("\n", fp);
	fclose(fp);
	/*char str[10];
	ifstream b_file("XD_fail.txt");
	while (!b_file.eof())
	{
		b_file >> str;
		cout << str << " ";
	}
	cin.get();*/

	return 0;
}
//make this split argList into arg tokens
void ConsoleArguments::TokenizeArgList(){
	char* tokenInBuffer;
	char* currentValue = currentValue = strtok_s(argList, " \0", &tokenInBuffer);

	
	while (currentValue != NULL){
		if (currentValue == NULL)break;

		argTokens.push_back(currentValue);

		currentValue = strtok_s(NULL, " ", &tokenInBuffer);
	}
}
Example #3
0
static char* FindApplicationPath(char* application)
{
	LPCSTR pathName = "PATH";
	char* path;
	char* save;
	DWORD nSize;
	LPSTR lpSystemPath;
	char* filename = NULL;

	if (!application)
		return NULL;

	if (application[0] == '/')
		return _strdup(application);

	nSize = GetEnvironmentVariableA(pathName, NULL, 0);

	if (!nSize)
		return _strdup(application);

	lpSystemPath = (LPSTR) malloc(nSize);

	if (!lpSystemPath)
		return NULL;

	if (GetEnvironmentVariableA(pathName, lpSystemPath, nSize) != nSize - 1)
	{
		free(lpSystemPath);
		return NULL;
	}

	save = NULL;
	path = strtok_s(lpSystemPath, ":", &save);

	while (path)
	{
		filename = GetCombinedPath(path, application);

		if (PathFileExistsA(filename))
		{
			break;
		}

		free(filename);
		filename = NULL;
		path = strtok_s(NULL, ":", &save);
	}

	free(lpSystemPath);
	return filename;
}
Example #4
0
// _____________________________________________________________________ //
//
// MAIN
// _____________________________________________________________________ //
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd)
{
	// One instance is enough
	HANDLE hGlobalLock = CreateMutex(NULL, TRUE, L"RestoreWindowsMutex");
	if(hGlobalLock == INVALID_HANDLE_VALUE || GetLastError() == ERROR_ALREADY_EXISTS)
		return 0;

	const char* tok = 0;
	char* context = NULL;
	const char* delims = " =\t";
	tok = strtok_s(lpCmdLine, delims, &context);
	while(tok)
	{
		if(!_stricmp(tok, "--debuglog"))
		{
			_sopen_s(&logfile, "RestoreWindows.log", _O_WRONLY | _O_BINARY | _O_TRUNC | _O_CREAT, _SH_DENYNO, _S_IWRITE);
		}
		else if(!_stricmp(tok, "--delay"))
		{
			tok = strtok_s(0, delims, &context);
			if(tok)
				ResumeTimerValue = clamp(0, 1000*60*10, atoi(tok));
		}
		tok = strtok_s(0, delims, &context);
	}

	DesiredMonitorPlacements = GetAllMonitors();

	Log("Delay: %d\n\n", ResumeTimerValue);
	for(auto it = DesiredMonitorPlacements.begin(); it != DesiredMonitorPlacements.end(); ++it)
		Log("Monitor: %d, %d\n", it->right-it->left, it->bottom-it->top);
	 Log("\n");

	LoadAllWindowPlacements();

	HWINEVENTHOOK hWinEventHook = SetWinEventHook(EVENT_MIN, EVENT_MAX, NULL, WinEventProc, 0, 0, WINEVENT_OUTOFCONTEXT);
	DetectWindow = CreateDetectionWnd();

	MSG msg;
	while(GetMessage(&msg, NULL, 0, 0) > 0)
	{
		DispatchMessage(&msg);
	}

	// Usually never gets here...
	UnhookWinEvent(hWinEventHook);
	_close(logfile);
	CloseHandle(hGlobalLock);

	return 0;
}
Example #5
0
//***************************************
//Method:    ParseHttpHead
//FullName:  ParseHttpHead
//Access:    public
//Returns:   void
//Qualifier: 解析TCP报文中的HTTP头部
//Parameter: char *buffer
//Parameter: HttpHeader *httpHeader
//****************************************
void ParseHttpHeader(char *buffer, HttpHeader *httpHeader)
{
	char *p;
	char *ptr;
	const char* delim = "\r\n";

	//提取第一行
	p = strtok_s(buffer, delim, &ptr);
	printf("%s\n", p);

	//GET方式
	if (p[0] == 'G')
	{
		memcpy(httpHeader->method, "GET", 3);
		memcpy(httpHeader->url, &p[4], strlen(p) - 13);
	}
	//POST方式
	else if (p[0] == 'P')
	{
		memcpy(httpHeader->method, "POST", 4);
		memcpy(httpHeader->url, &p[5], strlen(p) - 14);
	}
	printf("%s\n", httpHeader->url);
	//实际为第二个指针,指向截断位置
	p = strtok_s(NULL, delim, &ptr);
	while (p)
	{
		switch (p[0])
		{
		case 'H'://Host
			memcpy(httpHeader->host, &p[6], strlen(p) - 6);
			break;
		case 'C'://Cookie
			if (strlen(p) > 8)
			{
				char header[8];
				ZeroMemory(header, sizeof(header));
				memcpy(header, p, 6);
				if (!strcmp(header, "Cookie"))
				{
					memcpy(httpHeader->cookie, &p[8], strlen(p) - 8);
				}
			}
			break;
		default:
			break;
		}
		p = strtok_s(NULL, delim, &ptr);
	}
}
Example #6
0
Vector3f ParseVector3f(const char* s)
{
	Vector3f v;
	char* myString = new char[strlen(s)];
	char* nextToken;
	strcpy_s(myString, _TRUNCATE, s);
	char* first = strtok_s(myString, ",", &nextToken);
	v.x = (float)(atof(first));
	v.y = (float)(atof(nextToken + 1));
	char* second = strtok_s(NULL, ",", &nextToken);
	v.z = (float)(atof(nextToken + 1));

	return v;
}
Example #7
0
	void checkText(const Log::LOG &log, char *text)
	{
		int pozition = 0;
		char *a = new char[IN_MAX_LEN_TEXT], *nowRez = new char[IN_MAX_LEN_TEXT];
		char *next_token1 = NULL;
		 a= strtok_s(text, " \n", &next_token1);
		while (a)
		{
			std::cout << a << std::endl;
			a = strtok_s(NULL, " \n", &next_token1);
		}
		delete[] a;
		delete[] nowRez;
	}
Example #8
0
void promptInitialPosition(Vector& initialPosition)
{
    BOOL validPosition = FALSE;
    do
    {
        STRING initialPositionString;
        cout << "Entrez la position initiale comme suit X0, Y0, Z0: ";
        getline(cin, initialPositionString);

        CHAR* nextToken = NULL;
        INT tokenCount = 0;
        CHAR* token = strtok_s((CHAR*) initialPositionString.c_str(), ",", &nextToken);
        while (token != NULL && tokenCount < 3) 
        {
            initialPosition[tokenCount] = (FLOAT) atof(token);
            tokenCount++;
	        token = strtok_s(NULL, ",", &nextToken);
        }

        validPosition = TRUE;
        if ( tokenCount != 3 )
        {
            cout << "Nombre de composants invalide" << endl;
            validPosition = FALSE;
        }

        if ( initialPosition.x() < 0.0f || initialPosition.x() > Tp1Constants::PLAYER_ZONE_WIDTH )
        {
            cout << "Valeur en X invalide" << endl;
            validPosition = FALSE;
        }

        if ( initialPosition.y() < 0.0f || initialPosition.y() > Tp1Constants::PLAYER_ZONE_LENGTH )
        {
            cout << "Valeur en Y invalide" << endl;
            validPosition = FALSE;
        }

        if ( initialPosition.z() < 0.0f || initialPosition.z() > Tp1Constants::COURT_REACH )
        {
            cout << "Valeur en Z invalide" << endl;
            validPosition = FALSE;
        }

        if ( !validPosition )
            cout << "Position initiale invalide, veuillez recommencer" << endl << endl;

    } while( !validPosition );
}
Example #9
0
/*
=============
MD5Model::ReadJoints

	Reads all joints from a char buffer.
	Stores them in joints member variable.
	Returns a pointer to where the buffer should continue reading.
=============
*/
char* MD5Model::ReadJoints( char* startingPosition ) {
	char* nextLine      = NULL;
	char* currentLine   = strtok_s( startingPosition, "\n", &nextLine );
	char* nextToken     = NULL;
	int   jointIndex    = 0;    

	while ( currentLine[0] != '}' ) {     
		ReadJoint( currentLine, joints[jointIndex] );

		++jointIndex;
		currentLine = strtok_s( NULL, "\n", &nextLine );
	}

	return nextLine;
}
Example #10
0
static void ParseList(DynamicVectorClass<T> &List, CCINIClass * pINI, const char *section, const char *key) {
	if(pINI->ReadString(section, key, Ares::readDefval, Ares::readBuffer)) {
		List.Clear();

		char* context = nullptr;
		for(char *cur = strtok_s(Ares::readBuffer, Ares::readDelims, &context); cur; cur = strtok_s(nullptr, Ares::readDelims, &context)) {
			T buffer = T();
			if(Parser<T>::TryParse(cur, &buffer)) {
				List.AddItem(buffer);
			} else if(!std::is_pointer<T>() || !INIClass::IsBlank(cur)) {
				Debug::INIParseFailed(section, key, cur);
			}
		}
	}
};
Example #11
0
void linkCostChange() // "User to Host" Link cost message looks like: "L n cost"
{
	char* strptr;
	char tokstr[3][5];
	char * context;
	strptr = strtok_s(recvBuf, " ", &context);
	cout << 0 << ": strptr = " << *strptr << endl;
	strcpy_s(tokstr[0],sizeof(tokstr[0]), strptr);
	cout << 0 << ": tokstr[" << 0 << "]= " << tokstr[0] << endl;

	if (tokstr[0][0] != 'L') // Basic error checking, this should never be true.
	{
		cout << "Something is wrong. The link cost change function was called.\nBut the message does not contain a link cost change message header." << endl;
		return;
	}

	for (int i = 1; i < 3; i++) // Populate string array.
	{
		strptr = strtok_s(NULL, " ", &context);
		cout << i << ": strptr = " << *strptr << endl;
		strcpy_s(tokstr[i], sizeof(tokstr[1]), strptr);
		cout << i << ": tokstr[" << i << "]= " << tokstr[i] << endl;

		if (i == 1 && name == tokstr[i][0])
		{
			cout << "Invalid Link message content. You are attempting to create an entry for this router in it's own table. " << endl;
			return;
		}
		if ((i == 1 || i == 2) && tokstr[i][0] == 0) // Basic error checking, this should never be true.
		{
			cout << "Something is wrong. The link cost change function was called.\nBut the message is not a complete link cost change message." << endl;
			return;
		}
	}
	memset(recvBuf, '\0', sizeof(recvBuf));

	if (table[tokstr[1][0]].distance == INF)
	{
		cout << "The node to change a link with is not a neighbor, updating the routing distance with the new value." << endl;
		cout << "You may not have intended to do this." << endl;
		table[tokstr[1][0]].distance = stoi(tokstr[2]); // update distance cost with new value from user.
	}
	else
	{
		cout << "The node to change a link with is a neighbor, updating the adjacent distance with the new value." << endl;
		updateDistanceVectorTable(); // Update distance vector table to see if a better route exists after new link cost update.
	}
}
Example #12
0
/**
 * @brief	Create and initilize AVL tree for environment variables
 *			in global variable called "env_avltree"
 *
 * @return	void
 *
 * @retval	None
 */
void
create_env_avltree()
{
	int i = 0;
	char varname_tmp[_MAX_ENV] = {'\0'};
	char *name = NULL;
	char *value = NULL;
	AVL_IX_REC *pe = NULL;
	extern char **environ;

	if (env_avltree == NULL) {
		if ((env_avltree = malloc(sizeof(AVL_IX_DESC))) != NULL) {
			avl_create_index(env_avltree, AVL_NO_DUP_KEYS, 0);
		}
	}

	if (env_avltree != NULL) {
		for (i=0; environ[i] != NULL; i++) {
			(void)strncpy_s(varname_tmp, sizeof(varname_tmp), environ[i], _TRUNCATE);
			if ((name = strtok_s(varname_tmp, "=", &value)) != NULL) {
				if ((pe = malloc(sizeof(AVL_IX_REC) + WINLOG_BUF_SIZE + 1)) != NULL) {
					strncpy(pe->key, name, WINLOG_BUF_SIZE);
					if ((pe->recptr = (void *)strdup(value)) != NULL)
						avl_add_key(pe, env_avltree);
					free(pe);
					pe = NULL;
				}
			}
		}
	}
}
Example #13
0
 **/int convert_to_struct(const char *buffer, void *data, PROPERTY *structure)
{
	int len = 0;
	char temp[1025];
	if ( buffer[0]!='{' ) return -1;
	strncpy(temp,buffer+1,sizeof(temp));
	char *item = NULL;
	char *last = NULL;
	while ( (item=strtok_s(item?NULL:temp,";",&last))!=NULL )
	{
		char name[64], value[1024];
		while ( isspace(*item) ) item++;
		if ( *item=='}' ) return len;
		if ( sscanf(item,"%s %[^\n]",name,value)!=2 )
			return -len;
		PROPERTY *prop;
		for ( prop=structure ; prop!=NULL ; prop=prop->next )
		{
			if ( strcmp(prop->name,name)==0 )
			{
				void *addr = (char*)data + (size_t)prop->addr;
				PROPERTYSPEC *spec = property_getspec(prop->ptype);
				len += spec->string_to_data(value,addr,prop);
				break;
			}
		}
		if ( prop==NULL ) return -len;
	}
	return -len;
}
Example #14
0
BOOL CCookieMgr::LoadDomainAndPath(LPSTR lpszBuff, CStringA& strDomain, CStringA& strPath)
{
	int i = 0;
	char* lpszCtx = nullptr;

	for(; i < 2; i++)
	{
		char* lpszToken = strtok_s(lpszBuff, " \n\r", &lpszCtx);

		if(!lpszToken)
		{
			::SetLastError(ERROR_BAD_FORMAT);
			return FALSE;
		}

		if(i == 0)
		{
			strDomain = lpszToken;
			lpszBuff  = nullptr;
		}
		else
			strPath = lpszToken;
	}

	if(!CCookie::AdjustDomain(strDomain))
		return FALSE;
	if(!CCookie::AdjustPath(strPath))
		return FALSE;

	return TRUE;
}
Example #15
0
//rédéfinition de la fonction pour 
string trim(string ligne, char  delims[])
{
	char *mots;
	char *context = NULL;
	char* char_line = (char*)ligne.c_str(); // Non-const cast required.
	mots = strtok_s(char_line, delims, &context);

	string nouveauMot;

	while(mots != NULL)
	{
		nouveauMot.append(mots).append(" ");
		mots = strtok_s(NULL, delims, &context);
	}
	return nouveauMot = nouveauMot.substr(0, nouveauMot.find_last_of(" "));
}
Example #16
0
//fonction qui retourne une vecteur des mots coupés
vector<string> split(string ligne, char  delims[])
{
	char *mots;
	char *context = NULL;
	char* char_line = (char*)ligne.c_str(); // Non-const cast required.
	mots = strtok_s(char_line, delims, &context);

	vector<string> tableMot;

	while(mots != NULL)
	{
		tableMot.push_back(mots);
		mots = strtok_s(NULL, delims, &context);
	}
	return tableMot;
}
Example #17
0
//trim pour concatener les éléments sans ajouter les espaces à la fin
string trim(string ligne)
{
	char *mots;
	char *context = NULL;
	char* char_line = (char*)ligne.c_str(); // Non-const cast required.
	mots = strtok_s(char_line, " \t", &context);

	string nouveauMot;

	while(mots != NULL)
	{
		nouveauMot.append(mots);
		mots = strtok_s(NULL, " \t", &context);
	}
	return nouveauMot;
}
Example #18
0
 char *strtok(char *str, const char *sep, char **context) {
     #if  defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
         return strtok_s(str, sep, context);
     #else
         return strtok_r(str, sep, context);
     #endif
 }
Example #19
0
bool PeekString(std::ifstream & infile, const char * delim, std::string & outStr)
{
	if (true == infile.eof())
	{
		return false;
	}

	std::string line;
	std::streampos pos = infile.tellg();
	std::getline(infile, line);

	char * token = nullptr;
	char * nextToken = nullptr;
	token = strtok_s(&line[0], delim, &nextToken);

	if (token == nullptr)
	{
		return false;
	}

	outStr = std::string(token);

	infile.seekg(pos);

	return true;
}
Example #20
0
P_LIB_API pchar *
p_strtok (pchar *str, const pchar *delim, pchar **buf)
{
	if (P_UNLIKELY (delim == NULL))
		return str;

#ifdef P_OS_WIN
#  ifdef P_CC_MSVC
	if (P_UNLIKELY (buf == NULL))
		return str;
#    if _MSC_VER < 1400
	P_UNUSED (buf);
	return strtok (str, delim);
#    else
	return strtok_s (str, delim, buf);
#    endif
#  else
	P_UNUSED (buf);
	return strtok (str, delim);
#  endif
#else
	if (P_UNLIKELY (buf == NULL))
		return str;

	return strtok_r (str, delim, buf);
#endif
}
Example #21
0
int main() {
    int exit = 0;
    int childID = 0;
    int status = 0;
    char rawInput[BUFFERSIZE];
    char* commandFull = NULL;
    char* nextToken = NULL;

    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);
    ZeroMemory(&pi, sizeof(pi));


    while (1) {
        printf("Myshell> ");
        fgets(rawInput, BUFFERSIZE, stdin);
        commandFull = strtok_s(rawInput, "\n", &nextToken);
        if (strcmp(commandFull, "exit") == 0) {
            return 0;
        }

        if (!CreateProcess(NULL, commandFull, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
            printf("Error creating new process\n");
        }
        else {
            WaitForSingleObject(pi.hProcess, INFINITE);
        }
    }

return 0;
}
Example #22
0
void insertIndexes(std::vector<std::string> items, PaletteFilterFxRenderData *t)
{
#ifdef _WIN32
	for (int i = 0; i < (int)items.size(); i++) {
		char *starttoken, *endtoken;
		char subseps[] = "-";
		std::string tmp = items[i];
		char *context = 0;
		starttoken = strtok_s((char *)tmp.c_str(), subseps, &context);
		endtoken = strtok_s(NULL, subseps, &context);
		if (!endtoken && isInt(starttoken)) {
			int index;
			index = toInt(starttoken);
			t->m_colors.insert(index);
		} else {
			if (isInt(starttoken) && isInt(endtoken)) {
				int start, end;
				start = toInt(starttoken);
				end = toInt(endtoken);
				for (int i = start; i <= end; i++)
					t->m_colors.insert(i);
			}
		}
	}
#else
	for (int i = 0; i < (int)items.size(); i++) {
		char *starttoken, *endtoken;
		char subseps[] = "-";
		std::string tmp = items[i];
		starttoken = strtok((char *)tmp.c_str(), subseps);
		endtoken = strtok(NULL, subseps);
		if (!endtoken && isInt(starttoken)) {
			int index;
			index = toInt(starttoken);
			t->m_colors.insert(index);
		} else {
			if (isInt(starttoken) && isInt(endtoken)) {
				int start, end;
				start = toInt(starttoken);
				end = toInt(endtoken);
				for (int i = start; i <= end; i++)
					t->m_colors.insert(i);
			}
		}
	}
#endif
}
Example #23
0
char * os_strtok_r(char *str, const char *delim, char ** savestate)
{
#if LL_WINDOWS
	return strtok_s(str, delim, savestate);
#else
	return strtok_r(str, delim, savestate);
#endif
}
void ControlSpeekWindow::PreparePages()
{
	char* newtext = new char[strlen(character->ActiveConversation->ActiveNode->Statement)+1];
	int linecount = 0;
	char* token = nullptr;
	char* nextToken = nullptr;
	char newpage[512];

	currentpage = 0;
	for(int i=pages.size()-1; i>=0; i--)
	{
		delete pages.back();
		pages.pop_back();
	}

	strcpy_s(newtext, strlen(character->ActiveConversation->ActiveNode->Statement)+1, character->ActiveConversation->ActiveNode->Statement);
	token = strtok_s(newtext, "\n", &nextToken);
	while (token != nullptr)
	{
		if(linecount == 0)
		{
			strcpy_s(newpage, 512, "");
		}
		
		strcat_s(newpage, 512, token);
		strcat_s(newpage, 512, "\n");
		token = strtok_s(nullptr, "\n", &nextToken);
		linecount++;

		if(linecount == 5)
		{
			pages.push_back(new char[strlen(newpage)+1]);
			strcpy_s(pages.back(), strlen(newpage)+1, newpage);
			linecount = 0;
		}
	}

	if(linecount != 0)
	{
		pages.push_back(new char[strlen(newpage)+1]);
		strcpy_s(pages.back(), strlen(newpage)+1, newpage);
	}

	delete newtext;
	delete token;
};
Example #25
0
char *oscap_strtok_r(char *str, const char *delim, char **saveptr)
{
#ifdef OS_WINDOWS
	return strtok_s(str, delim, saveptr);
#else
	return strtok_r(str, delim, saveptr);
#endif
}
Example #26
0
const Vector<MyString> MyString::SplitString(const char *symbol, char* command)
{
	Vector<MyString> vec;
	char *cstr, *word, *context;

	uint len = strlen(command);
	cstr = new char[len + 1];
	strcpy_s(cstr, len + 1, command);

	word = strtok_s(cstr, symbol, &context);
	while (word != NULL)
	{
		vec.push_back(word);
		word = strtok_s(NULL, symbol, &context);
	}
	delete[] cstr;
	return vec;
}
Example #27
0
	/**
	 * Tokenize a string (alias for strtok_r or strtok_s depending on platform)
	 *
	 * @param str String to split
	 * @param delim Delimiters
	 * @param saveptr Pointer to a char * for temporary reentrant storage
	 */
	static inline char *stok(char *str,const char *delim,char **saveptr)
		throw()
	{
#ifdef __WINDOWS__
		return strtok_s(str,delim,saveptr);
#else
		return strtok_r(str,delim,saveptr);
#endif
	}
Example #28
0
bool CalcOptions::getFontValue(const char *name, CHARFORMAT *fmt)
{
	const std::string& key = findKey(name);
	if(!key.length())
		return false;

	// extract font properties
	char buff[MaxLineLength+1];
	strcpy_s(buff, sizeof(buff), key.c_str());

   char *nextToken;
	fmt->dwMask = atoi(strtok_s(buff, ", ", &nextToken));
	fmt->dwEffects = atoi(strtok_s(NULL, ", ", &nextToken));
	fmt->yHeight = atoi(strtok_s(NULL, ", ", &nextToken));
	fmt->crTextColor = atoi(strtok_s(NULL, ", ", &nextToken));
   strcpy_s(fmt->szFaceName, sizeof(fmt->szFaceName), strtok_s(NULL, ",", &nextToken));
	return true;
}
Example #29
0
void main()
{
    char    *p;
    char    *buffer;
    char    *delims = { " .," };
    size_t  buflen;
    char    *ptr;

    buffer = strdup( "Find words, all of them." );
    printf( "%s\n", buffer );
    buflen = strlen( buffer );
    p = strtok_s( buffer, &buflen, delims, &ptr );
    while( p != NULL ) {
      printf( "word: %s\n", p );
      p = strtok_s( NULL, &buflen, delims, &ptr );
    }
    printf( "%s\n", buffer );
}
Example #30
0
static AUO_RESULT write_log_x264_version(const char *x264fullpath) {
    AUO_RESULT ret = AUO_RESULT_WARNING;
    static const int REQUIRED_X264_CORE = 104;
    static const int REQUIRED_X264_REV = 1673;
    char buffer[2048] = { 0 };
    if (get_exe_message(x264fullpath, "--version", buffer, _countof(buffer), AUO_PIPE_MUXED) == RP_SUCCESS) {
        char print_line[512] = { 0 };
        const char *LINE_HEADER = "x264 version: ";
        const char *LINE_CONFIGURATION = "configuration:";
        BOOL line_configuration = FALSE; //現在取得中かどうか
        BOOL got_line_configuration = FALSE; //一度取得したかどうか
        int configuration_pos = 0; //取得開始の文字の位置
        sprintf_s(print_line, _countof(print_line), LINE_HEADER);
        int a = -1, b = -1, c = -1;
        for (char *ptr = buffer, *qtr = NULL; NULL != (ptr = strtok_s(ptr, "\r\n", &qtr)); ) {
            if (ptr == buffer) {
                strcat_s(print_line, _countof(print_line), ptr + strlen("x264 ") * (NULL == strncmp(ptr, "x264 ", strlen("x264 "))));
                if (3 != sscanf_s(ptr, "x264 %d.%d.%d", &a, &b, &c))
                    a = b = c = -1;
            } else if (strstr(ptr, LINE_CONFIGURATION) && !got_line_configuration) {
                const char *rtr = strstr(ptr, LINE_CONFIGURATION) + strlen(LINE_CONFIGURATION);
                while (*rtr == ' ') rtr++;
                strcat_s(print_line, _countof(print_line), " ");
                strcat_s(print_line, _countof(print_line), rtr);
                configuration_pos = rtr - ptr;
                line_configuration = TRUE;
                got_line_configuration = TRUE;
            } else if (line_configuration) {
                const char *rtr = ptr;
                while (*rtr == ' ') rtr++;
                if ((int)(rtr - ptr) == configuration_pos) {
                    strcat_s(print_line, _countof(print_line), " ");
                    strcat_s(print_line, _countof(print_line), rtr);
                } else {
                    line_configuration = FALSE;
                }
            } else {
                line_configuration = FALSE;
            }
            ptr = NULL;
        }
        if (strlen(print_line) > strlen(LINE_HEADER)) {
            write_log_auo_line(LOG_INFO, print_line);
        }
        if (a >= 0 && b >= 0 && c >= 0) {
            ret = (b >= REQUIRED_X264_CORE || c >= REQUIRED_X264_REV) ? AUO_RESULT_SUCCESS : AUO_RESULT_ERROR;
        }
        if (ret & AUO_RESULT_ERROR) {
            char required_ver[128] = { 0 };
            char current_ver[128] = { 0 };
            sprintf_s(required_ver, _countof(required_ver), "Core:%4d, Rev: %4d", REQUIRED_X264_CORE, REQUIRED_X264_REV);
            sprintf_s(current_ver,  _countof(current_ver),  "Core:%4d, Rev: %4d", b, c);
            error_x264_version(required_ver, current_ver);
        }
    }
    return ret;
}