machdep.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright (c) 1991 by the Vrije Universiteit, Amsterdam, the Netherlands.
  2. * For full copyright and restrictions on use see the file COPYING in the top
  3. * level of the LLgen tree.
  4. */
  5. /*
  6. * L L G E N
  7. *
  8. * An Extended LL(1) Parser Generator
  9. *
  10. * Author : Ceriel J.H. Jacobs
  11. */
  12. /*
  13. * machdep.c
  14. * Machine dependant things
  15. */
  16. #include <stdlib.h>
  17. #include <string.h>
  18. # include "types.h"
  19. # ifndef NORCSID
  20. static string rcsid5 = "$Id$";
  21. # endif
  22. /* In this file the following routines are defined: */
  23. //extern UNLINK();
  24. //extern RENAME();
  25. //extern string libpath();
  26. UNLINK(x) string x; {
  27. /* Must remove the file "x" */
  28. #ifdef USE_SYS
  29. sys_remove(x); /* systemcall to remove file */
  30. #else
  31. unlink(x);
  32. #endif
  33. }
  34. RENAME(x,y) string x,y; {
  35. /* Must move the file "x" to the file "y" */
  36. #ifdef USE_SYS
  37. if(! sys_rename(x,y)) fatal(1,"Cannot rename to %s",y);
  38. #else
  39. if (rename(x, y) == -1)
  40. fatal(1, "Cannot rename to %s", y);
  41. #endif
  42. }
  43. string
  44. libpath(s) string s; {
  45. /* Must deliver a full pathname to the library file "s" */
  46. register string p;
  47. register length;
  48. p_mem alloc();
  49. // string strcpy(), strcat();
  50. char* libdir = getenv("LLGEN_LIB_DIR");
  51. if (!libdir)
  52. libdir = LIBDIR;
  53. length = strlen(libdir) + strlen(s) + 2;
  54. p = (string) alloc((unsigned) length);
  55. strcpy(p,libdir);
  56. strcat(p,"/");
  57. strcat(p,s);
  58. return p;
  59. }