📄 build_stn_path.c
字号:
/*===========================================================================*//* DMC Interim | build_stn_path | Header_phase *//*===========================================================================*//* Name: build_stn_path Purpose: construct the base path to station info Usage: char *build_stn_path (); char *basepath; char *path; int error; error = build_stn_path (stationname, basepath, path); Input: stationname = string containing station name; e.g., "ANMO" may have trailing blanks on it; either works. basepath = string containing path to directory containing station info Output: path = string containing path to station info error = error value; FALSE if no error, nonzero otherwise. It contains values of MESSAGE, WARNING, ERROR, or FATAL (see constants.h) Externals: Debug - setting of environment variable DEBUG (globals.h) Messages: none Warnings: none Errors: Station name contains invalid characters or is too long; return to caller with empty path Fatals: none Called by: get_stn_hdr, get_chnl_hdr Calls to: error_handler - handle error conditions Algorithm: check station name for validity (return ERROR if not); construct path to station info Notes: none Problems: none known Debug: level D_MIN - print out start and finish notices level D_MED - print out constructed path level D_MAX - not used References: none Language: C, more or less ANSI standard, under Sun OS 3.5 Revisions: 02/24/89 Dennis O'Neill original version 05/04/89 Kevin MacKenzie changed return value to error, returning path via ptr 05/16/95 CL - no more ## signs*/#include "output.h"#ifndef CTYPE_INCLUDED#include <ctype.h>#define CTYPE_INCLUDED 1#endifint build_stn_path (stationname, network_code, basepath, path)char *stationname; /* station name */char *network_code;char *basepath; /* root path to stn info */char *path; /* path to stn info */{ int error; /* return error value */ unsigned int namelength; /* length of stn name */ unsigned int pathlength; /* length of path name */ char message[MSGLENGTH+1]; /* error message string */ char *p; /* internal ptr to path */ int i; /* general use int */ char stn[20]; if (Debug >= D_MIN) fprintf (D_OUT, "[build_stn_path] Started %s.\n", stationname); error = FALSE; p = path; /*=====================================*//*=================| check station name for validity |=================*/ /*=====================================*/ strcpy(stn, stationname); namelength = strlen (stn); if (namelength > 5) { sprintf (message, "[build_stn_path] station name >>%s<< too long.\n", stationname); error = ERROR; } for (i = 0; i < namelength; i++) { if ((isupper(stn[i]) || stn[i] == SPACE || stn[i] == '_' || isdigit(stn[i]) ) == FALSE) { sprintf (message, "[build_stn_path] bad station name >>%s<<.\n", stn); error = ERROR; } } if (error) { sprintf (path, ""); error = error_handler (error, message); return (error); } /*=====================================*//*=================| build path name |=================*/ /*=====================================*/ sprintf (path, "%s/%s.%s", basepath, stn, trim_str(network_code)); if (Debug >= D_MED) fprintf (D_OUT, "[build_stn_path] Path is %s.\n", path); if (Debug >= D_MIN) fprintf (D_OUT, "[build_stn_path] Completed.\n"); return (error);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -