|
|
@ -6,6 +6,7 @@
|
|
|
|
#include <Xm/Form.h>
|
|
|
|
#include <Xm/Form.h>
|
|
|
|
#include <XmHTML/XmHTML.h>
|
|
|
|
#include <XmHTML/XmHTML.h>
|
|
|
|
#include "easysock.h"
|
|
|
|
#include "easysock.h"
|
|
|
|
|
|
|
|
#include "url_manipulation.h"
|
|
|
|
|
|
|
|
|
|
|
|
void testFunc(Widget,XtPointer,XmPushButtonCallbackStruct *);
|
|
|
|
void testFunc(Widget,XtPointer,XmPushButtonCallbackStruct *);
|
|
|
|
|
|
|
|
|
|
|
@ -60,6 +61,28 @@ void testFunc(Widget w, XtPointer client_data, XmPushButtonCallbackStruct *callb
|
|
|
|
Widget* widget_list = (Widget *)client_data;
|
|
|
|
Widget* widget_list = (Widget *)client_data;
|
|
|
|
Widget result_widget = widget_list[1];
|
|
|
|
Widget result_widget = widget_list[1];
|
|
|
|
Widget text_widget = widget_list[0];
|
|
|
|
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,"");
|
|
|
|
XmHTMLTextSetString(result_widget,"");
|
|
|
|
// printf("%d\n",val);
|
|
|
|
// printf("%d\n",val);
|
|
|
|