\doxysection{vty.\+h}
\label{vty_8h_source}\index{include/osmocom/vty/vty.h@{include/osmocom/vty/vty.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{2 }
\DoxyCodeLine{3 \textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{4 \textcolor{preprocessor}{\#include <stdarg.h>}}
\DoxyCodeLine{5 \textcolor{preprocessor}{\#include <stdbool.h>}}
\DoxyCodeLine{6 \textcolor{preprocessor}{\#include <time.h>}}
\DoxyCodeLine{7 }
\DoxyCodeLine{8 \textcolor{preprocessor}{\#include <osmocom/core/linuxlist.h>}}
\DoxyCodeLine{9 \textcolor{preprocessor}{\#include <osmocom/core/defs.h>}}
\DoxyCodeLine{10 }
\DoxyCodeLine{15 \textcolor{comment}{/* GCC have printf type attribute check.  */}}
\DoxyCodeLine{16 \textcolor{preprocessor}{\#ifdef \_\_GNUC\_\_}}
\DoxyCodeLine{17 \textcolor{preprocessor}{\#define VTY\_PRINTF\_ATTRIBUTE(a,b) \_\_attribute\_\_ ((\_\_format\_\_ (\_\_printf\_\_, a, b)))}}
\DoxyCodeLine{18 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{19 \textcolor{preprocessor}{\#define VTY\_PRINTF\_ATTRIBUTE(a,b)}}
\DoxyCodeLine{20 \textcolor{preprocessor}{\#endif                          }\textcolor{comment}{/* \_\_GNUC\_\_ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{21 }
\DoxyCodeLine{22 \textcolor{comment}{/* Does the I/O error indicate that the operation should be retried later? */}}
\DoxyCodeLine{23 \textcolor{preprocessor}{\#define ERRNO\_IO\_RETRY(EN) \(\backslash\)}}
\DoxyCodeLine{24 \textcolor{preprocessor}{        (((EN) == EAGAIN) || ((EN) == EWOULDBLOCK) || ((EN) == EINTR))}}
\DoxyCodeLine{25 }
\DoxyCodeLine{26 \textcolor{comment}{/* Vty read buffer size. */}}
\DoxyCodeLine{27 \textcolor{preprocessor}{\#define VTY\_READ\_BUFSIZ 512}}
\DoxyCodeLine{28 }
\DoxyCodeLine{29 \textcolor{preprocessor}{\#define VTY\_BUFSIZ 512}}
\DoxyCodeLine{30 \textcolor{preprocessor}{\#define VTY\_MAXHIST 20}}
\DoxyCodeLine{31 }
\DoxyCodeLine{32 \textcolor{comment}{/* Number of application / library specific VTY attributes */}}
\DoxyCodeLine{33 \textcolor{preprocessor}{\#define VTY\_CMD\_USR\_ATTR\_NUM 32}}
\DoxyCodeLine{34 \textcolor{comment}{/* Flag characters reserved for global VTY attributes */}}
\DoxyCodeLine{35 \textcolor{preprocessor}{\#define VTY\_CMD\_ATTR\_FLAGS\_RESERVED \(\backslash\)}}
\DoxyCodeLine{36 \textcolor{preprocessor}{        \{ '.', '!', '@', '\string^' \}}}
\DoxyCodeLine{37 }
\DoxyCodeLine{39 \textcolor{keyword}{enum} \textcolor{keyword}{event} \{}
\DoxyCodeLine{40         VTY\_SERV,}
\DoxyCodeLine{41         VTY\_READ,}
\DoxyCodeLine{42         VTY\_WRITE,}
\DoxyCodeLine{43         VTY\_CLOSED,}
\DoxyCodeLine{44         VTY\_TIMEOUT\_RESET,}
\DoxyCodeLine{45 \textcolor{preprocessor}{\#ifdef VTYSH}}
\DoxyCodeLine{46         VTYSH\_SERV,}
\DoxyCodeLine{47         VTYSH\_READ,}
\DoxyCodeLine{48         VTYSH\_WRITE}
\DoxyCodeLine{49 \textcolor{preprocessor}{\#endif                          }\textcolor{comment}{/* VTYSH */}\textcolor{preprocessor}{}}
\DoxyCodeLine{50 \};}
\DoxyCodeLine{51 }
\DoxyCodeLine{52 \textcolor{keyword}{enum} vty\_type \{}
\DoxyCodeLine{53         VTY\_TERM,}
\DoxyCodeLine{54         VTY\_FILE,}
\DoxyCodeLine{55         VTY\_SHELL,}
\DoxyCodeLine{56         VTY\_SHELL\_SERV}
\DoxyCodeLine{57 \};}
\DoxyCodeLine{58 }
\DoxyCodeLine{60 \textcolor{keyword}{struct }vty \{}
\DoxyCodeLine{62         FILE *file;}
\DoxyCodeLine{63 }
\DoxyCodeLine{65         \textcolor{keywordtype}{void} *priv;}
\DoxyCodeLine{66 }
\DoxyCodeLine{68         \textcolor{keywordtype}{int} fd;}
\DoxyCodeLine{69 }
\DoxyCodeLine{71         \textcolor{keyword}{enum} vty\_type type;}
\DoxyCodeLine{72 }
\DoxyCodeLine{74         \textcolor{keywordtype}{int} node;}
\DoxyCodeLine{75 }
\DoxyCodeLine{77         \textcolor{keywordtype}{int} fail;}
\DoxyCodeLine{78 }
\DoxyCodeLine{80         \textcolor{keyword}{struct }buffer *obuf;}
\DoxyCodeLine{81 }
\DoxyCodeLine{83         \textcolor{keywordtype}{char} *buf;}
\DoxyCodeLine{84 }
\DoxyCodeLine{86         \textcolor{keywordtype}{int} cp;}
\DoxyCodeLine{87 }
\DoxyCodeLine{89         \textcolor{keywordtype}{int} length;}
\DoxyCodeLine{90 }
\DoxyCodeLine{92         \textcolor{keywordtype}{int} max;}
\DoxyCodeLine{93 }
\DoxyCodeLine{95         \textcolor{keywordtype}{char} *hist[VTY\_MAXHIST];}
\DoxyCodeLine{96 }
\DoxyCodeLine{98         \textcolor{keywordtype}{int} hp;}
\DoxyCodeLine{99 }
\DoxyCodeLine{101         \textcolor{keywordtype}{int} hindex;}
\DoxyCodeLine{102 }
\DoxyCodeLine{105         \textcolor{keywordtype}{void} *index;}
\DoxyCodeLine{106 }
\DoxyCodeLine{108         \textcolor{keywordtype}{void} *index\_sub;}
\DoxyCodeLine{109 }
\DoxyCodeLine{111         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} escape;}
\DoxyCodeLine{112 }
\DoxyCodeLine{114         \textcolor{keyword}{enum} \{ VTY\_NORMAL, VTY\_CLOSE, VTY\_MORE, VTY\_MORELINE \} status;}
\DoxyCodeLine{115 }
\DoxyCodeLine{121         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} iac;}
\DoxyCodeLine{122 }
\DoxyCodeLine{124         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} iac\_sb\_in\_progress;}
\DoxyCodeLine{125         \textcolor{comment}{/* At the moment, we care only about the NAWS (window size) negotiation,}}
\DoxyCodeLine{126 \textcolor{comment}{         * and that requires just a 5-\/character buffer (RFC 1073):}}
\DoxyCodeLine{127 \textcolor{comment}{         * <NAWS char> <16-\/bit width> <16-\/bit height> */}}
\DoxyCodeLine{128 \textcolor{preprocessor}{\#define TELNET\_NAWS\_SB\_LEN 5}}
\DoxyCodeLine{130         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} sb\_buf[TELNET\_NAWS\_SB\_LEN];}
\DoxyCodeLine{134         \textcolor{keywordtype}{size\_t} sb\_len;}
\DoxyCodeLine{135 }
\DoxyCodeLine{137         \textcolor{keywordtype}{int} width;}
\DoxyCodeLine{139         \textcolor{keywordtype}{int} height;}
\DoxyCodeLine{140 }
\DoxyCodeLine{142         \textcolor{keywordtype}{int} lines;}
\DoxyCodeLine{143 }
\DoxyCodeLine{144         \textcolor{keywordtype}{int} monitor;}
\DoxyCodeLine{145 }
\DoxyCodeLine{147         \textcolor{keywordtype}{int} config;}
\DoxyCodeLine{148 }
\DoxyCodeLine{150         \textcolor{keyword}{struct }llist\_head parent\_nodes;}
\DoxyCodeLine{151 }
\DoxyCodeLine{154         \textcolor{keywordtype}{char} *indent;}
\DoxyCodeLine{155 }
\DoxyCodeLine{157         \textcolor{keywordtype}{bool} expert\_mode;}
\DoxyCodeLine{158 \};}
\DoxyCodeLine{159 }
\DoxyCodeLine{160 \textcolor{comment}{/* Small macro to determine newline is newline only or linefeed needed. */}}
\DoxyCodeLine{161 \textcolor{preprocessor}{\#define VTY\_NEWLINE  ((vty-\/>type == VTY\_TERM) ? "{}\(\backslash\)r\(\backslash\)n"{}} : "{}\(\backslash\)n"{})}
\DoxyCodeLine{162 }
\DoxyCodeLine{163 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *vty\_newline(\textcolor{keyword}{struct} vty *vty)}
\DoxyCodeLine{164 \{}
\DoxyCodeLine{165         \textcolor{keywordflow}{return} VTY\_NEWLINE;}
\DoxyCodeLine{166 \}}
\DoxyCodeLine{167 }
\DoxyCodeLine{169 \textcolor{keyword}{struct }vty\_app\_info \{}
\DoxyCodeLine{171         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{173         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *version;}
\DoxyCodeLine{175         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *copyright;}
\DoxyCodeLine{177         \textcolor{keywordtype}{void} *tall\_ctx;}
\DoxyCodeLine{183         int (*go\_parent\_cb)(\textcolor{keyword}{struct }vty *vty);}
\DoxyCodeLine{186         int (*is\_config\_node)(\textcolor{keyword}{struct }vty *vty, \textcolor{keywordtype}{int} node)}
\DoxyCodeLine{187                 OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Implicit parent node tracking has replaced the use of this callback. This callback is"{}}}
\DoxyCodeLine{188                                 \textcolor{stringliteral}{"{} no longer called, ever, and can be left NULL."{}});}
\DoxyCodeLine{190         int (*config\_is\_consistent)(\textcolor{keyword}{struct }vty *vty);}
\DoxyCodeLine{192         \textcolor{keyword}{const} \textcolor{keywordtype}{char} * usr\_attr\_desc[VTY\_CMD\_USR\_ATTR\_NUM];}
\DoxyCodeLine{194         \textcolor{keywordtype}{char} usr\_attr\_letters[VTY\_CMD\_USR\_ATTR\_NUM];}
\DoxyCodeLine{195 \};}
\DoxyCodeLine{196 }
\DoxyCodeLine{197 \textcolor{comment}{/* Prototypes. */}}
\DoxyCodeLine{198 \textcolor{keywordtype}{void} vty\_init(\textcolor{keyword}{struct} vty\_app\_info *app\_info);}
\DoxyCodeLine{199 \textcolor{keywordtype}{int} vty\_read\_config\_file(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *file\_name, \textcolor{keywordtype}{void} *priv);}
\DoxyCodeLine{200 \textcolor{keywordtype}{int} vty\_read\_config\_filep(FILE *confp, \textcolor{keywordtype}{void} *priv);}
\DoxyCodeLine{201 \textcolor{keywordtype}{void} vty\_init\_vtysh (\textcolor{keywordtype}{void});}
\DoxyCodeLine{202 \textcolor{keywordtype}{void} vty\_reset (\textcolor{keywordtype}{void});}
\DoxyCodeLine{203 \textcolor{keyword}{struct }vty *vty\_new (\textcolor{keywordtype}{void});}
\DoxyCodeLine{204 \textcolor{keyword}{struct }vty *vty\_create (\textcolor{keywordtype}{int} vty\_sock, \textcolor{keywordtype}{void} *priv);}
\DoxyCodeLine{205 \textcolor{keywordtype}{bool} vty\_is\_active(\textcolor{keyword}{struct} vty *vty);}
\DoxyCodeLine{206 \textcolor{keywordtype}{int} vty\_out (\textcolor{keyword}{struct} vty *, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *, ...) VTY\_PRINTF\_ATTRIBUTE(2, 3);}
\DoxyCodeLine{207 \textcolor{keywordtype}{int} vty\_out\_va(struct vty *vty, const \textcolor{keywordtype}{char} *format, va\_list ap);}
\DoxyCodeLine{208 \textcolor{keywordtype}{int} vty\_out\_newline(struct vty *);}
\DoxyCodeLine{209 \textcolor{keywordtype}{int} vty\_out\_uptime(struct vty *vty, const struct timespec *starttime);}
\DoxyCodeLine{210 \textcolor{keywordtype}{int} vty\_read(struct vty *vty);}
\DoxyCodeLine{211 \textcolor{comment}{//void vty\_time\_print (struct vty *, int);}}
\DoxyCodeLine{212 \textcolor{keywordtype}{void} vty\_close (struct vty *);}
\DoxyCodeLine{213 \textcolor{keywordtype}{void} vty\_flush(struct vty *vty);}
\DoxyCodeLine{214 \textcolor{keywordtype}{char} *vty\_get\_cwd (\textcolor{keywordtype}{void});}
\DoxyCodeLine{215 \textcolor{keywordtype}{void} vty\_log (const \textcolor{keywordtype}{char} *level, const \textcolor{keywordtype}{char} *proto, const \textcolor{keywordtype}{char} *fmt, va\_list);}
\DoxyCodeLine{216 \textcolor{keywordtype}{int} vty\_config\_lock (struct vty *);}
\DoxyCodeLine{217 \textcolor{keywordtype}{int} vty\_config\_unlock (struct vty *);}
\DoxyCodeLine{218 \textcolor{keywordtype}{int} vty\_shell (struct vty *);}
\DoxyCodeLine{219 \textcolor{keywordtype}{int} vty\_shell\_serv (struct vty *);}
\DoxyCodeLine{220 \textcolor{keywordtype}{void} vty\_hello (struct vty *);}
\DoxyCodeLine{221 \textcolor{keywordtype}{void} *vty\_current\_index(struct vty *);}
\DoxyCodeLine{222 \textcolor{keywordtype}{int} vty\_current\_node(struct vty *vty);}
\DoxyCodeLine{223 \textcolor{keywordtype}{int} vty\_go\_parent(struct vty *vty);}
\DoxyCodeLine{224 }
\DoxyCodeLine{225 \textcolor{comment}{/* Return IP address passed to the 'line vty'/'bind' command, or "{}127.0.0.1"{} */}}
\DoxyCodeLine{226 const \textcolor{keywordtype}{char} *vty\_get\_bind\_addr(\textcolor{keywordtype}{void});}
\DoxyCodeLine{228 \textcolor{keywordtype}{int} vty\_get\_bind\_port(\textcolor{keywordtype}{int} default\_port);}
\DoxyCodeLine{229 }
\DoxyCodeLine{230 extern \textcolor{keywordtype}{void} *tall\_vty\_ctx;}
\DoxyCodeLine{231 }
\DoxyCodeLine{232 extern struct cmd\_element cfg\_description\_cmd;}
\DoxyCodeLine{233 extern struct cmd\_element cfg\_no\_description\_cmd;}
\DoxyCodeLine{234 }
\DoxyCodeLine{235 }
\DoxyCodeLine{239 enum signal\_vty \{}
\DoxyCodeLine{240         S\_VTY\_EVENT,}
\DoxyCodeLine{241 \};}
\DoxyCodeLine{242 }
\DoxyCodeLine{243 \textcolor{keyword}{struct }vty\_signal\_data \{}
\DoxyCodeLine{244         \textcolor{keyword}{enum} \textcolor{keyword}{event} event;}
\DoxyCodeLine{245         \textcolor{keywordtype}{int} sock;}
\DoxyCodeLine{246         \textcolor{keyword}{struct }vty *vty;}
\DoxyCodeLine{247 \};}
\DoxyCodeLine{248 }

\end{DoxyCode}
