getenv 685 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. .TH GETENV 2
  2. .SH NAME
  3. getenv, putenv \- access environment variables
  4. .SH SYNOPSIS
  5. .B #include <u.h>
  6. .br
  7. .B #include <libc.h>
  8. .PP
  9. .nf
  10. .B
  11. char* getenv(char *name)
  12. .br
  13. .B
  14. int putenv(char *name, char *val)
  15. .fi
  16. .SH DESCRIPTION
  17. .I Getenv
  18. reads the contents of
  19. .BI /env/ name
  20. (see
  21. .IR env (3))
  22. into memory allocated with
  23. .IR malloc (2),
  24. 0-terminates it,
  25. and returns a pointer to that area.
  26. If no file exists, 0
  27. is returned.
  28. .PP
  29. .I Putenv
  30. creates the file
  31. .BI /env/ name
  32. and writes the string
  33. .I val
  34. to it. The terminating
  35. .B 0
  36. is not written.
  37. If the file value cannot be written, \-1 is returned.
  38. .SH SOURCE
  39. .B /sys/src/libc/9sys
  40. .SH SEE ALSO
  41. .IR env (3)
  42. .SH DIAGNOSTICS
  43. Sets
  44. .IR errstr .