/**
 * Name  : Edison Chindrawalyg
 * Group : Sehoon Jung & Sangtae Park
 * Class : CSCI 3780 Spring 2001
 * File  : crypt_server.h
 * Project: #1
 */

#include <iostream.h>
#include <fstream.h>
#include <fcntl.h>
#include <ctype.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/errno.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <netinet/in.h>

#define STDIN 0
#define STDOUT 1
#define READ 0
#define WRITE 1
#define MAXSIZE 128
#define LISTENPORT 6501
#define CONNECTPORT 6502
#define BACKLOG 5

//for error handling flags:
#define socket_flag 0
#define bind_flag 1
#define listen_flag 2
#define accept_flag 3
#define send_flag 4
#define receive_flag 5
#define pipe_flag 6
#define write_flag 7
#define read_flag 8
#define select_flag 9

/**
 * int msg_length contains the message length
 * int option contains option - 1 to encrypt
 *                            - 2 to decrypt
 * char key contains the encrypt/decrypt key
 * char msg contains the message
 */
typedef struct
{
 int msg_length;
 int option;
 char key;
 char msg[MAXSIZE];
} MESSAGE;

char* encryptDecrypt(char *,char ,int);
void beginProcess(int);
int sendStruct(int, MESSAGE);
int receivedStruct(int,MESSAGE&);
char* deformStruct(MESSAGE);
void closeConnection(int);
int openConnection(int);
void verify(int, int, int);
int askPort();

 

1