ofstdio.c 767 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (C) Paul Mackerras 1997.
  3. * Copyright (C) Leigh Brown 2002.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version
  8. * 2 of the License, or (at your option) any later version.
  9. */
  10. #include "of1275.h"
  11. int
  12. ofstdio(ihandle *stdin, ihandle *stdout, ihandle *stderr)
  13. {
  14. ihandle in, out;
  15. phandle chosen;
  16. if ((chosen = finddevice("/chosen")) == OF_INVALID_HANDLE)
  17. goto err;
  18. if (getprop(chosen, "stdout", &out, sizeof(out)) != 4)
  19. goto err;
  20. if (getprop(chosen, "stdin", &in, sizeof(in)) != 4)
  21. goto err;
  22. *stdin = in;
  23. *stdout = out;
  24. *stderr = out;
  25. return 0;
  26. err:
  27. return -1;
  28. }