mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 16:50:14 +00:00
more formatting cleanup.
Move some code into a function sms_compose1() in preparation for supporting protocol 2 as well. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48599 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1007,32 +1007,11 @@ static unsigned char sms_handleincoming (sms_t * h)
|
|||||||
#define NAME_MAX 1024
|
#define NAME_MAX 1024
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*! \brief find and fill in next message, or send a REL if none waiting */
|
/*! \brief compose a message for protocol 1 */
|
||||||
static void sms_nextoutgoing (sms_t * h)
|
static void sms_compose1(sms_t *h, int more)
|
||||||
{
|
{
|
||||||
char fn[100 + NAME_MAX] = "";
|
unsigned int p = 2; /* next byte to write. Skip type and len */
|
||||||
DIR *d;
|
|
||||||
char more = 0;
|
|
||||||
|
|
||||||
*h->da = *h->oa = '\0'; /* clear destinations */
|
|
||||||
ast_copy_string (fn, spool_dir, sizeof (fn));
|
|
||||||
mkdir(fn, 0777); /* ensure it exists */
|
|
||||||
h->rx = 0; /* outgoing message */
|
|
||||||
snprintf (fn + strlen (fn), sizeof (fn) - strlen (fn), "/%s", h->smsc ? "mttx" : "motx");
|
|
||||||
mkdir (fn, 0777); /* ensure it exists */
|
|
||||||
d = opendir (fn);
|
|
||||||
if (d) {
|
|
||||||
struct dirent *f = readdirqueue (d, h->queue);
|
|
||||||
if (f) {
|
|
||||||
snprintf (fn + strlen (fn), sizeof (fn) - strlen (fn), "/%s", f->d_name);
|
|
||||||
sms_readfile (h, fn);
|
|
||||||
if (readdirqueue (d, h->queue))
|
|
||||||
more = 1; /* more to send */
|
|
||||||
}
|
|
||||||
closedir (d);
|
|
||||||
}
|
|
||||||
if (*h->da || *h->oa) { /* message to send */
|
|
||||||
unsigned char p = 2;
|
|
||||||
h->omsg[0] = 0x91; /* SMS_DATA */
|
h->omsg[0] = 0x91; /* SMS_DATA */
|
||||||
if (h->smsc) { /* deliver */
|
if (h->smsc) { /* deliver */
|
||||||
h->omsg[p++] = (more ? 4 : 0) + ((h->udhl > 0) ? 0x40 : 0);
|
h->omsg[p++] = (more ? 4 : 0) + ((h->udhl > 0) ? 0x40 : 0);
|
||||||
@@ -1066,12 +1045,39 @@ static void sms_nextoutgoing (sms_t * h)
|
|||||||
p += packsms (h->dcs, h->omsg + p, h->udhl, h->udh, h->udl, h->ud);
|
p += packsms (h->dcs, h->omsg + p, h->udhl, h->udh, h->udl, h->ud);
|
||||||
}
|
}
|
||||||
h->omsg[1] = p - 2;
|
h->omsg[1] = p - 2;
|
||||||
sms_messagetx (h);
|
}
|
||||||
|
|
||||||
|
/*! \brief find and fill in next message, or send a REL if none waiting */
|
||||||
|
static void sms_nextoutgoing (sms_t * h)
|
||||||
|
{
|
||||||
|
char fn[100 + NAME_MAX] = "";
|
||||||
|
DIR *d;
|
||||||
|
char more = 0;
|
||||||
|
|
||||||
|
*h->da = *h->oa = '\0'; /* clear destinations */
|
||||||
|
ast_copy_string (fn, spool_dir, sizeof (fn));
|
||||||
|
mkdir(fn, 0777); /* ensure it exists */
|
||||||
|
h->rx = 0; /* outgoing message */
|
||||||
|
snprintf (fn + strlen (fn), sizeof (fn) - strlen (fn), "/%s", h->smsc ? "mttx" : "motx");
|
||||||
|
mkdir (fn, 0777); /* ensure it exists */
|
||||||
|
d = opendir (fn);
|
||||||
|
if (d) {
|
||||||
|
struct dirent *f = readdirqueue (d, h->queue);
|
||||||
|
if (f) {
|
||||||
|
snprintf (fn + strlen (fn), sizeof (fn) - strlen (fn), "/%s", f->d_name);
|
||||||
|
sms_readfile (h, fn);
|
||||||
|
if (readdirqueue (d, h->queue))
|
||||||
|
more = 1; /* more to send */
|
||||||
|
}
|
||||||
|
closedir (d);
|
||||||
|
}
|
||||||
|
if (*h->da || *h->oa) { /* message to send */
|
||||||
|
sms_compose1(h, more);
|
||||||
} else { /* no message */
|
} else { /* no message */
|
||||||
h->omsg[0] = 0x94; /* SMS_REL */
|
h->omsg[0] = 0x94; /* SMS_REL */
|
||||||
h->omsg[1] = 0;
|
h->omsg[1] = 0;
|
||||||
sms_messagetx (h);
|
|
||||||
}
|
}
|
||||||
|
sms_messagetx (h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sms_debug (char *dir, unsigned char *msg)
|
static void sms_debug (char *dir, unsigned char *msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user