i am a dumb dummy
[oweals/gnunet.git] / src / transport / test_plugin_transport_wlan_dummy.c
1 /*\r
2          This file is part of GNUnet.
3      (C) 2010 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file transport/test_transport_wlan_dummy.c
22  * @brief helper for the testcase for plugin_transport_wlan.c
23  * @author David Brodski
24  */
25
26 #include "platform.h"
27 #include "gnunet_constants.h"
28 #include "gnunet_os_lib.h"
29 #include "gnunet_transport_plugin.h"
30 #include "transport.h"
31 #include "plugin_transport_wlan.h"
32 #include "gnunet_common.h"
33 #include "gnunet-transport-wlan-helper.h"
34 #include "plugin_transport_wlan.h"
35
36 #include <stdio.h>\r
37 #include <stdlib.h>\r
38 #include <sys/stat.h>\r
39 \r
40 #define FIFO_FILE1       "MYFIFOin"\r
41 #define FIFO_FILE2       "MYFIFOout"
42
43 int
44 main(int argc, char *argv[])
45 {
46         struct stat st;
47         int erg;
48         int first;
49         FILE *fpin;
50         FILE *fpout;
51         //make the fifos if needed
52         if(stat(FIFO_FILE1,&st) != 0){
53                 if(stat(FIFO_FILE2,&st) != 0){
54                                 perror("FIFO 2 exists, but FIFO 1 not");\r
55                 exit(1);
56                 }
57                 first = 1;
58                 umask(0);
59                 erg = mknod(FIFO_FILE1, S_IFIFO|0666, 0);
60                 erg = mknod(FIFO_FILE2, S_IFIFO|0666, 0);
61
62                 if((fpin = fopen(FIFO_FILE1, "r")) == NULL) {\r
63                 perror("fopen");\r
64                 exit(1);\r
65         }
66                 if((fpout = fopen(FIFO_FILE2, "w")) == NULL) {\r
67                 perror("fopen");\r
68                 exit(1);\r
69         }
70         } else {
71                 first = 0;
72                 if(stat(FIFO_FILE2,&st) == 0){
73                                 perror("FIFO 1 exists, but FIFO 2 not");\r
74                 exit(1);
75                 }
76                 if((fpout = fopen(FIFO_FILE1, "w")) == NULL) {\r
77                 perror("fopen");\r
78                 exit(1);\r
79         }
80                 if((fpin = fopen(FIFO_FILE2, "r")) == NULL) {\r
81                 perror("fopen");\r
82                 exit(1);\r
83         }
84
85         }
86         // Write the input to the output\r
87 \r
88         //clean up\r
89         if (first == 1){\r
90                 unlink(FIFO_FILE1);\r
91                 unlink(FIFO_FILE2);\r
92         }\r
93 \r
94 \r
95         fclose(fpin);\r
96         fclose(fpout);\r
97     return(0);\r
98 }\r
99