unixsysc.inc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {
  2. $Id$
  3. This file is part of the Free Component Library (FCL)
  4. Copyright (c) 1999-2000 by Peter Vreman
  5. Darwin temporary pclose/assignpipe implementation
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. Function PClose(Var F:file) : cint;
  13. var
  14. pl : ^cint;
  15. res : cint;
  16. begin
  17. fpclose(filerec(F).Handle);
  18. { closed our side, Now wait for the other - this appears to be needed ?? }
  19. pl:=@(filerec(f).userdata[2]);
  20. fpwaitpid(pl^,@res,0);
  21. pclose:=res shr 8;
  22. end;
  23. Function PClose(Var F:text) :cint;
  24. var
  25. pl : ^longint;
  26. res : longint;
  27. begin
  28. fpclose(Textrec(F).Handle);
  29. { closed our side, Now wait for the other - this appears to be needed ?? }
  30. pl:=@(textrec(f).userdata[2]);
  31. fpwaitpid(pl^,@res,0);
  32. pclose:=res shr 8;
  33. end;
  34. // can't have oldfpccall here, linux doesn't need it.
  35. Function AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
  36. {
  37. Sets up a pair of file variables, which act as a pipe. The first one can
  38. be read from, the second one can be written to.
  39. If the operation was unsuccesful, linuxerror is set.
  40. }
  41. var
  42. ret : longint;
  43. errn : cint;
  44. fdis : array[0..1] of cint;
  45. begin
  46. fdis[0]:=pipe_in;
  47. fdis[1]:=pipe_out;
  48. ret:=pipe(fdis);
  49. pipe_in:=fdis[0];
  50. pipe_out:=fdis[1];
  51. AssignPipe:=ret;
  52. end;
  53. {
  54. $Log$
  55. Revision 1.1 2004-01-04 20:05:38 jonas
  56. * first working version of the Darwin/Mac OS X (for PowerPC) RTL
  57. Several non-essential units are still missing, but make cycle works
  58. }