examclient.c File Reference

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <strings.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string.h>
#include <gtk/gtk.h>

Go to the source code of this file.

Defines

#define BUFFER   4096
#define SERVER_PORT   8000

Functions

gint closewin (GtkWidget *widget, GdkEvent *event, gpointer data)
 Properly ends the GTK program.
void button1 (GtkWidget *widget1, gpointer data)
 Radio button handler for button1.
void button2 (GtkWidget *widget1, gpointer data)
 Radio button handler for button2.
void button3 (GtkWidget *widget1, gpointer data)
 Radio button handler for button3.
void button4 (GtkWidget *widget1, gpointer data)
 Radio button handler for button4.
void question (char *)
int submit (GtkWidget *wid, gpointer data)
 Processes the answer provided by the client.
void endexam (int score, int total)
 Prints the final score when exam is ended, Prints an error message if exam is ended abruptly.
void question (char que[])
 Parses the question and prints it in a GUI window using GTK.
int main (int argc, char *argv[])
 Used to connect to the exam server and recieve the questions.

Variables

int read_desc
int write_desc
gboolean radio1 = TRUE
gboolean radio2 = FALSE
gboolean radio3 = FALSE
gboolean radio4 = FALSE
GtkWidget * window
GtkWidget * group
GtkWidget * label1
GtkWidget * rad1
GtkWidget * rad2
GtkWidget * rad3
GtkWidget * rad4
GtkWidget * box
GtkWidget * button5


Define Documentation

#define BUFFER   4096

Definition at line 13 of file examclient.c.

Referenced by main(), question(), and submit().

#define SERVER_PORT   8000

Definition at line 14 of file examclient.c.

Referenced by main().


Function Documentation

void button1 ( GtkWidget *  widget1,
gpointer  data 
)

Radio button handler for button1.

Returns:
nothing
Parameters:
widget1 GTKWidget
data gpointer object

Definition at line 188 of file examclient.c.

References radio1.

Referenced by question().

void button2 ( GtkWidget *  widget1,
gpointer  data 
)

Radio button handler for button2.

Returns:
nothing
Parameters:
widget1 GTKWidget
data gpointer object

Definition at line 203 of file examclient.c.

References radio2.

Referenced by question().

void button3 ( GtkWidget *  widget1,
gpointer  data 
)

Radio button handler for button3.

Returns:
nothing
Parameters:
widget1 GTKWidget
data gpointer object

Definition at line 218 of file examclient.c.

References radio3.

Referenced by question().

void button4 ( GtkWidget *  widget1,
gpointer  data 
)

Radio button handler for button4.

Returns:
nothing
Parameters:
widget1 GTKWidget
data gpointer object

Definition at line 233 of file examclient.c.

References radio4.

Referenced by question().

gint closewin ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  data 
)

Properly ends the GTK program.

Returns:
false
Parameters:
widget GTKWidget
event Event handling
data data object

Definition at line 22 of file examclient.c.

Referenced by main(), and question().

void endexam ( int  score,
int  total 
)

Prints the final score when exam is ended, Prints an error message if exam is ended abruptly.

Returns:
nothing
Parameters:
score final score
total total marks

Definition at line 166 of file examclient.c.

Referenced by main(), question(), and submit().

int main ( int  argc,
char *  argv[] 
)

Used to connect to the exam server and recieve the questions.

The questions are displayed in GTK window. It then send the answers. The client connects to the server using an IP address provided to it through command line. It uses the server port 8000 to connect to the server.

Returns:
0 if successful non-zero if fails.
Parameters:
argc number of command line arguments passed to the program including program name itself.
argv array of command line arguments.

Definition at line 252 of file examclient.c.

References BUFFER, closewin(), endexam(), question(), SERVER_PORT, window, and write_desc.

void question ( char  que[]  ) 

Parses the question and prints it in a GUI window using GTK.

Returns:
nothing
Parameters:
que takes a question in string. Options Separated by |

Definition at line 47 of file examclient.c.

References box, BUFFER, button1(), button2(), button3(), button4(), button5, closewin(), endexam(), group, label1, rad1, rad2, rad3, rad4, submit(), and window.

void question ( char *   ) 

Referenced by main(), and submit().

int submit ( GtkWidget *  wid,
gpointer  data 
)

Processes the answer provided by the client.

Returns:
answer given by the user.
Parameters:
wid GTKWidget
data gpointer

Definition at line 122 of file examclient.c.

References box, BUFFER, endexam(), question(), radio1, radio2, radio3, radio4, window, and write_desc.

Referenced by question().


Variable Documentation

GtkWidget * box

Definition at line 40 of file examclient.c.

Referenced by question(), and submit().

GtkWidget * button5

Definition at line 40 of file examclient.c.

Referenced by question().

GtkWidget * group

Definition at line 39 of file examclient.c.

Referenced by question().

GtkWidget* label1

Definition at line 40 of file examclient.c.

Referenced by question().

GtkWidget * rad1

Definition at line 40 of file examclient.c.

Referenced by question().

GtkWidget * rad2

Definition at line 40 of file examclient.c.

Referenced by question().

GtkWidget * rad3

Definition at line 40 of file examclient.c.

Referenced by question().

GtkWidget * rad4

Definition at line 40 of file examclient.c.

Referenced by question().

gboolean radio1 = TRUE

Definition at line 38 of file examclient.c.

Referenced by button1(), and submit().

gboolean radio2 = FALSE

Definition at line 38 of file examclient.c.

Referenced by button2(), and submit().

gboolean radio3 = FALSE

Definition at line 38 of file examclient.c.

Referenced by button3(), and submit().

gboolean radio4 = FALSE

Definition at line 38 of file examclient.c.

Referenced by button4(), and submit().

int read_desc

Definition at line 36 of file examclient.c.

GtkWidget* window

Definition at line 39 of file examclient.c.

Referenced by main(), question(), and submit().

Definition at line 37 of file examclient.c.

Referenced by main(), and submit().


Generated on Wed Apr 7 23:01:43 2010 for project by  doxygen 1.5.8