/** go ahead and read config, contact server and perform command and display */ static int go(const char* cfgfile, char* svr, int argc, char* argv[]) { struct config_file* cfg; int fd, ret; SSL_CTX* ctx; SSL* ssl; /* read config */ if(!(cfg = config_create())) fatal_exit("out of memory"); if(!config_read(cfg, cfgfile, NULL)) fatal_exit("could not read config file"); if(!cfg->remote_control_enable) log_warn("control-enable is 'no' in the config file."); ctx = setup_ctx(cfg); /* contact server */ fd = contact_server(svr, cfg, argc>0&&strcmp(argv[0],"status")==0); ssl = setup_ssl(ctx, fd); /* send command */ ret = go_cmd(ssl, argc, argv); SSL_free(ssl); #ifndef USE_WINSOCK close(fd); #else closesocket(fd); #endif SSL_CTX_free(ctx); config_delete(cfg); return ret; }
/** go ahead and read config, contact server and perform command and display */ static int go(const char* cfgfile, char* svr, int argc, char* argv[]) { struct nsd_options* opt; int fd, ret; SSL_CTX* ctx; SSL* ssl; /* read config */ if(!(opt = nsd_options_create(region_create(xalloc, free)))) { fprintf(stderr, "out of memory\n"); exit(1); } tsig_init(opt->region); if(!parse_options_file(opt, cfgfile, NULL, NULL)) { fprintf(stderr, "could not read config file\n"); exit(1); } if(!opt->control_enable) fprintf(stderr, "warning: control-enable is 'no' in the config file.\n"); ctx = setup_ctx(opt); /* contact server */ fd = contact_server(svr, opt, argc>0&&strcmp(argv[0],"status")==0); ssl = setup_ssl(ctx, fd); /* send command */ ret = go_cmd(ssl, fd, argc, argv); if(ssl) SSL_free(ssl); close(fd); if(ctx) SSL_CTX_free(ctx); region_destroy(opt->region); return ret; }
void uart5_handle(void) { u16 cpsr = __disable_irq(); if((rx_uart_count > 0 && rx_timeout == 0)) { if(rx_uart_buf[0] == 'w') write_1page(); else if(rx_uart_buf[0] == 'g') go_cmd(); else if(rx_uart_buf[0] == 'r') USART1_SendByte(rx_uart_buf[0]); rx_timeout = 20; /// rx_uart_count = 0; /// } if(!cpsr) __enable_irq(); }