Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
moberg
Commits
99355b76
Commit
99355b76
authored
Feb 22, 2019
by
Anders Blomdell
Browse files
Name shortening
parent
c8715ad3
Changes
12
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
99355b76
...
...
@@ -42,12 +42,12 @@ test: all
clean
:
find build
-type
f
-delete
rm
*
~
rm
-f
*
~
build/libmoberg.so
:
build/lib/moberg_config.o
build/libmoberg.so
:
build/lib/moberg_device.o
build/libmoberg.so
:
build/lib/moberg_
config_
parser.o
build/libmoberg.so
:
build/lib/moberg_parser.o
build/lib/moberg_device.o
:
moberg_device.h
build/parse_config.o
:
moberg_
config_
parser.h
build/parse_config.o
:
moberg_parser.h
parse_config
:
build/moberg_driver.o
parse_config
:
build/parse_config.o
moberg.c
View file @
99355b76
...
...
@@ -12,7 +12,7 @@
#include
<string.h>
#include
<moberg.h>
#include
<moberg_config.h>
#include
<moberg_
config_
parser.h>
#include
<moberg_parser.h>
struct
moberg_digital_in_t
{
int
index
;
...
...
moberg_config_parser_module.h
deleted
100644 → 0
View file @
c8715ad3
#ifndef __MOBERG_CONFIG_PARSER_MODULE_H__
#define __MOBERG_CONFIG_PARSER_MODULE_H__
#include
<stdio.h>
#include
<moberg_config_parser.h>
struct
moberg_config_parser_token
;
enum
moberg_config_parser_token_kind
{
tok_none
,
tok_EOF
,
tok_LPAREN
,
tok_RPAREN
,
tok_LBRACE
,
tok_RBRACE
,
tok_LBRACKET
,
tok_RBRACKET
,
tok_EQUAL
,
tok_COMMA
,
tok_COLON
,
tok_SEMICOLON
,
tok_INTEGER
,
tok_IDENT
,
tok_STRING
,
};
struct
moberg_config_parser_ident
{
int
length
;
const
char
*
value
;
};
struct
moberg_config_parser_token
{
enum
moberg_config_parser_token_kind
kind
;
union
{
struct
moberg_config_parser_ident
ident
;
struct
moberg_config_parser_ident
string
;
struct
moberg_config_parser_integer
{
int
value
;
}
integer
;
}
u
;
};
int
moberg_config_parser_acceptsym
(
struct
moberg_config_parser_context
*
c
,
enum
moberg_config_parser_token_kind
kind
,
struct
moberg_config_parser_token
*
token
);
int
moberg_config_parser_acceptkeyword
(
struct
moberg_config_parser_context
*
c
,
const
char
*
keyword
);
void
moberg_config_parser_failed
(
struct
moberg_config_parser_context
*
c
,
FILE
*
f
);
#endif
moberg_device.c
View file @
99355b76
...
...
@@ -56,7 +56,7 @@ void moberg_device_free(struct moberg_device *device)
}
int
moberg_device_parse_config
(
struct
moberg_device
*
device
,
struct
moberg_
config_
parser_context
*
context
)
struct
moberg_parser_context
*
context
)
{
return
device
->
driver
.
parse_config
(
device
,
context
);
}
...
...
@@ -73,7 +73,7 @@ int moberg_device_set_config(struct moberg_device *device,
}
int
moberg_device_parse_map
(
struct
moberg_device
*
device
,
struct
moberg_
config_
parser_context
*
context
,
struct
moberg_parser_context
*
context
,
struct
moberg_device_map_range
range
)
{
int
result
;
...
...
moberg_device.h
View file @
99355b76
...
...
@@ -2,7 +2,7 @@
#define __MOBERG_DEVICE_H__
#include
<moberg_config.h>
#include
<moberg_
config_
parser.h>
#include
<moberg_parser.h>
struct
moberg_device_map_range
{
enum
moberg_device_map_kind
{
...
...
@@ -51,17 +51,17 @@ struct moberg_device_encoder_in {
int
(
*
read
)(
struct
moberg_device_encoder_in_context
*
,
long
*
value
);
};
struct
moberg_
config_
parser_context
;
struct
moberg_parser_context
;
struct
moberg_device
;
struct
moberg_device_config
;
struct
moberg_device_driver
{
int
(
*
parse_config
)(
struct
moberg_device
*
device
,
struct
moberg_
config_
parser_context
*
context
);
struct
moberg_parser_context
*
context
);
int
(
*
parse_map
)(
struct
moberg_device
*
device
,
struct
moberg_
config_
parser_context
*
context
,
struct
moberg_parser_context
*
context
,
enum
moberg_device_map_kind
kind
);
int
(
*
config_free
)(
struct
moberg_device_config
*
config
);
...
...
@@ -74,13 +74,13 @@ struct moberg_device *moberg_device_new(const char *driver);
void
moberg_device_free
(
struct
moberg_device
*
device
);
int
moberg_device_parse_config
(
struct
moberg_device
*
device
,
struct
moberg_
config_
parser_context
*
context
);
struct
moberg_parser_context
*
context
);
int
moberg_device_set_config
(
struct
moberg_device
*
device
,
struct
moberg_device_config
*
config
);
int
moberg_device_parse_map
(
struct
moberg_device
*
device
,
struct
moberg_
config_
parser_context
*
context
,
struct
moberg_parser_context
*
context
,
struct
moberg_device_map_range
range
);
int
moberg_device_add_analog_in
(
struct
moberg_device
*
device
,
...
...
moberg_module.h
0 → 100644
View file @
99355b76
#ifndef __MOBERG_MODULE_H__
#define __MOBERG_MODULE_H__
#include
<stdio.h>
#include
<moberg_parser.h>
struct
moberg_parser_token
;
enum
moberg_parser_token_kind
{
tok_none
,
tok_EOF
,
tok_LPAREN
,
tok_RPAREN
,
tok_LBRACE
,
tok_RBRACE
,
tok_LBRACKET
,
tok_RBRACKET
,
tok_EQUAL
,
tok_COMMA
,
tok_COLON
,
tok_SEMICOLON
,
tok_INTEGER
,
tok_IDENT
,
tok_STRING
,
};
struct
moberg_parser_ident
{
int
length
;
const
char
*
value
;
};
struct
moberg_parser_integer
{
int
value
;
};
struct
moberg_parser_token
{
enum
moberg_parser_token_kind
kind
;
union
{
struct
moberg_parser_ident
ident
;
struct
moberg_parser_ident
string
;
struct
moberg_parser_integer
integer
;
}
u
;
};
int
moberg_parser_acceptsym
(
struct
moberg_parser_context
*
c
,
enum
moberg_parser_token_kind
kind
,
struct
moberg_parser_token
*
token
);
int
moberg_parser_acceptkeyword
(
struct
moberg_parser_context
*
c
,
const
char
*
keyword
);
void
moberg_parser_failed
(
struct
moberg_parser_context
*
c
,
FILE
*
f
);
#endif
moberg_
config_
parser.c
→
moberg_parser.c
View file @
99355b76
...
...
@@ -5,17 +5,17 @@
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<moberg_
config_
parser.h>
#include
<moberg_
config_parser_
module.h>
#include
<moberg_parser.h>
#include
<moberg_module.h>
#include
<moberg_device.h>
typedef
enum
moberg_
config_
parser_token_kind
kind_t
;
typedef
struct
moberg_
config_
parser_token
token_t
;
typedef
struct
moberg_
config_
parser_ident
ident_t
;
typedef
enum
moberg_parser_token_kind
kind_t
;
typedef
struct
moberg_parser_token
token_t
;
typedef
struct
moberg_parser_ident
ident_t
;
#define MAX_EXPECTED 10
typedef
struct
moberg_
config_
parser_context
{
typedef
struct
moberg_parser_context
{
struct
moberg_config
*
config
;
const
char
*
buf
;
/* Pointer to data to be parsed */
const
char
*
p
;
/* current parse location */
...
...
@@ -31,13 +31,13 @@ static inline int acceptsym(context_t *c,
kind_t
kind
,
token_t
*
token
)
{
return
moberg_
config_
parser_acceptsym
(
c
,
kind
,
token
);
return
moberg_parser_acceptsym
(
c
,
kind
,
token
);
}
static
inline
int
acceptkeyword
(
context_t
*
c
,
const
char
*
keyword
)
{
return
moberg_
config_
parser_acceptkeyword
(
c
,
keyword
);
return
moberg_parser_acceptkeyword
(
c
,
keyword
);
}
static
const
void
nextsym_ident
(
context_t
*
c
)
...
...
@@ -190,7 +190,7 @@ static int peeksym(context_t *c,
return
0
;
}
int
moberg_
config_
parser_acceptsym
(
context_t
*
c
,
int
moberg_parser_acceptsym
(
context_t
*
c
,
kind_t
kind
,
token_t
*
token
)
{
...
...
@@ -229,7 +229,7 @@ int moberg_config_parser_acceptsym(context_t *c,
return
0
;
}
int
moberg_
config_
parser_acceptkeyword
(
context_t
*
c
,
int
moberg_parser_acceptkeyword
(
context_t
*
c
,
const
char
*
keyword
)
{
token_t
t
;
...
...
@@ -246,8 +246,8 @@ int moberg_config_parser_acceptkeyword(context_t *c,
return
0
;
}
void
moberg_
config_
parser_failed
(
struct
moberg_
config_
parser_context
*
c
,
void
moberg_parser_failed
(
struct
moberg_parser_context
*
c
,
FILE
*
f
)
{
fprintf
(
f
,
"EXPECTED "
);
...
...
@@ -307,7 +307,7 @@ static int parse_map_range(context_t *c,
range
->
max
=
max
.
u
.
integer
.
value
;
return
1
;
syntax_err:
moberg_
config_
parser_failed
(
c
,
stderr
);
moberg_parser_failed
(
c
,
stderr
);
err:
return
0
;
}
...
...
@@ -329,7 +329,7 @@ static int parse_map(context_t *c,
if
(
!
acceptsym
(
c
,
tok_SEMICOLON
,
NULL
))
{
goto
syntax_err
;
}
return
1
;
syntax_err:
moberg_
config_
parser_failed
(
c
,
stderr
);
moberg_parser_failed
(
c
,
stderr
);
err:
return
0
;
}
...
...
@@ -356,7 +356,7 @@ static int parse_device(context_t *c,
}
return
1
;
syntax_err:
moberg_
config_
parser_failed
(
c
,
stderr
);
moberg_parser_failed
(
c
,
stderr
);
err:
return
0
;
}
...
...
@@ -397,7 +397,7 @@ static int parse(context_t *c)
}
return
1
;
syntax_err:
moberg_
config_
parser_failed
(
c
,
stderr
);
moberg_parser_failed
(
c
,
stderr
);
goto
err
;
err:
return
0
;
...
...
moberg_
config_
parser.h
→
moberg_parser.h
View file @
99355b76
#ifndef __MOBERG_
CONFIG_
PARSER_H__
#define __MOBERG_
CONFIG_
PARSER_H__
#ifndef __MOBERG_PARSER_H__
#define __MOBERG_PARSER_H__
#include
<moberg_config.h>
struct
moberg_
config_
parser_context
;
struct
moberg_parser_context
;
struct
moberg_config
*
moberg_config_parse
(
const
char
*
buf
);
...
...
modules/comedi/Makefile
View file @
99355b76
...
...
@@ -8,4 +8,4 @@ all: $(LIBRARIES:%=../../build/%)
../../build/libmoberg_comedi.so
:
comedi.c Makefile
$(CC)
-o
$@
$(CCFLAGS)
-shared
-fPIC
$<
../../build/libmoberg_comedi.so
:
../../moberg_
config_parser_
module.h
../../build/libmoberg_comedi.so
:
../../moberg_module.h
modules/comedi/comedi.c
View file @
99355b76
#include
<moberg_config.h>
#include
<moberg_
config_
parser.h>
#include
<moberg_
config_parser_
module.h>
#include
<moberg_parser.h>
#include
<moberg_module.h>
#include
<moberg_device.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
typedef
enum
moberg_
config_
parser_token_kind
kind_t
;
typedef
struct
moberg_
config_
parser_token
token_t
;
typedef
struct
moberg_
config_
parser_ident
ident_t
;
typedef
struct
moberg_
config_
parser_context
context_t
;
typedef
enum
moberg_parser_token_kind
kind_t
;
typedef
struct
moberg_parser_token
token_t
;
typedef
struct
moberg_parser_ident
ident_t
;
typedef
struct
moberg_parser_context
context_t
;
struct
moberg_device_map
{};
struct
moberg_device_config
{
...
...
@@ -20,18 +20,18 @@ static inline int acceptsym(context_t *c,
kind_t
kind
,
token_t
*
token
)
{
return
moberg_
config_
parser_acceptsym
(
c
,
kind
,
token
);
return
moberg_parser_acceptsym
(
c
,
kind
,
token
);
}
static
inline
int
acceptkeyword
(
context_t
*
c
,
const
char
*
keyword
)
{
return
moberg_
config_
parser_acceptkeyword
(
c
,
keyword
);
return
moberg_parser_acceptkeyword
(
c
,
keyword
);
}
static
int
parse_config
(
struct
moberg_device
*
device
,
struct
moberg_
config_
parser_context
*
c
)
struct
moberg_parser_context
*
c
)
{
struct
moberg_device_config
*
config
=
malloc
(
sizeof
*
config
);
if
(
!
config
)
{
...
...
@@ -81,7 +81,7 @@ static int parse_config(
moberg_device_set_config
(
device
,
config
);
return
1
;
syntax_err:
moberg_
config_
parser_failed
(
c
,
stderr
);
moberg_parser_failed
(
c
,
stderr
);
free
(
config
);
err:
return
0
;
...
...
@@ -89,7 +89,7 @@ err:
static
int
parse_map
(
struct
moberg_device
*
device
,
struct
moberg_
config_
parser_context
*
c
,
struct
moberg_parser_context
*
c
,
enum
moberg_device_map_kind
kind
)
{
token_t
min
,
max
;
...
...
@@ -138,7 +138,7 @@ static int parse_map(
if
(
!
acceptsym
(
c
,
tok_RBRACE
,
NULL
))
{
goto
err
;
}
return
1
;
err:
moberg_
config_
parser_failed
(
c
,
stderr
);
moberg_parser_failed
(
c
,
stderr
);
return
0
;
}
...
...
modules/serial2002/Makefile
View file @
99355b76
...
...
@@ -8,4 +8,4 @@ all: $(LIBRARIES:%=../../build/%)
../../build/libmoberg_serial2002.so
:
serial2002.c Makefile
$(CC)
-o
$@
$(CCFLAGS)
-shared
-fPIC
$<
../../build/libmoberg_serial2002.so
:
../../moberg_
config_parser_
module.h
../../build/libmoberg_serial2002.so
:
../../moberg_module.h
modules/serial2002/serial2002.c
View file @
99355b76
#include
<moberg_config.h>
#include
<moberg_
config_
parser.h>
#include
<moberg_
config_parser_
module.h>
#include
<moberg_parser.h>
#include
<moberg_module.h>
#include
<moberg_device.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
typedef
enum
moberg_
config_
parser_token_kind
kind_t
;
typedef
struct
moberg_
config_
parser_token
token_t
;
typedef
struct
moberg_
config_
parser_context
context_t
;
typedef
enum
moberg_parser_token_kind
kind_t
;
typedef
struct
moberg_parser_token
token_t
;
typedef
struct
moberg_parser_context
context_t
;
static
inline
int
acceptsym
(
context_t
*
c
,
kind_t
kind
,
token_t
*
token
)
{
return
moberg_
config_
parser_acceptsym
(
c
,
kind
,
token
);
return
moberg_parser_acceptsym
(
c
,
kind
,
token
);
}
static
inline
int
acceptkeyword
(
context_t
*
c
,
const
char
*
keyword
)
{
return
moberg_
config_
parser_acceptkeyword
(
c
,
keyword
);
return
moberg_parser_acceptkeyword
(
c
,
keyword
);
}
struct
moberg_device_config
{
...
...
@@ -30,7 +30,7 @@ struct moberg_device_config {
static
int
parse_config
(
struct
moberg_device
*
device
,
struct
moberg_
config_
parser_context
*
c
)
struct
moberg_parser_context
*
c
)
{
struct
moberg_device_config
*
config
=
malloc
(
sizeof
*
config
);
if
(
!
config
)
{
...
...
@@ -60,7 +60,7 @@ static int parse_config(
moberg_device_set_config
(
device
,
config
);
return
1
;
syntax_err:
moberg_
config_
parser_failed
(
c
,
stderr
);
moberg_parser_failed
(
c
,
stderr
);
free
(
config
);
err:
return
0
;
...
...
@@ -68,7 +68,7 @@ err:
static
int
parse_map
(
struct
moberg_device
*
device
,
struct
moberg_
config_
parser_context
*
c
,
struct
moberg_parser_context
*
c
,
enum
moberg_device_map_kind
ignore
)
{
enum
moberg_device_map_kind
kind
;
...
...
@@ -109,7 +109,7 @@ static int parse_map(
}
return
1
;
syntax_err:
moberg_
config_
parser_failed
(
c
,
stderr
);
moberg_parser_failed
(
c
,
stderr
);
return
0
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment