-int send_request(connection_t *c, const char *format, ...)
-{
- va_list args;
- char buffer[MAXBUFSIZE];
- int len, request;
-
- cp();
- /* Use vsnprintf instead of vasprintf: faster, no memory
- fragmentation, cleanup is automatic, and there is a limit on the
- input buffer anyway */
-
- va_start(args, format);
- len = vsnprintf(buffer, MAXBUFSIZE, format, args);
- va_end(args);
-
- if(len < 0 || len > MAXBUFSIZE-1)
- {
- syslog(LOG_ERR, _("Output buffer overflow while sending request to %s (%s)"), c->name, c->hostname);
- return -1;
- }
-
- if(debug_lvl >= DEBUG_PROTOCOL)
- {
- sscanf(buffer, "%d", &request);
- if(debug_lvl >= DEBUG_META)
- syslog(LOG_DEBUG, _("Sending %s to %s (%s): %s"), request_name[request], c->name, c->hostname, buffer);
- else
- syslog(LOG_DEBUG, _("Sending %s to %s (%s)"), request_name[request], c->name, c->hostname);
- }
-
- buffer[len++] = '\n';
- cp();
- if(c == broadcast)
- return broadcast_meta(NULL, buffer, len);
- else
- return send_meta(c, buffer, len);
-}