[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
GSMD::Gnokii coredumps sending SMS (long with code)
From: |
Konstantinos Agouros |
Subject: |
GSMD::Gnokii coredumps sending SMS (long with code) |
Date: |
15 Sep 2002 10:29:48 GMT |
User-agent: |
nn/6.6.4 |
Hi,
in this mail You will find the code for my SendSMS-routine, which is largely
borrowed from gnokii.c however the final sending coredumps. THe last
working printf is "Before send". I am using a smscno instead of an index
cause otherwise the getsmscno-call fails with a coredump. The CVS-Update I did
on gnokii is from last Friday.
Konstantin
int
SendSMS(ghash, smshash)
HvObject *ghash;
HV *smshash;
PREINIT:
GSM_API_SMS *sms;
SV **value;
int curpos;
int input_len;
CODE:
{
GSM_DataClear(&data);
sms = calloc(1, sizeof(GSM_API_SMS));
curpos=0;
gn_sms_default_submit(sms);
memset(&(sms->Remote.Number), 0, sizeof(sms->Remote.Number));
if((value = hv_fetch(smshash, "destination", 11, 0)) != NULL)
{
memcpy(&(sms->Remote.Number), SvPV_nolen(*value),
sizeof(sms->Remote.Number) - 1);
if (sms->Remote.Number[0] == '+')
sms->Remote.Type = SMS_International;
else
sms->Remote.Type = SMS_Unknown;
}
else
croak("Destination must be set in smshash");
printf("Checkpoint1\n");
value = hv_fetch(smshash, "smscnumber", 10, 0);
printf("Just to be sure \n");
if((value = hv_fetch(smshash, "smscnumber", 10, 0)) != NULL)
{
printf("smscn != NULL\n");
strncpy(sms->SMSC.Number, SvPV_nolen(*value),
sizeof(sms->SMSC.Number) - 1);
if (sms->SMSC.Number[0] == '+')
sms->SMSC.Type = SMS_International;
else
sms->SMSC.Type = SMS_Unknown;
}
else
printf("No smscn\n");
printf("Checkpoint2\n");
if((value = hv_fetch(smshash, "smscindex", 9, 0)) != NULL)
{
SMS_MessageCenter MessageCenter;
memset(&MessageCenter, 0, sizeof(SMS_MessageCenter));
MessageCenter.No = SvIV(*value);
data.MessageCenter = &MessageCenter;
printf("Number: %d\n",data.MessageCenter->No);
if (data.MessageCenter->No < 1 || data.MessageCenter->No > 5)
croak("Messagecenter index must be between 1 and 5");
printf("Vor SM_F1\n");
if (SM_Functions(GOP_GetSMSCenter, &data, &State) == GE_NONE)
{
printf("Vor strypu\n");
strcpy(sms->SMSC.Number, data.MessageCenter->SMSC.Number);
sms->SMSC.Type = data.MessageCenter->SMSC.Type;
}
printf("Printing number\n");
printf("Number is: %s\n", sms->SMSC.Number);
free(data.MessageCenter);
}
else
printf("No index\n");
printf("Checkpoint3\n");
if((value = hv_fetch(smshash, "animation", 9, 0)) != NULL)
{
char buf[10240];
char *s = buf, *t;
int i;
strcpy(buf, SvPV_nolen(*value));
sms->UserData[curpos].Type = SMS_AnimationData;
for (i = 0; i < 4; i++)
{
t = strchr(s, ';');
if (t)
*t++ = 0;
loadbitmap(&(sms->UserData[curpos].u.Animation[i]), s, i ?
GN_BMP_EMSAnimation2 : GN_BMP_EMSAnimation);
s = t;
}
sms->UserData[++curpos].Type = SMS_NoData;
curpos = -1;
}
printf("Checkpoint4\n");
if((value = hv_fetch(smshash, "report", 6, 0)) != NULL)
sms->DeliveryReport = true;
// hier gehts weiter
if((value = hv_fetch(smshash, "class", 5, 0)) != NULL)
{
int class;
class = new SvIV(*value);
if((class >= 0) && (class < 5))
sms->DCS.u.General.Class = class;
else
croak("Illegal classvalue");
}
printf("Checkpoint5\n");
if((value = hv_fetch(smshash, "validity", 8, 0)) != NULL)
sms->Validity = SvIV(*value);
printf("Checkpoint6\n");
if((value = hv_fetch(smshash, "eightbit", 8, 0)) != NULL)
{
sms->DCS.u.General.Alphabet = SMS_8bit;
input_len = GSM_MAX_8BIT_SMS_LENGTH;
}
// this is completely borrowed from gnokii.c
printf("Checkpoint7\n");
printf("SMSCNo = %s\n", sms->SMSC.Number);
if (!sms->SMSC.Number[0])
{
printf("Nach dem SMSC\n");
data.MessageCenter = calloc(1, sizeof(SMS_MessageCenter));
data.MessageCenter->No = 1;
printf("Vor SM_F\n");
if (SM_Functions(GOP_GetSMSCenter, &data, &State) == GE_NONE)
{
printf("Vor dem strcpy\n");
strcpy(sms->SMSC.Number, data.MessageCenter->SMSC.Number);
sms->SMSC.Type = data.MessageCenter->SMSC.Type;
}
printf("Vor dem free\n");
free(data.MessageCenter);
}
printf("Checkpoit8\n");
if (!sms->SMSC.Type)
sms->SMSC.Type = SMS_Unknown;
printf("Checkpoit9\n");
if((value = hv_fetch(smshash, "message", 7, 0)) != NULL)
{
memset(sms->UserData[curpos].u.Text, 0, GSM_MAX_SMS_LENGTH);
strcpy(sms->UserData[curpos].u.Text, SvPV_nolen(*value));
sms->UserData[curpos].Type = SMS_PlainText;
if (!gn_char_def_alphabet(sms->UserData[curpos].u.Text))
sms->DCS.u.General.Alphabet = SMS_UCS2;
sms->UserData[++curpos].Type = SMS_NoData;
}
else
croak("Need a message to send");
printf("Checkpoit10\n");
printf("Curpos %d Message: %s\n", curpos, sms->UserData[curpos -
1].u.Text);
data.SMS = sms;
printf("Before send\n");
RETVAL = gn_sms_send(&data, &State);
printf("After send\n");
}
OUTPUT:
RETVAL
--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: address@hidden
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not survive the forming of the cosmos." B'Elana Torres
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- GSMD::Gnokii coredumps sending SMS (long with code),
Konstantinos Agouros <=