Configuration of dwm for Mac Computers
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.

94 lines
1.3 KiB

18 years ago
18 years ago
18 years ago
  1. /*
  2. * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
  3. * See LICENSE file for license details.
  4. */
  5. #include <stdarg.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <sys/types.h>
  10. #include <sys/wait.h>
  11. #include <unistd.h>
  12. #include "wm.h"
  13. void
  14. error(const char *errstr, ...) {
  15. va_list ap;
  16. va_start(ap, errstr);
  17. vfprintf(stderr, errstr, ap);
  18. va_end(ap);
  19. exit(1);
  20. }
  21. static void
  22. bad_malloc(unsigned int size)
  23. {
  24. fprintf(stderr, "fatal: could not malloc() %d bytes\n",
  25. (int) size);
  26. exit(1);
  27. }
  28. void *
  29. emallocz(unsigned int size)
  30. {
  31. void *res = calloc(1, size);
  32. if(!res)
  33. bad_malloc(size);
  34. return res;
  35. }
  36. void *
  37. emalloc(unsigned int size)
  38. {
  39. void *res = malloc(size);
  40. if(!res)
  41. bad_malloc(size);
  42. return res;
  43. }
  44. void *
  45. erealloc(void *ptr, unsigned int size)
  46. {
  47. void *res = realloc(ptr, size);
  48. if(!res)
  49. bad_malloc(size);
  50. return res;
  51. }
  52. char *
  53. estrdup(const char *str)
  54. {
  55. char *res = strdup(str);
  56. if(!res)
  57. bad_malloc(strlen(str));
  58. return res;
  59. }
  60. void
  61. swap(void **p1, void **p2)
  62. {
  63. void *tmp = *p1;
  64. *p1 = *p2;
  65. *p2 = tmp;
  66. }
  67. void
  68. spawn(char *argv[])
  69. {
  70. if(!argv || !argv[0])
  71. return;
  72. if(fork() == 0) {
  73. if(fork() == 0) {
  74. if(dpy)
  75. close(ConnectionNumber(dpy));
  76. setsid();
  77. execvp(argv[0], argv);
  78. fprintf(stderr, "dwm: execvp %s", argv[0]);
  79. perror(" failed");
  80. }
  81. exit (0);
  82. }
  83. wait(0);
  84. }