static int parse_line_instruction(t_parser *parser, char **my_tab) { if (is_defined(my_tab[0]) == 1) { if (compressor(&my_tab) == 1) { my_putstr_err("Can’t perform malloc", 2); return (1); } if (is_number_valid(my_tab, my_tab[0]) == 1) parser->current_address += get_incsize(my_tab); else return (syntax_error_and_return(parser->line_nb)); if (valid_args(my_tab) == 0) return (syntax_error_and_return(parser->line_nb)); } else return (syntax_error_and_return(parser->line_nb)); return (0); }
/* * To start a new USB/IP attachment, a userland program needs to setup a TCP * connection and then write its socket descriptor with remote device * information into this sysfs file. * * A remote device is virtually attached to the root-hub port of @rhport with * @speed. @devid is embedded into a request to specify the remote device in a * server host. * * write() returns 0 on success, else negative errno. */ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct socket *socket; int sockfd = 0; __u32 port = 0, pdev_nr = 0, rhport = 0, devid = 0, speed = 0; struct usb_hcd *hcd; struct vhci_hcd *vhci_hcd; struct vhci_device *vdev; struct vhci *vhci; int err; unsigned long flags; /* * @rhport: port number of vhci_hcd * @sockfd: socket descriptor of an established TCP connection * @devid: unique device identifier in a remote host * @speed: usb device speed in a remote host */ if (sscanf(buf, "%u %u %u %u", &port, &sockfd, &devid, &speed) != 4) return -EINVAL; pdev_nr = port_to_pdev_nr(port); rhport = port_to_rhport(port); usbip_dbg_vhci_sysfs("port(%u) pdev(%d) rhport(%u)\n", port, pdev_nr, rhport); usbip_dbg_vhci_sysfs("sockfd(%u) devid(%u) speed(%u)\n", sockfd, devid, speed); /* check received parameters */ if (!valid_args(pdev_nr, rhport, speed)) return -EINVAL; hcd = platform_get_drvdata(vhcis[pdev_nr].pdev); if (hcd == NULL) { dev_err(dev, "port %d is not ready\n", port); return -EAGAIN; } vhci_hcd = hcd_to_vhci_hcd(hcd); vhci = vhci_hcd->vhci; if (speed == USB_SPEED_SUPER) vdev = &vhci->vhci_hcd_ss->vdev[rhport]; else vdev = &vhci->vhci_hcd_hs->vdev[rhport]; /* Extract socket from fd. */ socket = sockfd_lookup(sockfd, &err); if (!socket) return -EINVAL; /* now need lock until setting vdev status as used */ /* begin a lock */ spin_lock_irqsave(&vhci->lock, flags); spin_lock(&vdev->ud.lock); if (vdev->ud.status != VDEV_ST_NULL) { /* end of the lock */ spin_unlock(&vdev->ud.lock); spin_unlock_irqrestore(&vhci->lock, flags); sockfd_put(socket); dev_err(dev, "port %d already used\n", rhport); return -EINVAL; } dev_info(dev, "pdev(%u) rhport(%u) sockfd(%d)\n", pdev_nr, rhport, sockfd); dev_info(dev, "devid(%u) speed(%u) speed_str(%s)\n", devid, speed, usb_speed_string(speed)); vdev->devid = devid; vdev->speed = speed; vdev->ud.tcp_socket = socket; vdev->ud.status = VDEV_ST_NOTASSIGNED; spin_unlock(&vdev->ud.lock); spin_unlock_irqrestore(&vhci->lock, flags); /* end the lock */ vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx"); vdev->ud.tcp_tx = kthread_get_run(vhci_tx_loop, &vdev->ud, "vhci_tx"); rh_port_connect(vdev, speed); return count; }
int main(int argc, char **argv) { GDALAllRegister(); try { boost::timer::cpu_timer timer; input_arguments parsed_args; std::string bands_str; boost::program_options::options_description options_all("MODIS to SciDB's Multidimensional Array Conversion Options"); options_all.add_options() ("version", "Prints MODIS to SciDB conversion tool version.\n") ("help", "Prints help message.\n") ("verbose", "Turns on verbose mode: prints timing and some more information about the conversion progress.\n") ("f", boost::program_options::value<std::string>(&parsed_args.source_file_name), "The source HDF file to convert to SciDB's load format.\n") ("o", boost::program_options::value<std::string>(&parsed_args.target_file_name), "The target folder to store SciDB data file.\n") ("t", boost::program_options::value<int16_t>(&parsed_args.time_point)->default_value(-1), "The timeline position for the dataset.\n") ("b", boost::program_options::value<std::string>(&bands_str), "A list of comma separated spectral bands to extract data, starting from 0: \"3,4\".\n") ("co", boost::program_options::value<int32_t>(&parsed_args.column_offset)->default_value(0), "Column offset.\n") ("ro", boost::program_options::value<int32_t>(&parsed_args.row_offset)->default_value(0), "Row offset.\n") ; boost::program_options::variables_map options; boost::program_options::store(boost::program_options::parse_command_line(argc, argv, options_all), options); boost::program_options::notify(options); if(options.count("help")) { std::cout << options_all << std::endl; return EXIT_SUCCESS; } if(options.count("version")) { std::cout << "\n\nmodis2scidb version: " SCIETL_VERSION_STRING "\n" << std::endl; return EXIT_SUCCESS; } parsed_args.verbose = options.count("verbose") ? true : false; parsed_args.bands = modis2scidb::parse_bands(bands_str); valid_args(parsed_args); if(parsed_args.verbose) std::cout << "\nmodis2scidb started\n" << std::endl; convert(parsed_args); if(parsed_args.verbose) std::cout << "\n\nmodis2scidb finished successfully!\n" << std::endl; } catch(const modis2scidb::exception& e) { std::cerr << "\n\nmodis2scidb finished with errors!\n"; if(const std::string* d = boost::get_error_info<modis2scidb::error_description>(e)) std::cerr << "\nThe following error has occurried: " << *d << "\n"; std::cerr << "\nPlease, use 'modis2scidb --help' for help with input parameters. " "If you find it is a bug, please, report it to [email protected].\n" << std::endl; return EXIT_FAILURE; } catch(const std::exception& e) { std::cerr << "\n\nmodis2scidb finished with errors!\n"; if(e.what() != 0) std::cerr << "\nAn unexpected error has occurried: " << e.what() << "\n"; std::cerr << "\nPlease, report it to [email protected].\n" << std::endl; return EXIT_FAILURE; } catch(...) { std::cerr << "\n\nAn unexpected error has occurried with no additional information.\n" << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; }
/* * To start a new USB/IP attachment, a userland program needs to setup a TCP * connection and then write its socket descriptor with remote device * information into this sysfs file. * * A remote device is virtually attached to the root-hub port of @rhport with * @speed. @devid is embedded into a request to specify the remote device in a * server host. * * write() returns 0 on success, else negative errno. */ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct vhci_device *vdev; struct socket *socket; int sockfd = 0; __u32 rhport = 0, devid = 0, speed = 0; /* * @rhport: port number of vhci_hcd * @sockfd: socket descriptor of an established TCP connection * @devid: unique device identifier in a remote host * @speed: usb device speed in a remote host */ sscanf(buf, "%u %u %u %u", &rhport, &sockfd, &devid, &speed); usbip_dbg_vhci_sysfs("rhport(%u) sockfd(%u) devid(%u) speed(%u)\n", rhport, sockfd, devid, speed); /* check received parameters */ if (valid_args(rhport, speed) < 0) return -EINVAL; /* check sockfd */ socket = sockfd_to_socket(sockfd); if (!socket) return -EINVAL; /* now need lock until setting vdev status as used */ /* begin a lock */ spin_lock(&the_controller->lock); vdev = port_to_vdev(rhport); spin_lock(&vdev->ud.lock); if (vdev->ud.status != VDEV_ST_NULL) { /* end of the lock */ spin_unlock(&vdev->ud.lock); spin_unlock(&the_controller->lock); usbip_uerr("port %d already used\n", rhport); return -EINVAL; } usbip_uinfo("rhport(%u) sockfd(%d) devid(%u) speed(%u)\n", rhport, sockfd, devid, speed); vdev->devid = devid; vdev->speed = speed; vdev->ud.tcp_socket = socket; vdev->ud.status = VDEV_ST_NOTASSIGNED; wake_up_process(vdev->ud.tcp_rx); wake_up_process(vdev->ud.tcp_tx); spin_unlock(&vdev->ud.lock); spin_unlock(&the_controller->lock); /* end the lock */ rh_port_connect(rhport, speed); return count; }
/* * To start a new USB/IP attachment, a userland program needs to setup a TCP * connection and then write its socket descriptor with remote device * information into this sysfs file. * * A remote device is virtually attached to the root-hub port of @rhport with * @speed. @busnum and @devnum are used to convert URBs between a client host * and a server host. * * write() returns 0 on success, else negative errno. */ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct vhci_device *vdev; struct socket *socket; int sockfd = 0; __u32 rhport=0, busnum=0, devnum=0, speed=0; /* * @rhport: port number of vhci_hcd * @sockfd: socket descriptor of an established TCP connection * @busnum: usb bus number in a remote host * @devnum: usb device number in a remote host * @speed: usb device speed in a remote host */ sscanf(buf, "%u %u %u %u %u", &rhport, &sockfd, &busnum, &devnum, &speed); dbg_vhci_sysfs("rhport(%u) sockfd(%u) busnum(%u) devnum(%u) speed(%u)\n", rhport, sockfd, busnum, devnum, speed); /* check received parameters */ if (valid_args(rhport, busnum, devnum, speed) < 0) return -EINVAL; /* check sockfd */ socket = sockfd_to_socket(sockfd); if (!socket) return -EINVAL; #if 0 setnodelay(socket); #endif /* now need lock until setting vdev status as used */ /* begin a lock */ spin_lock(&the_controller->lock); vdev = port_to_vdev(rhport); spin_lock(&vdev->ud.lock); if (vdev->ud.status != VDEV_ST_NULL) { /* end of the lock */ spin_unlock(&vdev->ud.lock); spin_unlock(&the_controller->lock); uerr("port %d already used\n", rhport); return -EINVAL; } uinfo("rhport(%u) sockfd(%d) busnum(%u) devnum(%u) speed(%u)\n", rhport, sockfd, busnum, devnum, speed); vdev->busnum = busnum; vdev->devnum = devnum; vdev->speed = speed; vdev->ud.tcp_socket = socket; vdev->ud.status = VDEV_ST_NOTASSIGNED; spin_unlock(&vdev->ud.lock); spin_unlock(&the_controller->lock); /* end the lock */ /* * this function will sleep, so should be out of the lock. but, it's ok * because we already marked vdev as being used. really? */ usbip_start_threads(&vdev->ud); rh_port_connect(rhport, speed); return count; }
/* * To start a new USB/IP attachment, a userland program needs to setup a TCP * connection and then write its socket descriptor with remote device * information into this sysfs file. * * A remote device is virtually attached to the root-hub port of @rhport with * @speed. @devid is embedded into a request to specify the remote device in a * server host. * * write() returns 0 on success, else negative errno. */ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct vhci_device *vdev; struct socket *socket; int sockfd = 0; __u32 rhport = 0, devid = 0, speed = 0; int err; /* * @rhport: port number of vhci_hcd * @sockfd: socket descriptor of an established TCP connection * @devid: unique device identifier in a remote host * @speed: usb device speed in a remote host */ if (sscanf(buf, "%u %u %u %u", &rhport, &sockfd, &devid, &speed) != 4) return -EINVAL; usbip_dbg_vhci_sysfs("rhport(%u) sockfd(%u) devid(%u) speed(%u)\n", rhport, sockfd, devid, speed); /* check received parameters */ if (valid_args(rhport, speed) < 0) return -EINVAL; /* Extract socket from fd. */ socket = sockfd_lookup(sockfd, &err); if (!socket) return -EINVAL; /* now need lock until setting vdev status as used */ /* begin a lock */ spin_lock(&the_controller->lock); vdev = port_to_vdev(rhport); spin_lock(&vdev->ud.lock); if (vdev->ud.status != VDEV_ST_NULL) { /* end of the lock */ spin_unlock(&vdev->ud.lock); spin_unlock(&the_controller->lock); sockfd_put(socket); dev_err(dev, "port %d already used\n", rhport); return -EINVAL; } dev_info(dev, "rhport(%u) sockfd(%d) devid(%u) speed(%u) speed_str(%s)\n", rhport, sockfd, devid, speed, usb_speed_string(speed)); vdev->devid = devid; vdev->speed = speed; vdev->ud.tcp_socket = socket; vdev->ud.status = VDEV_ST_NOTASSIGNED; spin_unlock(&vdev->ud.lock); spin_unlock(&the_controller->lock); /* end the lock */ vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx"); vdev->ud.tcp_tx = kthread_get_run(vhci_tx_loop, &vdev->ud, "vhci_tx"); rh_port_connect(rhport, speed); return count; }
int main(int argc, char **argv) { GDALAllRegister(); try { boost::timer::cpu_timer timer; input_arguments parsed_args; boost::program_options::options_description options_all("Fire Points to SciDB's Multidimensional Array Conversion Options"); options_all.add_options() ("version", "Print Fire Points to SciDB conversion tool version.\n") ("help", "Prints help message.\n") ("verbose", "Turns on verbose mode: prints timing and some more information about the conversion progress.\n") ("f", boost::program_options::value<std::string>(&parsed_args.source_file_name), "The source TIFF file to convert to SciDB's load format.\n") ("o", boost::program_options::value<std::string>(&parsed_args.target_file_name), "The target folder to store SciDB data file.\n") ("t", boost::program_options::value<int16_t>(&parsed_args.time_point), "The timeline position for the dataset.\n") ; boost::program_options::variables_map options; boost::program_options::store(boost::program_options::parse_command_line(argc, argv, options_all), options); boost::program_options::notify(options); if(options.count("help")) { std::cout << options_all << std::endl; return EXIT_SUCCESS; } if(options.count("version")) { std::cout << "\n\nfocos2scidb version: " SCIETL_VERSION_STRING "\n" << std::endl; return EXIT_SUCCESS; } parsed_args.verbose = options.count("verbose") ? true : false; valid_args(parsed_args); if(parsed_args.verbose) std::cout << "\nfocos2scidb started\n" << std::endl; convert(parsed_args); if(parsed_args.verbose) std::cout << "\n\nfocos2scidb finished successfully!\n" << std::endl; } catch(const std::exception& e) { std::cerr << "\n\nfocos2scidb finished with errors!\n"; if(e.what() != 0) std::cerr << "\nAn unexpected error has occurried: " << e.what() << "\n"; std::cerr << "\nPlease, report it to [email protected].\n" << std::endl; return EXIT_FAILURE; } catch(...) { std::cerr << "\n\nAn unexpected error has occurried with no additional information.\n" << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; }