Beispiel #1
0
int GetContentLen( char *Header )
{
	char *ContentLength = NULL;

	if ( GetText( Header, &ContentLength, HeaderContentLength, "\r\n" ) != -1 )
		return m_atoi( ContentLength ) + m_lstrlen( Header );

	return -1;
}
Beispiel #2
0
bool secfile_t::read_int(int &i)
{
	const char* buf = get_next_line();
	/*if(!*buf) {
			throw mk_error("Expected a non-empty number");
		}*/
	++line; // ??
	return (m_atoi(i, buf))
		? clear_buffer(), true
		: false;
}
Beispiel #3
0
int main(int argc, char* argv[]) 
{
    unsigned int num = 616;

    printf("%d\n", argv[1] ? m_atoi(argv[1]) : num);
    printf("%d\n", argv[1] ? atoi(argv[1]) : num);

    printf("%d\n", argv[1] ? reverse(atoi(argv[1])) : reverse(num));
    
    printf("%d\n", argv[1] ? isPalindrome(atoi(argv[1])) : isPalindrome(num));

    return 0;
}
Beispiel #4
0
int GetDelay()
{
	MDBG_Config("Config","GetDelay");
	PCHAR Str = NULL;
	#ifdef DEBUGCONFIG
		Str = DebugDelay;
	#else
		Str = Delay;
	#endif

	int V = 0;
	if (Str != NULL)
		V = m_atoi(Str);

	if (V == 0)
		V = DEFAULT_DELAY;

	return V;
}
Beispiel #5
0
int		read_head(int fd, t_map *map)
{
	char	*temp;
	if (map->stats[3] < 4)
		return (-1);
	temp = (char *) malloc(sizeof(map->stats[3]));
	if (read(fd, temp, map->stats[3]) < 0)
		return (-2);
	map->stats[3]--;
	map->cset[2] = temp[map->stats[3]--];
	map->cset[1] = temp[map->stats[3]--];
	map->cset[0] = temp[map->stats[3]--];
	map->stats[1] = m_atoi(temp, map->stats[3] + 1);
	map->stats[3] += 3;
	if (map->stats[1] < 1)
		return (-3);
	read(fd, temp, 1);
	return (1);
}
Beispiel #6
0
static int
seq_init (struct msgs *mp, char *name, char *field)
{
    unsigned int i;
    int j, k, is_current;
    char *cp, **ap;

    /*
     * Check if this is "cur" sequence,
     * so we can do some special things.
     */
    is_current = !strcmp (current, name);

    /*
     * Search for this sequence name to see if we've seen
     * it already.  If we've seen this sequence before,
     * then clear the bit for this sequence from all the
     * mesages in this folder.
     */
    for (i = 0; i < svector_size (mp->msgattrs); i++) {
	if (!strcmp (svector_at (mp->msgattrs, i), name)) {
	    for (j = mp->lowmsg; j <= mp->hghmsg; j++)
		clear_sequence (mp, i, j);
	    break;
	}
    }

    /*
     * If we've already seen this sequence name, just free the
     * name string.  Else add it to the list of sequence names.
     */
    if (svector_at (mp->msgattrs, i)) {
	free (name);
    } else {
	svector_push_back (mp->msgattrs, name);
    }

    /*
     * Split up the different message ranges at whitespace
     */
    for (ap = brkstring (field, " ", "\n"); *ap; ap++) {
	if ((cp = strchr(*ap, '-')))
	    *cp++ = '\0';
	if ((j = m_atoi (*ap)) > 0) {
	    k = cp ? m_atoi (cp) : j;

	    /*
	     * Keep mp->curmsg and "cur" sequence in synch.  Unlike
	     * other sequences, this message doesn't need to exist.
	     * Think about the series of command (rmm; next) to
	     * understand why this can be the case.  But if it does
	     * exist, we will still set the bit flag for it like
	     * other sequences.
	     */
	    if (is_current)
		mp->curmsg = j;
	    /*
	     * We iterate through messages in this range
	     * and flip on bit for this sequence.
	     */
	    for (; j <= k; j++) {
		if (j >= mp->lowmsg && j <= mp->hghmsg && does_exist(mp, j))
		    add_sequence (mp, i, j);
	    }
	}
    }

    free (field);	/* free string containing message ranges */
    return i;
}
Beispiel #7
0
bool ParseUrl1( char *Url, char **Server, char **Path, int *Port )
{
	char *Ptr1 = NULL;
	char *Ptr2 = NULL;
	char *Ptr3 = NULL;
	char *Ptr4 = NULL;

	char *Host		   = (char*)MemAlloc( 512 );
	char *OptionalPort = (char*)MemAlloc( 512 );

	if ( Host == NULL ||
		 OptionalPort == NULL )
	{
		return false;
	}

	DWORD dwPort = 0;

	Ptr1 = m_strstr( Url, "://" );

	if( Ptr1 )
	{
		Ptr1 += 3;
	}
	else
	{
		Ptr1 = Url;
	}

    Ptr4 = m_strstr( Ptr1, "/" );
	Ptr2 = m_strstr( Ptr1, ":" );

	if( !Ptr2 )
	{
		*Port = 80;
		Ptr3   = m_strstr( Ptr1, "/" );

		if( !Ptr3 )
		{
			return false;
		}

		m_memcpy( Host, Ptr1, Ptr3 - Ptr1 );
		Host[ Ptr3 - Ptr1 ] = '\0';
	}
	else
	{
		Ptr3 = m_strstr( Ptr1, "/" );

		if( !Ptr3 )
		{
			return false;
		}

		m_memcpy( OptionalPort, Ptr2 + 1, Ptr3 - Ptr2 );
		m_memcpy( Host, Ptr1, Ptr2 - Ptr1 );

		OptionalPort[ Ptr3 - Ptr2 ] = '\0';
		Host[ Ptr2 - Ptr1 ]			= '\0';

		*Port = m_atoi( OptionalPort );
	}

	MemFree( OptionalPort );

	*Server = Host;
	*Path   = Ptr4;

	return true;
}