Merge branch 'master' of vi-di.fr:telnetChat
Merge branch 'master' of vi-di.fr:telnetChat

--- a/src/.vstmDB
+++ b/src/.vstmDB
@@ -4,4 +4,8 @@
 Support config file
 handle registering
 @H variables MAX_NICK_LEN and NICK_SPACE_NEEDED
+@H implement registering
+@H implement authentification
+@H when nick change, check if nick not already registered
+@L implement locking for users file
 

--- a/src/config.c
+++ b/src/config.c
@@ -50,8 +50,7 @@
 { /* {{{ */
 
 	int i;
-	char *tries[] = {srv->config_file, "./tncconfig", "/etc/tncconfig",
-	                 NULL};
+	char *tries[] = {srv->config_file, "./tnc.con", "/etc/tnc.conf", NULL};
 
 	for(i = 0; tries[i] != NULL || i == 0; i++) {
 		if(read_config_file(srv, tries[i]))

--- a/src/server.h
+++ b/src/server.h
@@ -79,6 +79,7 @@
 
 	/* serv. general config */
 	char *config_file;
+	char *users_file;
 };
 
 #endif

file:b/src/tnc.conf (new)
--- /dev/null
+++ b/src/tnc.conf
@@ -1,1 +1,5 @@
+#This is a commentary
 
+users_file=./passwd
+allow_registering=YES
+

file:a/src/tncconfig (deleted)
--- a/src/tncconfig
+++ /dev/null
@@ -1,17 +1,1 @@
-Hi
-How are you ?
-LOLO
-           Spaces before.
-Spaces after.            
-           Sp bf and aft.     
-	   TabsB.
-		TabsBA. 	
-a=foo
-bar = baz
-	bow 	=   	arrow      
-		port = 1336
 
-
-
-
-

--- a/src/users.c
+++ b/src/users.c
@@ -40,6 +40,7 @@
 #include "utils.h"
 #include "users.h"
 
+/* high level functions: nick change, etc.. */
 void
 client_set_nick(struct srv_conf *srv, int client, char *args)
 { /* {{{ */
@@ -137,6 +138,50 @@
 	return unique_nick;
 } /* }}} */
 
+const char
+*get_color(int color)
+{ /* {{{ */
+	register int num_colors;
+
+	/* how much colors we have - FIXME TODO*/
+	/* that is soooo "ugly", even uglier than rolinh's NOTREACHED :p */
+	for(num_colors = 0; colors_for_clients[num_colors]; num_colors++);
+
+	return colors_for_clients[color % num_colors];
+} /* }}} */
+
+const char
+*client_get_color(struct srv_conf *srv, int user)
+{ /* {{{ */
+	/* TODO: color=f(user, colors_already_used). USER attribute. at client join */
+	return get_color(srv->client_list[user].id);
+} /* }}} */
+
+int
+client_use_color(struct srv_conf *srv, int user)
+{ /* {{{ */
+	return srv->client_list[user].allow_colors;
+} /* }}} */
+
+int
+get_client_from_nick(struct srv_conf *srv, char *nick)
+{ /* {{{ */
+	int i;
+
+	if(!nick)
+		return 0;
+
+	i = 0;
+	while(foreach_user(srv, &i)) {
+		if(!strcmp(nick, srv->client_list[i].nick)) {
+			return i;
+		}
+	}
+
+	return 0;
+} /* }}} */
+
+/* lower level functions like file descriptors, etc.. */
 int
 client_get_fd(struct srv_conf *srv, int client)
 { /* {{{ */
@@ -161,6 +206,9 @@
 	return 0;
 } /* }}} */
 
+
+/* High level functions */
+
 void
 client_quit_chat(struct srv_conf *srv, int sender, char *reason)
 { /* {{{ */
@@ -191,46 +239,16 @@
 	delete_client(srv, sender);
 } /* }}} */
 
-const char
-*get_color(int color)
-{ /* {{{ */
-	register int num_colors;
-
-	/* how much colors we have - FIXME TODO*/
-	/* that is soooo "ugly", even uglier than rolinh's NOTREACHED :p */
-	for(num_colors = 0; colors_for_clients[num_colors]; num_colors++);
-
-	return colors_for_clients[color % num_colors];
-} /* }}} */
-
-const char
-*client_get_color(struct srv_conf *srv, int user)
-{ /* {{{ */
-	/* TODO: color=f(user, colors_already_used). USER attribute. at client join */
-	return get_color(srv->client_list[user].id);
-} /* }}} */
-
-int
-client_use_color(struct srv_conf *srv, int user)
-{ /* {{{ */
-	return srv->client_list[user].allow_colors;
-} /* }}} */
-
-int
-get_client_from_nick(struct srv_conf *srv, char *nick)
-{ /* {{{ */
-	int i;
-
-	if(!nick)
-		return 0;
-
-	i = 0;
-	while(foreach_user(srv, &i)) {
-		if(!strcmp(nick, srv->client_list[i].nick)) {
-			return i;
-		}
-	}
-
-	return 0;
-} /* }}} */
-
+int
+client_auth_passwd(struct srv_conf *srv, int sender, char *password)
+{
+	return 0; /* client could not be authentified */
+}
+
+int
+client_register(struct srv_conf *srv, int client, char *password)
+{
+
+	return 0; /* could not be registered */
+}
+

file:b/src/users_file.c (new)
--- /dev/null
+++ b/src/users_file.c
@@ -1,1 +1,54 @@
+/* LICENSE - BSD {{{
+Copyright (c) 2013, Frank Villaro-Dixon
+All rights reserved.
 
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+	* Redistributions of source code must retain the above copyright notice,
+	this list of conditions and the following disclaimer.
+	* Redistributions in binary form must reproduce the above copyright
+	notice, this list of conditions and the following disclaimer in the
+	documentation and/or other materials provided with the distribution.
+	* Neither the name of the author  nor the names of its contributors may
+	be used to endorse or promote products derived from this software
+	without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLEFOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+}}} */
+
+/*
+** Handles the user registering file
+** Telnet Chat Server
+** Frank Villaro-Dixon - 2013
+*/
+#include <stdio.h>
+
+#include "server.h"
+#include "users_file.h"
+
+int
+auth_user(struct srv_conf *srv, char *user, char *pwd)
+{
+
+
+	return 0;
+}
+
+int
+register_user(struct srv_conf *srv, char *user, char pwd)
+{
+
+
+	return 0;
+}
+

file:b/src/users_file.h (new)
--- /dev/null
+++ b/src/users_file.h
@@ -1,1 +1,8 @@
+#ifndef USERS_FILE_H 
+#define USERS_FILE_H
 
+#include "server.h"
+
+
+#endif
+

--- a/src/utils.c
+++ b/src/utils.c
@@ -61,7 +61,7 @@
 	char *to_return;
 	char *end_str;
 
-	if(*str == '\0' || *str == '\n') {
+	if(*str == '\0' || *str == '\n' || *str == '#') {
 		*str = '\0';
 		return str;
 	}
@@ -77,6 +77,9 @@
 		if(*str > ' ')
 			end_str = str;
 	}
+
+	if(*to_return == '#')
+		*to_return = '#';
 
 	*(end_str+1) = '\0';