33#include <fcntl.h>
44#include <unistd.h>
55#include <string.h>
6- #include <sys/ioctl.h>
76#include <stdlib.h>
8- #include "clientBridge .h"
7+ #include "moduleImplement/bridgeLink .h"
98#include "constants.h"
109#include "utilsClientBridge.h"
1110
1211char * * argsv ;
1312int argsc ;
1413
15- void write_message (int fd , unsigned long command , char * message ){
16- if (ioctl (fd , command , message ) == -1 ){
17- perror ("Write message error at ioctl" );
18- }
19- }
20-
21- void read_message (int fd , unsigned long command , char * message ){
22- if (ioctl (fd , command , message ) == -1 ){
23- perror ("Read message error at ioctl" );
24- }else {
25- printf ("Copy the messsage from the kernel\n" );
26- }
27- }
28-
29- void read_message_param (int fd , unsigned long command , int * value ){
30- if (ioctl (fd , command , value ) == -1 ){
31- perror ("Read message param error at ioctl" );
32- }else {
33- printf ("Copy the messsage from the kernel\n" );
34- }
35- }
36-
37- void write_int (int fd , unsigned long command , int * value ){
38- if (ioctl (fd , command , value ) == -1 ){
39- perror ("Write int error at ioctl" );
40- }
41- }
42-
43- void read_int (int fd , unsigned long command , int * value ){
44- if (ioctl (fd , command , value ) == -1 ){
45- perror ("Read int error at ioctl" );
46- }else {
47- printf ("Copy the int from the kernel\n" );
48- }
49- }
50-
51- int send_empty_command (int fd , unsigned long command ){
52- int result = ioctl (fd , command );
53- if ( result == -1 ){
54- perror ("Send command error at ioctl" );
55- }else {
56- printf ("Command OK to the kernel\n" );
57- }
58- return result ;
59- }
60-
61- void write_several_messages (int fd ){
62- write_message (fd , BRIDGE_W_S , "Message 1" );
63- write_message (fd , BRIDGE_W_S , "Message 2" );
64- write_message (fd , BRIDGE_W_S , "Message 3" );
65- }
66-
67- void read_all_messages (int fd ){
68- char message [100 ];
69- while ( send_empty_command (fd , BRIDGE_STATE_S ) > 0 ){
70- read_message (fd , BRIDGE_R_S , message );
71- printf ("Message: %s\n" , message );
72- }
73- }
74-
75- int callModule (){
76- const char * file_name = "/dev/bridgeOwn" ; //used by ioctl
77- int fd ;
78-
79- fd = open (file_name , O_RDWR );
80- if (fd == -1 ){
81- perror ("Bridge ioctl file open" );
82- return 2 ;
83- }
84- }
85-
8614void usageMenu (){
8715 printf ("uso: clientBridge [--help] \n" );
8816 printf ("\n" );
@@ -109,26 +37,19 @@ char* getPathFile(){
10937 return pathfile ;
11038}
11139
112- void validarSimetria (int fd ,char * * file ,int numOfLines ){
113- char test [100 ];
114- ioctl (fd , BRIDGE_W_S , "Hola este es un mensaje a la pila \n" );
115- ioctl (fd , BRIDGE_R_S , test );
116- printf ("%s\n" ,test );
117- }
118-
11940void chooseOption (char * option ){
12041
121- int fd = callModule ();
12242 char * pathfile = getPathFile ();
12343 int numOfLines = 0 ;
12444 char * * linesArray = readFile (pathfile ,& numOfLines );
12545
12646 if (strcmp (ORDEN_INVERSO , option ) == 0 ){
47+ ordenInverso (linesArray , numOfLines );
12748
12849 }else if (strcmp (RANDOM , option ) == 0 ){
12950
13051 }else if (strcmp (VALIDAR_SIMETRIA , option ) == 0 ){
131- validarSimetria (fd , linesArray ,numOfLines );
52+ validarSimetria (linesArray , numOfLines );
13253
13354 }else if (strcmp (COLA_PRIORIDAD , option ) == 0 ){
13455
@@ -139,7 +60,7 @@ void chooseOption(char* option){
13960 }else if (strcmp (CONCATENAR , option ) == 0 ){
14061
14162 }else if (strcmp (ROTACION , option ) == 0 ){
142-
63+ rotateToRight ( 5 );
14364 }else if (strcmp (LIMPIAR_LISTA , option ) == 0 ){
14465
14566 }else if (strcmp (MAYOR , option ) == 0 ){
0 commit comments