<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/24262">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vty: Introduce API vty_read_config_filep<br><br>This new API doesn't use host_config_set(), and allows passing a FILE*<br>from any source, not only a filesystem path.<br><br>Related: SYS#5369<br>Change-Id: I720ac04386261628c0798a1bfcaa91e2490a86c3<br>---<br>M TODO-RELEASE<br>M include/osmocom/vty/vty.h<br>M src/vty/vty.c<br>3 files changed, 11 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/TODO-RELEASE b/TODO-RELEASE</span><br><span>index c5d4ee8..e57ffab 100644</span><br><span>--- a/TODO-RELEASE</span><br><span>+++ b/TODO-RELEASE</span><br><span>@@ -11,3 +11,4 @@</span><br><span> libosmogsm      gsm0808_old_bss_to_new_bss_info ABI break (struct changes size), gsm0808_old_bss_to_new_bss_info_att_tlvdef symbol added</span><br><span> libosmosim       osim_card_hdl           ABI + API breakage due to new struct members</span><br><span> libosmocore     osmo_tdef_fsm_inst_state_chg    change default_timeout arg from unsigned long to long type (API breakage, not ABI)</span><br><span style="color: hsl(120, 100%, 40%);">+libosmovty      vty_read_config_filep   New API</span><br><span>diff --git a/include/osmocom/vty/vty.h b/include/osmocom/vty/vty.h</span><br><span>index d34433f..3e6178f 100644</span><br><span>--- a/include/osmocom/vty/vty.h</span><br><span>+++ b/include/osmocom/vty/vty.h</span><br><span>@@ -141,7 +141,7 @@</span><br><span> #define TELNET_NAWS_SB_LEN 5</span><br><span>   /*! sub-negotiation buffer */</span><br><span>        unsigned char sb_buf[TELNET_NAWS_SB_LEN];</span><br><span style="color: hsl(0, 100%, 40%);">-       /*! How many subnegotiation characters have we received?  </span><br><span style="color: hsl(120, 100%, 40%);">+    /*! How many subnegotiation characters have we received?</span><br><span>      *</span><br><span>    * We just drop those that do not fit in the buffer. */</span><br><span>      size_t sb_len;</span><br><span>@@ -210,6 +210,7 @@</span><br><span> /* Prototypes. */</span><br><span> void vty_init(struct vty_app_info *app_info);</span><br><span> int vty_read_config_file(const char *file_name, void *priv);</span><br><span style="color: hsl(120, 100%, 40%);">+int vty_read_config_filep(FILE *confp, void *priv);</span><br><span> void vty_init_vtysh (void);</span><br><span> void vty_reset (void);</span><br><span> struct vty *vty_new (void);</span><br><span>diff --git a/src/vty/vty.c b/src/vty/vty.c</span><br><span>index f4e8e80..76c6ef5 100644</span><br><span>--- a/src/vty/vty.c</span><br><span>+++ b/src/vty/vty.c</span><br><span>@@ -1462,9 +1462,13 @@</span><br><span>    return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* Read up configuration file */</span><br><span style="color: hsl(0, 100%, 40%);">-static int</span><br><span style="color: hsl(0, 100%, 40%);">-vty_read_file(FILE *confp, void *priv)</span><br><span style="color: hsl(120, 100%, 40%);">+/* Read up configuration from a file stream */</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Read up VTY configuration from a file stream</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] confp file pointer of the stream for the configuration file</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] priv private data to be passed to \ref vty_read_file</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns Zero on success, non-zero on error</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int vty_read_config_filep(FILE *confp, void *priv)</span><br><span> {</span><br><span>         int ret;</span><br><span>     struct vty *vty;</span><br><span>@@ -1870,7 +1874,7 @@</span><br><span>     if (!cfile)</span><br><span>          return -ENOENT;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-     rc = vty_read_file(cfile, priv);</span><br><span style="color: hsl(120, 100%, 40%);">+      rc = vty_read_config_filep(cfile, priv);</span><br><span>     fclose(cfile);</span><br><span> </span><br><span>   host_config_set(file_name);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/24262">change 24262</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/24262"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I720ac04386261628c0798a1bfcaa91e2490a86c3 </div>
<div style="display:none"> Gerrit-Change-Number: 24262 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>