⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gs_list.c

📁 使用TAP的蜂窝型GSM手机短消息服务中心
💻 C
字号:
/* -------------------------------------------------------------------- *//* SMS Client, send messages to mobile phones and pagers		*//*									*//* gs_list.c								*//*									*//*  Copyright (C) 1997,1998 Angelo Masci				*//*									*//*  This 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.	*//*									*//*  This 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 this library; if not, write to the Free		*//*  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.	*//*									*//*  You can contact the author at this e-mail address:			*//*									*//*  angelo@styx.demon.co.uk						*//*									*//* -------------------------------------------------------------------- *//* $Id$   -------------------------------------------------------------------- */#include <stdio.h>#include <stdlib.h>#include <string.h>#include "common.h"#include "logfile.h"#include "gs_token.h"/* -------------------------------------------------------------------- *//* -------------------------------------------------------------------- */TOKEN_LIST *malloc_token_list_item(void){	TOKEN_LIST		*list_item;	TOKEN	*token;	list_item = (TOKEN_LIST *)malloc(sizeof(TOKEN_LIST));	if (list_item == NULL)	{		lprintf(LOG_ERROR, "Allocating memory\n");		exit(1);	}	token = (TOKEN *)malloc(sizeof(TOKEN));	if (token == NULL)	{		free(list_item);			lprintf(LOG_ERROR, "Allocating memory\n");		exit(1);	}	list_item->token = token;	list_item->next  = NULL;	return list_item;}/* -------------------------------------------------------------------- *//* -------------------------------------------------------------------- */void update_token(TOKEN *token, char *str, int type, int ptr_type, void *ptr){	token->str      = strdup(str);	token->type     = type;	token->ptr_type = ptr_type;	token->ptr      = ptr;	lprintf(LOG_VERYVERBOSE, "Updating %s, %d, %d, %p\n", str, type, ptr_type, ptr);}/* -------------------------------------------------------------------- *//* -------------------------------------------------------------------- */TOKEN *find_item(TOKEN_LIST *list, char *str, int type){	TOKEN_LIST		*item;	item = list;	while(item != NULL)	{		if ((strcmp(item->token->str, str) == 0) &&		    (item->token->type == type))		{	return item->token;		}		item = item->next;	}	return NULL;}/* -------------------------------------------------------------------- *//* Try to locate item if it already exists, update			*//* it and return list.							*//* If the item cannot be located, create a new item,			*//* insert at the start of the list and return the new list.		*//* If list is empty add item to list and return list			*//* -------------------------------------------------------------------- */TOKEN_LIST *add_token_list_item(TOKEN_LIST *list, TOKEN **token, char *str, int type, int ptr_type, void *ptr){	TOKEN_LIST		*list_item;	TOKEN	*item;	lprintf(LOG_VERYVERBOSE, "Adding token '%s'\n", str);	item = find_item(list, str, type);	if (item != NULL)	{		lprintf(LOG_VERYVERBOSE, "Found token '%s'\n", str);		update_token(item, str, type, ptr_type, ptr);		*token = item;		return list;	}	lprintf(LOG_VERYVERBOSE, "Creating token '%s'\n", str);		list_item       = malloc_token_list_item();	list_item->next = list;	update_token(list_item->token, str, type, ptr_type, ptr);	*token = list_item->token;	return list_item;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -