utils.h 669 B

12345678910111213141516171819202122232425
  1. #ifndef UTILS_H
  2. #define UTILS_H
  3. // http://c-faq.com/lib/randrange.html
  4. int randint(int N);
  5. // http://c-faq.com/lib/randrange.html
  6. // numbers in the range [M, N] could be generated with something like
  7. int randrange(int M, int N);
  8. int random_activate(int w);
  9. /**
  10. * Display a repr of the given string.
  11. *
  12. * This converts most \n\r\v\f\t codes,
  13. * defaults to \xHH (hex value).
  14. */
  15. char *repr(const char *data);
  16. const char *strnstr(const char *source, int len, const char *needle);
  17. int rstrnstr(const char *buffer, int len, const char *find);
  18. int string_insert(char *buffer, int max_length, int pos, const char *insert);
  19. void pcopy(char *pstring, char *str);
  20. #endif