view src/protocols/oscar/util.c @ 4151:1a5dcfa1823e

[gaim-migrate @ 4377] Why do I make these things so long? I'm defective, that's why. Mr. Walp pointed out a problem with "allow only peeps in my buddy list" for ICQ, so I fixed that. One important problem: If you set your permdeny to "allow only peeps in my buddy list," and then add or remove someone from your buddy list, it will not update the allow/deny list on the server. And that's a bad thing. I changed an error message string or 4 in oscar.c for various reasons. 1) I feel that "he/she" is much better than "it." If you disagree, please let me know, because I'm not sure of the correct phrasing. 2) There is only 1 unknown reason, it just applies to multiple messages. I shuffled some of the clientauto functions around in oscar.c to make it more uniform. I intend to look into why status messages aren't working well soon. I added some semblance of more advanced ICQ info support to libfaim. There's also a bit of support in oscar.c for it, but making it display itself nicely will take a little work, so I'll do it later. A patch from the good Mr. Blanton taking out a non-ascii character from oscar.c (my bad). A patch from the good Mr. Blanton adding support for i18n to away messages and aim profile info. Questions for the good Mr. Blanton: 1) Line 59 of info.c, in the first half of that if statement, should profile_len also be &&'ed in with the other 2? 2) I changed a gaim_parse_user_info so that it works for non-unicode away messages and profiles. Or so I think. 3) I changed little bits of your patch to appease my annoyingness, so it might not cvs update cleanly for you. Sorry. I organized the ChangeLog entries for 0.60. I tried to put stuff that I thought was more important near the top of each category. Please change stuff around, because I'm pretty sure it could be better. Breathe in, breathe out, breathe in, breathe out... Tied to a wheel... committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 29 Dec 2002 17:12:05 +0000
parents 07283934dedd
children 2a2d6d21f1d7
line wrap: on
line source

/*
 *
 *
 *
 */

#define FAIM_INTERNAL
#include <aim.h>
#include <ctype.h>

faim_export faim_shortfunc int aimutil_putstr(u_char *dest, const char *src, int len)
{
	memcpy(dest, src, len);
	return len;
}

/*
 * Tokenizing functions.  Used to portably replace strtok/sep.
 *   -- DMP.
 *
 */
faim_export int aimutil_tokslen(char *toSearch, int index, char dl)
{
	int curCount = 1;
	char *next;
	char *last;
	int toReturn;

	last = toSearch;
	next = strchr(toSearch, dl);

	while(curCount < index && next != NULL) {
		curCount++;
		last = next + 1;
		next = strchr(last, dl);
	}

	if ((curCount < index) || (next == NULL))
		toReturn = strlen(toSearch) - (curCount - 1);
	else
		toReturn = next - toSearch - (curCount - 1);

	return toReturn;
}

faim_export int aimutil_itemcnt(char *toSearch, char dl)
{
	int curCount;
	char *next;

	curCount = 1;

	next = strchr(toSearch, dl);

	while(next != NULL) {
		curCount++;
		next = strchr(next + 1, dl);
	}

	return curCount;
}

faim_export char *aimutil_itemidx(char *toSearch, int index, char dl)
{
	int curCount;
	char *next;
	char *last;
	char *toReturn;

	curCount = 0;

	last = toSearch;
	next = strchr(toSearch, dl);

	while (curCount < index && next != NULL) {
		curCount++;
		last = next + 1;
		next = strchr(last, dl);
	}

	if (curCount < index) {
		toReturn = malloc(sizeof(char));
		*toReturn = '\0';
	}
	next = strchr(last, dl);

	if (curCount < index) {
		toReturn = malloc(sizeof(char));
		*toReturn = '\0';
	} else {
		if (next == NULL) {
			toReturn = malloc((strlen(last) + 1) * sizeof(char));
			strcpy(toReturn, last);
		} else {
			toReturn = malloc((next - last + 1) * sizeof(char));
			memcpy(toReturn, last, (next - last));
			toReturn[next - last] = '\0';
		}
	}
	return toReturn;
}

/*
* int snlen(const char *)
* 
* This takes a screen name and returns its length without
* spaces.  If there are no spaces in the SN, then the 
* return is equal to that of strlen().
*
*/
faim_export int aim_snlen(const char *sn)
{
	int i = 0;
	const char *curPtr = NULL;

	if (!sn)
		return 0;

	curPtr = sn;
	while ( (*curPtr) != (char) NULL) {
		if ((*curPtr) != ' ')
		i++;
		curPtr++;
	}

	return i;
}

/*
* int sncmp(const char *, const char *)
*
* This takes two screen names and compares them using the rules
* on screen names for AIM/AOL.  Mainly, this means case and space
* insensitivity (all case differences and spacing differences are
* ignored).
*
* Return: 0 if equal
*     non-0 if different
*
*/
faim_export int aim_sncmp(const char *sn1, const char *sn2)
{
	const char *curPtr1 = NULL, *curPtr2 = NULL;

	if (aim_snlen(sn1) != aim_snlen(sn2))
		return 1;

	curPtr1 = sn1;
	curPtr2 = sn2;
	while ( (*curPtr1 != (char) NULL) && (*curPtr2 != (char) NULL) ) {
		if ( (*curPtr1 == ' ') || (*curPtr2 == ' ') ) {
			if (*curPtr1 == ' ')
				curPtr1++;
			if (*curPtr2 == ' ')
				curPtr2++;
		} else {
			if ( toupper(*curPtr1) != toupper(*curPtr2))
				return 1;
			curPtr1++;
			curPtr2++;
		}
	}

	/* Should both be NULL */
	if (*curPtr1 != *curPtr2)
		return 1;

	return 0;
}

/* strsep Copyright (C) 1992, 1993 Free Software Foundation, Inc.
strsep is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB.  If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.  */

/* Minor changes by and1000 on 15/1/97 to make it go under Nemesis */

faim_export char *aim_strsep(char **pp, const char *delim)
{
	char *p, *q;

	if (!(p = *pp))
		return 0;

	if ((q = strpbrk (p, delim))) {
		*pp = q + 1;
		*q = '\0';
	} else
		*pp = 0;

	return p;
}