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

📄 get_data_path.c

📁 seed格式数据解压程序,地震分析人员必备
💻 C
字号:
/*===========================================================================*//* DMC interim out |            get_data_path              |         utility *//*===========================================================================*//*	Name:		get_data_path	Purpose:	recover base location for SEED data from environment	Usage:		struct path_list *get_data_path ();	Input:		Environment Variable "DATA_PATH"				of the form, "a:b:c:d"	Output:		a pointer to a circularly linked list of struct path_list	Externals:	none	Messages:	none	Warnings:	none	Errors:		none	Fatals:		none	Called by:	anything	Calls to:	none	Algorithm:	read the value of the environment variable DATA_PATH				and parse it, constructing the list. If there is no				DATA_PATH, default to value of string "noenv".	Notes:		usually called from main routine	Problems:	none known	Debug:		not used	References:	none	Language:	C	Revisions:	04mar89 mark wiederspahn	created, overwritten, retyped	19nov90		mw		change error level if no DATA_PATH in environment						from WARNING to FATAL - ain't no point to continue.*/#include <stdlib.h>#include "globals.h"#include "output.h"struct path_list *get_data_path (){char *p, *lp;							/* ptr to value of DATA_PATH */struct	path_list	*head, *tail;static char noenv[] = "cache";			/* default directory *//* Used for my testing - make sure to have ending '/' */static char *tmp_path = "/seed/0010142002/data_files/";	if( (p = (char *)getenv("DATA_PATH")) != NULL )	{		head = NULL;		tail = NULL;		lp = p;		while( lp >= p )					/* while other places to scan */		{			while( *p !=  0 && *p != ':' ) p++;	/* find terminator */			if( head == NULL )				head = tail =					(struct path_list *)						malloc( sizeof(struct path_list) );			else			{				tail->next =					(struct path_list *)						malloc( sizeof(struct path_list) );				tail = tail->next;			}			tail->next = NULL;#if 0/* #### added tmp_path for debugging and testing CL #### */			tail->path = (char *)malloc( sizeof(char)*(p-lp+1) + strlen(tmp_path));			strcpy(tail->path, tmp_path);/* ### changed strncpy to strcat - took out terminator line### */			strncat( tail->path, lp, (p-lp) );		/* 	*(tail->path+(p-lp+1)) = 0; */#else			tail->path = (char *)malloc(sizeof(char)*(p-lp+1));			strncpy(tail->path, lp, (p-lp));             *(tail->path+(p-lp)) = 0;#endif			if( *p != 0) p = lp = p+1;		/* if not end, set for next */		}	}	else	{			head = tail =				(struct path_list *)					malloc( sizeof(struct path_list) );			tail->path = noenv;			if (!Write_Data)				error_handler( FATAL,					"[get_data_path] environment DATA_PATH not defined" );	}	tail->next = head;	return( head );}

⌨️ 快捷键说明

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