#ifndef _SmsRobot_Header
#define _SmsRobot_Header
#include "smslib.h"

struct sms_robot;
typedef struct sms_robot SmsRobot;

struct robot_message;
typedef struct robot_message RobotMessage;

typedef struct robot_init {
	char *cmdline;
} RobotInit;

SmsRobot *sms_robot_init(Sms *sms, RobotInit *init, int *errcode);
void sms_robot_free(SmsRobot **robot);

RobotMessage *sms_robot_wait(SmsRobot *robot, long timeout_msec, int *errcode);

int sms_robot_send(SmsRobot *robot, void *data, char *from, char *to, char *message);
int sms_robot_recv(SmsRobot *robot, RobotMessage *msg);
int sms_robot_accept(SmsRobot *robot, RobotMessage *msg, int code, char *reason);
int sms_robot_reject(SmsRobot *robot, RobotMessage *msg, int code, char *reason);

char *sms_robot_error(SmsRobot *robot, int errcode, char *bf, int bfsz);

char *sms_robot_fromip(SmsRobot *robot, RobotMessage *msg);
char *sms_robot_from(SmsRobot *robot, RobotMessage *msg);
char *sms_robot_to(SmsRobot *robot, RobotMessage *msg);
char *sms_robot_body(SmsRobot *robot, RobotMessage *msg);

void sms_robot_msgfree(SmsRobot *robot, RobotMessage **msg);

#define SMS_NOT_SUPPORTED		SMS_NO_ERROR+1
#define SMS_SPAWN_FAILED		SMS_NO_ERROR+2
#define SMS_SPAWN_READ			SMS_NO_ERROR+3
#define SMS_SPAWN_WRITE			SMS_NO_ERROR+4
#define SMS_SEND_FAIL			SMS_NO_ERROR+5
#endif
