+ if ((tmplt != NULL) && (opt_daemon != NULL))
+ {
+ rrd_set_error("The caching opt_daemon cannot be used together with "
+ "templates yet.");
+ goto out;
+ }
+
+ if ((tmplt == NULL) && (opt_daemon == NULL))
+ {
+ char *temp;
+
+ temp = getenv (ENV_RRDCACHED_ADDRESS);
+ if (temp != NULL)
+ {
+ opt_daemon = strdup (temp);
+ if (opt_daemon == NULL)
+ {
+ rrd_set_error("strdup failed.");
+ goto out;
+ }
+ }
+ }
+
+ if (opt_daemon != NULL)
+ {
+ int status;
+
+ status = rrdc_connect (opt_daemon);
+ if (status != 0)
+ {
+ rrd_set_error("Unable to connect to opt_daemon: %s",
+ (status < 0)
+ ? "Internal error"
+ : rrd_strerror (status));
+ goto out;
+ }
+
+ status = rrdc_update (/* file = */ argv[optind],
+ /* values_num = */ argc - optind - 1,
+ /* values = */ (void *) (argv + optind + 1));
+ if (status != 0)
+ {
+ rrd_set_error("Failed sending the values to the opt_daemon: %s",
+ (status < 0)
+ ? "Internal error"
+ : rrd_strerror (status));
+ }
+ else
+ {
+ rc = 0;
+ }
+
+ rrdc_disconnect ();
+ goto out;
+ } /* if (opt_daemon != NULL) */
+