From 550f17100a5e15f9a5ac96c2923e258c786ac454 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 13 Oct 2006 22:41:34 +0000 Subject: [PATCH] add initial version of our new documentation - not too pretty yet, but will be improved SVN-Revision: 5060 --- docs/Makefile | 15 +++++++ docs/config.tex | 79 ++++++++++++++++++++++++++++++++++++ docs/config.txt | 72 --------------------------------- docs/network-scripts.tex | 54 +++++++++++++++++++++++++ docs/network-scripts.txt | 52 ------------------------ docs/network.tex | 86 ++++++++++++++++++++++++++++++++++++++++ docs/network.txt | 79 ------------------------------------ docs/openwrt.tex | 45 +++++++++++++++++++++ 8 files changed, 279 insertions(+), 203 deletions(-) create mode 100644 docs/Makefile create mode 100644 docs/config.tex delete mode 100644 docs/config.txt create mode 100644 docs/network-scripts.tex delete mode 100644 docs/network-scripts.txt create mode 100644 docs/network.tex delete mode 100644 docs/network.txt create mode 100644 docs/openwrt.tex diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000000..0a4128754b --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,15 @@ +openwrt.pdf: Makefile openwrt.tex config.tex network.tex network-scripts.tex + $(MAKE) cleanup + pdflatex openwrt.tex + pdflatex openwrt.tex + $(MAKE) cleanup + +clean: cleanup + rm -f openwrt.pdf + +cleanup: FORCE + rm -f *.log *.aux *.toc + + +FORCE: +.PHONY: FORCE diff --git a/docs/config.tex b/docs/config.tex new file mode 100644 index 0000000000..44b6689b53 --- /dev/null +++ b/docs/config.tex @@ -0,0 +1,79 @@ +\subsubsection{Structure of the configuration files} + +The config files are divided into sections and options/values. + +Every section has a type, but does not necessarily have a name. +Every option has a name and a value and is assigned to the section +it was written under. + +Syntax: + +\begin{Verbatim} +config [] # Section + option # Option +\end{Verbatim} + +Every parameter needs to be a single string and is formatted exactly +like a parameter for a shell function. The same rules for Quoting and +special characters also apply, as it is parsed by the shell. + +\subsubsection{Parsing configuration files in custom scripts} + +To be able to load configuration files, you need to include the common +functions with: + +\begin{Verbatim} +. /etc/functions.sh +\end{Verbatim} + +Then you can use \texttt{config\_load \textit{}} to load config files. The function +first checks for \textit{} as absolute filename and falls back to loading +it from \texttt{/etc/config} (which is the most common way of using it). + +If you want to use special callbacks for sections and/or options, you +need to define the following shell functions before running \texttt{config\_load} +(after including \texttt{/etc/functions.sh}): + +\begin{Verbatim} +config_cb() { + local type="$1" + local name="$2" + # commands to be run for every section +} + +option_cb() { + # commands to be run for every option +} +\end{Verbatim} + +You can also alter \texttt{option\_cb} from \texttt{config\_cb} based on the section type. +This allows you to process every single config section based on its type +individually. + +\texttt{config\_cb} is run every time a new section starts (before options are being +processed). You can access the last section through the \texttt{CONFIG\_SECTION} +variable. Also an extra call to \texttt{config\_cb} (without a new section) is generated +after \texttt{config\_load} is done. +That allows you to process sections both before and after all options were +processed. + +You can access already processed options with the \texttt{config\_get} command +Syntax: + +\begin{Verbatim} +config_get