Index: Changes
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/Changes,v
retrieving revision 1.1.1.1.2.1.2.1.2.2456
diff -u -r1.1.1.1.2.1.2.1.2.2456 Changes
--- Changes	18 Jul 2007 11:25:14 -0000	1.1.1.1.2.1.2.1.2.2456
+++ Changes	20 Jul 2007 18:52:12 -0000
@@ -1851,3 +1851,5 @@
 Remember to use different listening ports (or interfaces) on every
 unrealircd-*.conf files.
 - Changed version into 3.2.8 as this will be the target for devel branch
+- Added level-on-join to set default level when first user creates a channel, suggested by Shining Phoenix (#3308).
+- Fixed some compiling bugs.
Index: wircd.def
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/Attic/wircd.def,v
retrieving revision 1.1.6.8
diff -u -r1.1.6.8 wircd.def
--- wircd.def	11 Jun 2007 18:36:05 -0000	1.1.6.8
+++ wircd.def	20 Jul 2007 18:52:12 -0000
@@ -868,4 +868,5 @@
 	stripbadwords
 	spamfilter_build_user_string
 	free_motd
-	
+	level_join
+	level_sjoin
Index: doc/unreal32docs.html
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/doc/Attic/unreal32docs.html,v
retrieving revision 1.1.2.157
diff -u -r1.1.2.157 unreal32docs.html
--- doc/unreal32docs.html	4 Jun 2007 17:21:20 -0000	1.1.2.157
+++ doc/unreal32docs.html	20 Jul 2007 18:52:19 -0000
@@ -2477,6 +2477,11 @@
  <p><font class="set">set::modef-max-unsettime &lt;value&gt;</font><br>
   The maximum amount of minutes for a mode +f unsettime (in +f [5j#i&lt;TIME&gt;]:15), this is a 
   value between 0 and 255. The default is 60 (= 1 hour).</p>
+ <p><font class="set">set::nick-length &lt;value&gt;</font><br>
+  Maximum length for nicknames.</p>
+ <p><font class="set">set::level-on-join &lt;value&gt;</font><br>
+  Level given to first user when creates a channel, 'o' by default. You can specify one or more levels from 'qaohv'. 
+  You can also leave this value empty to do not give any level.</p>
  <p><font class="set">set::ban-version-tkl-time &lt;value&gt;</font><br>
   If you specify an 'action' like zline/gline/etc in ban version, then you can specify here 
   how long the ip should be banned, the default is 86400 (1 day).</p>
Index: include/dynconf.h
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/include/dynconf.h,v
retrieving revision 1.1.1.1.6.1.2.64
diff -u -r1.1.1.1.6.1.2.64 dynconf.h
--- include/dynconf.h	4 Jun 2007 17:21:20 -0000	1.1.1.1.6.1.2.64
+++ include/dynconf.h	20 Jul 2007 18:52:19 -0000
@@ -150,6 +150,7 @@
 	int pingpong_warning;
 	aNetwork network;
 	int nicklen;
+	long level_on_join;
 };
 
 #ifndef DYNCONF_C
@@ -258,6 +259,8 @@
 
 #define PINGPONG_WARNING	iConf.pingpong_warning
 
+#define LEVEL_ON_JOIN iConf.level_on_join
+
 /* Used for "is present?" and duplicate checking */
 struct SetCheck {
 	unsigned has_show_opermotd:1;
@@ -364,6 +367,7 @@
 	unsigned has_cgiirc_hosts:1;
 	unsigned has_cgiirc_webpass:1;
 	unsigned has_nicklen:1;
+	unsigned has_level_on_join:1;
 };
 
 
Index: include/h.h
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/include/h.h,v
retrieving revision 1.1.1.1.6.1.2.199
diff -u -r1.1.1.1.6.1.2.199 h.h
--- include/h.h	11 Jun 2007 21:51:20 -0000	1.1.1.1.6.1.2.199
+++ include/h.h	20 Jul 2007 18:52:20 -0000
@@ -783,3 +783,5 @@
 extern void cm_freeparameter_ex(void **p, char mode, char *str);
 extern void kick_insecure_users(aChannel *);
 extern void free_motd(aMotd *m);
+extern MODVAR char level_sjoin[6];
+extern MODVAR char level_join[6];
Index: src/channel.c
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/src/channel.c,v
retrieving revision 1.1.1.1.6.1.2.328
diff -u -r1.1.1.1.6.1.2.328 channel.c
--- src/channel.c	13 May 2007 23:09:24 -0000	1.1.1.1.6.1.2.328
+++ src/channel.c	20 Jul 2007 18:52:22 -0000
@@ -51,6 +51,11 @@
     ("(C) 1990 University of Oulu, Computing Center and Jarkko Oikarinen");
 
 long opermode = 0;
+#ifdef PREFIX_AQ
+char level_sjoin[6], level_join[6];
+#else
+char level_sjoin[4], level_join[4];
+#endif
 aChannel *channel = NullChn;
 extern char backupbuf[];
 extern ircstats IRCstats;
Index: src/ircd.c
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/src/ircd.c,v
retrieving revision 1.1.1.1.6.1.2.219
diff -u -r1.1.1.1.6.1.2.219 ircd.c
--- src/ircd.c	20 Jun 2007 00:35:07 -0000	1.1.1.1.6.1.2.219
+++ src/ircd.c	20 Jul 2007 18:52:23 -0000
@@ -1305,7 +1305,7 @@
 			  }
 			  
 			  if (flag == 'p')
-				  MessageBox(NULL, result, "Encrypted password", MB_ICONINFORMATION | MB_OK);*/
+				  MessageBox(NULL, result, "Encrypted password", MB_ICONINFORMATION | MB_OK);
 			  else
 			  if (OpenClipboard(NULL))
 			  {
@@ -1324,7 +1324,7 @@
 			      }
 			      CloseClipboard();
 			  }
-			  exit 0;
+			  exit(0);
 		  }
 #endif
 
Index: src/modules.c
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/src/Attic/modules.c,v
retrieving revision 1.1.2.97
diff -u -r1.1.2.97 modules.c
--- src/modules.c	12 Jun 2007 21:30:08 -0000	1.1.2.97
+++ src/modules.c	20 Jul 2007 18:52:25 -0000
@@ -325,7 +325,7 @@
 #ifndef _WIN32
 	if(!strchr(path, '/'))
 #else
-	if (!strchr(path, '\\') && !strchr(path, '/')
+	if (!strchr(path, '\\') && !strchr(path, '/'))
 #endif
 	{
 		path = MyMalloc(strlen(path) + 3);
Index: src/s_conf.c
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/src/s_conf.c,v
retrieving revision 1.1.1.1.6.1.2.392
diff -u -r1.1.1.1.6.1.2.392 s_conf.c
--- src/s_conf.c	27 Jun 2007 11:30:08 -0000	1.1.1.1.6.1.2.392
+++ src/s_conf.c	20 Jul 2007 18:52:33 -0000
@@ -1338,6 +1338,9 @@
 	i->timesynch_timeout = 3;
 	i->timesynch_server = strdup("193.67.79.202,192.43.244.18,128.250.36.3"); /* nlnet (EU), NIST (US), uni melbourne (AU). All open acces, nonotify, nodns. */
 	i->nicklen = NICKLEN;
+	i->level_on_join = CHFL_CHANOP;
+	strcpy(level_join, "@");
+	strcpy(level_sjoin, "@");
 	i->name_server = strdup("127.0.0.1"); /* default, especially needed for w2003+ in some rare cases */
 }
 
@@ -6875,6 +6878,49 @@
 			if (loop.ircd_booted)
 				IsupportSetValue(IsupportFind("NICKLEN"), cep->ce_vardata);
 		}
+		else if (!strcmp(cep->ce_varname,"level-on-join")) {
+			if (BadPtr(cep->ce_vardata))
+			{
+				tempiConf.level_on_join = CHFL_DEOPPED;
+				level_sjoin[0] = level_join[0] = '\0';
+			}
+			else
+			{
+				char *c;
+				int i = 0;
+				tempiConf.level_on_join = 0L;
+				for (c = cep->ce_vardata; !BadPtr(c); c++)
+				{
+					switch(*c)
+					{
+#ifdef PREFIX_AQ
+						case 'q':
+							tempiConf.level_on_join |= CHFL_CHANOWNER;
+							level_sjoin[i++] = '*';
+							break;
+						case 'a':
+							tempiConf.level_on_join |= CHFL_CHANPROT;
+							level_sjoin[i++] = '~';
+							break;
+#endif
+						case 'o':
+							tempiConf.level_on_join |= CHFL_CHANOP;
+							level_sjoin[i++] = '@';
+							break;
+						case 'h':
+							tempiConf.level_on_join |= CHFL_HALFOP;
+							level_sjoin[i++] = '%';
+							break;
+						case 'v':
+							tempiConf.level_on_join |= CHFL_VOICE;
+							level_sjoin[i++] = '+';
+							break;
+					}
+				}
+				level_sjoin[i] = '\0';
+				strlcpy(level_join, cep->ce_vardata, sizeof(level_join));
+			}
+		}
 		else if (!strcmp(cep->ce_varname, "ssl")) {
 #ifdef USE_SSL
 			for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next) {
@@ -7796,6 +7842,28 @@
 				errors++;
 			}
 		}
+		else if (!strcmp(cep->ce_varname, "level-on-join")) {
+			int v;
+			CheckDuplicate(cep, nicklen, "level-on-join");
+			if (!BadPtr(cep->ce_vardata))
+			{
+				char *c;
+#ifdef PREFIX_AQ
+				char *flg = "qaohv";
+#else
+				char *flg = "ohv";
+#endif
+				for (c = cep->ce_vardata; !BadPtr(c); c++)
+				{
+					if (!strchr(flg, *c))
+					{
+						config_error("%s:%i: set::level-on-join: unknown '%c' level (only allowed %s)",
+							cep->ce_fileptr->cf_filename, cep->ce_varlinenum, *c, flg);
+						errors++;
+					}
+				}
+			}
+		}
 		else if (!strcmp(cep->ce_varname, "ssl")) {
 #ifdef USE_SSL
 			for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next) {
Index: src/modules/m_join.c
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/src/modules/Attic/m_join.c,v
retrieving revision 1.1.6.8
diff -u -r1.1.6.8 m_join.c
--- src/modules/m_join.c	25 Apr 2007 17:37:05 -0000	1.1.6.8
+++ src/modules/m_join.c	20 Jul 2007 18:52:34 -0000
@@ -283,10 +283,10 @@
 		    TOK_JOIN, "%s", chptr->chname);
 
 #ifdef JOIN_INSTEAD_OF_SJOIN_ON_REMOTEJOIN
-	if ((MyClient(sptr) && !(flags & CHFL_CHANOP)) || !MyClient(sptr))
+	if ((MyClient(sptr) && (flags == CHFL_DEOPPED)) || !MyClient(sptr))
 		sendto_serv_butone_token_opt(cptr, OPT_SJ3, sptr->name, MSG_JOIN,
 		    TOK_JOIN, "%s", chptr->chname);
-	if (flags & CHFL_CHANOP)
+	if (flags != CHFL_DEOPPED)
 	{
 #endif
 		/* I _know_ that the "@%s " look a bit wierd
@@ -295,11 +295,11 @@
 		sendto_serv_butone_token_opt(cptr, OPT_SJ3|OPT_SJB64,
 			me.name, MSG_SJOIN, TOK_SJOIN,
 			"%B %s :%s%s ", (long)chptr->creationtime, 
-			chptr->chname, flags & CHFL_CHANOP ? "@" : "", sptr->name);
+			chptr->chname, level_sjoin, sptr->name);
 		sendto_serv_butone_token_opt(cptr, OPT_SJ3|OPT_NOT_SJB64,
 			me.name, MSG_SJOIN, TOK_SJOIN,
 			"%li %s :%s%s ", chptr->creationtime, 
-			chptr->chname, flags & CHFL_CHANOP ? "@" : "", sptr->name);
+			chptr->chname, level_sjoin, sptr->name);
 #ifdef JOIN_INSTEAD_OF_SJOIN_ON_REMOTEJOIN
 	}
 #endif		
@@ -319,12 +319,25 @@
 			    chptr->chname, chptr->creationtime);
 		}
 		del_invite(sptr, chptr);
-		if (flags & CHFL_CHANOP)
+		if (flags != CHFL_DEOPPED)
+		{
+			int reps = strlen(level_join), i;
+			size_t namesiz = sizeof(char) * ((strlen(sptr->name) + 1) * reps);
+			char *namerep = (char *)MyMalloc(namesiz);
+			namerep[0] = '\0';
+			for (i = 0; i < reps; i++)
+			{
+				strlcat(namerep, sptr->name, namesiz);
+				strlcat(namerep, " ", namesiz);
+			}
+			namerep[namesiz-1] = '\0';
 			sendto_serv_butone_token_opt(cptr, OPT_NOT_SJ3, 
 			    me.name,
-			    MSG_MODE, TOK_MODE, "%s +o %s %lu",
-			    chptr->chname, sptr->name,
+			    MSG_MODE, TOK_MODE, "%s +%s %s %lu",
+			    chptr->chname, level_join, namerep,
 			    chptr->creationtime);
+			MyFree(namerep);
+		}
 		if (chptr->topic)
 		{
 			sendto_one(sptr, rpl_str(RPL_TOPIC),
@@ -498,7 +511,7 @@
 			 */
 
 			flags =
-			    (ChannelExists(name)) ? CHFL_DEOPPED : CHFL_CHANOP;
+			    (ChannelExists(name)) ? CHFL_DEOPPED : LEVEL_ON_JOIN;
 
 			if (!IsAnOper(sptr))	/* opers can join unlimited chans */
 				if (sptr->user->joined >= MAXCHANNELSPERUSER)
Index: src/modules/m_names.c
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/src/modules/Attic/m_names.c,v
retrieving revision 1.1.6.3
diff -u -r1.1.6.3 m_names.c
--- src/modules/m_names.c	20 May 2007 21:19:05 -0000	1.1.6.3
+++ src/modules/m_names.c	20 Jul 2007 18:52:34 -0000
@@ -99,7 +99,7 @@
 	Member *cm;
 	int  idx, flag = 1, spos;
 	char *s, *para = parv[1];
-
+	char *nuhBuffer;
 
 	if (parc < 2 || !MyConnect(sptr))
 	{
@@ -204,19 +204,20 @@
 			if (cm->flags & CHFL_VOICE)
 				buf[idx++] = '+';
 		}
-		char nuhBuffer[bufLen + 1];
+		nuhBuffer = (char *)MyMalloc(sizeof(char) * (bufLen + 1));
 		if(!uhnames) {
-			strlcpy(nuhBuffer, acptr->name, sizeof(nuhBuffer));
+			strlcpy(nuhBuffer, acptr->name, sizeof(char) * (bufLen + 1));
 		} else {
 			strlcpy(nuhBuffer, make_nick_user_host(acptr->name, 
 				acptr->user->username, GetHost(acptr)),
-				sizeof(nuhBuffer));
+				sizeof(char) * (bufLen + 1));
 		}
 		for (s = nuhBuffer; *s; s++)
 			buf[idx++] = *s;
 		buf[idx++] = ' ';
 		buf[idx] = '\0';
 		flag = 1;
+		MyFree(nuhBuffer);
 		if (mlen + idx + bufLen > BUFSIZE - 7)
 		{
 			sendto_one(sptr, rpl_str(RPL_NAMREPLY), me.name,
