Project 1 - Peer-to-peer and interface protocols using C  1.0
A half-duplex layered communication system.
 All Classes Files Functions Macros
layer.h
Go to the documentation of this file.
1 #ifndef LAYER_H
2 #define LAYER_H
3 
4 
20 
21 
29 
30 //--------------------------------------------------------------------- :Global:
31 // ___ _ _ _
32 // / __| |___| |__ __ _| |
33 // | (_ | / _ \ '_ \/ _` | |
34 // \___|_\___/_.__/\__,_|_|
35 //
36 // -----------------------------------------------------------------------------
37 #define MAX_CHUNK_SIZE 16 /* sets chunk for all layers as 16 bytes */
38 #define LAYER 0 /* 1-5 for testing. 0 for normal use */
39 //------------------------------------------------------------------ :Libraries:
40 // _ _ _ _
41 // | | (_) |__ _ _ __ _ _ _(_)___ ___
42 // | |__| | '_ \ '_/ _` | '_| / -_|_-<
43 // |____|_|_.__/_| \__,_|_| |_\___/__/
44 //
45 // -----------------------------------------------------------------------------
46 #include <stdio.h> /* printf, fprintf, etc */
47 #include <unistd.h> /* need this for read(), write() */
48 #include <stdlib.h> /* needed for exit() */
49 #include <string.h> /* strlen, etc */
50 /* ------------------------------------------------------------------- :Student:
51  * ___ _ _ _
52  * / __| |_ _ _ __| |___ _ _| |_
53  * \__ \ _| || / _` / -_) ' \ _|
54  * |___/\__|\_,_\__,_\___|_||_\__|
55  *
56  * -------------------------------------------------------------------------- */
57 typedef struct
58 {
59  char * firstname;
60  char * lastname;
61  int rin;
62  double gpa;
63 } student;
64 
65 extern void print_title( int num, FILE * mode, char* title );
66 extern int my_pow(int x, int n);
67 extern int bin_exp(int num);
68 extern void itozstring( char * o_buff, int num, int len );
69 extern int stonum( char * i_buff, int len );
70 extern double stodoub( char * i_buff );
72 extern int layer1_read( char * b );
73 extern int layer1_write( char b );
74 extern int layer2_write( char * chunk, int len );
75 extern int layer2_read( char * chunk, int max );
76 extern int layer3_write( char * msg, int len );
77 extern int layer3_read( char * msg, int max );
78 extern int layer4_write( char * msg, int len );
79 extern int layer4_read( char * msg, int max );
80 extern int layer5_write( student * stu );
81 extern int layer5_read( student * stu );
82 //--------------------------------------------------------------------- :Layers:
83 // _
84 // | | __ _ _ _ ___ _ _ ___
85 // | |__/ _` | || / -_) '_(_-<
86 // |____\__,_|\_, \___|_| /__/
87 // |__/
88 // -----------------------------------------------------------------------------
90 // Layer 1
92 #if ( LAYER >= 1 )
93 #include "layer1.c"
94 #endif /* LAYER1 */
95 
96 // Layer 2
98 #if ( LAYER >= 2 )
99 #include "layer2.c"
100 #endif /* LAYER2 */
101 
102 // Layer 3
104 #if ( LAYER >= 3 )
105 #include "layer3.c"
106 #endif /* LAYER3 */
107 
108 // Layer 4
110 #if ( LAYER >= 4 )
111 #include "layer4.c"
112 #endif /* LAYER4 */
113 
114 // Layer 5
116 #if ( LAYER >= 5 )
117 #include "layer5.c"
118 #endif /* LAYER5 */
119 
120 #endif /* LAYER_H */