//-------------------------------------------------------- //static int8_t input0 (func_cb_ptr p, void *data, uint16_t length) { static int8_t input0 (func_cb_ptr p, token_type_t *t) { update_background_state_t *s = (update_background_state_t *)sys_get_state(); // Get token from port. if (s->state == UPD_STATE_INIT) { s->backMat = (CYCLOPS_Matrix *)capture_token_data(t, s->pid); if (s->backMat == NULL) return -ENOMEM; s->state = UPD_STATE_PROCESS; } else { CYCLOPS_Matrix *M = (CYCLOPS_Matrix *)get_token_data(t); //check that input matrix's depth is 1 byte if( (M->depth != CYCLOPS_1BYTE) || (s->backMat->depth != CYCLOPS_1BYTE) ) return -EINVAL; token_type_t *my_token = create_token(s->backMat, sizeof(CYCLOPS_Matrix), s->pid); if (my_token == NULL) return -EINVAL; set_token_type(my_token, CYCLOPS_MATRIX); //SOS_CALL(s->put_token, put_token_func_t, s->output0, my_token); dispatch(s->output0, my_token); destroy_token(my_token); } return SOS_OK; }
//-------------------------------------------------------- //static int8_t input3 (func_cb_ptr p, void *data, uint16_t length) { static int8_t input3 (func_cb_ptr p, token_type_t *t) { over_thresh_state_t *s = (over_thresh_state_t *)sys_get_state(); if (t == NULL) return -EINVAL; // Get token from port. s->col = *((uint8_t *)get_token_data(t)); s->state++; return process_input(s); }
static int8_t input0 (func_cb_ptr p, token_type_t *t) { uint8_t value = *((uint8_t *)get_token_data(t)); LED_DBG(LED_RED_OFF); LED_DBG(LED_GREEN_OFF); LED_DBG(LED_YELLOW_OFF); if (value & 0x01) LED_DBG(LED_RED_ON); if (value & 0x02) LED_DBG(LED_GREEN_ON); if (value & 0x04) LED_DBG(LED_YELLOW_ON); return SOS_OK; }
static int8_t input0 (func_cb_ptr p, token_type_t *t) { element_state_t *s = (element_state_t *)sys_get_state(); s->value = *((uint8_t *)get_token_data(t)); // Get token from port. // If want to break the chain of calls here, then copy the token into a private // data structure(global), and return appropriate value (SOS_OK). //SOS_CALL(s->put_token, put_token_func_t, s->output0, &threshold, sizeof(uint8_t)); LED_DBG(LED_GREEN_TOGGLE); sys_post_uart(TRANSMIT_MOD_PID, 0x80, sizeof(uint8_t), &(s->value), 0, BCAST_ADDRESS); return SOS_OK; }
static int8_t input0 (func_cb_ptr p, token_type_t *t) { element_state_t *s = (element_state_t *)sys_get_state(); // Get token from port. // If want to break the chain of calls here, then copy the token into a private // data structure(global), and return appropriate value (SOS_OK). // Process input: Extract 3 LSB's and pass it on to the next function. // We need a separate place to hold the output as we are modifying the input. // Remember, this module does not own the input token, so should not // overwrite it. uint8_t out_value = (*((uint8_t *)get_token_data(t))) & s->bit_mask; token_type_t *my_token = create_token(&out_value, sizeof(uint8_t), s->pid); if (my_token == NULL) return -ENOMEM; //SOS_CALL(s->put_token, put_token_func_t, s->output0, my_token); dispatch(s->output0, my_token); destroy_token(my_token); return SOS_OK; }
static int8_t input2 (func_cb_ptr p, token_type_t *t) { element_state_t *s = (element_state_t *)sys_get_state(); DEBUG("COMBINE: Accept - token %d on input 2.\n", *((uint8_t *)get_token_data(t))); return process_input(s, *((uint8_t *)get_token_data(t))); }
BOOL ExtractISO(const char* src_iso, const char* dest_dir, bool scan) { size_t i; int j; FILE* fd; BOOL r = FALSE; iso9660_t* p_iso = NULL; udf_t* p_udf = NULL; udf_dirent_t* p_udf_root; LONG progress_style; char* tmp; char path[64]; const char* scan_text = "Scanning ISO image..."; const char* basedir[] = { "i386", "minint" }; const char* tmp_sif = ".\\txtsetup.sif~"; if ((src_iso == NULL) || (dest_dir == NULL)) return FALSE; scan_only = scan; cdio_log_set_handler(log_handler); psz_extract_dir = dest_dir; progress_style = GetWindowLong(hISOProgressBar, GWL_STYLE); if (scan_only) { total_blocks = 0; memset(&iso_report, 0, sizeof(iso_report)); // String array of all isolinux/syslinux locations StrArrayCreate(&config_path, 8); // Change the Window title and static text SetWindowTextU(hISOProgressDlg, scan_text); SetWindowTextU(hISOFileName, scan_text); // Change progress style to marquee for scanning SetWindowLong(hISOProgressBar, GWL_STYLE, progress_style | PBS_MARQUEE); SendMessage(hISOProgressBar, PBM_SETMARQUEE, TRUE, 0); } else { uprintf("Extracting files...\n"); if (total_blocks == 0) { uprintf("Error: ISO has not been properly scanned.\n"); FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_ISO_SCAN); goto out; } nb_blocks = 0; iso_blocking_status = 0; SetWindowLong(hISOProgressBar, GWL_STYLE, progress_style & (~PBS_MARQUEE)); SendMessage(hISOProgressBar, PBM_SETPOS, 0, 0); } ShowWindow(hISOProgressDlg, SW_SHOW); UpdateWindow(hISOProgressDlg); /* First try to open as UDF - fallback to ISO if it failed */ p_udf = udf_open(src_iso); if (p_udf == NULL) goto try_iso; uprintf("Disc image is an UDF image\n"); p_udf_root = udf_get_root(p_udf, true, 0); if (p_udf_root == NULL) { uprintf("Couldn't locate UDF root directory\n"); goto out; } if (scan_only) { if (udf_get_logical_volume_id(p_udf, iso_report.label, sizeof(iso_report.label)) <= 0) iso_report.label[0] = 0; } r = udf_extract_files(p_udf, p_udf_root, ""); goto out; try_iso: p_iso = iso9660_open_ext(src_iso, ISO_EXTENSION_ALL); if (p_iso == NULL) { uprintf("Unable to open image '%s'.\n", src_iso); goto out; } i_joliet_level = iso9660_ifs_get_joliet_level(p_iso); uprintf("Disc image is an ISO9660 image\n"); if (scan_only) { if (iso9660_ifs_get_volume_id(p_iso, &tmp)) { safe_strcpy(iso_report.label, sizeof(iso_report.label), tmp); safe_free(tmp); } else iso_report.label[0] = 0; } r = iso_extract_files(p_iso, ""); out: iso_blocking_status = -1; if (scan_only) { // Remove trailing spaces from the label for (j=safe_strlen(iso_report.label)-1; ((j>=0)&&(isspace(iso_report.label[j]))); j--) iso_report.label[j] = 0; // We use the fact that UDF_BLOCKSIZE and ISO_BLOCKSIZE are the same here iso_report.projected_size = total_blocks * ISO_BLOCKSIZE; // We will link the existing isolinux.cfg from a syslinux.cfg we create // If multiple config file exist, choose the one with the shortest path if (iso_report.has_isolinux) { safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.Table[0]); for (i=1; i<config_path.Index; i++) { if (safe_strlen(iso_report.cfg_path) > safe_strlen(config_path.Table[i])) safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.Table[i]); } uprintf("Will use %s for Syslinux\n", iso_report.cfg_path); } if (IS_WINPE(iso_report.winpe)) { // In case we have a WinPE 1.x based iso, we extract and parse txtsetup.sif // during scan, to see if /minint was provided for OsLoadOptions, as it decides // whether we should use 0x80 or 0x81 as the disk ID in the MBR safe_sprintf(path, sizeof(path), "/%s/txtsetup.sif", basedir[((iso_report.winpe&WINPE_I386) == WINPE_I386)?0:1]); ExtractISOFile(src_iso, path, tmp_sif); tmp = get_token_data(tmp_sif, "OsLoadOptions"); if (tmp != NULL) { for (i=0; i<strlen(tmp); i++) tmp[i] = (char)tolower(tmp[i]); uprintf("Checking txtsetup.sif:\n OsLoadOptions = %s\n", tmp); iso_report.uses_minint = (strstr(tmp, "/minint") != NULL); } _unlink(tmp_sif); safe_free(tmp); } StrArrayDestroy(&config_path); } else if (iso_report.has_isolinux) { safe_sprintf(path, sizeof(path), "%s\\syslinux.cfg", dest_dir); // Create a /syslinux.cfg (if none exists) that points to the existing isolinux cfg fd = fopen(path, "r"); if (fd == NULL) { fd = fopen(path, "w"); // No "/syslinux.cfg" => create a new one if (fd == NULL) { uprintf("Unable to create %s - booting from USB will not work\n", path); r = 1; } else { fprintf(fd, "DEFAULT loadconfig\n\nLABEL loadconfig\n CONFIG %s\n", iso_report.cfg_path); for (i=safe_strlen(iso_report.cfg_path); (i>0)&&(iso_report.cfg_path[i]!='/'); i--); if (i>0) { iso_report.cfg_path[i] = 0; fprintf(fd, " APPEND %s/\n", iso_report.cfg_path); iso_report.cfg_path[i] = '/'; } uprintf("Created: %s\n", path); } } if (fd != NULL) fclose(fd); } ShowWindow(hISOProgressDlg, SW_HIDE); if (p_iso != NULL) iso9660_close(p_iso); if (p_udf != NULL) udf_close(p_udf); if ((r != 0) && (FormatStatus == 0)) FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR((scan_only?ERROR_ISO_SCAN:ERROR_ISO_EXTRACT)); return (r == 0); }