\doxysection{test.\+c} \hypertarget{test_8c_source}{}\label{test_8c_source}\mbox{\hyperlink{test_8c}{Go to the documentation of this file.}} \begin{DoxyCode}{0} \DoxyCodeLine{\Hypertarget{test_8c_source_l00001}00001\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{config_8h}{config.h}}"{}}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00002}00002\ \textcolor{preprocessor}{\#include\ }} \DoxyCodeLine{\Hypertarget{test_8c_source_l00003}00003\ \textcolor{preprocessor}{\#include\ }} \DoxyCodeLine{\Hypertarget{test_8c_source_l00004}00004\ \textcolor{preprocessor}{\#include\ }} \DoxyCodeLine{\Hypertarget{test_8c_source_l00005}00005\ \textcolor{preprocessor}{\#include\ }} \DoxyCodeLine{\Hypertarget{test_8c_source_l00006}00006\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{file_8h}{file.h}}"{}}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00007}00007\ } \DoxyCodeLine{\Hypertarget{test_8c_source_l00008}\mbox{\hyperlink{test_8c_a840291bc02cba5474a4cb46a9b9566fe}{00008}}\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{test_8c_a840291bc02cba5474a4cb46a9b9566fe}{main}}(\textcolor{keywordtype}{void})} \DoxyCodeLine{\Hypertarget{test_8c_source_l00009}00009\ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00010}00010\ \ \ \ \textcolor{keywordtype}{char}\ teststr[]\ =\ \textcolor{stringliteral}{"{}sdafsdfsdf[12345asdfddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd]"{}};} \DoxyCodeLine{\Hypertarget{test_8c_source_l00011}00011\ \ \ \ \textcolor{keywordtype}{char}\ *name\ =\ NULL;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00012}00012\ \ \ \ \textcolor{keywordtype}{char}\ *sectionName=NULL;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00013}00013\ \ \ \ \textcolor{keywordtype}{int}\ ret=0;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00014}00014\ \ \ \ name\ =\ malloc(\mbox{\hyperlink{config_8h_aa454692b60895f7025f12b1e0065acea}{MAX\_LEN\_SECTIONNAME}}*\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}));} \DoxyCodeLine{\Hypertarget{test_8c_source_l00015}00015\ \ \ \ \mbox{\hyperlink{config_8c_a699e504c1ab9ceffb828dbf365a5e374}{getStrAtPos}}(teststr,\ 11,\ 15,\ \&name,\ \mbox{\hyperlink{config_8h_aa454692b60895f7025f12b1e0065acea}{MAX\_LEN\_SECTIONNAME}});} \DoxyCodeLine{\Hypertarget{test_8c_source_l00016}00016\ } \DoxyCodeLine{\Hypertarget{test_8c_source_l00017}00017\ \ \ \ sectionName\ =\ malloc(\mbox{\hyperlink{config_8h_aa454692b60895f7025f12b1e0065acea}{MAX\_LEN\_SECTIONNAME}});} \DoxyCodeLine{\Hypertarget{test_8c_source_l00018}00018\ \ \ \ memset(sectionName,0,\mbox{\hyperlink{config_8h_aa454692b60895f7025f12b1e0065acea}{MAX\_LEN\_SECTIONNAME}});} \DoxyCodeLine{\Hypertarget{test_8c_source_l00019}00019\ \ \ \ ret=\mbox{\hyperlink{config_8c_aae86bc3f3ebba4d6aba3ca1392c0126a}{checkSection}}(teststr,\textcolor{charliteral}{'['},\textcolor{charliteral}{']'},\ \§ionName);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00020}00020\ \ \ \ \textcolor{keywordflow}{if}(ret\ ==\ \mbox{\hyperlink{config_8h_a02f5a0519bc0372946e64d593c0c58ce}{FOUND\_SECTION}})} \DoxyCodeLine{\Hypertarget{test_8c_source_l00021}00021\ \ \ \ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00022}00022\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}checkSection\ sucessfull\(\backslash\)nsectionName=\%s\(\backslash\)n"{}},sectionName);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00023}00023\ \ \ \ \}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00024}00024\ \ \ \ \textcolor{keywordflow}{else}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00025}00025\ \ \ \ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00026}00026\ \ \ \ \ \ \ \ free(sectionName);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00027}00027\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}an\ error\ occured:\%d\(\backslash\)n"{}},ret);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00028}00028\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00029}00029\ \ \ \ \}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00030}00030\ \ \ } \DoxyCodeLine{\Hypertarget{test_8c_source_l00031}00031\ \ \ \ \textcolor{keywordtype}{char}\ testpair[]\ =\ \textcolor{stringliteral}{"{}asifdsfo=s1254124"{}};} \DoxyCodeLine{\Hypertarget{test_8c_source_l00032}00032\ \ \ \ \textcolor{keywordtype}{char}\ *keyName=NULL;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00033}00033\ \ \ \ \textcolor{keywordtype}{char}\ *keyValue=NULL;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00034}00034\ \ \ \ \textcolor{keywordtype}{char}\ *content=NULL;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00035}00035\ \ \ \ } \DoxyCodeLine{\Hypertarget{test_8c_source_l00036}00036\ \ \ \ keyName\ =\ malloc(\mbox{\hyperlink{config_8h_aa454692b60895f7025f12b1e0065acea}{MAX\_LEN\_SECTIONNAME}});} \DoxyCodeLine{\Hypertarget{test_8c_source_l00037}00037\ \ \ \ keyValue\ =\ malloc(\mbox{\hyperlink{config_8h_aa454692b60895f7025f12b1e0065acea}{MAX\_LEN\_SECTIONNAME}});} \DoxyCodeLine{\Hypertarget{test_8c_source_l00038}00038\ \ \ \ memset(keyName,0,\mbox{\hyperlink{config_8h_aa454692b60895f7025f12b1e0065acea}{MAX\_LEN\_SECTIONNAME}});} \DoxyCodeLine{\Hypertarget{test_8c_source_l00039}00039\ \ \ \ memset(keyValue,0,\mbox{\hyperlink{config_8h_aa454692b60895f7025f12b1e0065acea}{MAX\_LEN\_SECTIONNAME}});} \DoxyCodeLine{\Hypertarget{test_8c_source_l00040}00040\ } \DoxyCodeLine{\Hypertarget{test_8c_source_l00041}00041\ \ \ \ \textcolor{keywordflow}{if}((ret=\mbox{\hyperlink{config_8c_ab0b547ee554d9b305adc1b2ad85080a3}{getNameValuePair}}(testpair,} \DoxyCodeLine{\Hypertarget{test_8c_source_l00042}00042\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{charliteral}{'='},0,} \DoxyCodeLine{\Hypertarget{test_8c_source_l00043}00043\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \&keyName,\&keyValue,} \DoxyCodeLine{\Hypertarget{test_8c_source_l00044}00044\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{config_8h_aa454692b60895f7025f12b1e0065acea}{MAX\_LEN\_SECTIONNAME}},\mbox{\hyperlink{config_8h_aa454692b60895f7025f12b1e0065acea}{MAX\_LEN\_SECTIONNAME}}))==\mbox{\hyperlink{config_8h_a258bb72419ef143530a2f8f55e7d57af}{NO\_ERROR}})} \DoxyCodeLine{\Hypertarget{test_8c_source_l00045}00045\ \ \ \ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00046}00046\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}keyname:\%s\ Value:\ \%s\(\backslash\)n"{}},keyName,keyValue);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00047}00047\ \ \ \ \}\textcolor{keywordflow}{else}\{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00048}00048\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}error\ getNameValuePair:\ \%d\(\backslash\)n"{}},ret);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00049}00049\ \ \ \ \}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00050}00050\ \ \ \ \ } \DoxyCodeLine{\Hypertarget{test_8c_source_l00051}00051\ \ \ \ \ \textcolor{keywordtype}{long}\ neededSize=0;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00052}00052\ \ \ \ \ \textcolor{keywordflow}{if}((ret=\mbox{\hyperlink{file_8c_a415337a87938760b49ba4c0d74ab6c6a}{getFile}}(\textcolor{stringliteral}{"{}config-\/segfault.cfg"{}},NULL,0,\&neededSize))==\mbox{\hyperlink{config_8h_a258bb72419ef143530a2f8f55e7d57af}{NO\_ERROR}})} \DoxyCodeLine{\Hypertarget{test_8c_source_l00053}00053\ \ \ \ \ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00054}00054\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}sucessfull\ retrieved\ size:\%ld\(\backslash\)n"{}},neededSize);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00055}00055\ \ \ \ \ \}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00056}00056\ \ \ \ \ \textcolor{keywordflow}{else}\ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00057}00057\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ on\ getFile:\%d\(\backslash\)n"{}},ret);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00058}00058\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00059}00059\ \ \ \ \ \}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00060}00060\ \ \ \ \ content\ =\ malloc(neededSize);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00061}00061\ \ \ \ \ printf(\textcolor{stringliteral}{"{}allocate\ buffer\ for\ filecontent\ size:\%ld\(\backslash\)n"{}},neededSize);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00062}00062\ \ \ \ \ \textcolor{keywordflow}{if}(content\ ==\ NULL)} \DoxyCodeLine{\Hypertarget{test_8c_source_l00063}00063\ \ \ \ \ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00064}00064\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ error\ =\ errno;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00065}00065\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}MALLOC:\ \%d\(\backslash\)n"{}},error);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00066}00066\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ error;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00067}00067\ \ \ \ \ \}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00068}00068\ \ \ \ \ memset(content,0,neededSize);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00069}00069\ \ \ \ \ \textcolor{keywordflow}{if}((ret=\mbox{\hyperlink{file_8c_a415337a87938760b49ba4c0d74ab6c6a}{getFile}}(\textcolor{stringliteral}{"{}config-\/segfault.cfg"{}},\&content,neededSize,\&neededSize))==\mbox{\hyperlink{config_8h_a258bb72419ef143530a2f8f55e7d57af}{NO\_ERROR}})} \DoxyCodeLine{\Hypertarget{test_8c_source_l00070}00070\ \ \ \ \ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00071}00071\ \ \ \ \ \ \ \ \ \textcolor{comment}{//printf("{}Sucessfull\ read\ file\ into\ buffer:\%s|\(\backslash\)n-\/-\/-\/\(\backslash\)n"{},content);}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00072}00072\ \ \ \ \ \}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00073}00073\ \ \ \ \ \textcolor{keywordflow}{else}\ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00074}00074\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ on\ getFile:\%d\(\backslash\)n"{}},ret);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00075}00075\ \ \ \ \ \ \ \ \ free(content);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00076}00076\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00077}00077\ \ \ \ \ \}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00078}00078\ \ \ \ \ \textcolor{keyword}{struct\ }\mbox{\hyperlink{structconfigEntry}{configEntry}}\ *entry=NULL;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00079}00079\ \ \ \ \ \textcolor{keywordtype}{int}\ returnedCount=0;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00080}00080\ \ \ \ \ \textcolor{keywordtype}{int}\ i=0;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00081}00081\ \ \ \ \ \textcolor{keywordtype}{int}\ count=10;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00082}00082\ } \DoxyCodeLine{\Hypertarget{test_8c_source_l00083}00083\ \ \ \ \ entry\ =\ malloc(count*\textcolor{keyword}{sizeof}(\textcolor{keyword}{struct}\ \mbox{\hyperlink{structconfigEntry}{configEntry}}));} \DoxyCodeLine{\Hypertarget{test_8c_source_l00084}00084\ \ \ \ \ \textcolor{keywordflow}{if}(entry\ ==\ NULL)} \DoxyCodeLine{\Hypertarget{test_8c_source_l00085}00085\ \ \ \ \ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00086}00086\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ error\ =\ errno;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00087}00087\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}MALLOC:\ \%d\(\backslash\)n"{}},error);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00088}00088\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{test_8c_source_l00089}00089\ \ \ \ \ \}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00090}00090\ \ \ \ \ ret\ =\ \mbox{\hyperlink{config_8c_a15a5f64f830221feac0af723899208b2}{parseConfig}}(content,\&entry,count,\&returnedCount);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00091}00091\ \ \ \ \ \textcolor{keywordflow}{if}(ret!=\mbox{\hyperlink{config_8h_a258bb72419ef143530a2f8f55e7d57af}{NO\_ERROR}})} \DoxyCodeLine{\Hypertarget{test_8c_source_l00092}00092\ \ \ \ \ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00093}00093\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ on\ parseConfig:\%d\(\backslash\)nReallocate\ from\ size\ \%d,\ to\ \%d\(\backslash\)n"{}},ret,count,returnedCount);} \DoxyCodeLine{\Hypertarget{test_8c_source_l00094}00094\ \ \ \ \ \}} \DoxyCodeLine{\Hypertarget{test_8c_source_l00095}00095\ \ \ \ \ \textcolor{keywordflow}{if}(returnedCount\ >\ count)} \DoxyCodeLine{\Hypertarget{test_8c_source_l00096}00096\ \ \ \ \ \{} \DoxyCodeLine{\Hypertarget{test_8c_source_l00097}00097\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}(i=0;i