#include #include #include #include #include "sms.h" extern char phone[256]; extern char smsserver[256]; extern unsigned short smsserverport; extern char program[256]; extern char run[256]; extern char progargs[256]; char port[32]; struct Run { char *name; char *value; }; /* * Prepend the escape character before all non-alpha or digit characters. */ static char *escape(char *input) { struct Push buf; char *string=NULL; INIT_PUSH(buf); while (input && *input) { if((*input != ' ') && !isalnum((int)*input) ) PushByte(&buf, '\\'); string = PushByte(&buf, *input); input++; }; return string; }; int smsit(char *message) { if(strlen(run)) { struct Push buf; char *out; int i; FILE *runit; struct Run vars[]={ {"program", program}, {"server", smsserver}, {"port", port}, {"phone", phone}, {"progargs", progargs}, {"message", message}, }; INIT_PUSH(buf); sprintf(port, "%d", smsserverport); out = run; while(*out) { if('$' == *out) { out++; for(i=0; i