register and login
register and login

--- a/src/extra_options.c
+++ b/src/extra_options.c
@@ -110,10 +110,7 @@
 	char nick_buffer[MAX_NICK_LEN];
 	char old_nick[MAX_NICK_LEN + 5];
 
-
-
-
-	sprintf(old_nick, "%s", client_get_nick(srv, asker));
+	sprintf(old_nick, "%s", client_get_nick(srv, asker)); /* Stupid ? */
 
 	if(!args) {
 		client_nick_to_display(srv, asker, nick_buffer,
@@ -142,12 +139,8 @@
 
 	if(args == NULL || strlen(args) < 2) {
 		send_msg_to_client(srv, TNCMSG_OPT_LOGIN_USAGE"\n", asker);
-		puts("Foo");
 		return;
 	}
-	puts("FUU");
-	printf(">>%s<<", args);
-
 	nick = args;
 	pwd = args;
 	while(*pwd != ' ' && *pwd != '\0')
@@ -186,30 +179,15 @@
 client_opt_register(struct srv_conf *srv, int asker, char *args)
 { /* {{{ */
 
-	char msg_buffer[MAX_NICK_LEN + 40];
-	char change_buffer[MAX_NICK_LEN + MAX_NICK_LEN + 50];
-	char nick_buffer[MAX_NICK_LEN];
-	char old_nick[MAX_NICK_LEN + 5];
-
-
-
-
-	sprintf(old_nick, "%s", client_get_nick(srv, asker));
-
 	if(!args) {
-		client_nick_to_display(srv, asker, nick_buffer,
-		                       client_use_color(srv, asker));
-		sprintf(msg_buffer, "Your nick is %s\n", nick_buffer);
-		send_msg_to_client(srv, msg_buffer, asker);
-
-	}
-	else {
-		client_set_nick(srv, asker, args);
-		sprintf(change_buffer, "%s changed his nick to %s",
-		        old_nick, client_get_nick(srv, asker));
-		send_brdcst(srv, change_buffer, NULL, -1);
-		/* TODO: add color */
-	}
+		send_msg_to_client(srv, TNCMSG_OPT_REGISTER_USAGE"\n", asker);
+		return;
+	}
+
+	if(client_register(srv, asker, args)) {
+		send_msg_to_client(srv, TNCMSG_OPT_REGISTER_SUCCESS"\n", asker);
+	}
+
 } /* }}} */
 
 void

--- a/src/messages.h
+++ b/src/messages.h
@@ -19,6 +19,9 @@
 #define TNCMSG_OPT_LOGIN_CHANGED_NICK "%s changed his nick to %s"
 #define TNCMSG_OPT_LOGIN_WRONG "Wrong password or nick not registered"
 #define TNCMSG_OPT_LOGIN_USAGE "Usage: /login USER PASSWORD"
+/* REGISTER */
+#define TNCMSG_OPT_REGISTER_USAGE "\"/register PASSWORD\" will register your actual nick"
+#define TNCMSG_OPT_REGISTER_SUCCESS "Your nick was registered ! Don't forget your password ;)"
 
 /**** USERS ****/
 #define TNCMSG_NICK_TAKEN_NEED_LOGIN "The nick is taken/registered. If you want to use it, type: /login nick password"

file:a/src/passwd -> file:b/src/passwd
--- a/src/passwd
+++ b/src/passwd
@@ -1,2 +1,3 @@
 foo	bar
+toto	blahblah
 

--- a/src/users.c
+++ b/src/users.c
@@ -123,7 +123,7 @@
 	}
 
 	if(user_taken(srv, my_nick)) {
-		send_msg_to_client(srv, TNCMSG_NICK_TAKEN_NEED_LOGIN, client);
+		send_msg_to_client(srv, TNCMSG_NICK_TAKEN_NEED_LOGIN"\n", client);
 		goto make_anon_nick; /* 13 lines below */
 	}
 

--- a/src/users_file.c
+++ b/src/users_file.c
@@ -55,8 +55,6 @@
 		return 0; /* Could not be authed */
 	}
 
-	printf("OK, I have: nick: >%s< and pwd: >%s<\n", user, pwd);
-
 	while(fgets(buffer, sizeof(buffer) - 2, users_file) != NULL) {
 		if(*buffer == '\0' || *buffer == '\n')
 			continue;
@@ -75,14 +73,10 @@
 			pwdbis++;
 		*pwdbis = '\0';
 
-		printf("I read: >%s< >%s<\n", buffer, password);
-
 		if(!strcmp(buffer, user)) {
 			/* User exists */
-			puts("User exists!");
 			pwd_hashed = hash_pwd(pwd);
 			if(!strcmp(password, pwd_hashed)) {
-				puts("and pw ok !");
 				/* Pwd OK ! */
 				free(pwd_hashed);
 				return 1;
@@ -106,7 +100,7 @@
 	if(srv->users_file == NULL)
 		return 0; /* Server does not support logins */
 
-	if(auth_user(srv, user, "!!##!!//(())") == -1) {
+	if(user_taken(srv, user)) {
 		/* very crappy way to see if user exists */
 		return 0;
 	}