Súbor: [Platon] / dead / mail2sms / strings.c (stiahnutie)
Revízia 1.10, Fri Nov 16 19:30:01 2001 UTC (22 years, 4 months ago) by host8
Zmeny od 1.9: +4 -15
[lines]
Patched bug in declaration/definition of global variable debug.
|
/*
* Author: Lubomir Host 'rajo' <host8@kepler.fmph.uniba.sk>
* $Log: strings.c,v $
* Revision 1.10 2001/11/16 19:30:01 host8
* Patched bug in declaration/definition of global variable debug.
*
* Revision 1.9 2001/11/12 20:19:10 host8
* http_connect() probably works fine.
* Some problems with http_requests for www.mtnsms.com.
*
* Revision 1.8 2001/11/12 16:08:00 host8
* Big improvements in http. connect() doesn't work correctly yet.
*
* Revision 1.7 2001/10/30 17:24:02 host8
* New implementation of http request.
*
* Revision 1.6 2001/10/25 20:05:28 host8
* First implementation of login with password.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "mail2sms.h"
#include "strings.h"
// Function isnnumber() {{{
int isnnumber(char *str, int len)
{
int i;
for(i=0; 1<len; i++)
if (!isdigit(*str++))
return 0;
return 1;
} // }}}
// Function strdel() strrmlf() strrmcr() {{{
char *strdel(char *s)
{
register int i;
for (i = 0; s[i] != '\0'; i++)
s[i] = s[i + 1];
return s;
}
char *strrmlf(char *s)
{
while (strchr(s, '\n') != NULL)
strdel(strchr(s, '\n'));
return s;
}
char *strrmcr(char *s)
{
while (strchr(s, '\r') != NULL)
strdel(strchr(s, '\r'));
return s;
} // }}}
// Function strtolower() {{{
char *strtolower(char *str)
{
while (*str) {
*str=tolower(*str);
str++;
}
return str;
} // }}}
// Function strip() {{{
char *strip(char *str)
{
register int k=-1;
while (++k, str[k]!='\0') {
if ((*(str+k) == *(str+k+1)) &&
(!isdigit(*(str+k)))) {
strdel(str+k);
k--;
}
}
return(str);
} // }}}
// Function hexa() {{{
char *hexa(int c)
{
char *str;
if (c >= 0 && c < 256) {
str = (char *) malloc(4*sizeof(char));
sprintf(str, "%.2X", c);
// printf("HEXA: '%s'\n", str);
return (str);
}
return (NULL);
} // }}}
// Function compress_str() {{{
char *compress_str(char *str)
{
int j;
strip(str);
j=-1;
while (++j,*(str+j)!='\0') {
if (isspace(*(str+j))) {
strdel(str+j);
*(str+j)=toupper(*(str+j));
}
}
return str;
} // }}}
// Function add_str_to_sms() {{{
void add_str_to_sms(char *str)
{
int j;
char *pom;
compress_str(str);
if (strlen(g.text) < SMS_LEN) {
j=0;
while (strlen(g.text)<SMS_LEN && *(str+j)!='\0') {
if (isalnum(*(str+j))) {
strncat(g.text, (str+j), 1);
}
else {
if ((SMS_LEN-strlen(g.text)) > 2) {
strcat(g.text, "%");
pom = hexa(*(str+j));
strcat(g.text, pom);
my_free(pom);
}
else return;
}
j++;
}
}
return;
} // }}}
/* Modeline for ViM {{{1
* vim:set ts=4:
* vim600:fdm=marker fdl=0 fdc=3:
* }}}1 */
Platon Group <platon@platon.sk> http://platon.sk/
|