server.c File Reference

This program is created for handling the requests sentby the client program. More...

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

Go to the source code of this file.

Defines

#define SIZE_ID   20
#define SIZE_PASS_WORD   10
#define BUFFER_SIZE   4096*1000
#define LISTEN_PORT   9999

Functions

void close_properly (int signal)
 Closes the server after pressing the ctrl+c.
void owner_login ()
 An account login for the server that is created for the usages of the server such as storing the information of the user,password,details.
void drop_tables ()
 Used for dropping all the tables.
void create_tables ()
 Creates the required tables login_details,user_details,file_details.
int create_account (char *name, char *email_id, char *user_id, char *pass_word, char *org)
 Creates a new account in the server.
int user_check (char *user_id, char *password)
 Checks for the validity of the user.
int search_for (char *qry)
 Searches for the files which are alike given qry.
int delete_from_database (char *str)
 Deletes the particular file from data base.
void delete_user ()
 Deletes the user perminently from the database.
int add_to_database (char *file)
 Adds the uploaded files to the database.
char * handle_ip (char *input)
 Handles all the messages generated by the user.
int main (int argc, char *argv[])
 MAIN FUNCTION.

Variables

MYSQL * connection1
MYSQL * connection2
MYSQL_RES * result
MYSQL_ROW sqlrow
int num_of_res
FILE * fw = NULL
FILE * fr = NULL
int logged_in = 0
char logged_user [100]
char search_res [100][50]
char resp_users [100][50]
int listen_file_descriptor
char cur_file [100]


Detailed Description

This program is created for handling the requests sentby the client program.

Author:
VENKAT RAO NANNAKA

Definition in file server.c.


Define Documentation

#define BUFFER_SIZE   4096*1000

Definition at line 22 of file server.c.

#define LISTEN_PORT   9999

Definition at line 23 of file server.c.

#define SIZE_ID   20

Definition at line 20 of file server.c.

#define SIZE_PASS_WORD   10

Definition at line 21 of file server.c.


Function Documentation

int add_to_database ( char *  file  ) 

Adds the uploaded files to the database.

Parameters:
file name of the to be added

Definition at line 232 of file server.c.

References connection1, and logged_user.

Referenced by handle_ip().

void close_properly ( int  signal  ) 

Closes the server after pressing the ctrl+c.

Definition at line 38 of file server.c.

References listen_file_descriptor.

Referenced by main().

int create_account ( char *  name,
char *  email_id,
char *  user_id,
char *  pass_word,
char *  org 
)

Creates a new account in the server.

Parameters:
name name of the user
email_id email_id of the user
user_id user_id of the user
pass_word password of the user
org organization of the user

Definition at line 94 of file server.c.

References connection1, result, and sqlrow.

Referenced by handle_ip().

void create_tables (  ) 

Creates the required tables login_details,user_details,file_details.

..etc

Definition at line 74 of file server.c.

References connection1, drop_tables(), and result.

int delete_from_database ( char *  str  ) 

Deletes the particular file from data base.

Parameters:
str name of the file to be deleted

Definition at line 203 of file server.c.

References connection1, and logged_user.

Referenced by handle_ip().

void delete_user (  ) 

Deletes the user perminently from the database.

Definition at line 214 of file server.c.

References connection1, and logged_user.

Referenced by handle_ip().

void drop_tables (  ) 

Used for dropping all the tables.

Definition at line 66 of file server.c.

References connection1.

Referenced by create_tables().

char* handle_ip ( char *  input  ) 

Handles all the messages generated by the user.

Parameters:
input password of the user

Definition at line 242 of file server.c.

References add_to_database(), create_account(), cur_file, delete_from_database(), delete_user(), fw, ip, logged_in, logged_user, num_of_res, resp_users, result, search_for(), search_res, and user_check().

Referenced by main().

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

MAIN FUNCTION.

Parameters:
argc No. of command line arguements
argv contains all the arguemtns in the command line

Definition at line 415 of file server.c.

References BUFFER_SIZE, close_properly(), fr, handle_ip(), input_data, listen_file_descriptor, LISTEN_PORT, num_of_res, owner_login(), and search_res.

void owner_login (  ) 

An account login for the server that is created for the usages of the server such as storing the information of the user,password,details.

.etc

Definition at line 58 of file server.c.

References connection1.

Referenced by main().

int search_for ( char *  qry  ) 

Searches for the files which are alike given qry.

Parameters:
qry Query given by the user

Definition at line 184 of file server.c.

References connection1, resp_users, result, search_res, and sqlrow.

Referenced by handle_ip().

int user_check ( char *  user_id,
char *  password 
)

Checks for the validity of the user.

Parameters:
user_id user_id of the user
pass_word password of the user

Definition at line 135 of file server.c.

References connection1, result, and sqlrow.

Referenced by handle_ip().


Variable Documentation

MYSQL* connection1

MYSQL* connection2

Definition at line 25 of file server.c.

char cur_file[100]

Definition at line 227 of file server.c.

Referenced by handle_ip().

FILE * fr = NULL

Definition at line 29 of file server.c.

Referenced by main().

FILE* fw = NULL

Definition at line 29 of file server.c.

Referenced by handle_ip().

Definition at line 34 of file server.c.

Referenced by close_properly(), and main().

int logged_in = 0

Definition at line 31 of file server.c.

Referenced by handle_ip().

char logged_user[100]

Definition at line 32 of file server.c.

Referenced by add_to_database(), delete_from_database(), delete_user(), and handle_ip().

Definition at line 28 of file server.c.

Referenced by handle_ip(), and main().

char resp_users[100][50]

Definition at line 33 of file server.c.

Referenced by handle_ip(), and search_for().

MYSQL_RES* result

char search_res[100][50]

Definition at line 33 of file server.c.

Referenced by handle_ip(), main(), and search_for().

MYSQL_ROW sqlrow

Definition at line 27 of file server.c.

Referenced by create_account(), search_for(), and user_check().


Generated on Sun Apr 18 16:31:53 2010 for 200905039 by  doxygen 1.5.8