[Olsr-dev] [PATCH v1 000/115] Merge common code from jsoninfo and txtinfo

Ferry Huberts (spam-protected)
Wed Dec 2 21:27:33 CET 2015


From: Ferry Huberts <(spam-protected)>

It's here, and a lot of good fun I had doing these 115 patches </sarcasm>.

Anyway, it's a lot of shuffling code around, beating it into shape, and then
some more shuffling around.

Patch 43 does the actual merge of common code into the info module.
Everything after that is cleanup and optimisation resulting from review.

There are also some actual fixes in this series, highlights:

008: applies the same fix to jsoninfo as e2149e7
011: use a standard function instead of a homebrewn one for a jsoninfo parameter
066: make sure that output buffers are correctly cleaned up and freed, their
     sockets properly closed
092: close the ipc socket on error paths
096: check against the correct __linux__ define
107: show float/double values in full precision in jsoninfo

I've cleaned up the info, jsoninfo and txtinfo modules and reviewed them.
The only thing it didn't clean up and review yet are the ipc_print_* functions
of both jsoninfo and txtinfo. That will come later.

Feedback welcome.


Ferry Huberts (115):
  txtinfo: use the same 'c-basic-offset: 2' as jsoninfo
  txtinfo: treat the olsrd configuration differently
  txtinfo: catch '/all' earlier when determining the action
  txtinfo: send the information in the runtime and startup groups for
    '/all'
  txtinfo: '/ver' and '/neighbours' are specials when determining the
    action
  txtinfo: add (unsupported) commands '/config' and '/plugins'
  txtinfo: add /runtime and /startup commands
  jsoninfo: INADDR_LOOPBACK is in host format and the socket address is
    not
  jsoninfo: fix PLUGIN_NAME that is reported on plugin init
  jsoninfo: initialise uuidfile as well
  jsoninfo: use standard set_plugin_string function for uuidfile
    parameter
  jsoninfo: reorder some includes
  jsoninfo: fix some indents
  jsoninfo: add Freifunk neighbours special case, like txtinfo
  txtinfo: move http header related functions into common code
  jsoninfo: move http header related functions into common code
  txtinfo: move determining the action into a separate function
  jsoninfo: move determining the action into a separate function
  txtinfo: add plugin_init hook
  jsoninfo: add plugin_init hook
  txtinfo: move ipc_print_* functions into a 'printers' unit
  jsoninfo: move ipc_print_* functions into a 'printers' unit
  txtinfo: use a table of function pointers in send_info
  jsoninfo: use a table of function pointers in send_info
  txtinfo: move SIW_x defines into common code
  jsoninfo: move SIW_x defines into common code
  txtinfo: wrap the outbuffer in a struct for easier usage
  jsoninfo: wrap the outbuffer in a struct for easier usage
  jsoninfo: only need to reset entry number for json output
  txtinfo: determine the mime type via the functions table
  jsoninfo: determine the mime type via the functions table
  txtinfo: put the plugin init hook in the functions table
  jsoninfo: put the plugin init hook in the functions table
  txtinfo: put command parsing in the functions table
  jsoninfo: put command parsing in the functions table
  txtinfo: put output start/end in the functions table
  jsoninfo: put output start/end in the functions table
  txtinfo: convert INFO_ALLOW_LOCALHOST define into a plugin parameter
  jsoninfo: convert INFO_ALLOW_LOCALHOST define into a plugin parameter
  txtinfo: convert ACTIVATE_VTIME_TXTINFO into a plugin parameter
  txtinfo: wrap generic info plugin configuration in a struct
  jsoninfo: wrap generic info plugin configuration in a struct
  info: merge jsoninfo and txtinfo common code
  Makefile: add pseudo plugin info
  txtinfo: move code from olsr_txtinfo into olsr_plugin
  jsoninfo: move code from olsr_jsoninfo into olsr_plugin
  info: code formatting
  info: rename some http header function parameters
  info: rename type printer_functions_t to info_plugin_functions_t
  info: rename variable printer_functions to functions
  txtinfo: rename variable printer_functions to functions
  jsoninfo: rename variable printer_functions to functions
  info: rename type outbuffer_t to info_plugin_outbuffer_t
  info: do not export info_plugin_outbuffer_t, only used internally
  info: rename header files recursive include guards
  info: rename a http header function
  info: update copyrights
  jsoninfo: rename info_plugin_config to config
  txtinfo: rename info_plugin_config to config
  info: rename a function parameter
  info: rename info_plugin_config to config
  info: rename PLUGIN_NAME to name
  info: rename a function
  info: add some asserts
  info: remove some comments
  info: ensure all variables are correctly initialised and cleaned up
  info: use a define for the info_plugin_config_t plugin parameters
  jsoninfo: rename 'printers' unit
  txtinfo: rename 'printers' unit
  info: split out neighbors and 2hop printer functions
  info: rename a function prototype
  info: minor formatting fix
  info: there can only be a single command, optimise determine_action
  info: write_data: exit early if there is nothing to send
  info: write_data: do not add invalid sockets to the FD set
  info: write_data: add a comment
  info: write_data: properly clean up an output buffer
  info: write_data: do not consider an invalid socket for send
  info: write_data: use a safer 'close the socket' condition
  info: write_data: do not move buffers around
  info: ipc_action: rename 2 variables
  info: ipc_action: move inet_ntop out of condition blocks
  info: ipc_action: only use addr in debug builds
  info: ipc_action: minor simplification
  info: ipc_action: merge 2 if statements
  info: ipc_action: make the IPv6 if statement like the IPv4 one
  info: ipc_action: use a static sink buffer
  info: ipc_action: use a safer 'oversize' comparison
  info: ipc_action: minor fix
  info: plugin_ipc_init: rename 2 variables
  info: plugin_ipc_init: 'unelse' an else branch, the if already returns
  info: plugin_ipc_init: close the ipc_socket on the error paths
  info: plugin_ipc_init: fix a perror message
  info: plugin_ipc_init: merge 2 if statements
  info: http headers: add some asserts
  info: check against the correct __linux__ define
  txtinfo: rename header files recursive include guards
  jsoninfo: rename header files recursive include guards
  txtinfo: remove some unused includes
  jsoninfo: remove some unused includes
  info: add a function to initialise the config
  txtinfo: use the function to initialise the config
  jsoninfo: use the function to initialise the config
  jsoninfo: helpers: minor simplification of abuf_json_new_indent
  jsoninfo: helpers: firm up asserts on currentjsondepth
  jsoninfo: helpers: use abuf_json_insert_comma
  jsoninfo: helpers: output floats in full precision
  jsoninfo: helpers: fix output format for int/long
  jsoninfo: helpers: use an actual bool as parameter for
    abuf_json_boolean
  jsoninfo: helpers: get_string_from_file ensures '\0' in the first byte
  jsoninfo: helpers: use sizeof() for buffers
  jsoninfo: helpers: use a double as parameter for abuf_json_float
  jsoninfo: helpers: use sizeof() for uuid size
  txtinfo: define the vtime extern in the proper place
  jsoninfo: define the uuidfile extern in the proper place

 Makefile                                           |  24 +-
 lib/info/Makefile                                  |  17 +
 lib/info/README_INFO                               |   4 +
 lib/info/http_headers.c                            | 108 +++
 src/bsd/apm.c => lib/info/http_headers.h           |  37 +-
 lib/info/info_types.h                              | 141 ++++
 lib/info/olsrd_info.c                              | 505 ++++++++++++
 src/lq_mpr.h => lib/info/olsrd_info.h              |  20 +-
 lib/jsoninfo/Makefile                              |   3 +
 lib/jsoninfo/README_JSONINFO                       |  13 +-
 lib/jsoninfo/src/olsrd_jsoninfo.c                  | 866 ++++++---------------
 lib/jsoninfo/src/olsrd_jsoninfo.h                  |  55 +-
 lib/jsoninfo/src/olsrd_jsoninfo_helpers.c          |  63 +-
 lib/jsoninfo/src/olsrd_jsoninfo_helpers.h          |  13 +-
 lib/jsoninfo/src/olsrd_plugin.c                    |  91 ++-
 .../src/olsrd_plugin.h}                            |  14 +-
 lib/txtinfo/Makefile                               |   3 +
 lib/txtinfo/README_TXTINFO                         |   6 +
 lib/txtinfo/src/olsrd_plugin.c                     |  87 ++-
 .../src/olsrd_plugin.h}                            |  14 +-
 lib/txtinfo/src/olsrd_txtinfo.c                    | 677 +++-------------
 lib/txtinfo/src/olsrd_txtinfo.h                    |  50 +-
 22 files changed, 1378 insertions(+), 1433 deletions(-)
 create mode 100644 lib/info/Makefile
 create mode 100644 lib/info/README_INFO
 create mode 100644 lib/info/http_headers.c
 copy src/bsd/apm.c => lib/info/http_headers.h (79%)
 create mode 100644 lib/info/info_types.h
 create mode 100644 lib/info/olsrd_info.c
 copy src/lq_mpr.h => lib/info/olsrd_info.h (84%)
 copy lib/{dot_draw/src/olsrd_dot_draw.h => jsoninfo/src/olsrd_plugin.h} (90%)
 copy lib/{dot_draw/src/olsrd_dot_draw.h => txtinfo/src/olsrd_plugin.h} (91%)

-- 
2.5.0




More information about the Olsr-dev mailing list