mirror of
https://github.com/eddyem/eddys_snippets.git
synced 2025-12-06 02:35:12 +03:00
Fixed a lot of bugs in HSFV_management
This commit is contained in:
parent
220655233e
commit
bf4ea0c493
@ -1,3 +1,60 @@
|
|||||||
Edmund Optics high-speed filter wheel management
|
Edmund Optics high-speed filter wheel management
|
||||||
================================================
|
================================================
|
||||||
|
|
||||||
|
This command-line utility allows you to manage with HSFW turrets: check and change their positions,
|
||||||
|
list connected devices and their property, rename wheels' and filters' names stored in EEPROM of
|
||||||
|
given turret.
|
||||||
|
|
||||||
|
## Command line options:
|
||||||
|
|
||||||
|
|
||||||
|
-H, --home move to home position
|
||||||
|
-N, --wheel-name=arg wheel name
|
||||||
|
-W, --wheel-id=arg letter wheel identificator
|
||||||
|
-h, --help show this help
|
||||||
|
-i, --filter-id=arg filter identificator like "A3"
|
||||||
|
-n, --filter-name=arg filter name
|
||||||
|
-p, --f-position=arg filter position number
|
||||||
|
-s, --serial=arg turret serial (with leading zeros)
|
||||||
|
--list list only present devices' names
|
||||||
|
--list-all list all stored names
|
||||||
|
--rename rename stored wheels/filters names
|
||||||
|
--resetnames reset all names to default values
|
||||||
|
|
||||||
|
## Usage examples
|
||||||
|
|
||||||
|
#### List all devices connected
|
||||||
|
Свойства подключенного колеса
|
||||||
|
Wheel ID 'A', name 'UBVRI', serial '00000563', 5 filters:
|
||||||
|
1: 'U'
|
||||||
|
2: 'B'
|
||||||
|
3: 'V'
|
||||||
|
4: 'R'
|
||||||
|
5: 'I'
|
||||||
|
current position: 1
|
||||||
|
|
||||||
|
Свойства подключенного колеса
|
||||||
|
Wheel ID 'B', name 'Sloan', serial '00000532', 5 filters:
|
||||||
|
1: '1'
|
||||||
|
2: '2'
|
||||||
|
3: '3'
|
||||||
|
4: '4'
|
||||||
|
5: '5'
|
||||||
|
current position: 1
|
||||||
|
|
||||||
|
#### Move wheel by turret's serial and position number
|
||||||
|
HSFW_manage -s 00000563 -p 3
|
||||||
|
|
||||||
|
Will move first turret (wheel 'A' named 'UBVRI') into third position (filter 'V').
|
||||||
|
|
||||||
|
#### Move wheel by filter name
|
||||||
|
HSFW_manage -nV
|
||||||
|
|
||||||
|
Is equivalent of previous.
|
||||||
|
|
||||||
|
#### Rename wheel 'B' of first turret
|
||||||
|
HSFW_manage --rename -s00000563 -WB -N "New name"
|
||||||
|
|
||||||
|
Assigns "New name" to wheel 'B' of first turret in spite of its absence in current moment.
|
||||||
|
You can control all changes by `HSFV_manage --list` (show only wheels presents) or
|
||||||
|
`HSFV_manage --list-all` (show all EEPROM information).
|
||||||
|
|||||||
@ -32,68 +32,68 @@
|
|||||||
* access by wheel ID could lead undefined behaviour!
|
* access by wheel ID could lead undefined behaviour!
|
||||||
*/
|
*/
|
||||||
int find_wheels(wheel_descr **wheels){
|
int find_wheels(wheel_descr **wheels){
|
||||||
struct udev *udev;
|
struct udev *udev;
|
||||||
struct udev_enumerate *enumerate;
|
struct udev_enumerate *enumerate;
|
||||||
struct udev_list_entry *devices, *dev_list_entry;
|
struct udev_list_entry *devices, *dev_list_entry;
|
||||||
wheel_descr *founded = NULL;
|
wheel_descr *Found = NULL;
|
||||||
// Create the udev object
|
// Create the udev object
|
||||||
udev = udev_new();
|
udev = udev_new();
|
||||||
int N = 0;
|
int N = 0;
|
||||||
if(!udev){
|
if(!udev){
|
||||||
ERR("Can't create udev");
|
ERR("Can't create udev");
|
||||||
}
|
}
|
||||||
// Create a list of the devices in the 'hidraw' subsystem.
|
// Create a list of the devices in the 'hidraw' subsystem.
|
||||||
enumerate = udev_enumerate_new(udev);
|
enumerate = udev_enumerate_new(udev);
|
||||||
udev_enumerate_add_match_subsystem(enumerate, "hidraw");
|
udev_enumerate_add_match_subsystem(enumerate, "hidraw");
|
||||||
udev_enumerate_scan_devices(enumerate);
|
udev_enumerate_scan_devices(enumerate);
|
||||||
devices = udev_enumerate_get_list_entry(enumerate);
|
devices = udev_enumerate_get_list_entry(enumerate);
|
||||||
// Check out each device found
|
// Check out each device found
|
||||||
udev_list_entry_foreach(dev_list_entry, devices){
|
udev_list_entry_foreach(dev_list_entry, devices){
|
||||||
const char *path;
|
const char *path;
|
||||||
struct udev_device *dev;
|
struct udev_device *dev;
|
||||||
path = udev_list_entry_get_name(dev_list_entry);
|
path = udev_list_entry_get_name(dev_list_entry);
|
||||||
dev = udev_device_new_from_syspath(udev, path);
|
dev = udev_device_new_from_syspath(udev, path);
|
||||||
const char *devpath = udev_device_get_devnode(dev);
|
const char *devpath = udev_device_get_devnode(dev);
|
||||||
DBG("Device Node Path: %s", devpath);
|
DBG("Device Node Path: %s", devpath);
|
||||||
dev = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_device");
|
dev = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_device");
|
||||||
if(!dev){
|
if(!dev){
|
||||||
WARNX("Unable to find parent usb device for %s", devpath);
|
WARNX("Unable to find parent usb device for %s", devpath);
|
||||||
udev_device_unref(dev);
|
udev_device_unref(dev);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const char *vid, *pid;
|
const char *vid, *pid;
|
||||||
vid = udev_device_get_sysattr_value(dev,"idVendor");
|
vid = udev_device_get_sysattr_value(dev,"idVendor");
|
||||||
pid = udev_device_get_sysattr_value(dev, "idProduct");
|
pid = udev_device_get_sysattr_value(dev, "idProduct");
|
||||||
DBG(" VID/PID: %s/%s", vid, pid);
|
DBG(" VID/PID: %s/%s", vid, pid);
|
||||||
if(strcmp(vid, W_VID) == 0 && strcmp(pid, W_PID) == 0){
|
if(strcmp(vid, W_VID) == 0 && strcmp(pid, W_PID) == 0){
|
||||||
++N;
|
++N;
|
||||||
if(!founded){
|
if(!Found){
|
||||||
founded = MALLOC(wheel_descr, 1);
|
Found = MALLOC(wheel_descr, 1);
|
||||||
}else{
|
}else{
|
||||||
founded = realloc(founded, sizeof(wheel_descr)*N);
|
Found = realloc(Found, sizeof(wheel_descr)*N);
|
||||||
if(!founded) ERR("realloc");
|
if(!Found) ERR("realloc");
|
||||||
}
|
}
|
||||||
wheel_descr *curdev = &founded[N-1];
|
wheel_descr *curdev = &Found[N-1];
|
||||||
int fd = open(devpath, O_RDWR|O_NONBLOCK);
|
int fd = open(devpath, O_RDWR|O_NONBLOCK);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
/// "îÅ ÍÏÇÕ ÏÔËÒÙÔØ %s"
|
/// "îÅ ÍÏÇÕ ÏÔËÒÙÔØ %s"
|
||||||
WARN(_("Can't open %s"), devpath);
|
WARN(_("Can't open %s"), devpath);
|
||||||
curdev->fd = -1;
|
curdev->fd = -1;
|
||||||
}else
|
}else
|
||||||
curdev->fd = fd;
|
curdev->fd = fd;
|
||||||
DBG("%s %s",
|
DBG("%s %s",
|
||||||
udev_device_get_sysattr_value(dev,"manufacturer"),
|
udev_device_get_sysattr_value(dev,"manufacturer"),
|
||||||
udev_device_get_sysattr_value(dev,"product"));
|
udev_device_get_sysattr_value(dev,"product"));
|
||||||
curdev->serial = strdup(udev_device_get_sysattr_value(dev, "serial"));
|
curdev->serial = strdup(udev_device_get_sysattr_value(dev, "serial"));
|
||||||
DBG("serial: %s\n", curdev->serial);
|
DBG("serial: %s\n", curdev->serial);
|
||||||
}
|
}
|
||||||
udev_device_unref(dev);
|
udev_device_unref(dev);
|
||||||
}
|
}
|
||||||
// Free the enumerator object
|
// Free the enumerator object
|
||||||
udev_enumerate_unref(enumerate);
|
udev_enumerate_unref(enumerate);
|
||||||
if(wheels){
|
if(wheels){
|
||||||
*wheels = founded;
|
*wheels = Found;
|
||||||
}else
|
}else
|
||||||
free(founded);
|
free(Found);
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,11 +26,11 @@
|
|||||||
#define W_PID "82cd"
|
#define W_PID "82cd"
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
int fd;
|
int fd;
|
||||||
char *serial;
|
char *serial;
|
||||||
char ID;
|
char ID;
|
||||||
char name[9];
|
char name[9];
|
||||||
int maxpos;
|
int maxpos;
|
||||||
} wheel_descr;
|
} wheel_descr;
|
||||||
|
|
||||||
int find_wheels(wheel_descr **wheels);
|
int find_wheels(wheel_descr **wheels);
|
||||||
|
|||||||
@ -30,10 +30,10 @@
|
|||||||
|
|
||||||
// wheel Id & filter position given (if given by name - check names stored)
|
// wheel Id & filter position given (if given by name - check names stored)
|
||||||
static int wheel_id = -1 // wheel ID given or found by name
|
static int wheel_id = -1 // wheel ID given or found by name
|
||||||
,filter_pos = -1 // filter position given or found by name
|
,filter_pos = -1 // filter position given or found by name
|
||||||
,max_pos = -1 // max filter position allowed
|
,max_pos = -1 // max filter position allowed
|
||||||
,wheel_fd = -1 // file descriptor of active wheel
|
,wheel_fd = -1 // file descriptor of active wheel
|
||||||
,HW_found = 0 // amount of wheels found
|
,HW_found = 0 // amount of wheels found
|
||||||
;
|
;
|
||||||
|
|
||||||
static wheel_descr *wheel_chosen = NULL; // pointer to chosen wheel
|
static wheel_descr *wheel_chosen = NULL; // pointer to chosen wheel
|
||||||
@ -56,121 +56,133 @@ int poll_regstatus(int fd, int msg);
|
|||||||
* set variables pointing current wheel to wheels[idx]
|
* set variables pointing current wheel to wheels[idx]
|
||||||
*/
|
*/
|
||||||
void set_cur_wheel(int idx){
|
void set_cur_wheel(int idx){
|
||||||
wheel_chosen = &wheels[idx];
|
wheel_chosen = &wheels[idx];
|
||||||
wheel_id = wheel_chosen->ID;
|
wheel_id = wheel_chosen->ID;
|
||||||
wheel_fd = wheel_chosen->fd;
|
wheel_fd = wheel_chosen->fd;
|
||||||
max_pos = wheel_chosen->maxpos;
|
max_pos = wheel_chosen->maxpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check command line arguments, find filters/wheels by name, find max positions & so on
|
* Check command line arguments, find filters/wheels by name, find max positions & so on
|
||||||
*/
|
*/
|
||||||
void check_args(){
|
void check_args(){
|
||||||
// here we fill value of wheel_id if no given and present only one turret
|
// here we fill value of wheel_id if no given and present only one turret
|
||||||
list_hw(listNms); // also exit if no HW found
|
list_hw(listNms); // also exit if no HW found
|
||||||
if(listNms) return;
|
if(listNms) return;
|
||||||
int i;
|
int i;
|
||||||
if(G.wheelID || G.filterId){
|
// add wheel ID to global parameters if there was nothing
|
||||||
char wID = (G.wheelID) ? *G.wheelID : *G.filterId;
|
if(G.serial){ // HW given by its serial
|
||||||
if((wID < 'A' || wID > POS_B_END) || (G.wheelID && strlen(G.wheelID) != 1)){
|
DBG("User give serial: %s", G.serial);
|
||||||
/// "éÄÅÎÔÉÆÉËÁÔÏÒ ËÏÌÅÓÁ ÄÏÌÖÅÎ ÂÙÔØ ÂÕË×ÏÊ ÏÔ \"A\" ÄÏ \"H\"!"
|
for(i = 0; i < HW_found; ++i){
|
||||||
ERRX(_("Wheel ID should be a letter from \"A\" to \"H\"!"));
|
if(strcmp(wheels[i].serial, G.serial) == 0){
|
||||||
}
|
/// "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÊ ÔÕÒÅÌÉ Ó ÓÅÒÉÊÎÙÍ ÎÏÍÅÒÏÍ '%s'!"
|
||||||
wheel_id = wID;
|
if(wheel_fd > 0) ERRX(_("More than one turret with serial '%s' found!"), G.serial);
|
||||||
DBG("wheel given by id: %c", wheel_id);
|
set_cur_wheel(i);
|
||||||
for(i = 0; i < HW_found; ++i){
|
DBG("Find given serial @ wheel %d", i);
|
||||||
if(wheels[i].ID == wheel_id){
|
}
|
||||||
/// "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÄÅÎÔÉÆÉËÁÔÏÒÏÍ '%c'!"
|
}
|
||||||
if(wheel_fd > 0) ERRX(_("More than one wheel with ID '%c' found!"), wheel_id);
|
if(wheel_fd < 0){
|
||||||
set_cur_wheel(i);
|
/// "ôÕÒÅÌØ Ó ÓÅÒÉÊÎÙÍ ÎÏÍÅÒÏÍ '%s' ÎÅ ÎÁÊÄÅÎÁ"
|
||||||
}
|
ERRX(_("Turret with serial '%s' not found"), G.serial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char oldid = wheel_id;
|
if(G.wheelID || G.filterId){ // HW by wheel or filter ID or ID 2 rename
|
||||||
if(G.wheelName && (!reName || (G.filterPos || G.filterName))){ // find wheel by name given
|
char wID = (G.wheelID) ? *G.wheelID : *G.filterId;
|
||||||
if(G.wheelID && !reName){
|
DBG("wID=%c", wID);
|
||||||
/// "úÁÄÁÎÙ É ÉÄÅÎÔÉÆÉËÁÔÏÒ, É ÉÍÑ ËÏÌÅÓÁ; ÐÏÐÒÏÂÕÊÔÅ ÞÔÏ-ÔÏ ÏÄÎÏ!"
|
if((wID < 'A' || wID > POS_B_END) || (G.wheelID && strlen(G.wheelID) != 1)){
|
||||||
ERRX(_("You give both wheel ID and wheel name, try something one!"));
|
/// "éÄÅÎÔÉÆÉËÁÔÏÒ ËÏÌÅÓÁ ÄÏÌÖÅÎ ÂÙÔØ ÂÕË×ÏÊ ÏÔ \"A\" ÄÏ \"H\"!"
|
||||||
}
|
ERRX(_("Wheel ID should be a letter from \"A\" to \"H\"!"));
|
||||||
for(i = 0; i < HW_found; ++i){
|
}else if(G.filterId && strlen(G.filterId) != 2){
|
||||||
if(strcmp(wheels[i].name, G.wheelName) == 0){
|
/// "éÄÅÎÔÉÆÉËÁÔÏÒ ÆÉÌØÔÒÁ ÄÏÌÖÅÎ ÓÏÓÔÏÑÔØ ÉÚ Ä×ÕÈ ÓÉÍ×ÏÌÏ×: ÉÄÅÎÔÉÆÉËÁÔÏÒÁ ËÏÌÅÓÁ É ÎÏÍÅÒÁ ÐÏÚÉÃÉÉ"
|
||||||
set_cur_wheel(i);
|
ERRX(_("Filter ID should have two symbols: wheel ID and filter position"));
|
||||||
break;
|
}
|
||||||
}
|
wheel_id = wID;
|
||||||
}
|
DBG("wheel given by id: %c", wheel_id);
|
||||||
if(reName) wheel_id = oldid;
|
if(!reName){
|
||||||
}
|
for(i = 0; i < HW_found; ++i){
|
||||||
void setWid(){
|
if(wheels[i].ID == wheel_id){
|
||||||
if(oldid > 0) wheel_id = oldid;
|
/// "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÄÅÎÔÉÆÉËÁÔÏÒÏÍ '%c'!"
|
||||||
if(!G.wheelID){
|
if(wheel_fd > 0) ERRX(_("More than one wheel with ID '%c' found!"), wheel_id);
|
||||||
G.wheelID = calloc(2, 1);
|
set_cur_wheel(i);
|
||||||
*G.wheelID = wheel_id;
|
DBG("Find given ID @ wheel %d", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(G.serial){ // HW given by its serial
|
}
|
||||||
for(i = 0; i < HW_found; ++i){
|
if(wheel_fd < 0){
|
||||||
if(strcmp(wheels[i].serial, G.serial) == 0){
|
/// "ëÏÌÅÓÏ Ó ÉÄÅÎÔÉÆÉËÁÔÏÒÏÍ '%c' ÎÅ ÎÁÊÄÅÎÏ"
|
||||||
set_cur_wheel(i);
|
ERRX(_("Wheel with ID '%c' not found"), wheel_id);
|
||||||
if(reName) setWid();
|
}
|
||||||
break;
|
if(G.filterId) filter_pos = G.filterId[1] - '0';
|
||||||
}
|
} else if(G.wheelName){ // find wheel by name given
|
||||||
}
|
for(i = 0; i < HW_found; ++i){
|
||||||
if(i == HW_found) wheel_id = 0; // make an error message later
|
if(strcmp(wheels[i].name, G.wheelName) == 0){
|
||||||
}
|
/// "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÍÅÎÅÍ '%s'!"
|
||||||
// if there's only one turret, fill wheel_id
|
if(wheel_fd > 0) ERRX(_("More than one wheel with name '%s' found!"), G.wheelName);
|
||||||
if(HW_found == 1 && (wheel_id < 0 || (wheel_fd < 0 && reName))){
|
set_cur_wheel(i);
|
||||||
set_cur_wheel(0);
|
DBG("Find given name @ wheel %d", i);
|
||||||
if(reName) setWid();
|
}
|
||||||
}
|
}
|
||||||
if((wheel_fd < 0 || !wheel_chosen) && !G.filterName){
|
if(wheel_fd < 0 && !reName){
|
||||||
/// "úÁÄÁÎÎÏÅ ËÏÌÅÓÏ ÎÅ ÏÂÎÁÒÕÖÅÎÏ!"
|
/// "ëÏÌÅÓÏ Ó ÉÍÅÎÅÍ '%s' ÎÅ ÎÁÊÄÅÎÏ"
|
||||||
ERRX(_("Given wheel not found!"));
|
ERRX(_("Wheel with name '%s' not found"), G.wheelName);
|
||||||
}
|
}
|
||||||
if(showpos || setdef) return;
|
}
|
||||||
if(G.filterId){ // filter given by its id like "B3"
|
// if there's only one turret, choose it
|
||||||
char *fid = G.filterId;
|
if(HW_found == 1 && wheel_id < 0){
|
||||||
/// "éÄÅÎÔÉÆÉËÁÔÏÒ ÆÉÌØÔÒÁ ÓÏÓÔÏÉÔ ÉÚ ÂÕË×Ù (ËÏÌÅÓÏ) É ÃÉÆÒÙ (ÐÏÚÉÃÉÑ)"
|
set_cur_wheel(0);
|
||||||
if(strlen(G.filterId) != 2 || fid[1] > '9' || fid[1] < '0')
|
DBG("No specific options with only turret, choose it");
|
||||||
/// "éÄÅÎÔÉÆÉËÁÔÏÒ ÆÉÌØÔÒÁ - ÂÕË×Á (ËÏÌÅÓÏ) É ÞÉÓÌÏ (ÐÏÚÉÃÉÑ)"
|
}
|
||||||
ERRX(_("Filter ID is letter (wheel) and number (position)"));
|
if(G.filterPos){ // filter given by numerical position
|
||||||
filter_pos = fid[1] - '0';
|
filter_pos = G.filterPos;
|
||||||
}else if(G.filterPos){ // filter given by numerical position
|
}
|
||||||
filter_pos = G.filterPos;
|
DBG("filter_pos=%d", filter_pos);
|
||||||
}else if(G.filterName){ // filter given by name - search it
|
// Check if user ask to find filter with given name
|
||||||
int search_f(int N){
|
if(filter_pos < 1 && G.filterName && !reName){ // filter given by name - search it
|
||||||
int i, m = wheels[N].maxpos;
|
int search_f(wheel_descr *wheel){
|
||||||
for(i = 1; i <= m; ++i){
|
int i, m = wheel->maxpos;
|
||||||
DBG("Search filter %s in pos %d (%s)", G.filterName, i, get_filter_name(&wheels[N], i));
|
for(i = 1; i <= m; ++i){
|
||||||
if(strcmp(G.filterName, get_filter_name(&wheels[N], i)) == 0){
|
DBG("Search filter %s in pos %d (%s)", G.filterName, i, get_filter_name(wheel, i));
|
||||||
filter_pos = i;
|
DBG("len1: %zd, len2: %zd", strlen(G.filterName), strlen(get_filter_name(wheel, i)));
|
||||||
if(!wheel_chosen){
|
if(strcmp(G.filterName, get_filter_name(wheel, i)) == 0){
|
||||||
set_cur_wheel(N);
|
filter_pos = i;
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
if(i > m) return 1;
|
||||||
if(i > m) return 1;
|
return 0;
|
||||||
return 0;
|
}
|
||||||
}
|
int not_found = 1;
|
||||||
int not_found = 1;
|
if(wheel_chosen) not_found = search_f(wheel_chosen);
|
||||||
if(wheel_chosen) not_found = search_f(wheel_id);
|
else for(i = 0; i < HW_found; ++i){
|
||||||
else for(i = 0; i < HW_found && not_found; ++i){
|
if(!search_f(&wheels[i])){
|
||||||
not_found = search_f(i);
|
not_found = 0;
|
||||||
}
|
/// "ïÂÎÁÒÕÖÅÎÏ ÂÏÌØÛÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÍÅÎÅÍ ÆÉÌØÔÒÁ '%s'!"
|
||||||
if(not_found){
|
if(wheel_fd > 0) ERRX(_("More than one wheel with filter name '%s' found!"), G.filterName);
|
||||||
/// "æÉÌØÔÒ %s ÎÅ ÏÂÎÁÒÕÖÅÎ"
|
set_cur_wheel(i);
|
||||||
ERRX(_("Filter %s not found!"), G.filterName);
|
}
|
||||||
}
|
}
|
||||||
}else{
|
if(not_found){
|
||||||
if(!gohome) showpos = 1; // no action given - just show position
|
/// "æÉÌØÔÒ %s ÎÅ ÏÂÎÁÒÕÖÅÎ"
|
||||||
return;
|
ERRX(_("Filter %s not found!"), G.filterName);
|
||||||
}
|
}
|
||||||
if(reName) max_pos = get_max_pos(wheel_id);
|
}
|
||||||
if(filter_pos < 1 || filter_pos > max_pos){
|
if(wheel_fd < 0){
|
||||||
/// "ðÏÚÉÃÉÑ ÆÉÌØÔÒÁ ÄÏÌÖÎÁ ÂÙÔØ ÞÉÓÌÏÍ ÏÔ 1 ÄÏ %d!"
|
/// "úÁÄÁÎÎÏÅ ËÏÌÅÓÏ ÎÅ ÏÂÎÁÒÕÖÅÎÏ!"
|
||||||
ERRX(_("Filter position should be a number from 1 to %d!"), max_pos);
|
ERRX(_("Given wheel not found!"));
|
||||||
}
|
}
|
||||||
DBG("filter given by position: %d", filter_pos);
|
if(reName && !G.wheelID){
|
||||||
|
G.wheelID = calloc(2, 1);
|
||||||
|
*G.wheelID = wheel_id;
|
||||||
|
}
|
||||||
|
if(filter_pos < 1 && !gohome) showpos = 1; // no action given - just show position
|
||||||
|
if(showpos || setdef || gohome) return;
|
||||||
|
// now check if filter position right
|
||||||
|
if(reName) max_pos = get_max_pos(wheel_id);
|
||||||
|
if(filter_pos < 1 || filter_pos > max_pos){
|
||||||
|
/// "ðÏÚÉÃÉÑ ÆÉÌØÔÒÁ ÄÏÌÖÎÁ ÂÙÔØ ÞÉÓÌÏÍ ÏÔ 1 ÄÏ %d!"
|
||||||
|
ERRX(_("Filter position should be a number from 1 to %d!"), max_pos);
|
||||||
|
}
|
||||||
|
DBG("filter given by position: %d", filter_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,20 +190,20 @@ void check_args(){
|
|||||||
* return 0 if all OK
|
* return 0 if all OK
|
||||||
*/
|
*/
|
||||||
int writereg(int fd, uint8_t *buf, int l){
|
int writereg(int fd, uint8_t *buf, int l){
|
||||||
uint8_t reg = buf[0];
|
uint8_t reg = buf[0];
|
||||||
//#if 0//
|
#if 0
|
||||||
#ifdef EBUG
|
// #ifdef EBUG
|
||||||
int i;
|
int i;
|
||||||
printf("Write reg %d:", reg);
|
printf("Write reg %d:", reg);
|
||||||
for(i = 0; i < l; ++i) printf(" %02hhx", buf[i]);
|
for(i = 0; i < l; ++i) printf(" %02hhx", buf[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
if(ioctl(fd, HIDIOCSFEATURE(l), buf) < 0 || buf[0] != reg){
|
if(ioctl(fd, HIDIOCSFEATURE(l), buf) < 0 || buf[0] != reg){
|
||||||
/// "ïÛÉÂËÁ ÏÔÐÒÁ×ËÉ ÄÁÎÎÙÈ"
|
/// "ïÛÉÂËÁ ÏÔÐÒÁ×ËÉ ÄÁÎÎÙÈ"
|
||||||
WARNX(_("Error sending data"));
|
WARNX(_("Error sending data"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,57 +211,57 @@ int writereg(int fd, uint8_t *buf, int l){
|
|||||||
* return 0 if all OK
|
* return 0 if all OK
|
||||||
*/
|
*/
|
||||||
int readreg(int fd, uint8_t *buf, int reg, int l){
|
int readreg(int fd, uint8_t *buf, int reg, int l){
|
||||||
memset(buf, 0, l);
|
memset(buf, 0, l);
|
||||||
buf[0] = reg;
|
buf[0] = reg;
|
||||||
if(ioctl(fd, HIDIOCGFEATURE(l), buf) < 0 || buf[0] != reg){
|
if(ioctl(fd, HIDIOCGFEATURE(l), buf) < 0 || buf[0] != reg){
|
||||||
/// "ïÛÉÂËÁ ÞÔÅÎÉÑ ÄÁÎÎÙÈ"
|
/// "ïÛÉÂËÁ ÞÔÅÎÉÑ ÄÁÎÎÙÈ"
|
||||||
WARNX(_("Error reading data"));
|
WARNX(_("Error reading data"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//#if 0//
|
#if 0
|
||||||
#ifdef EBUG
|
//#ifdef EBUG
|
||||||
int i;
|
int i;
|
||||||
printf("Read reg %d:", reg);
|
printf("Read reg %d:", reg);
|
||||||
for(i = 0; i < l; ++i) printf(" %02hhx", buf[i]);
|
for(i = 0; i < l; ++i) printf(" %02hhx", buf[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check error state and clear it if need
|
* Check error state and clear it if need
|
||||||
*/
|
*/
|
||||||
void check_and_clear_err(int fd){
|
void check_and_clear_err(int fd){
|
||||||
int i, stat = 1;
|
int i, stat = 1;
|
||||||
uint8_t buf[REG_STATUS_LEN];
|
uint8_t buf[REG_STATUS_LEN];
|
||||||
for(i = 0; i < 10 && stat; ++i){
|
for(i = 0; i < 10 && stat; ++i){
|
||||||
stat = readreg(fd, buf, REG_STATUS, REG_STATUS_LEN);
|
stat = readreg(fd, buf, REG_STATUS, REG_STATUS_LEN);
|
||||||
if(stat) usleep(100000);
|
if(stat) usleep(100000);
|
||||||
}
|
}
|
||||||
/// "ïÛÉÂËÁ, ËÏÌÉÞÅÓÔ×Ï ÐÏÐÙÔÏË ÉÓÔÅËÌÏ"
|
/// "ïÛÉÂËÁ, ËÏÌÉÞÅÓÔ×Ï ÐÏÐÙÔÏË ÉÓÔÅËÌÏ"
|
||||||
if(i == 10) ERRX(_("Error, tries amount exceed"));
|
if(i == 10) ERRX(_("Error, tries amount exceed"));
|
||||||
if(buf[1] != 0xff){
|
if(buf[1] != 0xff){
|
||||||
if(buf[5]){
|
if(buf[5]){
|
||||||
/// "ïÛÉÂËÁ No %d, ÓÂÒÁÓÙ×ÁÀ"
|
/// "ïÛÉÂËÁ No %d, ÓÂÒÁÓÙ×ÁÀ"
|
||||||
//red(_("Error No %d, clear it"), buf[5]);
|
//red(_("Error No %d, clear it"), buf[5]);
|
||||||
stat = 1;
|
stat = 1;
|
||||||
for(i = 0; i < 10 && stat; ++i){
|
for(i = 0; i < 10 && stat; ++i){
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
buf[0] = REG_CLERR;
|
buf[0] = REG_CLERR;
|
||||||
stat = writereg(fd, buf, REG_CLERR_LEN);
|
stat = writereg(fd, buf, REG_CLERR_LEN);
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
if(!stat) stat = readreg(fd, buf, REG_STATUS, REG_STATUS_LEN);
|
if(!stat) stat = readreg(fd, buf, REG_STATUS, REG_STATUS_LEN);
|
||||||
if(!stat && buf[5]) stat = 1;
|
if(!stat && buf[5]) stat = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
readreg(fd, buf, REG_STATUS, REG_STATUS_LEN);
|
readreg(fd, buf, REG_STATUS, REG_STATUS_LEN);
|
||||||
if(buf[1] != 0xff){
|
if(buf[1] != 0xff){
|
||||||
/// "ôÕÒÅÌØ ÎÅ ÉÎÉÃÉÁÌÉÚÉÒÏ×ÁÎÁ, Ä×ÉÖÅÎÉÅ × \"ÄÏÍ\""
|
/// "ôÕÒÅÌØ ÎÅ ÉÎÉÃÉÁÌÉÚÉÒÏ×ÁÎÁ, Ä×ÉÖÅÎÉÅ × \"ÄÏÍ\""
|
||||||
red(_("Turret isn't initialized, move home..."));
|
red(_("Turret isn't initialized, move home..."));
|
||||||
go_home(fd);
|
go_home(fd);
|
||||||
readreg(fd, buf, REG_STATUS, REG_STATUS_LEN);
|
readreg(fd, buf, REG_STATUS, REG_STATUS_LEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -259,25 +271,25 @@ void check_and_clear_err(int fd){
|
|||||||
* @return current position
|
* @return current position
|
||||||
*/
|
*/
|
||||||
int poll_regstatus(int fd, int msg){
|
int poll_regstatus(int fd, int msg){
|
||||||
uint8_t buf[REG_STATUS_LEN];
|
uint8_t buf[REG_STATUS_LEN];
|
||||||
int i, stat = 1;
|
int i, stat = 1;
|
||||||
/// "ïÖÉÄÁÎÉÅ ÏËÏÎÞÁÎÉÑ Ä×ÉÖÅÎÉÑ"
|
/// "ïÖÉÄÁÎÉÅ ÏËÏÎÞÁÎÉÑ Ä×ÉÖÅÎÉÑ"
|
||||||
if(msg) printf(_("Wait for end of moving "));
|
if(msg) printf(_("Wait for end of moving "));
|
||||||
for(i = 0; i < 300 && stat; ++i){
|
for(i = 0; i < 300 && stat; ++i){
|
||||||
stat = readreg(fd, buf, REG_STATUS, REG_STATUS_LEN);
|
stat = readreg(fd, buf, REG_STATUS, REG_STATUS_LEN);
|
||||||
if(!stat){
|
if(!stat){
|
||||||
if(buf[2] == 0xff || buf[3] == 0xff) stat = 1;
|
if(buf[2] == 0xff || buf[3] == 0xff) stat = 1;
|
||||||
}
|
}
|
||||||
if(buf[5]){
|
if(buf[5]){
|
||||||
if(msg) printf("\n");
|
if(msg) printf("\n");
|
||||||
/// "ðÒÏÉÚÏÛÌÁ ÏÛÉÂËÁ, ÐÏ×ÔÏÒÉÔÅ ÚÁÐÕÓË"
|
/// "ðÒÏÉÚÏÛÌÁ ÏÛÉÂËÁ, ÐÏ×ÔÏÒÉÔÅ ÚÁÐÕÓË"
|
||||||
ERRX(_("Error ocured, repeat again"));
|
ERRX(_("Error ocured, repeat again"));
|
||||||
}
|
}
|
||||||
usleep(50000);
|
usleep(50000);
|
||||||
if(msg) printf("."); fflush(stdout);
|
if(msg) printf("."); fflush(stdout);
|
||||||
}
|
}
|
||||||
if(msg) printf("\n");
|
if(msg) printf("\n");
|
||||||
return buf[4];
|
return buf[4];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -286,117 +298,118 @@ int poll_regstatus(int fd, int msg){
|
|||||||
* @param pos - filter position (starts from 1)
|
* @param pos - filter position (starts from 1)
|
||||||
*/
|
*/
|
||||||
char *get_filter_name(wheel_descr *wheel, int pos){
|
char *get_filter_name(wheel_descr *wheel, int pos){
|
||||||
static uint8_t buf[REG_NAME_LEN];
|
static uint8_t buf[REG_NAME_LEN];
|
||||||
int fd = wheel->fd;
|
int fd = wheel->fd;
|
||||||
if(fd < 0) return NULL;
|
if(fd < 0) return NULL;
|
||||||
if(pos < 1 || pos > wheel->maxpos){
|
if(pos < 1 || pos > wheel->maxpos){
|
||||||
/// "úÁÄÁÎÎÁÑ ÐÏÚÉÃÉÑ ×ÎÅ ÄÉÁÐÁÚÏÎÁ 1..%d"
|
/// "úÁÄÁÎÎÁÑ ÐÏÚÉÃÉÑ ×ÎÅ ÄÉÁÐÁÚÏÎÁ 1..%d"
|
||||||
WARNX(_("Given position out of range 1..%d"), wheel->maxpos);
|
WARNX(_("Given position out of range 1..%d"), wheel->maxpos);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
buf[0] = REG_NAME;
|
buf[0] = REG_NAME;
|
||||||
buf[1] = FILTER_NAME;
|
buf[1] = FILTER_NAME;
|
||||||
buf[2] = wheel->ID;
|
buf[2] = wheel->ID;
|
||||||
buf[3] = pos;
|
buf[3] = pos;
|
||||||
if(writereg(fd, buf, REG_NAME_LEN)) return NULL;
|
if(writereg(fd, buf, REG_NAME_LEN)) return NULL;
|
||||||
if(readreg(fd, buf, REG_NAME, REG_NAME_LEN)) return NULL;
|
if(readreg(fd, buf, REG_NAME, REG_NAME_LEN)) return NULL;
|
||||||
if(buf[2]) return NULL;
|
if(buf[2]) return NULL;
|
||||||
if(buf[6]){
|
if(buf[6]){
|
||||||
char *x = strchr((char*)&buf[6], ' ');
|
char *x = strchr((char*)&buf[6], ' ');
|
||||||
if(x) *x = 0;
|
if(x) *x = 0;
|
||||||
return (char*) &buf[6];
|
return (char*) &buf[6];
|
||||||
}
|
}
|
||||||
else return NULL;
|
else return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list properties of wheels & fill remain fields of struct wheel_descr
|
* list properties of wheels & fill remain fields of struct wheel_descr
|
||||||
*/
|
*/
|
||||||
void list_props(_U_ int verblevl, wheel_descr *wheel){
|
void list_props(int verblevl, wheel_descr *wheel){
|
||||||
uint8_t buf[REG_NAME_LEN+1];
|
uint8_t buf[REG_NAME_LEN+1];
|
||||||
int fd = wheel->fd;
|
int fd = wheel->fd;
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
/// "îÅ ÍÏÇÕ ÏÔËÒÙÔØ ÕÓÔÒÏÊÓÔ×Ï"
|
/// "îÅ ÍÏÇÕ ÏÔËÒÙÔØ ÕÓÔÒÏÊÓÔ×Ï"
|
||||||
WARNX(_("Can't open device"));
|
WARNX(_("Can't open device"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
check_and_clear_err(fd);
|
check_and_clear_err(fd);
|
||||||
// get status of wheel
|
// get status of wheel
|
||||||
if(readreg(fd, buf, REG_INFO, REG_INFO_LEN)) return;
|
if(readreg(fd, buf, REG_INFO, REG_INFO_LEN)) return;
|
||||||
wheel->ID = buf[5];
|
wheel->ID = buf[5];
|
||||||
wheel->maxpos = buf[4];
|
wheel->maxpos = buf[4];
|
||||||
DBG("Wheel with id '%c' and maxpos %d", wheel->ID, wheel->maxpos);
|
DBG("Wheel with id '%c' and maxpos %d", wheel->ID, wheel->maxpos);
|
||||||
char *getwname(int id){
|
char *getwname(int id){
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
buf[0] = REG_NAME;
|
buf[0] = REG_NAME;
|
||||||
buf[1] = WHEEL_NAME;
|
buf[1] = WHEEL_NAME;
|
||||||
buf[2] = id;
|
buf[2] = id;
|
||||||
if(writereg(fd, buf, REG_NAME_LEN)) return NULL;
|
if(writereg(fd, buf, REG_NAME_LEN)) return NULL;
|
||||||
if(readreg(fd, buf, REG_NAME, REG_NAME_LEN)) return NULL;
|
if(readreg(fd, buf, REG_NAME, REG_NAME_LEN)) return NULL;
|
||||||
if(buf[6]){
|
if(buf[6]){
|
||||||
char *x = strchr((char*)&buf[6], ' ');
|
char *x = strchr((char*)&buf[6], ' ');
|
||||||
if(x) *x = 0;
|
if(x) *x = 0;
|
||||||
return (char*)&buf[6];
|
return (char*)&buf[6];
|
||||||
}
|
}
|
||||||
else return NULL;
|
else return NULL;
|
||||||
}
|
}
|
||||||
if(verblevl == LIST_PRES || !verblevl){ // list only presented devices or not list
|
if(verblevl == LIST_PRES || !verblevl){ // list only presented devices or not list
|
||||||
char *nm;
|
char *nm;
|
||||||
/// "\nó×ÏÊÓÔ×Á ÐÏÄËÌÀÞÅÎÎÏÇÏ ËÏÌÅÓÁ\n"
|
/// "\nó×ÏÊÓÔ×Á ÐÏÄËÌÀÞÅÎÎÏÇÏ ËÏÌÅÓÁ\n"
|
||||||
if(verblevl) green(_("\nConnected wheel properties\n"));
|
if(verblevl) green(_("\nConnected wheel properties\n"));
|
||||||
if(verblevl) printf("Wheel ID '%c'", wheel->ID);
|
if(verblevl) printf("Wheel ID '%c'", wheel->ID);
|
||||||
nm = getwname(wheel->ID);
|
nm = getwname(wheel->ID);
|
||||||
if(nm){
|
if(nm){
|
||||||
strncpy(wheel->name, nm, 9);
|
strncpy(wheel->name, nm, 9);
|
||||||
if(verblevl) printf(", name '%s'", wheel->name);
|
if(verblevl) printf(", name '%s'", wheel->name);
|
||||||
}
|
DBG("Wheel name: %s", wheel->name);
|
||||||
if(wheel->serial && verblevl){
|
}
|
||||||
printf(", serial '%s'", wheel->serial);
|
if(wheel->serial && verblevl){
|
||||||
}
|
printf(", serial '%s'", wheel->serial);
|
||||||
if(verblevl) printf(", %d filters:\n", wheel->maxpos);
|
}
|
||||||
else return;
|
if(verblevl) printf(", %d filters:\n", wheel->maxpos);
|
||||||
int i, m = wheel->maxpos + 1;
|
else return;
|
||||||
// now get filter names
|
int i, m = wheel->maxpos + 1;
|
||||||
for(i = 1; i < m; ++i){
|
// now get filter names
|
||||||
nm = get_filter_name(wheel, i);
|
for(i = 1; i < m; ++i){
|
||||||
printf("\t%d", i);
|
nm = get_filter_name(wheel, i);
|
||||||
if(nm) printf(": '%s'", nm);
|
printf("\t%d", i);
|
||||||
printf("\n");
|
if(nm) printf(": '%s'", nm);
|
||||||
}
|
printf("\n");
|
||||||
if(verblevl){
|
}
|
||||||
printf("current position: %d\n", poll_regstatus(wheel->fd, 0));
|
if(verblevl){
|
||||||
}
|
printf("current position: %d\n", poll_regstatus(wheel->fd, 0));
|
||||||
}
|
}
|
||||||
if(verblevl != LIST_ALL) return;
|
}
|
||||||
// now list all things stored in memory of turret driver
|
if(verblevl != LIST_ALL) return;
|
||||||
int w;
|
// now list all things stored in memory of turret driver
|
||||||
/// "\n÷ÓÅ ÚÁÐÉÓÉ EEPROM\n"
|
int w;
|
||||||
green(_("\nAll records from EEPROM\n"));
|
/// "\n÷ÓÅ ÚÁÐÉÓÉ EEPROM\n"
|
||||||
wheel_descr wl;
|
green(_("\nAll records from EEPROM\n"));
|
||||||
wl.fd = fd;
|
wheel_descr wl;
|
||||||
if(wheel->serial) printf("Turret with serial '%s'\n", wheel->serial);
|
wl.fd = fd;
|
||||||
for(w = 'A'; w < 'I'; ++w){
|
if(wheel->serial) printf("Turret with serial '%s'\n", wheel->serial);
|
||||||
char *nm = getwname(w);
|
for(w = 'A'; w < 'I'; ++w){
|
||||||
int f;
|
char *nm = getwname(w);
|
||||||
printf("Wheel ID '%c'", w);
|
int f;
|
||||||
wl.maxpos = get_max_pos(w);
|
printf("Wheel ID '%c'", w);
|
||||||
if(nm) printf(", name '%s'", nm);
|
wl.maxpos = get_max_pos(w);
|
||||||
printf(", %d filters:\n", wl.maxpos );
|
if(nm) printf(", name '%s'", nm);
|
||||||
wl.ID = w;
|
printf(", %d filters:\n", wl.maxpos );
|
||||||
for(f = 1; f <= wl.maxpos; ++f){
|
wl.ID = w;
|
||||||
nm = get_filter_name(&wl, f);
|
for(f = 1; f <= wl.maxpos; ++f){
|
||||||
if(!nm){
|
nm = get_filter_name(&wl, f);
|
||||||
check_and_clear_err(fd);
|
if(!nm){
|
||||||
memset(buf, 0, sizeof(buf));
|
check_and_clear_err(fd);
|
||||||
buf[0] = REG_NAME;
|
memset(buf, 0, sizeof(buf));
|
||||||
writereg(fd, buf, REG_NAME_LEN);
|
buf[0] = REG_NAME;
|
||||||
readreg(fd, buf, REG_NAME, REG_NAME_LEN);
|
writereg(fd, buf, REG_NAME_LEN);
|
||||||
break;
|
readreg(fd, buf, REG_NAME, REG_NAME_LEN);
|
||||||
}
|
break;
|
||||||
printf("\t%d: '%s'\n", f, nm);
|
}
|
||||||
}
|
printf("\t%d: '%s'\n", f, nm);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -404,117 +417,117 @@ void list_props(_U_ int verblevl, wheel_descr *wheel){
|
|||||||
* if 'show' != 0 show names found
|
* if 'show' != 0 show names found
|
||||||
*/
|
*/
|
||||||
void list_hw(int show){
|
void list_hw(int show){
|
||||||
int i;
|
int i;
|
||||||
if(show) DBG("show");
|
if(show) DBG("show");
|
||||||
HW_found = find_wheels(&wheels);
|
HW_found = find_wheels(&wheels); // get list of wheels with therir file descriptors and serial numbers
|
||||||
DBG("Found %d dev[s]", HW_found);
|
DBG("Found %d dev[s]", HW_found);
|
||||||
if(HW_found == 0){
|
if(HW_found == 0){
|
||||||
/// "ôÕÒÅÌÉ ÎÅ ÏÂÎÁÒÕÖÅÎÙ"
|
/// "ôÕÒÅÌÉ ÎÅ ÏÂÎÁÒÕÖÅÎÙ"
|
||||||
ERRX(_("No turrets found"));
|
ERRX(_("No turrets found"));
|
||||||
}
|
}
|
||||||
for(i = 0; i < HW_found; ++i)
|
for(i = 0; i < HW_found; ++i)
|
||||||
if(wheels[i].fd > 0) break;
|
if(wheels[i].fd > 0) break;
|
||||||
if(i == HW_found){
|
if(i == HW_found){
|
||||||
/// "ïÂÎÁÒÕÖÅÎÏ %d ÔÕÒÅÌÅÊ, ÎÏ ÎÉ Ë ÏÄÎÏÊ ÎÅÔ ÐÒÁ× ÄÏÓÔÕÐÁ"
|
/// "ïÂÎÁÒÕÖÅÎÏ %d ÔÕÒÅÌÅÊ, ÎÏ ÎÉ Ë ÏÄÎÏÊ ÎÅÔ ÐÒÁ× ÄÏÓÔÕÐÁ"
|
||||||
ERRX(_("Found %d turrets but have no access rights to any"), HW_found);
|
ERRX(_("Found %d turrets but have no access rights to any"), HW_found);
|
||||||
}
|
}
|
||||||
// read other wheel properties & list if show!=0
|
// read other wheel properties & list if show!=0
|
||||||
for(i = 0; i < HW_found; ++i){
|
for(i = 0; i < HW_found; ++i){
|
||||||
list_props(show, &wheels[i]);
|
list_props(show, &wheels[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename wheels or filters
|
* Rename wheels or filters
|
||||||
*/
|
*/
|
||||||
void rename_hw(){
|
void rename_hw(){
|
||||||
FNAME();
|
FNAME();
|
||||||
check_and_clear_err(wheel_fd);
|
check_and_clear_err(wheel_fd);
|
||||||
char *newname = NULL;
|
char *newname = NULL;
|
||||||
size_t L = 0;
|
size_t L = 0;
|
||||||
uint8_t buf[REG_NAME_LEN];
|
uint8_t buf[REG_NAME_LEN];
|
||||||
void checknm(char *nm){
|
void checknm(char *nm){
|
||||||
newname = nm;
|
newname = nm;
|
||||||
/// "îÁÚ×ÁÎÉÅ ÎÅ ÄÏÌÖÎÏ ÐÒÅ×ÙÛÁÔØ ×ÏÓØÍÉ ÓÉÍ×ÏÌÏ×"
|
/// "îÁÚ×ÁÎÉÅ ÎÅ ÄÏÌÖÎÏ ÐÒÅ×ÙÛÁÔØ ×ÏÓØÍÉ ÓÉÍ×ÏÌÏ×"
|
||||||
if((L = strlen(nm)) > 8) ERRX(_("Name should be not longer than 8 symbols"));
|
if((L = strlen(nm)) > 8) ERRX(_("Name should be not longer than 8 symbols"));
|
||||||
}
|
}
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
uint8_t cmd = 0;
|
uint8_t cmd = 0;
|
||||||
// now check what user wants to rename
|
// now check what user wants to rename
|
||||||
if(setdef){
|
if(setdef){
|
||||||
DBG("Reset names to default");
|
DBG("Reset names to default");
|
||||||
cmd = RESTORE_DEFVALS;
|
cmd = RESTORE_DEFVALS;
|
||||||
}else if(G.filterName && (G.filterId || G.filterPos)){ // user wants to rename filter
|
}else if(G.filterName && (G.filterId || G.filterPos)){ // user wants to rename filter
|
||||||
checknm(G.filterName);
|
checknm(G.filterName);
|
||||||
DBG("Rename filter %d to %s", filter_pos, newname);
|
DBG("Rename filter %d to %s", filter_pos, newname);
|
||||||
cmd = RENAME_FILTER;
|
cmd = RENAME_FILTER;
|
||||||
}else if(G.wheelName && (G.wheelID || G.filterId)){ // rename wheel
|
}else if(G.wheelName && (G.wheelID || G.filterId)){ // rename wheel
|
||||||
checknm(G.wheelName);
|
checknm(G.wheelName);
|
||||||
DBG("Rename wheel '%c' to %s", wheel_id, newname);
|
DBG("Rename wheel '%c' to %s", wheel_id, newname);
|
||||||
cmd = RENAME_WHEEL;
|
cmd = RENAME_WHEEL;
|
||||||
}
|
}
|
||||||
if(!cmd){
|
if(!cmd){
|
||||||
/// "þÔÏÂÙ ÐÅÒÅÉÍÅÎÏ×ÁÔØ, ÎÅÏÂÈÏÄÉÍÏ ÕËÁÚÁÔØ ÎÏ×ÏÅ ÎÁÚ×ÁÎÉÅ ÆÉÌØÔÒÁ/ËÏÌÅÓÁ É ÅÇÏ ÐÏÚÉÃÉÀ/ÉÄÅÎÔÉÆÉËÁÔÏÒ!"
|
/// "þÔÏÂÙ ÐÅÒÅÉÍÅÎÏ×ÁÔØ, ÎÅÏÂÈÏÄÉÍÏ ÕËÁÚÁÔØ ÎÏ×ÏÅ ÎÁÚ×ÁÎÉÅ ÆÉÌØÔÒÁ/ËÏÌÅÓÁ É ÅÇÏ ÐÏÚÉÃÉÀ/ÉÄÅÎÔÉÆÉËÁÔÏÒ!"
|
||||||
ERRX(_("You should give new filter/wheel name and its POS/ID to rename!"));
|
ERRX(_("You should give new filter/wheel name and its POS/ID to rename!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int i, stat = 1;
|
int i, stat = 1;
|
||||||
for(i = 0; i < 10 && stat; ++i){
|
for(i = 0; i < 10 && stat; ++i){
|
||||||
buf[0] = REG_NAME;
|
buf[0] = REG_NAME;
|
||||||
buf[1] = cmd;
|
buf[1] = cmd;
|
||||||
if(cmd != RESTORE_DEFVALS){
|
if(cmd != RESTORE_DEFVALS){
|
||||||
buf[2] = wheel_id;
|
buf[2] = wheel_id;
|
||||||
memcpy(&buf[4], newname, L);
|
memcpy(&buf[4], newname, L);
|
||||||
}
|
}
|
||||||
if(cmd == RENAME_FILTER) buf[3] = filter_pos;
|
if(cmd == RENAME_FILTER) buf[3] = filter_pos;
|
||||||
if((stat = writereg(wheel_fd, buf, REG_NAME_LEN))) continue;
|
if((stat = writereg(wheel_fd, buf, REG_NAME_LEN))) continue;
|
||||||
if((stat = readreg(wheel_fd, buf, REG_NAME, REG_NAME_LEN))) continue;
|
if((stat = readreg(wheel_fd, buf, REG_NAME, REG_NAME_LEN))) continue;
|
||||||
if(buf[2]){ // err not empty
|
if(buf[2]){ // err not empty
|
||||||
DBG("ER: %d", buf[2]);
|
DBG("ER: %d", buf[2]);
|
||||||
check_and_clear_err(wheel_fd);
|
check_and_clear_err(wheel_fd);
|
||||||
stat = 1; continue;
|
stat = 1; continue;
|
||||||
}
|
}
|
||||||
if(memcmp(&buf[6], newname, L)){
|
if(memcmp(&buf[6], newname, L)){
|
||||||
DBG("Names not match!");
|
DBG("Names not match!");
|
||||||
stat = 1;
|
stat = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/// "îÅ ÕÄÁÌÏÓØ ÐÅÒÅÉÍÅÎÏ×ÁÔØ"
|
/// "îÅ ÕÄÁÌÏÓØ ÐÅÒÅÉÍÅÎÏ×ÁÔØ"
|
||||||
if(i == 10) ERRX(_("Can't rename"));
|
if(i == 10) ERRX(_("Can't rename"));
|
||||||
/// "ðÅÒÅÉÍÅÎÏ×ÁÎÏ ÕÄÁÞÎÏ!"
|
/// "ðÅÒÅÉÍÅÎÏ×ÁÎÏ ÕÄÁÞÎÏ!"
|
||||||
green(_("Succesfully renamed!\n"));
|
green(_("Succesfully renamed!\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* move wheel home
|
* move wheel home
|
||||||
*/
|
*/
|
||||||
void go_home(int fd){
|
void go_home(int fd){
|
||||||
static int Nruns = 0;
|
static int Nruns = 0;
|
||||||
/// "úÁÃÉËÌÉ×ÁÎÉÅ, ÐÏÐÒÏÂÕÊÔÅ ÅÝÅ ÒÁÚ"
|
/// "úÁÃÉËÌÉ×ÁÎÉÅ, ÐÏÐÒÏÂÕÊÔÅ ÅÝÅ ÒÁÚ"
|
||||||
if(++Nruns > 10) ERRX(_("Cycling detected, try again"));
|
if(++Nruns > 10) ERRX(_("Cycling detected, try again"));
|
||||||
DBG("Wheel go home");
|
DBG("Wheel go home");
|
||||||
poll_regstatus(fd, 0); // wait for last moving
|
poll_regstatus(fd, 0); // wait for last moving
|
||||||
uint8_t buf[REG_HOME_LEN];
|
uint8_t buf[REG_HOME_LEN];
|
||||||
int i, stat = 1;
|
int i, stat = 1;
|
||||||
for(i = 0; i < 10 && stat; ++i){
|
for(i = 0; i < 10 && stat; ++i){
|
||||||
memset(buf, 0, REG_HOME_LEN);
|
memset(buf, 0, REG_HOME_LEN);
|
||||||
buf[0] = REG_HOME;
|
buf[0] = REG_HOME;
|
||||||
stat = writereg(fd, buf, REG_HOME_LEN);
|
stat = writereg(fd, buf, REG_HOME_LEN);
|
||||||
if(stat){usleep(100000); continue;}
|
if(stat){usleep(100000); continue;}
|
||||||
if((stat = readreg(fd, buf, REG_HOME, REG_HOME_LEN))) continue;
|
if((stat = readreg(fd, buf, REG_HOME, REG_HOME_LEN))) continue;
|
||||||
if(buf[1] != 0xff){
|
if(buf[1] != 0xff){
|
||||||
stat = 1; continue;
|
stat = 1; continue;
|
||||||
}else{
|
}else{
|
||||||
readreg(fd, buf, REG_HOME, REG_HOME_LEN);
|
readreg(fd, buf, REG_HOME, REG_HOME_LEN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(i == 10) exit(1);
|
if(i == 10) exit(1);
|
||||||
// now poll REG_STATUS
|
// now poll REG_STATUS
|
||||||
poll_regstatus(fd, 1);
|
poll_regstatus(fd, 1);
|
||||||
check_and_clear_err(fd);
|
check_and_clear_err(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -522,35 +535,35 @@ void go_home(int fd){
|
|||||||
* @return 0 if all OK
|
* @return 0 if all OK
|
||||||
*/
|
*/
|
||||||
int move_wheel(){
|
int move_wheel(){
|
||||||
DBG("Move wheel %c to pos %d", wheel_id, filter_pos);
|
DBG("Move wheel %c to pos %d", wheel_id, filter_pos);
|
||||||
if(wheel_fd < 0) return 1;
|
if(wheel_fd < 0) return 1;
|
||||||
if(filter_pos == poll_regstatus(wheel_fd, 0)){
|
if(filter_pos == poll_regstatus(wheel_fd, 0)){
|
||||||
/// "õÖÅ × ÚÁÄÁÎÎÏÊ ÐÏÚÉÃÉÉ"
|
/// "õÖÅ × ÚÁÄÁÎÎÏÊ ÐÏÚÉÃÉÉ"
|
||||||
WARNX(_("Already at position"));
|
WARNX(_("Already at position"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uint8_t buf[REG_GOTO_LEN];
|
uint8_t buf[REG_GOTO_LEN];
|
||||||
int i, stat = 1;
|
int i, stat = 1;
|
||||||
for(i = 0; i < 10 && stat; ++i){
|
for(i = 0; i < 10 && stat; ++i){
|
||||||
DBG("i=%d",i);
|
DBG("i=%d",i);
|
||||||
memset(buf, 0, REG_GOTO_LEN);
|
memset(buf, 0, REG_GOTO_LEN);
|
||||||
buf[0] = REG_GOTO;
|
buf[0] = REG_GOTO;
|
||||||
buf[1] = filter_pos;
|
buf[1] = filter_pos;
|
||||||
stat = writereg(wheel_fd, buf, REG_GOTO_LEN);
|
stat = writereg(wheel_fd, buf, REG_GOTO_LEN);
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
if(stat) continue;
|
if(stat) continue;
|
||||||
if((stat = readreg(wheel_fd, buf, REG_GOTO, REG_GOTO_LEN))) continue;
|
if((stat = readreg(wheel_fd, buf, REG_GOTO, REG_GOTO_LEN))) continue;
|
||||||
if(buf[1] != 0xff){
|
if(buf[1] != 0xff){
|
||||||
stat = 1; continue;
|
stat = 1; continue;
|
||||||
}else{
|
}else{
|
||||||
readreg(wheel_fd, buf, REG_GOTO, REG_HOME_LEN);
|
readreg(wheel_fd, buf, REG_GOTO, REG_HOME_LEN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(i == 10) return 1;
|
if(i == 10) return 1;
|
||||||
poll_regstatus(wheel_fd, 1);
|
poll_regstatus(wheel_fd, 1);
|
||||||
check_and_clear_err(wheel_fd);
|
check_and_clear_err(wheel_fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -558,27 +571,27 @@ int move_wheel(){
|
|||||||
* @return 0 if all OK
|
* @return 0 if all OK
|
||||||
*/
|
*/
|
||||||
int process_args(){
|
int process_args(){
|
||||||
FNAME();
|
FNAME();
|
||||||
if(wheel_id < 0) return 1;
|
if(wheel_id < 0) return 1;
|
||||||
if(showpos){
|
if(reName || setdef){
|
||||||
printf("%d\n", poll_regstatus(wheel_fd, 0));
|
rename_hw();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(gohome){
|
if(showpos){
|
||||||
go_home(wheel_fd);
|
printf("%d\n", poll_regstatus(wheel_fd, 0));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(reName || setdef){
|
if(gohome){
|
||||||
rename_hw();
|
go_home(wheel_fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(filter_pos < 0) return 1;
|
if(filter_pos < 0) return 1;
|
||||||
return move_wheel();
|
return move_wheel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check max position allowed for given filter id
|
// check max position allowed for given filter id
|
||||||
int get_max_pos(char id){
|
int get_max_pos(char id){
|
||||||
if(id >= 'A' && id <= POS_A_END) return ABS_MAX_POS_A;
|
if(id >= 'A' && id <= POS_A_END) return ABS_MAX_POS_A;
|
||||||
else if(id > POS_A_END && id <= POS_B_END) return ABS_MAX_POS_B;
|
else if(id > POS_A_END && id <= POS_B_END) return ABS_MAX_POS_B;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,33 +22,33 @@
|
|||||||
#ifndef __HSFW_H__
|
#ifndef __HSFW_H__
|
||||||
#define __HSFW_H__
|
#define __HSFW_H__
|
||||||
|
|
||||||
#define REG_CLERR (0x02)
|
#define REG_CLERR (0x02)
|
||||||
#define REG_CLERR_LEN (2)
|
#define REG_CLERR_LEN (2)
|
||||||
#define REG_STATUS (0x0a)
|
#define REG_STATUS (0x0a)
|
||||||
#define REG_STATUS_LEN (6)
|
#define REG_STATUS_LEN (6)
|
||||||
#define REG_INFO (0x0b)
|
#define REG_INFO (0x0b)
|
||||||
#define REG_INFO_LEN (7)
|
#define REG_INFO_LEN (7)
|
||||||
#define REG_GOTO (0x14)
|
#define REG_GOTO (0x14)
|
||||||
#define REG_GOTO_LEN (3)
|
#define REG_GOTO_LEN (3)
|
||||||
#define REG_HOME (0x15)
|
#define REG_HOME (0x15)
|
||||||
#define REG_HOME_LEN (3)
|
#define REG_HOME_LEN (3)
|
||||||
#define REG_NAME (0x16)
|
#define REG_NAME (0x16)
|
||||||
#define REG_NAME_LEN (14)
|
#define REG_NAME_LEN (14)
|
||||||
|
|
||||||
// absolute max position (5 for wheels 'A'..'E' & 8 for wheels 'F'..'G')
|
// absolute max position (5 for wheels 'A'..'E' & 8 for wheels 'F'..'G')
|
||||||
#define ABS_MAX_POS_A (5)
|
#define ABS_MAX_POS_A (5)
|
||||||
#define ABS_MAX_POS_B (8)
|
#define ABS_MAX_POS_B (8)
|
||||||
// end of 5-position wheel descriptor range
|
// end of 5-position wheel descriptor range
|
||||||
#define POS_A_END ('E')
|
#define POS_A_END ('E')
|
||||||
// end of 8-pos range
|
// end of 8-pos range
|
||||||
#define POS_B_END ('H')
|
#define POS_B_END ('H')
|
||||||
|
|
||||||
enum name_cmd{
|
enum name_cmd{
|
||||||
RESTORE_DEFVALS = 1,
|
RESTORE_DEFVALS = 1,
|
||||||
RENAME_FILTER,
|
RENAME_FILTER,
|
||||||
FILTER_NAME,
|
FILTER_NAME,
|
||||||
RENAME_WHEEL,
|
RENAME_WHEEL,
|
||||||
WHEEL_NAME
|
WHEEL_NAME
|
||||||
};
|
};
|
||||||
|
|
||||||
void check_args();
|
void check_args();
|
||||||
|
|||||||
Binary file not shown.
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2016-05-16 14:08+0300\n"
|
"POT-Creation-Date: 2017-05-05 16:16+0300\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -17,224 +17,6 @@ msgstr ""
|
|||||||
"Content-Type: text/plain; charset=koi8-r\n"
|
"Content-Type: text/plain; charset=koi8-r\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#. amount of pcount and/or scount wrong
|
|
||||||
#. / "îÅÐÒÁ×ÉÌØÎÙÊ ÆÏÒÍÁÔ ÓÔÒÏËÉ ÐÏÍÏÝÉ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:56
|
|
||||||
msgid "Wrong helpstring!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ãÅÌÏÅ ×ÎÅ ÄÏÐÕÓÔÉÍÏÇÏ ÄÉÁÐÁÚÏÎÁ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:86
|
|
||||||
msgid "Integer out of range"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅÐÒÁ×ÉÌØÎÙÊ ÐÁÒÁÍÅÔÒ: %s"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:480
|
|
||||||
#, c-format
|
|
||||||
msgid "Wrong parameter: %s"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "%s: ÎÅÏÂÈÏÄÉÍ ÁÒÇÕÍÅÎÔ!"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:485
|
|
||||||
#, c-format
|
|
||||||
msgid "%s: argument needed!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅÐÒÁ×ÉÌØÎÙÊ ÁÒÇÕÍÅÎÔ \"%s\" ÐÁÒÁÍÅÔÒÁ \"%s\""
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:490
|
|
||||||
#, c-format
|
|
||||||
msgid "Wrong argument \"%s\" of parameter \"%s\""
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅ ÍÏÇÕ ÏÔËÒÙÔØ %s"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hidmanage.c:80
|
|
||||||
#, c-format
|
|
||||||
msgid "Can't open %s"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅ ÚÁÄÁÎÏ ÉÍÑ ÆÁÊÌÁ!"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:174
|
|
||||||
msgid "No filename given!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅ ÍÏÇÕ ÏÔËÒÙÔØ %s ÄÌÑ ÞÔÅÎÉÑ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:177
|
|
||||||
#, c-format
|
|
||||||
msgid "Can't open %s for reading"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅ ÍÏÇÕ ×ÙÐÏÌÎÉÔØ stat %s"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:180
|
|
||||||
#, c-format
|
|
||||||
msgid "Can't stat %s"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ïÛÉÂËÁ mmap"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:184
|
|
||||||
msgid "Mmap error for input"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅ ÍÏÇÕ ÚÁËÒÙÔØ mmap'ÎÕÔÙÊ ÆÁÊÌ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:186
|
|
||||||
msgid "Can't close mmap'ed file"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅ ÍÏÇÕ munmap"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:196
|
|
||||||
msgid "Can't munmap"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅ ÍÏÇÕ ÎÁÓÔÒÏÉÔØ ËÏÎÓÏÌØ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:221
|
|
||||||
msgid "Can't setup console"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. Get settings
|
|
||||||
#. / "îÅ ÍÏÇÕ ÐÏÌÕÞÉÔØ ÎÁÓÔÒÏÊËÉ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:291
|
|
||||||
msgid "Can't get settings"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅ ÍÏÇÕ ÕÓÔÁÎÏ×ÉÔØ ÎÁÓÔÒÏÊËÉ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:302
|
|
||||||
msgid "Can't set settings"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "éÄÅÎÔÉÆÉËÁÔÏÒ ËÏÌÅÓÁ ÄÏÌÖÅÎ ÂÙÔØ ÂÕË×ÏÊ ÏÔ \"A\" ÄÏ \"H\"!"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:77
|
|
||||||
msgid "Wheel ID should be a letter from \"A\" to \"H\"!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÄÅÎÔÉÆÉËÁÔÏÒÏÍ '%c'!"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:84
|
|
||||||
#, c-format
|
|
||||||
msgid "More than one wheel with ID '%c' found!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "úÁÄÁÎÙ É ÉÄÅÎÔÉÆÉËÁÔÏÒ, É ÉÍÑ ËÏÌÅÓÁ; ÐÏÐÒÏÂÕÊÔÅ ÞÔÏ-ÔÏ ÏÄÎÏ!"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:93
|
|
||||||
msgid "You give both wheel ID and wheel name, try something one!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "úÁÄÁÎÎÏÅ ËÏÌÅÓÏ ÎÅ ÏÂÎÁÒÕÖÅÎÏ!"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:127
|
|
||||||
msgid "Given wheel not found!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "éÄÅÎÔÉÆÉËÁÔÏÒ ÆÉÌØÔÒÁ - ÂÕË×Á (ËÏÌÅÓÏ) É ÞÉÓÌÏ (ÐÏÚÉÃÉÑ)"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:135
|
|
||||||
msgid "Filter ID is letter (wheel) and number (position)"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "æÉÌØÔÒ %s ÎÅ ÏÂÎÁÒÕÖÅÎ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:162
|
|
||||||
#, c-format
|
|
||||||
msgid "Filter %s not found!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ðÏÚÉÃÉÑ ÆÉÌØÔÒÁ ÄÏÌÖÎÁ ÂÙÔØ ÞÉÓÌÏÍ ÏÔ 1 ÄÏ %d!"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:171
|
|
||||||
#, c-format
|
|
||||||
msgid "Filter position should be a number from 1 to %d!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ïÛÉÂËÁ ÏÔÐÒÁ×ËÉ ÄÁÎÎÙÈ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:191
|
|
||||||
msgid "Error sending data"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ïÛÉÂËÁ ÞÔÅÎÉÑ ÄÁÎÎÙÈ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:206
|
|
||||||
msgid "Error reading data"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ïÛÉÂËÁ, ËÏÌÉÞÅÓÔ×Ï ÐÏÐÙÔÏË ÉÓÔÅËÌÏ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:230
|
|
||||||
msgid "Error, tries amount exceed"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ôÕÒÅÌØ ÎÅ ÉÎÉÃÉÁÌÉÚÉÒÏ×ÁÎÁ, Ä×ÉÖÅÎÉÅ × \"ÄÏÍ\""
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:248
|
|
||||||
msgid "Turret isn't initialized, move home..."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ïÖÉÄÁÎÉÅ ÏËÏÎÞÁÎÉÑ Ä×ÉÖÅÎÉÑ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:265
|
|
||||||
#, c-format
|
|
||||||
msgid "Wait for end of moving "
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ðÒÏÉÚÏÛÌÁ ÏÛÉÂËÁ, ÐÏ×ÔÏÒÉÔÅ ÚÁÐÕÓË"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:274
|
|
||||||
msgid "Error ocured, repeat again"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "úÁÄÁÎÎÁÑ ÐÏÚÉÃÉÑ ×ÎÅ ÄÉÁÐÁÚÏÎÁ 1..%d"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:294
|
|
||||||
#, c-format
|
|
||||||
msgid "Given position out of range 1..%d"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅ ÍÏÇÕ ÏÔËÒÙÔØ ÕÓÔÒÏÊÓÔ×Ï"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:321
|
|
||||||
msgid "Can't open device"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "\nó×ÏÊÓÔ×Á ÐÏÄËÌÀÞÅÎÎÏÇÏ ËÏÌÅÓÁ\n"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:347
|
|
||||||
msgid ""
|
|
||||||
"\n"
|
|
||||||
"Connected wheel properties\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "\n÷ÓÅ ÚÁÐÉÓÉ EEPROM\n"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:375
|
|
||||||
msgid ""
|
|
||||||
"\n"
|
|
||||||
"All records from EEPROM\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ôÕÒÅÌÉ ÎÅ ÏÂÎÁÒÕÖÅÎÙ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:413
|
|
||||||
msgid "No turrets found"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ïÂÎÁÒÕÖÅÎÏ %d ÔÕÒÅÌÅÊ, ÎÏ ÎÉ Ë ÏÄÎÏÊ ÎÅÔ ÐÒÁ× ÄÏÓÔÕÐÁ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:419
|
|
||||||
#, c-format
|
|
||||||
msgid "Found %d turrets but have no access rights to any"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÁÚ×ÁÎÉÅ ÎÅ ÄÏÌÖÎÏ ÐÒÅ×ÙÛÁÔØ ×ÏÓØÍÉ ÓÉÍ×ÏÌÏ×"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:439
|
|
||||||
msgid "Name should be not longer than 8 symbols"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "þÔÏÂÙ ÐÅÒÅÉÍÅÎÏ×ÁÔØ, ÎÅÏÂÈÏÄÉÍÏ ÕËÁÚÁÔØ ÎÏ×ÏÅ ÎÁÚ×ÁÎÉÅ ÆÉÌØÔÒÁ/ËÏÌÅÓÁ É ÅÇÏ ÐÏÚÉÃÉÀ/ÉÄÅÎÔÉÆÉËÁÔÏÒ!"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:458
|
|
||||||
msgid "You should give new filter/wheel name and its POS/ID to rename!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "îÅ ÕÄÁÌÏÓØ ÐÅÒÅÉÍÅÎÏ×ÁÔØ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:485
|
|
||||||
msgid "Can't rename"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ðÅÒÅÉÍÅÎÏ×ÁÎÏ ÕÄÁÞÎÏ!"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:487
|
|
||||||
msgid "Succesfully renamed!\n"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "úÁÃÉËÌÉ×ÁÎÉÅ, ÐÏÐÒÏÂÕÊÔÅ ÅÝÅ ÒÁÚ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:496
|
|
||||||
msgid "Cycling detected, try again"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "õÖÅ × ÚÁÄÁÎÎÏÊ ÐÏÚÉÃÉÉ"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:529
|
|
||||||
msgid "Already at position"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. / "ÏÔÏÂÒÁÚÉÔØ ÜÔÕ ÓÐÒÁ×ËÕ"
|
#. / "ÏÔÏÂÒÁÚÉÔØ ÜÔÕ ÓÐÒÁ×ËÕ"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/cmdlnopts.c:64
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/cmdlnopts.c:64
|
||||||
msgid "show this help"
|
msgid "show this help"
|
||||||
@ -303,3 +85,252 @@ msgstr ""
|
|||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/cmdlnopts.c:128
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/cmdlnopts.c:128
|
||||||
msgid "Ignore parameters:"
|
msgid "Ignore parameters:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅ ÍÏÇÕ ÏÔËÒÙÔØ %s"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hidmanage.c:80
|
||||||
|
#, c-format
|
||||||
|
msgid "Can't open %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÊ ÔÕÒÅÌÉ Ó ÓÅÒÉÊÎÙÍ ÎÏÍÅÒÏÍ '%s'!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:79
|
||||||
|
#, c-format
|
||||||
|
msgid "More than one turret with serial '%s' found!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ôÕÒÅÌØ Ó ÓÅÒÉÊÎÙÍ ÎÏÍÅÒÏÍ '%s' ÎÅ ÎÁÊÄÅÎÁ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:86
|
||||||
|
#, c-format
|
||||||
|
msgid "Turret with serial '%s' not found"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "éÄÅÎÔÉÆÉËÁÔÏÒ ËÏÌÅÓÁ ÄÏÌÖÅÎ ÂÙÔØ ÂÕË×ÏÊ ÏÔ \"A\" ÄÏ \"H\"!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:94
|
||||||
|
msgid "Wheel ID should be a letter from \"A\" to \"H\"!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "éÄÅÎÔÉÆÉËÁÔÏÒ ÆÉÌØÔÒÁ ÄÏÌÖÅÎ ÓÏÓÔÏÑÔØ ÉÚ Ä×ÕÈ ÓÉÍ×ÏÌÏ×: ÉÄÅÎÔÉÆÉËÁÔÏÒÁ ËÏÌÅÓÁ É ÎÏÍÅÒÁ ÐÏÚÉÃÉÉ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:97
|
||||||
|
msgid "Filter ID should have two symbols: wheel ID and filter position"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÄÅÎÔÉÆÉËÁÔÏÒÏÍ '%c'!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:105
|
||||||
|
#, c-format
|
||||||
|
msgid "More than one wheel with ID '%c' found!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ëÏÌÅÓÏ Ó ÉÄÅÎÔÉÆÉËÁÔÏÒÏÍ '%c' ÎÅ ÎÁÊÄÅÎÏ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:113
|
||||||
|
#, c-format
|
||||||
|
msgid "Wheel with ID '%c' not found"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÍÅÎÅÍ '%s'!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:120
|
||||||
|
#, c-format
|
||||||
|
msgid "More than one wheel with name '%s' found!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ëÏÌÅÓÏ Ó ÉÍÅÎÅÍ '%s' ÎÅ ÎÁÊÄÅÎÏ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:127
|
||||||
|
#, c-format
|
||||||
|
msgid "Wheel with name '%s' not found"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ïÂÎÁÒÕÖÅÎÏ ÂÏÌØÛÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÍÅÎÅÍ ÆÉÌØÔÒÁ '%s'!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:160
|
||||||
|
#, c-format
|
||||||
|
msgid "More than one wheel with filter name '%s' found!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "æÉÌØÔÒ %s ÎÅ ÏÂÎÁÒÕÖÅÎ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:166
|
||||||
|
#, c-format
|
||||||
|
msgid "Filter %s not found!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "úÁÄÁÎÎÏÅ ËÏÌÅÓÏ ÎÅ ÏÂÎÁÒÕÖÅÎÏ!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:171
|
||||||
|
msgid "Given wheel not found!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ðÏÚÉÃÉÑ ÆÉÌØÔÒÁ ÄÏÌÖÎÁ ÂÙÔØ ÞÉÓÌÏÍ ÏÔ 1 ÄÏ %d!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:183
|
||||||
|
#, c-format
|
||||||
|
msgid "Filter position should be a number from 1 to %d!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ïÛÉÂËÁ ÏÔÐÒÁ×ËÉ ÄÁÎÎÙÈ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:203
|
||||||
|
msgid "Error sending data"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ïÛÉÂËÁ ÞÔÅÎÉÑ ÄÁÎÎÙÈ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:218
|
||||||
|
msgid "Error reading data"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ïÛÉÂËÁ, ËÏÌÉÞÅÓÔ×Ï ÐÏÐÙÔÏË ÉÓÔÅËÌÏ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:242
|
||||||
|
msgid "Error, tries amount exceed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ôÕÒÅÌØ ÎÅ ÉÎÉÃÉÁÌÉÚÉÒÏ×ÁÎÁ, Ä×ÉÖÅÎÉÅ × \"ÄÏÍ\""
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:260
|
||||||
|
msgid "Turret isn't initialized, move home..."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ïÖÉÄÁÎÉÅ ÏËÏÎÞÁÎÉÑ Ä×ÉÖÅÎÉÑ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:277
|
||||||
|
#, c-format
|
||||||
|
msgid "Wait for end of moving "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ðÒÏÉÚÏÛÌÁ ÏÛÉÂËÁ, ÐÏ×ÔÏÒÉÔÅ ÚÁÐÕÓË"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:286
|
||||||
|
msgid "Error ocured, repeat again"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "úÁÄÁÎÎÁÑ ÐÏÚÉÃÉÑ ×ÎÅ ÄÉÁÐÁÚÏÎÁ 1..%d"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:306
|
||||||
|
#, c-format
|
||||||
|
msgid "Given position out of range 1..%d"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅ ÍÏÇÕ ÏÔËÒÙÔØ ÕÓÔÒÏÊÓÔ×Ï"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:333
|
||||||
|
msgid "Can't open device"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "\nó×ÏÊÓÔ×Á ÐÏÄËÌÀÞÅÎÎÏÇÏ ËÏÌÅÓÁ\n"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:359
|
||||||
|
msgid ""
|
||||||
|
"\n"
|
||||||
|
"Connected wheel properties\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "\n÷ÓÅ ÚÁÐÉÓÉ EEPROM\n"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:388
|
||||||
|
msgid ""
|
||||||
|
"\n"
|
||||||
|
"All records from EEPROM\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ôÕÒÅÌÉ ÎÅ ÏÂÎÁÒÕÖÅÎÙ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:426
|
||||||
|
msgid "No turrets found"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ïÂÎÁÒÕÖÅÎÏ %d ÔÕÒÅÌÅÊ, ÎÏ ÎÉ Ë ÏÄÎÏÊ ÎÅÔ ÐÒÁ× ÄÏÓÔÕÐÁ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:432
|
||||||
|
#, c-format
|
||||||
|
msgid "Found %d turrets but have no access rights to any"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÁÚ×ÁÎÉÅ ÎÅ ÄÏÌÖÎÏ ÐÒÅ×ÙÛÁÔØ ×ÏÓØÍÉ ÓÉÍ×ÏÌÏ×"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:452
|
||||||
|
msgid "Name should be not longer than 8 symbols"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "þÔÏÂÙ ÐÅÒÅÉÍÅÎÏ×ÁÔØ, ÎÅÏÂÈÏÄÉÍÏ ÕËÁÚÁÔØ ÎÏ×ÏÅ ÎÁÚ×ÁÎÉÅ ÆÉÌØÔÒÁ/ËÏÌÅÓÁ É ÅÇÏ ÐÏÚÉÃÉÀ/ÉÄÅÎÔÉÆÉËÁÔÏÒ!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:471
|
||||||
|
msgid "You should give new filter/wheel name and its POS/ID to rename!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅ ÕÄÁÌÏÓØ ÐÅÒÅÉÍÅÎÏ×ÁÔØ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:498
|
||||||
|
msgid "Can't rename"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ðÅÒÅÉÍÅÎÏ×ÁÎÏ ÕÄÁÞÎÏ!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:500
|
||||||
|
msgid "Succesfully renamed!\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "úÁÃÉËÌÉ×ÁÎÉÅ, ÐÏÐÒÏÂÕÊÔÅ ÅÝÅ ÒÁÚ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:509
|
||||||
|
msgid "Cycling detected, try again"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "õÖÅ × ÚÁÄÁÎÎÏÊ ÐÏÚÉÃÉÉ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:542
|
||||||
|
msgid "Already at position"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. amount of pcount and/or scount wrong
|
||||||
|
#. / "îÅÐÒÁ×ÉÌØÎÙÊ ÆÏÒÍÁÔ ÓÔÒÏËÉ ÐÏÍÏÝÉ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:56
|
||||||
|
msgid "Wrong helpstring!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ãÅÌÏÅ ×ÎÅ ÄÏÐÕÓÔÉÍÏÇÏ ÄÉÁÐÁÚÏÎÁ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:86
|
||||||
|
msgid "Integer out of range"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅÐÒÁ×ÉÌØÎÙÊ ÐÁÒÁÍÅÔÒ: %s"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:480
|
||||||
|
#, c-format
|
||||||
|
msgid "Wrong parameter: %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "%s: ÎÅÏÂÈÏÄÉÍ ÁÒÇÕÍÅÎÔ!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:485
|
||||||
|
#, c-format
|
||||||
|
msgid "%s: argument needed!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅÐÒÁ×ÉÌØÎÙÊ ÁÒÇÕÍÅÎÔ \"%s\" ÐÁÒÁÍÅÔÒÁ \"%s\""
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:490
|
||||||
|
#, c-format
|
||||||
|
msgid "Wrong argument \"%s\" of parameter \"%s\""
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅ ÚÁÄÁÎÏ ÉÍÑ ÆÁÊÌÁ!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:174
|
||||||
|
msgid "No filename given!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅ ÍÏÇÕ ÏÔËÒÙÔØ %s ÄÌÑ ÞÔÅÎÉÑ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:177
|
||||||
|
#, c-format
|
||||||
|
msgid "Can't open %s for reading"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅ ÍÏÇÕ ×ÙÐÏÌÎÉÔØ stat %s"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:180
|
||||||
|
#, c-format
|
||||||
|
msgid "Can't stat %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "ïÛÉÂËÁ mmap"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:184
|
||||||
|
msgid "Mmap error for input"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅ ÍÏÇÕ ÚÁËÒÙÔØ mmap'ÎÕÔÙÊ ÆÁÊÌ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:186
|
||||||
|
msgid "Can't close mmap'ed file"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅ ÍÏÇÕ munmap"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:196
|
||||||
|
msgid "Can't munmap"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅ ÍÏÇÕ ÎÁÓÔÒÏÉÔØ ËÏÎÓÏÌØ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:221
|
||||||
|
msgid "Can't setup console"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. Get settings
|
||||||
|
#. / "îÅ ÍÏÇÕ ÐÏÌÕÞÉÔØ ÎÁÓÔÒÏÊËÉ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:291
|
||||||
|
msgid "Can't get settings"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. / "îÅ ÍÏÇÕ ÕÓÔÁÎÏ×ÉÔØ ÎÁÓÔÒÏÊËÉ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/usefull_macros.c:302
|
||||||
|
msgid "Can't set settings"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr "Project-Id-Version: PACKAGE VERSION\n"
|
msgstr "Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2016-05-16 14:03+0300\n"
|
"POT-Creation-Date: 2017-05-05 16:16+0300\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -17,14 +17,14 @@ msgstr "Project-Id-Version: PACKAGE VERSION\n"
|
|||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#. / "\nВсе записи EEPROM\n"
|
#. / "\nВсе записи EEPROM\n"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:375
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:388
|
||||||
msgid "\n"
|
msgid "\n"
|
||||||
"All records from EEPROM\n"
|
"All records from EEPROM\n"
|
||||||
msgstr "\n"
|
msgstr "\n"
|
||||||
"Все записи EEPROM\n"
|
"Все записи EEPROM\n"
|
||||||
|
|
||||||
#. / "\nСвойства подключенного колеса\n"
|
#. / "\nСвойства подключенного колеса\n"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:347
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:359
|
||||||
msgid "\n"
|
msgid "\n"
|
||||||
"Connected wheel properties\n"
|
"Connected wheel properties\n"
|
||||||
msgstr "\n"
|
msgstr "\n"
|
||||||
@ -37,7 +37,7 @@ msgid "%s: argument needed!"
|
|||||||
msgstr "%s: необходим аргумент!"
|
msgstr "%s: необходим аргумент!"
|
||||||
|
|
||||||
#. / "Уже в заданной позиции"
|
#. / "Уже в заданной позиции"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:529
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:542
|
||||||
msgid "Already at position"
|
msgid "Already at position"
|
||||||
msgstr "Уже в заданной позиции"
|
msgstr "Уже в заданной позиции"
|
||||||
|
|
||||||
@ -70,12 +70,12 @@ msgid "Can't open %s for reading"
|
|||||||
msgstr "Не могу открыть %s для чтения"
|
msgstr "Не могу открыть %s для чтения"
|
||||||
|
|
||||||
#. / "Не могу открыть устройство"
|
#. / "Не могу открыть устройство"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:321
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:333
|
||||||
msgid "Can't open device"
|
msgid "Can't open device"
|
||||||
msgstr "Не могу открыть устройство"
|
msgstr "Не могу открыть устройство"
|
||||||
|
|
||||||
#. / "Не удалось переименовать"
|
#. / "Не удалось переименовать"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:485
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:498
|
||||||
msgid "Can't rename"
|
msgid "Can't rename"
|
||||||
msgstr "Не удалось переименовать"
|
msgstr "Не удалось переименовать"
|
||||||
|
|
||||||
@ -96,61 +96,61 @@ msgid "Can't stat %s"
|
|||||||
msgstr "Не могу выполнить stat %s"
|
msgstr "Не могу выполнить stat %s"
|
||||||
|
|
||||||
#. / "Зацикливание, попробуйте еще раз"
|
#. / "Зацикливание, попробуйте еще раз"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:496
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:509
|
||||||
msgid "Cycling detected, try again"
|
msgid "Cycling detected, try again"
|
||||||
msgstr "Зацикливание, попробуйте еще раз"
|
msgstr "Зацикливание, попробуйте еще раз"
|
||||||
|
|
||||||
#. / "Произошла ошибка, повторите запуск"
|
#. / "Произошла ошибка, повторите запуск"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:274
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:286
|
||||||
msgid "Error ocured, repeat again"
|
msgid "Error ocured, repeat again"
|
||||||
msgstr "Произошла ошибка, повторите запуск"
|
msgstr "Произошла ошибка, повторите запуск"
|
||||||
|
|
||||||
#. / "Ошибка чтения данных"
|
#. / "Ошибка чтения данных"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:206
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:218
|
||||||
msgid "Error reading data"
|
msgid "Error reading data"
|
||||||
msgstr "Ошибка чтения данных"
|
msgstr "Ошибка чтения данных"
|
||||||
|
|
||||||
#. / "Ошибка отправки данных"
|
#. / "Ошибка отправки данных"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:191
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:203
|
||||||
msgid "Error sending data"
|
msgid "Error sending data"
|
||||||
msgstr "Ошибка отправки данных"
|
msgstr "Ошибка отправки данных"
|
||||||
|
|
||||||
#. / "Ошибка, количество попыток истекло"
|
#. / "Ошибка, количество попыток истекло"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:230
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:242
|
||||||
msgid "Error, tries amount exceed"
|
msgid "Error, tries amount exceed"
|
||||||
msgstr "Ошибка, количество попыток истекло"
|
msgstr "Ошибка, количество попыток истекло"
|
||||||
|
|
||||||
#. / "Фильтр %s не обнаружен"
|
#. / "Фильтр %s не обнаружен"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:162
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:166
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Filter %s not found!"
|
msgid "Filter %s not found!"
|
||||||
msgstr "Фильтр %s не обнаружен"
|
msgstr "Фильтр %s не обнаружен"
|
||||||
|
|
||||||
#. / "éÄÅÎÔÉÆÉËÁÔÏÒ ÆÉÌØÔÒÁ - ÂÕË×Á (ËÏÌÅÓÏ) É ÞÉÓÌÏ (ÐÏÚÉÃÉÑ)"
|
#. / "éÄÅÎÔÉÆÉËÁÔÏÒ ÆÉÌØÔÒÁ ÄÏÌÖÅÎ ÓÏÓÔÏÑÔØ ÉÚ Ä×ÕÈ ÓÉÍ×ÏÌÏ×: ÉÄÅÎÔÉÆÉËÁÔÏÒÁ ËÏÌÅÓÁ É ÎÏÍÅÒÁ ÐÏÚÉÃÉÉ"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:135
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:97
|
||||||
msgid "Filter ID is letter (wheel) and number (position)"
|
msgid "Filter ID should have two symbols: wheel ID and filter position"
|
||||||
msgstr "éÄÅÎÔÉÆÉËÁÔÏÒ ÆÉÌØÔÒÁ - ÂÕË×Á (ËÏÌÅÓÏ) É ÞÉÓÌÏ (ÐÏÚÉÃÉÑ)"
|
msgstr "éÄÅÎÔÉÆÉËÁÔÏÒ ÆÉÌØÔÒÁ ÄÏÌÖÅÎ ÓÏÓÔÏÑÔØ ÉÚ Ä×ÕÈ ÓÉÍ×ÏÌÏ×: ÉÄÅÎÔÉÆÉËÁÔÏÒÁ ËÏÌÅÓÁ É ÎÏÍÅÒÁ ÐÏÚÉÃÉÉ"
|
||||||
|
|
||||||
#. / "Позиция фильтра должна быть числом от 1 до %d!"
|
#. / "Позиция фильтра должна быть числом от 1 до %d!"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:171
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:183
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Filter position should be a number from 1 to %d!"
|
msgid "Filter position should be a number from 1 to %d!"
|
||||||
msgstr "Позиция фильтра должна быть числом от 1 до %d!"
|
msgstr "Позиция фильтра должна быть числом от 1 до %d!"
|
||||||
|
|
||||||
#. / "Обнаружено %d турелей, но ни к одной нет прав доступа"
|
#. / "Обнаружено %d турелей, но ни к одной нет прав доступа"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:419
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:432
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Found %d turrets but have no access rights to any"
|
msgid "Found %d turrets but have no access rights to any"
|
||||||
msgstr "Обнаружено %d турелей, но ни к одной нет прав доступа"
|
msgstr "Обнаружено %d турелей, но ни к одной нет прав доступа"
|
||||||
|
|
||||||
#. / "Заданная позиция вне диапазона 1..%d"
|
#. / "Заданная позиция вне диапазона 1..%d"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:294
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:306
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Given position out of range 1..%d"
|
msgid "Given position out of range 1..%d"
|
||||||
msgstr "Заданная позиция вне диапазона 1..%d"
|
msgstr "Заданная позиция вне диапазона 1..%d"
|
||||||
|
|
||||||
#. / "Заданное колесо не обнаружено!"
|
#. / "Заданное колесо не обнаружено!"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:127
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:171
|
||||||
msgid "Given wheel not found!"
|
msgid "Given wheel not found!"
|
||||||
msgstr "Заданное колесо не обнаружено!"
|
msgstr "Заданное колесо не обнаружено!"
|
||||||
|
|
||||||
@ -169,14 +169,32 @@ msgstr "
|
|||||||
msgid "Mmap error for input"
|
msgid "Mmap error for input"
|
||||||
msgstr "Ошибка mmap"
|
msgstr "Ошибка mmap"
|
||||||
|
|
||||||
|
#. / "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÊ ÔÕÒÅÌÉ Ó ÓÅÒÉÊÎÙÍ ÎÏÍÅÒÏÍ '%s'!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:79
|
||||||
|
#, c-format
|
||||||
|
msgid "More than one turret with serial '%s' found!"
|
||||||
|
msgstr "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÊ ÔÕÒÅÌÉ Ó ÓÅÒÉÊÎÙÍ ÎÏÍÅÒÏÍ '%s'!"
|
||||||
|
|
||||||
#. / "Обнаружено более одного колеса с идентификатором '%c'!"
|
#. / "Обнаружено более одного колеса с идентификатором '%c'!"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:84
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:105
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "More than one wheel with ID '%c' found!"
|
msgid "More than one wheel with ID '%c' found!"
|
||||||
msgstr "Обнаружено более одного колеса с идентификатором '%c'!"
|
msgstr "Обнаружено более одного колеса с идентификатором '%c'!"
|
||||||
|
|
||||||
|
#. / "ïÂÎÁÒÕÖÅÎÏ ÂÏÌØÛÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÍÅÎÅÍ ÆÉÌØÔÒÁ '%s'!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:160
|
||||||
|
#, c-format
|
||||||
|
msgid "More than one wheel with filter name '%s' found!"
|
||||||
|
msgstr "ïÂÎÁÒÕÖÅÎÏ ÂÏÌØÛÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÍÅÎÅÍ ÆÉÌØÔÒÁ '%s'!"
|
||||||
|
|
||||||
|
#. / "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÍÅÎÅÍ '%s'!"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:120
|
||||||
|
#, c-format
|
||||||
|
msgid "More than one wheel with name '%s' found!"
|
||||||
|
msgstr "ïÂÎÁÒÕÖÅÎÏ ÂÏÌÅÅ ÏÄÎÏÇÏ ËÏÌÅÓÁ Ó ÉÍÅÎÅÍ '%s'!"
|
||||||
|
|
||||||
#. / "Название не должно превышать восьми символов"
|
#. / "Название не должно превышать восьми символов"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:439
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:452
|
||||||
msgid "Name should be not longer than 8 symbols"
|
msgid "Name should be not longer than 8 symbols"
|
||||||
msgstr "Название не должно превышать восьми символов"
|
msgstr "Название не должно превышать восьми символов"
|
||||||
|
|
||||||
@ -186,31 +204,49 @@ msgid "No filename given!"
|
|||||||
msgstr "Не задано имя файла!"
|
msgstr "Не задано имя файла!"
|
||||||
|
|
||||||
#. / "Турели не обнаружены"
|
#. / "Турели не обнаружены"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:413
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:426
|
||||||
msgid "No turrets found"
|
msgid "No turrets found"
|
||||||
msgstr "Турели не обнаружены"
|
msgstr "Турели не обнаружены"
|
||||||
|
|
||||||
#. / "Переименовано удачно!"
|
#. / "Переименовано удачно!"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:487
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:500
|
||||||
msgid "Succesfully renamed!\n"
|
msgid "Succesfully renamed!\n"
|
||||||
msgstr "Переименовано удачно!\n"
|
msgstr "Переименовано удачно!\n"
|
||||||
|
|
||||||
#. / "Турель не инициализирована, движение в \"дом\""
|
#. / "Турель не инициализирована, движение в \"дом\""
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:248
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:260
|
||||||
msgid "Turret isn't initialized, move home..."
|
msgid "Turret isn't initialized, move home..."
|
||||||
msgstr "Турель не инициализирована, движение в \"дом\""
|
msgstr "Турель не инициализирована, движение в \"дом\""
|
||||||
|
|
||||||
|
#. / "ôÕÒÅÌØ Ó ÓÅÒÉÊÎÙÍ ÎÏÍÅÒÏÍ '%s' ÎÅ ÎÁÊÄÅÎÁ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:86
|
||||||
|
#, c-format
|
||||||
|
msgid "Turret with serial '%s' not found"
|
||||||
|
msgstr "ôÕÒÅÌØ Ó ÓÅÒÉÊÎÙÍ ÎÏÍÅÒÏÍ '%s' ÎÅ ÎÁÊÄÅÎÁ"
|
||||||
|
|
||||||
#. / "Ожидание окончания движения"
|
#. / "Ожидание окончания движения"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:265
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:277
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Wait for end of moving "
|
msgid "Wait for end of moving "
|
||||||
msgstr "Ожидание окончания движения"
|
msgstr "Ожидание окончания движения"
|
||||||
|
|
||||||
#. / "Идентификатор колеса должен быть буквой от \"A\" до \"H\"!"
|
#. / "Идентификатор колеса должен быть буквой от \"A\" до \"H\"!"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:77
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:94
|
||||||
msgid "Wheel ID should be a letter from \"A\" to \"H\"!"
|
msgid "Wheel ID should be a letter from \"A\" to \"H\"!"
|
||||||
msgstr "Идентификатор колеса должен быть буквой от \"A\" до \"H\"!"
|
msgstr "Идентификатор колеса должен быть буквой от \"A\" до \"H\"!"
|
||||||
|
|
||||||
|
#. / "ëÏÌÅÓÏ Ó ÉÄÅÎÔÉÆÉËÁÔÏÒÏÍ '%c' ÎÅ ÎÁÊÄÅÎÏ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:113
|
||||||
|
#, c-format
|
||||||
|
msgid "Wheel with ID '%c' not found"
|
||||||
|
msgstr "ëÏÌÅÓÏ Ó ÉÄÅÎÔÉÆÉËÁÔÏÒÏÍ '%c' ÎÅ ÎÁÊÄÅÎÏ"
|
||||||
|
|
||||||
|
#. / "ëÏÌÅÓÏ Ó ÉÍÅÎÅÍ '%s' ÎÅ ÎÁÊÄÅÎÏ"
|
||||||
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:127
|
||||||
|
#, c-format
|
||||||
|
msgid "Wheel with name '%s' not found"
|
||||||
|
msgstr "ëÏÌÅÓÏ Ó ÉÍÅÎÅÍ '%s' ÎÅ ÎÁÊÄÅÎÏ"
|
||||||
|
|
||||||
#. / "Неправильный аргумент \"%s\" параметра \"%s\""
|
#. / "Неправильный аргумент \"%s\" параметра \"%s\""
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:490
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/parseargs.c:490
|
||||||
#, c-format
|
#, c-format
|
||||||
@ -234,13 +270,8 @@ msgstr "
|
|||||||
msgid "Wrong parameter: %s"
|
msgid "Wrong parameter: %s"
|
||||||
msgstr "Неправильный параметр: %s"
|
msgstr "Неправильный параметр: %s"
|
||||||
|
|
||||||
#. / "úÁÄÁÎÙ É ÉÄÅÎÔÉÆÉËÁÔÏÒ, É ÉÍÑ ËÏÌÅÓÁ; ÐÏÐÒÏÂÕÊÔÅ ÞÔÏ-ÔÏ ÏÄÎÏ!"
|
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:93
|
|
||||||
msgid "You give both wheel ID and wheel name, try something one!"
|
|
||||||
msgstr "úÁÄÁÎÙ É ÉÄÅÎÔÉÆÉËÁÔÏÒ, É ÉÍÑ ËÏÌÅÓÁ; ÐÏÐÒÏÂÕÊÔÅ ÞÔÏ-ÔÏ ÏÄÎÏ!"
|
|
||||||
|
|
||||||
#. / "Чтобы переименовать, необходимо указать новое название фильтра/колеса и его позицию/идентификатор!"
|
#. / "Чтобы переименовать, необходимо указать новое название фильтра/колеса и его позицию/идентификатор!"
|
||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:458
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/hsfw.c:471
|
||||||
msgid "You should give new filter/wheel name and its POS/ID to rename!"
|
msgid "You should give new filter/wheel name and its POS/ID to rename!"
|
||||||
msgstr "Чтобы переименовать, необходимо указать новое название фильтра/"
|
msgstr "Чтобы переименовать, необходимо указать новое название фильтра/"
|
||||||
"колеса и его позицию/идентификатор!"
|
"колеса и его позицию/идентификатор!"
|
||||||
@ -303,3 +334,6 @@ msgstr "
|
|||||||
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/cmdlnopts.c:68
|
#: /home/eddy/Docs/SAO/Edmund_optics/HSFW_management/cmdlnopts.c:68
|
||||||
msgid "wheel name"
|
msgid "wheel name"
|
||||||
msgstr "название колеса"
|
msgstr "название колеса"
|
||||||
|
|
||||||
|
#~ msgid "You give both wheel ID and wheel name, try something one!"
|
||||||
|
#~ msgstr "úÁÄÁÎÙ É ÉÄÅÎÔÉÆÉËÁÔÏÒ, É ÉÍÑ ËÏÌÅÓÁ; ÐÏÐÒÏÂÕÊÔÅ ÞÔÏ-ÔÏ ÏÄÎÏ!"
|
||||||
|
|||||||
@ -19,15 +19,15 @@
|
|||||||
* MA 02110-1301, USA.
|
* MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h> // printf
|
#include <stdio.h> // printf
|
||||||
#include <getopt.h> // getopt_long
|
#include <getopt.h> // getopt_long
|
||||||
#include <stdlib.h> // calloc, exit, strtoll
|
#include <stdlib.h> // calloc, exit, strtoll
|
||||||
#include <assert.h> // assert
|
#include <assert.h> // assert
|
||||||
#include <string.h> // strdup, strchr, strlen
|
#include <string.h> // strdup, strchr, strlen
|
||||||
#include <strings.h>// strcasecmp
|
#include <strings.h>// strcasecmp
|
||||||
#include <limits.h> // INT_MAX & so on
|
#include <limits.h> // INT_MAX & so on
|
||||||
#include <libintl.h>// gettext
|
#include <libintl.h>// gettext
|
||||||
#include <ctype.h> // isalpha
|
#include <ctype.h> // isalpha
|
||||||
#include "parseargs.h"
|
#include "parseargs.h"
|
||||||
#include "usefull_macros.h"
|
#include "usefull_macros.h"
|
||||||
|
|
||||||
@ -39,23 +39,23 @@ char *helpstring = "%s\n";
|
|||||||
* @param str (i) - new format
|
* @param str (i) - new format
|
||||||
*/
|
*/
|
||||||
void change_helpstring(char *s){
|
void change_helpstring(char *s){
|
||||||
int pcount = 0, scount = 0;
|
int pcount = 0, scount = 0;
|
||||||
char *str = s;
|
char *str = s;
|
||||||
// check `helpstring` and set it to default in case of error
|
// check `helpstring` and set it to default in case of error
|
||||||
for(; pcount < 2; str += 2){
|
for(; pcount < 2; str += 2){
|
||||||
if(!(str = strchr(str, '%'))) break;
|
if(!(str = strchr(str, '%'))) break;
|
||||||
if(str[1] != '%') pcount++; // increment '%' counter if it isn't "%%"
|
if(str[1] != '%') pcount++; // increment '%' counter if it isn't "%%"
|
||||||
else{
|
else{
|
||||||
str += 2; // pass next '%'
|
str += 2; // pass next '%'
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(str[1] == 's') scount++; // increment "%s" counter
|
if(str[1] == 's') scount++; // increment "%s" counter
|
||||||
};
|
};
|
||||||
if(pcount > 1 || pcount != scount){ // amount of pcount and/or scount wrong
|
if(pcount > 1 || pcount != scount){ // amount of pcount and/or scount wrong
|
||||||
/// "îÅÐÒÁ×ÉÌØÎÙÊ ÆÏÒÍÁÔ ÓÔÒÏËÉ ÐÏÍÏÝÉ"
|
/// "îÅÐÒÁ×ÉÌØÎÙÊ ÆÏÒÍÁÔ ÓÔÒÏËÉ ÐÏÍÏÝÉ"
|
||||||
ERRX(_("Wrong helpstring!"));
|
ERRX(_("Wrong helpstring!"));
|
||||||
}
|
}
|
||||||
helpstring = s;
|
helpstring = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,54 +66,54 @@ void change_helpstring(char *s){
|
|||||||
* @return TRUE if conversion sone without errors, FALSE otherwise
|
* @return TRUE if conversion sone without errors, FALSE otherwise
|
||||||
*/
|
*/
|
||||||
static bool myatoll(void *num, char *str, argtype t){
|
static bool myatoll(void *num, char *str, argtype t){
|
||||||
long long tmp, *llptr;
|
long long tmp, *llptr;
|
||||||
int *iptr;
|
int *iptr;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
assert(str);
|
assert(str);
|
||||||
assert(num);
|
assert(num);
|
||||||
tmp = strtoll(str, &endptr, 0);
|
tmp = strtoll(str, &endptr, 0);
|
||||||
if(endptr == str || *str == '\0' || *endptr != '\0')
|
if(endptr == str || *str == '\0' || *endptr != '\0')
|
||||||
return FALSE;
|
return FALSE;
|
||||||
switch(t){
|
switch(t){
|
||||||
case arg_longlong:
|
case arg_longlong:
|
||||||
llptr = (long long*) num;
|
llptr = (long long*) num;
|
||||||
*llptr = tmp;
|
*llptr = tmp;
|
||||||
break;
|
break;
|
||||||
case arg_int:
|
case arg_int:
|
||||||
default:
|
default:
|
||||||
if(tmp < INT_MIN || tmp > INT_MAX){
|
if(tmp < INT_MIN || tmp > INT_MAX){
|
||||||
/// "ãÅÌÏÅ ×ÎÅ ÄÏÐÕÓÔÉÍÏÇÏ ÄÉÁÐÁÚÏÎÁ"
|
/// "ãÅÌÏÅ ×ÎÅ ÄÏÐÕÓÔÉÍÏÇÏ ÄÉÁÐÁÚÏÎÁ"
|
||||||
WARNX(_("Integer out of range"));
|
WARNX(_("Integer out of range"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
iptr = (int*)num;
|
iptr = (int*)num;
|
||||||
*iptr = (int)tmp;
|
*iptr = (int)tmp;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the same as myatoll but for double
|
// the same as myatoll but for double
|
||||||
// There's no NAN & INF checking here (what if they would be needed?)
|
// There's no NAN & INF checking here (what if they would be needed?)
|
||||||
static bool myatod(void *num, const char *str, argtype t){
|
static bool myatod(void *num, const char *str, argtype t){
|
||||||
double tmp, *dptr;
|
double tmp, *dptr;
|
||||||
float *fptr;
|
float *fptr;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
assert(str);
|
assert(str);
|
||||||
tmp = strtod(str, &endptr);
|
tmp = strtod(str, &endptr);
|
||||||
if(endptr == str || *str == '\0' || *endptr != '\0')
|
if(endptr == str || *str == '\0' || *endptr != '\0')
|
||||||
return FALSE;
|
return FALSE;
|
||||||
switch(t){
|
switch(t){
|
||||||
case arg_double:
|
case arg_double:
|
||||||
dptr = (double *) num;
|
dptr = (double *) num;
|
||||||
*dptr = tmp;
|
*dptr = tmp;
|
||||||
break;
|
break;
|
||||||
case arg_float:
|
case arg_float:
|
||||||
default:
|
default:
|
||||||
fptr = (float *) num;
|
fptr = (float *) num;
|
||||||
*fptr = (float)tmp;
|
*fptr = (float)tmp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,13 +123,13 @@ static bool myatod(void *num, const char *str, argtype t){
|
|||||||
* @return index in array
|
* @return index in array
|
||||||
*/
|
*/
|
||||||
static int get_optind(int opt, myoption *options){
|
static int get_optind(int opt, myoption *options){
|
||||||
int oind;
|
int oind;
|
||||||
myoption *opts = options;
|
myoption *opts = options;
|
||||||
assert(opts);
|
assert(opts);
|
||||||
for(oind = 0; opts->name && opts->val != opt; oind++, opts++);
|
for(oind = 0; opts->name && opts->val != opt; oind++, opts++);
|
||||||
if(!opts->name || opts->val != opt) // no such parameter
|
if(!opts->name || opts->val != opt) // no such parameter
|
||||||
showhelp(-1, options);
|
showhelp(-1, options);
|
||||||
return oind;
|
return oind;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,46 +139,46 @@ static int get_optind(int opt, myoption *options){
|
|||||||
* @return pointer to new (next) value
|
* @return pointer to new (next) value
|
||||||
*/
|
*/
|
||||||
void *get_aptr(void *paptr, argtype type){
|
void *get_aptr(void *paptr, argtype type){
|
||||||
int i = 1;
|
int i = 1;
|
||||||
void **aptr = *((void***)paptr);
|
void **aptr = *((void***)paptr);
|
||||||
if(aptr){ // there's something in array
|
if(aptr){ // there's something in array
|
||||||
void **p = aptr;
|
void **p = aptr;
|
||||||
while(*p++) ++i;
|
while(*p++) ++i;
|
||||||
}
|
}
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
switch(type){
|
switch(type){
|
||||||
default:
|
default:
|
||||||
case arg_none:
|
case arg_none:
|
||||||
/// "îÅ ÍÏÇÕ ÉÓÐÏÌØÚÏ×ÁÔØ ÎÅÓËÏÌØËÏ ÐÁÒÁÍÅÔÒÏ× ÂÅÚ ÁÒÇÕÍÅÎÔÏ×!"
|
/// "îÅ ÍÏÇÕ ÉÓÐÏÌØÚÏ×ÁÔØ ÎÅÓËÏÌØËÏ ÐÁÒÁÍÅÔÒÏ× ÂÅÚ ÁÒÇÕÍÅÎÔÏ×!"
|
||||||
ERRX("Can't use multiple args with arg_none!");
|
ERRX("Can't use multiple args with arg_none!");
|
||||||
break;
|
break;
|
||||||
case arg_int:
|
case arg_int:
|
||||||
sz = sizeof(int);
|
sz = sizeof(int);
|
||||||
break;
|
break;
|
||||||
case arg_longlong:
|
case arg_longlong:
|
||||||
sz = sizeof(long long);
|
sz = sizeof(long long);
|
||||||
break;
|
break;
|
||||||
case arg_double:
|
case arg_double:
|
||||||
sz = sizeof(double);
|
sz = sizeof(double);
|
||||||
break;
|
break;
|
||||||
case arg_float:
|
case arg_float:
|
||||||
sz = sizeof(float);
|
sz = sizeof(float);
|
||||||
break;
|
break;
|
||||||
case arg_string:
|
case arg_string:
|
||||||
sz = 0;
|
sz = 0;
|
||||||
break;
|
break;
|
||||||
/* case arg_function:
|
/* case arg_function:
|
||||||
sz = sizeof(argfn *);
|
sz = sizeof(argfn *);
|
||||||
break;*/
|
break;*/
|
||||||
}
|
}
|
||||||
aptr = realloc(aptr, (i + 1) * sizeof(void*));
|
aptr = realloc(aptr, (i + 1) * sizeof(void*));
|
||||||
*((void***)paptr) = aptr;
|
*((void***)paptr) = aptr;
|
||||||
aptr[i] = NULL;
|
aptr[i] = NULL;
|
||||||
if(sz){
|
if(sz){
|
||||||
aptr[i - 1] = malloc(sz);
|
aptr[i - 1] = malloc(sz);
|
||||||
}else
|
}else
|
||||||
aptr[i - 1] = &aptr[i - 1];
|
aptr[i - 1] = &aptr[i - 1];
|
||||||
return aptr[i - 1];
|
return aptr[i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -189,145 +189,145 @@ void *get_aptr(void *paptr, argtype type){
|
|||||||
* @param argc (io) - address of argc of main(), return value of argc stay after `getopt`
|
* @param argc (io) - address of argc of main(), return value of argc stay after `getopt`
|
||||||
* @param argv (io) - address of argv of main(), return pointer to argv stay after `getopt`
|
* @param argv (io) - address of argv of main(), return pointer to argv stay after `getopt`
|
||||||
* BE CAREFUL! if you wanna use full argc & argv, save their original values before
|
* BE CAREFUL! if you wanna use full argc & argv, save their original values before
|
||||||
* calling this function
|
* calling this function
|
||||||
* @param options (i) - array of `myoption` for arguments parcing
|
* @param options (i) - array of `myoption` for arguments parcing
|
||||||
*
|
*
|
||||||
* @exit: in case of error this function show help & make `exit(-1)`
|
* @exit: in case of error this function show help & make `exit(-1)`
|
||||||
*/
|
*/
|
||||||
void parseargs(int *argc, char ***argv, myoption *options){
|
void parseargs(int *argc, char ***argv, myoption *options){
|
||||||
char *short_options, *soptr;
|
char *short_options, *soptr;
|
||||||
struct option *long_options, *loptr;
|
struct option *long_options, *loptr;
|
||||||
size_t optsize, i;
|
size_t optsize, i;
|
||||||
myoption *opts = options;
|
myoption *opts = options;
|
||||||
// check whether there is at least one options
|
// check whether there is at least one options
|
||||||
assert(opts);
|
assert(opts);
|
||||||
assert(opts[0].name);
|
assert(opts[0].name);
|
||||||
// first we count how much values are in opts
|
// first we count how much values are in opts
|
||||||
for(optsize = 0; opts->name; optsize++, opts++);
|
for(optsize = 0; opts->name; optsize++, opts++);
|
||||||
// now we can allocate memory
|
// now we can allocate memory
|
||||||
short_options = calloc(optsize * 3 + 1, 1); // multiply by three for '::' in case of args in opts
|
short_options = calloc(optsize * 3 + 1, 1); // multiply by three for '::' in case of args in opts
|
||||||
long_options = calloc(optsize + 1, sizeof(struct option));
|
long_options = calloc(optsize + 1, sizeof(struct option));
|
||||||
opts = options; loptr = long_options; soptr = short_options;
|
opts = options; loptr = long_options; soptr = short_options;
|
||||||
// in debug mode check the parameters are not repeated
|
// in debug mode check the parameters are not repeated
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
char **longlist = MALLOC(char*, optsize);
|
char **longlist = MALLOC(char*, optsize);
|
||||||
char *shortlist = MALLOC(char, optsize);
|
char *shortlist = MALLOC(char, optsize);
|
||||||
#endif
|
#endif
|
||||||
// fill short/long parameters and make a simple checking
|
// fill short/long parameters and make a simple checking
|
||||||
for(i = 0; i < optsize; i++, loptr++, opts++){
|
for(i = 0; i < optsize; i++, loptr++, opts++){
|
||||||
// check
|
// check
|
||||||
assert(opts->name); // check name
|
assert(opts->name); // check name
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
longlist[i] = strdup(opts->name);
|
longlist[i] = strdup(opts->name);
|
||||||
#endif
|
#endif
|
||||||
if(opts->has_arg){
|
if(opts->has_arg){
|
||||||
assert(opts->type != arg_none); // check error with arg type
|
assert(opts->type != arg_none); // check error with arg type
|
||||||
assert(opts->argptr); // check pointer
|
assert(opts->argptr); // check pointer
|
||||||
}
|
}
|
||||||
if(opts->type != arg_none) // if there is a flag without arg, check its pointer
|
if(opts->type != arg_none) // if there is a flag without arg, check its pointer
|
||||||
assert(opts->argptr);
|
assert(opts->argptr);
|
||||||
// fill long_options
|
// fill long_options
|
||||||
// don't do memcmp: what if there would be different alignment?
|
// don't do memcmp: what if there would be different alignment?
|
||||||
loptr->name = opts->name;
|
loptr->name = opts->name;
|
||||||
loptr->has_arg = (opts->has_arg < MULT_PAR) ? opts->has_arg : 1;
|
loptr->has_arg = (opts->has_arg < MULT_PAR) ? opts->has_arg : 1;
|
||||||
loptr->flag = opts->flag;
|
loptr->flag = opts->flag;
|
||||||
loptr->val = opts->val;
|
loptr->val = opts->val;
|
||||||
// fill short options if they are:
|
// fill short options if they are:
|
||||||
if(!opts->flag){
|
if(!opts->flag){
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
shortlist[i] = (char) opts->val;
|
shortlist[i] = (char) opts->val;
|
||||||
#endif
|
#endif
|
||||||
*soptr++ = opts->val;
|
*soptr++ = opts->val;
|
||||||
if(loptr->has_arg) // add ':' if option has required argument
|
if(loptr->has_arg) // add ':' if option has required argument
|
||||||
*soptr++ = ':';
|
*soptr++ = ':';
|
||||||
if(loptr->has_arg == 2) // add '::' if option has optional argument
|
if(loptr->has_arg == 2) // add '::' if option has optional argument
|
||||||
*soptr++ = ':';
|
*soptr++ = ':';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sort all lists & check for repeating
|
// sort all lists & check for repeating
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
int cmpstringp(const void *p1, const void *p2){
|
int cmpstringp(const void *p1, const void *p2){
|
||||||
return strcmp(* (char * const *) p1, * (char * const *) p2);
|
return strcmp(* (char * const *) p1, * (char * const *) p2);
|
||||||
}
|
}
|
||||||
int cmpcharp(const void *p1, const void *p2){
|
int cmpcharp(const void *p1, const void *p2){
|
||||||
return (int)(*(char * const)p1 - *(char *const)p2);
|
return (int)(*(char * const)p1 - *(char *const)p2);
|
||||||
}
|
}
|
||||||
qsort(longlist, optsize, sizeof(char *), cmpstringp);
|
qsort(longlist, optsize, sizeof(char *), cmpstringp);
|
||||||
qsort(shortlist,optsize, sizeof(char), cmpcharp);
|
qsort(shortlist,optsize, sizeof(char), cmpcharp);
|
||||||
char *prevl = longlist[0], prevshrt = shortlist[0];
|
char *prevl = longlist[0], prevshrt = shortlist[0];
|
||||||
for(i = 1; i < optsize; ++i){
|
for(i = 1; i < optsize; ++i){
|
||||||
if(longlist[i]){
|
if(longlist[i]){
|
||||||
if(prevl){
|
if(prevl){
|
||||||
if(strcmp(prevl, longlist[i]) == 0) ERRX("double long arguments: --%s", prevl);
|
if(strcmp(prevl, longlist[i]) == 0) ERRX("double long arguments: --%s", prevl);
|
||||||
}
|
}
|
||||||
prevl = longlist[i];
|
prevl = longlist[i];
|
||||||
}
|
}
|
||||||
if(shortlist[i]){
|
if(shortlist[i]){
|
||||||
if(prevshrt){
|
if(prevshrt){
|
||||||
if(prevshrt == shortlist[i]) ERRX("double short arguments: -%c", prevshrt);
|
if(prevshrt == shortlist[i]) ERRX("double short arguments: -%c", prevshrt);
|
||||||
}
|
}
|
||||||
prevshrt = shortlist[i];
|
prevshrt = shortlist[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// now we have both long_options & short_options and can parse `getopt_long`
|
// now we have both long_options & short_options and can parse `getopt_long`
|
||||||
while(1){
|
while(1){
|
||||||
int opt;
|
int opt;
|
||||||
int oindex = 0, optind = 0; // oindex - number of option in argv, optind - number in options[]
|
int oindex = 0, optind = 0; // oindex - number of option in argv, optind - number in options[]
|
||||||
if((opt = getopt_long(*argc, *argv, short_options, long_options, &oindex)) == -1) break;
|
if((opt = getopt_long(*argc, *argv, short_options, long_options, &oindex)) == -1) break;
|
||||||
if(opt == '?'){
|
if(opt == '?'){
|
||||||
opt = optopt;
|
opt = optopt;
|
||||||
optind = get_optind(opt, options);
|
optind = get_optind(opt, options);
|
||||||
if(options[optind].has_arg == NEED_ARG || options[optind].has_arg == MULT_PAR)
|
if(options[optind].has_arg == NEED_ARG || options[optind].has_arg == MULT_PAR)
|
||||||
showhelp(optind, options); // need argument
|
showhelp(optind, options); // need argument
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(opt == 0 || oindex > 0) optind = oindex;
|
if(opt == 0 || oindex > 0) optind = oindex;
|
||||||
else optind = get_optind(opt, options);
|
else optind = get_optind(opt, options);
|
||||||
}
|
}
|
||||||
opts = &options[optind];
|
opts = &options[optind];
|
||||||
if(opt == 0 && opts->has_arg == NO_ARGS) continue; // only long option changing integer flag
|
if(opt == 0 && opts->has_arg == NO_ARGS) continue; // only long option changing integer flag
|
||||||
// now check option
|
// now check option
|
||||||
if(opts->has_arg == NEED_ARG || opts->has_arg == MULT_PAR)
|
if(opts->has_arg == NEED_ARG || opts->has_arg == MULT_PAR)
|
||||||
if(!optarg) showhelp(optind, options); // need argument
|
if(!optarg) showhelp(optind, options); // need argument
|
||||||
void *aptr;
|
void *aptr;
|
||||||
if(opts->has_arg == MULT_PAR){
|
if(opts->has_arg == MULT_PAR){
|
||||||
aptr = get_aptr(opts->argptr, opts->type);
|
aptr = get_aptr(opts->argptr, opts->type);
|
||||||
}else
|
}else
|
||||||
aptr = opts->argptr;
|
aptr = opts->argptr;
|
||||||
bool result = TRUE;
|
bool result = TRUE;
|
||||||
// even if there is no argument, but argptr != NULL, think that optarg = "1"
|
// even if there is no argument, but argptr != NULL, think that optarg = "1"
|
||||||
if(!optarg) optarg = "1";
|
if(!optarg) optarg = "1";
|
||||||
switch(opts->type){
|
switch(opts->type){
|
||||||
default:
|
default:
|
||||||
case arg_none:
|
case arg_none:
|
||||||
if(opts->argptr) *((int*)aptr) += 1; // increment value
|
if(opts->argptr) *((int*)aptr) += 1; // increment value
|
||||||
break;
|
break;
|
||||||
case arg_int:
|
case arg_int:
|
||||||
result = myatoll(aptr, optarg, arg_int);
|
result = myatoll(aptr, optarg, arg_int);
|
||||||
break;
|
break;
|
||||||
case arg_longlong:
|
case arg_longlong:
|
||||||
result = myatoll(aptr, optarg, arg_longlong);
|
result = myatoll(aptr, optarg, arg_longlong);
|
||||||
break;
|
break;
|
||||||
case arg_double:
|
case arg_double:
|
||||||
result = myatod(aptr, optarg, arg_double);
|
result = myatod(aptr, optarg, arg_double);
|
||||||
break;
|
break;
|
||||||
case arg_float:
|
case arg_float:
|
||||||
result = myatod(aptr, optarg, arg_float);
|
result = myatod(aptr, optarg, arg_float);
|
||||||
break;
|
break;
|
||||||
case arg_string:
|
case arg_string:
|
||||||
result = (*((void**)aptr) = (void*)strdup(optarg));
|
result = (*((void**)aptr) = (void*)strdup(optarg));
|
||||||
break;
|
break;
|
||||||
case arg_function:
|
case arg_function:
|
||||||
result = ((argfn)aptr)(optarg);
|
result = ((argfn)aptr)(optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!result){
|
if(!result){
|
||||||
showhelp(optind, options);
|
showhelp(optind, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*argc -= optind;
|
*argc -= optind;
|
||||||
*argv += optind;
|
*argv += optind;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -335,19 +335,19 @@ void parseargs(int *argc, char ***argv, myoption *options){
|
|||||||
* first - sort by short options; second - sort arguments without sort opts (by long options)
|
* first - sort by short options; second - sort arguments without sort opts (by long options)
|
||||||
*/
|
*/
|
||||||
static int argsort(const void *a1, const void *a2){
|
static int argsort(const void *a1, const void *a2){
|
||||||
const myoption *o1 = (myoption*)a1, *o2 = (myoption*)a2;
|
const myoption *o1 = (myoption*)a1, *o2 = (myoption*)a2;
|
||||||
const char *l1 = o1->name, *l2 = o2->name;
|
const char *l1 = o1->name, *l2 = o2->name;
|
||||||
int s1 = o1->val, s2 = o2->val;
|
int s1 = o1->val, s2 = o2->val;
|
||||||
int *f1 = o1->flag, *f2 = o2->flag;
|
int *f1 = o1->flag, *f2 = o2->flag;
|
||||||
// check if both options has short arg
|
// check if both options has short arg
|
||||||
if(f1 == NULL && f2 == NULL){ // both have short arg
|
if(f1 == NULL && f2 == NULL){ // both have short arg
|
||||||
return (s1 - s2);
|
return (s1 - s2);
|
||||||
}else if(f1 != NULL && f2 != NULL){ // both don't have short arg - sort by long
|
}else if(f1 != NULL && f2 != NULL){ // both don't have short arg - sort by long
|
||||||
return strcmp(l1, l2);
|
return strcmp(l1, l2);
|
||||||
}else{ // only one have short arg -- return it
|
}else{ // only one have short arg -- return it
|
||||||
if(f2) return -1; // a1 have short - it is 'lesser'
|
if(f2) return -1; // a1 have short - it is 'lesser'
|
||||||
else return 1;
|
else return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -358,57 +358,57 @@ static int argsort(const void *a1, const void *a2){
|
|||||||
* @exit: run `exit(-1)` !!!
|
* @exit: run `exit(-1)` !!!
|
||||||
*/
|
*/
|
||||||
void showhelp(int oindex, myoption *options){
|
void showhelp(int oindex, myoption *options){
|
||||||
int max_opt_len = 0; // max len of options substring - for right indentation
|
int max_opt_len = 0; // max len of options substring - for right indentation
|
||||||
const int bufsz = 255;
|
const int bufsz = 255;
|
||||||
char buf[bufsz+1];
|
char buf[bufsz+1];
|
||||||
myoption *opts = options;
|
myoption *opts = options;
|
||||||
assert(opts);
|
assert(opts);
|
||||||
assert(opts[0].name); // check whether there is at least one options
|
assert(opts[0].name); // check whether there is at least one options
|
||||||
if(oindex > -1){ // print only one message
|
if(oindex > -1){ // print only one message
|
||||||
opts = &options[oindex];
|
opts = &options[oindex];
|
||||||
printf(" ");
|
printf(" ");
|
||||||
if(!opts->flag && isalpha(opts->val)) printf("-%c, ", opts->val);
|
if(!opts->flag && isalpha(opts->val)) printf("-%c, ", opts->val);
|
||||||
printf("--%s", opts->name);
|
printf("--%s", opts->name);
|
||||||
if(opts->has_arg == 1) printf("=arg");
|
if(opts->has_arg == 1) printf("=arg");
|
||||||
else if(opts->has_arg == 2) printf("[=arg]");
|
else if(opts->has_arg == 2) printf("[=arg]");
|
||||||
printf(" %s\n", _(opts->help));
|
printf(" %s\n", _(opts->help));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
// header, by default is just "progname\n"
|
// header, by default is just "progname\n"
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if(strstr(helpstring, "%s")) // print progname
|
if(strstr(helpstring, "%s")) // print progname
|
||||||
printf(helpstring, __progname);
|
printf(helpstring, __progname);
|
||||||
else // only text
|
else // only text
|
||||||
printf("%s", helpstring);
|
printf("%s", helpstring);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
// count max_opt_len
|
// count max_opt_len
|
||||||
do{
|
do{
|
||||||
int L = strlen(opts->name);
|
int L = strlen(opts->name);
|
||||||
if(max_opt_len < L) max_opt_len = L;
|
if(max_opt_len < L) max_opt_len = L;
|
||||||
}while((++opts)->name);
|
}while((++opts)->name);
|
||||||
max_opt_len += 14; // format: '-S , --long[=arg]' - get addition 13 symbols
|
max_opt_len += 14; // format: '-S , --long[=arg]' - get addition 13 symbols
|
||||||
opts = options;
|
opts = options;
|
||||||
// count amount of options
|
// count amount of options
|
||||||
int N; for(N = 0; opts->name; ++N, ++opts);
|
int N; for(N = 0; opts->name; ++N, ++opts);
|
||||||
if(N == 0) exit(-2);
|
if(N == 0) exit(-2);
|
||||||
// Now print all help (sorted)
|
// Now print all help (sorted)
|
||||||
opts = options;
|
opts = options;
|
||||||
qsort(opts, N, sizeof(myoption), argsort);
|
qsort(opts, N, sizeof(myoption), argsort);
|
||||||
do{
|
do{
|
||||||
int p = sprintf(buf, " "); // a little indent
|
int p = sprintf(buf, " "); // a little indent
|
||||||
if(!opts->flag) // .val is short argument
|
if(!opts->flag) // .val is short argument
|
||||||
p += snprintf(buf+p, bufsz-p, "-%c, ", opts->val);
|
p += snprintf(buf+p, bufsz-p, "-%c, ", opts->val);
|
||||||
p += snprintf(buf+p, bufsz-p, "--%s", opts->name);
|
p += snprintf(buf+p, bufsz-p, "--%s", opts->name);
|
||||||
if(opts->has_arg == 1) // required argument
|
if(opts->has_arg == 1) // required argument
|
||||||
p += snprintf(buf+p, bufsz-p, "=arg");
|
p += snprintf(buf+p, bufsz-p, "=arg");
|
||||||
else if(opts->has_arg == 2) // optional argument
|
else if(opts->has_arg == 2) // optional argument
|
||||||
p += snprintf(buf+p, bufsz-p, "[=arg]");
|
p += snprintf(buf+p, bufsz-p, "[=arg]");
|
||||||
assert(p < max_opt_len); // there would be magic if p >= max_opt_len
|
assert(p < max_opt_len); // there would be magic if p >= max_opt_len
|
||||||
printf("%-*s%s\n", max_opt_len+1, buf, _(opts->help)); // write options & at least 2 spaces after
|
printf("%-*s%s\n", max_opt_len+1, buf, _(opts->help)); // write options & at least 2 spaces after
|
||||||
++opts;
|
++opts;
|
||||||
}while(--N);
|
}while(--N);
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -418,80 +418,80 @@ void showhelp(int oindex, myoption *options){
|
|||||||
* @return TRUE if all OK
|
* @return TRUE if all OK
|
||||||
*/
|
*/
|
||||||
bool get_suboption(char *str, mysuboption *opt){
|
bool get_suboption(char *str, mysuboption *opt){
|
||||||
int findsubopt(char *par, mysuboption *so){
|
int findsubopt(char *par, mysuboption *so){
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
if(!par) return -1;
|
if(!par) return -1;
|
||||||
while(so[idx].name){
|
while(so[idx].name){
|
||||||
if(strcasecmp(par, so[idx].name) == 0) return idx;
|
if(strcasecmp(par, so[idx].name) == 0) return idx;
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
return -1; // badarg
|
return -1; // badarg
|
||||||
}
|
}
|
||||||
bool opt_setarg(mysuboption *so, int idx, char *val){
|
bool opt_setarg(mysuboption *so, int idx, char *val){
|
||||||
mysuboption *soptr = &so[idx];
|
mysuboption *soptr = &so[idx];
|
||||||
bool result = FALSE;
|
bool result = FALSE;
|
||||||
void *aptr = soptr->argptr;
|
void *aptr = soptr->argptr;
|
||||||
switch(soptr->type){
|
switch(soptr->type){
|
||||||
default:
|
default:
|
||||||
case arg_none:
|
case arg_none:
|
||||||
if(soptr->argptr) *((int*)aptr) += 1; // increment value
|
if(soptr->argptr) *((int*)aptr) += 1; // increment value
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
break;
|
break;
|
||||||
case arg_int:
|
case arg_int:
|
||||||
result = myatoll(aptr, val, arg_int);
|
result = myatoll(aptr, val, arg_int);
|
||||||
break;
|
break;
|
||||||
case arg_longlong:
|
case arg_longlong:
|
||||||
result = myatoll(aptr, val, arg_longlong);
|
result = myatoll(aptr, val, arg_longlong);
|
||||||
break;
|
break;
|
||||||
case arg_double:
|
case arg_double:
|
||||||
result = myatod(aptr, val, arg_double);
|
result = myatod(aptr, val, arg_double);
|
||||||
break;
|
break;
|
||||||
case arg_float:
|
case arg_float:
|
||||||
result = myatod(aptr, val, arg_float);
|
result = myatod(aptr, val, arg_float);
|
||||||
break;
|
break;
|
||||||
case arg_string:
|
case arg_string:
|
||||||
result = (*((void**)aptr) = (void*)strdup(val));
|
result = (*((void**)aptr) = (void*)strdup(val));
|
||||||
break;
|
break;
|
||||||
case arg_function:
|
case arg_function:
|
||||||
result = ((argfn)aptr)(val);
|
result = ((argfn)aptr)(val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
char *tok;
|
char *tok;
|
||||||
bool ret = FALSE;
|
bool ret = FALSE;
|
||||||
char *tmpbuf;
|
char *tmpbuf;
|
||||||
tok = strtok_r(str, ":,", &tmpbuf);
|
tok = strtok_r(str, ":,", &tmpbuf);
|
||||||
do{
|
do{
|
||||||
char *val = strchr(tok, '=');
|
char *val = strchr(tok, '=');
|
||||||
int noarg = 0;
|
int noarg = 0;
|
||||||
if(val == NULL){ // no args
|
if(val == NULL){ // no args
|
||||||
val = "1";
|
val = "1";
|
||||||
noarg = 1;
|
noarg = 1;
|
||||||
}else{
|
}else{
|
||||||
*val++ = '\0';
|
*val++ = '\0';
|
||||||
if(!*val || *val == ':' || *val == ','){ // no argument - delimeter after =
|
if(!*val || *val == ':' || *val == ','){ // no argument - delimeter after =
|
||||||
val = "1"; noarg = 1;
|
val = "1"; noarg = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int idx = findsubopt(tok, opt);
|
int idx = findsubopt(tok, opt);
|
||||||
if(idx < 0){
|
if(idx < 0){
|
||||||
/// "îÅÐÒÁ×ÉÌØÎÙÊ ÐÁÒÁÍÅÔÒ: %s"
|
/// "îÅÐÒÁ×ÉÌØÎÙÊ ÐÁÒÁÍÅÔÒ: %s"
|
||||||
WARNX(_("Wrong parameter: %s"), tok);
|
WARNX(_("Wrong parameter: %s"), tok);
|
||||||
goto returning;
|
goto returning;
|
||||||
}
|
}
|
||||||
if(noarg && opt[idx].has_arg == NEED_ARG){
|
if(noarg && opt[idx].has_arg == NEED_ARG){
|
||||||
/// "%s: ÎÅÏÂÈÏÄÉÍ ÁÒÇÕÍÅÎÔ!"
|
/// "%s: ÎÅÏÂÈÏÄÉÍ ÁÒÇÕÍÅÎÔ!"
|
||||||
WARNX(_("%s: argument needed!"), tok);
|
WARNX(_("%s: argument needed!"), tok);
|
||||||
goto returning;
|
goto returning;
|
||||||
}
|
}
|
||||||
if(!opt_setarg(opt, idx, val)){
|
if(!opt_setarg(opt, idx, val)){
|
||||||
/// "îÅÐÒÁ×ÉÌØÎÙÊ ÁÒÇÕÍÅÎÔ \"%s\" ÐÁÒÁÍÅÔÒÁ \"%s\""
|
/// "îÅÐÒÁ×ÉÌØÎÙÊ ÁÒÇÕÍÅÎÔ \"%s\" ÐÁÒÁÍÅÔÒÁ \"%s\""
|
||||||
WARNX(_("Wrong argument \"%s\" of parameter \"%s\""), val, tok);
|
WARNX(_("Wrong argument \"%s\" of parameter \"%s\""), val, tok);
|
||||||
goto returning;
|
goto returning;
|
||||||
}
|
}
|
||||||
}while((tok = strtok_r(NULL, ":,", &tmpbuf)));
|
}while((tok = strtok_r(NULL, ":,", &tmpbuf)));
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
returning:
|
returning:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,11 +26,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifndef TRUE
|
#ifndef TRUE
|
||||||
#define TRUE true
|
#define TRUE true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FALSE
|
#ifndef FALSE
|
||||||
#define FALSE false
|
#define FALSE false
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// macro for argptr
|
// macro for argptr
|
||||||
@ -44,35 +44,35 @@ typedef bool(*argfn)(void *arg);
|
|||||||
* WARNING!
|
* WARNING!
|
||||||
* My function change value of flags by pointer, so if you want to use another type
|
* My function change value of flags by pointer, so if you want to use another type
|
||||||
* make a latter conversion, example:
|
* make a latter conversion, example:
|
||||||
* char charg;
|
* char charg;
|
||||||
* int iarg;
|
* int iarg;
|
||||||
* myoption opts[] = {
|
* myoption opts[] = {
|
||||||
* {"value", 1, NULL, 'v', arg_int, &iarg, "char val"}, ..., end_option};
|
* {"value", 1, NULL, 'v', arg_int, &iarg, "char val"}, ..., end_option};
|
||||||
* ..(parse args)..
|
* ..(parse args)..
|
||||||
* charg = (char) iarg;
|
* charg = (char) iarg;
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
arg_none = 0, // no arg
|
arg_none = 0, // no arg
|
||||||
arg_int, // integer
|
arg_int, // integer
|
||||||
arg_longlong, // long long
|
arg_longlong, // long long
|
||||||
arg_double, // double
|
arg_double, // double
|
||||||
arg_float, // float
|
arg_float, // float
|
||||||
arg_string, // char *
|
arg_string, // char *
|
||||||
arg_function // parse_args will run function `bool (*fn)(char *optarg, int N)`
|
arg_function // parse_args will run function `bool (*fn)(char *optarg, int N)`
|
||||||
} argtype;
|
} argtype;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure for getopt_long & help
|
* Structure for getopt_long & help
|
||||||
* BE CAREFUL: .argptr is pointer to data or pointer to function,
|
* BE CAREFUL: .argptr is pointer to data or pointer to function,
|
||||||
* conversion depends on .type
|
* conversion depends on .type
|
||||||
*
|
*
|
||||||
* ATTENTION: string `help` prints through macro PRNT(), bu default it is gettext,
|
* ATTENTION: string `help` prints through macro PRNT(), bu default it is gettext,
|
||||||
* but you can redefine it before `#include "parseargs.h"`
|
* but you can redefine it before `#include "parseargs.h"`
|
||||||
*
|
*
|
||||||
* if arg is string, then value wil be strdup'ed like that:
|
* if arg is string, then value wil be strdup'ed like that:
|
||||||
* char *str;
|
* char *str;
|
||||||
* myoption opts[] = {{"string", 1, NULL, 's', arg_string, &str, "string val"}, ..., end_option};
|
* myoption opts[] = {{"string", 1, NULL, 's', arg_string, &str, "string val"}, ..., end_option};
|
||||||
* *(opts[1].str) = strdup(optarg);
|
* *(opts[1].str) = strdup(optarg);
|
||||||
* in other cases argptr should be address of some variable (or pointer to allocated memory)
|
* in other cases argptr should be address of some variable (or pointer to allocated memory)
|
||||||
*
|
*
|
||||||
* NON-NULL argptr should be written inside macro APTR(argptr) or directly: (void*)argptr
|
* NON-NULL argptr should be written inside macro APTR(argptr) or directly: (void*)argptr
|
||||||
@ -81,22 +81,22 @@ typedef enum {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef enum{
|
typedef enum{
|
||||||
NO_ARGS = 0, // first three are the same as in getopt_long
|
NO_ARGS = 0, // first three are the same as in getopt_long
|
||||||
NEED_ARG = 1,
|
NEED_ARG = 1,
|
||||||
OPT_ARG = 2,
|
OPT_ARG = 2,
|
||||||
MULT_PAR
|
MULT_PAR
|
||||||
} hasarg;
|
} hasarg;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
// these are from struct option:
|
// these are from struct option:
|
||||||
const char *name; // long option's name
|
const char *name; // long option's name
|
||||||
hasarg has_arg; // 0 - no args, 1 - nesessary arg, 2 - optionally arg, 4 - need arg & key can repeat (args are stored in null-terminated array)
|
hasarg has_arg; // 0 - no args, 1 - nesessary arg, 2 - optionally arg, 4 - need arg & key can repeat (args are stored in null-terminated array)
|
||||||
int *flag; // NULL to return val, pointer to int - to set its value of val (function returns 0)
|
int *flag; // NULL to return val, pointer to int - to set its value of val (function returns 0)
|
||||||
int val; // short opt name (if flag == NULL) or flag's value
|
int val; // short opt name (if flag == NULL) or flag's value
|
||||||
// and these are mine:
|
// and these are mine:
|
||||||
argtype type; // type of argument
|
argtype type; // type of argument
|
||||||
void *argptr; // pointer to variable to assign optarg value or function `bool (*fn)(char *optarg, int N)`
|
void *argptr; // pointer to variable to assign optarg value or function `bool (*fn)(char *optarg, int N)`
|
||||||
const char *help; // help string which would be shown in function `showhelp` or NULL
|
const char *help; // help string which would be shown in function `showhelp` or NULL
|
||||||
} myoption;
|
} myoption;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -104,10 +104,10 @@ typedef struct{
|
|||||||
* used in parse_subopts()
|
* used in parse_subopts()
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct{
|
||||||
const char *name;
|
const char *name;
|
||||||
hasarg has_arg;
|
hasarg has_arg;
|
||||||
argtype type;
|
argtype type;
|
||||||
void *argptr;
|
void *argptr;
|
||||||
} mysuboption;
|
} mysuboption;
|
||||||
|
|
||||||
// last string of array (all zeros)
|
// last string of array (all zeros)
|
||||||
|
|||||||
@ -26,11 +26,11 @@
|
|||||||
* @return double value: time in seconds
|
* @return double value: time in seconds
|
||||||
*/
|
*/
|
||||||
double dtime(){
|
double dtime(){
|
||||||
double t;
|
double t;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
t = tv.tv_sec + ((double)tv.tv_usec)/1e6;
|
t = tv.tv_sec + ((double)tv.tv_usec)/1e6;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
@ -50,22 +50,22 @@ int (*_WARN)(const char *fmt, ...);
|
|||||||
* @return number of printed symbols
|
* @return number of printed symbols
|
||||||
*/
|
*/
|
||||||
int r_pr_(const char *fmt, ...){
|
int r_pr_(const char *fmt, ...){
|
||||||
va_list ar; int i;
|
va_list ar; int i;
|
||||||
printf(RED);
|
printf(RED);
|
||||||
va_start(ar, fmt);
|
va_start(ar, fmt);
|
||||||
i = vprintf(fmt, ar);
|
i = vprintf(fmt, ar);
|
||||||
va_end(ar);
|
va_end(ar);
|
||||||
printf(OLDCOLOR);
|
printf(OLDCOLOR);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
int g_pr_(const char *fmt, ...){
|
int g_pr_(const char *fmt, ...){
|
||||||
va_list ar; int i;
|
va_list ar; int i;
|
||||||
printf(GREEN);
|
printf(GREEN);
|
||||||
va_start(ar, fmt);
|
va_start(ar, fmt);
|
||||||
i = vprintf(fmt, ar);
|
i = vprintf(fmt, ar);
|
||||||
va_end(ar);
|
va_end(ar);
|
||||||
printf(OLDCOLOR);
|
printf(OLDCOLOR);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* print red error/warning messages (if output is a tty)
|
* print red error/warning messages (if output is a tty)
|
||||||
@ -73,20 +73,20 @@ int g_pr_(const char *fmt, ...){
|
|||||||
* @return number of printed symbols
|
* @return number of printed symbols
|
||||||
*/
|
*/
|
||||||
int r_WARN(const char *fmt, ...){
|
int r_WARN(const char *fmt, ...){
|
||||||
va_list ar; int i = 1;
|
va_list ar; int i = 1;
|
||||||
fprintf(stderr, RED);
|
fprintf(stderr, RED);
|
||||||
va_start(ar, fmt);
|
va_start(ar, fmt);
|
||||||
if(globErr){
|
if(globErr){
|
||||||
errno = globErr;
|
errno = globErr;
|
||||||
vwarn(fmt, ar);
|
vwarn(fmt, ar);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
globErr = 0;
|
globErr = 0;
|
||||||
}else
|
}else
|
||||||
i = vfprintf(stderr, fmt, ar);
|
i = vfprintf(stderr, fmt, ar);
|
||||||
va_end(ar);
|
va_end(ar);
|
||||||
i++;
|
i++;
|
||||||
fprintf(stderr, OLDCOLOR "\n");
|
fprintf(stderr, OLDCOLOR "\n");
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char stars[] = "****************************************";
|
static const char stars[] = "****************************************";
|
||||||
@ -97,49 +97,49 @@ static const char stars[] = "****************************************";
|
|||||||
* @return number of printed symbols
|
* @return number of printed symbols
|
||||||
*/
|
*/
|
||||||
int s_WARN(const char *fmt, ...){
|
int s_WARN(const char *fmt, ...){
|
||||||
va_list ar; int i;
|
va_list ar; int i;
|
||||||
i = fprintf(stderr, "\n%s\n", stars);
|
i = fprintf(stderr, "\n%s\n", stars);
|
||||||
va_start(ar, fmt);
|
va_start(ar, fmt);
|
||||||
if(globErr){
|
if(globErr){
|
||||||
errno = globErr;
|
errno = globErr;
|
||||||
vwarn(fmt, ar);
|
vwarn(fmt, ar);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
globErr = 0;
|
globErr = 0;
|
||||||
}else
|
}else
|
||||||
i = +vfprintf(stderr, fmt, ar);
|
i = +vfprintf(stderr, fmt, ar);
|
||||||
va_end(ar);
|
va_end(ar);
|
||||||
i += fprintf(stderr, "\n%s\n", stars);
|
i += fprintf(stderr, "\n%s\n", stars);
|
||||||
i += fprintf(stderr, "\n");
|
i += fprintf(stderr, "\n");
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
int r_pr_notty(const char *fmt, ...){
|
int r_pr_notty(const char *fmt, ...){
|
||||||
va_list ar; int i;
|
va_list ar; int i;
|
||||||
i = printf("\n%s\n", stars);
|
i = printf("\n%s\n", stars);
|
||||||
va_start(ar, fmt);
|
va_start(ar, fmt);
|
||||||
i += vprintf(fmt, ar);
|
i += vprintf(fmt, ar);
|
||||||
va_end(ar);
|
va_end(ar);
|
||||||
i += printf("\n%s\n", stars);
|
i += printf("\n%s\n", stars);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run this function in the beginning of main() to setup locale & coloured output
|
* Run this function in the beginning of main() to setup locale & coloured output
|
||||||
*/
|
*/
|
||||||
void initial_setup(){
|
void initial_setup(){
|
||||||
// setup coloured output
|
// setup coloured output
|
||||||
if(isatty(STDOUT_FILENO)){ // make color output in tty
|
if(isatty(STDOUT_FILENO)){ // make color output in tty
|
||||||
red = r_pr_; green = g_pr_;
|
red = r_pr_; green = g_pr_;
|
||||||
}else{ // no colors in case of pipe
|
}else{ // no colors in case of pipe
|
||||||
red = r_pr_notty; green = printf;
|
red = r_pr_notty; green = printf;
|
||||||
}
|
}
|
||||||
if(isatty(STDERR_FILENO)) _WARN = r_WARN;
|
if(isatty(STDERR_FILENO)) _WARN = r_WARN;
|
||||||
else _WARN = s_WARN;
|
else _WARN = s_WARN;
|
||||||
// Setup locale
|
// Setup locale
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
setlocale(LC_NUMERIC, "C");
|
setlocale(LC_NUMERIC, "C");
|
||||||
#if defined GETTEXT_PACKAGE && defined LOCALEDIR
|
#if defined GETTEXT_PACKAGE && defined LOCALEDIR
|
||||||
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
||||||
textdomain(GETTEXT_PACKAGE);
|
textdomain(GETTEXT_PACKAGE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,10 +153,10 @@ void initial_setup(){
|
|||||||
* @return pointer to allocated memory area
|
* @return pointer to allocated memory area
|
||||||
*/
|
*/
|
||||||
void *my_alloc(size_t N, size_t S){
|
void *my_alloc(size_t N, size_t S){
|
||||||
void *p = calloc(N, S);
|
void *p = calloc(N, S);
|
||||||
if(!p) ERR("malloc");
|
if(!p) ERR("malloc");
|
||||||
//assert(p);
|
//assert(p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,35 +166,35 @@ void *my_alloc(size_t N, size_t S){
|
|||||||
* @return stuct with mmap'ed file or die
|
* @return stuct with mmap'ed file or die
|
||||||
*/
|
*/
|
||||||
mmapbuf *My_mmap(char *filename){
|
mmapbuf *My_mmap(char *filename){
|
||||||
int fd;
|
int fd;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
size_t Mlen;
|
size_t Mlen;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
/// "îÅ ÚÁÄÁÎÏ ÉÍÑ ÆÁÊÌÁ!"
|
/// "îÅ ÚÁÄÁÎÏ ÉÍÑ ÆÁÊÌÁ!"
|
||||||
if(!filename) ERRX(_("No filename given!"));
|
if(!filename) ERRX(_("No filename given!"));
|
||||||
if((fd = open(filename, O_RDONLY)) < 0)
|
if((fd = open(filename, O_RDONLY)) < 0)
|
||||||
/// "îÅ ÍÏÇÕ ÏÔËÒÙÔØ %s ÄÌÑ ÞÔÅÎÉÑ"
|
/// "îÅ ÍÏÇÕ ÏÔËÒÙÔØ %s ÄÌÑ ÞÔÅÎÉÑ"
|
||||||
ERR(_("Can't open %s for reading"), filename);
|
ERR(_("Can't open %s for reading"), filename);
|
||||||
if(fstat (fd, &statbuf) < 0)
|
if(fstat (fd, &statbuf) < 0)
|
||||||
/// "îÅ ÍÏÇÕ ×ÙÐÏÌÎÉÔØ stat %s"
|
/// "îÅ ÍÏÇÕ ×ÙÐÏÌÎÉÔØ stat %s"
|
||||||
ERR(_("Can't stat %s"), filename);
|
ERR(_("Can't stat %s"), filename);
|
||||||
Mlen = statbuf.st_size;
|
Mlen = statbuf.st_size;
|
||||||
if((ptr = mmap (0, Mlen, PROT_READ, MAP_PRIVATE, fd, 0)) == MAP_FAILED)
|
if((ptr = mmap (0, Mlen, PROT_READ, MAP_PRIVATE, fd, 0)) == MAP_FAILED)
|
||||||
/// "ïÛÉÂËÁ mmap"
|
/// "ïÛÉÂËÁ mmap"
|
||||||
ERR(_("Mmap error for input"));
|
ERR(_("Mmap error for input"));
|
||||||
/// "îÅ ÍÏÇÕ ÚÁËÒÙÔØ mmap'ÎÕÔÙÊ ÆÁÊÌ"
|
/// "îÅ ÍÏÇÕ ÚÁËÒÙÔØ mmap'ÎÕÔÙÊ ÆÁÊÌ"
|
||||||
if(close(fd)) ERR(_("Can't close mmap'ed file"));
|
if(close(fd)) ERR(_("Can't close mmap'ed file"));
|
||||||
mmapbuf *ret = MALLOC(mmapbuf, 1);
|
mmapbuf *ret = MALLOC(mmapbuf, 1);
|
||||||
ret->data = ptr;
|
ret->data = ptr;
|
||||||
ret->len = Mlen;
|
ret->len = Mlen;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void My_munmap(mmapbuf *b){
|
void My_munmap(mmapbuf *b){
|
||||||
if(munmap(b->data, b->len))
|
if(munmap(b->data, b->len))
|
||||||
/// "îÅ ÍÏÇÕ munmap"
|
/// "îÅ ÍÏÇÕ munmap"
|
||||||
ERR(_("Can't munmap"));
|
ERR(_("Can't munmap"));
|
||||||
FREE(b);
|
FREE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -205,24 +205,24 @@ static struct termios oldt, newt; // terminal flags
|
|||||||
static int console_changed = 0;
|
static int console_changed = 0;
|
||||||
// run on exit:
|
// run on exit:
|
||||||
void restore_console(){
|
void restore_console(){
|
||||||
if(console_changed)
|
if(console_changed)
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // return terminal to previous state
|
tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // return terminal to previous state
|
||||||
console_changed = 0;
|
console_changed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initial setup:
|
// initial setup:
|
||||||
void setup_con(){
|
void setup_con(){
|
||||||
if(console_changed) return;
|
if(console_changed) return;
|
||||||
tcgetattr(STDIN_FILENO, &oldt);
|
tcgetattr(STDIN_FILENO, &oldt);
|
||||||
newt = oldt;
|
newt = oldt;
|
||||||
newt.c_lflag &= ~(ICANON | ECHO);
|
newt.c_lflag &= ~(ICANON | ECHO);
|
||||||
if(tcsetattr(STDIN_FILENO, TCSANOW, &newt) < 0){
|
if(tcsetattr(STDIN_FILENO, TCSANOW, &newt) < 0){
|
||||||
/// "îÅ ÍÏÇÕ ÎÁÓÔÒÏÉÔØ ËÏÎÓÏÌØ"
|
/// "îÅ ÍÏÇÕ ÎÁÓÔÒÏÉÔØ ËÏÎÓÏÌØ"
|
||||||
WARN(_("Can't setup console"));
|
WARN(_("Can't setup console"));
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
|
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
|
||||||
signals(0); //quit?
|
signals(0); //quit?
|
||||||
}
|
}
|
||||||
console_changed = 1;
|
console_changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,20 +230,20 @@ void setup_con(){
|
|||||||
* @return char readed
|
* @return char readed
|
||||||
*/
|
*/
|
||||||
int read_console(){
|
int read_console(){
|
||||||
int rb;
|
int rb;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int retval;
|
int retval;
|
||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
FD_SET(STDIN_FILENO, &rfds);
|
FD_SET(STDIN_FILENO, &rfds);
|
||||||
tv.tv_sec = 0; tv.tv_usec = 10000;
|
tv.tv_sec = 0; tv.tv_usec = 10000;
|
||||||
retval = select(1, &rfds, NULL, NULL, &tv);
|
retval = select(1, &rfds, NULL, NULL, &tv);
|
||||||
if(!retval) rb = 0;
|
if(!retval) rb = 0;
|
||||||
else {
|
else {
|
||||||
if(FD_ISSET(STDIN_FILENO, &rfds)) rb = getchar();
|
if(FD_ISSET(STDIN_FILENO, &rfds)) rb = getchar();
|
||||||
else rb = 0;
|
else rb = 0;
|
||||||
}
|
}
|
||||||
return rb;
|
return rb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,10 +252,10 @@ int read_console(){
|
|||||||
* @return character readed
|
* @return character readed
|
||||||
*/
|
*/
|
||||||
int mygetchar(){ // getchar() without need of pressing ENTER
|
int mygetchar(){ // getchar() without need of pressing ENTER
|
||||||
int ret;
|
int ret;
|
||||||
do ret = read_console();
|
do ret = read_console();
|
||||||
while(ret == 0);
|
while(ret == 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -267,10 +267,10 @@ static int comfd = -1; // TTY fd
|
|||||||
|
|
||||||
// run on exit:
|
// run on exit:
|
||||||
void restore_tty(){
|
void restore_tty(){
|
||||||
if(comfd == -1) return;
|
if(comfd == -1) return;
|
||||||
ioctl(comfd, TCSANOW, &oldtty ); // return TTY to previous state
|
ioctl(comfd, TCSANOW, &oldtty ); // return TTY to previous state
|
||||||
close(comfd);
|
close(comfd);
|
||||||
comfd = -1;
|
comfd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BAUD_RATE
|
#ifndef BAUD_RATE
|
||||||
@ -278,31 +278,31 @@ void restore_tty(){
|
|||||||
#endif
|
#endif
|
||||||
// init:
|
// init:
|
||||||
void tty_init(char *comdev){
|
void tty_init(char *comdev){
|
||||||
DBG("\nOpen port...\n");
|
DBG("\nOpen port...\n");
|
||||||
if ((comfd = open(comdev,O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0){
|
if ((comfd = open(comdev,O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0){
|
||||||
WARN("Can't use port %s\n",comdev);
|
WARN("Can't use port %s\n",comdev);
|
||||||
ioctl(comfd, TCSANOW, &oldtty); // return TTY to previous state
|
ioctl(comfd, TCSANOW, &oldtty); // return TTY to previous state
|
||||||
close(comfd);
|
close(comfd);
|
||||||
signals(0); // quit?
|
signals(0); // quit?
|
||||||
}
|
}
|
||||||
DBG(" OK\nGet current settings... ");
|
DBG(" OK\nGet current settings... ");
|
||||||
if(ioctl(comfd,TCGETA,&oldtty) < 0){ // Get settings
|
if(ioctl(comfd,TCGETA,&oldtty) < 0){ // Get settings
|
||||||
/// "îÅ ÍÏÇÕ ÐÏÌÕÞÉÔØ ÎÁÓÔÒÏÊËÉ"
|
/// "îÅ ÍÏÇÕ ÐÏÌÕÞÉÔØ ÎÁÓÔÒÏÊËÉ"
|
||||||
WARN(_("Can't get settings"));
|
WARN(_("Can't get settings"));
|
||||||
signals(0);
|
signals(0);
|
||||||
}
|
}
|
||||||
tty = oldtty;
|
tty = oldtty;
|
||||||
tty.c_lflag = 0; // ~(ICANON | ECHO | ECHOE | ISIG)
|
tty.c_lflag = 0; // ~(ICANON | ECHO | ECHOE | ISIG)
|
||||||
tty.c_oflag = 0;
|
tty.c_oflag = 0;
|
||||||
tty.c_cflag = BAUD_RATE|CS8|CREAD|CLOCAL; // 9.6k, 8N1, RW, ignore line ctrl
|
tty.c_cflag = BAUD_RATE|CS8|CREAD|CLOCAL; // 9.6k, 8N1, RW, ignore line ctrl
|
||||||
tty.c_cc[VMIN] = 0; // non-canonical mode
|
tty.c_cc[VMIN] = 0; // non-canonical mode
|
||||||
tty.c_cc[VTIME] = 5;
|
tty.c_cc[VTIME] = 5;
|
||||||
if(ioctl(comfd,TCSETA,&tty) < 0){
|
if(ioctl(comfd,TCSETA,&tty) < 0){
|
||||||
/// "îÅ ÍÏÇÕ ÕÓÔÁÎÏ×ÉÔØ ÎÁÓÔÒÏÊËÉ"
|
/// "îÅ ÍÏÇÕ ÕÓÔÁÎÏ×ÉÔØ ÎÁÓÔÒÏÊËÉ"
|
||||||
WARN(_("Can't set settings"));
|
WARN(_("Can't set settings"));
|
||||||
signals(0);
|
signals(0);
|
||||||
}
|
}
|
||||||
DBG(" OK\n");
|
DBG(" OK\n");
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Read data from TTY
|
* Read data from TTY
|
||||||
@ -311,26 +311,26 @@ void tty_init(char *comdev){
|
|||||||
* @return amount of readed bytes
|
* @return amount of readed bytes
|
||||||
*/
|
*/
|
||||||
size_t read_tty(uint8_t *buff, size_t length){
|
size_t read_tty(uint8_t *buff, size_t length){
|
||||||
ssize_t L = 0;
|
ssize_t L = 0;
|
||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int retval;
|
int retval;
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
FD_SET(comfd, &rfds);
|
FD_SET(comfd, &rfds);
|
||||||
tv.tv_sec = 0; tv.tv_usec = 50000; // wait for 50ms
|
tv.tv_sec = 0; tv.tv_usec = 50000; // wait for 50ms
|
||||||
retval = select(comfd + 1, &rfds, NULL, NULL, &tv);
|
retval = select(comfd + 1, &rfds, NULL, NULL, &tv);
|
||||||
if (!retval) return 0;
|
if (!retval) return 0;
|
||||||
if(FD_ISSET(comfd, &rfds)){
|
if(FD_ISSET(comfd, &rfds)){
|
||||||
if((L = read(comfd, buff, length)) < 1) return 0;
|
if((L = read(comfd, buff, length)) < 1) return 0;
|
||||||
}
|
}
|
||||||
return (size_t)L;
|
return (size_t)L;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_tty(uint8_t *buff, size_t length){
|
int write_tty(uint8_t *buff, size_t length){
|
||||||
ssize_t L = write(comfd, buff, length);
|
ssize_t L = write(comfd, buff, length);
|
||||||
if((size_t)L != length){
|
if((size_t)L != length){
|
||||||
WARN("Write error!");
|
WARN("Write error!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,12 +38,12 @@
|
|||||||
* GETTEXT
|
* GETTEXT
|
||||||
*/
|
*/
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#define _(String) gettext(String)
|
#define _(String) gettext(String)
|
||||||
#define gettext_noop(String) String
|
#define gettext_noop(String) String
|
||||||
#define N_(String) gettext_noop(String)
|
#define N_(String) gettext_noop(String)
|
||||||
#else
|
#else
|
||||||
#define _(String) (String)
|
#define _(String) (String)
|
||||||
#define N_(String) (String)
|
#define N_(String) (String)
|
||||||
#endif
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
@ -59,9 +59,9 @@
|
|||||||
/*
|
/*
|
||||||
* Coloured messages output
|
* Coloured messages output
|
||||||
*/
|
*/
|
||||||
#define RED "\033[1;31;40m"
|
#define RED "\033[1;31;40m"
|
||||||
#define GREEN "\033[1;32;40m"
|
#define GREEN "\033[1;32;40m"
|
||||||
#define OLDCOLOR "\033[0;0;0m"
|
#define OLDCOLOR "\033[0;0;0m"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ERROR/WARNING messages
|
* ERROR/WARNING messages
|
||||||
@ -78,13 +78,13 @@ extern void signals(int sig);
|
|||||||
* debug mode, -DEBUG
|
* debug mode, -DEBUG
|
||||||
*/
|
*/
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
#define FNAME() fprintf(stderr, "\n%s (%s, line %d)\n", __func__, __FILE__, __LINE__)
|
#define FNAME() fprintf(stderr, "\n%s (%s, line %d)\n", __func__, __FILE__, __LINE__)
|
||||||
#define DBG(...) do{fprintf(stderr, "%s (%s, line %d): ", __func__, __FILE__, __LINE__); \
|
#define DBG(...) do{fprintf(stderr, "%s (%s, line %d): ", __func__, __FILE__, __LINE__); \
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
fprintf(stderr, "\n");} while(0)
|
fprintf(stderr, "\n");} while(0)
|
||||||
#else
|
#else
|
||||||
#define FNAME() do{}while(0)
|
#define FNAME() do{}while(0)
|
||||||
#define DBG(...) do{}while(0)
|
#define DBG(...) do{}while(0)
|
||||||
#endif //EBUG
|
#endif //EBUG
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -92,7 +92,7 @@ extern void signals(int sig);
|
|||||||
*/
|
*/
|
||||||
#define ALLOC(type, var, size) type * var = ((type *)my_alloc(size, sizeof(type)))
|
#define ALLOC(type, var, size) type * var = ((type *)my_alloc(size, sizeof(type)))
|
||||||
#define MALLOC(type, size) ((type *)my_alloc(size, sizeof(type)))
|
#define MALLOC(type, size) ((type *)my_alloc(size, sizeof(type)))
|
||||||
#define FREE(ptr) do{if(ptr){free(ptr); ptr = NULL;}}while(0)
|
#define FREE(ptr) do{free(ptr); ptr = NULL;}while(0)
|
||||||
|
|
||||||
double dtime();
|
double dtime();
|
||||||
|
|
||||||
@ -105,8 +105,8 @@ void initial_setup();
|
|||||||
|
|
||||||
// mmap file
|
// mmap file
|
||||||
typedef struct{
|
typedef struct{
|
||||||
char *data;
|
char *data;
|
||||||
size_t len;
|
size_t len;
|
||||||
} mmapbuf;
|
} mmapbuf;
|
||||||
mmapbuf *My_mmap(char *filename);
|
mmapbuf *My_mmap(char *filename);
|
||||||
void My_munmap(mmapbuf *b);
|
void My_munmap(mmapbuf *b);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/*
|
/* geany_encoding=koi8-r
|
||||||
* parseargs.c - parsing command line arguments & print help
|
* parseargs.c - parsing command line arguments & print help
|
||||||
*
|
*
|
||||||
* Copyright 2013 Edward V. Emelianoff <eddy@sao.ru>
|
* Copyright 2013 Edward V. Emelianoff <eddy@sao.ru>
|
||||||
@ -286,7 +286,7 @@ void parseargs(int *argc, char ***argv, myoption *options){
|
|||||||
else optind = get_optind(opt, options);
|
else optind = get_optind(opt, options);
|
||||||
}
|
}
|
||||||
opts = &options[optind];
|
opts = &options[optind];
|
||||||
//if(opt == 0 && opts->has_arg == NO_ARGS) continue; // only long option changing integer flag
|
// if(opt == 0 && opts->has_arg == NO_ARGS) continue; // only long option changing integer flag
|
||||||
// now check option
|
// now check option
|
||||||
if(opts->has_arg == NEED_ARG || opts->has_arg == MULT_PAR)
|
if(opts->has_arg == NEED_ARG || opts->has_arg == MULT_PAR)
|
||||||
if(!optarg) showhelp(optind, options); // need argument
|
if(!optarg) showhelp(optind, options); // need argument
|
||||||
|
|||||||
@ -168,8 +168,6 @@ void server_(int sock){
|
|||||||
}
|
}
|
||||||
// Main loop
|
// Main loop
|
||||||
while(1){
|
while(1){
|
||||||
fd_set readfds;
|
|
||||||
struct timeval timeout;
|
|
||||||
socklen_t size = sizeof(struct sockaddr_in);
|
socklen_t size = sizeof(struct sockaddr_in);
|
||||||
struct sockaddr_in their_addr;
|
struct sockaddr_in their_addr;
|
||||||
int newsock;
|
int newsock;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user