Update
This commit is contained in:
parent
94c4769241
commit
7b2caf39b6
|
@ -12,12 +12,12 @@ lib/network/tcp/server.o: lib/header.h lib/network/tcp/server.h lib/network/tcp/
|
|||
lib/network/udp/server.o: lib/header.h lib/network/udp/server.h lib/network/udp/server.c
|
||||
gcc $(CFLAGS) -c -o lib/network/udp/server.o lib/network/udp/server.c
|
||||
|
||||
lib/util.o: lib/util.h lib/util.c
|
||||
gcc $(CFLAGS) -c -o lib/util.o lib/util.c
|
||||
lib/network/format/serializer.o: lib/network/format/serializer.h lib/network/format/serializer.c
|
||||
gcc $(CFLAGS) -c -o lib/network/format/serializer.o lib/network/format/serializer.c
|
||||
|
||||
# Compiles the SGCA
|
||||
boot: lib/network/tcp/server.o lib/network/udp/server.o lib/util.o central-manager.h central-manager.c
|
||||
gcc $(CFLAGS) -o boot lib/network/udp/server.o lib/network/tcp/server.o lib/util.o central-manager.c
|
||||
boot: lib/network/tcp/server.o lib/network/udp/server.o lib/network/format/serializer.o central-manager.h central-manager.c
|
||||
gcc $(CFLAGS) -o boot lib/network/udp/server.o lib/network/tcp/server.o lib/network/format/serializer.o central-manager.c
|
||||
|
||||
|
||||
# Run full compilation
|
||||
|
|
|
@ -5,15 +5,11 @@
|
|||
* @argv : {0:program name}
|
||||
*
|
||||
* @history
|
||||
* [0] Initialisation des variables
|
||||
* [1] On démarre le SERVEUR TCP d'écoute globale
|
||||
* [2] On démarre le SERVEUR UDP d'écoute globale
|
||||
* repeat:
|
||||
* [3] Attente d'une demande de connection TCP -> création d'un THREAD
|
||||
* [4] Attente d'une demande de connection UDP -> création d'un THREAD
|
||||
* si SIGINT:
|
||||
* [3] On attends la fin de tous les THREADS
|
||||
* [4] On ferme la SOCKET d'écoute globale
|
||||
* [1] Lancement des THREADS d'écoute
|
||||
* 1. On démarre le SERVEUR TCP d'écoute globale
|
||||
* 2. On démarre le SERVEUR UDP d'écoute globale
|
||||
* [2] On attends la fin de tous les THREADS
|
||||
* [3] On ferme la SOCKET d'écoute globale
|
||||
*
|
||||
*/
|
||||
int main(int argc, char* argv[]){
|
||||
|
@ -35,13 +31,16 @@ int main(int argc, char* argv[]){
|
|||
pthread_join(listenManagers[0], NULL);
|
||||
pthread_join(listenManagers[1], NULL);
|
||||
|
||||
/* [4] On ferme la SOCKET d'écoute globale
|
||||
/* [3] On ferme la SOCKET d'écoute globale
|
||||
==========================================================*/
|
||||
printf("FERMETURE DE TOUTES LES CONNECTIONS!\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Attente de connection TCP
|
||||
*
|
||||
* @history
|
||||
|
@ -136,6 +135,9 @@ void* LISTEN_TCP(){
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Attente de connection UDP
|
||||
*
|
||||
* @history
|
||||
|
@ -262,7 +264,15 @@ void* managePlane(void* THREADABLE_SOCKET){
|
|||
break;
|
||||
}
|
||||
|
||||
printf("\t\tRequest(%d bytes) : '%s'\n", read, request);
|
||||
/* 3. On désérialise la requête*/
|
||||
|
||||
|
||||
printf("\t\tPLANE Request(%d bytes) : '%s'\n", read, request);
|
||||
|
||||
/* [3] Gestion de la requête
|
||||
=========================================================*/
|
||||
|
||||
|
||||
|
||||
}while( 0 );
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
#include "lib/header.h"
|
||||
|
||||
#include "lib/plane/plane.h"
|
||||
|
||||
|
||||
|
||||
/* local dependencies */
|
||||
#include "lib/util.h"
|
||||
#include "lib/network/tcp/server.h"
|
||||
#include "lib/network/udp/server.h"
|
||||
#include "lib/network/format/serializer.h"
|
||||
|
||||
|
||||
/* headers */
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
#include "serializer.h"
|
||||
|
||||
|
||||
int parse_plane_request(const char* pIn, struct plane_request* pOut){
|
||||
|
||||
/* 1. Check buffer length */
|
||||
if( strlen(pIn)*sizeof(char) != sizeof(struct plane_request) )
|
||||
return -1;
|
||||
|
||||
/* 2. Parse buffer */
|
||||
memcpy(pOut, pIn, (size_t) sizeof(struct plane_request));
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int parse_viewterm_request(const char* pIn, struct vterm_request* pOut){
|
||||
|
||||
/* 1. Check buffer length */
|
||||
if( strlen(pIn)*sizeof(char) != sizeof(struct vterm_request) )
|
||||
return -1;
|
||||
|
||||
/* 2. Parse buffer */
|
||||
memcpy(pOut, pIn, sizeof(struct vterm_request));
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int parse_ctrlterm_request(const char* pIn, struct cterm_request* pOut){
|
||||
|
||||
/* 1. Check buffer length */
|
||||
if( strlen(pIn)*sizeof(char) != sizeof(struct cterm_request) )
|
||||
return -1;
|
||||
|
||||
/* 2. Parse buffer */
|
||||
memcpy(pOut, pIn, sizeof(struct cterm_request));
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int serialize_term_response(const struct term_response* pIn, char* pOut, const size_t pSize){
|
||||
|
||||
/* 1. Check buffer length */
|
||||
if( sizeof(struct term_response) > pSize*sizeof(char) )
|
||||
return -1;
|
||||
|
||||
/* 2. Serialize response into buffer */
|
||||
memcpy(pOut, pIn, sizeof(struct term_response));
|
||||
return 0;
|
||||
|
||||
}
|
|
@ -1,11 +1,65 @@
|
|||
#ifndef _LIB_NETWORK_FORMAT_SERIALIZER_H_
|
||||
#define _LIB_NETWORK_FORMAT_SERIALIZER_H_
|
||||
|
||||
#include <string.h>
|
||||
#include "../../plane/plane.h"
|
||||
|
||||
#include "../../header.h";
|
||||
struct plane_request{ // Plane Request
|
||||
struct coord co;
|
||||
struct control ct;
|
||||
};
|
||||
|
||||
struct vterm_request{ // ViewTerminal Request
|
||||
char flags;
|
||||
};
|
||||
|
||||
struct term_response{ // Terminal-s Response
|
||||
char flags;
|
||||
struct coord co;
|
||||
struct control ct;
|
||||
};
|
||||
|
||||
struct cterm_request{ // ControlTerminal Request
|
||||
char flags;
|
||||
int z;
|
||||
struct control ct;
|
||||
};
|
||||
|
||||
/* Parse a plane request ('char*' to 'struct plane_request')
|
||||
*
|
||||
* @history
|
||||
* [1] Check if buffer have correct size (according to destination struct)
|
||||
* [2] Parse buffer to struct
|
||||
*
|
||||
*/
|
||||
int parse_plane_request(const char* pIn, struct plane_request* pOut);
|
||||
|
||||
/* Parse a viewTerminal request ('char*' to 'struct vt_request')
|
||||
*
|
||||
* @history
|
||||
* [1] Check if buffer have correct size (according to destination struct)
|
||||
* [2] Parse buffer to struct
|
||||
*
|
||||
*/
|
||||
int parse_viewterm_request(const char* pIn, struct vterm_request* pOut);
|
||||
|
||||
/* Parse a ctrlTerminal request ('char*' to 'struct ct_request')
|
||||
*
|
||||
* @history
|
||||
* [1] Check if buffer have correct size (according to destination struct)
|
||||
* [2] Parse buffer to struct
|
||||
*
|
||||
*/
|
||||
int parse_ctrlterm_request(const char* pIn, struct cterm_request* pOut);
|
||||
|
||||
/* Serialize a Terminal response ('struct t_response' to 'char*')
|
||||
*
|
||||
* @history
|
||||
* [1] Check if buffer have correct size (according to input struct)
|
||||
* [2] Serialize struct into buffer
|
||||
*
|
||||
*/
|
||||
int serialize_term_response(const struct term_response* pIn, char* pOut, const size_t pSize);
|
||||
|
||||
|
||||
#endif
|
|
@ -1 +0,0 @@
|
|||
../../../global/plane.c
|
|
@ -1 +1 @@
|
|||
../../../global/plane.h
|
||||
../../../plane/plane.h
|
|
@ -1,104 +0,0 @@
|
|||
#include "util.h"
|
||||
|
||||
|
||||
int swrite(int* pSocket, char* pBuffer){
|
||||
if( *pSocket == -1 ) return -1; // si SOCKET fermée, on retourne une erreur
|
||||
if( strlen(pBuffer) == 0 ) return 0; // si on a rien à écrire, on n'écrit rien :p
|
||||
|
||||
|
||||
/* 1. On écrit sur la SOCKET */
|
||||
if( DEBUGMOD&BUF ) printf("SENDLEN_1: %lu\n", strlen(pBuffer));
|
||||
int nbSent = write(*pSocket, pBuffer, strlen(pBuffer));
|
||||
if( DEBUGMOD&BUF ) printf("SENDLEN_2: %d\n", nbSent);
|
||||
|
||||
/* 2. Si on est déconnecté, on retourne une erreur */
|
||||
if( nbSent <= 0 ){
|
||||
if( DEBUGMOD&BUF ) printf("NOTHING TO SEND\n");
|
||||
return -1; // on retourne une erreur
|
||||
}
|
||||
|
||||
if( DEBUGMOD&RVL ) printf("SEND_1\n");
|
||||
if( DEBUGMOD&RVL ) revealString(pBuffer);
|
||||
if( DEBUGMOD&RVL ) printf("SEND_2\n");
|
||||
|
||||
|
||||
/* 3. On retourne le nombre de <char> envoyés */
|
||||
return nbSent;
|
||||
}
|
||||
|
||||
|
||||
int sread(int* pSocket, char* pBuffer){
|
||||
if( *pSocket == -1 ) return -1; // si SOCKET fermée, on retourne une erreur
|
||||
|
||||
|
||||
/* 1. On vide le buffer avant de lire */
|
||||
memset(pBuffer, '\0', MAX_BUF_LEN);
|
||||
if( DEBUGMOD&BUF ) printf("READLEN_1: %lu\n", strlen(pBuffer));
|
||||
|
||||
/* 2. On lit la SOCKET */
|
||||
int nbRead = read(*pSocket, pBuffer, MAX_BUF_LEN);
|
||||
if( DEBUGMOD&BUF ) printf("READLEN_3: %d\n", nbRead);
|
||||
|
||||
|
||||
/* 3. Si on est déconnecté, on retourne une erreur */
|
||||
if( nbRead <= 0 ){
|
||||
if( DEBUGMOD&BUF ) printf("NOTHING TO READ\n");
|
||||
return -1; // on retourne une erreur
|
||||
}
|
||||
|
||||
if( DEBUGMOD&RVL ) printf("READ_1\n");
|
||||
if( DEBUGMOD&RVL ) revealString(pBuffer);
|
||||
if( DEBUGMOD&RVL ) printf("READ_2\n");
|
||||
|
||||
/* 4. On retourne le nombre de caractères lus */
|
||||
return nbRead;
|
||||
}
|
||||
|
||||
|
||||
void setSocketTimeout(int* pSocket, const int pSec, const int pUSec){
|
||||
/* 1. On créé la structure contenant le timeout */
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = pSec;
|
||||
timeout.tv_usec = pUSec;
|
||||
|
||||
setsockopt(*pSocket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(struct timeval));
|
||||
|
||||
if( DEBUGMOD&SCK ) printf("Set socket(%d) timeout to %lus\n", *pSocket, (long unsigned) timeout.tv_sec );
|
||||
}
|
||||
|
||||
|
||||
void xPrint(char* pPattern, char* pBuffer){
|
||||
char tmpBuffer[MAX_BUF_LEN];
|
||||
strcpy(tmpBuffer, pBuffer);
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
// on supprimes les retours à la ligne de la fin
|
||||
for( i = strlen(tmpBuffer)-1 ; i >= 0 && tmpBuffer[i] != '\0' ; i-- )
|
||||
if( tmpBuffer[i] == '\n' || tmpBuffer[i] == '\r' ) // si c'est un retour chariot
|
||||
tmpBuffer[i] = '\0'; // on efface
|
||||
else
|
||||
break;
|
||||
|
||||
printf(pPattern, pBuffer);
|
||||
}
|
||||
|
||||
|
||||
void revealString(char* pString){
|
||||
/* 1. On créé une copie de @pString */
|
||||
char revealedString[MAX_BUF_LEN] = {0};
|
||||
|
||||
/* 2. On rend visible tous les caractères "invisibles" */
|
||||
int i;
|
||||
for( i = 0 ; i < strlen(pString) && pString[i] != '\0' ; i++ ){
|
||||
if( pString[i] == '\r' ){ revealedString[strlen(revealedString)] = '\\'; revealedString[strlen(revealedString)] = 'r'; }
|
||||
else if( pString[i] == '\n' ){ revealedString[strlen(revealedString)] = '\\'; revealedString[strlen(revealedString)] = 'n'; }
|
||||
else revealedString[strlen(revealedString)] = pString[i];
|
||||
|
||||
revealedString[strlen(revealedString)] = '\0';
|
||||
}
|
||||
|
||||
/* 3. On affiche la chaîne explicite */
|
||||
if( DEBUGMOD&RVL ) printf("[[%s]]\n", revealedString);
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#include "header.h"
|
||||
|
||||
void setSocketTimeout(int* pSocket, const int pSec, const int pUSec);
|
||||
|
||||
|
||||
/* read/write socket */
|
||||
int swrite(int* pSocket, char* pBuffer);
|
||||
int sread(int* pSocket, char* pBuffer);
|
||||
|
||||
|
||||
|
||||
/* Affiche une string en supprimant les retours à la ligne de fin de chaînes
|
||||
*
|
||||
* @pPattern<char*> Schéma du print (1er arg)
|
||||
* @pBuffer<char*> Buffer en question
|
||||
*
|
||||
*/
|
||||
void xPrint(char* pPattern, char* pBuffer);
|
||||
|
||||
|
||||
/* Révèle les caractères spéciaux d'une string
|
||||
*
|
||||
* @pString<char*> La string à révéler
|
||||
*
|
||||
*
|
||||
* @print explicitString<char*> On affiche la chaîne explicité
|
||||
*
|
||||
*/
|
||||
void revealString(char* pString);
|
167
global/plane.c
167
global/plane.c
|
@ -1,167 +0,0 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "avion.h"
|
||||
|
||||
// caractéristiques du déplacement de l'avion
|
||||
struct deplacement dep;
|
||||
|
||||
// coordonnées spatiales de l'avion
|
||||
struct coordonnees coord;
|
||||
|
||||
// numéro de vol de l'avion : code sur 5 caractères
|
||||
char numero_vol[6];
|
||||
|
||||
/********************************
|
||||
*** 3 fonctions à implémenter
|
||||
********************************/
|
||||
|
||||
int ouvrir_communication()
|
||||
{
|
||||
// fonction à implémenter qui permet d'entrer en communication via TCP
|
||||
// avec le gestionnaire de vols
|
||||
return 1;
|
||||
}
|
||||
|
||||
void fermer_communication()
|
||||
{
|
||||
// fonction à implémenter qui permet de fermer la communication
|
||||
// avec le gestionnaire de vols
|
||||
}
|
||||
|
||||
void envoyer_caracteristiques()
|
||||
{
|
||||
// fonction à implémenter qui envoie l'ensemble des caractéristiques
|
||||
// courantes de l'avion au gestionnaire de vols
|
||||
}
|
||||
|
||||
/********************************
|
||||
*** Fonctions gérant le déplacement de l'avion : ne pas modifier
|
||||
********************************/
|
||||
|
||||
// initialise aléatoirement les paramètres initiaux de l'avion
|
||||
void initialiser_avion()
|
||||
{
|
||||
// initialisation aléatoire du compteur aléatoire
|
||||
int seed;
|
||||
time(&seed);
|
||||
srandom(seed);
|
||||
|
||||
// intialisation des paramètres de l'avion
|
||||
coord.x = 1000 + random() % 1000;
|
||||
coord.y = 1000 + random() % 1000;
|
||||
coord.altitude = 900 + random() % 100;
|
||||
|
||||
dep.cap = random() % 360;
|
||||
dep.vitesse = 600 + random() % 200;
|
||||
|
||||
// initialisation du numero de l'avion : chaine de 5 caractères
|
||||
// formée de 2 lettres puis 3 chiffres
|
||||
numero_vol[0] = (random() % 26) + 'A';
|
||||
numero_vol[1] = (random() % 26) + 'A';
|
||||
sprintf (&numero_vol[2], "%03d", (random() % 999) + 1);
|
||||
numero_vol[5] = 0;
|
||||
}
|
||||
|
||||
// modifie la valeur de l'avion avec la valeur passée en paramètre
|
||||
void changer_vitesse(int vitesse)
|
||||
{
|
||||
if (vitesse < 0)
|
||||
dep.vitesse = 0;
|
||||
else if (vitesse > VITMAX)
|
||||
dep.vitesse = VITMAX;
|
||||
else dep.vitesse = vitesse;
|
||||
}
|
||||
|
||||
// modifie le cap de l'avion avec la valeur passée en paramètre
|
||||
void changer_cap(int cap)
|
||||
{
|
||||
if ((cap >= 0) && (cap < 360))
|
||||
dep.cap = cap;
|
||||
}
|
||||
|
||||
// modifie l'altitude de l'avion avec la valeur passée en paramètre
|
||||
void changer_altitude(int alt)
|
||||
{
|
||||
if (alt < 0)
|
||||
coord.altitude = 0;
|
||||
else if (alt > ALTMAX)
|
||||
coord.altitude = ALTMAX;
|
||||
else coord.altitude = alt;
|
||||
}
|
||||
|
||||
// affiche les caractéristiques courantes de l'avion
|
||||
void afficher_donnees()
|
||||
{
|
||||
printf("Avion %s -> localisation : (%d,%d), altitude : %d, vitesse : %d, cap : %d\n",
|
||||
numero_vol, coord.x, coord.y, coord.altitude, dep.vitesse, dep.cap);
|
||||
}
|
||||
|
||||
// recalcule la localisation de l'avion en fonction de sa vitesse et de son cap
|
||||
void calcul_deplacement()
|
||||
{
|
||||
float cosinus, sinus;
|
||||
float dep_x, dep_y;
|
||||
int nb;
|
||||
|
||||
if (dep.vitesse < VITMIN)
|
||||
{
|
||||
printf("Vitesse trop faible : crash de l'avion\n");
|
||||
fermer_communication();
|
||||
exit(2);
|
||||
}
|
||||
if (coord.altitude == 0)
|
||||
{
|
||||
printf("L'avion s'est ecrase au sol\n");
|
||||
fermer_communication();
|
||||
exit(3);
|
||||
}
|
||||
|
||||
cosinus = cos(dep.cap * 2 * M_PI / 360);
|
||||
sinus = sin(dep.cap * 2 * M_PI / 360);
|
||||
|
||||
dep_x = cos(dep.cap * 2 * M_PI / 360) * dep.vitesse * 10 / VITMIN;
|
||||
dep_y = sin(dep.cap * 2 * M_PI / 360) * dep.vitesse * 10 / VITMIN;
|
||||
|
||||
// on se déplace d'au moins une case quels que soient le cap et la vitesse
|
||||
// sauf si cap est un des angles droit
|
||||
if ((dep_x > 0) && (dep_x < 1)) dep_x = 1;
|
||||
if ((dep_x < 0) && (dep_x > -1)) dep_x = -1;
|
||||
|
||||
if ((dep_y > 0) && (dep_y < 1)) dep_y = 1;
|
||||
if ((dep_y < 0) && (dep_y > -1)) dep_y = -1;
|
||||
|
||||
//printf(" x : %f y : %f\n", dep_x, dep_y);
|
||||
|
||||
coord.x = coord.x + (int)dep_x;
|
||||
coord.y = coord.y + (int)dep_y;
|
||||
|
||||
afficher_donnees();
|
||||
}
|
||||
|
||||
// fonction principale : gère l'exécution de l'avion au fil du temps
|
||||
void se_deplacer()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
sleep(PAUSE);
|
||||
calcul_deplacement();
|
||||
envoyer_caracteristiques();
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// on initialise l'avion
|
||||
initialiser_avion();
|
||||
|
||||
afficher_donnees();
|
||||
// on quitte si on arrive à pas contacter le gestionnaire de vols
|
||||
if (!ouvrir_communication())
|
||||
{
|
||||
printf("Impossible de contacter le gestionnaire de vols\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// on se déplace une fois toutes les initialisations faites
|
||||
se_deplacer();
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
#define ALTMAX 20000
|
||||
#define ALTMIN 0
|
||||
|
||||
#define VITMAX 1000
|
||||
#define VITMIN 200
|
||||
|
||||
#define PAUSE 2
|
||||
|
||||
struct coordonnees {
|
||||
int x;
|
||||
int y;
|
||||
int altitude;
|
||||
};
|
||||
|
||||
struct deplacement {
|
||||
int cap;
|
||||
int vitesse;
|
||||
};
|
|
@ -0,0 +1,26 @@
|
|||
CFLAGS=-Wall
|
||||
|
||||
# Runs 'all' depenency as default / i.e. 'make' command will run 'make all' implicitly
|
||||
default: all
|
||||
|
||||
|
||||
|
||||
|
||||
lib/network/tcp/client.o: lib/header.h lib/network/tcp/client.h lib/network/tcp/client.c
|
||||
gcc $(CFLAGS) -c -o lib/network/tcp/client.o lib/network/tcp/client.c
|
||||
|
||||
lib/network/format/serializer.o: lib/network/format/serializer.h lib/network/format/serializer.c
|
||||
gcc $(CFLAGS) -c -o lib/network/format/serializer.o lib/network/format/serializer.c
|
||||
|
||||
# Compiles the Plane
|
||||
boot: lib/network/tcp/client.o lib/network/format/serializer.o plane.h plane.c
|
||||
gcc $(CFLAGS) -o boot lib/network/tcp/client.o lib/network/format/serializer.o plane.c -lm
|
||||
|
||||
|
||||
# Run full compilation
|
||||
all: boot
|
||||
|
||||
# cleans the compiled files
|
||||
clean:
|
||||
rm boot;
|
||||
rm ./**/*.o
|
|
@ -1,500 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head data-suburl="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
|
||||
<meta name="author" content="xdrm-brackets" />
|
||||
<meta name="description" content="proxy.ftp.c" />
|
||||
<meta name="keywords" content="go, git, self-hosted, gogs">
|
||||
|
||||
<meta name="referrer" content="no-referrer" />
|
||||
<meta name="_csrf" content="oL9HDhjy3U7tPSwjawLkQB4VNfA6MTQ5MDcxOTc2NTY0Nzg0MDkyNQ==" />
|
||||
<meta name="_suburl" content="" />
|
||||
|
||||
|
||||
|
||||
|
||||
<meta property="og:url" content="https://git.xdrm.io/xdrm-brackets/proxy.ftp.c" />
|
||||
<meta property="og:type" content="object" />
|
||||
<meta property="og:title" content="xdrm-brackets/proxy.ftp.c">
|
||||
<meta property="og:description" content="">
|
||||
|
||||
|
||||
<link rel="shortcut icon" href="/img/favicon.png" />
|
||||
|
||||
<script src="/js/jquery-1.11.3.min.js"></script>
|
||||
<script src="/js/libs/jquery.are-you-sure.js"></script>
|
||||
<link rel="stylesheet" href="/assets/font-awesome-4.6.3/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="/assets/octicons-4.3.0/octicons.min.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/css/semantic-2.2.7.min.css">
|
||||
<link rel="stylesheet" href="/css/gogs.css?v=73519fd9811805bce6fc4aa2d24bb413">
|
||||
|
||||
|
||||
<script src="/js/semantic-2.2.7.min.js"></script>
|
||||
<script src="/js/gogs.js?v=73519fd9811805bce6fc4aa2d24bb413"></script>
|
||||
|
||||
<title>xdrm-brackets/proxy.ftp.c - xdrm-brackets' git server</title>
|
||||
|
||||
<meta name="theme-color" content="#ff5343">
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="full height">
|
||||
<noscript>Please enable JavaScript in your browser!</noscript>
|
||||
|
||||
|
||||
<div class="following bar light">
|
||||
<div class="ui container">
|
||||
<div class="ui grid">
|
||||
<div class="column">
|
||||
<div class="ui top secondary menu">
|
||||
<a class="item brand" href="/">
|
||||
<img class="ui mini image" src="/img/favicon.png">
|
||||
</a>
|
||||
|
||||
|
||||
<a class="item" href="/">Home</a>
|
||||
|
||||
|
||||
<a class="item" href="/explore/repos">Explore</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<a class="item" target="_blank" href="https://gogs.io/docs" rel="noreferrer">Help</a>
|
||||
<div class="right menu">
|
||||
|
||||
<a class="item" href="/user/sign_up">
|
||||
<i class="octicon octicon-person"></i> Register
|
||||
</a>
|
||||
|
||||
<a class="item" href="/user/login?redirect_to=%2fxdrm-brackets%2fproxy.ftp.c%2fsrc%2fmaster%2fdep%2fclient.c">
|
||||
<i class="octicon octicon-sign-in"></i> Sign In
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="repository file list">
|
||||
<div class="header-wrapper">
|
||||
|
||||
<div class="ui container">
|
||||
<div class="ui vertically padded grid head">
|
||||
<div class="column">
|
||||
<div class="ui header">
|
||||
<div class="ui huge breadcrumb">
|
||||
<i class="mega-octicon octicon-repo"></i>
|
||||
<a href="/xdrm-brackets">xdrm-brackets</a>
|
||||
<div class="divider"> / </div>
|
||||
<a href="/xdrm-brackets/proxy.ftp.c">proxy.ftp.c</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="ui right">
|
||||
<div class="ui labeled button" tabindex="0">
|
||||
<a class="ui button" href="/xdrm-brackets/proxy.ftp.c/action/watch?redirect_to=%2fxdrm-brackets%2fproxy.ftp.c%2fsrc%2fmaster%2fdep%2fclient.c">
|
||||
<i class="icon fa-eye-slash"></i>Watch
|
||||
</a>
|
||||
<a class="ui basic label" href="/xdrm-brackets/proxy.ftp.c/watchers">
|
||||
1
|
||||
</a>
|
||||
</div>
|
||||
<div class="ui labeled button" tabindex="0">
|
||||
<a class="ui button" href="/xdrm-brackets/proxy.ftp.c/action/star?redirect_to=%2fxdrm-brackets%2fproxy.ftp.c%2fsrc%2fmaster%2fdep%2fclient.c">
|
||||
<i class="icon fa-star-o"></i>Star
|
||||
</a>
|
||||
<a class="ui basic label" href="/xdrm-brackets/proxy.ftp.c/stars">
|
||||
0
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="ui labeled button" tabindex="0">
|
||||
<a class="ui button " href="/repo/fork/49">
|
||||
<i class="octicon octicon-repo-forked"></i>Fork
|
||||
</a>
|
||||
<a class="ui basic label" href="/xdrm-brackets/proxy.ftp.c/forks">
|
||||
0
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="ui tabs container">
|
||||
<div class="ui tabular menu navbar">
|
||||
<a class="active item" href="/xdrm-brackets/proxy.ftp.c">
|
||||
<i class="octicon octicon-file-text"></i> Files
|
||||
</a>
|
||||
|
||||
<a class=" item" href="/xdrm-brackets/proxy.ftp.c/issues">
|
||||
<i class="octicon octicon-issue-opened"></i> Issues <span class="ui gray small label">0</span>
|
||||
</a>
|
||||
|
||||
|
||||
<a class=" item" href="/xdrm-brackets/proxy.ftp.c/pulls">
|
||||
<i class="octicon octicon-git-pull-request"></i> Pull Requests <span class="ui gray small label">0</span>
|
||||
</a>
|
||||
|
||||
<a class=" item" href="/xdrm-brackets/proxy.ftp.c/commits/master">
|
||||
<i class="octicon octicon-history"></i> Commits <span class="ui blue small label">23</span>
|
||||
</a>
|
||||
<a class=" item" href="/xdrm-brackets/proxy.ftp.c/releases">
|
||||
<i class="octicon octicon-tag"></i> Releases <span class="ui gray small label">0</span>
|
||||
</a>
|
||||
|
||||
<a class=" item" href="/xdrm-brackets/proxy.ftp.c/wiki">
|
||||
<i class="octicon octicon-book"></i> Wiki
|
||||
</a>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui tabs divider"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="ui container">
|
||||
|
||||
|
||||
|
||||
|
||||
<p id="repo-desc">
|
||||
<span class="no-description text-italic">No Description</span>
|
||||
<a class="link" href=""></a>
|
||||
</p>
|
||||
<div class="ui secondary menu">
|
||||
|
||||
<div class="fitted item choose reference">
|
||||
<div class="ui floating filter dropdown" data-no-results="No results found.">
|
||||
<div class="ui basic small button">
|
||||
<span class="text">
|
||||
<i class="octicon octicon-git-branch"></i>
|
||||
Branch:
|
||||
<strong>master</strong>
|
||||
</span>
|
||||
<i class="dropdown icon"></i>
|
||||
</div>
|
||||
<div class="menu">
|
||||
<div class="ui icon search input">
|
||||
<i class="filter icon"></i>
|
||||
<input name="search" placeholder="Filter branch or tag...">
|
||||
</div>
|
||||
<div class="header">
|
||||
<div class="ui grid">
|
||||
<div class="two column row">
|
||||
<a class="reference column" href="#" data-target="#branch-list">
|
||||
<span class="text black">
|
||||
<i class="octicon octicon-git-branch"></i> Branches
|
||||
</span>
|
||||
</a>
|
||||
<a class="reference column" href="#" data-target="#tag-list">
|
||||
<span class="text ">
|
||||
<i class="reference tags icon"></i> Tags
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="branch-list" class="scrolling menu" >
|
||||
|
||||
<div class="item selected" data-url="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c">master</div>
|
||||
|
||||
</div>
|
||||
<div id="tag-list" class="scrolling menu" style="display: none">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fitted item">
|
||||
<div class="ui breadcrumb">
|
||||
<a class="section" href="/xdrm-brackets/proxy.ftp.c/src/master">proxy.ftp.c</a>
|
||||
|
||||
|
||||
|
||||
<div class="divider"> / </div>
|
||||
|
||||
|
||||
<span class="section"><a href="/xdrm-brackets/proxy.ftp.c/src/master/dep">dep</a></span>
|
||||
|
||||
|
||||
<div class="divider"> / </div>
|
||||
|
||||
<span class="active section">client.c</span>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="right fitted item">
|
||||
|
||||
<div id="file-buttons" class="ui tiny blue buttons">
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="file-content" class="tab-size-8">
|
||||
<h4 class="ui top attached header" id="repo-read-file">
|
||||
|
||||
<i class="file text outline icon ui left"></i>
|
||||
<strong>client.c</strong> <span class="text grey normal">3.9KB</span>
|
||||
|
||||
|
||||
<div class="ui right file-actions">
|
||||
<div class="ui buttons">
|
||||
|
||||
<a class="ui button" href="/xdrm-brackets/proxy.ftp.c/src/18a5e4338baaec92912eee057d26004b57b0b2a0/dep/client.c">Permalink</a>
|
||||
|
||||
<a class="ui button" href="/xdrm-brackets/proxy.ftp.c/commits/master/dep/client.c">History</a>
|
||||
<a class="ui button" href="/xdrm-brackets/proxy.ftp.c/raw/master/dep/client.c">Raw</a>
|
||||
</div>
|
||||
|
||||
|
||||
<i class="octicon octicon-pencil btn-octicon poping up disabled" data-content="You must fork this repository before editing the file" data-position="bottom center" data-variation="tiny inverted"></i>
|
||||
|
||||
|
||||
<i class="octicon octicon-trashcan btn-octicon poping up disabled" data-content="You must have write access to make or propose changes to this file" data-position="bottom center" data-variation="tiny inverted"></i>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</h4>
|
||||
<div class="ui attached table segment">
|
||||
<div id="" class="file-view code-view has-emoji">
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
|
||||
<td class="lines-num"><span id="L1">1</span><span id="L2">2</span><span id="L3">3</span><span id="L4">4</span><span id="L5">5</span><span id="L6">6</span><span id="L7">7</span><span id="L8">8</span><span id="L9">9</span><span id="L10">10</span><span id="L11">11</span><span id="L12">12</span><span id="L13">13</span><span id="L14">14</span><span id="L15">15</span><span id="L16">16</span><span id="L17">17</span><span id="L18">18</span><span id="L19">19</span><span id="L20">20</span><span id="L21">21</span><span id="L22">22</span><span id="L23">23</span><span id="L24">24</span><span id="L25">25</span><span id="L26">26</span><span id="L27">27</span><span id="L28">28</span><span id="L29">29</span><span id="L30">30</span><span id="L31">31</span><span id="L32">32</span><span id="L33">33</span><span id="L34">34</span><span id="L35">35</span><span id="L36">36</span><span id="L37">37</span><span id="L38">38</span><span id="L39">39</span><span id="L40">40</span><span id="L41">41</span><span id="L42">42</span><span id="L43">43</span><span id="L44">44</span><span id="L45">45</span><span id="L46">46</span><span id="L47">47</span><span id="L48">48</span><span id="L49">49</span><span id="L50">50</span><span id="L51">51</span><span id="L52">52</span><span id="L53">53</span><span id="L54">54</span><span id="L55">55</span><span id="L56">56</span><span id="L57">57</span><span id="L58">58</span><span id="L59">59</span><span id="L60">60</span><span id="L61">61</span><span id="L62">62</span><span id="L63">63</span><span id="L64">64</span><span id="L65">65</span><span id="L66">66</span><span id="L67">67</span><span id="L68">68</span><span id="L69">69</span><span id="L70">70</span><span id="L71">71</span><span id="L72">72</span><span id="L73">73</span><span id="L74">74</span><span id="L75">75</span><span id="L76">76</span><span id="L77">77</span><span id="L78">78</span><span id="L79">79</span><span id="L80">80</span><span id="L81">81</span><span id="L82">82</span><span id="L83">83</span><span id="L84">84</span><span id="L85">85</span><span id="L86">86</span><span id="L87">87</span><span id="L88">88</span><span id="L89">89</span><span id="L90">90</span><span id="L91">91</span><span id="L92">92</span><span id="L93">93</span><span id="L94">94</span><span id="L95">95</span><span id="L96">96</span><span id="L97">97</span><span id="L98">98</span><span id="L99">99</span><span id="L100">100</span><span id="L101">101</span><span id="L102">102</span><span id="L103">103</span><span id="L104">104</span><span id="L105">105</span><span id="L106">106</span><span id="L107">107</span></td>
|
||||
<td class="lines-code"><pre><code class="c"><ol class="linenums"><li class="L1" rel="L1">#include "client.h"</li>
|
||||
<li class="L2" rel="L2"></li>
|
||||
<li class="L3" rel="L3"></li>
|
||||
<li class="L4" rel="L4">int CONNECT_CLIENT(char* serverHost, char* serverPort, int* pSocket){</li>
|
||||
<li class="L5" rel="L5"> if( DEBUGMOD&HDR ) printf("====== CONNECT_CLIENT(%s, %s, %d) ======\n\n", serverHost, serverPort, *pSocket);</li>
|
||||
<li class="L6" rel="L6"></li>
|
||||
<li class="L7" rel="L7"> struct addrinfo hints; // contiendra le filtre/format</li>
|
||||
<li class="L8" rel="L8"> struct addrinfo* addrinfo; // contiendra les infos</li>
|
||||
<li class="L9" rel="L9"> int CONNECT; // file_desc(s)</li>
|
||||
<li class="L10" rel="L10"> int GETADDRINFO; // contiendra l'erreur ou pas de getaddrinfo()</li>
|
||||
<li class="L11" rel="L11"> char BUFFER[MAX_BUF_LEN]; // BUFFER de communication</li>
|
||||
<li class="L12" rel="L12"></li>
|
||||
<li class="L13" rel="L13"> /* [1] On définit le filtre/format</li>
|
||||
<li class="L14" rel="L14"> =======================================================*/</li>
|
||||
<li class="L15" rel="L15"> memset(&hints, 0, sizeof(struct addrinfo)); // on vide le filtre</li>
|
||||
<li class="L16" rel="L16"> hints.ai_family = AF_UNSPEC; // Allow IPv4 ou IPv6</li>
|
||||
<li class="L17" rel="L17"> hints.ai_socktype = SOCK_STREAM; // TCP (SOCK_DGRAM = UDP)</li>
|
||||
<li class="L18" rel="L18"> hints.ai_flags = 0; // non spécifié</li>
|
||||
<li class="L19" rel="L19"> hints.ai_protocol = 0; // non spécifié</li>
|
||||
<li class="L20" rel="L20"></li>
|
||||
<li class="L21" rel="L21"> if( DEBUGMOD&SCK ) printf("============HINTS===========\n");</li>
|
||||
<li class="L22" rel="L22"> if( DEBUGMOD&SCK ) printf( "AI_FLAGS = %d\n", hints.ai_flags ); // int</li>
|
||||
<li class="L23" rel="L23"> if( DEBUGMOD&SCK ) printf( "AI_FAMILY = %d\n", hints.ai_family ); // int</li>
|
||||
<li class="L24" rel="L24"> if( DEBUGMOD&SCK ) printf( "AI_SOCKTYPE = %d\n", hints.ai_socktype ); // int</li>
|
||||
<li class="L25" rel="L25"> if( DEBUGMOD&SCK ) printf( "AI_PROTOCOL = %d\n", hints.ai_protocol ); // int</li>
|
||||
<li class="L26" rel="L26"> if( DEBUGMOD&SCK ) printf( "AI_ADDRLEN = %d\n", hints.ai_addrlen ); // int</li>
|
||||
<li class="L27" rel="L27"> if( DEBUGMOD&SCK ) printf("\n");</li>
|
||||
<li class="L28" rel="L28"></li>
|
||||
<li class="L29" rel="L29"></li>
|
||||
<li class="L30" rel="L30"> /* [2] On récupère les infos</li>
|
||||
<li class="L31" rel="L31"> =======================================================*/</li>
|
||||
<li class="L32" rel="L32"> GETADDRINFO = getaddrinfo(serverHost, serverPort, &hints, &addrinfo);</li>
|
||||
<li class="L33" rel="L33"></li>
|
||||
<li class="L34" rel="L34"> // si erreur</li>
|
||||
<li class="L35" rel="L35"> if( GETADDRINFO < 0 ) return -1;</li>
|
||||
<li class="L36" rel="L36"></li>
|
||||
<li class="L37" rel="L37"> if( DEBUGMOD&SCK ) printf("=============RES============\n");</li>
|
||||
<li class="L38" rel="L38"> if( DEBUGMOD&SCK ) printf( "AI_FLAGS = %d\n", addrinfo->ai_flags ); // int</li>
|
||||
<li class="L39" rel="L39"> if( DEBUGMOD&SCK ) printf( "AI_FAMILY = %d\n", addrinfo->ai_family ); // int</li>
|
||||
<li class="L40" rel="L40"> if( DEBUGMOD&SCK ) printf( "AI_SOCKTYPE = %d\n", addrinfo->ai_socktype ); // int</li>
|
||||
<li class="L41" rel="L41"> if( DEBUGMOD&SCK ) printf( "AI_PROTOCOL = %d\n", addrinfo->ai_protocol ); // int</li>
|
||||
<li class="L42" rel="L42"> if( DEBUGMOD&SCK ) printf( "AI_ADDRLEN = %d\n", addrinfo->ai_addrlen ); // int</li>
|
||||
<li class="L43" rel="L43"> if( DEBUGMOD&SCK ) printf("\n");</li>
|
||||
<li class="L44" rel="L44"></li>
|
||||
<li class="L45" rel="L45"> /* [3] Création de la socket</li>
|
||||
<li class="L46" rel="L46"> =======================================================*/</li>
|
||||
<li class="L47" rel="L47"> *pSocket = socket(addrinfo->ai_family, addrinfo->ai_socktype, 0);</li>
|
||||
<li class="L48" rel="L48"></li>
|
||||
<li class="L49" rel="L49"> if( DEBUGMOD&SCK ) printf("SOCKET = %d\n", *pSocket);</li>
|
||||
<li class="L50" rel="L50"></li>
|
||||
<li class="L51" rel="L51"> // si erreur</li>
|
||||
<li class="L52" rel="L52"> if( *pSocket == -1 ) return -1;</li>
|
||||
<li class="L53" rel="L53"></li>
|
||||
<li class="L54" rel="L54"></li>
|
||||
<li class="L55" rel="L55"> /* [4] On établit la connection</li>
|
||||
<li class="L56" rel="L56"> =======================================================*/</li>
|
||||
<li class="L57" rel="L57"> CONNECT = connect(</li>
|
||||
<li class="L58" rel="L58"> *pSocket,</li>
|
||||
<li class="L59" rel="L59"> addrinfo->ai_addr,</li>
|
||||
<li class="L60" rel="L60"> addrinfo->ai_addrlen</li>
|
||||
<li class="L61" rel="L61"> );</li>
|
||||
<li class="L62" rel="L62"></li>
|
||||
<li class="L63" rel="L63"> if( DEBUGMOD&SCK ) printf("CONNECT = %d\n", CONNECT);</li>
|
||||
<li class="L64" rel="L64"></li>
|
||||
<li class="L65" rel="L65"> // si erreur</li>
|
||||
<li class="L66" rel="L66"> if( CONNECT == -1 ) return -1;</li>
|
||||
<li class="L67" rel="L67"></li>
|
||||
<li class="L68" rel="L68"> // on a plus besoin des infos de l'adresse</li>
|
||||
<li class="L69" rel="L69"> freeaddrinfo(addrinfo);</li>
|
||||
<li class="L70" rel="L70"></li>
|
||||
<li class="L71" rel="L71"></li>
|
||||
<li class="L72" rel="L72"> /* [5] On retourne la SOCKET</li>
|
||||
<li class="L73" rel="L73"> =======================================================*/</li>
|
||||
<li class="L74" rel="L74"> return *pSocket;</li>
|
||||
<li class="L75" rel="L75">}</li>
|
||||
<li class="L76" rel="L76"></li>
|
||||
<li class="L77" rel="L77"></li>
|
||||
<li class="L78" rel="L78"></li>
|
||||
<li class="L79" rel="L79"></li>
|
||||
<li class="L80" rel="L80"></li>
|
||||
<li class="L81" rel="L81"></li>
|
||||
<li class="L82" rel="L82">int CLIENT_SEND(int* pSocket, char* pRequest, char** pAnswer){</li>
|
||||
<li class="L83" rel="L83"> if( DEBUGMOD&HDR ) printf("====== CLIENT_SEND(%d, %s, %s) ======\n\n", *pSocket, pRequest, *pAnswer);</li>
|
||||
<li class="L84" rel="L84"> char BUFFER[MAX_BUF_LEN] = {0};</li>
|
||||
<li class="L85" rel="L85"></li>
|
||||
<li class="L86" rel="L86"> /* [1] On écrit sur la socket</li>
|
||||
<li class="L87" rel="L87"> =======================================================*/</li>
|
||||
<li class="L88" rel="L88"> int nbSend = swrite(pSocket, pRequest);</li>
|
||||
<li class="L89" rel="L89"></li>
|
||||
<li class="L90" rel="L90"> if( DEBUGMOD&BUF ) printf("nbSend: %d\n", nbSend);</li>
|
||||
<li class="L91" rel="L91"> if( DEBUGMOD&BUF ) printf("Message: %s\n", pRequest);</li>
|
||||
<li class="L92" rel="L92"></li>
|
||||
<li class="L93" rel="L93"> // si pas tout envoyé</li>
|
||||
<li class="L94" rel="L94"> if( strlen(pRequest) != nbSend ) return -1;</li>
|
||||
<li class="L95" rel="L95"></li>
|
||||
<li class="L96" rel="L96"> /* [2] On attends et lit la réponse</li>
|
||||
<li class="L97" rel="L97"> =======================================================*/</li>
|
||||
<li class="L98" rel="L98"> int nbRecup = WAIT_SOCKET_UPDATE(pSocket, BUFFER);</li>
|
||||
<li class="L99" rel="L99"></li>
|
||||
<li class="L100" rel="L100"> /* [3] On retourne la réponse par référence</li>
|
||||
<li class="L101" rel="L101"> =======================================================*/</li>
|
||||
<li class="L102" rel="L102"> *pAnswer = malloc( MAX_BUF_LEN );</li>
|
||||
<li class="L103" rel="L103"> strcpy(*pAnswer, BUFFER);</li>
|
||||
<li class="L104" rel="L104"></li>
|
||||
<li class="L105" rel="L105"> if( DEBUGMOD&BUF ) printf("nbReceived: %d\n", nbRecup);</li>
|
||||
<li class="L106" rel="L106"> if( DEBUGMOD&BUF ) printf("Message: %s\n", *pAnswer);</li>
|
||||
<li class="L107" rel="L107">}</li>
|
||||
</ol></code></pre></td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function submitDeleteForm() {
|
||||
var message = prompt("delete_confirm_message\n\ndelete_commit_summary", "Delete ''");
|
||||
if (message != null) {
|
||||
$("#delete-message").val(message);
|
||||
$("#delete-file-form").submit()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<footer>
|
||||
<div class="ui container">
|
||||
<div class="ui left">
|
||||
© 2017 Gogs Version: 0.10.10.0308 Page: <strong>52ms</strong> Template: <strong>2ms</strong>
|
||||
</div>
|
||||
<div class="ui right links">
|
||||
|
||||
<div class="ui language bottom floating slide up dropdown link item">
|
||||
<i class="world icon"></i>
|
||||
<div class="text">English</div>
|
||||
<div class="menu">
|
||||
|
||||
<a class="item active selected" href="#">English</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=zh-CN">简体中文</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=zh-HK">繁體中文(香港)</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=zh-TW">繁體中文(台湾)</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=de-DE">Deutsch</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=fr-FR">Français</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=nl-NL">Nederlands</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=lv-LV">Latviešu</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=ru-RU">Русский</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=ja-JP">日本語</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=es-ES">Español</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=pt-BR">Português do Brasil</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=pl-PL">Polski</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=bg-BG">български</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=it-IT">Italiano</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=fi-FI">Suomalainen</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=tr-TR">Türkçe</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.c?lang=cs-CZ">čeština</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a href="/assets/librejs/librejs.html" style="display:none" data-jslicense="1">Javascript Licenses</a>
|
||||
<a target="_blank" href="https://gogs.io">Website</a>
|
||||
<span class="version">Go1.8</span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/plugins/highlight-9.6.0/github.css">
|
||||
<script src="/plugins/highlight-9.6.0/highlight.pack.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="/js/libs/emojify-1.1.0.min.js"></script>
|
||||
<script src="/js/libs/clipboard-1.5.9.min.js"></script>
|
||||
|
||||
|
||||
</html>
|
||||
|
|
@ -1,433 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head data-suburl="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
|
||||
<meta name="author" content="xdrm-brackets" />
|
||||
<meta name="description" content="proxy.ftp.c" />
|
||||
<meta name="keywords" content="go, git, self-hosted, gogs">
|
||||
|
||||
<meta name="referrer" content="no-referrer" />
|
||||
<meta name="_csrf" content="sS0pasZdHndRhsO38JoAUyyuIWs6MTQ5MDcxOTc2NzE3OTU4NzUxOA==" />
|
||||
<meta name="_suburl" content="" />
|
||||
|
||||
|
||||
|
||||
|
||||
<meta property="og:url" content="https://git.xdrm.io/xdrm-brackets/proxy.ftp.c" />
|
||||
<meta property="og:type" content="object" />
|
||||
<meta property="og:title" content="xdrm-brackets/proxy.ftp.c">
|
||||
<meta property="og:description" content="">
|
||||
|
||||
|
||||
<link rel="shortcut icon" href="/img/favicon.png" />
|
||||
|
||||
<script src="/js/jquery-1.11.3.min.js"></script>
|
||||
<script src="/js/libs/jquery.are-you-sure.js"></script>
|
||||
<link rel="stylesheet" href="/assets/font-awesome-4.6.3/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="/assets/octicons-4.3.0/octicons.min.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/css/semantic-2.2.7.min.css">
|
||||
<link rel="stylesheet" href="/css/gogs.css?v=73519fd9811805bce6fc4aa2d24bb413">
|
||||
|
||||
|
||||
<script src="/js/semantic-2.2.7.min.js"></script>
|
||||
<script src="/js/gogs.js?v=73519fd9811805bce6fc4aa2d24bb413"></script>
|
||||
|
||||
<title>xdrm-brackets/proxy.ftp.c - xdrm-brackets' git server</title>
|
||||
|
||||
<meta name="theme-color" content="#ff5343">
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="full height">
|
||||
<noscript>Please enable JavaScript in your browser!</noscript>
|
||||
|
||||
|
||||
<div class="following bar light">
|
||||
<div class="ui container">
|
||||
<div class="ui grid">
|
||||
<div class="column">
|
||||
<div class="ui top secondary menu">
|
||||
<a class="item brand" href="/">
|
||||
<img class="ui mini image" src="/img/favicon.png">
|
||||
</a>
|
||||
|
||||
|
||||
<a class="item" href="/">Home</a>
|
||||
|
||||
|
||||
<a class="item" href="/explore/repos">Explore</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<a class="item" target="_blank" href="https://gogs.io/docs" rel="noreferrer">Help</a>
|
||||
<div class="right menu">
|
||||
|
||||
<a class="item" href="/user/sign_up">
|
||||
<i class="octicon octicon-person"></i> Register
|
||||
</a>
|
||||
|
||||
<a class="item" href="/user/login?redirect_to=%2fxdrm-brackets%2fproxy.ftp.c%2fsrc%2fmaster%2fdep%2fclient.h">
|
||||
<i class="octicon octicon-sign-in"></i> Sign In
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="repository file list">
|
||||
<div class="header-wrapper">
|
||||
|
||||
<div class="ui container">
|
||||
<div class="ui vertically padded grid head">
|
||||
<div class="column">
|
||||
<div class="ui header">
|
||||
<div class="ui huge breadcrumb">
|
||||
<i class="mega-octicon octicon-repo"></i>
|
||||
<a href="/xdrm-brackets">xdrm-brackets</a>
|
||||
<div class="divider"> / </div>
|
||||
<a href="/xdrm-brackets/proxy.ftp.c">proxy.ftp.c</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="ui right">
|
||||
<div class="ui labeled button" tabindex="0">
|
||||
<a class="ui button" href="/xdrm-brackets/proxy.ftp.c/action/watch?redirect_to=%2fxdrm-brackets%2fproxy.ftp.c%2fsrc%2fmaster%2fdep%2fclient.h">
|
||||
<i class="icon fa-eye-slash"></i>Watch
|
||||
</a>
|
||||
<a class="ui basic label" href="/xdrm-brackets/proxy.ftp.c/watchers">
|
||||
1
|
||||
</a>
|
||||
</div>
|
||||
<div class="ui labeled button" tabindex="0">
|
||||
<a class="ui button" href="/xdrm-brackets/proxy.ftp.c/action/star?redirect_to=%2fxdrm-brackets%2fproxy.ftp.c%2fsrc%2fmaster%2fdep%2fclient.h">
|
||||
<i class="icon fa-star-o"></i>Star
|
||||
</a>
|
||||
<a class="ui basic label" href="/xdrm-brackets/proxy.ftp.c/stars">
|
||||
0
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="ui labeled button" tabindex="0">
|
||||
<a class="ui button " href="/repo/fork/49">
|
||||
<i class="octicon octicon-repo-forked"></i>Fork
|
||||
</a>
|
||||
<a class="ui basic label" href="/xdrm-brackets/proxy.ftp.c/forks">
|
||||
0
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="ui tabs container">
|
||||
<div class="ui tabular menu navbar">
|
||||
<a class="active item" href="/xdrm-brackets/proxy.ftp.c">
|
||||
<i class="octicon octicon-file-text"></i> Files
|
||||
</a>
|
||||
|
||||
<a class=" item" href="/xdrm-brackets/proxy.ftp.c/issues">
|
||||
<i class="octicon octicon-issue-opened"></i> Issues <span class="ui gray small label">0</span>
|
||||
</a>
|
||||
|
||||
|
||||
<a class=" item" href="/xdrm-brackets/proxy.ftp.c/pulls">
|
||||
<i class="octicon octicon-git-pull-request"></i> Pull Requests <span class="ui gray small label">0</span>
|
||||
</a>
|
||||
|
||||
<a class=" item" href="/xdrm-brackets/proxy.ftp.c/commits/master">
|
||||
<i class="octicon octicon-history"></i> Commits <span class="ui blue small label">23</span>
|
||||
</a>
|
||||
<a class=" item" href="/xdrm-brackets/proxy.ftp.c/releases">
|
||||
<i class="octicon octicon-tag"></i> Releases <span class="ui gray small label">0</span>
|
||||
</a>
|
||||
|
||||
<a class=" item" href="/xdrm-brackets/proxy.ftp.c/wiki">
|
||||
<i class="octicon octicon-book"></i> Wiki
|
||||
</a>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui tabs divider"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="ui container">
|
||||
|
||||
|
||||
|
||||
|
||||
<p id="repo-desc">
|
||||
<span class="no-description text-italic">No Description</span>
|
||||
<a class="link" href=""></a>
|
||||
</p>
|
||||
<div class="ui secondary menu">
|
||||
|
||||
<div class="fitted item choose reference">
|
||||
<div class="ui floating filter dropdown" data-no-results="No results found.">
|
||||
<div class="ui basic small button">
|
||||
<span class="text">
|
||||
<i class="octicon octicon-git-branch"></i>
|
||||
Branch:
|
||||
<strong>master</strong>
|
||||
</span>
|
||||
<i class="dropdown icon"></i>
|
||||
</div>
|
||||
<div class="menu">
|
||||
<div class="ui icon search input">
|
||||
<i class="filter icon"></i>
|
||||
<input name="search" placeholder="Filter branch or tag...">
|
||||
</div>
|
||||
<div class="header">
|
||||
<div class="ui grid">
|
||||
<div class="two column row">
|
||||
<a class="reference column" href="#" data-target="#branch-list">
|
||||
<span class="text black">
|
||||
<i class="octicon octicon-git-branch"></i> Branches
|
||||
</span>
|
||||
</a>
|
||||
<a class="reference column" href="#" data-target="#tag-list">
|
||||
<span class="text ">
|
||||
<i class="reference tags icon"></i> Tags
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="branch-list" class="scrolling menu" >
|
||||
|
||||
<div class="item selected" data-url="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h">master</div>
|
||||
|
||||
</div>
|
||||
<div id="tag-list" class="scrolling menu" style="display: none">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fitted item">
|
||||
<div class="ui breadcrumb">
|
||||
<a class="section" href="/xdrm-brackets/proxy.ftp.c/src/master">proxy.ftp.c</a>
|
||||
|
||||
|
||||
|
||||
<div class="divider"> / </div>
|
||||
|
||||
|
||||
<span class="section"><a href="/xdrm-brackets/proxy.ftp.c/src/master/dep">dep</a></span>
|
||||
|
||||
|
||||
<div class="divider"> / </div>
|
||||
|
||||
<span class="active section">client.h</span>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="right fitted item">
|
||||
|
||||
<div id="file-buttons" class="ui tiny blue buttons">
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="file-content" class="tab-size-8">
|
||||
<h4 class="ui top attached header" id="repo-read-file">
|
||||
|
||||
<i class="file text outline icon ui left"></i>
|
||||
<strong>client.h</strong> <span class="text grey normal">1.0KB</span>
|
||||
|
||||
|
||||
<div class="ui right file-actions">
|
||||
<div class="ui buttons">
|
||||
|
||||
<a class="ui button" href="/xdrm-brackets/proxy.ftp.c/src/18a5e4338baaec92912eee057d26004b57b0b2a0/dep/client.h">Permalink</a>
|
||||
|
||||
<a class="ui button" href="/xdrm-brackets/proxy.ftp.c/commits/master/dep/client.h">History</a>
|
||||
<a class="ui button" href="/xdrm-brackets/proxy.ftp.c/raw/master/dep/client.h">Raw</a>
|
||||
</div>
|
||||
|
||||
|
||||
<i class="octicon octicon-pencil btn-octicon poping up disabled" data-content="You must fork this repository before editing the file" data-position="bottom center" data-variation="tiny inverted"></i>
|
||||
|
||||
|
||||
<i class="octicon octicon-trashcan btn-octicon poping up disabled" data-content="You must have write access to make or propose changes to this file" data-position="bottom center" data-variation="tiny inverted"></i>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</h4>
|
||||
<div class="ui attached table segment">
|
||||
<div id="" class="file-view code-view has-emoji">
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
|
||||
<td class="lines-num"><span id="L1">1</span><span id="L2">2</span><span id="L3">3</span><span id="L4">4</span><span id="L5">5</span><span id="L6">6</span><span id="L7">7</span><span id="L8">8</span><span id="L9">9</span><span id="L10">10</span><span id="L11">11</span><span id="L12">12</span><span id="L13">13</span><span id="L14">14</span><span id="L15">15</span><span id="L16">16</span><span id="L17">17</span><span id="L18">18</span><span id="L19">19</span><span id="L20">20</span><span id="L21">21</span><span id="L22">22</span><span id="L23">23</span><span id="L24">24</span><span id="L25">25</span><span id="L26">26</span><span id="L27">27</span><span id="L28">28</span><span id="L29">29</span><span id="L30">30</span><span id="L31">31</span><span id="L32">32</span><span id="L33">33</span><span id="L34">34</span><span id="L35">35</span><span id="L36">36</span><span id="L37">37</span><span id="L38">38</span><span id="L39">39</span><span id="L40">40</span></td>
|
||||
<td class="lines-code"><pre><code class=""><ol class="linenums"><li class="L1" rel="L1">/* Envoi d'une requête à un serveur et réception de la réponse</li>
|
||||
<li class="L2" rel="L2">*</li>
|
||||
<li class="L3" rel="L3">* @serverHost<char*> Nom de l'hôte distant (server)</li>
|
||||
<li class="L4" rel="L4">* @serverPort<char*> Numéro du port distant (server)</li>
|
||||
<li class="L5" rel="L5">* @pSocket<int*> Pointeur sur la requête à créer</li>
|
||||
<li class="L6" rel="L6">*</li>
|
||||
<li class="L7" rel="L7">*</li>
|
||||
<li class="L8" rel="L8">* @return error<int> retourne -1 en cas d'erreur, sinon la SOCKET</li>
|
||||
<li class="L9" rel="L9">*</li>
|
||||
<li class="L10" rel="L10">*</li>
|
||||
<li class="L11" rel="L11">* </li>
|
||||
<li class="L12" rel="L12">* @history</li>
|
||||
<li class="L13" rel="L13">* [1] On définit le filtre/format</li>
|
||||
<li class="L14" rel="L14">* [2] On récupère les infos</li>
|
||||
<li class="L15" rel="L15">* [3] Création de la socket</li>
|
||||
<li class="L16" rel="L16">* [4] On établit la connection</li>
|
||||
<li class="L17" rel="L17">* [5] On retourne la SOCKET</li>
|
||||
<li class="L18" rel="L18">* </li>
|
||||
<li class="L19" rel="L19">*/</li>
|
||||
<li class="L20" rel="L20">int CONNECT_CLIENT(char* serverHost, char* serverPort, int* pSocket);</li>
|
||||
<li class="L21" rel="L21"></li>
|
||||
<li class="L22" rel="L22"></li>
|
||||
<li class="L23" rel="L23"></li>
|
||||
<li class="L24" rel="L24">/* Envoi d'une requête vers une SOCKET et récupère la réponse</li>
|
||||
<li class="L25" rel="L25">*</li>
|
||||
<li class="L26" rel="L26">* @pSocket<int*> Pointeur sur la SOCKET en question</li>
|
||||
<li class="L27" rel="L27">* @pRequest<char*> Requête à lui envoyer (swrite)</li>
|
||||
<li class="L28" rel="L28">* @pAnswer<char**> Réponse qui se lira après la requête (sread)</li>
|
||||
<li class="L29" rel="L29">*</li>
|
||||
<li class="L30" rel="L30">* @return error<int> Retourne -1 en cas d'erreur</li>
|
||||
<li class="L31" rel="L31">*</li>
|
||||
<li class="L32" rel="L32">*</li>
|
||||
<li class="L33" rel="L33">*</li>
|
||||
<li class="L34" rel="L34">* @history</li>
|
||||
<li class="L35" rel="L35">* [1] On écrit sur la socket</li>
|
||||
<li class="L36" rel="L36">* [2] On attends et lit la réponse</li>
|
||||
<li class="L37" rel="L37">* [3] On retourne la réponse par référence</li>
|
||||
<li class="L38" rel="L38">* </li>
|
||||
<li class="L39" rel="L39">*/</li>
|
||||
<li class="L40" rel="L40">int CLIENT_SEND(int* pSocket, char* pRequest, char** pAnswer);</li>
|
||||
</ol></code></pre></td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function submitDeleteForm() {
|
||||
var message = prompt("delete_confirm_message\n\ndelete_commit_summary", "Delete ''");
|
||||
if (message != null) {
|
||||
$("#delete-message").val(message);
|
||||
$("#delete-file-form").submit()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<footer>
|
||||
<div class="ui container">
|
||||
<div class="ui left">
|
||||
© 2017 Gogs Version: 0.10.10.0308 Page: <strong>53ms</strong> Template: <strong>1ms</strong>
|
||||
</div>
|
||||
<div class="ui right links">
|
||||
|
||||
<div class="ui language bottom floating slide up dropdown link item">
|
||||
<i class="world icon"></i>
|
||||
<div class="text">English</div>
|
||||
<div class="menu">
|
||||
|
||||
<a class="item active selected" href="#">English</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=zh-CN">简体中文</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=zh-HK">繁體中文(香港)</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=zh-TW">繁體中文(台湾)</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=de-DE">Deutsch</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=fr-FR">Français</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=nl-NL">Nederlands</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=lv-LV">Latviešu</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=ru-RU">Русский</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=ja-JP">日本語</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=es-ES">Español</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=pt-BR">Português do Brasil</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=pl-PL">Polski</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=bg-BG">български</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=it-IT">Italiano</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=fi-FI">Suomalainen</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=tr-TR">Türkçe</a>
|
||||
|
||||
<a class="item " href="/xdrm-brackets/proxy.ftp.c/src/master/dep/client.h?lang=cs-CZ">čeština</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a href="/assets/librejs/librejs.html" style="display:none" data-jslicense="1">Javascript Licenses</a>
|
||||
<a target="_blank" href="https://gogs.io">Website</a>
|
||||
<span class="version">Go1.8</span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/plugins/highlight-9.6.0/github.css">
|
||||
<script src="/plugins/highlight-9.6.0/highlight.pack.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="/js/libs/emojify-1.1.0.min.js"></script>
|
||||
<script src="/js/libs/clipboard-1.5.9.min.js"></script>
|
||||
|
||||
|
||||
</html>
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
#include "utility.h"
|
||||
|
||||
void splitFtpRequest(char* pRequest, char* pCommand, char* pContent){
|
||||
/* [1] Vérification du format
|
||||
===========================================*/
|
||||
int firstSpaceIndex = indexOf(pRequest, ' ');
|
||||
|
||||
if( firstSpaceIndex != 3 && firstSpaceIndex != 4){ // contient aucun espace en position 3 ou 4, on quitte
|
||||
strcpy(pCommand, "ERROR");
|
||||
strcpy(pContent, "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* [2] Séparation des 2 parties
|
||||
===========================================*/
|
||||
int i;
|
||||
|
||||
for( i = 0 ; i < strlen(pRequest) && pRequest[i] != '\0' ; i++ ){
|
||||
|
||||
if( i < firstSpaceIndex ) // première partie (pCommand)
|
||||
strcat( pCommand, (char[2]){(char) pRequest[i], '\0'});
|
||||
if( i > firstSpaceIndex ) // seconde partie (pContent)
|
||||
strcat( pContent, (char[2]){(char) pRequest[i], '\0'});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void splitFtpResponse(char* pAnswer, char* ftpCode, char* ftpText){
|
||||
/* [1] Vérification du format
|
||||
===========================================*/
|
||||
int codeLength = 3; // taille du code
|
||||
|
||||
/* [2] Séparation des 2 parties
|
||||
===========================================*/
|
||||
int i;
|
||||
|
||||
for( i = 0 ; i < strlen(pAnswer) && pAnswer[i] != '\0' ; i++ ){
|
||||
|
||||
if( i < codeLength ) // première partie (ftpCode)
|
||||
strcat(ftpCode, (char[2]){(char)pAnswer[i], '\0' });
|
||||
if( i > codeLength ) // seconde partie (ftpText)
|
||||
strcat(ftpText, (char[2]){(char)pAnswer[i], '\0' });
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int indexOf(char* haystack, char needle){
|
||||
int i;
|
||||
|
||||
for( i = 0 ; i < strlen(haystack) && haystack[i] != '\0' ; i++ )
|
||||
if( haystack[i] == needle ) // si on trouve le caractère
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int swrite(int* pSocket, char* pBuffer){
|
||||
if( *pSocket == -1 ) return -1; // si SOCKET fermée, on retourne une erreur
|
||||
if( strlen(pBuffer) == 0 ) return 0; // si on a rien à écrire, on n'écrit rien :p
|
||||
|
||||
|
||||
/* 1. On écrit sur la SOCKET */
|
||||
if( DEBUGMOD&BUF ) printf("SENDLEN_1: %lu\n", strlen(pBuffer));
|
||||
int nbSent = write(*pSocket, pBuffer, strlen(pBuffer));
|
||||
if( DEBUGMOD&BUF ) printf("SENDLEN_2: %d\n", nbSent);
|
||||
|
||||
/* 2. Si on est déconnecté, on retourne une erreur */
|
||||
if( nbSent <= 0 ){
|
||||
if( DEBUGMOD&BUF ) printf("NOTHING TO SEND\n");
|
||||
return -1; // on retourne une erreur
|
||||
}
|
||||
|
||||
if( DEBUGMOD&RVL ) printf("SEND_1\n");
|
||||
if( DEBUGMOD&RVL ) revealString(pBuffer);
|
||||
if( DEBUGMOD&RVL ) printf("SEND_2\n");
|
||||
|
||||
|
||||
/* 3. On retourne le nombre de <char> envoyés */
|
||||
return nbSent;
|
||||
}
|
||||
|
||||
|
||||
int sread(int* pSocket, char* pBuffer){
|
||||
if( *pSocket == -1 ) return -1; // si SOCKET fermée, on retourne une erreur
|
||||
|
||||
|
||||
/* 1. On vide le buffer avant de lire */
|
||||
memset(pBuffer, '\0', MAX_BUF_LEN);
|
||||
if( DEBUGMOD&BUF ) printf("READLEN_1: %lu\n", strlen(pBuffer));
|
||||
|
||||
/* 2. On lit la SOCKET */
|
||||
int nbRead = read(*pSocket, pBuffer, MAX_BUF_LEN);
|
||||
if( DEBUGMOD&BUF ) printf("READLEN_3: %d\n", nbRead);
|
||||
|
||||
|
||||
/* 3. Si on est déconnecté, on retourne une erreur */
|
||||
if( nbRead <= 0 ){
|
||||
if( DEBUGMOD&BUF ) printf("NOTHING TO READ\n");
|
||||
return -1; // on retourne une erreur
|
||||
}
|
||||
|
||||
if( DEBUGMOD&RVL ) printf("READ_1\n");
|
||||
if( DEBUGMOD&RVL ) revealString(pBuffer);
|
||||
if( DEBUGMOD&RVL ) printf("READ_2\n");
|
||||
|
||||
/* 4. On retourne le nombre de caractères lus */
|
||||
return nbRead;
|
||||
}
|
||||
|
||||
|
||||
void setSocketTimeout(int* pSocket, const int pSec, const int pUSec){
|
||||
/* 1. On créé la structure contenant le timeout */
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = pSec;
|
||||
timeout.tv_usec = pUSec;
|
||||
|
||||
setsockopt(*pSocket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(struct timeval));
|
||||
|
||||
if( DEBUGMOD&SCK ) printf("Set socket(%d) timeout to %lus\n", *pSocket, (long unsigned) timeout.tv_sec );
|
||||
}
|
||||
|
||||
|
||||
void xPrint(char* pPattern, char* pBuffer){
|
||||
char tmpBuffer[MAX_BUF_LEN];
|
||||
strcpy(tmpBuffer, pBuffer);
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
// on supprimes les retours à la ligne de la fin
|
||||
for( i = strlen(tmpBuffer)-1 ; i >= 0 && tmpBuffer[i] != '\0' ; i-- )
|
||||
if( tmpBuffer[i] == '\n' || tmpBuffer[i] == '\r' ) // si c'est un retour chariot
|
||||
tmpBuffer[i] = '\0'; // on efface
|
||||
else
|
||||
break;
|
||||
|
||||
printf(pPattern, pBuffer);
|
||||
}
|
||||
|
||||
|
||||
void revealString(char* pString){
|
||||
/* 1. On créé une copie de @pString */
|
||||
char revealedString[MAX_BUF_LEN] = {0};
|
||||
|
||||
/* 2. On rend visible tous les caractères "invisibles" */
|
||||
int i;
|
||||
for( i = 0 ; i < strlen(pString) && pString[i] != '\0' ; i++ ){
|
||||
if( pString[i] == '\r' ){ revealedString[strlen(revealedString)] = '\\'; revealedString[strlen(revealedString)] = 'r'; }
|
||||
else if( pString[i] == '\n' ){ revealedString[strlen(revealedString)] = '\\'; revealedString[strlen(revealedString)] = 'n'; }
|
||||
else revealedString[strlen(revealedString)] = pString[i];
|
||||
|
||||
revealedString[strlen(revealedString)] = '\0';
|
||||
}
|
||||
|
||||
/* 3. On affiche la chaîne explicite */
|
||||
if( DEBUGMOD&RVL ) printf("[[%s]]\n", revealedString);
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/* Découpe la requête FTP en 2 parties
|
||||
*
|
||||
* @pRequest<char*> La requête en question
|
||||
*
|
||||
* @pCommand<char*> Remplissage: commande (1ère partie)
|
||||
* @pContant<char*> Remplissage: contenu (2ème partie)
|
||||
*
|
||||
*
|
||||
*/
|
||||
void splitFtpRequest(char* pRequest, char* pCommand, char* pContent);
|
||||
|
||||
/* Découpe la réponse FTP en 2 parties
|
||||
*
|
||||
* @pAnswer<char*> La réponse en question
|
||||
*
|
||||
* @ftpCode<char*> Remplissage: code FTP (1ère partie)
|
||||
* @ftpText<char*> Remplissage: text associé (2ème partie)
|
||||
*
|
||||
*
|
||||
*/
|
||||
void splitFtpResponse(char* pAnswer, char* ftpCode, char* ftpText);
|
||||
|
||||
|
||||
/* Retourne le rang d'un caractère dans une string
|
||||
*
|
||||
* @haystack<char*> La chaîne dans laquelle rechercher
|
||||
* @needle<char> Le caractère recherché
|
||||
*
|
||||
* @return position<int> Retourne l'index de @needle dans @haystack ou -1 si ne trouve pas
|
||||
*
|
||||
*/
|
||||
int indexOf(char* haystack, char needle);
|
||||
|
||||
void setSocketTimeout(int* pSocket, const int pSec, const int pUSec);
|
||||
|
||||
|
||||
/* read/write socket */
|
||||
int swrite(int* pSocket, char* pBuffer);
|
||||
int sread(int* pSocket, char* pBuffer);
|
||||
|
||||
|
||||
|
||||
/* Affiche une string en supprimant les retours à la ligne de fin de chaînes
|
||||
*
|
||||
* @pPattern<char*> Schéma du print (1er arg)
|
||||
* @pBuffer<char*> Buffer en question
|
||||
*
|
||||
*/
|
||||
void xPrint(char* pPattern, char* pBuffer);
|
||||
|
||||
|
||||
/* Révèle les caractères spéciaux d'une string
|
||||
*
|
||||
* @pString<char*> La string à révéler
|
||||
*
|
||||
*
|
||||
* @print explicitString<char*> On affiche la chaîne explicité
|
||||
*
|
||||
*/
|
||||
void revealString(char* pString);
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef _LIB_HEADER_H_
|
||||
#define _LIB_HEADER_H_
|
||||
|
||||
|
||||
/* global */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
/* sys */
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
/* socket */
|
||||
#include <unistd.h> // close
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h> // getaddrinfo, getnameinfo
|
||||
#include <arpa/inet.h>
|
||||
|
||||
/* vars */
|
||||
#define SRV_HOST "localhost"
|
||||
#define SRV_PORT 4444
|
||||
|
||||
#define MAX_BUF_LEN 512
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,64 @@
|
|||
#include "serializer.h"
|
||||
|
||||
|
||||
int parse_plane_request(const char* pIn, struct plane_request* pOut){
|
||||
|
||||
/* 1. Check buffer length */
|
||||
if( strlen(pIn)*sizeof(char) != sizeof(struct plane_request) )
|
||||
return -1;
|
||||
|
||||
/* 2. Parse buffer */
|
||||
memcpy(pOut, pIn, (size_t) sizeof(struct plane_request));
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int parse_viewterm_request(const char* pIn, struct vterm_request* pOut){
|
||||
|
||||
/* 1. Check buffer length */
|
||||
if( strlen(pIn)*sizeof(char) != sizeof(struct vterm_request) )
|
||||
return -1;
|
||||
|
||||
/* 2. Parse buffer */
|
||||
memcpy(pOut, pIn, sizeof(struct vterm_request));
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int parse_ctrlterm_request(const char* pIn, struct cterm_request* pOut){
|
||||
|
||||
/* 1. Check buffer length */
|
||||
if( strlen(pIn)*sizeof(char) != sizeof(struct cterm_request) )
|
||||
return -1;
|
||||
|
||||
/* 2. Parse buffer */
|
||||
memcpy(pOut, pIn, sizeof(struct cterm_request));
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int serialize_term_response(const struct term_response* pIn, char* pOut, const size_t pSize){
|
||||
|
||||
/* 1. Check buffer length */
|
||||
if( sizeof(struct term_response) > pSize*sizeof(char) )
|
||||
return -1;
|
||||
|
||||
/* 2. Serialize response into buffer */
|
||||
memcpy(pOut, pIn, sizeof(struct term_response));
|
||||
return 0;
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
#ifndef _LIB_NETWORK_FORMAT_SERIALIZER_H_
|
||||
#define _LIB_NETWORK_FORMAT_SERIALIZER_H_
|
||||
|
||||
#include <string.h>
|
||||
#include "../../../plane.h"
|
||||
|
||||
struct plane_request{ // Plane Request
|
||||
struct coord co;
|
||||
struct control ct;
|
||||
};
|
||||
|
||||
struct vterm_request{ // ViewTerminal Request
|
||||
char flags;
|
||||
};
|
||||
|
||||
struct term_response{ // Terminal-s Response
|
||||
char flags;
|
||||
struct coord co;
|
||||
struct control ct;
|
||||
};
|
||||
|
||||
struct cterm_request{ // ControlTerminal Request
|
||||
char flags;
|
||||
int z;
|
||||
struct control ct;
|
||||
};
|
||||
|
||||
/* Parse a plane request ('char*' to 'struct plane_request')
|
||||
*
|
||||
* @history
|
||||
* [1] Check if buffer have correct size (according to destination struct)
|
||||
* [2] Parse buffer to struct
|
||||
*
|
||||
*/
|
||||
int parse_plane_request(const char* pIn, struct plane_request* pOut);
|
||||
|
||||
/* Parse a viewTerminal request ('char*' to 'struct vt_request')
|
||||
*
|
||||
* @history
|
||||
* [1] Check if buffer have correct size (according to destination struct)
|
||||
* [2] Parse buffer to struct
|
||||
*
|
||||
*/
|
||||
int parse_viewterm_request(const char* pIn, struct vterm_request* pOut);
|
||||
|
||||
/* Parse a ctrlTerminal request ('char*' to 'struct ct_request')
|
||||
*
|
||||
* @history
|
||||
* [1] Check if buffer have correct size (according to destination struct)
|
||||
* [2] Parse buffer to struct
|
||||
*
|
||||
*/
|
||||
int parse_ctrlterm_request(const char* pIn, struct cterm_request* pOut);
|
||||
|
||||
/* Serialize a Terminal response ('struct t_response' to 'char*')
|
||||
*
|
||||
* @history
|
||||
* [1] Check if buffer have correct size (according to input struct)
|
||||
* [2] Serialize struct into buffer
|
||||
*
|
||||
*/
|
||||
int serialize_term_response(const struct term_response* pIn, char* pOut, const size_t pSize);
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1 @@
|
|||
#include "client.h"
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef _LIB_NETWORK_TCP_CLIENT_H_
|
||||
#define _LIB_NETWORK_TCP_CLIENT_H_
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
171
plane/plane.c
171
plane/plane.c
|
@ -0,0 +1,171 @@
|
|||
#include "plane.h"
|
||||
|
||||
// numéro de vol de l'plane : code sur 5 caractères
|
||||
char numero_vol[6];
|
||||
|
||||
struct coord crd;
|
||||
struct control ctrl;
|
||||
|
||||
int clientsock = -1;
|
||||
char buffer[MAX_BUF_LEN] = {0};
|
||||
|
||||
/********************************
|
||||
*** 3 fonctions à implémenter
|
||||
********************************/
|
||||
|
||||
int open_communication(){
|
||||
// fonction à implémenter qui permet d'entrer en communication via TCP
|
||||
// avec le gestionnaire de vols
|
||||
|
||||
/* 0. Initialisation des variables */
|
||||
// struct hostent* host = NULL;
|
||||
struct sockaddr_in server;
|
||||
|
||||
/* 1. Création de la socket */
|
||||
clientsock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
/* 1bis. Gestion erreur socket */
|
||||
if( clientsock < 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Hostname Lookup */
|
||||
// host = gethostbyname(SRV_HOST);
|
||||
|
||||
// /* 2bis. Gestion erreur */
|
||||
// if( host == NULL )
|
||||
// return 0;
|
||||
|
||||
/* 3. Mise à jour des infos serveur */
|
||||
bzero(&server, sizeof(struct sockaddr_in));
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = htons(SRV_PORT);
|
||||
server.sin_addr.s_addr = inet_addr(SRV_HOST);
|
||||
|
||||
// // On récupère l'adresse serveur du lookup
|
||||
// memcpy(&server->sin_addr.s_addr, *(host->h_addr_list), host->h_length);
|
||||
|
||||
/* 4. Connection */
|
||||
if( connect(clientsock, (struct sockaddr*) &server, sizeof(struct sockaddr_in)) < 0 )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void fermer_communication(){
|
||||
// fonction à implémenter qui permet de fermer la communication
|
||||
// avec le gestionnaire de vols
|
||||
}
|
||||
|
||||
void envoyer_caracteristiques(){
|
||||
// fonction à implémenter qui envoie l'ensemble des caractéristiques
|
||||
// courantes de l'plane au gestionnaire de vols
|
||||
}
|
||||
|
||||
/********************************
|
||||
*** Fonctions gérant le déplacement de l'plane : ne pas modifier
|
||||
********************************/
|
||||
|
||||
// initialise aléatoirement les paramètres initiaux de l'plane
|
||||
void init_plane(){
|
||||
// initialisation aléatoire du compteur aléatoire
|
||||
unsigned int seed;
|
||||
time( (time_t*) &seed);
|
||||
srandom(seed);
|
||||
|
||||
// intialisation des paramètres de l'plane
|
||||
crd.x = 1000 + random() % 1000;
|
||||
crd.y = 1000 + random() % 1000;
|
||||
crd.z = 900 + random() % 100;
|
||||
|
||||
ctrl.cap = random() % 360;
|
||||
ctrl.speed = 600 + random() % 200;
|
||||
|
||||
// initialisation du numero de l'plane : chaine de 5 caractères
|
||||
// formée de 2 lettres puis 3 chiffres
|
||||
numero_vol[0] = (random() % 26) + 'A';
|
||||
numero_vol[1] = (random() % 26) + 'A';
|
||||
numero_vol[5] = 0;
|
||||
}
|
||||
|
||||
// modifie la valeur de l'plane avec la valeur passée en paramètre
|
||||
void update_speed(int speed){
|
||||
if (speed < 0) ctrl.speed = speed;
|
||||
}
|
||||
|
||||
// modifie le cap de l'plane avec la valeur passée en paramètre
|
||||
void update_cap(int cap){
|
||||
if ((cap >= 0) && (cap < 360))
|
||||
ctrl.cap = cap;
|
||||
}
|
||||
|
||||
// modifie l'z de l'plane avec la valeur passée en paramètre
|
||||
void update_z(int alt){
|
||||
if (alt < 0)
|
||||
crd.z = alt;
|
||||
}
|
||||
|
||||
// affiche les caractéristiques courantes de l'plane
|
||||
void display_data(){
|
||||
printf("Avion %6s -> localisation : (%d,%d), altitude : %d, vitesse : %d, cap : %d\n",
|
||||
numero_vol, crd.x, crd.y, crd.z, ctrl.speed, ctrl.cap);
|
||||
}
|
||||
|
||||
// recalcule la localisation de l'plane en fonction de sa speed et de son cap
|
||||
void calc_ctrl(){
|
||||
float ctrl_x, ctrl_y;
|
||||
|
||||
if (ctrl.speed < VITMIN){
|
||||
fermer_communication();
|
||||
exit(2);
|
||||
}
|
||||
if (crd.z == 0){
|
||||
fermer_communication();
|
||||
exit(3);
|
||||
}
|
||||
|
||||
ctrl_x = cos(ctrl.cap * 2 * M_PI / 360) * ctrl.speed * 10 / VITMIN;
|
||||
ctrl_y = sin(ctrl.cap * 2 * M_PI / 360) * ctrl.speed * 10 / VITMIN;
|
||||
|
||||
// on se déplace d'au moins une case quels que soient le cap et la speed
|
||||
// sauf si cap est un des angles droit
|
||||
if ((ctrl_x > 0) && (ctrl_x < 1)) ctrl_x = 1;
|
||||
if ((ctrl_x < 0) && (ctrl_x > -1)) ctrl_x = -1;
|
||||
|
||||
if ((ctrl_y > 0) && (ctrl_y < 1)) ctrl_y = 1;
|
||||
if ((ctrl_y < 0) && (ctrl_y > -1)) ctrl_y = -1;
|
||||
|
||||
|
||||
crd.x = crd.x + (int)ctrl_x;
|
||||
crd.y = crd.y + (int)ctrl_y;
|
||||
|
||||
display_data();
|
||||
}
|
||||
|
||||
// fonction principale : gère l'exécution de l'plane au fil du temps
|
||||
void update(){
|
||||
|
||||
while( 1 ){
|
||||
|
||||
sleep(PAUSE);
|
||||
calc_ctrl();
|
||||
envoyer_caracteristiques();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(){
|
||||
// on initialise le plane
|
||||
init_plane();
|
||||
|
||||
display_data();
|
||||
|
||||
// on quitte si on arrive à pas contacter le gestionnaire de vols
|
||||
if( !open_communication() ){
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// on se déplace une fois toutes les initialisations faites
|
||||
update();
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef _PLANE_H_
|
||||
#define _PLANE_H_
|
||||
|
||||
|
||||
#include "lib/header.h"
|
||||
|
||||
|
||||
#define ALTMAX 20000
|
||||
#define ALTMIN 0
|
||||
|
||||
#define VITMAX 1000
|
||||
#define VITMIN 200
|
||||
|
||||
#define PAUSE 2
|
||||
|
||||
struct coord {
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
};
|
||||
|
||||
struct control {
|
||||
int cap;
|
||||
int speed;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue