diff --git a/main.c b/main.c index e7a0157..acf616e 100644 --- a/main.c +++ b/main.c @@ -6,6 +6,7 @@ #include #include #include "easysock.h" +#include "url_manipulation.h" void testFunc(Widget,XtPointer,XmPushButtonCallbackStruct *); @@ -60,7 +61,29 @@ void testFunc(Widget w, XtPointer client_data, XmPushButtonCallbackStruct *callb Widget* widget_list = (Widget *)client_data; Widget result_widget = widget_list[1]; Widget text_widget = widget_list[0]; + int port; + + char* url = XmTextFieldGetString(text_widget); + + char* protocol = url_to_proto(url); /* Extract the protocol string from the URL input */ + + if (strcmp(protocol,"http") == 0) { + port = 80; + } else if (strcmp(protocol,"https") == 0) { + port = 443; + } else { + exit(50); /* I haven't added support for other protocols yet */ + } + /* We call the create_remote function to create an address, bind it to a socket, + and make the connection for us. It returns the socket, so that the HTTP request can be made. + First parameter is IP version - set to -1 because we don't know yet if the address is IPv4 or IPv6. */ + + struct sockaddr* address_struct; + int remote_socket = create_remote(-1,'T',url_to_hostname(url),port,address_struct); + + + XmHTMLTextSetString(result_widget,""); // printf("%d\n",val); // exit(2);