Humble script for creating the port's snapshots.
[AROS.git] / test / pipe / autopipe.c
blob4ace2e3345140da3114ae6d2679e7c2082e6b5e7
1 /*
2 * Copyright (C) 2012, The AROS Development Team. All rights reserved.
3 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
5 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
6 */
8 #include <proto/alib.h>
9 #include <proto/exec.h>
10 #include <proto/dos.h>
12 #include <aros/shcommands.h>
14 AROS_SH0(autopipe, 1.0)
16 AROS_SHCOMMAND_INIT
18 int err = RETURN_FAIL;
20 BPTR fhw;
21 if ((fhw = Open("PIPE:*", MODE_NEWFILE))) {
22 TEXT name[64];
24 if (NameFromFH(fhw, name, sizeof(name)) != 0) {
25 BPTR fhr;
27 Printf("PIPE:* => %s\n", name);
28 if ((fhr = Open(name, MODE_OLDFILE))) {
29 Write(fhw, "Hello", 5);
30 Read(fhr, name, 5);
31 name[5] = 0;
32 Close(fhr);
33 Printf("Hello => %s\n", name);
34 err = 0;
36 } else {
37 Printf("Can't get name, Error %d\n", IoErr());
39 Close(fhw);
40 } else {
41 Printf("Can't open PIPE:*\n");
44 return err;
46 AROS_SHCOMMAND_EXIT