A Simple X Image Viewer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* sxiv: util.h
  2. * Copyright (c) 2011 Bert Muennich <muennich at informatik.hu-berlin.de>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef UTIL_H
  19. #define UTIL_H
  20. #include <stdio.h>
  21. #include <stdarg.h>
  22. #include <dirent.h>
  23. #define ABS(a) ((a) < 0 ? (-(a)) : (a))
  24. #define MIN(a,b) ((a) < (b) ? (a) : (b))
  25. #define MAX(a,b) ((a) > (b) ? (a) : (b))
  26. #define LEN(a) (sizeof(a) / sizeof(a[0]))
  27. #define TIMEDIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec) * 1000 + \
  28. ((t1)->tv_usec - (t2)->tv_usec) / 1000)
  29. #define MSEC_TO_TIMEVAL(t,tv) { \
  30. (tv)->tv_sec = (t) / 1000; \
  31. (tv)->tv_usec = (t) % 1000 * 1000; \
  32. }
  33. #ifndef TIMESPEC_TO_TIMEVAL
  34. #define TIMESPEC_TO_TIMEVAL(tv,ts) { \
  35. (tv)->tv_sec = (ts)->tv_sec; \
  36. (tv)->tv_usec = (ts)->tv_nsec / 1000; \
  37. }
  38. #endif
  39. typedef struct {
  40. DIR *dir;
  41. char *name;
  42. int d;
  43. char **stack;
  44. int stcap;
  45. int stlen;
  46. } r_dir_t;
  47. void* s_malloc(size_t);
  48. void* s_realloc(void*, size_t);
  49. char* s_strdup(char*);
  50. void warn(const char*, ...);
  51. void die(const char*, ...);
  52. void size_readable(float*, const char**);
  53. char* absolute_path(const char*);
  54. int r_opendir(r_dir_t*, const char*);
  55. int r_closedir(r_dir_t*);
  56. char* r_readdir(r_dir_t*);
  57. int r_mkdir(const char *);
  58. #endif /* UTIL_H */