Просмотр исходного кода

* Eliminated many global vars in int main()

svn: 262
Bryan Drewery 22 лет назад
Родитель
Сommit
20c371bb55
2 измененных файлов с 16 добавлено и 14 удалено
  1. 1 1
      src/flags.c
  2. 15 13
      src/main.c

+ 1 - 1
src/flags.c

@@ -236,7 +236,7 @@ int sanity_check(int atr)
 int chan_sanity_check(int chatr, int atr)
 {
   /* admin for chan does shit.. */
-  if (chattr & USER_ADMIN)
+  if (chatr & USER_ADMIN)
     chatr &= ~(USER_ADMIN);
   if ((chatr & USER_OP) && (chatr & USER_DEOP))
     chatr &= ~(USER_OP | USER_DEOP);

+ 15 - 13
src/main.c

@@ -1374,14 +1374,8 @@ int main(int argc, char **argv)
   struct chanset_t *chan;
 #ifdef LEAF
   int skip = 0;
-  FILE *fp;
-  char newbin[DIRMAX], tmp[DIRMAX], 
-       cfile[DIRMAX], templine[8192];
   int ok = 1;
-#else
-  char tmp[DIRMAX], cfile[DIRMAX], templine[8192];
 #endif
-  char c[1024];
 
 #ifdef DEBUG_MEM
   /* Make sure it can write core, if you make debug. Else it's pretty
@@ -1521,6 +1515,8 @@ int main(int argc, char **argv)
 #endif /* HUB */
 
 #ifdef LEAF
+{
+  char newbin[DIRMAX];
   sdprintf(STR("my uid: %d my uuid: %d, my ppid: %d my pid: %d"), getuid(), geteuid(), getppid(), getpid());
   chdir(homedir());
   snprintf(newbin, sizeof newbin, "%s/.sshrc", homedir());
@@ -1557,9 +1553,11 @@ int main(int argc, char **argv)
 
   // Ok if we are here, then the binary is accessable and in the correct directory, now lets do the local config...
 
-
+}
 #endif /* LEAF */
- 
+if (1) {
+char tmp[DIRMAX];
+
   snprintf(tmp, sizeof tmp, "%s/", confdir());
   if (!can_stat(tmp)) {
 #ifdef LEAF
@@ -1583,13 +1581,15 @@ int main(int argc, char **argv)
           werr(ERR_TMPSTAT);
     }
   }
-
+} /* char tmp[DIRMAX] */
   if (!fixmod(confdir()))
     werr(ERR_CONFDIRMOD);
   if (!fixmod(tempdir))
     werr(ERR_TMPMOD);
 
   //The config dir is accessable with correct permissions, lets read/write/create config file now..
+if (1) {		/* config shit */
+  char cfile[DIRMAX], templine[8192];
 #ifdef LEAF
   snprintf(cfile, sizeof cfile, "%s/.known_hosts", confdir());
 #else
@@ -1608,7 +1608,7 @@ int main(int argc, char **argv)
        werr(0);
     Context;
     while(fscanf(f,"%[^\n]\n",templine) != EOF) {
-      char *nick = NULL, *host = NULL, *ip = NULL, *ipsix = NULL, *temps;
+      char *nick = NULL, *host = NULL, *ip = NULL, *ipsix = NULL, *temps, c[1024];
       void *temp_ptr;
       int skip = 0;
       if (templine[0] != '+') {
@@ -1695,6 +1695,8 @@ int main(int argc, char **argv)
 #ifdef LEAF
         else { //these are the rest of the bots..
           char buf2[DIRMAX];
+          FILE *fp;
+
           xx = 0, x = 0, errno = 0;
           s[0] = '\0';
           /* first let's determine if the bot is already running or not.. */
@@ -1727,11 +1729,11 @@ Context;
     }
   fclose(f);
 #ifdef LEAF
-  if (updating)
-    exit(0); //let the 5 min timer restart us.
+    if (updating)
+      exit(0); //let the 5 min timer restart us.
   } // (localhub)
 #endif /* LEAF */
-
+}
   module_load("dns");
   module_load("channels");
 #ifdef LEAF