From 2e553811981364419915e50d2e2c8ff80185e37f Mon Sep 17 00:00:00 2001 From: ha7ilm Date: Wed, 4 Nov 2015 10:08:33 +0100 Subject: [PATCH] Started working on ddcd --- ddcd.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 ddcd.c diff --git a/ddcd.c b/ddcd.c new file mode 100644 index 0000000..f93d1ce --- /dev/null +++ b/ddcd.c @@ -0,0 +1,96 @@ +/* +This software is part of libcsdr, a set of simple DSP routines for +Software Defined Radio. + +Copyright (c) 2014, Andras Retzler +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 +#include +#include + + + +struct client_s +{ + int socket; + int addr; +} client_t; + + + +int main(int argc, char* argv[]) +{ + int c; + + //arguments: + int host_port; + char host_address[100] = "127.0.0.1"; + int decimation; + + 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 '?': + default: + printf(" 0%o ??\n", c); + } + + + + + } + + struct sockaddr_in addr_host; + int listen_socket; + std::vector 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"); + +}