#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] |
Definition in file server.c.
int add_to_database | ( | char * | file | ) |
Adds the uploaded files to the database.
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.
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.
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.
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.
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.
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.
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().
MYSQL* connection1 |
Definition at line 24 of file server.c.
Referenced by add_to_database(), create_account(), create_tables(), delete_from_database(), delete_user(), drop_tables(), owner_login(), search_for(), and user_check().
MYSQL* connection2 |
char cur_file[100] |
FILE* fw = NULL |
int logged_in = 0 |
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().
int num_of_res |
char resp_users[100][50] |
MYSQL_RES* result |
Definition at line 26 of file server.c.
Referenced by create_account(), create_tables(), delete(), delete_file(), find(), handle_ip(), logout(), search(), search_for(), submit(), submit1(), upload(), and user_check().
char search_res[100][50] |
MYSQL_ROW sqlrow |
Definition at line 27 of file server.c.
Referenced by create_account(), search_for(), and user_check().