deprecated.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* Copyright 2003-2004,2006,2008-2018
  2. Free Software Foundation, Inc.
  3. This file is part of Guile.
  4. Guile is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Lesser General Public License as published
  6. by the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. Guile is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  11. License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with Guile. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifdef HAVE_CONFIG_H
  16. # include <config.h>
  17. #endif
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include <unistd.h>
  21. #define SCM_BUILDING_DEPRECATED_CODE
  22. #include "deprecation.h"
  23. #include "gc.h"
  24. #include "deprecated.h"
  25. #if (SCM_ENABLE_DEPRECATED == 1)
  26. #ifndef MAXPATHLEN
  27. #define MAXPATHLEN 80
  28. #endif /* ndef MAXPATHLEN */
  29. #ifndef X_OK
  30. #define X_OK 1
  31. #endif /* ndef X_OK */
  32. char *
  33. scm_find_executable (const char *name)
  34. {
  35. char tbuf[MAXPATHLEN];
  36. int i = 0, c;
  37. FILE *f;
  38. scm_c_issue_deprecation_warning ("scm_find_executable is deprecated.");
  39. /* fprintf(stderr, "s_f_e checking access %s ->%d\n", name, access(name, X_OK)); fflush(stderr); */
  40. if (access (name, X_OK))
  41. return 0L;
  42. f = fopen (name, "r");
  43. if (!f)
  44. return 0L;
  45. if ((fgetc (f) == '#') && (fgetc (f) == '!'))
  46. {
  47. while (1)
  48. switch (c = fgetc (f))
  49. {
  50. case /*WHITE_SPACES */ ' ':
  51. case '\t':
  52. case '\r':
  53. case '\f':
  54. case EOF:
  55. tbuf[i] = 0;
  56. fclose (f);
  57. return strdup (tbuf);
  58. default:
  59. tbuf[i++] = c;
  60. break;
  61. }
  62. }
  63. fclose (f);
  64. return strdup (name);
  65. }
  66. void
  67. scm_i_init_deprecated ()
  68. {
  69. #include "deprecated.x"
  70. }
  71. #endif /* SCM_ENABLE_DEPRECATD == 1 */