Lines Matching refs:options

3  * options.c
4 * Set of functions to deal with the options structure and for parsing
5 * options in TFTP data buffer.
7 * $Id: options.c,v 1.16 2003/04/25 00:16:18 jp Exp $
34 #include "options.h"
39 int opt_parse_request(char *data, int data_size, struct tftp_opt *options)
51 opt_set_options(options, "filename", entry);
57 opt_set_options(options, "mode", entry);
58 /* scan for options */
67 opt_set_options(options, tmp, entry);
73 * Fill a structure looking only at TFTP options.
75 int opt_parse_options(char *data, int data_size, struct tftp_opt *options)
89 opt_set_options(options, tmp, entry);
101 int opt_set_options(struct tftp_opt *options, char *name, char *value)
107 if (strncasecmp(name, options[i].option, OPT_SIZE) == 0)
109 options[i].specified = 1;
111 Strncpy(options[i].value, value, VAL_SIZE);
113 Strncpy(options[i].value, tftp_default_options[i].value,
125 int opt_get_options(struct tftp_opt *options, char *name, char *value)
131 if (strncasecmp(name, options[i].option, OPT_SIZE) == 0)
133 if (options[i].enabled)
134 Strncpy(value, options[i].value, VAL_SIZE);
146 int opt_disable_options(struct tftp_opt *options, char *name)
153 options[i].specified = 0;
156 if (strncasecmp(name, options[i].option, OPT_SIZE) == 0)
158 options[i].specified = 0;
170 * Return 1 if one or more options are specified in the options structure.
172 int opt_support_options(struct tftp_opt *options)
179 if (options[i].specified)
186 * The next few functions deal with TFTP options. Function's name are self
190 int opt_get_tsize(struct tftp_opt *options)
193 if (options[OPT_TSIZE].enabled && options[OPT_TSIZE].specified)
195 tsize = atoi(options[OPT_TSIZE].value);
201 int opt_get_timeout(struct tftp_opt *options)
204 if (options[OPT_TIMEOUT].enabled && options[OPT_TIMEOUT].specified)
206 timeout = atoi(options[OPT_TIMEOUT].value);
212 int opt_get_blksize(struct tftp_opt *options)
215 if (options[OPT_BLKSIZE].enabled && options[OPT_BLKSIZE].specified)
217 blksize = atoi(options[OPT_BLKSIZE].value);
223 int opt_get_multicast(struct tftp_opt *options, char *addr, int *port, int *mc)
229 if (options[OPT_MULTICAST].enabled && options[OPT_MULTICAST].specified)
231 string = strdup(options[OPT_MULTICAST].value);
276 void opt_set_tsize(int tsize, struct tftp_opt *options)
278 snprintf(options[OPT_TSIZE].value, VAL_SIZE, "%d", tsize);
281 void opt_set_timeout(int timeout, struct tftp_opt *options)
283 snprintf(options[OPT_TIMEOUT].value, VAL_SIZE, "%d", timeout);
286 void opt_set_blksize(int blksize, struct tftp_opt *options)
288 snprintf(options[OPT_BLKSIZE].value, VAL_SIZE, "%d", blksize);
291 void opt_set_multicast(struct tftp_opt *options, char *addr, int port, int mc)
293 snprintf(options[OPT_MULTICAST].value, VAL_SIZE, "%s,%d,%d", addr, port,
298 * Format the content of the options structure (this is the content of a
301 void opt_request_to_string(struct tftp_opt *options, char *string, int len)
307 if ((index + strlen(options[i].option) + 2) < len)
309 Strncpy(string + index, options[i].option, len - index);
310 index += strlen(options[i].option);
314 if ((index + strlen(options[i].value) + 2) < len)
316 Strncpy(string + index, options[i].value, len - index);
317 index += strlen(options[i].value);
322 opt_options_to_string(options, string + index, len - index);
326 * Convert the options structure to a string.
328 void opt_options_to_string(struct tftp_opt *options, char *string, int len)
334 if (options[i].specified && options[i].enabled)
336 if ((index + strlen(options[i].option) + 2) < len)
338 Strncpy(string + index, options[i].option, len - index);
339 index += strlen(options[i].option);
343 if ((index + strlen(options[i].value) + 2) < len)
345 Strncpy(string + index, options[i].value, len - index);
346 index += strlen(options[i].value);