*** app_meetme.c.orig	Sat Feb 26 18:45:52 2005
--- app_meetme.c	Sun Feb 27 00:31:50 2005
***************
*** 129,134 ****
--- 129,135 ----
  	char *recordingformat;		/* Format to record the Conference in */
  	char pin[AST_MAX_EXTENSION];			/* If protected by a PIN */
  	char pinadmin[AST_MAX_EXTENSION];	/* If protected by a admin PIN */
+ 	char maxusers[AST_MAX_EXTENSION];	/* max */
  	struct ast_conference *next;
  } *confs;
  
***************
*** 245,251 ****
  		ast_autoservice_stop(chan);
  }
  
! static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin, int make, int dynamic)
  {
  	struct ast_conference *cnf;
  	struct zt_confinfo ztc;
--- 246,252 ----
  		ast_autoservice_stop(chan);
  }
  
! static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin, char *maxusers, int make, int dynamic)
  {
  	struct ast_conference *cnf;
  	struct zt_confinfo ztc;
***************
*** 264,269 ****
--- 265,271 ----
  			strncpy(cnf->confno, confno, sizeof(cnf->confno) - 1);
  			strncpy(cnf->pin, pin, sizeof(cnf->pin) - 1);
  			strncpy(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin) - 1);
+ 			strncpy(cnf->maxusers, maxusers, sizeof(cnf->maxusers) - 1);  /* maxusers */
  			cnf->markedusers = 0;
  			cnf->chan = ast_request("zap", AST_FORMAT_ULAW, "pseudo", NULL);
  			if (cnf->chan) {
***************
*** 1238,1246 ****
  					/* Query the user to enter a PIN */
  					ast_app_getdata(chan, "conf-getpin", dynamic_pin, AST_MAX_EXTENSION - 1, 0);
  				}
! 				cnf = build_conf(confno, dynamic_pin, "", make, dynamic);
  			} else {
! 				cnf = build_conf(confno, "", "", make, dynamic);
  			}
  		} else {
  			/* Check the config */
--- 1240,1248 ----
  					/* Query the user to enter a PIN */
  					ast_app_getdata(chan, "conf-getpin", dynamic_pin, AST_MAX_EXTENSION - 1, 0);
  				}
! 				cnf = build_conf(confno, dynamic_pin, "", "",make, dynamic); /* maxusers */
  			} else {
! 				cnf = build_conf(confno, "", "", "",make, dynamic); /* maxusers */
  			}
  		} else {
  			/* Check the config */
***************
*** 1253,1275 ****
  			while(var) {
  				if (!strcasecmp(var->name, "conf")) {
  					/* Separate the PIN */
! 					char *pin, *pinadmin, *conf;
  
! 					if ((pinadmin = ast_strdupa(var->value))) {
! 						conf = strsep(&pinadmin, "|,");
! 						pin = strsep(&pinadmin, "|,");
  						if (!strcasecmp(conf, confno)) {
  							/* Bingo it's a valid conference */
  							if (pin)
! 								if (pinadmin)
! 									cnf = build_conf(confno, pin, pinadmin, make, dynamic);
  								else
! 									cnf = build_conf(confno, pin, "", make, dynamic);
  							else
! 								if (pinadmin)
! 									cnf = build_conf(confno, "", pinadmin, make, dynamic);
  								else
! 									cnf = build_conf(confno, "", "", make, dynamic);
  							break;
  						}
  					}
--- 1255,1278 ----
  			while(var) {
  				if (!strcasecmp(var->name, "conf")) {
  					/* Separate the PIN */
! 					char *pin, *pinadmin, *maxusers, *conf;
  
! 					if ((maxusers = ast_strdupa(var->value))) {
! 						conf = strsep(&maxusers, "|,");
! 						pin = strsep(&maxusers, "|,");
! 						pinadmin = strsep(&maxusers, "|,");
  						if (!strcasecmp(conf, confno)) {
  							/* Bingo it's a valid conference */
  							if (pin)
! 								if (maxusers)
! 									cnf = build_conf(confno, pin, pinadmin, maxusers, make, dynamic);
  								else
! 									cnf = build_conf(confno, pin, "", maxusers, make, dynamic);
  							else
! 								if (maxusers)
! 									cnf = build_conf(confno, "", pinadmin, maxusers, make, dynamic);
  								else
! 									cnf = build_conf(confno, "", "", "", make, dynamic);
  							break;
  						}
  					}
***************
*** 1341,1346 ****
--- 1344,1350 ----
  	int empty = 0, empty_no_pin = 0;
  	int always_prompt = 0;
  	char *notdata, *info, *inflags = NULL, *inpin = NULL, the_pin[AST_MAX_EXTENSION] = "";
+ 	int maxusers = 0;
  
  	if (!data || ast_strlen_zero(data)) {
  		allowretry = 1;
***************
*** 1541,1546 ****
--- 1545,1557 ----
  				if (allowretry)
  					confno[0] = '\0';
  			} else {
+ 			/* max users */
+ 			maxusers = atoi(cnf->maxusers);	
+ 			if (cnf->users>maxusers) {
+                                 res = ast_streamfile(chan, "conf-maxusers", chan->language);
+                                 allowretry = 0;
+ 				continue;
+ 			}
  				if ((!ast_strlen_zero(cnf->pin) && ! (confflags & CONFFLAG_ADMIN)) || (!ast_strlen_zero(cnf->pinadmin) && (confflags & CONFFLAG_ADMIN))) {
  					char pin[AST_MAX_EXTENSION]="";
  					int j;
