[OpenSIPS-Devel] [OpenSIPS/opensips] d6780d: DEV-1 (Pluggable Preprocessor): Prepare code layout

Liviu Chircu noreply at github.com
Fri Feb 22 09:20:35 EST 2019


  Branch: refs/heads/master
  Home:   https://github.com/OpenSIPS/opensips
  Commit: d6780db16e43086cc4f5220f2c2a50f77f16bfbf
      https://github.com/OpenSIPS/opensips/commit/d6780db16e43086cc4f5220f2c2a50f77f16bfbf
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-02-21 (Thu, 21 Feb 2019)

  Changed paths:
    A cfg.c
    A cfg.h
    M help_msg.h
    M main.c

  Log Message:
  -----------
  DEV-1 (Pluggable Preprocessor): Prepare code layout

    * add/document new "-p" (preprocessor) cmdline option
    * hook the new "-p" option into the parsing code
    * re-organize cfg file managing code into a separate file


  Commit: e83904d75666eca38dbb0f16350e7531d5c76d4e
      https://github.com/OpenSIPS/opensips/commit/e83904d75666eca38dbb0f16350e7531d5c76d4e
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-02-21 (Thu, 21 Feb 2019)

  Changed paths:
    M cfg.c
    M main.c

  Log Message:
  -----------
  DEV-1: Implement config file flattening + adnotations

The main idea is to be able to feed the preprocessor with a contiguous
stream of input.  The consequence of doing this is that we must
pre-resolve all "include_file" statements by creating one large cfg
file, in a process called "flattening".

Example of flattening + adnotation:

------ cfg/opensips-3.0-preproc-1.cfg ------
log_level = 4
log_stderror = yes

include_file "cfg/opensips-3.0-preproc-2.cfg"
loadmodule "tm.so"
include_file "cfg/opensips-3.0-preproc-4.cfg"
loadmodule "dialog.so"

------ cfg/opensips-3.0-preproc-2.cfg ------
listen = udp:*:5060
include_file "cfg/opensips-3.0-preproc-3.cfg"

------ cfg/opensips-3.0-preproc-3.cfg ------
mpath = "modules/"
loadmodule "proto_udp.so"

------ cfg/opensips-3.0-preproc-4.cfg ------
loadmodule "usrloc.so"

These four files with nested includes will be flattened into this beast:
---------------------------------------------------
__OSSPP_FILEBEGIN__ "cfg/opensips-3.0-preproc-1.cfg"
__OSSPP_LINE__ 1
log_level = 4
__OSSPP_LINE__ 2
log_stderror = yes
__OSSPP_LINE__ 3

__OSSPP_LINE__ 4
__OSSPP_FILEBEGIN__ "cfg/opensips-3.0-preproc-2.cfg"
__OSSPP_LINE__ 1
listen = udp:*:5060
__OSSPP_LINE__ 2
__OSSPP_FILEBEGIN__ "cfg/opensips-3.0-preproc-3.cfg"
__OSSPP_LINE__ 1
mpath = "modules/"
__OSSPP_LINE__ 2
loadmodule "proto_udp.so"
__OSSPP_FILEEND__
__OSSPP_FILEEND__
__OSSPP_LINE__ 5
loadmodule "tm.so"
__OSSPP_LINE__ 6
__OSSPP_FILEBEGIN__ "cfg/opensips-3.0-preproc-4.cfg"
__OSSPP_LINE__ 1
loadmodule "usrloc.so"
__OSSPP_FILEEND__
__OSSPP_LINE__ 7
loadmodule "dialog.so"
__OSSPP_FILEEND__
---------------------------------------------------


  Commit: 3050f7c57f779538980f0e1a4d5e09dac778e3e6
      https://github.com/OpenSIPS/opensips/commit/3050f7c57f779538980f0e1a4d5e09dac778e3e6
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-02-21 (Thu, 21 Feb 2019)

  Changed paths:
    R cfg.c
    R cfg.h
    M cfg.lex
    M cfg.y
    A cfg_pp.c
    A cfg_pp.h
    M main.c

  Log Message:
  -----------
  DEV-1: Hook the newly added logic into lexer/parser


  Commit: 9f251028a8d92076abb8d9929c28f9fa9daa3770
      https://github.com/OpenSIPS/opensips/commit/9f251028a8d92076abb8d9929c28f9fa9daa3770
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-02-21 (Thu, 21 Feb 2019)

  Changed paths:
    M cfg.lex

  Log Message:
  -----------
  DEV-1: Clear deprecated "stacked Yacc buffers" logic


  Commit: 5405515f1ba3e0e2b283eab912493b653d43dc9d
      https://github.com/OpenSIPS/opensips/commit/5405515f1ba3e0e2b283eab912493b653d43dc9d
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-02-21 (Thu, 21 Feb 2019)

  Changed paths:
    M cfg.y
    M cfg_pp.c
    M cfg_pp.h

  Log Message:
  -----------
  DEV-1: Display a file inclusion backtrace on syntax errors


  Commit: 46491c764cdb9b68269ca298d2098c484a07b9fe
      https://github.com/OpenSIPS/opensips/commit/46491c764cdb9b68269ca298d2098c484a07b9fe
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-02-22 (Fri, 22 Feb 2019)

  Changed paths:
    M cfg.lex
    M cfg_pp.c

  Log Message:
  -----------
  DEV-1: Various fixes

    * avoid unnecessary strdup operation
    * do not close file streams multiple times
    * fix buffer size for final config file
    * remove unused lexer tokens


  Commit: 55e874ff3ddea54b54ecfe8561836f9331871102
      https://github.com/OpenSIPS/opensips/commit/55e874ff3ddea54b54ecfe8561836f9331871102
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-02-22 (Fri, 22 Feb 2019)

  Changed paths:
    M cfg_pp.c

  Log Message:
  -----------
  DEV-1: Avoid printing the include trace multiple times


  Commit: 134424deabb8fecaa4863a952d8149d8d4db675a
      https://github.com/OpenSIPS/opensips/commit/134424deabb8fecaa4863a952d8149d8d4db675a
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-02-22 (Fri, 22 Feb 2019)

  Changed paths:
    M cfg.lex
    M cfg.y
    M cfg_pp.c
    M cfg_pp.h

  Log Message:
  -----------
  DEV-1: Digest the pp tokens within lexer, not parser!

Using the lexer to consume the preprocessor tokens makes life so much
easier, as otherwise the complexity of the scripting language grammer
would skyrocket.  Example problem which is avoided by this:

if
<pp_token may go here>
(
<pp_token may go here>
condition
<pp_token may go here>
)
<pp_token may go here>
{
<pp_token may go here>
$var(x) = 5;
<pp_token may go here>
}

Although the coding style is horrible, this is still valid script
syntax, but, all of a sudden, the grammar must be extended in order to
support random tokens on any possible line of this "if" statement.
Nope, not going there.  Just use the lexer to eat the tokens and be done
with the problem!


  Commit: 3162d504593ecf7989567d469a582a4e210ec89d
      https://github.com/OpenSIPS/opensips/commit/3162d504593ecf7989567d469a582a4e210ec89d
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-02-22 (Fri, 22 Feb 2019)

  Changed paths:
    M cfg_pp.c

  Log Message:
  -----------
  DEV-1: Exec the preprocessor cmdline; Feed output to Yacc


  Commit: fd9c65072eec0bef941dbaf123e53a4f6bd0629c
      https://github.com/OpenSIPS/opensips/commit/fd9c65072eec0bef941dbaf123e53a4f6bd0629c
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-02-22 (Fri, 22 Feb 2019)

  Changed paths:
    M cfg.lex
    M cfg.y
    A cfg_pp.c
    A cfg_pp.h
    M help_msg.h
    M main.c

  Log Message:
  -----------
  Merge branch 'feature/pluggable-preprocessor'


Compare: https://github.com/OpenSIPS/opensips/compare/ec89b7866743...fd9c65072eec



More information about the Devel mailing list