#ifndef _CLIB_H
#define _CLIB_H

// varargs functions better be done with macros, because they're not
// inline'able
#define printf(_fmt, _args...) \
  ({ void *_argv[] = { _args }; VPrintf (_fmt, _argv); })

extern inline const char *
index (const char *s, char ch)
{
  char *sp = (char *) s;

  do
    if (*sp == ch)
      return (const char *) sp;
  while (*++sp);
  return 0;
}

extern inline const char *
rindex (const char *s, char ch)
{
  char *last = 0;
  do
    if (*s == ch)
      last = (char *) s;
  while (*++s);
  return (const char *) last;
}

extern inline u_long
strlen (const char *s)
{
  const char *start = s;
  while (*s++) ;
  return s - start;
}

extern inline char *
strcpy (char *d, const char *s)
{
  char *tgt = d;
  while (*d++ = *s++) ;
  return tgt;
}

#endif /* _CLIB_H */
