200905030 - 200905014/server.c File Reference

This program is to act like a server for Autograph Book. More...

#include <gtk/gtk.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <time.h>
#include <signal.h>
#include <poll.h>
#include <pthread.h>
#include <mysql/mysql.h>

Go to the source code of this file.

Defines

#define BUFFER_SIZE   4096
#define SERVER_PORT   1300
#define NUM_CLIENTS   1000
#define LEN   1000

Functions

void close_properly (int signal)
 to close the signal
void * display (void *arg)
 This function is used to receive the client data which is passed from the client and call the appropriate functions to store the data in the database.
int main (int argc, char *argv[])
 Used to create a tcp server.
void signup_program (char *name, char *contact, char *birth, char *address, char *hobbies, char *email, char *user_name, char *pass, char *conpass, int client)
 Used to create a new user with details mentined below.
void signin_program (char *user_name, char *pass, int client)
 Used to check the user id in the exiting database.
 submit_program (char *uname, char *user_name, char *name, char *contact, char *birth, char *address, char *hobbies, char *email, int client)
 Used to add the details of the friends to the user.
 users_program (int client)
 Used to get the user names from the database.
 user_fnds_program (char *user_name, int client)
 Used to Get the friend details of the selected user.
 add_program (char *oud, char *uname, int client)
 Used to add the others user details.
 fnds_program (char *uname, int client)
 Used to get the friends usernames.
 update_program (char *uname, char *user_name, char *name, char *contact, char *birth, char *address, char *hobbies, char *email, int client)
 Used to update the details of the friends to the user.
 delete_program (char *uname, char *user_name, int client)
 Used to delete the friends details.
 search_program (char *uname, char *user_name, int client)
 Used to get the friend details.

Variables

char to_client [2]
int NUM_QS
int TOTAL_QS
int LISTEN_PORT
int listen_file_descriptor
int connection_file_descriptor [NUM_CLIENTS]
char combine [1000]
MYSQL_ROW sqlrow
MYSQL_ROW temp
MYSQL_RES * result1
int ucount
int fcount
int scount
int pucount
int pfcount
int pscount
char name [1000]
char cn [1000]
char dob [100]
char addr [1000]
char hob [1000]
char email [100]
char uname [1000]
char pass1 [20]
char pass2 [20]
char nemail [100]
char pass [20]
char nuname [1000]
char username [1000]
char back [10][1000]
GtkWidget * ntext
GtkWidget * nlabel
GtkWidget * nlabel_search
GtkWidget * nlabel_user
GtkWidget * nlabel_details
GtkWidget * ncombo_user
GtkWidget * ncombo_details
GtkWidget * ncombo_search
GtkWidget * NAME
GtkWidget * CN
GtkWidget * DOB
GtkWidget * ADDR
GtkWidget * HOB
GtkWidget * EMAIL
GtkWidget * UNAME
GtkWidget * PASS
GtkWidget * NUNAME
GtkWidget * PASS1
GtkWidget * PASS2
GtkWidget * NEMAIL
GtkWidget * USERNAME
GtkWidget * dialog
GtkWidget * window2
GtkWidget * button2
GtkWidget * filew
GtkWidget * image
GtkWidget * combo_user
GtkWidget * combo_details
GtkWidget * combo_search
char ch
int mainscreen
int enterdetails
int argc1
char * argv1 []
int success = 0
char exe [1000]
char sea [1000]
char ou [1000]
char oud [1000]

Detailed Description

This program is to act like a server for Autograph Book.

Author:
Praveen kumar and Lakshmikanth Reddy
Version:
1.0

Definition in file server.c.


Define Documentation

#define BUFFER_SIZE   4096

Definition at line 25 of file server.c.

Referenced by display().

#define LEN   1000

Definition at line 31 of file server.c.

Referenced by display(), and main().

#define NUM_CLIENTS   1000

Definition at line 28 of file server.c.

Referenced by main().

#define SERVER_PORT   1300

Definition at line 27 of file server.c.


Function Documentation

add_program ( char *  oud,
char *  uname,
int  client 
)

Used to add the others user details.

Returns:
0 to calling program on success
Parameters:
oud used to store user id
uname used store the login name
client used to recognise client number

Definition at line 745 of file server.c.

References connection_file_descriptor, email, hob, name, result1, sqlrow, and to_client.

Referenced by display().

void close_properly ( int  signal  ) 

to close the signal

Definition at line 62 of file server.c.

References listen_file_descriptor.

Referenced by main().

delete_program ( char *  uname,
char *  user_name,
int  client 
)

Used to delete the friends details.

Returns:
0 to calling program on success
Parameters:
uname used store user name
user_name used store the friend user name
client used to recognise client number

Definition at line 1012 of file server.c.

References connection_file_descriptor, result1, and to_client.

Referenced by display().

void* display ( void *  arg  ) 

This function is used to receive the client data which is passed from the client and call the appropriate functions to store the data in the database.

Parameters:
arg pass the client number

Definition at line 82 of file server.c.

References add_program(), BUFFER_SIZE, connection_file_descriptor, delete_program(), email, fnds_program(), LEN, name, search_program(), signin_program(), signup_program(), submit_program(), update_program(), user_fnds_program(), username, and users_program().

Referenced by main().

fnds_program ( char *  uname,
int  client 
)

Used to get the friends usernames.

Returns:
0 to calling program on success
Parameters:
uname used to store user id
client used to recognise client number

Definition at line 843 of file server.c.

References combine, connection_file_descriptor, sqlrow, and ucount.

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

Used to create a tcp server.

This is an iterative server and hence responds to clients.

Returns:
zero to calling program on success, else 1.
Parameters:
argc number of command line arguments passed to the program including program name itself.
argv array of command line arguments.

Definition at line 199 of file server.c.

References close_properly(), connection_file_descriptor, display(), LEN, listen_file_descriptor, LISTEN_PORT, NUM_CLIENTS, and SERVER_PORT.

search_program ( char *  uname,
char *  user_name,
int  client 
)

Used to get the friend details.

Returns:
0 to calling program on success
Parameters:
uname used store user name
user_name used store the friend user name
client used to recognise client number

Definition at line 1094 of file server.c.

References combine, connection_file_descriptor, result1, sqlrow, and to_client.

Referenced by display().

void signin_program ( char *  user_name,
char *  pass,
int  client 
)

Used to check the user id in the exiting database.

Returns:
NULL to calling program on success
Parameters:
user_name used to create user_name of new user
pass used to store password of new user
client used to recognise client number of new user

Definition at line 403 of file server.c.

References connection_file_descriptor, mainscreen, result1, sqlrow, temp, and to_client.

Referenced by display().

void signup_program ( char *  name,
char *  contact,
char *  birth,
char *  address,
char *  hobbies,
char *  email,
char *  user_name,
char *  pass,
char *  conpass,
int  client 
)

Used to create a new user with details mentined below.

Returns:
NULL to calling program on success
Parameters:
name used to store the name of the new user
contact used to store contact number of new user
birth used to store dateofbirth of new user
hobbies used to store hobbies of new user
email used to store email id of new user
user_name used to create user_name of new user
pass used to store password of new user
conpass used to store conform password of new user
client used to recognise client number of new user

Definition at line 296 of file server.c.

References connection_file_descriptor, result1, sqlrow, and to_client.

Referenced by display().

submit_program ( char *  uname,
char *  user_name,
char *  name,
char *  contact,
char *  birth,
char *  address,
char *  hobbies,
char *  email,
int  client 
)

Used to add the details of the friends to the user.

Returns:
NULL to calling program on success
Parameters:
name used to store the name of the new user
contact used to store contact number of new user
birth used to store dateofbirth of new user
hobbies used to store hobbies of new user
email used to store email id of new user
user_name used to create user_name of new user
pass used to store password of new user
conpass used to store conform password of new user
client used to recognise client number of new user

Definition at line 501 of file server.c.

References connection_file_descriptor, exe, and to_client.

Referenced by display().

update_program ( char *  uname,
char *  user_name,
char *  name,
char *  contact,
char *  birth,
char *  address,
char *  hobbies,
char *  email,
int  client 
)

Used to update the details of the friends to the user.

Returns:
0 to calling program on success
Parameters:
uname used to store the user name
name used to store the name of the updated user
contact used to store contact number of updated user
birth used to store dateofbirth of updated user
hobbies used to store hobbies of updated user
email used to store email id of updated user
user_name used to create user_name of updated user
pass used to store password of updated user
conpass used to store conform password of updated user
client used to recognise client number of updated user

Definition at line 938 of file server.c.

References connection_file_descriptor, result1, and to_client.

Referenced by display().

user_fnds_program ( char *  user_name,
int  client 
)

Used to Get the friend details of the selected user.

Returns:
0 to calling program on success
Parameters:
user_name to pass the user name
client used to recognise client number

Definition at line 643 of file server.c.

References combine, connection_file_descriptor, dialog, fcount, pfcount, and sqlrow.

users_program ( int  client  ) 

Used to get the user names from the database.

Returns:
0 to calling program on success
Parameters:
client used to recognise client number of new user

Definition at line 563 of file server.c.

References combine, connection_file_descriptor, pucount, sqlrow, and ucount.


Variable Documentation

GtkWidget * ADDR

Definition at line 46 of file server.c.

char addr[1000]

Definition at line 41 of file server.c.

int argc1

Definition at line 51 of file server.c.

char* argv1[]

Definition at line 52 of file server.c.

char back[10][1000]

Definition at line 42 of file server.c.

GtkWidget * button2

Definition at line 47 of file server.c.

char ch

Definition at line 49 of file server.c.

GtkWidget * CN

Definition at line 46 of file server.c.

char cn[1000]

Definition at line 41 of file server.c.

char combine[1000]

Definition at line 37 of file server.c.

GtkWidget * combo_details

Definition at line 48 of file server.c.

GtkWidget * combo_search

Definition at line 48 of file server.c.

GtkWidget* combo_user

Definition at line 48 of file server.c.

int connection_file_descriptor[NUM_CLIENTS]
GtkWidget* dialog

Definition at line 47 of file server.c.

GtkWidget * DOB

Definition at line 46 of file server.c.

char dob[100]

Definition at line 41 of file server.c.

GtkWidget * EMAIL

Definition at line 46 of file server.c.

char email[100]

Definition at line 41 of file server.c.

Definition at line 50 of file server.c.

char exe[1000]

Definition at line 54 of file server.c.

int fcount

Definition at line 40 of file server.c.

GtkWidget * filew

Definition at line 47 of file server.c.

GtkWidget * HOB

Definition at line 46 of file server.c.

char hob[1000]

Definition at line 41 of file server.c.

GtkWidget * image

Definition at line 47 of file server.c.

Definition at line 35 of file server.c.

Referenced by close_properly(), and main().

Definition at line 34 of file server.c.

Referenced by main().

Definition at line 50 of file server.c.

GtkWidget* NAME

Definition at line 46 of file server.c.

char name[1000]

Definition at line 41 of file server.c.

GtkWidget * ncombo_details

Definition at line 45 of file server.c.

GtkWidget * ncombo_search

Definition at line 45 of file server.c.

GtkWidget* ncombo_user

Definition at line 45 of file server.c.

GtkWidget * NEMAIL

Definition at line 46 of file server.c.

char nemail[100]

Definition at line 41 of file server.c.

GtkWidget * nlabel

Definition at line 44 of file server.c.

GtkWidget * nlabel_details

Definition at line 44 of file server.c.

GtkWidget * nlabel_search

Definition at line 44 of file server.c.

GtkWidget * nlabel_user

Definition at line 44 of file server.c.

GtkWidget* ntext

Definition at line 44 of file server.c.

int NUM_QS

Definition at line 32 of file server.c.

GtkWidget * NUNAME

Definition at line 46 of file server.c.

char nuname[1000]

Definition at line 41 of file server.c.

char ou[1000]

Definition at line 55 of file server.c.

char oud[1000]

Definition at line 55 of file server.c.

GtkWidget * PASS

Definition at line 46 of file server.c.

char pass[20]

Definition at line 41 of file server.c.

GtkWidget * PASS1

Definition at line 46 of file server.c.

char pass1[20]

Definition at line 41 of file server.c.

GtkWidget * PASS2

Definition at line 46 of file server.c.

char pass2[20]

Definition at line 41 of file server.c.

int pfcount

Definition at line 40 of file server.c.

int pscount

Definition at line 40 of file server.c.

int pucount

Definition at line 40 of file server.c.

MYSQL_RES* result1
int scount

Definition at line 40 of file server.c.

char sea[1000]

Definition at line 55 of file server.c.

MYSQL_ROW sqlrow

Definition at line 38 of file server.c.

int success = 0

Definition at line 53 of file server.c.

MYSQL_ROW temp

Definition at line 38 of file server.c.

char to_client[2]
int TOTAL_QS

Definition at line 33 of file server.c.

int ucount

Definition at line 40 of file server.c.

GtkWidget * UNAME

Definition at line 46 of file server.c.

char uname[1000]

Definition at line 41 of file server.c.

GtkWidget * USERNAME

Definition at line 46 of file server.c.

char username[1000]

Definition at line 41 of file server.c.

GtkWidget * window2

Definition at line 47 of file server.c.


Generated on Sun Apr 18 18:05:05 2010 for project by  doxygen 1.6.1