/* ------------------------------------------------ Copyright 2014 AT&T Intellectual Property Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ------------------------------------------- */ #include "gsconfig.h" #include "gstypes.h" #include "gshub.h" #include "lapp.h" #include "fta.h" #include "lfta/rts.h" #include "stdio.h" #include "stdlib.h" #include #include #include #include #include #include #include gs_retval_t main_csv(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); gs_retval_t main_gdat(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); gs_retval_t main_dproto(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); gs_retval_t main_kafka(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); int main (int argc, char* argv[]) { gs_int32_t pid; gs_int32_t x; gs_int32_t y; gs_sp_t* device; gs_int32_t devcnt=0; gs_sp_t* mappings; gs_int32_t mapcnt=0; gs_sp_t* lmap; gs_int32_t lmapcnt=0; FILE * cfg_file; gs_int32_t tip1,tip2,tip3,tip4; endpoint gshub; gs_sp_t instance_name; gs_csp_t kafka; gsopenlog(argv[0]); if (setpgid(0,0)<0) { gslog(LOG_EMERG,"Could not set process group id of rts"); exit(1); } if (argc<4) { gslog(LOG_EMERG,"Wrong arguments at startup"); exit(1); } /* allocate more than enough for each array */ if ((device=(gs_sp_t*)malloc(sizeof(gs_sp_t*) * argc))==0) { gslog(LOG_EMERG,"malloc error"); exit(1); } if ((mappings=(gs_sp_t*)malloc(sizeof(gs_sp_t*) * argc))==0) { gslog(LOG_EMERG,"malloc error"); exit(1); } if ((lmap=(gs_sp_t*)malloc(sizeof(gs_sp_t*) * argc))==0) { gslog(LOG_EMERG,"malloc error"); exit(1); } /* parse the arguments */ if ((sscanf(argv[1],"%u.%u.%u.%u:%hu",&tip1,&tip2,&tip3,&tip4,&(gshub.port))!=5)) { gslog(LOG_EMERG,"HUB IP NOT DEFINED"); exit(1); } gshub.ip=htonl(tip1<<24|tip2<<16|tip3<<8|tip4); gshub.port=htons(gshub.port); instance_name=strdup(argv[2]); if (set_hub(gshub)!=0) { gslog(LOG_EMERG,"Could not set hub"); exit(1); } if (set_instance_name(instance_name)!=0) { gslog(LOG_EMERG,"Could not set instance name"); exit(1); } for(x=3;x