Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/elvnct/AlloHouston
Browse files Browse the repository at this point in the history
  • Loading branch information
AxelVincent committed Dec 8, 2017
2 parents 3d84388 + c61ea94 commit 6311d00
Show file tree
Hide file tree
Showing 114 changed files with 8,516 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# file: ~/.gitignore_global
.DS_Store
.idea
*/AlloHoustonServer
*/AlloHoustonClient
.serveur/bin/AlloHoustonServer
.client/bin/AlloHoustonClient
2,494 changes: 2,494 additions & 0 deletions Doxyfile

Large diffs are not rendered by default.

Binary file added client/bin/AlloHoustonClient
Binary file not shown.
2 changes: 1 addition & 1 deletion client/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CC = gcc
CFLAGS = -Iheaders
SRCS = ./sources/main.c
OBJS = $(SRCS:.c=.o)
EXEC = AlloHoustonClient
EXEC = ./bin/AlloHoustonClient

all: $(EXEC)
$(EXEC): $(OBJS)
Expand Down
51 changes: 48 additions & 3 deletions client/sources/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,22 @@
#define INVALID_SOCKET -1
#define SIZE_MSG 1024


/**
* @file client/main.c
* @date 5 Dec 2017
* @brief Main du client
*
* @see ../headers/main.h
*/


/**
* @fn int main(int argc, char *argv[])
* @brief Fonction main du client
* @param argc le nombre de paramètres
* @param argv[] les paramètres de la commande
* @return 1 si reussite, 0 sinon
*/
int main(int argc, char *argv[])
{
if(argc == 3)
Expand Down Expand Up @@ -77,7 +92,15 @@ int main(int argc, char *argv[])

}

char* getHostName(char* host_name){

/**
* @fn char* getHostName(char* host_name)
* @brief Recupère le hostname grace a la fonction gethostbyname
* @param host_name le nom de l'host
* @return le nom de l'adresse
*/
char* getHostName(char* host_name)
{
struct hostent* host_info;
host_info = gethostbyname(host_name);

Expand Down Expand Up @@ -105,6 +128,14 @@ char* getHostName(char* host_name){

}


/**
* @fn int creationClient(char* adresse, int numeroPort)
* @brief Créer le client
* @param adresse le nom de l'host
* @param numeroPort le numero de port
* @return le descripteur de fichier
*/
int creationClient(char* adresse, int numeroPort)
{

Expand Down Expand Up @@ -141,7 +172,13 @@ int creationClient(char* adresse, int numeroPort)
}



/**
* @fn void lectureEntreeClient(int descripteurSocketClient, char * messageAEnvoyer)
* @brief Ecrit au serveur
* @param descripteurSocketClient le socket a qui parler
* @param messageAEnvoyer le message a envoyer
* @return void
*/
void lectureEntreeClient(int descripteurSocketClient, char * messageAEnvoyer)
{
int resultWrite;
Expand All @@ -151,6 +188,14 @@ void lectureEntreeClient(int descripteurSocketClient, char * messageAEnvoyer)
resultWrite = write(descripteurSocketClient, messageAEnvoyer, SIZE_MSG);
}


/**
* @fn void receptionMessageServeur(int descripteurSocketClient, char *commandeRecu)
* @brief recoit les messages
* @param descripteurSocketClient le socket a qui parler
* @param commandeRecu la command recu
* @return void
*/
void receptionMessageServeur(int descripteurSocketClient, char *commandeRecu){

//Reception des messages serveur
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Allo Houston: /home/abyfall/Projet/AlloHouston/serveur/sources/train.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Allo Houston
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
<div class="headertitle">
<div class="title">/home/abyfall/Projet/AlloHouston/serveur/sources/train.c</div> </div>
</div><!--header-->
<div class="contents">
<p>char *nomFichier = "../ressources/Trains.txt"; Train **listeTrain; int nbTrain; listeTrain = trainFromFile(nomFichier, &amp;nbTrain); // Récupération de la liste de train</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;../headers/temps.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;../headers/train.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;../headers/outils.h&quot;</span></div><div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;string.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;stdlib.h&gt;</span></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> printTrain(Train* train)</div><div class="line">{</div><div class="line"> printf(<span class="stringliteral">&quot;%d : %s -&gt; %s Départ %d:%d arrivée %d:%d Prix : %f Reduc : %d&quot;</span>, train-&gt;id, train-&gt;villeDepart, train-&gt;villeArrivee, train-&gt;heureDepart-&gt;heure, train-&gt;heureDepart-&gt;minute, train-&gt;heureArrivee-&gt;heure, train-&gt;heureArrivee-&gt;minute, train-&gt;prix, train-&gt;reduc);</div><div class="line">}</div><div class="line"></div><div class="line">Train* <a name="a0"></a><a class="code" href="train_8c.html#aed8aaf00ced6d9a3121352a88c2f8c23">trainFromCSV</a>(<span class="keywordtype">char</span>* csv)</div><div class="line">{</div><div class="line"> <span class="keyword">struct </span>Train* train = malloc(<span class="keyword">sizeof</span>(Train));</div><div class="line"> <span class="keywordtype">char</span> *token, *str, *tofree;</div><div class="line"> tofree = str = strdup(csv); <span class="comment">// We own str&#39;s memory now.</span></div><div class="line"> <span class="comment">// id</span></div><div class="line"> token = strsep(&amp;str, <span class="stringliteral">&quot;;&quot;</span>);</div><div class="line"> train-&gt;id = atoi(token);</div><div class="line"></div><div class="line"> <span class="comment">// villeDepart</span></div><div class="line"> token = strsep(&amp;str, <span class="stringliteral">&quot;;&quot;</span>);</div><div class="line"> <a name="a1"></a><a class="code" href="outils_8c.html#a687ea0d581d240391192e821e70ab607">strToUpper</a>(token); <span class="comment">// On met le nom de ville en majuscule</span></div><div class="line"> train-&gt;villeDepart = strdup(token);</div><div class="line"></div><div class="line"> <span class="comment">// villeArrivee</span></div><div class="line"> token = strsep(&amp;str, <span class="stringliteral">&quot;;&quot;</span>);</div><div class="line"> <a class="code" href="outils_8c.html#a687ea0d581d240391192e821e70ab607">strToUpper</a>(token); <span class="comment">// On met le nom de ville en majuscule</span></div><div class="line"> train-&gt;villeArrivee = strdup(token);</div><div class="line"></div><div class="line"> <span class="comment">// heureDepart</span></div><div class="line"> token = strsep(&amp;str, <span class="stringliteral">&quot;;&quot;</span>);</div><div class="line"> <span class="keyword">struct </span>Temps* heureDepart = malloc(<span class="keyword">sizeof</span>(Temps));</div><div class="line"> heureDepart = <a name="a2"></a><a class="code" href="temps_8c.html#a81e0f2549d4dd4dcb072ae1086bb65dc">tempsFromCSV</a>(token);</div><div class="line"> train-&gt;heureDepart = heureDepart;</div><div class="line"></div><div class="line"> <span class="comment">// heureArrivee</span></div><div class="line"> token = strsep(&amp;str, <span class="stringliteral">&quot;;&quot;</span>);</div><div class="line"> <span class="keyword">struct </span>Temps* heureArrivee = malloc(<span class="keyword">sizeof</span>(Temps));</div><div class="line"> heureArrivee = <a class="code" href="temps_8c.html#a81e0f2549d4dd4dcb072ae1086bb65dc">tempsFromCSV</a>(token);</div><div class="line"> train-&gt;heureArrivee = heureArrivee;</div><div class="line"></div><div class="line"> <span class="comment">// prix</span></div><div class="line"> token = strsep(&amp;str, <span class="stringliteral">&quot;;&quot;</span>);</div><div class="line"> train-&gt;prix = atof(token);</div><div class="line"></div><div class="line"> <span class="comment">// reduc</span></div><div class="line"> token = strsep(&amp;str, <span class="stringliteral">&quot;;&quot;</span>);</div><div class="line"> <span class="keywordflow">if</span> (token != NULL)</div><div class="line"> {</div><div class="line"> <a class="code" href="outils_8c.html#a687ea0d581d240391192e821e70ab607">strToUpper</a>(token); <span class="comment">// On met la reduc ou supp en majuscule</span></div><div class="line"> <span class="keywordtype">int</span> len = strlen(token);</div><div class="line"> token[len-1] = <span class="charliteral">&#39;\0&#39;</span>;</div><div class="line"> <span class="keywordflow">if</span> (strcmp(token, <span class="stringliteral">&quot;REDUC&quot;</span>) == 0)</div><div class="line"> {</div><div class="line"> train-&gt;reduc = 1;</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(token, <span class="stringliteral">&quot;SUPPL&quot;</span>) == 0)</div><div class="line"> {</div><div class="line"> train-&gt;reduc = -1;</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> train-&gt;reduc = 0;</div><div class="line"> }</div><div class="line"> }</div><div class="line"> free(tofree); <span class="comment">// We free the str we made</span></div><div class="line"> <span class="keywordflow">return</span> train;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line">Train * <a name="a3"></a><a class="code" href="train_8c.html#ab3d507e8de3d02f93aa66801142d4840">trainFromFile</a>(<span class="keywordtype">char</span>* nomFichier, <span class="keywordtype">int</span>* nbTrain){</div><div class="line"> Train * listeToutTrain;</div><div class="line"> FILE *fichier = fopen ( nomFichier, <span class="stringliteral">&quot;r&quot;</span> );</div><div class="line"> <span class="keywordtype">int</span> compteLigne = 0;</div><div class="line"> <span class="keywordflow">if</span> (fichier != NULL)</div><div class="line"> {</div><div class="line"> <span class="keywordtype">char</span> ligne [ 256 ];</div><div class="line"> <span class="keywordtype">int</span> lineCount = 0;</div><div class="line"> <span class="keywordflow">while</span> (fgets(ligne, <span class="keyword">sizeof</span> ligne, fichier) != NULL) <span class="comment">/* lit une ligne */</span></div><div class="line"> {</div><div class="line"> compteLigne ++;</div><div class="line"> }</div><div class="line"> printf(<span class="stringliteral">&quot;%d ligne dans le fichier Trains.txt\n&quot;</span>, compteLigne);</div><div class="line"> rewind(fichier);</div><div class="line"> listeToutTrain = malloc(compteLigne * <span class="keyword">sizeof</span>(Train));</div><div class="line"> <span class="keywordflow">while</span> (fgets ( ligne, <span class="keyword">sizeof</span> ligne, fichier ) != NULL) <span class="comment">/* lit une ligne */</span></div><div class="line"> {</div><div class="line"> *(listeToutTrain + lineCount) = *<a class="code" href="train_8c.html#aed8aaf00ced6d9a3121352a88c2f8c23">trainFromCSV</a>(ligne);</div><div class="line"> lineCount ++;</div><div class="line"> }</div><div class="line"> fclose (fichier);</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> perror ( nomFichier ); <span class="comment">/* Pourquoi le fichier ne s&#39;est pas ouvert ? */</span></div><div class="line"> }</div><div class="line"> *nbTrain = compteLigne;</div><div class="line"> <span class="keywordflow">return</span> listeToutTrain;</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
Binary file added doc/html/bc_s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/html/bdwn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/html/closed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions doc/html/dir_17197e2a5901f70601536f515e8d47d9.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Allo Houston: serveur Directory Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Allo Houston
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_17197e2a5901f70601536f515e8d47d9.html">serveur</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">serveur Directory Reference</div> </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="subdirs"></a>
Directories</h2></td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
Loading

0 comments on commit 6311d00

Please sign in to comment.