Esempio n. 1
0
static GenericAgentConfig *CheckOpts(int argc, char **argv)
{
    extern char *optarg;
    char *sp;
    int optindex = 0;
    int c, alpha = false, v6 = false;
    GenericAgentConfig *config = GenericAgentConfigNewDefault(AGENT_TYPE_AGENT);

/* Because of the MacOS linker we have to call this from each agent
   individually before Generic Initialize */

    POLICY_SERVER[0] = '\0';

    while ((c = getopt_long(argc, argv, "rdvnKIf:D:N:Vs:x:MBb:h", OPTIONS, &optindex)) != EOF)
    {
        switch ((char) c)
        {
        case 'f':
            if (optarg && strlen(optarg) < 5)
            {
                FatalError(" -f used but argument \"%s\" incorrect", optarg);
            }

            GenericAgentConfigSetInputFile(config, optarg);
            MINUSF = true;
            break;

        case 'b':
            if (optarg)
            {
                config->bundlesequence = SplitStringAsRList(optarg, ',');
                CBUNDLESEQUENCE_STR = optarg;
            }
            break;

        case 'd':
            HardClass("opt_debug");
            DEBUG = true;
            break;

        case 'B':
            BOOTSTRAP = true;
            MINUSF = true;
            GenericAgentConfigSetInputFile(config, "promises.cf");
            IGNORELOCK = true;
            HardClass("bootstrap_mode");
            break;

        case 's':
            
            if(IsLoopbackAddress(optarg))
            {
                FatalError("Use a non-loopback address when bootstrapping");
            }

            // temporary assure that network functions are working
            OpenNetwork();

            strncpy(POLICY_SERVER, Hostname2IPString(optarg), CF_BUFSIZE - 1);

            CloseNetwork();

            for (sp = POLICY_SERVER; *sp != '\0'; sp++)
            {
                if (isalpha((int)*sp))
                {
                    alpha = true;
                }

                if (ispunct((int)*sp) && *sp != ':' && *sp != '.')
                {
                    alpha = true;
                }

                if (*sp == ':')
                {
                    v6 = true;
                }
            }

            if (alpha && !v6)
            {
                FatalError
                    ("Error specifying policy server. The policy server's IP address could not be looked up. Please use the IP address instead if there is no error.");
            }

            break;

        case 'K':
            IGNORELOCK = true;
            break;

        case 'D':
            NewClassesFromString(optarg);
            break;

        case 'N':
            NegateClassesFromString(optarg);
            break;

        case 'I':
            INFORM = true;
            break;

        case 'v':
            VERBOSE = true;
            break;

        case 'n':
            DONTDO = true;
            IGNORELOCK = true;
            HardClass("opt_dry_run");
            break;

        case 'V':
            PrintVersionBanner("cf-agent");
            exit(0);

        case 'h':
            Syntax("cf-agent - cfengine's change agent", OPTIONS, HINTS, ID);
            exit(0);

        case 'M':
            ManPage("cf-agent - cfengine's change agent", OPTIONS, HINTS, ID);
            exit(0);

        case 'x':
            CfOut(cf_error, "", "Self-diagnostic functionality is retired");
            exit(0);

        case 'r':
            SHOWREPORTS = true;
            break;

        default:
            Syntax("cf-agent - cfengine's change agent", OPTIONS, HINTS, ID);
            exit(1);
        }
    }

    if (argv[optind] != NULL)
    {
        CfOut(cf_error, "", "Unexpected argument with no preceding option: %s\n", argv[optind]);
        FatalError("Aborted");
    }

    CfDebug("Set debugging\n");

    return config;
}
Esempio n. 2
0
void CheckOpts(int argc,char **argv)

{ extern char *optarg;
 char arg[CF_BUFSIZE],*sp;
  int optindex = 0;
  int c,alpha = false,v6 = false;

/* Because of the MacOS linker we have to call this from each agent
   individually before Generic Initialize */

POLICY_SERVER[0] = '\0';
  
while ((c=getopt_long(argc,argv,"rd:vnKIf:D:N:Vs:x:MBb:",OPTIONS,&optindex)) != EOF)
  {
  switch ((char) c)
      {
      case 'f':

          if (optarg == NULL)
             {
             FatalError(" -f used but no argument");
             }

          if (optarg && strlen(optarg) < 5)
             {
             snprintf(arg,CF_MAXVARSIZE," -f used but argument \"%s\" incorrect",optarg);
             FatalError(arg);
             }

          strncpy(VINPUTFILE,optarg,CF_BUFSIZE-1);
          MINUSF = true;
          break;

      case 'b':
          if (optarg)
             {
             CBUNDLESEQUENCE = SplitStringAsRList(optarg,',');
             CBUNDLESEQUENCE_STR = optarg;
             }
          break;
          
      case 'd': 
          NewClass("opt_debug");
          switch ((optarg==NULL) ? '3' : *optarg)
             {
             case '1':
                 D1 = true;
                 DEBUG = true;
                 break;
             case '2':
                 D2 = true;
                 DEBUG = true;
                 break;
             default:
                 DEBUG = true;
                 break;
             }
          break;

      case 'B':
          BOOTSTRAP = true;
          MINUSF = true;
          IGNORELOCK = true;
          NewClass("bootstrap_mode");
          break;

      case 's':
	  
	  // temporary assure that network functions are working
   	  OpenNetwork();

          strncpy(POLICY_SERVER,Hostname2IPString(optarg),CF_BUFSIZE-1);

          CloseNetwork();


          for (sp = POLICY_SERVER; *sp != '\0'; sp++)
             {
             if (isalpha(*sp))
                {
                alpha = true;
                }

             if (ispunct(*sp) && *sp != ':' && *sp != '.')
                {
                alpha = true;
                }
             
             if (*sp == ':')
                {
                v6 = true;
                }
             }

          if (alpha && !v6)
             {
             FatalError("Error specifying policy server. The policy server's IP address could not be looked up. Please use the IP address instead if there is no error.");
             }
          
          break;
          
      case 'K':
          IGNORELOCK = true;
          break;
                    
      case 'D': NewClassesFromString(optarg);
          break;
          
      case 'N': NegateClassesFromString(optarg,&VNEGHEAP);
          break;
          
      case 'I': INFORM = true;
          break;
          
      case 'v': VERBOSE = true;
          break;
          
      case 'n': DONTDO = true;
          IGNORELOCK = true;
          NewClass("opt_dry_run");
          break;
          
      case 'V':
          PrintVersionBanner("cf-agent");
          exit(0);
          
      case 'h':
          Syntax("cf-agent - cfengine's change agent",OPTIONS,HINTS,ID);
          exit(0);

      case 'M':
          ManPage("cf-agent - cfengine's change agent",OPTIONS,HINTS,ID);
          exit(0);

      case 'x':
	 AgentDiagnostic(optarg);
          exit(0);
          
      case 'r':
          SHOWREPORTS = true;
          break;

      default:  Syntax("cf-agent - cfengine's change agent",OPTIONS,HINTS,ID);
          exit(1);          
      }
  }

if (argv[optind] != NULL)
   {
   CfOut(cf_error,"","Unexpected argument with no preceding option: %s\n",argv[optind]);
   FatalError("Aborted");
   }

Debug("Set debugging\n");
}
Esempio n. 3
0
int main (int argc, char* argv[])
{
  int i,j ;
  char *RetVal ;
  char *Hue ;
  char *Sat ;
  char *Val ;
  char *White ;
  unsigned char Data[8] ; 
  int R,G,B,W ;
  int H,S,V ;
  ULONG CanID ;
  char Var[256] ;
  FILE *Dat ;
  clock_t start,end ;

  usleep(1) ;
  InitNetwork () ;

 
  Dat = fopen("LED","r") ;
  if (Dat!=NULL) {
    fscanf (Dat,"%d %d %d %d\n",&H,&S,&V,&W) ;
    fclose (Dat) ;
  } ;

  RetVal = getenv("QUERY_STRING") ;
  if (RetVal==NULL) {
    printf ("Content-type: text/html\n\n") ;
    printf ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n") ;
    printf ("<html><head><title>Umgebungsvariablen</title></head><body>\n");
    
    printf ("No Query String\n") ;
    printf ("</html>") ;  
    exit(0);
  } ;
  Hue = strstr(RetVal,"Hue.x=") ;
  if (Hue!=NULL) {
    sscanf (Hue,"Hue.x=%d",&H) ;
  } ;
  Sat = strstr(RetVal,"Sat.x=") ;
  if (Sat!=NULL) {
    sscanf (Sat,"Sat.x=%d",&S) ;
  } ;

  Val = strstr(RetVal,"Val.x=") ;
  if (Val!=NULL) {
    sscanf (Val,"Val.x=%d",&V) ;
  } ;

  Val = strstr(RetVal,"White.x=") ;
  if (Val!=NULL) {
    sscanf (Val,"White.x=%d",&W) ;
  } ;

  Val = strstr(RetVal,"An") ;
  if (Val!=NULL) {
    V = 255 ;
    S = 0 ;
    W = 255 ;
  } ;
  
  Val = strstr(RetVal,"Aus") ;
  if (Val!=NULL) {
    V = 0 ;
    W = 0 ;
  } ;

  Val = strstr(RetVal,"KH") ;
  if (Val!=NULL) {
    Rolladen (1,1,101,1) ;
  } ;

  Val = strstr(RetVal,"KR") ;
  if (Val!=NULL) {
    Rolladen (-1,1,101,1) ;
  } ;

  Val = strstr(RetVal,"KS") ;
  if (Val!=NULL) {
    Rolladen (0,1,101,1) ;
  } ;

  Val = strstr(RetVal,"WAH") ;
  if (Val!=NULL) {
    Jalousie (-1) ;
  } ;

  Val = strstr(RetVal,"WAR") ;
  if (Val!=NULL) {
    Jalousie (1) ;
  } ;

  Val = strstr(RetVal,"WAS") ;
  if (Val!=NULL) {
    Jalousie (0) ;
  } ;

  Val = strstr(RetVal,"WOH") ;
  if (Val!=NULL) {
    Rolladen (-1,3,104,4) ;
  } ;

  Val = strstr(RetVal,"WOR") ;
  if (Val!=NULL) {
    Rolladen (1,3,104,4) ;
  } ;

  Val = strstr(RetVal,"WOS") ;
  if (Val!=NULL) {
    Rolladen (0,3,104,4) ;
  } ;

  Val = strstr(RetVal,"WLH") ;
  if (Val!=NULL) {
    Rolladen (-1,3,104,1) ;
  } ;

  Val = strstr(RetVal,"WLR") ;
  if (Val!=NULL) {
    Rolladen (1,3,104,1) ;
  } ;

  Val = strstr(RetVal,"WLS") ;
  if (Val!=NULL) {
    Rolladen (0,3,104,1) ;
  } ;

  Val = strstr(RetVal,"WMH") ;
  if (Val!=NULL) {
    Rolladen (-1,3,104,3) ;
  } ;

  Val = strstr(RetVal,"WMR") ;
  if (Val!=NULL) {
    Rolladen (1,3,104,3) ;
  } ;

  Val = strstr(RetVal,"WMS") ;
  if (Val!=NULL) {
    Rolladen (0,3,104,3) ;
  } ;

  Val = strstr(RetVal,"WRH") ;
  if (Val!=NULL) {
    Rolladen (-1,3,104,5) ;
  } ;

  Val = strstr(RetVal,"WRR") ;
  if (Val!=NULL) {
    Rolladen (1,3,104,5) ;
  } ;

  Val = strstr(RetVal,"WRS") ;
  if (Val!=NULL) {
    Rolladen (0,3,104,5) ;
  } ;

  Val = strstr(RetVal,"WAO") ;
  if (Val!=NULL) {
    Jalousie(-1);
    usleep(500000);
    Jalousie(0);
  } ;


  Val = strstr(RetVal,"EH") ;
  if (Val!=NULL) {
    Rolladen (1,1,103,3) ;
  } ;

  Val = strstr(RetVal,"ER") ;
  if (Val!=NULL) {
    Rolladen (-1,1,103,3) ;
  } ;

  Val = strstr(RetVal,"ES") ;
  if (Val!=NULL) {
    Rolladen (0,1,103,3) ;
  } ;

  Val = strstr(RetVal,"WLAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,100,0) ;
    Data [0] = 30 ;
    Data [1] = 9;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"WLAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,100,0) ;
    Data [0] = 31 ;
    Data [1] = 9;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"BLAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,102,0) ;
    Data [0] = 30 ;
    Data [1] = 8;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"BLAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,102,0) ;
    Data [0] = 31 ;
    Data [1] = 8;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"FLAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,102,0) ;
    Data [0] = 30 ;
    Data [1] = 2;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"FLAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,102,0) ;
    Data [0] = 31 ;
    Data [1] = 2;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"SWZFRAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,103,0) ;
    Data [0] = 30 ;
    Data [1] = 1;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"SWZFRAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,103,0) ;
    Data [0] = 31 ;
    Data [1] = 1;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"SWZFLAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,100,0) ;
    Data [0] = 30 ;
    Data [1] = 5;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
    CanID = BuildCANId (0,0,0,1,1,100,0) ;
    Data [0] = 30 ;
    Data [1] = 10;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"SWZFLAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,100,0) ;
    Data [0] = 31 ;
    Data [1] = 5;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
    CanID = BuildCANId (0,0,0,1,1,100,0) ;
    Data [0] = 31 ;
    Data [1] = 10;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"SEZFLAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,103,0) ;
    Data [0] = 30 ;
    Data [1] = 7;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"SEZFLAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,103,0) ;
    Data [0] = 31 ;
    Data [1] = 7;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"SEZFTAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,103,0) ;
    Data [0] = 30 ;
    Data [1] = 4;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"SEZFTAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,103,0) ;
    Data [0] = 31 ;
    Data [1] = 4;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"KFSMAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,102,0) ;
    Data [0] = 30 ;
    Data [1] = 9;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"KFSMAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,102,0) ;
    Data [0] = 31 ;
    Data [1] = 9;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"KFSSAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,102,0) ;
    Data [0] = 30 ;
    Data [1] = 4;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"KFSSAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,102,0) ;
    Data [0] = 31 ;
    Data [1] = 4;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"GLAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,102,0) ;
    Data [0] = 30 ;
    Data [1] = 6;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"GLAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,102,0) ;
    Data [0] = 31 ;
    Data [1] = 6;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"KLAn") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,101,0) ;
    Data [0] = 30 ;
    Data [1] = 5;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
    CanID = BuildCANId (0,0,0,1,1,100,0) ;
    Data [0] = 30 ;
    Data [1] = 2;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"KLAus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,1,101,0) ;
    Data [0] = 31 ;
    Data [1] = 5;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
    CanID = BuildCANId (0,0,0,1,1,100,0) ;
    Data [0] = 31 ;
    Data [1] = 2;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"KBAL1An") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,3,102,0) ;
    Data [0] = 30 ;
    Data [1] = 3;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"KBAL1Aus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,3,102,0) ;
    Data [0] = 31 ;
    Data [1] = 3;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"BL1An") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,3,102,0) ;
    Data [0] = 30 ;
    Data [1] = 6;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"BL1Aus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,3,102,0) ;
    Data [0] = 31 ;
    Data [1] = 6;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"BL2An") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,3,102,0) ;
    Data [0] = 30 ;
    Data [1] = 1;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"BL2Aus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,3,102,0) ;
    Data [0] = 31 ;
    Data [1] = 1;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"NL1An") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,3,102,0) ;
    Data [0] = 30 ;
    Data [1] = 7;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"NL1Aus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,3,102,0) ;
    Data [0] = 31 ;
    Data [1] = 7;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"NL2An") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,3,102,0) ;
    Data [0] = 30 ;
    Data [1] = 2;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"NL2Aus") ;
  if (Val!=NULL) {
    CanID = BuildCANId (0,0,0,1,3,102,0) ;
    Data [0] = 31 ;
    Data [1] = 2;
    SendCANMessage (CanID, 2 ,Data) ;
    usleep(50000) ;
  } ;

  Val = strstr(RetVal,"BRH") ;
  if (Val!=NULL) {
    Beckiefenster (-1) ;
  } ;

  Val = strstr(RetVal,"BRR") ;
  if (Val!=NULL) {
    Beckiefenster (1) ;
  } ;

  Val = strstr(RetVal,"BRS") ;
  if (Val!=NULL) {
    Beckiefenster (0) ;
  } ;

  Val = strstr(RetVal,"NRH") ;
  if (Val!=NULL) {
    Niklasfenster (-1) ;
  } ;

  Val = strstr(RetVal,"NRR") ;
  if (Val!=NULL) {
    Niklasfenster (1) ;
  } ;

  Val = strstr(RetVal,"NRS") ;
  if (Val!=NULL) {
    Niklasfenster (0) ;
  } ;

  Val = strstr(RetVal,"DAH") ;
  if (Val!=NULL) {
    Elternfenster (-1,0) ;
  } ;

  Val = strstr(RetVal,"DAR") ;
  if (Val!=NULL) {
    Elternfenster (1,0) ;
  } ;

  Val = strstr(RetVal,"DAS") ;
  if (Val!=NULL) {
    Elternfenster (0,0) ;
  } ;

  Val = strstr(RetVal,"DGGH") ;
  if (Val!=NULL) {
    Elternfenster (-1,2) ;
  } ;

  Val = strstr(RetVal,"DGGR") ;
  if (Val!=NULL) {
    Elternfenster (1,2) ;
  } ;

  Val = strstr(RetVal,"DGGS") ;
  if (Val!=NULL) {
    Elternfenster (0,2) ;
  } ;

  Val = strstr(RetVal,"DGVH") ;
  if (Val!=NULL) {
    Elternfenster (-1,1) ;
  } ;

  Val = strstr(RetVal,"DGVR") ;
  if (Val!=NULL) {
    Elternfenster (1,1) ;
  } ;

  Val = strstr(RetVal,"DGVS") ;
  if (Val!=NULL) {
    Elternfenster (0,1) ;
  } ;

  Val = strstr(RetVal,"DG1H") ;
  if (Val!=NULL) {
    Rolladen (1,3,100,1) ;
  } ;

  Val = strstr(RetVal,"DG1R") ;
  if (Val!=NULL) {
    Rolladen (-1,3,100,1) ;
  } ;

  Val = strstr(RetVal,"DG1S") ;
  if (Val!=NULL) {
    Rolladen (0,3,100,1) ;
  } ;

  Val = strstr(RetVal,"DG2H") ;
  if (Val!=NULL) {
    Rolladen (1,3,100,3) ;
  } ;

  Val = strstr(RetVal,"DG2R") ;
  if (Val!=NULL) {
    Rolladen (-1,3,100,3) ;
  } ;

  Val = strstr(RetVal,"DG2S") ;
  if (Val!=NULL) {
    Rolladen (0,3,100,3) ;
  } ;

  Val = strstr(RetVal,"DG3H") ;
  if (Val!=NULL) {
    Rolladen (1,3,100,4) ;
  } ;

  Val = strstr(RetVal,"DG3R") ;
  if (Val!=NULL) {
    Rolladen (-1,3,100,4) ;
  } ;

  Val = strstr(RetVal,"DG3S") ;
  if (Val!=NULL) {
    Rolladen (0,3,100,4) ;
  } ;

  Val = strstr(RetVal,"DG4H") ;
  if (Val!=NULL) {
    Rolladen (1,3,100,5) ;
  } ;

  Val = strstr(RetVal,"DG4R") ;
  if (Val!=NULL) {
    Rolladen (-1,3,100,5) ;
  } ;

  Val = strstr(RetVal,"DG4S") ;
  if (Val!=NULL) {
    Rolladen (0,3,100,5) ;
  } ;

  Val = strstr(RetVal,"DG5H") ;
  if (Val!=NULL) {
    Rolladen (1,3,101,4) ;
  } ;

  Val = strstr(RetVal,"DG5R") ;
  if (Val!=NULL) {
    Rolladen (-1,3,101,4) ;
  } ;

  Val = strstr(RetVal,"DG5S") ;
  if (Val!=NULL) {
    Rolladen (0,3,101,4) ;
  } ;

  Val = strstr(RetVal,"DG6H") ;
  if (Val!=NULL) {
    Rolladen (1,3,101,5) ;
  } ;

  Val = strstr(RetVal,"DG6R") ;
  if (Val!=NULL) {
    Rolladen (-1,3,101,5) ;
  } ;

  Val = strstr(RetVal,"DG6S") ;
  if (Val!=NULL) {
    Rolladen (0,3,101,5) ;
  } ;

  Val = strstr(RetVal,"KBH") ;
  if (Val!=NULL) {
    Rolladen (1,3,105,5) ;
  } ;

  Val = strstr(RetVal,"KBR") ;
  if (Val!=NULL) {
    Rolladen (-1,3,105,5) ;
  } ;

  Val = strstr(RetVal,"KBS") ;
  if (Val!=NULL) {
    Rolladen (0,3,105,5) ;
  } ;

  Dat = fopen("LED","w") ;
  fprintf (Dat,"%d %d %d %d\n",H,S,V,W) ;
  fclose (Dat) ;
  

  /*  Data[0] = 10 ;
      Data[1] = (unsigned char)H ;
      Data[2] = (unsigned char)S ;
      Data[3] = (unsigned char)V ;
      Data[4] = (unsigned char)W ;
      
      Val = strstr(RetVal,"Disko") ;
      if (Val!=NULL) {
      for (i=0;i<20;i++) {
      Data[0] = 19 ;
      Data[1] = i ;
      CanID = BuildCANId (0,0,0,1,1,23,0) ;
      SendCANMessage (CanID, 2 ,Data) ; 
      usleep(100000) ;
      } ;
      } else if (strstr(RetVal,"DAus")) {
      Data[0] = 20 ;
      Data[1] = 22 ;
      CanID = BuildCANId (0,0,0,1,1,23,0) ;
      SendCANMessage (CanID, 2 ,Data) ; 
      } else if (strstr(RetVal,"LED=7")!=NULL) {
      CanID = BuildCANId (0,0,0,1,1,23,0) ;
      SendCANMessage (CanID, 5 ,Data) ;
      } else {
      for (i=0;i<7;i++) {
      sprintf (Var,"LED=%d",i) ;
      if (strstr(RetVal,Var)!=NULL) {
      CanID = BuildCANId (0,0,0,1,1,16+i,0) ;
      SendCANMessage (CanID, 5 ,Data) ;
      usleep(1000) ;
      } ;
      } ;
      } ;
  */

  printf ("Content-type: text/html\n\n") ;
  printf ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n") ;
  printf ("<html><head><title>Umgebungsvariablen</title></head><body>\n");

  //  printf ("%s\n",RetVal) ;
  printf ("<script type=\"text/javascript\">\n") ;
  printf ("history.back();\n") ;
  printf ("</script>") ;
  printf ("</html>") ;
  CloseNetwork () ;
}
Esempio n. 4
0
bool InitNetwork()
{
	QString strNetInitFile, strNetInitArgs, strValue;
	bool bContinue = true;
	int iErrorCode;

	// make sure network isn't running
	CloseNetwork();

	if (g_bNetworkEnabled)
		return false;

	g_pLogger->LogInfo("Opening Network Interface...");

	g_strDeviceName = g_pSettings->GetParam(PARAMKEY_NETWORK_DEVNAME, g_pSettings->m_sSettings[SETTINGS_NETWORK_DEVICENAME_NUM].GetValue().strValue, true);
	g_strDeviceType = g_pSettings->m_sSettings[SETTINGS_NETWORK_DEVICETYPE_NUM].GetValue().strValue;
	if (g_pSettings->GetParam(PARAMKEY_NETWORK_IP, "", false).isEmpty() || !StringToIPAddress(g_pSettings->GetParam(PARAMKEY_NETWORK_IP, "", false), g_ipAddress))
	{
		if (!StringToIPAddress(g_pSettings->m_sSettings[SETTINGS_NETWORK_IPADDRESS_NUM].GetValue().strValue, g_ipAddress))
			g_ipAddress = 0;
	}
	if (g_pSettings->GetParam(PARAMKEY_NETWORK_SUBNET, "", false).isEmpty() || !StringToIPAddress(g_pSettings->GetParam(PARAMKEY_NETWORK_SUBNET, "", false), g_ipSubnet))
		StringToIPAddress(g_pSettings->m_sSettings[SETTINGS_NETWORK_IPSUBNET_NUM].GetValue().strValue, g_ipSubnet);
	g_iTXPower = g_pSettings->m_sSettings[SETTINGS_NETWORK_TXPOWER_NUM].GetValue().iValue;
	g_iTXRate = g_pSettings->m_sSettings[SETTINGS_NETWORK_TXRATE_NUM].GetValue().iValue;

	strNetInitFile = g_pSettings->m_sSettings[SETTINGS_NETWORK_INITFILE_NUM].GetValue().strValue;
	if (!strNetInitFile.isEmpty())
	{
		strNetInitArgs = g_pSettings->m_sSettings[SETTINGS_NETWORK_INITARGS_NUM].GetValue().strValue;

		strNetInitArgs.replace("%dn", g_strDeviceName);
		strNetInitArgs.replace("%dt", g_strDeviceType);
		strNetInitArgs.replace("%ip", IPAddressToString(g_ipAddress));
		strNetInitArgs.replace("%sub", IPAddressToString(g_ipSubnet));
		strNetInitArgs.replace("%txp", QString::number(g_iTXPower));
		strNetInitArgs.replace("%txr", QString::number(g_iTXRate));

		if (!strNetInitArgs.isEmpty())
			strNetInitFile += " " + strNetInitArgs;

		while (bContinue)
		{
			iErrorCode = system(strNetInitFile);
			if (iErrorCode == 0) {
				g_bNetworkEnabled = true;
				bContinue = false;
			} else
				bContinue = g_pLogger->PromptLogError(PACKAGE_TITLE, QString("Could not open network interface (code %1)").arg(iErrorCode), false);
		}
	}
	else
		g_bNetworkEnabled = true;

	if (g_bNetworkEnabled)
	{
		/*if (g_strDeviceType.compare("denso") == 0)
			g_bNetworkEnabled = InitializeDensoUnit(g_ipAddress, g_ipSubnet, g_strDeviceName, g_iTXPower, g_iTXRate);
		*/
	}

	if (g_bNetworkEnabled)
		g_pLogger->LogInfo("Successful\n");
	else {
		g_pLogger->LogInfo("Failed\n");
		return false;
	}

	if (g_pMainWindow != NULL)
	{
		g_pMainWindow->m_pNetInit->setMenuText("Re&initialize");
		g_pMainWindow->m_pNetInit->setToolTip("Reinitialize network devices and connections");
		g_pMainWindow->m_pNetClose->setEnabled(true);
		g_pMainWindow->m_pNetMenu->setItemEnabled(g_pMainWindow->m_iNetServerMenuID, true);
		g_pMainWindow->m_pNetworkManager->SetNetworkInitialized(true);
	}

	g_pOldSigPipeHandler = signal(SIGPIPE, SIG_IGN);

	// start server
	if (g_pSettings->m_sSettings[SETTINGS_NETWORK_AUTOSERVER_NUM].GetValue().bValue)
	{
		if (g_strDeviceType.compare("denso") == 0)
			return StartServer(UDPSERVER_NAME);
		else
			return StartServer(UDPSERVER_NAME);
	}
	else
		return true;
}