X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=doc%2Fgnunet-c-tutorial.tex;h=70981b1387999e24dec334dc9cea341ea7c849bf;hb=3d5caa37c686f4ce440f97815b07d9e92ff4fea7;hp=e58e473995995f34a04e117f3a14c53875d429d1;hpb=9122bceef097dd520e236d04d086d2bd061cc6f9;p=oweals%2Fgnunet.git diff --git a/doc/gnunet-c-tutorial.tex b/doc/gnunet-c-tutorial.tex index e58e47399..70981b138 100644 --- a/doc/gnunet-c-tutorial.tex +++ b/doc/gnunet-c-tutorial.tex @@ -117,7 +117,9 @@ ECC functions not available in any released version of libgcrypt. $ git clone git://git.gnupg.org/libgcrypt.git $ cd libgcrypt $ ./autogen.sh -$ ./configure ; $ make install +$ ./configure +$ sudo make install +$ sudo ldconfig \end{lstlisting} \label{sub:install} @@ -310,7 +312,10 @@ Now you have to edit {\tt peer2.conf} and change: \begin{itemize} \itemsep0em \item{\texttt{SERVICEHOME} under \texttt{PATHS}} - \item{Every value for ``\texttt{PORT}'' (add 10000) in any section (if \texttt{PORT} is enabled, may be disabled using "\#") } + \item{Every (uncommented) value for ``\texttt{PORT}'' (add 10000) in any + section (the option may be commented out if \texttt{PORT} is + prefixed by "\#", in this case, UNIX domain sockets are used + and the PORT option does not need to be touched) } \item{Every value for ``\texttt{UNIXPATH}'' in any section (e.g. by adding a "-p2" suffix)} \end{itemize} to a fresh, unique value. Make sure that the \texttt{PORT} numbers stay @@ -417,7 +422,7 @@ The source code for the above listing can be found at \begin{lstlisting} $ export CPPFLAGS="-I/path/to/gnunet/headers" $ export LDFLAGS="-L/path/to/gnunet/libraries" -$ gcc -o testbed-test -lgnunettestbed -lgnunetdht -lgnunetutil testbed_test.c +$ gcc $CPPFLAGS $LDFLAGS -o testbed-test testbed_test.c -lgnunettestbed -lgnunetdht -lgnunetutil \end{lstlisting} The \texttt{CPPFLAGS} and \texttt{LDFLAGS} are necessary if GNUnet is installed into a different directory other than \texttt{/usr/local}. @@ -462,8 +467,9 @@ disconnect from the service with the provided service handle (\texttt{op\_result \exercise{Find out how many peers you can run on your system.} -\exercise{Find out how to create connections from within {\tt run} and create a - 2D torus topology. Then use the DHT API to store and retrieve values in the +\exercise{Find out how to create a 2D torus topology by changing the + options in the configuration file.\footnote{See \url{https://gnunet.org/content/supported-topologies}} + Then use the DHT API to store and retrieve values in the network.} \section{Developing Applications} @@ -588,6 +594,8 @@ static int a_flag; &GNUNET_GETOPT_set_one, &a_flag}, GNUNET_GETOPT_OPTION_END }; + string_option = NULL; + a_flag = GNUNET_SYSERR; // ... \end{lstlisting} @@ -596,7 +604,10 @@ the {\tt --help} argument and error handling are taken care of when using this approach. Other {\tt GNUNET\_GETOPT\_}-functions can be used to obtain integer value options, increment counters, etc. You can even write custom option parsers for special circumstances not covered -by the available handlers. +by the available handlers. To check if an argument was specified by the +user you initialize the variable with a specific value (e.g. NULL for +a string and GNUNET\_SYSERR for a integer) and check after parsing +happened if the values were modified. Inside the {\tt run} method, the program would perform the application-specific logic, which typically involves initializing and @@ -700,7 +711,7 @@ static size_t transmit_cb (void *cls, size_t size, void *buf) { // ... - if (NULL == buf) { handle_error(); return 0; } + if (NULL == buf) { /* handle error here */; return 0; } GNUNET_assert (size >= msg_size); memcpy (buf, my_msg, msg_size); // ...