Пример #1
0
struct shortfile * getbcache(char* bname)
{
    register int i;
    resolve_boards();
    for (i = 0; i < numboards; i++)
        if (!ci_strncmp(bname, bcache[i].filename, STRLEN))
            return &bcache[i];
    return NULL;
}
Пример #2
0
int searchuser(char* userid)
{
    register int i;
    resolve_ucache();
    //	for (i = 0; i < uidshm->number; i++)
    for (i = 0; i < MAXUSERS; i++)
        if (!ci_strncmp(userid, uidshm->userid[i], IDLEN + 1))
            return i + 1;
    return 0;
}
Пример #3
0
int getbnum(char *bname)
{
    register int i;
    resolve_boards();

    for (i = 0; i < numboards; i++)
    {
        if(bcache[i].level & PERM_POSTMASK || HAS_PERM(bcache[i].level)
                ||(bcache[i].level & PERM_NOZAP))
        {
            if (!ci_strncmp(bname, bcache[i].filename, STRLEN))
                return i + 1;
        }
    }
    return 0;
}
Пример #4
0
int bbssetenv(char* env, char* val)
{
	register int i, len;
	if (numbbsenvs == 0)
		bbsenv[0] = NULL;
	len = strlen(env);
	for (i = 0; bbsenv[i]; i++)
		if (!ci_strncmp(env, bbsenv[i], len))
			break;
	if (i >= MAXENVS)
		return -1;
	if (bbsenv[i])
		free(bbsenv[i]);
	else
		bbsenv[++numbbsenvs] = NULL;
	bbsenv[i] = malloc(strlen(env) + strlen(val) + 2);
	strcpy(bbsenv[i], env);
	strcat(bbsenv[i], "=");
	strcat(bbsenv[i], val);
	return 0;
}
Пример #5
0
/**************************************************************************
 *      load_datafile_text
 *
 *      Loads text field for a driver into the buffer specified. Specify the
 *      driver, a pointer to the buffer, the buffer size, the index created by
 *      index_datafile(), and the desired text field (e.g., DATAFILE_TAG_BIO).
 *
 *      Returns 0 if successful.
 **************************************************************************/
static int load_datafile_text (const struct GameDriver *drv, char *buffer, int bufsize,
        struct tDatafileIndex *idx, const char *tag)
{
        int     offset = 0;
        int found = 0;
        UINT32  token = TOKEN_SYMBOL;
        UINT32  prev_token = TOKEN_SYMBOL;

        *buffer = '\0';

        /* find driver in datafile index */
        while (idx->driver)
        {

                if (idx->driver == drv) break;

                idx++;
        }
        if (idx->driver == 0) return 1; /* driver not found in index */

        /* seek to correct point in datafile */
        if (ParseSeek (idx->offset, SEEK_SET)) return 1;

        /* read text until buffer is full or end of entry is encountered */
        while (TOKEN_INVALID != token)
        {
                char *s;
                int len;
                long tell;

                token = GetNextToken (&s, &tell);
                if (TOKEN_INVALID == token) continue;

                if (found)
                {
                        /* end entry when a tag is encountered */
                        if (TOKEN_SYMBOL == token && DATAFILE_TAG == s[0] && TOKEN_LINEBREAK == prev_token) break;

                        prev_token = token;

                        /* translate platform-specific linebreaks to '\n' */
                        if (TOKEN_LINEBREAK == token)
                                strcpy (s, "\n");

                        /* append a space to words */
                        if (TOKEN_LINEBREAK != token)
                                strcat (s, " ");

                        /* remove extraneous space before commas */
                        if (TOKEN_COMMA == token)
                        {
                                --buffer;
                                --offset;
                                *buffer = '\0';
                        }

                        /* Get length of text to add to the buffer */
                        len = strlen (s);

                        /* Check for buffer overflow */
                        /* For some reason we can get a crash if we try */
                        /* to use the last 30 characters of the buffer  */
                        if ((bufsize - offset) - len <= 45)
                        {
                            strcpy (s, " ...[TRUNCATED]");
                            len = strlen(s);
                            strcpy (buffer, s);
                            buffer += len;
                            offset += len;
                            break;
                        }

                        /* add this word to the buffer */
                        strcpy (buffer, s);
                        buffer += len;
                        offset += len;
                }
                else
                {
                        if (TOKEN_SYMBOL == token)
                        {
                                /* looking for requested tag */
                                if (!ci_strncmp (tag, s, strlen (tag)))
                                        found = 1;
                                else if (!ci_strncmp (DATAFILE_TAG_KEY, s, strlen (DATAFILE_TAG_KEY)))
                                        break; /* error: tag missing */
                        }
                }
        }
        return (!found);
}
Пример #6
0
/**************************************************************************
 *      index_datafile
 *      Create an index for the records in the currently open datafile.
 *
 *      Returns 0 on error, or the number of index entries created.
 **************************************************************************/
static int index_datafile (struct tDatafileIndex **_index)
{
        struct tDatafileIndex *idx;
        int count = 0;
        UINT32 token = TOKEN_SYMBOL;

        /* rewind file */
        if (ParseSeek (0L, SEEK_SET)) return 0;

        /* allocate index */
        idx = *_index = malloc (MAX_DATAFILE_ENTRIES * sizeof (struct tDatafileIndex));
        if (NULL == idx) return 0;

        /* loop through datafile */
        while ((count < (MAX_DATAFILE_ENTRIES - 1)) && TOKEN_INVALID != token)
        {
                long tell;
                char *s;

                token = GetNextToken (&s, &tell);
                if (TOKEN_SYMBOL != token) continue;

                /* DATAFILE_TAG_KEY identifies the driver */
                if (!ci_strncmp (DATAFILE_TAG_KEY, s, strlen (DATAFILE_TAG_KEY)))
                {
                        token = GetNextToken (&s, &tell);
                        if (TOKEN_EQUALS == token)
                        {
                                int done = 0;

                                token = GetNextToken (&s, &tell);
                                while (!done && TOKEN_SYMBOL == token)
                                {
									int game_index;
									char *p;
									for (p = s; *p; p++)
										*p = tolower(*p);

									game_index = GetGameNameIndex(s);
									if (game_index >= 0)
									{
										idx->driver = drivers[game_index];
										idx->offset = tell;
										idx++;
										count++;
										/* done = 1;  Not done, as we must process other clones in list */

									}
									if (!done)
									{
										token = GetNextToken (&s, &tell);

										if (TOKEN_COMMA == token)
											token = GetNextToken (&s, &tell);
										else
											done = 1; /* end of key field */
									}
                                }
                        }
                }
        }

        /* mark end of index */
        idx->offset = 0L;
        idx->driver = 0;
        return count;
}