Exemple #1
0
char* GeneratePassword(char* username, char* serviceName) {
	char* firstWord;
	char* secondWord; 
	char* thirdWord; 
	char* finalPassword;
	int firstLine = 0;
	int secondLine = 0;
	int thirdLine = 0;
	int i;

	for(i = 0; username[i] != '\n'; i++) {
		double factor = username[i] << CONSTANT_FACTOR;
		factor = (int) fmod(INT_MAX, factor);
		factor = factor - (i * CONSTANT_FACTOR);
		factor = (int) fmod(INT_MAX, factor);
		firstLine += (int) abs(factor);
	}
	firstLine = globals.numLines % firstLine;
	firstWord = GetLineFromFile(globals.dictionary, firstLine);

	for(i = 0; serviceName[i] != '\n'; i++) {
		double factor = serviceName[i] << CONSTANT_FACTOR;
		factor = (int) fmod(INT_MAX, factor);
		factor = factor + (i * CONSTANT_FACTOR);
		factor = (int) fmod(INT_MAX, factor);
		secondLine += (int) abs(factor);
	}
	secondLine = globals.numLines % secondLine;
	secondWord = GetLineFromFile(globals.dictionary, secondLine);

	for(i = 0; CONSTANT_WORD[i] != '\0'; i++) {
		double factor = CONSTANT_WORD[i] << CONSTANT_FACTOR;
		factor = (int) fmod(INT_MAX, factor);
		factor = factor - (i * firstLine);
		factor = (int) fmod(INT_MAX, factor);
		factor = factor + (i * secondLine);
		factor = (int) fmod(INT_MAX, factor);
		thirdLine += (int) abs(factor);
	}
	thirdLine = globals.numLines % secondLine;
	thirdWord = GetLineFromFile(globals.dictionary, thirdLine);

	size_t len1 = strlen(firstWord);
	size_t len2 = strlen(secondWord);
	size_t len3 = strlen(thirdWord);
	
	finalPassword = malloc(len1 + len2 + len3 + 3);
	snprintf(finalPassword, len1 + len2 + len3 + 3, "%s %s %s", firstWord, secondWord, thirdWord);
	
	free(firstWord);
	free(secondWord);
	free(thirdWord);

	return finalPassword;
}
Exemple #2
0
bool GetMoboInfo (const char *key, char *value)
{
    char path[256];
    sprintf (path, "%s%s", MOBO_BASE, key);

    return GetLineFromFile (path, value);
}
Exemple #3
0
void CLuaRemoteDebug::GetLuaCallStack(std::vector<SLuaStackEntry> &callstack)
{
	lua_State* L = m_pScriptSystem->GetLuaState();
	callstack.clear();

	int level = 0; 
	lua_Debug ar;
	string description;
	while (lua_getstack(L, level++, &ar))
	{
		description.clear();

		lua_getinfo(L, ("Sl"), &ar);
		if (ar.source && *ar.source && _stricmp(ar.source, "=C") != 0 && ar.linedefined != 0)
		{
			description = GetLineFromFile(ar.source + 1, ar.linedefined);
		}

		SLuaStackEntry se;
		se.description = description;
		se.line = ar.currentline;
		se.source = ar.source;

		callstack.push_back(se);
	}
}
Exemple #4
0
void PrintCpuModelVersion()
{
	char line[100];
	GetLineFromFile(CPU, line, 100);
	//printf("%s\n", line);

	char word[10];
	GetWordFromLine(line, word, 2, ":");
	printf("%s ", word);
}
Exemple #5
0
// Print functions
void PrintKernelVersion()
{
	char line[100];
	GetLineFromFile(VERSION, line, 100);
	//printf("%s\n", line);

	char word[10];
	GetWordFromLine(line, word, 3, " ");
	printf("%s\n", word);
}
Exemple #6
0
/**
 * Reads a property file.
 *
 * There are several property files, this code can read all
 * of those but will only make use of the properties it recognizes.
 *
 * @returns 0 on success.
 * @returns !0 on failure.
 * @param   pszBasePath         The base path, can be NULL.
 * @param   pszFilename     The name of the file.
 */
static int ReadProperties(const char *pszBasePath, const char *pszFilename)
{
    /*
     * Open input.
     */
    FILE *pFile = OpenFile(pszBasePath, pszFilename);
    if (!pFile)
        return 1;

    /*
     * Parse the input and spit out the output.
     */
    char szLine[4096];
    while (GetLineFromFile(szLine, sizeof(szLine), pFile) != NULL)
    {
        if (IsCommentOrBlankLine(szLine))
            continue;
        char *pszCurField;
        char *pszRange    = FirstField(&pszCurField, StripLine(szLine));
        char *pszProperty = NextField(&pszCurField);
        if (!*pszProperty)
        {
            ParseError("no property field.\n");
            continue;
        }

        RTUNICP LastCP;
        RTUNICP StartCP = ToRange(pszRange, &LastCP);
        if (StartCP == ~(RTUNICP)0)
            continue;

        while (StartCP <= LastCP)
            ApplyProperty(StartCP++, pszProperty, pszCurField);
    }

    CloseFile(pFile);

    return 0;
}
Exemple #7
0
void PrintTimeSinceBoot()
{
	char line[100];
	GetLineFromFile(BOOTTIME, line, 100);
	//printf("%s\n", line);
	
	char word[25];
	double num;
	GetWordFromLine(line, word, 1, " ");
	sscanf(word, "%lf", &num);
	
	int days = (int)num/86400;
	num = num - (days * 86400);
	
	int hours = (int)num/3600;
	num = num - (hours * 3600);
	
	int mins = (int)num/60;
	num = num - (mins * 60);
	
	int secs = (int)num;
	
	printf("%02d:%02d:%02d:%02d\n", days, hours, mins, secs);
}
Exemple #8
0
/**
 * Read the UnicodeData.txt file.
 * @returns 0 on success.
 * @returns !0 on failure.
 * @param   pszBasePath         The base path, can be NULL.
 * @param   pszFilename         The name of the file.
 */
static int ReadUnicodeData(const char *pszBasePath, const char *pszFilename)
{
    /*
     * Open input.
     */
    FILE *pFile = OpenFile(pszBasePath, pszFilename);
    if (!pFile)
        return 1;

    /*
     * Parse the input and spit out the output.
     */
    char szLine[4096];
    RTUNICP i = 0;
    while (GetLineFromFile(szLine, sizeof(szLine), pFile) != NULL)
    {
        if (IsCommentOrBlankLine(szLine))
            continue;

        char *pszCurField;
        char *pszCodePoint = FirstField(&pszCurField, StripLine(szLine)); /* 0 */
        char *pszName = NextField(&pszCurField);                          /* 1 */
        char *pszGeneralCategory = NextField(&pszCurField);               /* 2 */
        char *pszCanonicalCombiningClass = NextField(&pszCurField);       /* 3 */
        char *pszBidiClass = NextField(&pszCurField);                     /* 4 */
        char *pszDecompositionType = NextField(&pszCurField);             /* 5 */
        char *pszDecompositionMapping = SplitDecompField(&pszDecompositionType);
        char *pszNumericType = NextField(&pszCurField);                   /* 6 */
        char *pszNumericValueD = NextField(&pszCurField);                 /* 7 */
        char *pszNumericValueN = NextField(&pszCurField);                 /* 8 */
        char *pszBidiMirrored = NextField(&pszCurField);                  /* 9 */
        char *pszUnicode1Name = NextField(&pszCurField);                  /* 10 */
        char *pszISOComment = NextField(&pszCurField);                    /* 11 */
        char *pszSimpleUpperCaseMapping = NextField(&pszCurField);        /* 12 */
        char *pszSimpleLowerCaseMapping = NextField(&pszCurField);        /* 13 */
        char *pszSimpleTitleCaseMapping = NextField(&pszCurField);        /* 14 */

        RTUNICP CodePoint = ToNum(pszCodePoint);
        if (CodePoint >= RT_ELEMENTS(g_aCPInfo))
        {
            ParseError("U+05X is out of range\n", CodePoint);
            continue;
        }

        /* catchup? */
        while (i < CodePoint)
            NullEntry(i++);
        if (i != CodePoint)
        {
            ParseError("i=%d CodePoint=%u\n", i, CodePoint);
            CloseFile(pFile);
            return 1;
        }

        /* this one */
        g_aCPInfo[i].CodePoint = i;
        g_aCPInfo[i].fNullEntry = 0;
        g_aCPInfo[i].pszName                    = DupStr(pszName);
        g_aCPInfo[i].SimpleUpperCaseMapping     = ToNumDefault(pszSimpleUpperCaseMapping, CodePoint);
        g_aCPInfo[i].SimpleLowerCaseMapping     = ToNumDefault(pszSimpleLowerCaseMapping, CodePoint);
        g_aCPInfo[i].SimpleTitleCaseMapping     = ToNumDefault(pszSimpleTitleCaseMapping, CodePoint);
        g_aCPInfo[i].CanonicalCombiningClass    = ToNum(pszCanonicalCombiningClass);
        g_aCPInfo[i].pszDecompositionType       = DupStr(pszDecompositionType);
        g_aCPInfo[i].paDecompositionMapping     = ToMapping(pszDecompositionMapping, &g_aCPInfo[i].cDecompositionMapping, 20);
        g_aCPInfo[i].pszGeneralCategory         = DupStr(pszGeneralCategory);
        g_aCPInfo[i].pszBidiClass               = DupStr(pszBidiClass);
        g_aCPInfo[i].pszNumericType             = DupStr(pszNumericType);
        g_aCPInfo[i].pszNumericValueD           = DupStr(pszNumericValueD);
        g_aCPInfo[i].pszNumericValueN           = DupStr(pszNumericValueN);
        g_aCPInfo[i].pszBidiMirrored            = DupStr(pszBidiMirrored);
        g_aCPInfo[i].pszUnicode1Name            = DupStr(pszUnicode1Name);
        g_aCPInfo[i].pszISOComment              = DupStr(pszISOComment);
        i++;
    }

    /* catchup? */
    while (i < RT_ELEMENTS(g_aCPInfo))
        NullEntry(i++);
    CloseFile(pFile);

    return 0;
}
STRING GetStringFromKeyboard()
{
  fflush(stdin);
  return GetLineFromFile(stdin);
}