csdr/ddcd.c

101 lines
3.1 KiB
C
Raw Normal View History

2015-11-04 17:08:33 +08:00
/*
This software is part of libcsdr, a set of simple DSP routines for
Software Defined Radio.
Copyright (c) 2014, Andras Retzler <randras@sdr.hu>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL ANDRAS RETZLER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <signal.h>
#include <stdio.h>
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
2015-11-04 17:08:33 +08:00
#define SOFTWARE_NAME "ddcd"
#define MSG_START SOFTWARE_NAME ": "
2015-11-04 17:08:33 +08:00
struct client_s
{
int socket;
int addr;
} client_t;
int host_port = 0;
char host_address[100] = "127.0.0.1";
int decimation = 0;
2015-11-04 17:08:33 +08:00
int main(int argc, char* argv[])
{
int c;
//arguments:
2015-11-04 17:08:33 +08:00
for(;;)
{
int option_index = 0;
static struct option long_options[] = {
{"port", required_argument, 0, 'p' },
{"address", required_argument, 0, 'a' },
{"decimation", required_argument, 0, 'd' }
};
c = getopt_long(argc, argv, "p:a:d:", long_options, &option_index);
if(c==-1) break;
switch (c)
{
case 'a':
host_address[100-1]=0;
strncpy(host_address,optarg,100-1);
break;
case 'p':
host_port=atoi(optarg);
break;
case 'd':
decimation=atoi(optarg);
break;
case 0:
case '?':
case ':':
2015-11-04 17:08:33 +08:00
default:
printf(" 0%o ??\n", c);
}
}
if(!decimation) { fprintf(stderr, MSG_START "missing required command line argument, --decimation.\n"); exit(1); }
if(!host_port) { fprintf(stderr, MSG_START "missing required command line argument, --port.\n"); exit(1); }
/*struct sockaddr_in addr_host;
2015-11-04 17:08:33 +08:00
int listen_socket;
std::vector<client_t> clients;
listen_socket=socket(AF_INET,SOCK_STREAM,0);
memset(&addr_host,'0',sizeof(addr_host));
addr_host.sin_family=AF_INET;
addr_host.sin_port=htons(8888);
addr_host.sin_addr.s_addr=inet_addr("127.0.0.1");
*/
2015-11-04 17:08:33 +08:00
}