My slstatus configuration
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 

44 рядки
688 B

  1. /* See LICENSE file for copyright and license details. */
  2. #include <err.h>
  3. #include <errno.h>
  4. #include <stdarg.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include "util.h"
  8. const char *
  9. bprintf(const char *fmt, ...)
  10. {
  11. va_list ap;
  12. size_t len;
  13. va_start(ap, fmt);
  14. len = vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
  15. va_end(ap);
  16. if (len >= sizeof(buf))
  17. buf[sizeof(buf)-1] = '\0';
  18. return buf;
  19. }
  20. int
  21. pscanf(const char *path, const char *fmt, ...)
  22. {
  23. FILE *fp;
  24. va_list ap;
  25. int n;
  26. if (!(fp = fopen(path, "r"))) {
  27. warn("fopen %s: %s\n", path, strerror(errno));
  28. return -1;
  29. }
  30. va_start(ap, fmt);
  31. n = vfscanf(fp, fmt, ap);
  32. va_end(ap);
  33. fclose(fp);
  34. return (n == EOF) ? -1 : n;
  35. }