1/*++ 2/* NAME 3/* mail_command_client 3 4/* SUMMARY 5/* single-command client 6/* SYNOPSIS 7/* #include <mail_proto.h> 8/* 9/* int mail_command_client(class, name, type, attr, ...) 10/* const char *class; 11/* const char *name; 12/* int type; 13/* const char *attr; 14/* DESCRIPTION 15/* This module implements a client interface for single-command 16/* clients: a client that sends a single command and expects 17/* a single completion status code. 18/* 19/* Arguments: 20/* .IP class 21/* Service type: MAIL_CLASS_PUBLIC or MAIL_CLASS_PRIVATE 22/* .IP name 23/* Service name (master.cf). 24/* .IP "type, attr, ..." 25/* Attribute information as defined in attr_print(3). 26/* DIAGNOSTICS 27/* The result is -1 if the request could not be sent, otherwise 28/* the result is the status reported by the server. 29/* Warnings: problems connecting to the requested service. 30/* Fatal: out of memory. 31/* SEE ALSO 32/* attr_print(3), send attributes over byte stream 33/* mail_command_server(3), server interface 34/* mail_proto(3h), client-server protocol 35/* LICENSE 36/* .ad 37/* .fi 38/* The Secure Mailer license must be distributed with this software. 39/* AUTHOR(S) 40/* Wietse Venema 41/* IBM T.J. Watson Research 42/* P.O. Box 704 43/* Yorktown Heights, NY 10598, USA 44/*--*/ 45 46/* System library. */ 47 48#include <sys_defs.h> 49#include <stdlib.h> /* 44BSD stdarg.h uses abort() */ 50#include <stdarg.h> 51 52/* Utility library. */ 53 54#include <vstream.h> 55 56/* Global library. */ 57 58#include <mail_proto.h> 59 60/* mail_command_client - single-command transaction with completion status */ 61 62int mail_command_client(const char *class, const char *name,...) 63{ 64 va_list ap; 65 VSTREAM *stream; 66 int status; 67 68 /* 69 * Talk a little protocol with the specified service. 70 */ 71 if ((stream = mail_connect(class, name, BLOCKING)) == 0) 72 return (-1); 73 va_start(ap, name); 74 status = attr_vprint(stream, ATTR_FLAG_NONE, ap); 75 va_end(ap); 76 if (status != 0 77 || attr_scan(stream, ATTR_FLAG_STRICT, 78 ATTR_TYPE_INT, MAIL_ATTR_STATUS, &status, 0) != 1) 79 status = -1; 80 (void) vstream_fclose(stream); 81 return (status); 82} 83