little fix

This commit is contained in:
eddyem
2016-12-29 16:12:14 +03:00
parent edcc1fd563
commit ce21cb7e10
43 changed files with 80 additions and 77 deletions

View File

@@ -1,5 +1,5 @@
/*
* cmdlnopts.c - the only function that parce cmdln args and returns glob parameters
* cmdlnopts.c - the only function that parse cmdln args and returns glob parameters
*
* Copyright 2013 Edward V. Emelianoff <eddy@sao.ru>
*
@@ -93,13 +93,13 @@ myoption cmdlnopts[] = {
/**
* Parce command line options and return dynamically allocated structure
* Parse command line options and return dynamically allocated structure
* to global parameters
* @param argc - copy of argc from main
* @param argv - copy of argv from main
* @return allocated structure with global parameters
*/
glob_pars *parce_args(int argc, char **argv){
glob_pars *parse_args(int argc, char **argv){
int i;
void *ptr;
ptr = memcpy(&G, &Gdefault, sizeof(G)); assert(ptr);
@@ -107,7 +107,7 @@ glob_pars *parce_args(int argc, char **argv){
/// "éÓÐÏÌØÚÏ×ÁÎÉÅ: %s [ÁÒÇÕÍÅÎÔÙ]\n\n\tçÄÅ ÁÒÇÕÍÅÎÔÙ:\n"
change_helpstring(_("Usage: %s [args]\n\n\tWhere args are:\n"));
// parse arguments
parceargs(&argc, &argv, cmdlnopts);
parseargs(&argc, &argv, cmdlnopts);
if(help) showhelp(-1, cmdlnopts);
if(argc > 0){
/// "éÇÎÏÒÉÒÕÀ ÁÒÇÕÍÅÎÔ[Ù]:"

View File

@@ -1,5 +1,5 @@
/*
* cmdlnopts.h - comand line options for parceargs
* cmdlnopts.h - comand line options for parseargs
*
* Copyright 2013 Edward V. Emelianoff <eddy@sao.ru>
*
@@ -23,7 +23,7 @@
#ifndef __CMDLNOPTS_H__
#define __CMDLNOPTS_H__
#include "parceargs.h"
#include "parseargs.h"
/*
* here are some typedef's for global data
@@ -35,6 +35,6 @@ typedef struct{
double relmove; // move relative current position
}glob_pars;
glob_pars *parce_args(int argc, char **argv);
glob_pars *parse_args(int argc, char **argv);
#endif // __CMDLNOPTS_H__

View File

@@ -235,7 +235,7 @@ int main(int argc, char *argv[]){
char buff[BUFLEN+1];
pthread_t motor_thread;
size_t L;
Global_parameters = parce_args(argc, argv);
Global_parameters = parse_args(argc, argv);
assert(Global_parameters != NULL);
if(!get_shm_block(&sdat, ClientSide) || !check_shm_block(&sdat)){
fprintf(stderr, "Can't get SHM block!");

View File

@@ -1,5 +1,5 @@
/*
* parceargs.c - parcing command line arguments & print help
* parseargs.c - parsing command line arguments & print help
*
* Copyright 2013 Edward V. Emelianoff <eddy@sao.ru>
*
@@ -27,7 +27,7 @@
#include <limits.h> // INT_MAX & so on
#include <libintl.h>// gettext
#include <ctype.h> // isalpha
#include "parceargs.h"
#include "parseargs.h"
// macro to print help messages
#ifndef PRNT
@@ -135,7 +135,7 @@ int get_optind(int opt, myoption *options){
}
/**
* Parce command line arguments
* Parse command line arguments
* ! If arg is string, then value will be strdup'ed!
*
* @param argc (io) - address of argc of main(), return value of argc stay after `getopt`
@@ -146,7 +146,7 @@ int get_optind(int opt, myoption *options){
*
* @exit: in case of error this function show help & make `exit(-1)`
*/
void parceargs(int *argc, char ***argv, myoption *options){
void parseargs(int *argc, char ***argv, myoption *options){
char *short_options, *soptr;
struct option *long_options, *loptr;
size_t optsize, i;
@@ -247,7 +247,7 @@ void parceargs(int *argc, char ***argv, myoption *options){
*/
void showhelp(int oindex, myoption *options){
// ATTENTION: string `help` prints through macro PRNT(), by default it is gettext,
// but you can redefine it before `#include "parceargs.h"`
// but you can redefine it before `#include "parseargs.h"`
int max_opt_len = 0; // max len of options substring - for right indentation
const int bufsz = 255;
char buf[bufsz+1];

View File

@@ -1,5 +1,5 @@
/*
* parceargs.h - headers for parcing command line arguments
* parseargs.h - headers for parcing command line arguments
*
* Copyright 2013 Edward V. Emelianoff <eddy@sao.ru>
*
@@ -19,8 +19,8 @@
* MA 02110-1301, USA.
*/
#pragma once
#ifndef __PARCEARGS_H__
#define __PARCEARGS_H__
#ifndef __PARSEARGS_H__
#define __PARSEARGS_H__
#include <stdbool.h>// bool
#include <stdlib.h>
@@ -48,7 +48,7 @@ typedef bool(*argfn)(void *arg, int N);
* int iarg;
* myoption opts[] = {
* {"value", 1, NULL, 'v', arg_int, &iarg, "char val"}, ..., end_option};
* ..(parce args)..
* ..(parse args)..
* charg = (char) iarg;
*/
typedef enum {
@@ -58,7 +58,7 @@ typedef enum {
arg_double, // double
arg_float, // float
arg_string, // char *
arg_function // parce_args will run function `bool (*fn)(char *optarg, int N)`
arg_function // parse_args will run function `bool (*fn)(char *optarg, int N)`
} argtype;
/*
@@ -67,7 +67,7 @@ typedef enum {
* conversion depends on .type
*
* ATTENTION: string `help` prints through macro PRNT(), bu default it is gettext,
* but you can redefine it before `#include "parceargs.h"`
* but you can redefine it before `#include "parseargs.h"`
*
* if arg is string, then value wil be strdup'ed like that:
* char *str;
@@ -99,8 +99,8 @@ typedef struct{
extern const char *__progname;
void showhelp(int oindex, myoption *options);
void parceargs(int *argc, char ***argv, myoption *options);
void parseargs(int *argc, char ***argv, myoption *options);
void change_helpstring(char *s);
bool myatod(void *num, const char *str, argtype t);
#endif // __PARCEARGS_H__
#endif // __PARSEARGS_H__