void remove_token(char *source, int parmnum, char separator)
{
int i;
- int len;
+ int len, slen;
int curr_parm;
int start, end;
start = (-1);
end = (-1);
- if (strlen(source) == 0) {
+ slen = strlen(source);
+ if (slen == 0) {
return;
}
- for (i = 0; i < strlen(source); ++i) {
+ for (i = 0;
+ ( (i < slen) && (end == -1) );
+ ++i) {
if ((start < 0) && (curr_parm == parmnum)) {
start = i;
}
}
if (end < 0)
- end = strlen(source);
+ end = slen;
- strcpy(&source[start], &source[end]);
+ memmove(&source[start], &source[end], slen - end + 1);
}
*/
void striplt(char *buf)
{
- if (strlen(buf) == 0) return;
- while ((strlen(buf) > 0) && (isspace(buf[0])))
- strcpy(buf, &buf[1]);
- if (strlen(buf) == 0) return;
- while (isspace(buf[strlen(buf) - 1]))
- buf[strlen(buf) - 1] = 0;
+ long len;
+
+ len = strlen(buf);
+ if (len == 0) return;
+ while ((len > 0) && (isspace(buf[0]))){
+ memmove (buf, &buf[1], len);
+ len --;
+ }
+ if (len == 0) return;
+ while (isspace(buf[len - 1])){
+ buf[len - 1] = 0;
+ len --;
+ }
}
* \param sourcelen the length of the source data (may contain string terminators)
*/
-void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen)
+void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen, int linebreaks)
{
int i, hiteof = FALSE;
int spos = 0;
dest[dpos] = 0;
}
thisline += 4;
- if (thisline > 70) {
+ if ( (linebreaks) && (thisline > 70) ) {
dest[dpos++] = '\r';
dest[dpos++] = '\n';
dest[dpos] = 0;
}
}
}
- if (thisline > 70) {
+ if ( (linebreaks) && (thisline > 70) ) {
dest[dpos++] = '\r';
dest[dpos++] = '\n';
dest[dpos] = 0;
void generate_uuid(char *buf) {
static int seq = 0;
- sprintf(buf, "%s-%lx-%x-%x",
+ sprintf(buf, "%s-%lx-%lx-%x",
serv_info.serv_nodename,
(long)time(NULL),
- getpid(),
+ (long)getpid(),
(seq++)
);
}