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

📄 gs_translate.c

📁 使用TAP的蜂窝型GSM手机短消息服务中心
💻 C
字号:
/* -------------------------------------------------------------------- *//* SMS Client, send messages to mobile phones and pagers		*//*									*//* gs_translate.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 "common.h"#include "logfile.h"#include "gs_token.h"#include "gs_list.h"#include "gs_translate.h"#include "gs_parser.h"/* -------------------------------------------------------------------- *//* -------------------------------------------------------------------- */static char *get_word(char *string, char **eptr);/* -------------------------------------------------------------------- *//* -------------------------------------------------------------------- */TOKEN_HEAP *gs_parse_file(char *file){	TOKEN_HEAP 		*token_heap;	TOKEN_ID		token_id;	init_builtin_heap();	token_heap = (TOKEN_HEAP *)malloc(sizeof(TOKEN_HEAP));	if (token_heap == NULL)	{	return NULL;	}	token_heap->list = NULL;	if (gs_open(file))	{	return NULL;	}	if (parse_dictionary(token_heap))	{		token_id = get_next_token(token_heap);		if (token_id != eof_tok)		{			gs_close();			return NULL;		}	}	else	{	gs_close();		return NULL;	}		if (gs_close())	{	return NULL;	}	return token_heap;}/* -------------------------------------------------------------------- *//* -------------------------------------------------------------------- */static char *get_word(char *string, char **eptr){static	char 	word[1024],		*word_ptr,		*ptr;	if (*string == '\0')	{	return NULL;	}	word_ptr = word;	ptr = string;	while (*ptr != '\0')	{		if (*ptr == '.')		{	break;		}		*word_ptr++ = *ptr++;	}	*word_ptr = '\0';	if (*ptr != '\0')	{	ptr++;	}	*eptr = ptr;	return word;}/* -------------------------------------------------------------------- *//* -------------------------------------------------------------------- */char *get_strvalue(TOKEN_HEAP *heap, char *variable){	char 	*ptr,		*str,		*word;	TOKEN	*token;	lprintf(LOG_VERYVERBOSE, "Searching for variable '%s'\n", variable);	str = NULL;	word = get_word(variable, &ptr);	while(word != NULL)	{		token = find_item(heap->list, word, T_IDENTIFIER);		if (token == NULL)		{	return NULL;		}		if (get_token_type(heap, token) == T_IDENTIFIER)		{			if (get_token_indirect_type(heap, token) == TP_STRING)			{				str = get_token_indirect_string(heap, token);			}			else			if ((get_token_indirect_type(heap, token) == TP_DICTIONARY) ||			    (get_token_indirect_type(heap, token) == TP_LIST))			{				heap = get_token_indirect_dictionary(heap, token);			}		}		else		{	return NULL;		}		word = get_word(ptr, &ptr);	}	return str;}/* -------------------------------------------------------------------- *//* -------------------------------------------------------------------- */TOKEN_HEAP *get_varlist(TOKEN_HEAP *heap, char *variable){	char 	*ptr,		*word;	TOKEN	*token;	word = get_word(variable, &ptr);	while(word != NULL)	{		token = find_item(heap->list, word, T_IDENTIFIER);		if (token == NULL)		{	return NULL;		}		if (get_token_type(heap, token) == T_IDENTIFIER)		{			if ((get_token_indirect_type(heap, token) == TP_DICTIONARY) ||			    (get_token_indirect_type(heap, token) == TP_LIST))			{				heap = get_token_indirect_dictionary(heap, token);			}			else			{	return NULL;			}		}		else		{	return NULL;		}		word = get_word(ptr, &ptr);	}	return heap;}

⌨️ 快捷键说明

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