#include <stdio.h>
#include <math.h>
#include "pi.h"
#include "type.h"

/* structure which saves line parameters */

typedef struct {


	} LINE;

extern FILE *fdata;

/**********************************************************************

			line()

************************************************************************

Function computes the ABCD matrix of a

Inputs: pointer to the data structure for the twoport and the frequency
Output: ABCD matrix for the twoport
*/

ABCD line(current,f)
TWOPORT *current; 	/* twoport being modelled */
double f;		/* frequency */

{
	ABCD tmsect;
	POINTER calloc();
	LINE *param;

/* the first time this function is called we simply read the parameters
   of the line from the input line */

	if(current->line != NULL) {

		/* allocate storage for the line parameters -- this
		   function may be called for many lines so it has to
		   be unique */

		if((current->param = calloc(1,sizeof(LINE))) == NULL)
			error_alloc();

		param = (LINE *) current->param;

		if(sscanf(current->line,"line%f%d",
		&param->length,&param->gauge) != 2) {
			fprintf(stderr,
		"line(): cannot read parameters on line\n%s\n",
			current->line);
			exit(1);
			}

		fprintf(fdata,"Transmission line %f km long with gauge AWG%d\n",
			param->length,param->gauge);
		}

/* every other time this function is called we calculate the ABCD matrix */

	else 	{

		param = (LINE *) current->param;

		}

	return(tmsect);
}

