swixteen  0.03
Switch a lamp on/off with X10 RF commands
 All Files Functions Variables Macros Pages
GetOldElroCommandsBy.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <string.h>
3 #include <unistd.h>
4 #include <stdlib.h>
5 
6 #include "./config.h"
7 #include "../Commands/Commands.h"
8 
15 int GetOldElroCommandsBy( char *NameToFind )
16  {
17  int n=0;
18  int NrOfCommands=0;
19 
20  NrOfCommands=InitOldElroCommands();
21 
22  for( n=0; n < NrOfCommands; n++ )
23  {
24 
25  if( strcmp(NameToFind, Name[n] ) == 0 )
26  {
27  fprintf(stdout, "Sending code %s consisting of %i and %i\n", Name[n], Address[n], Action[n] );
28  break;
29  }
30 
31  }
32 
33  if(n >= NrOfCommands)
34  {
35 
36  for( n=0; n < NrOfCommands; n++ )
37  {
38  fprintf( stderr, "%s\n", Name[n] );
39  }
40 
41  fprintf( stderr, "\n" );
42  fprintf( stderr, "Name %s not found, please choose one of the above\n", NameToFind );
43  exit(-1);
44  }
45 
46  return(n);
47  }
48