HTTP Parser and message builder / objects in plain C Snapshot
Functions
sutils.h File Reference

Go to the source code of this file.

Functions

M_INLINE int is_space (char ch)
M_INLINE char * skip_spaces (char *line)
M_INLINE char * skip_non_spaces (char *line)
M_INLINE char * get_token (char *line, char **eof)
M_INLINE char * strdup_range (char *from, char *to)

Function Documentation

M_INLINE char* get_token ( char *  line,
char **  eof 
)

Definition at line 35 of file sutils.h.

{
  char *ret;

  ret = skip_spaces( line );
  if (*ret == '\0') {
    *eof = ret;
    return 0;
  }
  *eof = skip_non_spaces( ret );
  return ret;
}
M_INLINE int is_space ( char  ch)

Definition at line 12 of file sutils.h.

{
  return ch == ' ' || ch == '\t';
}
M_INLINE char* skip_non_spaces ( char *  line)

Definition at line 26 of file sutils.h.

{
  char *pos;

  for( pos = line; *pos != '\0' && ! is_space( *pos ) ; ++pos );

  return pos;
}
M_INLINE char* skip_spaces ( char *  line)

Definition at line 17 of file sutils.h.

{
  char *pos;

  for( pos = line; is_space( *pos ) ; ++pos );

  return pos;
}
M_INLINE char* strdup_range ( char *  from,
char *  to 
)

Definition at line 48 of file sutils.h.

                                                  {
  char *r;

  r = malloc( to - from + 1 );
  if (!r) {
    return 0;
  }

  strncpy( r, from, to - from  );
  r[ to - from ] = '\0';
  
  return r;
}