Ejemplo n.º 1
0
EspressoPWscfConfig::EspressoPWscfConfig (QObject *parent) :
    QObject(parent) {
    setupControl();
    setupSystem();
    setupElectrons();
    setupIons();
    setupCell();
    setupSpecies();
}
Ejemplo n.º 2
0
void loop(void) {
    setupControl();
    turnOff();

    startLoopFunction(30000, searchForTempSensors, false);

    startLoopFunction(1000, updateDuty, false);
    startLoopFunction(100, updatePinsForSetDuty, false);
    startLoopFunction(250, updateStepTimer, false);
    startLoopFunction(1000, readSensors, false);
    startLoopFunction(1000, selectReadingSensors, false);

    while (true) {
        sleep(100000);
    }

}
Ejemplo n.º 3
0
static UtilHashTable *buildClassRegisters()
{
   char *dir;
   char *dn;

   setupControl(configfile);

   if (getControlChars("registrationDir",&dir)) {
     dir = "/var/lib/sfcb/registration";
   }

   dn=(char*)alloca(strlen(dir)+32);
   strcpy(dn,dir);
   if (dir[strlen(dir)-1]!='/') strcat(dn,"/");
   strcat(dn,"repository");
   return gatherNameSpaces(dn,NULL,1);   
}
Ejemplo n.º 4
0
int
getControlNum(char *id, long *val)
{
  Control        *ctl;
  int             rc = -1;

  if (ct == NULL) {
    setupControl(configfile);
  }

  if ((ctl = ct->ft->get(ct, id))) {
    if (ctl->type == 1) {
      *val = strtol(ctl->strValue, NULL, 0);
      return 0;
    }
    rc = -2;
  }
  *val = 0;
  return rc;
}
Ejemplo n.º 5
0
int
getControlChars(char *id, char **val)
{
  Control        *ctl;
  int             rc = -1;

  if (ct == NULL) {
    setupControl(configfile);
  }

  if ((ctl = ct->ft->get(ct, id))) {
    if (ctl->type == 0 || ctl->type == 3) {
      *val = ctl->strValue;
      return 0;
    }
    rc = -2;
  }
  *val = NULL;
  return rc;
}
Ejemplo n.º 6
0
bool CPetConversations::setup(CPetControl *petControl) {
	if (petControl && setupControl(petControl))
		return reset();
	return false;
}
Ejemplo n.º 7
0
bool CPetConversations::isValid(CPetControl *petControl) {
	return setupControl(petControl);
}
Ejemplo n.º 8
0
ProviderRegister *newProviderRegister()
{
   FILE *in;
   char *dir,*provuser = NULL;
   char fin[1024], *stmt = NULL;
   ProviderInfo *info = NULL;
   int err = 0, n = 0, i;
   CntlVals rv;
   int id=0;
   int provSFCB,provuid=-1;
   int interopFound=0;
   struct passwd *passwd;

   ProviderRegister *br = (ProviderRegister *) malloc(sizeof(ProviderRegister) +
                                                      sizeof(ProviderBase));
   ProviderBase *bb = (ProviderBase *) (br + 1);
   
   setupControl(configfile);
   
   // Get/check provider user info
   if (getControlBool("providerDefaultUserSFCB",&provSFCB)) {
     provSFCB = 1;
   } 
   if (provSFCB) {
     // This indicates that we should use the SFCB user by default
     provuid = -1;
   } else {
      if (getControlChars("providerDefaultUser",&provuser)) {
        provuid = -1;
      } else {
        errno=0;
        passwd=getpwnam(provuser);
        if (passwd) {
            provuid=passwd->pw_uid;
        } else {
            mlogf(M_ERROR,M_SHOW,"--- Couldn't find username %s requested in SFCB config file. Errno: %d\n",provuser,errno);
            err=1;
        }
      }
    }


   if (getControlChars("registrationDir",&dir)) {
     dir = "/var/lib/sfcb/registration";
   }

   strcpy(fin, dir);
   strcat(fin, "/providerRegister");
   in = fopen(fin, "r");
   if (in == NULL) 
      mlogf(M_ERROR,M_SHOW, "--- %s not found\n", fin);
      
   else {

      br->hdl = bb;
      br->ft = ProviderRegisterFT;
      bb->fn = strdup(fin);
      bb->ht = UtilFactory->newHashTable(61,
                  UtilHashTable_charKey | UtilHashTable_ignoreKeyCase);

      while (fgets(fin, 1024, in)) {
         n++;
         if (stmt) free(stmt);
         stmt = strdup(fin);
         switch (cntlParseStmt(fin, &rv)) {
         case 0:
            mlogf(M_ERROR,M_SHOW,"--- registration statement not recognized: \n\t%d: %s\n", n,stmt);
            err = 1;
            break;
         case 1:
            if (info) {
               if (classProvInfoPtr==NULL) {
                  if (strcmp(info->className,"$ClassProvider$")==0) classProvInfoPtr=info;
               }   
               else if (defaultProvInfoPtr==NULL) {
                  if (strcmp(info->className,"$DefaultProvider$")==0) defaultProvInfoPtr=info;
               }   
               else if (interOpProvInfoPtr==NULL) {
                  if (strcmp(info->className,"$InterOpProvider$")==0) {
                     if (exFlags & 2) interOpProvInfoPtr=info;
                     else interopFound=1;
                  }   
               }               
               else if (qualiProvInfoPtr==NULL) {
                  if (strcmp(info->className,"$QualifierProvider$")==0) qualiProvInfoPtr=info;
               }
               err = addProviderToHT(info, ((ProviderBase *) br->hdl)->ht);
	       if (err)
		  break;
            }
            info = (ProviderInfo *) calloc(1, sizeof(ProviderInfo));
            info->className = strdup(rv.id);
            info->id= ++id;
            // Set the default provider uid
            info->uid=provuid;
            if (!provSFCB)
               info->user=strdup(provuser);
            break;
         case 2:
            if (strcmp(rv.id, "provider") == 0)
               info->providerName = strdup(cntlGetVal(&rv));
            else if (strcmp(rv.id, "location") == 0)
               info->location = strdup(cntlGetVal(&rv));
            else if (strcmp(rv.id, "parameters") == 0) {
               info->parms = strdup(cntlGetStr(&rv));
               for (i=strlen(info->parms); i>0 && info->parms[i]<=' '; i--) {
                   info->parms[i]=0;
               }
            }
            else if (strcmp(rv.id, "user") == 0) {
               info->user = strdup(cntlGetVal(&rv));
               errno=0;
               passwd=getpwnam(info->user);
               if (passwd) {
                  info->uid=passwd->pw_uid;
               } else {
                  mlogf(M_ERROR,M_SHOW,"--- Couldn't find username %s requested in providerRegister. Errno: %d\n",info->user,errno);
                  err = 1;
                  break;
               }
            }
            else if (strcmp(rv.id, "group") == 0)
               info->group = strdup(cntlGetVal(&rv));
            else if (strcmp(rv.id, "unload") == 0) {
               char *u;
               info->unload = 0;
               while ((u = cntlGetVal(&rv)) != NULL) {
                  if (strcmp(u, "never") == 0) {
                     info->unload =-1;
                  }   
                  else {
                     mlogf(M_ERROR,M_SHOW,"--- invalid unload specification: \n\t%d: %s\n", n, stmt);
                     err = 1;
                  }
               }   
            }   
            else if (strcmp(rv.id, "type") == 0) {
               char *t;
               info->type = 0;
               while ((t = cntlGetVal(&rv)) != NULL) {
                  if (strcmp(t, "instance") == 0)
                     info->type |= INSTANCE_PROVIDER;
                  else if (strcmp(t, "association") == 0)
                     info->type |= ASSOCIATION_PROVIDER;
                  else if (strcmp(t, "method") == 0)
                     info->type |= METHOD_PROVIDER;
                  else if (strcmp(t, "indication") == 0)
                     info->type |= INDICATION_PROVIDER;
                  else if (strcmp(t, "class") == 0)
                     info->type |= CLASS_PROVIDER;
                  else if (strcmp(t, "property") == 0)
                     info->type |= PROPERTY_PROVIDER; 
                  else if (strcmp(t, "qualifier") == 0)
                     info->type |= QUALIFIER_PROVIDER;                     
                  else {
                     mlogf(M_ERROR,M_SHOW,"--- invalid type specification: \n\t%d: %s\n", n, stmt);
                     err = 1;
                  }
               }
            }
            else if (strcmp(rv.id, "namespace") == 0) {
               int max=1,next=0;
               char *t;
               info->ns=(char**)malloc(sizeof(char*)*(max+1));
               while ((t = cntlGetVal(&rv)) != NULL) {
                  if (next==max) {
                     max++;
                     info->ns=(char**)realloc(info->ns,sizeof(char*)*(max+1));
                  }
                  info->ns[next]=strdup(t);
                  info->ns[++next]=NULL;
               }
            }
            else {
               mlogf(M_ERROR,M_SHOW,"--- invalid registration statement: \n\t%d: %s\n", n, stmt);
               err = 1;
            }
            break;
         case 3:
            break;
         }
	 if (err)
	    break;
      }

      if (info) {
	if (err == 0) {
	  err = addProviderToHT(info, ((ProviderBase *) br->hdl)->ht);
        }
	else {
	  freeInfoPtr(info);
	}
      }
   }
   if (in) {
     fclose(in);
   }
   
   if (classProvInfoPtr==NULL) {
      mlogf(M_ERROR,M_SHOW,"--- Class provider definition not found - sfcbd will terminate\n");
      err=1;
   }
   
   if (defaultProvInfoPtr==NULL) 
      mlogf(M_INFO,M_SHOW,"--- Default provider definition not found - no instance repository available\n");

   if (qualiProvInfoPtr==NULL) 
      mlogf(M_INFO,M_SHOW,"--- Qualifier provider definition not found - no qualifier support available\n");
   
   if (interOpProvInfoPtr==NULL) {
      if (exFlags & 2 && interopFound==0)
         mlogf(M_INFO,M_SHOW,"--- InterOp provider definition not found - no InterOp support available\n");
      else if (interopFound)    
         mlogf(M_INFO,M_SHOW,"--- InterOp provider definition found but not started - no InterOp support available\n");
      interOpProvInfoPtr=&forceNotFound;
   }   
   
   if (err) {
      mlogf(M_ERROR,M_SHOW,"--- Broker terminated because of previous error(s)\n");
      exit(5);
   }
   if (stmt) free(stmt);
   return br;
}
Ejemplo n.º 9
0
int main(int argc, char *argv[])
{
   int c, i;
   long tmask = 0, sslMode=0,sslOMode=0, tracelevel=0;
   char * tracefile = NULL;
#ifdef HAVE_UDS
   int enableUds=0;
#endif
   int enableHttp=0,enableHttps=0,useChunking=0,doBa=0,enableInterOp=0,httpLocalOnly=0;
   int syslogLevel=LOG_ERR;
   long dSockets,sSockets,pSockets;
   char *pauseStr;

   /* SF 3462309 - If there is an instance running already, return */
   int pid_found = 0;
   if ((pid_found = sfcb_is_running()) != 0) {
      mlogf(M_ERROR, M_SHOW, " --- A previous instance of sfcbd [%d] is running. Exiting.\n", pid_found);
      exit(1);
   }

   name = strrchr(argv[0], '/');
   if (name != NULL) ++name;
   else name = argv[0];

   collectStat=0;
   colorTrace=0;
   processName="sfcbd";
   provPauseStr=getenv("SFCB_PAUSE_PROVIDER");
   httpPauseStr=getenv("SFCB_PAUSE_CODEC");
   currentProc=sfcBrokerPid=getpid();
   restartArgc=argc;
   restartArgv=argv;


   exFlags = 0;

   static struct option const long_options[] =
       {
	   { "config-file",      required_argument, 0,        'c' },
	   { "daemon",           no_argument,       0,        'd' },
	   { "help",             no_argument,       0,        'h' },
	   { "color-trace",      no_argument,       0,        'k' },
	   { "collect-stats",    no_argument,       0,        's' },
	   { "syslog-level",     required_argument, 0,        'l' },
	   { "trace-components", required_argument, 0,        't' },
	   { "version",          no_argument,       0,        'v' },
           { "disable-repository-default-inst-provider", no_argument,       0,        'i' },
	   { 0, 0, 0, 0 }
       };

   while ((c = getopt_long(argc, argv, "c:dhkst:vil:", long_options, 0)) != -1)
   {
       switch(c)
       {
	   case 0:
	       break;

	   case 'c':
	       configfile = strdup(optarg);
	       break;

	   case 'd':
	       daemon(0, 0);
	       currentProc=sfcBrokerPid=getpid(); /* req. on some systems */
	       break;

	   case 'h':
	       usage(0);

	   case 'k':
	       colorTrace = 1;
	       break;

	   case 's':
	       collectStat = 1;
	       break;

	   case 't':
	       if (*optarg == '?') {
		   fprintf(stdout, "---   Traceable Components:     Int       Hex\n");
		   for (i = 0; traceIds[i].id; i++)
		       fprintf(stdout, "--- \t%18s:    %d\t0x%05X\n", traceIds[i].id, traceIds[i].code, traceIds[i].code);
		   exit(0);
	       } else if (isdigit(*optarg)) {
		   char *ep;
		   tmask = strtol(optarg, &ep, 0);
	       } else {
		   fprintf(stderr, "Try %s -t ? for a list of the trace components and bitmasks.\n", name);
		   exit(1);
	       }
	       break;

	   case 'v':
	       version();

           case 'i':
               disableDefaultProvider=1;
               break;

	   case 'l':
            if (strcmp(optarg,"LOG_ERR")==0) {
                syslogLevel=LOG_ERR;
            } else if (strcmp(optarg,"LOG_INFO")==0) {
                syslogLevel=LOG_INFO;
            } else if (strcmp(optarg,"LOG_DEBUG")==0) {
                syslogLevel=LOG_DEBUG;
            } else {
                fprintf(stderr,"Invalid value for syslog-level.\n");
	            usage(3);
            }
            break;
        
	   default:
	       usage(3);
       }
   }

   if (optind < argc)
   {
      fprintf(stderr,"SFCB not started: unrecognized config property %s\n",argv[optind]);
      usage(1);
   }

   startLogging(syslogLevel,1);

   mlogf(M_INFO,M_SHOW,"--- %s V" sfcHttpDaemonVersion " started - %d\n", name, currentProc);

   //get the creation timestamp for the sequence context
   struct timeval  tv;
   struct timezone tz;
   gettimeofday(&tv, &tz);
   struct tm cttm;
   sfcBrokerStart = (char *) malloc(15 * sizeof(char));
   memset((void *)sfcBrokerStart, 0, 15 * sizeof(char));
   if (gmtime_r(&tv.tv_sec, &cttm) != NULL) {
     strftime((char *)sfcBrokerStart, 15, "%Y%m%d%H%M%S", &cttm);
   }

   if (collectStat) {
       mlogf(M_INFO,M_SHOW,"--- Statistics collection enabled\n");
       remove("sfcbStat");
   }

   setupControl(configfile);      
   
   _SFCB_TRACE_INIT();

   if (tmask == 0) {
     /* trace mask not specified, check in config file */
     getControlNum("traceMask",&tmask);
   }
   
   if (tmask) {
     if (getControlNum("traceLevel",&tracelevel) || tracelevel == 0) {
       /* no tracelevel found in config file, use default */
       tracelevel = 1;
     }
     if (getenv("SFCB_TRACE_FILE") == NULL && 
	 getControlChars("traceFile",&tracefile) == 0) {
       /* only set tracefile from config file if not specified via env */
       _SFCB_TRACE_SETFILE(tracefile);
     }
     _SFCB_TRACE_START(tracelevel,tmask);
   }

//        SFCB_DEBUG
#ifndef SFCB_DEBUG
   if (tmask)
      mlogf(M_ERROR,M_SHOW,"--- SCFB_DEBUG not configured. -t %d ignored\n",tmask);
#endif

   if ((pauseStr=getenv("SFCB_PAUSE_PROVIDER"))) {
     printf("--- Provider pausing for: %s\n",pauseStr);
   }
      
   if (getControlBool("enableHttp", &enableHttp))
      enableHttp=1;

#ifdef HAVE_UDS
   if (getControlBool("enableUds", &enableUds))
      enableUds=1;
#endif
      
#if defined USE_SSL
   if (getControlBool("enableHttps", &enableHttps))
      enableHttps=0;

   sslMode=enableHttps;
#ifdef HAVE_UDS
   sslOMode=sslMode & !enableHttp & !enableUds;
#else
   sslOMode=sslMode & !enableHttp;
#endif
#else
   mlogf(M_INFO,M_SHOW,"--- SSL not configured\n");
   enableHttps=0;
   sslMode=0;
   sslOMode=0;
#endif
   
   if (getControlBool("useChunking", &useChunking))
      useChunking=0;
   if (useChunking==0)
         mlogf(M_INFO,M_SHOW,"--- Chunking disabled\n");

   if (getControlBool("doBasicAuth", &doBa))
      doBa=0;
   if (!doBa)
      mlogf(M_INFO,M_SHOW,"--- User authentication disabled\n");

   if (getControlBool("enableInterOp", &enableInterOp))
       enableInterOp=0;

   if (getControlNum("httpProcs", (long*)&dSockets))
      dSockets = 10;
   if (getControlNum("httpsProcs", (long*)&sSockets))
      sSockets = 10;
   if (getControlNum("provProcs", (long*)&pSockets))
      pSockets = 16;

   if (getControlBool("httpLocalOnly", &httpLocalOnly))
      httpLocalOnly=0;   
   if (httpLocalOnly)
      mlogf(M_INFO,M_SHOW,"--- External HTTP connections disabled; using loopback only\n");

   if (getControlNum("providerSampleInterval", (long*)&provSampleInterval))
      provSampleInterval = 30;
   if (getControlNum("providerTimeoutInterval", (long*)&provTimeoutInterval))
      provTimeoutInterval = 60;
   if (getControlBool("providerAutoGroup", (int*)&provAutoGroup))
      provAutoGroup=1;

   resultSockets=getSocketPair("sfcbd result");
   sfcbSockets=getSocketPair("sfcbd sfcb");

   if (enableInterOp==0)
       mlogf(M_INFO,M_SHOW,"--- InterOp namespace disabled\n");
   else
       exFlags = exFlags | 2;

   if ((enableInterOp && pSockets < 4 ) || pSockets < 3) {
     /* adjusting provider number */
     if (enableInterOp) {
       pSockets = 4;
     } else {
       pSockets = 3;
     }
     mlogf(M_INFO,M_SHOW,
	   "--- Max provider process number adjusted to %d\n", pSockets);
   }

   // Check for whitespace trimming option
   if (getControlBool("trimWhitespace", &trimws)) {
     trimws = 0;
   }

   if ((enableHttp || enableHttps) && dSockets > 0) {
     startHttp = 1;
   }
   
   initSem(dSockets,sSockets,pSockets);
   initProvProcCtl(pSockets);
   init_sfcBroker();
   initSocketPairs(pSockets,dSockets,sSockets);

   setSignal(SIGQUIT, handleSigquit,0);
   setSignal(SIGINT,  handleSigquit,0);
   
   setSignal(SIGTERM, handleSigquit,0);
   setSignal(SIGHUP,  handleSigHup,0);

   atexit(uninitGarbageCollector);

   startLocalConnectServer();
   
#ifndef LOCAL_CONNECT_ONLY_ENABLE
   if (startHttp) {
     startHttpd(argc, argv, sslMode);
   }
#endif // LOCAL_CONNECT_ONLY_ENABLE
   
#ifdef HAVE_JDBC
   //Start dbProtocol-Daemon
   if (startDbp) {
      if (sslMode)
         startDbpd(argc, argv,1);
      if (!sslOMode)
         startDbpd(argc, argv,0);
   }
#endif	


   setSignal(SIGSEGV, handleSigSegv,SA_ONESHOT);
   setSignal(SIGCHLD, handleSigChld,0);
   
   processProviderMgrRequests();

   return 0;
}
Ejemplo n.º 10
0
bool CPetRealLife::isValid(CPetControl *petControl) {
	setupControl(petControl);
	return true;
}
Ejemplo n.º 11
0
bool CPetRealLife::setup(CPetControl *petControl) {
	if (petControl && setupControl(petControl))
		return reset();
	return false;
}
Ejemplo n.º 12
0
bool CPetRooms::isValid(CPetControl *petControl) {
	return setupControl(petControl);
}
Ejemplo n.º 13
0
bool CPetRemote::isValid(CPetControl *petControl) {
	return setupControl(petControl);
}
Ejemplo n.º 14
0
/*
 * Von httpDaemon aus httpAdapter abgeschrieben.
 *
 */
int dbpDaemon(int argc, char *argv[], int sslMode, int sfcbPid) {//int argc, char *argv[], int sslMode) {
	struct sockaddr_in sin;
   int sin_len,ru;
   socklen_t sz;
   char *cp;
   long procs, port;
   int listenFd, connFd;

   name = argv[0];
   debug = 1;
   doFork = 1;

   _SFCB_ENTER(TRACE_DBPDAEMON, "dbpDaemon");

   setupControl(configfile);
   sfcbSSLMode=sslMode;
   if (sslMode) processName="DBPS-Daemon";
   else processName="DBP-Daemon";

   if (sslMode) {
      if (getControlNum("dbpsPort", &port))
         port = 5981;
      hBase=stBase;
      hMax=stMax;
   }
   else {
      if (getControlNum("dbpPort", &port))
         port = 5980;
      hBase=htBase;
      hMax=htMax;
   }

   if (getControlNum("dbpProcs", &procs))
      procs = 10;
   initDbpProcCtl(procs);

//   if (getControlBool("doBasicAuth", &doBa))
//      doBa=0;
//
//   i = 1;
//   while (i < argc && argv[i][0] == '-') {
//      if (strcmp(argv[i], "-D") == 0)
//         debug = 1;
//      else if (strcmp(argv[i], "-nD") == 0)
//         debug = 0;
//      else if (strcmp(argv[i], "-p") == 0 && i + 1 < argc) {
//         ++i;
//         port = (unsigned short) atoi(argv[i]);
//      }
//      else if (strcmp(argv[i], "-tm") == 0) {
//         if (isdigit(*argv[i + 1])) {
//            ++i;
//         }
//      }
//      else if (strcmp(argv[i], "-F") == 0)
//         doFork = 1;
//      else if (strcmp(argv[i], "-nF") == 0)
//         doFork = 0;
//      else if (strcmp(argv[i], "-H") == 0);
//      ++i;
//   }
//
//   if (getControlBool("useChunking", &noChunking))
//      noChunking=0;
//   noChunking=noChunking==0;

   cp = strrchr(name, '/');
   if (cp != NULL)
      ++cp;
   else  cp = name;
   name = cp;

   if (sslMode) mlogf(M_INFO,M_SHOW,"--- %s DBPS Daemon V" sfcdbpDaemonVersion " started - %d - port %ld\n", 
         name, currentProc,port);
   else mlogf(M_INFO,M_SHOW,"--- %s DBP  Daemon V" sfcdbpDaemonVersion " started - %d - port %ld\n", 
         name, currentProc,port);


   if (doBa) mlogf(M_INFO,M_SHOW,"--- Using Basic Authentication\n");

   listenFd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
   sin_len = sizeof(sin);

   ru = 1;
   setsockopt(listenFd, SOL_SOCKET, SO_REUSEADDR, (char *) &ru, sizeof(ru));

   memset(&sin,0,sin_len);

   sin.sin_family = AF_INET;
   sin.sin_addr.s_addr = INADDR_ANY;
   sin.sin_port = htons(port);

   if (bind(listenFd, (struct sockaddr *) &sin, sin_len) ||
       listen(listenFd, 0)) {
      mlogf(M_ERROR,M_SHOW,"--- Cannot listen on port %ld\n", port);
      kill(sfcbPid,3);
   }

  if (!debug) {
      int rc = fork();
      if (rc == -1) {
         char *emsg=strerror(errno);
         mlogf(M_ERROR,M_SHOW,"--- fork daemon: %s",emsg);
         exit(1);
      }
      else if (rc)
         exit(0);
   }
//   memInit();
    currentProc=getpid();
    setSignal(SIGCHLD, handleSigChld,0);
    setSignal(SIGUSR1, handleSigUsr1,0);
    setSignal(SIGINT, SIG_IGN,0);
    setSignal(SIGTERM, SIG_IGN,0);
    setSignal(SIGHUP, SIG_IGN,0);

 //   commInit();

#if defined USE_SSL
    if (sfcbSSLMode) {
       char *fnc,*fnk;
       ctx = SSL_CTX_new(SSLv23_method());
       getControlChars("sslCertificateFilePath", &fnc);
       if (SSL_CTX_use_certificate_chain_file(ctx, fnc) != 1)
           intSSLerror("Error loading certificate from file");
       getControlChars("sslKeyFilePath", &fnk);
       if (SSL_CTX_use_PrivateKey_file(ctx, fnk, SSL_FILETYPE_PEM) != 1)
           intSSLerror("Error loading private key from file");
    }
#endif

   for (;;) {
   char *emsg;
      listen(listenFd, 1);
      sz = sizeof(sin);
      if ((connFd = accept(listenFd, (__SOCKADDR_ARG) & sin, &sz))<0) {
         if (errno == EINTR || errno == EAGAIN) {
            if (stopAccepting) break;
            continue;
         }   
         emsg=strerror(errno);
         mlogf(M_ERROR,M_SHOW,"--- accept error %s\n",emsg);
         _SFCB_ABORT();
      }
      _SFCB_TRACE(1, ("--- Processing dbp request"));

      handleDbpSession(connFd); 
      close(connFd);
   }
   
   printf("--- %s draining %d\n",processName,running);
   for (;;) {
      if (running==0) {
         mlogf(M_INFO,M_SHOW,"--- %s terminating %d\n",processName,getpid());
         exit(0);
      }   
      sleep(1);
   }   
	



/*   struct sockaddr_in sin;
   int sz,i,sin_len,ru;
   char *cp;//??
   long procs, port;
   int listenFd, connFd;


   name = "sfcBroker";
   //debug = 1;
   //doFork = 1;

   _SFCB_ENTER(TRACE_DBPDAEMON, "dbpDaemon");

   //setupControl(NULL);
   processName="DBP Daemon"; //Variable aus sfcBroker, dieser neue Prozess hat noch keinen zugewiesen bekommen

	//if (getControlNum("httpPort", &port))
        port = 5980;
    //hBase=htBase;
    //hMax=htMax;
   
//initndpProcCtl(procs);
   

   cp = strrchr(name, '/');
   if (cp != NULL)
      ++cp;
   else  cp = name;
   name = cp;

   
   printf("--- %s  DBP  Daemon V" sfcdbpDaemonVersion " started - %d - port %ld\n", name, getpid(),port);



   listenFd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
   sin_len = sizeof(sin);

   ru = 1;
   setsockopt(listenFd, SOL_SOCKET, SO_REUSEADDR, (char *) &ru, sizeof(ru));

   memset(&sin,0,sin_len);

   sin.sin_family = AF_INET;
   sin.sin_addr.s_addr = INADDR_ANY;
   sin.sin_port = htons(port);

   if (bind(listenFd, (struct sockaddr *) &sin, sin_len) ||
       listen(listenFd, 0)) {//Test, ob Port frei ist
      printf("cannot listen on port %ld", port);
      exit(3);
   }

  //if (!debug) {
      int rc = fork();
      if (rc == -1) {
         perror("fork daemon");
         exit(1);
      }
      else if (rc)
         exit(0);
   //}
//   memInit();
//printf("jetzt kann sich jemand verbinden\n");
 //   setSignal(SIGCHLD, handleSigChld,0);
	
    for (;;) {
     	
        listen(listenFd, 1);
        sz = sizeof(sin);
        if ((connFd = accept(listenFd, (__SOCKADDR_ARG) & sin, &sz))<0) {
            if (errno == EINTR || errno == EAGAIN)
            	continue;
        	perror("accept error");
        //  _SFCB_ABORT();
        }
         _SFCB_TRACE(1, ("--- Processing  dbp request"));

	   	printd("es hat sich glaub ich jemand verbunden\n");
	   
	    handleDbpSession(connFd); 
       	close(connFd);
    }
*/
}
Ejemplo n.º 15
0
bool CPetStarfield::setup(CPetControl *petControl) {
	if (petControl && setupControl(petControl))
		return reset();
	return false;
}
Ejemplo n.º 16
0
bool CPetStarfield::isValid(CPetControl *petControl) {
	return setupControl(petControl);
}