\doxysection{tdef.\+h}
\label{tdef_8h_source}\index{include/osmocom/core/tdef.h@{include/osmocom/core/tdef.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{4 \textcolor{comment}{/*}}
\DoxyCodeLine{5 \textcolor{comment}{ * (C) 2018-\/2019 by sysmocom -\/ s.f.m.c. GmbH <info@sysmocom.de>}}
\DoxyCodeLine{6 \textcolor{comment}{ *}}
\DoxyCodeLine{7 \textcolor{comment}{ * All Rights Reserved}}
\DoxyCodeLine{8 \textcolor{comment}{ *}}
\DoxyCodeLine{9 \textcolor{comment}{ * SPDX-\/License-\/Identifier: GPL-\/2.0+}}
\DoxyCodeLine{10 \textcolor{comment}{ *}}
\DoxyCodeLine{11 \textcolor{comment}{ * Author: Neels Hofmeyr <neels@hofmeyr.de>}}
\DoxyCodeLine{12 \textcolor{comment}{ *}}
\DoxyCodeLine{13 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{14 \textcolor{comment}{ * it under the terms of the GNU Affero General Public License as published by}}
\DoxyCodeLine{15 \textcolor{comment}{ * the Free Software Foundation; either version 3 of the License, or}}
\DoxyCodeLine{16 \textcolor{comment}{ * (at your option) any later version.}}
\DoxyCodeLine{17 \textcolor{comment}{ *}}
\DoxyCodeLine{18 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{19 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{20 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{21 \textcolor{comment}{ * GNU Affero General Public License for more details.}}
\DoxyCodeLine{22 \textcolor{comment}{ *}}
\DoxyCodeLine{23 \textcolor{comment}{ * You should have received a copy of the GNU Affero General Public License}}
\DoxyCodeLine{24 \textcolor{comment}{ * along with this program.  If not, see <http://www.gnu.org/licenses/>.}}
\DoxyCodeLine{25 \textcolor{comment}{ */}}
\DoxyCodeLine{26 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{27 }
\DoxyCodeLine{28 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{29 \textcolor{preprocessor}{\#include <osmocom/core/utils.h>}}
\DoxyCodeLine{30 }
\DoxyCodeLine{31 \textcolor{keyword}{struct }osmo\_fsm\_inst;}
\DoxyCodeLine{32 }
\DoxyCodeLine{38 \textcolor{keyword}{enum} osmo\_tdef\_unit \{}
\DoxyCodeLine{39         OSMO\_TDEF\_S = 0,     }
\DoxyCodeLine{40         OSMO\_TDEF\_MS,               }
\DoxyCodeLine{41         OSMO\_TDEF\_M,         }
\DoxyCodeLine{42         OSMO\_TDEF\_CUSTOM,       }
\DoxyCodeLine{43         OSMO\_TDEF\_US,               }
\DoxyCodeLine{44 \};}
\DoxyCodeLine{45 }
\DoxyCodeLine{46 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }value\_string osmo\_tdef\_unit\_names[];}
\DoxyCodeLine{48 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_tdef\_unit\_name(\textcolor{keyword}{enum} osmo\_tdef\_unit val)}
\DoxyCodeLine{49 \{ \textcolor{keywordflow}{return} get\_value\_string(osmo\_tdef\_unit\_names, val); \}}
\DoxyCodeLine{50 }
\DoxyCodeLine{65 \textcolor{keyword}{struct }osmo\_tdef \{}
\DoxyCodeLine{70         \textcolor{keyword}{const} \textcolor{keywordtype}{int} T;}
\DoxyCodeLine{73         \textcolor{keyword}{const} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} default\_val;}
\DoxyCodeLine{74         \textcolor{keyword}{const} \textcolor{keyword}{enum} osmo\_tdef\_unit unit;}
\DoxyCodeLine{77         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *desc;}
\DoxyCodeLine{80         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} val;}
\DoxyCodeLine{82         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} min\_val;}
\DoxyCodeLine{84         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} max\_val;}
\DoxyCodeLine{85 \};}
\DoxyCodeLine{86 }
\DoxyCodeLine{98 \textcolor{preprocessor}{\#define osmo\_tdef\_for\_each(t, tdefs) \(\backslash\)}}
\DoxyCodeLine{99 \textcolor{preprocessor}{        for (t = tdefs; t \&\& (t-\/>T || t-\/>default\_val || t-\/>desc); t++)}}
\DoxyCodeLine{100 }
\DoxyCodeLine{101 \textcolor{keywordtype}{void} osmo\_tdefs\_reset(\textcolor{keyword}{struct} osmo\_tdef *tdefs);}
\DoxyCodeLine{102 \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} osmo\_tdef\_get(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_tdef *tdefs, \textcolor{keywordtype}{int} T, \textcolor{keyword}{enum} osmo\_tdef\_unit as\_unit,}
\DoxyCodeLine{103                             \textcolor{keywordtype}{long} val\_if\_not\_present);}
\DoxyCodeLine{104 \textcolor{keyword}{struct }osmo\_tdef *osmo\_tdef\_get\_entry(\textcolor{keyword}{struct} osmo\_tdef *tdefs, \textcolor{keywordtype}{int} T);}
\DoxyCodeLine{105 \textcolor{keywordtype}{int} osmo\_tdef\_set(\textcolor{keyword}{struct} osmo\_tdef *tdefs, \textcolor{keywordtype}{int} T, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} val, \textcolor{keyword}{enum} osmo\_tdef\_unit val\_unit);}
\DoxyCodeLine{106 \textcolor{keywordtype}{bool} osmo\_tdef\_val\_in\_range(\textcolor{keyword}{struct} osmo\_tdef *tdef, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} new\_val);}
\DoxyCodeLine{107 \textcolor{keywordtype}{int} osmo\_tdef\_range\_str\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{struct} osmo\_tdef *t);}
\DoxyCodeLine{108 }
\DoxyCodeLine{111 \textcolor{keyword}{struct }osmo\_tdef\_state\_timeout \{}
\DoxyCodeLine{115         \textcolor{keywordtype}{int} T;}
\DoxyCodeLine{118         \textcolor{keywordtype}{bool} keep\_timer;}
\DoxyCodeLine{119 \};}
\DoxyCodeLine{120 }
\DoxyCodeLine{121 \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_tdef\_state\_timeout *osmo\_tdef\_get\_state\_timeout(uint32\_t state,}
\DoxyCodeLine{122                                                                   \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_tdef\_state\_timeout *timeouts\_array);}
\DoxyCodeLine{123 }
\DoxyCodeLine{163 \textcolor{preprocessor}{\#define osmo\_tdef\_fsm\_inst\_state\_chg(fi, state, timeouts\_array, tdefs, default\_timeout) \(\backslash\)}}
\DoxyCodeLine{164 \textcolor{preprocessor}{        \_osmo\_tdef\_fsm\_inst\_state\_chg(fi, state, timeouts\_array, tdefs, default\_timeout, \(\backslash\)}}
\DoxyCodeLine{165 \textcolor{preprocessor}{                                      \_\_FILE\_\_, \_\_LINE\_\_)}}
\DoxyCodeLine{166 \textcolor{keywordtype}{int} \_osmo\_tdef\_fsm\_inst\_state\_chg(\textcolor{keyword}{struct} osmo\_fsm\_inst *fi, uint32\_t state,}
\DoxyCodeLine{167                                   \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_tdef\_state\_timeout *timeouts\_array,}
\DoxyCodeLine{168                                   \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_tdef *tdefs, \textcolor{keywordtype}{signed} \textcolor{keywordtype}{long} default\_timeout,}
\DoxyCodeLine{169                                   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file, \textcolor{keywordtype}{int} line);}
\DoxyCodeLine{170 }
\DoxyCodeLine{175 \textcolor{keyword}{struct }osmo\_tdef\_group \{}
\DoxyCodeLine{176         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{177         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *desc;}
\DoxyCodeLine{178         \textcolor{keyword}{struct }osmo\_tdef *tdefs;}
\DoxyCodeLine{179 \};}
\DoxyCodeLine{180 }
\DoxyCodeLine{185 \textcolor{preprocessor}{\#define osmo\_tdef\_groups\_for\_each(g, tdef\_groups) \(\backslash\)}}
\DoxyCodeLine{186 \textcolor{preprocessor}{        for (g = tdef\_groups; g \&\& g-\/>tdefs; g++)}}
\DoxyCodeLine{187 }

\end{DoxyCode}
