CCL Home Page
Up Directory CCL stertext.c
/**************************************************************************/
/**************************************************************************/
/**************************   "steric"   **********************************/
/**************************************************************************/
/*************     Program to calculate ligand cone    ********************/
/*************     angles as a measure of steric size  ********************/
/**************************************************************************/
/**************************************************************************/

/**************************************************************************/
/******************      Text mode Functions     **************************/
/**************************************************************************/
/******************        This module is        **************************/
/******************      system independant      **************************/
/**************************************************************************/

#include 
#include 

#include "sterdefn.h" /* declaration of structures, functions and globals */
#include "stertext.h" /* all text functions for text mode                 */

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

int Out_Message(char *message, char mode)
{
  switch(mode)
  {
    case O_BLANK : fprintf(output,"%s",message); break;
    case O_CARET : fprintf(output,"%s\r",message); break;
    case O_NEWLN : fprintf(output,"%s\n",message); break;
    case O_CRNLN : fprintf(output,"%s\r\n",message); break;
    default      : fprintf(output,"%s",message); break;
  }
  return(1);
}

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

int Error_Message(int error, char *string)
{
  FILE *err;
  char word[ERR_NUM+1];
  char line[LINELEN];
  int count=0,num=0,l=0;

  sprintf(line,"steric.err");
  if ((err = fopen(line, "rt")) == NULL)
  {
    sprintf(line,"%s/steric.err",STERICHOME);
    if ((err = fopen(line, "rt")) == NULL)
    {
      sprintf(line,"No error message file [steric.err] | [%s/steric.err]",STERICHOME);
      Out_Message(line,O_NEWLN);
    }
  }
  else
  {
    while(fgets(line,115,err)!=NULL)
    {
      if(line[0]!='#')
      {
        for(count=0;countERR_NUM) Out_Message(line+ERR_NUM,O_BLANK);
          else Out_Message("",O_NEWLN);
          l++;
        }
      }
    }
    fclose(err);
  }
  return(0);
}

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

int Title(void)
{
  char line[120];
  sprintf(line,"                            STERIC");
  Out_Message(line,O_NEWLN);
  sprintf(line,"             text version %4.2f by B.C.Taverner %d/'%d",(float)VERSION/100,V_MONTH,V_YEAR);
  Out_Message(line,O_NEWLN);
  sprintf(line,"   Calculations of Cone Angles, Solid Angles, Volumes and Areas");
  Out_Message(line,O_NEWLN);
  sprintf(line,"               as Measures of Molecule Steric Size");
  Out_Message(line,O_NEWLN);
  Out_Message("",O_NEWLN);
  return(1);
}

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

int Get_Yes_No_Request(char *line, unsigned mode, FILE *input)
{
  char ans[10];
  ans[1]='>';
  ans[2]=0;
  if(mode) { ans[0]='y'; mode='y'; }
  else { ans[0]='n'; mode='n'; }
  if(input==stdin) printf("%s <",line);
  Get_Input_Line(ans,input);
  while(1)
  {
    if((ans[0]=='n')||(ans[0]=='N')) return(0);
    else if((ans[0]=='y')||(ans[0]=='Y')) return(1);
    else ans[0]=mode;
  }
  return(1);
}

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

int Get_Input_Line(char *line, FILE *input)
{
  if(input==stdin)
  {
    printf(line);
  }
  if((fgets(line,LINELEN-2,input)==NULL)||(feof(input)))
  {
    printf(line);
    if(fgets(line,LINELEN-2,stdin)==NULL) return(2);
    if(strchr(line,'\n')) *strchr(line,'\n')=0;
    return(0);
  }
  if(strchr(line,'\n')) *strchr(line,'\n')=0;
  return(1);
}

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

int Get_Command_Line(char *line, FILE *input)
{
  return(Get_Input_Line(line,input));
}

/**************************************************************************/
/*************************  The End ... ***********************************/
/**************************************************************************/

Modified: Fri Dec 8 17:00:00 1995 GMT
Page accessed 4532 times since Sat Apr 17 22:00:01 1999 GMT