H3270 * lib3270_session_new(const char *model) { static int configured = 0; H3270 *hSession = &h3270; Trace("%s - configured=%d",__FUNCTION__,configured); if(configured) { // TODO (perry#5#): Allocate a new structure. errno = EBUSY; return hSession; } configured = 1; lib3270_session_init(hSession, model); if(screen_init(hSession)) return NULL; Trace("Charset: %s",appres.charset); if (charset_init(appres.charset) != CS_OKAY) { Warning( _( "Cannot find charset \"%s\", using defaults" ), appres.charset); (void) charset_init(CN); } kybd_init(); // hostfile_init(); // hostfile_init(); ansi_init(); #if defined(X3270_FT) ft_init(); #endif #if defined(X3270_PRINTER) printer_init(); #endif Trace("%s finished",__FUNCTION__); errno = 0; return hSession; }
int main(void) { ansi_init(); uart_init();// Initialize UART Peripheral IntializeTimer(); // Clear the Screen of the hyper terminal <send clear code> spi_init();// Initialize SPI w5100_init();// Initial the W5100 Ethernet if(S0_initialize_socket(MR_TCP,30000)) { printf("INIT DONE 2\n"); //S0_connect(dest_ip,dest_port); } printf("%x\n",get_socket0_status()); uart_putch('\0',&uart_str); uart_flush(); host= http_extract_host(url); relativeAddress = http_extract_relativeAddress(url,strlen(host)); request= http_create_request(method,relativeAddress,httpV,host); ;//="GET / HTTP/1.1\r\nHost: www.google.com\r\nConnection: keep-alive\r\nUser-Agent: Mozilla/5.0 (windows NT 6.1; wow64) Applewebkit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 safari/537.11\r\nAccept: text/html\r\nAccept-Encoding: gzip, deflate\r\n"; //printf("%s",request); S0_connect(dest_ip,dest_port); if(get_socket0_status() == SOCK_ESTABLISHED) { printf("Connected\n"); uart_putch('\0',&uart_str); } // Loop forever int loop = 1, counter = 0; //sei(); while(loop) { // keep reading the socket zero status // and handle at least socket closed and socket established uint8_t sockstat=get_socket0_status(); switch(sockstat/*Handle all possible socket status here*/) { case SOCK_CLOSED: //printf("ERROR1\n"); //uart_putch('\0',&uart_str); //S0_connect(dest_ip,dest_port); printf("%x\n",get_socket0_status()); uart_putch('\0',&uart_str); loop = 0; break; case SOCK_ESTABLISHED: printf("SOCK_ESTABLISHED\n"); uart_putch('\0',&uart_str); // Get the client request size // And read the client Request in temp buffer // make sure the temp buffer is sending GET request S0_send((uint8_t*)request,strlen(request)); printf("Request Sent\n"); uart_putch('\0',&uart_str); uart_flush(); _delay_ms(2000); if(S0_RX_getReceivedSize() != 0) { counter++; S0_recv(buf,S0_RX_getReceivedSize()); printf("RECV Response\n"); uart_putch('\0',&uart_str); printf("%s",(char*)buf); uart_putch('\0',&uart_str); //loop =0; } // create a buffer that will hold the response and send it // if the GET request has an option to turn on/off a LED Carry that now. // finally disconnect the socket with the client. break; case SOCK_FIN_WAIT: case SOCK_CLOSING: case SOCK_TIME_WAIT: case SOCK_CLOSE_WAIT: case SOCK_LAST_ACK: loop = 0; printf("Recevied %d\n",counter); uart_putch('\0',&uart_str); close(0); // force the socket to be closed break; //default: //printf("nothing\n"); } } return 0; }
int ucon64_execute_options (void) /* Execute all options for a single file. Please, if you experience problems then try your luck with the flags in ucon64_misc.c/ucon64_wf[] before changing things here or in ucon64_rom_handling() */ { int c = 0, result = 0, x = 0, opts = 0; static int first_call = 1; // first call to this function ucon64.dat = NULL; #ifdef USE_DISCMAGE ucon64.image = NULL; #endif ucon64.rominfo = NULL; ucon64.battery = ucon64.bs_dump = ucon64.buheader_len = ucon64.console = ucon64.controller = ucon64.controller2 = ucon64.do_not_calc_crc = ucon64.id = ucon64.interleaved = ucon64.mirror = ucon64.part_size = ucon64.region = ucon64.snes_header_base = ucon64.snes_hirom = ucon64.split = ucon64.tv_standard = ucon64.use_dump_info = ucon64.vram = UCON64_UNKNOWN; ucon64.file_size = ucon64.crc32 = ucon64.fcrc32 = ucon64.io_mode = 0; // switches for (x = 0; arg[x].val; x++) { if (arg[x].console != UCON64_UNKNOWN) ucon64.console = arg[x].console; if (arg[x].flags) ucon64.flags = arg[x].flags; if (arg[x].val) ucon64.option = arg[x].val; ucon64.optarg = arg[x].optarg; // if (ucon64.flags & WF_SWITCH) ucon64_switches (&ucon64); } #ifdef USE_ANSI_COLOR if (ucon64.ansi_color && first_call) ucon64.ansi_color = ansi_init (); #endif #ifdef USE_PARALLEL /* The copier options need root privileges for parport_open() We can't use ucon64.flags & WF_PAR to detect whether a (parallel port) copier option has been specified, because another switch might've been specified after -port. */ if (ucon64.parport_needed == 1) ucon64.parport = parport_open (ucon64.parport); #endif // USE_PARALLEL #if defined __unix__ && !defined __MSDOS__ /* We can drop privileges after we have set up parallel port access. We cannot drop privileges if the user wants to communicate with the USB version of the F2A. SECURITY WARNING: We stay in root mode if the user specified an F2A option! We could of course drop privileges which requires the user to run uCON64 as root (not setuid root), but we want to be user friendly. Besides, doing things as root is bad anyway (from a security viewpoint). */ if (first_call && ucon64.parport_needed != 2 #ifdef USE_USB && !ucon64.usbport #endif ) drop_privileges (); #endif // __unix__ && !__MSDOS__ first_call = 0; for (x = 0; arg[x].val; x++) if (!(arg[x].flags & WF_SWITCH)) { if (ucon64.console == UCON64_UNKNOWN) ucon64.console = arg[x].console; ucon64.flags = arg[x].flags; ucon64.option = arg[x].val; ucon64.optarg = arg[x].optarg; opts++; // WF_NO_SPLIT, WF_INIT, WF_PROBE, CRC32, DATabase and WF_NFO result = ucon64_rom_handling (); if (result == -1) // no rom, but WF_NO_ROM return -1; if (ucon64_options (&ucon64) == -1) { const st_getopt2_t *p = getopt2_get_index_by_val (options, c); const char *opt = p ? p->name : NULL; fprintf (stderr, "ERROR: %s%s encountered a problem\n", opt ? (!opt[1] ? OPTION_S : OPTION_LONG_S) : "", opt ? opt : "uCON64"); // if (p) // getopt2_usage (p); fputs (" Is the option you used available for the current console system?\n" " Please report bugs to [email protected] or [email protected]\n\n", stderr); return -1; } #if 0 // WF_NFO_AFTER?! if (!result && (ucon64.flags & WF_NFO_AFTER) && ucon64.quiet < 1) ucon64_rom_handling (); #endif /* "stop" options: - -multi (and -xfalmulti) takes more than one file as argument, but should be executed only once. - stop after sending one ROM to a copier ("multizip") - stop after applying a patch so that the patch file won't be interpreted as ROM */ if (ucon64.flags & WF_STOP) break; } if (!opts) // no options => just display ROM info { ucon64.flags = WF_DEFAULT; // WF_NO_SPLIT WF_INIT, WF_PROBE, CRC32, DATabase and WF_NFO if (ucon64_rom_handling () == -1) return -1; // no rom, but WF_NO_ROM } fflush (stdout); return 0; }