X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=doc%2Fgnunet-c-tutorial.tex;h=70981b1387999e24dec334dc9cea341ea7c849bf;hb=3d5caa37c686f4ce440f97815b07d9e92ff4fea7;hp=8ad4d30190a1dc9217ed1635fa5bb3b1a5f2e576;hpb=d71637007a11ed352bc82590fa6899faba3802d0;p=oweals%2Fgnunet.git diff --git a/doc/gnunet-c-tutorial.tex b/doc/gnunet-c-tutorial.tex index 8ad4d3019..70981b138 100644 --- a/doc/gnunet-c-tutorial.tex +++ b/doc/gnunet-c-tutorial.tex @@ -594,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} @@ -602,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 @@ -706,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); // ...