int adb_init(unsigned short port) { atexit(usb_cleanup); signal(SIGPIPE, SIG_IGN); adb_port = port; init_transport_registration(); usb_vendors_init(); usb_init(); local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); adb_auth_init(); adb_set_tcp_specifics(adb_port); char local_name[30]; build_local_name(local_name, sizeof(local_name), adb_port); if(install_listener(local_name, "*smartsocket*", NULL, 0)) { return 0; } pthread_t tid; if(pthread_create(&tid, NULL, fdevent_loop_thread,NULL)) { return 0; } return 1; }
/*========================================================== * transl_load_all_tts -- Load internal list of available translation * tables (based on *.tt files in TTPATH) * Created: 2002/11/28 (Perry Rapp) *========================================================*/ void transl_load_all_tts (void) { CNSTRING ttpath = getlloptstr("TTPATH", "."); if (!inited) local_init(); xl_load_all_dyntts(ttpath); }
int dwthread_init() { local_init(TID_START); current_tid = TID_START; return 0; }
int decode(struct dec_opts *opts) { struct shdec dec1; struct shdec * dec = &dec1; SHCodecs_Decoder * decoder; int bytes_decoded; ssize_t n; debug_printf("Format: %s\n", opts->format == SHCodecs_Format_H264 ? "H.264" : "MPEG4"); debug_printf("Resolution: %dx%d\n", opts->w, opts->h); debug_printf("Input file: %s\n", opts->file_in); debug_printf("Output file: %s\n", opts->file_out); /* H.264 spec: Max NAL size is the size of an uncompressed image divided by the "Minimum Compression Ratio", MinCR. This is 2 for most levels but is 4 for levels 3.1 to 4. Since we don't know the level, we just use MinCR=2. */ dec->max_nal_size = (opts->w * opts->h * 3) / 2; /* YCbCr420 */ dec->max_nal_size /= 2; /* Apply MinCR */ if ((decoder = shcodecs_decoder_init(opts->w, opts->h, opts->format)) == NULL) { return -1; } if (local_init(dec, opts->file_in, opts->file_out) < 0) return -1; shcodecs_decoder_set_decoded_callback (decoder, frame_decoded, dec); /* decode main loop */ do { int rem; bytes_decoded = shcodecs_decode (decoder, dec->input_buffer, dec->si_isize); rem = dec->si_isize - bytes_decoded; memmove(dec->input_buffer, dec->input_buffer + bytes_decoded, rem); n = read (dec->input_fd, dec->input_buffer + rem, dec->max_nal_size - rem); if (n < 0) break; dec->si_isize = rem + n; } while (!(n == 0 && bytes_decoded == 0)); bytes_decoded = shcodecs_decode (decoder, dec->input_buffer, dec->si_isize); /* Finalize the decode output, in case a final frame is available */ shcodecs_decoder_finalize (decoder); local_close (dec); shcodecs_decoder_close(decoder); return 0; }
local_t* function_newlocal(function_t *func, long long size) { func->locals = local_init(size, func->stack_offset, func->locals); func->stack_offset += size; func->stack_size += size; if (func->stack_size >= 256) { fprintf(stderr, "INTERNAL COMPILER ERROR: "); fprintf(stderr, "function %s has too many locals\n", func->name); exit(1); } return func->locals; }
/********************************************************************* * 初期化 ********************************************************************* */ int UsbInit(int verbose,int enable_bulk, char *serial,char *baud) { int type = 0; verbose_mode = verbose; if( hidasp_init(type,serial,baud) != 0) { if (verbose) { fprintf(stderr, "error: [%s] device not found!\n", serial); } // Sleep(1000); return 0; } else { local_init(); UsbCheckPollCmd(); return 1; // OK. } }
int main(int argc, char **argv) { printf("myGPIP main called!\n"); int err = local_init(); if (!err) { // init GPIO 17 as output initGPIO(gpio_direction_output, 17); // ...and start toggling while(1) { setGPIO(17, 1); sleep(1); setGPIO(17, 0); sleep(1); } } return 0; }
/*========================================================== * transl_load_xlats -- Load translations for all regular codesets * (internal, GUI, ...) * returns FALSE if needed conversions not available * Created: 2002/11/28 (Perry Rapp) *========================================================*/ void transl_load_xlats (void) { INT i; if (!inited) local_init(); clear_predefined_list(); for (i=0; i<NUM_TT_MAPS; ++i) { struct conversion_s * conv = getconvert(i); STRING src, dest; BOOLEAN adhoc = FALSE; ASSERT(conv->trnum == i); if (conv->src_codeset && int_codeset) { ASSERT(conv->dest_codeset); src = *conv->src_codeset; dest = *conv->dest_codeset; conv->xlat = xl_get_xlat(src, dest, adhoc); } else { /* even if codesets are unspecified, have to have a placeholder in which to store any legacy translation tables */ conv->xlat = xl_get_null_xlat(); } /* 2003-09-09, Perry I just added this today quickly today to get legacy translations working; this is kind of confusing and ought to be cleaned up */ xl_set_uparam(conv->xlat, 0); if (BTR) { TRANTABLE tt=0; if (init_map_from_rec(conv->key, i, &tt) && tt) { transl_set_legacy_tt(i, tt); } xl_set_uparam(conv->xlat, i+1); } } }
int adb_server_main(int is_daemon, int server_port, int ack_reply_fd) { #if defined(_WIN32) // adb start-server starts us up with stdout and stderr hooked up to // anonymous pipes. When the C Runtime sees this, it makes stderr and // stdout buffered, but to improve the chance that error output is seen, // unbuffer stdout and stderr just like if we were run at the console. // This also keeps stderr unbuffered when it is redirected to adb.log. if (is_daemon) { if (setvbuf(stdout, NULL, _IONBF, 0) == -1) { fatal("cannot make stdout unbuffered: %s", strerror(errno)); } if (setvbuf(stderr, NULL, _IONBF, 0) == -1) { fatal("cannot make stderr unbuffered: %s", strerror(errno)); } } SetConsoleCtrlHandler(ctrlc_handler, TRUE); #endif init_transport_registration(); usb_init(); local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); adb_auth_init(); std::string error; std::string local_name = android::base::StringPrintf("tcp:%d", server_port); if (install_listener(local_name, "*smartsocket*", nullptr, 0, &error)) { fatal("could not install *smartsocket* listener: %s", error.c_str()); } // Inform our parent that we are up and running. if (is_daemon) { close_stdin(); setup_daemon_logging(); // Any error output written to stderr now goes to adb.log. We could // keep around a copy of the stderr fd and use that to write any errors // encountered by the following code, but that is probably overkill. #if defined(_WIN32) const HANDLE ack_reply_handle = cast_int_to_handle(ack_reply_fd); const CHAR ack[] = "OK\n"; const DWORD bytes_to_write = arraysize(ack) - 1; DWORD written = 0; if (!WriteFile(ack_reply_handle, ack, bytes_to_write, &written, NULL)) { fatal("adb: cannot write ACK to handle 0x%p: %s", ack_reply_handle, SystemErrorCodeToString(GetLastError()).c_str()); } if (written != bytes_to_write) { fatal("adb: cannot write %lu bytes of ACK: only wrote %lu bytes", bytes_to_write, written); } CloseHandle(ack_reply_handle); #else // TODO(danalbert): Can't use SendOkay because we're sending "OK\n", not // "OKAY". if (!android::base::WriteStringToFd("OK\n", ack_reply_fd)) { fatal_errno("error writing ACK to fd %d", ack_reply_fd); } unix_close(ack_reply_fd); #endif } D("Event loop starting"); fdevent_loop(); return 0; }
int adb_main(int is_daemon) { #if !ADB_HOST int secure = 0; char value[PROPERTY_VALUE_MAX]; // prevent the OOM killer from killing us char text[64]; snprintf(text, sizeof text, "/proc/%d/oom_adj", (int)getpid()); int fd = adb_open(text, O_WRONLY); if (fd >= 0) { // -17 should make us immune to OOM snprintf(text, sizeof text, "%d", -17); adb_write(fd, text, strlen(text)); adb_close(fd); } else { D("adb: unable to open %s\n", text); } #endif atexit(adb_cleanup); #ifdef HAVE_WIN32_PROC SetConsoleCtrlHandler( ctrlc_handler, TRUE ); #elif defined(HAVE_FORKEXEC) signal(SIGCHLD, sigchld_handler); signal(SIGPIPE, SIG_IGN); #endif init_transport_registration(); #if ADB_HOST HOST = 1; usb_init(); local_init(); if(install_listener("tcp:5037", "*smartsocket*", NULL)) { exit(1); } #else /* run adbd in secure mode if ro.secure is set and ** we are not in the emulator */ property_get("ro.kernel.qemu", value, ""); if (strcmp(value, "1") != 0) { property_get("ro.secure", value, ""); if (strcmp(value, "1") == 0) { // don't run as root if ro.secure is set... secure = 1; // ... except we allow running as root in userdebug builds if the // service.adb.root property has been set by the "adb root" command property_get("ro.debuggable", value, ""); if (strcmp(value, "1") == 0) { property_get("service.adb.root", value, ""); if (strcmp(value, "1") == 0) { secure = 0; } } } } /* don't listen on port 5037 if we are running in secure mode */ /* don't run as root if we are running in secure mode */ if (secure) { /* add extra groups: ** AID_ADB to access the USB driver ** AID_LOG to read system logs (adb logcat) ** AID_INPUT to diagnose input issues (getevent) ** AID_INET to diagnose network issues (netcfg, ping) ** AID_GRAPHICS to access the frame buffer ** AID_NET_BT and AID_NET_BT_ADMIN to diagnose bluetooth (hcidump) */ gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS, AID_NET_BT, AID_NET_BT_ADMIN }; setgroups(sizeof(groups)/sizeof(groups[0]), groups); /* then switch user and group to "shell" */ setgid(AID_SHELL); setuid(AID_SHELL); D("Local port 5037 disabled\n"); } else { if(install_listener("tcp:5037", "*smartsocket*", NULL)) { exit(1); } } /* for the device, start the usb transport if the ** android usb device exists, otherwise start the ** network transport. */ if(access("/dev/android_adb", F_OK) == 0 || access("/dev/android", F_OK) == 0) { usb_init(); } else { local_init(); } init_jdwp(); #endif if (is_daemon) { // inform our parent that we are up and running. #ifdef HAVE_WIN32_PROC DWORD count; WriteFile( GetStdHandle( STD_OUTPUT_HANDLE ), "OK\n", 3, &count, NULL ); #elif defined(HAVE_FORKEXEC) fprintf(stderr, "OK\n"); #endif start_logging(); } fdevent_loop(); usb_cleanup(); return 0; }
int adb_main(int is_daemon, int server_port) { #if !ADB_HOST int port; char value[PROPERTY_VALUE_MAX]; umask(000); #endif atexit(adb_cleanup); #ifdef HAVE_WIN32_PROC SetConsoleCtrlHandler( ctrlc_handler, TRUE ); #elif defined(HAVE_FORKEXEC) // No SIGCHLD. Let the service subproc handle its children. signal(SIGPIPE, SIG_IGN); #endif init_transport_registration(); #if ADB_HOST HOST = 1; #ifdef WORKAROUND_BUG6558362 if(is_daemon) adb_set_affinity(); #endif usb_vendors_init(); usb_init(); local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); adb_auth_init(); char local_name[30]; build_local_name(local_name, sizeof(local_name), server_port); if(install_listener(local_name, "*smartsocket*", NULL, 0)) { exit(1); } #else property_get("ro.adb.secure", value, "0"); auth_enabled = !strcmp(value, "1"); if (auth_enabled) adb_auth_init(); // Our external storage path may be different than apps, since // we aren't able to bind mount after dropping root. const char* adb_external_storage = getenv("ADB_EXTERNAL_STORAGE"); if (NULL != adb_external_storage) { setenv("EXTERNAL_STORAGE", adb_external_storage, 1); } else { D("Warning: ADB_EXTERNAL_STORAGE is not set. Leaving EXTERNAL_STORAGE" " unchanged.\n"); } /* don't listen on a port (default 5037) if running in secure mode */ /* don't run as root if we are running in secure mode */ if (should_drop_privileges()) { drop_capabilities_bounding_set_if_needed(); /* add extra groups: ** AID_ADB to access the USB driver ** AID_LOG to read system logs (adb logcat) ** AID_INPUT to diagnose input issues (getevent) ** AID_INET to diagnose network issues (netcfg, ping) ** AID_GRAPHICS to access the frame buffer ** AID_NET_BT and AID_NET_BT_ADMIN to diagnose bluetooth (hcidump) ** AID_SDCARD_R to allow reading from the SD card ** AID_SDCARD_RW to allow writing to the SD card ** AID_MOUNT to allow unmounting the SD card before rebooting ** AID_NET_BW_STATS to read out qtaguid statistics */ gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS, AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_R, AID_SDCARD_RW, AID_MOUNT, AID_NET_BW_STATS }; if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { exit(1); } /* then switch user and group to "shell" */ if (setgid(AID_SHELL) != 0) { exit(1); } if (setuid(AID_SHELL) != 0) { exit(1); } D("Local port disabled\n"); } else { char local_name[30]; if ((root_seclabel != NULL) && (is_selinux_enabled() > 0)) { // b/12587913: fix setcon to allow const pointers if (setcon((char *)root_seclabel) < 0) { exit(1); } } build_local_name(local_name, sizeof(local_name), server_port); if(install_listener(local_name, "*smartsocket*", NULL, 0)) { exit(1); } } int usb = 0; if (access(USB_ADB_PATH, F_OK) == 0 || access(USB_FFS_ADB_EP0, F_OK) == 0) { // listen on USB usb_init(); usb = 1; } // If one of these properties is set, also listen on that port // If one of the properties isn't set and we couldn't listen on usb, // listen on the default port. property_get("service.adb.tcp.port", value, ""); if (!value[0]) { property_get("persist.adb.tcp.port", value, ""); } if (sscanf(value, "%d", &port) == 1 && port > 0) { printf("using port=%d\n", port); // listen on TCP port specified by service.adb.tcp.port property local_init(port); } else if (!usb) { // listen on default port local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); } D("adb_main(): pre init_jdwp()\n"); init_jdwp(); D("adb_main(): post init_jdwp()\n"); #endif if (is_daemon) { // inform our parent that we are up and running. #ifdef HAVE_WIN32_PROC DWORD count; WriteFile( GetStdHandle( STD_OUTPUT_HANDLE ), "OK\n", 3, &count, NULL ); #elif defined(HAVE_FORKEXEC) fprintf(stderr, "OK\n"); #endif start_logging(); } D("Event loop starting\n"); fdevent_loop(); usb_cleanup(); return 0; }
int gles_preinit(const char *arg) { local_init(arg); }
void plugin_init(G_GNUC_UNUSED GeanyData *gdata) { GeanyKeyGroup *scope_key_group; char *gladefile = g_build_filename(PLUGINDATADIR, "scope.glade", NULL); GError *gerror = NULL; GtkWidget *menubar1 = find_widget(geany->main_widgets->window, "menubar1"); guint item; const MenuKey *menu_key = debug_menu_keys; ToolItem *tool_item = toolbar_items; const ScopeCallback *scb; main_locale_init(LOCALEDIR, GETTEXT_PACKAGE); scope_key_group = plugin_set_key_group(geany_plugin, "scope", COUNT_KB, NULL); builder = gtk_builder_new(); gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE); scp_tree_store_register_dynamic(); if (!gtk_builder_add_from_file(builder, gladefile, &gerror)) { msgwin_status_add(_("Scope: %s."), gerror->message); g_warning(_("Scope: %s."), gerror->message); g_error_free(gerror); g_object_unref(builder); builder = NULL; } g_free(gladefile); if (!builder) return; /* interface */ #ifndef G_OS_UNIX gtk_widget_hide(get_widget("terminal_show")); #endif debug_item = get_widget("debug_item"); if (menubar1) gtk_menu_shell_insert(GTK_MENU_SHELL(menubar1), debug_item, DEBUG_MENU_ITEM_POS); else gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), debug_item); menu_connect("debug_menu", &debug_menu_info, NULL); ui_add_document_sensitive(get_widget("scope_reset_markers")); ui_add_document_sensitive(get_widget("scope_cleanup_files")); for (item = 0; item < EVALUATE_KB; item++, menu_key++) { keybindings_set_item(scope_key_group, item, on_scope_key, 0, 0, menu_key->name, _(menu_key->label), debug_menu_items[item].widget); } geany_statusbar = GTK_STATUSBAR(gtk_widget_get_parent(geany->main_widgets->progressbar)); debug_statusbar = get_widget("debug_statusbar"); debug_state_label = GTK_LABEL(get_widget("debug_state_label")); gtk_box_pack_end(GTK_BOX(geany_statusbar), debug_statusbar, FALSE, FALSE, 0); debug_panel = get_widget("debug_panel"); gtk_notebook_append_page(GTK_NOTEBOOK(geany->main_widgets->message_window_notebook), debug_panel, get_widget("debug_label")); /* startup */ gtk216_init(); program_init(); prefs_init(); conterm_init(); inspect_init(); register_init(); parse_init(); debug_init(); views_init(); thread_init(); break_init(); watch_init(); stack_init(); local_init(); memory_init(); menu_init(); menu_set_popup_keybindings(scope_key_group, item); for (item = 0; tool_item->index != -1; item++, tool_item++) { GtkMenuItem *menu_item = GTK_MENU_ITEM(debug_menu_items[tool_item->index].widget); GtkToolItem *button = gtk_tool_button_new(NULL, gtk_menu_item_get_label(menu_item)); gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(button), gtk_menu_item_get_use_underline(menu_item)); g_signal_connect(button, "clicked", G_CALLBACK(on_toolbar_button_clicked), GINT_TO_POINTER(tool_item->index)); g_signal_connect(button, "toolbar-reconfigured", G_CALLBACK(on_toolbar_reconfigured), tool_item); tool_item->widget = GTK_WIDGET(button); plugin_add_toolbar_item(geany_plugin, button); } toolbar_update_state(DS_INACTIVE); views_update_state(DS_INACTIVE); configure_toolbar(); g_signal_connect(debug_panel, "switch-page", G_CALLBACK(on_view_changed), NULL); for (scb = scope_callbacks; scb->name; scb++) plugin_signal_connect(geany_plugin, NULL, scb->name, FALSE, scb->callback, NULL); }
int adbd_main(int server_port) { umask(0); signal(SIGPIPE, SIG_IGN); init_transport_registration(); // We need to call this even if auth isn't enabled because the file // descriptor will always be open. adbd_cloexec_auth_socket(); if (ALLOW_ADBD_NO_AUTH && property_get_bool("ro.adb.secure", 0) == 0) { auth_required = false; } adbd_auth_init(); // Our external storage path may be different than apps, since // we aren't able to bind mount after dropping root. const char* adb_external_storage = getenv("ADB_EXTERNAL_STORAGE"); if (adb_external_storage != nullptr) { setenv("EXTERNAL_STORAGE", adb_external_storage, 1); } else { D("Warning: ADB_EXTERNAL_STORAGE is not set. Leaving EXTERNAL_STORAGE" " unchanged.\n"); } drop_privileges(server_port); bool is_usb = false; if (access(USB_ADB_PATH, F_OK) == 0 || access(USB_FFS_ADB_EP0, F_OK) == 0) { // Listen on USB. usb_init(); is_usb = true; } // If one of these properties is set, also listen on that port. // If one of the properties isn't set and we couldn't listen on usb, listen // on the default port. char prop_port[PROPERTY_VALUE_MAX]; property_get("service.adb.tcp.port", prop_port, ""); if (prop_port[0] == '\0') { property_get("persist.adb.tcp.port", prop_port, ""); } int port; if (sscanf(prop_port, "%d", &port) == 1 && port > 0) { D("using port=%d", port); // Listen on TCP port specified by service.adb.tcp.port property. local_init(port); } else if (!is_usb) { // Listen on default port. local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); } D("adbd_main(): pre init_jdwp()"); init_jdwp(); D("adbd_main(): post init_jdwp()"); D("Event loop starting"); fdevent_loop(); return 0; }
static void setup_port(int port) { local_init(port); setup_mdns(port); }
/*char isStuck() { m_wait(100); //localize(data); distfrombound = data[1] + ((float)BOUNDARYTHRESHOLD)*sin((data[2]+90.0)*3.14/180.0*-1.0); if (distfrombound > 60.0 || distfrombound < -60.0) { return 1; } m_usb_tx_int((int)distfrombound); m_usb_tx_char('\n'); } long loccounter = 0; float prevx = 0.0; float prevy = 0.0; */ int main(void) { //goal side clear(DDRB,1); clear(PORTB,1); if (check(PINB,1)) { goal = 1; } set(DDRB,0); set(PORTB,0); set(DDRD,5); set(DDRD,3); //wireless stuffs m_bus_init(); m_rf_open(CHANNEL, RXADDRESS, PACKET_LENGTH); int counter = 0; // //m_num_init(); int flag; m_clockdivide(0); m_disableJTAG(); //TIMER 0: For Controlling the solenoid // // set(TCCR0B, WGM02); // set(TCCR0A, WGM01); // set(TCCR0A, WGM01); // // set(TCCR0A, COM0B1); // clear(TCCR0A, COM0B0); // // set(TCCR0B, CS02); // set(TCCR0B, CS01); // set(TCCR0B, CS00); // set(DDRB,7); // OCR0A = 0xFF; // OCR0B = 0xff; // //TIMER 1: For Controlling the left wheel set(TCCR1B, WGM13); set(TCCR1B, WGM12); set(TCCR1A, WGM11); set(TCCR1A, WGM10); set(TCCR1A, COM1B1); clear(TCCR1A, COM1B0); clear(TCCR1B, CS12); clear(TCCR1B, CS11); set(TCCR1B, CS10); set(DDRB,6); OCR1A = 0xFFFF; OCR1B = 0; //TIMER 3: For Controlling the right wheel //up to ICR3, clear at OCR3A & set at rollover set(TCCR3B, WGM33); set(TCCR3B, WGM32); set(TCCR3A, WGM31); clear(TCCR3A, WGM30); set(TCCR3A, COM3A1); clear(TCCR3A, COM3A0); clear(TCCR3B, CS32); clear(TCCR3B, CS31); set(TCCR3B, CS30); ICR3 = 0xFFFF; OCR3A = 0; // //Set TCNT0 to go up to OCR0A // clear(TCCR0B, WGM02); // set (TCCR0A, WGM01); // clear(TCCR0A, WGM00); // // // Don't change pin upon hitting OCR0B // clear(TCCR0A, COM0A1); // clear(TCCR0A, COM0A0); // // // Set clock scale to /1024 // set(TCCR0B, CS02); // clear(TCCR0B, CS01); // set(TCCR0B, CS00); // // // Set Frequency of readings to 1/SAMPLERATE; dt = 1/SAMPLERATE // OCR0A = (unsigned int) ((float) F_CPU / 1024 / REPORTRATE); // OCR0B = 1; // Set up interrupt for reading values at sampling rate //Pin for controlling solenoid pulse set(DDRB,7); //Pins for controlling speed of left and right wheel set(DDRB,6); set(DDRC,6); //Pins for determining direction of wheels set(DDRB,2); set(DDRB,3); //Blue LED for Comm Test //set(DDRB,5); //ADC's sei(); //Set up interrupts set(ADCSRA, ADIE); clear(ADMUX, REFS1); //Voltage reference is AR pin (5V) clear(ADMUX, REFS0); //^ set(ADCSRA, ADPS2); //Set scale to /128 set(ADCSRA, ADPS1); //^ set(ADCSRA, ADPS0); //^ set(DIDR0, ADC0D); //Disable digital input for F0 set(DIDR0, ADC1D), set(DIDR0, ADC4D); set(DIDR0, ADC5D); set(DIDR0, ADC6D); set(DIDR0, ADC7D); set(DIDR2, ADC8D); set(DIDR2, ADC9D); set(ADCSRA, ADATE); //Set trigger to free-running mode chooseInput(0); set(ADCSRA, ADEN); //Enable/Start conversion set(ADCSRA, ADSC); //^ set(ADCSRA, ADIF); //Enable reading results //Limit Switch stuffs // clear(DDRB,0); //set to input, RIGHT LIMIT SWITCH // clear(DDRB,1); //set to input, LEFT LIMIT SWITCH // // clear(PORTB,0); //disable internal pull up resistor // clear(PORTB,1); //disable internal pull up resistor //int state; // state variable state = 0; //set state play = 0; long count = 0; if (state == 70) { m_usb_init(); // connect usb while(!m_usb_isconnected()); //wait for connection } //m_bus_init(); m_wii_open(); //m_usb_init(); m_red(ON); local_init(); localize(data); m_red(OFF); //set(TIMSK0, OCIE0A); while(1) { if (play) {m_red(ON);} else {m_red(OFF);} // m_wait(100); // m_red(TOGGLE); // localize(data); /*if (loccounter == LOCCOUNT) { if (sqrt((data[0]-prevx)*(data[0]-prevx)+(data[1]-prevy)-(data[1]-prevy)) < 1.0) { m_red(ON); reverse(); m_wait(100); state = 6; } else { m_red(OFF); state = 2; } prevx = data[0]; prevy = data[1]; loccounter = 0; }*/ //loccounter++; // localize(data); // locdata[1] = (char)data[0]; // locdata[2] = (char)data[1]; // toggle(PORTD,3); changedState = 0; angle_dif = 0; //Detect weather we have the puck getADC(); //if (!play) game_pause(); if (ADCarr[7] > 500) { //set(PORTD,5); //set(PORTD,5); iHaveThePuck = 1; m_green(ON); if (play && goal == A) state = 3; if (play && goal == B) state = 4; } else { //clear(PORTD,5); iHaveThePuck = 0; m_green(OFF); if (play) state = 2; } if(iHaveThePuck && state == 2) { //set(PORTB,5); //drive_to_goalA(); } else { //clear(PORTB,5); //if (state != 0) state = 2; } // if(isStuck()) { // //set(PORTD,5);u // } // else { // //clear(PORTD,5); // } //localize(data); // if (check(PINB,0)) { // set(PORTD,5); // state = 0x1A; // } else { // clear(PORTD,5); // state = 2; // } if (!play) state = buffer[0]; //switch states switch (state) { case -2: getADC(); if (ADCarr[0] > 500) { m_green(ON); } else {m_green(OFF)} break; case -1: //test Limit switches //m_green(ON); if (check(PINB,1)) { m_green(ON); } else if (check(PINB,0)) { m_red(ON); } else { m_red(OFF); m_green(OFF); } break; case 0: //drive_to_point2(-100,0); game_pause(); break; case 1: findPuck(); break; case 2: //m_red(ON); if (!iHaveThePuck) { if (play) drive_to_puck(); } break; case 3: if (play) drive_to_goalA(); break; case 4: if (play) drive_to_goalB(); break; case 5: getADC(); if (ADCarr[7] > 500) { //set(PORTD,5); } else { //clear(PORTD,5); } break; case 6: if (data[2] > 0) { rotate(RIGHT,1); } else { rotate(LEFT,1); } break; case 7: drive_to_point2(-50,0); break; case 0xA0: comm_test(); break; case 0xA1: play = 1; drive_to_puck(); break; case 0xA2: play = 0; game_pause(); break; case 0xA3: play = 0; game_pause(); break; case 0xA4: play = 0; game_pause(); break; case 0xA6: play = 0; game_pause(); break; case 0xA7: game_pause(); break; case 69: set(PORTB,2); set(PORTB,3); OCR1B = OCR1A; OCR3A = ICR3; break; case 70: reportADC(); break; default: game_pause(); break; } } }
Bool zpl_read(const char* filename, Bool with_management, void* user_data) { Prog* prog = NULL; Set* set; void* lp = NULL; Bool ret = FALSE; stkchk_init(); yydebug = 0; yy_flex_debug = 0; zpl_print_banner(stdout, FALSE); blk_init(); str_init(); rand_init(13021967UL); numb_init(with_management); elem_init(); set_init(); mio_init(); interns_init(); local_init(); if (0 == setjmp(zpl_read_env)) { is_longjmp_ok = TRUE; set = set_pseudo_new(); (void)symbol_new(SYMBOL_NAME_INTERNAL, SYM_VAR, set, 100, NULL); set_free(set); prog = prog_new(); prog_load(prog, NULL, filename); if (prog_is_empty(prog)) fprintf(stderr, "*** Error 168: No program statements to execute\n"); else { if (verbose >= VERB_DEBUG) prog_print(stderr, prog); lp = xlp_alloc(filename, FALSE, user_data); prog_execute(prog, lp); ret = TRUE; } } is_longjmp_ok = FALSE; if (lp != NULL) xlp_free(lp); if (prog != NULL) prog_free(prog); local_exit(); interns_exit(); mio_exit(); symbol_exit(); define_exit(); set_exit(); elem_exit(); numb_exit(); str_exit(); blk_exit(); return ret; }
int main(int argc, char* const* argv) { Prog* prog; Set* set; void* lp; const char* extension = ""; char* filter = strdup("%s"); char* outfile; char* tblfile; char* ordfile; char* mstfile; char* basefile = NULL; char* inppipe = NULL; char* outpipe; LpFormat format = LP_FORM_LPF; FILE* fp; Bool write_order = FALSE; Bool write_mst = FALSE; Bool presolve = FALSE; int name_length = 0; char* prog_text; unsigned long seed = 13021967UL; char** param_table; int param_count = 0; int c; int i; FILE* (*openfile)(const char*, const char*) = fopen; int (*closefile)(FILE*) = fclose; stkchk_init(); yydebug = 0; yy_flex_debug = 0; verbose = VERB_NORMAL; param_table = malloc(sizeof(*param_table)); while((c = getopt(argc, argv, options)) != -1) { switch(c) { case 'b' : yydebug = 1; break; case 'D' : param_table = realloc(param_table, ((unsigned int)param_count + 1) * sizeof(*param_table)); param_table[param_count] = strdup(optarg); param_count++; break; case 'h' : zpl_print_banner(stdout, TRUE); printf(usage, argv[0]); puts(help); exit(0); case 'f' : yy_flex_debug = 1; break; case 'F' : free(filter); filter = strdup(optarg); openfile = popen; closefile = pclose; break; case 'l' : name_length = atoi(optarg); break; case 'm' : write_mst = TRUE; break; case 'n' : if (*optarg != 'c') { fprintf(stderr, usage, argv[0]); exit(0); } switch(optarg[1]) { case 'm' : conname_format(CON_FORM_MAKE); break; case 'n' : conname_format(CON_FORM_NAME); break; case 'f' : conname_format(CON_FORM_FULL); break; default : fprintf(stderr, usage, argv[0]); exit(0); } break; case 'o' : basefile = strdup(optarg); break; case 'O' : presolve = TRUE; break; case 'P' : inppipe = strdup(optarg); break; case 's' : seed = (unsigned long)atol(optarg); break; case 'r' : write_order = TRUE; break; case 't' : switch(tolower(*optarg)) { case 'h' : format = LP_FORM_HUM; break; case 'm' : format = LP_FORM_MPS; break; case 'l' : format = LP_FORM_LPF; break; case 'p' : format = LP_FORM_PIP; break; case 'r' : format = LP_FORM_RLP; break; default : if (verbose > VERB_QUIET) fprintf(stderr, "--- Warning 103: Output format \"%s\" not supported, using LP format\n", optarg); format = LP_FORM_LPF; break; } break; case 'v' : verbose = atoi(optarg); break; case 'V' : printf("%s\n", VERSION); exit(0); case '?': fprintf(stderr, usage, argv[0]); exit(0); default : abort(); } } if ((argc - optind) < 1) { fprintf(stderr, usage, argv[0]); exit(0); } zpl_print_banner(stdout, TRUE); if (basefile == NULL) basefile = strip_extension(strdup(strip_path(argv[optind]))); switch(format) { case LP_FORM_LPF : extension = ".lp"; break; case LP_FORM_MPS : extension = ".mps"; break; case LP_FORM_HUM : extension = ".hum"; break; case LP_FORM_RLP : extension = ".rlp"; break; case LP_FORM_PIP : extension = ".pip"; break; default : abort(); } assert(extension != NULL); outfile = add_extention(basefile, extension); tblfile = add_extention(basefile, ".tbl"); ordfile = add_extention(basefile, ".ord"); mstfile = add_extention(basefile, ".mst"); outpipe = malloc(strlen(basefile) + strlen(filter) + 256); assert(outpipe != NULL); blk_init(); str_init(); rand_init(seed); numb_init(TRUE); elem_init(); set_init(); mio_init(); interns_init(); local_init(); /* Make symbol to hold entries of internal variables */ set = set_pseudo_new(); (void)symbol_new(SYMBOL_NAME_INTERNAL, SYM_VAR, set, 100, NULL); set_free(set); /* Now store the param defines */ for(i = 0; i < param_count; i++) zpl_add_parameter(param_table[i]); /* Next we read in the zpl program(s) */ prog = prog_new(); for(i = optind; i < argc; i++) prog_load(prog, inppipe, argv[i]); if (prog_is_empty(prog)) { fprintf(stderr, "*** Error 168: No program statements to execute\n"); exit(EXIT_FAILURE); } if (verbose >= VERB_DEBUG) prog_print(stderr, prog); lp = xlp_alloc(argv[optind], write_mst || write_order, NULL); zlp_setnamelen(lp, name_length); prog_execute(prog, lp); /* Presolve */ if (presolve) fprintf(stderr, "--- Warning: Presolve no longer support. If you need it, send me an email\n"); #if 0 if (!zlp_presolve()) exit(EXIT_SUCCESS); #endif if (verbose >= VERB_NORMAL) zlp_stat(lp); /* Write order file */ if (write_order) { sprintf(outpipe, filter, ordfile, "ord"); if (verbose >= VERB_NORMAL) printf("Writing [%s]\n", outpipe); if (NULL == (fp = (*openfile)(outpipe, "w"))) { fprintf(stderr, "*** Error 104: File open failed "); perror(ordfile); exit(EXIT_FAILURE); } zlp_orderfile(lp, fp, format); check_write_ok(fp, ordfile); (void)(*closefile)(fp); } /* Write MST file */ if (write_mst) { sprintf(outpipe, filter, mstfile, "mst"); if (verbose >= VERB_NORMAL) printf("Writing [%s]\n", outpipe); if (NULL == (fp = (*openfile)(outpipe, "w"))) { fprintf(stderr, "*** Error 104: File open failed "); perror(mstfile); exit(EXIT_FAILURE); } zlp_mstfile(lp, fp, format); check_write_ok(fp, mstfile); (void)(*closefile)(fp); } /* Write Output */ sprintf(outpipe, filter, outfile, "lp"); if (verbose >= VERB_NORMAL) printf("Writing [%s]\n", outpipe); if (NULL == (fp = (*openfile)(outpipe, "w"))) { fprintf(stderr, "*** Error 104: File open failed "); perror(outfile); exit(EXIT_FAILURE); } if (format != LP_FORM_RLP) prog_text = prog_tostr(prog, format == LP_FORM_MPS ? "* " : "\\ ", title, 128); else { prog_text = malloc(strlen(title) + 4); assert(prog_text != NULL); sprintf(prog_text, "\\%s\n", title); } zlp_write(lp, fp, format, prog_text); check_write_ok(fp, outfile); (void)(*closefile)(fp); /* We do not need the translation table for human readable format * Has to be written after the LP file, so the scaling has been done. */ if (format != LP_FORM_HUM) { /* Write translation table */ sprintf(outpipe, filter, tblfile, "tbl"); if (verbose >= VERB_NORMAL) printf("Writing [%s]\n", outpipe); if (NULL == (fp = (*openfile)(outpipe, "w"))) { fprintf(stderr, "*** Error 104: File open failed"); perror(tblfile); exit(EXIT_FAILURE); } zlp_transtable(lp, fp, format); check_write_ok(fp, tblfile); (void)(*closefile)(fp); } free(prog_text); if (verbose >= VERB_DEBUG) symbol_print_all(stderr); #if defined(__INSURE__) || !defined(NDEBUG) || defined(FREEMEM) /* Now clean up. */ if (inppipe != NULL) free(inppipe); for(i = 0; i < param_count; i++) free(param_table[i]); free(param_table); prog_free(prog); local_exit(); interns_exit(); xlp_free(lp); mio_exit(); symbol_exit(); define_exit(); set_exit(); elem_exit(); numb_exit(); str_exit(); blk_exit(); free(mstfile); free(ordfile); free(outfile); free(tblfile); free(basefile); free(filter); free(outpipe); if (verbose >= VERB_NORMAL) { mem_display(stdout); stkchk_maximum(stdout); } #endif /* __INSURE__ || !NDEBUG || FREEMEM */ return 0; }
static void um_account_dialog_init (UmAccountDialog *self) { GtkBuilder *builder; GtkWidget *widget; const gchar *filename; GError *error = NULL; GtkDialog *dialog; GtkWidget *content; GtkWidget *actions; GtkWidget *box; builder = gtk_builder_new (); filename = UIDIR "/account-dialog.ui"; if (!g_file_test (filename, G_FILE_TEST_EXISTS)) filename = "data/account-dialog.ui"; if (!gtk_builder_add_from_file (builder, filename, &error)) { g_error ("%s", error->message); g_error_free (error); return; } dialog = GTK_DIALOG (self); actions = gtk_dialog_get_action_area (dialog); content = gtk_dialog_get_content_area (dialog); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_title (GTK_WINDOW (dialog), " "); gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-users"); /* Rearrange the bottom of dialog, so we can have spinner on left */ g_object_ref (actions); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_container_remove (GTK_CONTAINER (content), actions); gtk_box_pack_end (GTK_BOX (box), actions, FALSE, TRUE, 0); gtk_box_pack_end (GTK_BOX (content), box, TRUE, TRUE, 0); gtk_widget_show (box); g_object_unref (actions); /* Create the spinner, but don't show it yet */ self->spinner = GTK_SPINNER (gtk_spinner_new ()); widget = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 0, 0, 12, 6); gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (self->spinner)); gtk_widget_show (widget); gtk_dialog_add_button (dialog, _("Cancel"), GTK_RESPONSE_CANCEL); widget = gtk_dialog_add_button (dialog, _("_Add"), GTK_RESPONSE_OK); gtk_widget_grab_default (widget); widget = (GtkWidget *) gtk_builder_get_object (builder, "account-dialog"); gtk_container_add (GTK_CONTAINER (content), widget); self->container_widget = widget; local_init (self, builder); enterprise_init (self, builder); join_init (self, builder); mode_init (self, builder); g_object_unref (builder); }
Bool zpl_read_with_args(char** argv, int argc, Bool with_management, void* user_data) { const char* options = "D:mP:sv:"; unsigned long seed = 13021967UL; char** param_table; int param_count = 0; int c; int i; Prog* prog = NULL; Set* set; void* lp = NULL; Bool ret = FALSE; char* inppipe = NULL; Bool use_startval = FALSE; stkchk_init(); yydebug = 0; yy_flex_debug = 0; param_table = malloc(sizeof(*param_table)); zpl_print_banner(stdout, FALSE); /* getopt might be called more than once */ optind = 1; while((c = getopt(argc, argv, options)) != -1) { switch(c) { case 'D' : param_table = realloc(param_table, ((unsigned int)param_count + 1) * sizeof(*param_table)); param_table[param_count] = strdup(optarg); if (verbose >= VERB_DEBUG) printf("Parameter %d [%s]\n", param_count, param_table[param_count]); param_count++; break; case 'm' : use_startval = TRUE; break; case 'P' : inppipe = strdup(optarg); break; case 's' : seed = (unsigned long)atol(optarg); break; case 'v' : verbose = atoi(optarg); break; case '?': fprintf(stderr, "Unknown option '%c'\n", c); return FALSE; default : abort(); } } if ((argc - optind) < 1) { fprintf(stderr, "Filename missing\n"); free(param_table); return FALSE; } blk_init(); str_init(); rand_init(seed); numb_init(with_management); elem_init(); set_init(); mio_init(); interns_init(); local_init(); if (0 == setjmp( zpl_read_env)) { is_longjmp_ok = TRUE; /* Make symbol to hold entries of internal variables */ set = set_pseudo_new(); (void)symbol_new(SYMBOL_NAME_INTERNAL, SYM_VAR, set, 100, NULL); set_free(set); /* Now store the param defines */ for(i = 0; i < param_count; i++) zpl_add_parameter(param_table[i]); prog = prog_new(); for(i = optind; i < argc; i++) prog_load(prog, inppipe, argv[i]); if (prog_is_empty(prog)) fprintf(stderr, "*** Error 168: No program statements to execute\n"); else { if (verbose >= VERB_DEBUG) prog_print(stderr, prog); lp = xlp_alloc(argv[optind], use_startval, user_data); prog_execute(prog, lp); ret = TRUE; } } is_longjmp_ok = FALSE; if (lp != NULL) xlp_free(lp); /* Now clean up. */ if (inppipe != NULL) free(inppipe); for(i = 0; i < param_count; i++) free(param_table[i]); free(param_table); if (prog != NULL) prog_free(prog); local_exit(); interns_exit(); mio_exit(); symbol_exit(); define_exit(); set_exit(); elem_exit(); numb_exit(); str_exit(); blk_exit(); return ret; }
static int rte_init(void) { int ret; char *error = NULL; char *tmp=NULL; orte_jobid_t jobid=ORTE_JOBID_INVALID; orte_vpid_t vpid=ORTE_VPID_INVALID; int32_t jfam; /* run the prolog */ if (ORTE_SUCCESS != (ret = orte_ess_base_std_prolog())) { error = "orte_ess_base_std_prolog"; goto error; } /* if we were given a jobid, use it */ mca_base_param_reg_string_name("orte", "ess_jobid", "Process jobid", true, false, NULL, &tmp); if (NULL != tmp) { if (ORTE_SUCCESS != (ret = orte_util_convert_string_to_jobid(&jobid, tmp))) { ORTE_ERROR_LOG(ret); error = "convert_jobid"; goto error; } free(tmp); ORTE_PROC_MY_NAME->jobid = jobid; } /* if we were given a vpid, use it */ mca_base_param_reg_string_name("orte", "ess_vpid", "Process vpid", true, false, NULL, &tmp); if (NULL != tmp) { if (ORTE_SUCCESS != (ret = orte_util_convert_string_to_vpid(&vpid, tmp))) { ORTE_ERROR_LOG(ret); error = "convert_vpid"; goto error; } free(tmp); ORTE_PROC_MY_NAME->vpid = vpid; } /* if both were given, then we are done */ if (ORTE_JOBID_INVALID == jobid || ORTE_VPID_INVALID == vpid) { /* create our own name */ if (ORTE_SUCCESS != (ret = orte_plm_base_open())) { ORTE_ERROR_LOG(ret); error = "orte_plm_base_open"; goto error; } if (ORTE_SUCCESS != (ret = orte_plm_base_select())) { ORTE_ERROR_LOG(ret); error = "orte_plm_base_select"; goto error; } if (ORTE_SUCCESS != (ret = orte_plm.set_hnp_name())) { ORTE_ERROR_LOG(ret); error = "orte_plm_set_hnp_name"; goto error; } /* close the plm since we opened it to set our * name, but have no further use for it */ orte_plm_base_close(); } /* do the rest of the standard tool init */ if (ORTE_SUCCESS != (ret = local_init())) { ORTE_ERROR_LOG(ret); error = "orte_ess_tool_init"; goto error; } return ORTE_SUCCESS; error: orte_show_help("help-orte-runtime.txt", "orte_init:startup:internal-failure", true, error, ORTE_ERROR_NAME(ret), ret); return ret; }
int adb_main(int is_daemon, int server_port) { #if !ADB_HOST int secure = 0; int port; char value[PROPERTY_VALUE_MAX]; #endif atexit(adb_cleanup); #ifdef HAVE_WIN32_PROC SetConsoleCtrlHandler( ctrlc_handler, TRUE ); #elif defined(HAVE_FORKEXEC) signal(SIGCHLD, sigchld_handler); signal(SIGPIPE, SIG_IGN); #endif init_transport_registration(); #if ADB_HOST HOST = 1; usb_vendors_init(); usb_init(); local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); char local_name[30]; build_local_name(local_name, sizeof(local_name), server_port); if(install_listener(local_name, "*smartsocket*", NULL)) { exit(1); } #else /* run adbd in secure mode if ro.secure is set and ** we are not in the emulator */ property_get("ro.kernel.qemu", value, ""); if (strcmp(value, "1") != 0) { property_get("ro.secure", value, ""); if (strcmp(value, "1") == 0) { // don't run as root if ro.secure is set... secure = 1; // ... except we allow running as root in userdebug builds if the // service.adb.root property has been set by the "adb root" command property_get("ro.debuggable", value, ""); if (strcmp(value, "1") == 0) { property_get("service.adb.root", value, ""); if (strcmp(value, "1") == 0) { secure = 0; } } } } /* don't listen on a port (default 5037) if running in secure mode */ /* don't run as root if we are running in secure mode */ if (secure) { struct __user_cap_header_struct header; struct __user_cap_data_struct cap; if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) != 0) { exit(1); } /* add extra groups: ** AID_ADB to access the USB driver ** AID_LOG to read system logs (adb logcat) ** AID_INPUT to diagnose input issues (getevent) ** AID_INET to diagnose network issues (netcfg, ping) ** AID_GRAPHICS to access the frame buffer ** AID_NET_BT and AID_NET_BT_ADMIN to diagnose bluetooth (hcidump) ** AID_SDCARD_RW to allow writing to the SD card ** AID_MOUNT to allow unmounting the SD card before rebooting */ gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS, AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_RW, AID_MOUNT }; if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { exit(1); } /* then switch user and group to "shell" */ if (setgid(AID_SHELL) != 0) { exit(1); } if (setuid(AID_SHELL) != 0) { exit(1); } /* set CAP_SYS_BOOT capability, so "adb reboot" will succeed */ header.version = _LINUX_CAPABILITY_VERSION; header.pid = 0; cap.effective = cap.permitted = (1 << CAP_SYS_BOOT); cap.inheritable = 0; capset(&header, &cap); D("Local port disabled\n"); } else { char local_name[30]; build_local_name(local_name, sizeof(local_name), server_port); if(install_listener(local_name, "*smartsocket*", NULL)) { exit(1); } } /* for the device, start the usb transport if the ** android usb device exists and the "service.adb.tcp.port" and ** "persist.adb.tcp.port" properties are not set. ** Otherwise start the network transport. */ property_get("service.adb.tcp.port", value, ""); if (!value[0]) property_get("persist.adb.tcp.port", value, ""); if (sscanf(value, "%d", &port) == 1 && port > 0) { // listen on TCP port specified by service.adb.tcp.port property local_init(port); } else if (access("/dev/android_adb", F_OK) == 0) { // listen on USB usb_init(); } else { // listen on default port local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); } init_jdwp(); #endif if (is_daemon) { // inform our parent that we are up and running. #ifdef HAVE_WIN32_PROC DWORD count; WriteFile( GetStdHandle( STD_OUTPUT_HANDLE ), "OK\n", 3, &count, NULL ); #elif defined(HAVE_FORKEXEC) fprintf(stderr, "OK\n"); #endif start_logging(); } fdevent_loop(); usb_cleanup(); return 0; }
void bfelf_loader_ut::test_bfelf_loader_resolve_symbol_real_test() { auto ret = 0LL; bfelf_file_t dummy_misc_ef; bfelf_file_t dummy_code_ef; ret = bfelf_file_init(m_dummy_misc.get(), m_dummy_misc_length, &dummy_misc_ef); ASSERT_TRUE(ret == BFELF_SUCCESS); ret = bfelf_file_init(m_dummy_code.get(), m_dummy_code_length, &dummy_code_ef); ASSERT_TRUE(ret == BFELF_SUCCESS); m_dummy_misc_exec = load_elf_file(&dummy_misc_ef); ASSERT_TRUE(m_dummy_misc_exec.get() != 0); m_dummy_code_exec = load_elf_file(&dummy_code_ef); ASSERT_TRUE(m_dummy_code_exec.get() != 0); bfelf_loader_t loader; memset(&loader, 0, sizeof(loader)); ret = bfelf_loader_add(&loader, &dummy_misc_ef, m_dummy_misc_exec.get()); ASSERT_TRUE(ret == BFELF_SUCCESS); ret = bfelf_loader_add(&loader, &dummy_code_ef, m_dummy_code_exec.get()); ASSERT_TRUE(ret == BFELF_SUCCESS); ret = bfelf_loader_relocate(&loader); EXPECT_TRUE(ret == BFELF_SUCCESS); { section_info_t info; local_init_t local_init; e_string_t name = {"local_init", 10}; ret = bfelf_loader_get_info(&loader, &dummy_misc_ef, &info); ASSERT_TRUE(ret == BFELF_SUCCESS); ret = bfelf_file_resolve_symbol(&dummy_misc_ef, &name, (void **)&local_init); ASSERT_TRUE(ret == BFELF_SUCCESS); local_init(&info); ret = bfelf_loader_get_info(&loader, &dummy_code_ef, &info); ASSERT_TRUE(ret == BFELF_SUCCESS); ret = bfelf_file_resolve_symbol(&dummy_misc_ef, &name, (void **)&local_init); ASSERT_TRUE(ret == BFELF_SUCCESS); local_init(&info); } { func_t func; e_string_t name = {"foo", 3}; ret = bfelf_loader_resolve_symbol(&loader, &name, (void **)&func); ASSERT_TRUE(ret == BFELF_SUCCESS); EXPECT_TRUE(func(5) == 1005); } { section_info_t info; local_fini_t local_fini; e_string_t name = {"local_fini", 10}; ret = bfelf_loader_get_info(&loader, &dummy_misc_ef, &info); ASSERT_TRUE(ret == BFELF_SUCCESS); ret = bfelf_file_resolve_symbol(&dummy_misc_ef, &name, (void **)&local_fini); ASSERT_TRUE(ret == BFELF_SUCCESS); local_fini(&info); ret = bfelf_loader_get_info(&loader, &dummy_code_ef, &info); ASSERT_TRUE(ret == BFELF_SUCCESS); ret = bfelf_file_resolve_symbol(&dummy_misc_ef, &name, (void **)&local_fini); ASSERT_TRUE(ret == BFELF_SUCCESS); local_fini(&info); } }