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

/**************************************************************************/
/******************    Menu command functions    **************************/
/**************************************************************************/
/******************        This module is        **************************/
/******************      system independant      **************************/
/**************************************************************************/

#include 
#include 
#include 

#include "stercomm.h"      /* definitions of all menu command options     */
#include "steraid.h"       /* additional functions needed                 */
#include "stertext.h"      /* all text functions for text mode            */
#include "stererr.h"       /* defines for all error calls                 */

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

Comm *New_Command(Comm *super, Comm *old
                 ,unsigned short level, char a, char *s, char *l)
{
  Comm *new=NULL;
  if((new=(Comm *)malloc(sizeof(Comm)))==NULL)
  {
	Error_Message(E_NOMEM,"New Command");
	return(NULL);
  }
  new->next=NULL;
  new->prev=NULL;
  new->lev=level;
  new->a=a;
  strcpy(new->s,s);
  strcpy(new->l,l);
  new->num=0;
  new->sub=NULL;
  if(super!=NULL)
  {
    super->sub=new;
    super->num++;
    if((level)&&(super->lev!=new->lev-1))
      Error_Message(E_BDCOMM,"New Command");
  }

  if(old==NULL) return(new);
  new->next=old->next;
  new->prev=old;
  if(old->next) old->next->prev=new;
  old->next=new;
  return(new);
}

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

int Merge_Arguements(char *line, char **args)
{
  int num=0;
  line[0]=0;
  while(numprev)) find=find->prev;
  while(find!=NULL)
  {
    if(((strlen(command)==1)&&(command[0]==find->a))
     ||((strlen(command)>1)&&(strncmp(command,find->s,4)==0)))
    {
      args[0]=find->a;
      args[1]=0;
      return(find);
    }
    find=find->next;
  }
  return(NULL);
}

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

int Find_Commands(char *args, char *line, char *command_line, Comm *comm)
{
  Comm *find=NULL;
  Comm *found=NULL;
  char command[C_LEN];
  int num=0, lev=0;
  char *argptr[MAXARG];
  char newline[C_LEN];

  args[0]=0;
  strcpy(newline,command_line);
  if((num=Get_Arguements(newline,argptr))==0) return(0);
  found=comm;
  do
  {
    strcpy(command,argptr[lev]);
    if((find=Test_Command(args+lev,command,found))==NULL) break;
    if(find->lev) found=find->sub;
    if(find!=NULL) lev++;
  } while((found!=NULL)&&(find!=NULL)&&(levlev) Merge_Arguements(line,argptr+lev);
  return(lev);
}

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

Comm *Initialize_Commands(void)
{
  Comm *first=NULL;
  Comm *c1=NULL;
  Comm *c2=NULL;
  Comm *c3=NULL;

/* file manipulation commands                                             */

  c1=New_Command(NULL,NULL,1,FILS,FILS_S,FILS_L);
  first=c1;
    c2=NULL;
    c2=New_Command(c1,c2,2,LOAD,LOAD_S,LOAD_L);
    c2=New_Command(c1,c2,2,SAVE,SAVE_S,SAVE_L);
    c2=New_Command(c1,c2,2,SVAS,SVAS_S,SVAS_L);
    c2=New_Command(c1,c2,2,SHEL,SHEL_S,SHEL_L);

/* Molecule manipulation commands                                         */

  c1=New_Command(NULL,c1,1,MOLE,MOLE_S,MOLE_L);
    c2=NULL;
    c2=New_Command(c1,c2,2,VIEW,VIEW_S,VIEW_L);
    c2=New_Command(c1,c2,2,NEXT,NEXT_S,NEXT_L);
    c2=New_Command(c1,c2,2,GOTO,GOTO_S,GOTO_L);
    c2=New_Command(c1,c2,2,PREV,PREV_S,PREV_L);
    c2=New_Command(c1,c2,2,KILL,KILL_S,KILL_L);
      c3=NULL;
      c3=New_Command(c2,c3,3,ATMS,ATMS_S,ATMS_L);
      c3=New_Command(c2,c3,3,TYPS,TYPS_S,TYPS_L);
      c3=New_Command(c2,c3,3,GRPS,GRPS_S,GRPS_L);
      c3=New_Command(c2,c3,3,GRPN,GRPN_S,GRPN_L);
      c3=New_Command(c2,c3,3,REST,REST_S,REST_L);
    c2=New_Command(c1,c2,2,CLOS,CLOS_S,CLOS_L);
      c3=NULL;
      c3=New_Command(c2,c3,3,ATMS,ATMS_S,ATMS_L);
      c3=New_Command(c2,c3,3,TYPS,TYPS_S,TYPS_L);
      c3=New_Command(c2,c3,3,GRPS,GRPS_S,GRPS_L);
      c3=New_Command(c2,c3,3,GRPN,GRPN_S,GRPN_L);
      c3=New_Command(c2,c3,3,MOLC,MOLC_S,MOLC_L);

/* symmetry manipulation commands                                         */

  c1=New_Command(NULL,c1,1,SYMM,SYMM_S,SYMM_L);
    c2=NULL;
    c2=New_Command(c1,c2,2,TRAN,TRAN_S,TRAN_L);
    c2=New_Command(c1,c2,2,XPND,XPND_S,XPND_L);
    c2=New_Command(c1,c2,2,BOXU,BOXU_S,BOXU_L);
    c2=New_Command(c1,c2,2,BOND,BOND_S,BOND_L);
    c2=New_Command(c1,c2,2,GRUP,GRUP_S,GRUP_L);
    c2=New_Command(c1,c2,2,XGRR,XGRR_S,XGRR_L);
    c2=New_Command(c1,c2,2,REDU,REDU_S,REDU_L);
    c2=New_Command(c1,c2,2,SHLV,SHLV_S,SHLV_L);
      c3=NULL;
      c3=New_Command(c2,c3,0,OLDL,OLDL_S,OLDL_L);
#ifdef _RYAN_
      c3=New_Command(c2,c3,0,RYAN,RYAN_S,RYAN_L);
#endif
      c3=New_Command(c2,c3,0,CRAI,CRAI_S,CRAI_L);
      c3=New_Command(c2,c3,0,VAOV,VAOV_S,VAOV_L);
      c3=New_Command(c2,c3,0,SAOV,SAOV_S,SAOV_L);
    c2=New_Command(c1,c2,2,SVOL,SVOL_S,SVOL_L);
      c3=NULL;
      c3=New_Command(c2,c3,0,FREV,FREV_S,FREV_L);
      c3=New_Command(c2,c3,0,GRPV,GRPV_S,GRPV_L);
      c3=New_Command(c2,c3,0,CAVV,CAVV_S,CAVV_L);
    c2=New_Command(c1,c2,2,SPRO,SPRO_S,SPRO_L);

/* calculation commands                                                   */

  c1=New_Command(NULL,c1,1,CALC,CALC_S,CALC_L);
    c2=NULL;
    c2=New_Command(c1,c2,2,TOTA,TOTA_S,TOTA_L);
      c3=NULL;
      c3=New_Command(c2,c3,0,CONE,CONE_S,CONE_L);
      c3=New_Command(c2,c3,0,TOLM,TOLM_S,TOLM_L);
      c3=New_Command(c2,c3,0,OLDL,OLDL_S,OLDL_L);
#ifdef _RYAN_
      c3=New_Command(c2,c3,0,RYAN,RYAN_S,RYAN_L);
#endif
      c3=New_Command(c2,c3,0,CRAI,CRAI_S,CRAI_L);
      c3=New_Command(c2,c3,0,NUME,NUME_S,NUME_L);
      c3=New_Command(c2,c3,0,VAOV,VAOV_S,VAOV_L);
      c3=New_Command(c2,c3,0,SAOV,SAOV_S,SAOV_L);
      c3=New_Command(c2,c3,0,PROJ,PROJ_S,PROJ_L);
      c3=New_Command(c2,c3,0,VOLM,VOLM_S,VOLM_L);
    c2=New_Command(c1,c2,2,CONF,CONF_S,CONF_L);
      c3=NULL;
      c3=New_Command(c2,c3,0,CONE,CONE_S,CONE_L);
      c3=New_Command(c2,c3,0,TOLM,TOLM_S,TOLM_L);
      c3=New_Command(c2,c3,0,OLDL,OLDL_S,OLDL_L);
#ifdef _RYAN_
      c3=New_Command(c2,c3,0,RYAN,RYAN_S,RYAN_L);
#endif
      c3=New_Command(c2,c3,0,CRAI,CRAI_S,CRAI_L);
      c3=New_Command(c2,c3,0,NUME,NUME_S,NUME_L);
      c3=New_Command(c2,c3,0,VAOV,VAOV_S,VAOV_L);
      c3=New_Command(c2,c3,0,SAOV,SAOV_S,SAOV_L);
      c3=New_Command(c2,c3,0,PROJ,PROJ_S,PROJ_L);
      c3=New_Command(c2,c3,0,VOLM,VOLM_S,VOLM_L);
    c2=New_Command(c1,c2,2,PROF,PROF_S,PROF_L);
      c3=NULL;
      c3=New_Command(c2,c3,0,ANGU,ANGU_S,ANGU_L);
      c3=New_Command(c2,c3,0,CONE,CONE_S,CONE_L);
      c3=New_Command(c2,c3,0,TOLM,TOLM_S,TOLM_L);
      c3=New_Command(c2,c3,0,OLDL,OLDL_S,OLDL_L);
#ifdef _RYAN_
      c3=New_Command(c2,c3,0,RYAN,RYAN_S,RYAN_L);
#endif
      c3=New_Command(c2,c3,0,CRAI,CRAI_S,CRAI_L);
      c3=New_Command(c2,c3,0,NUME,NUME_S,NUME_L);
      c3=New_Command(c2,c3,0,VAOV,VAOV_S,VAOV_L);
      c3=New_Command(c2,c3,0,SAOV,SAOV_S,SAOV_L);
    c2=New_Command(c1,c2,2,AREA,AREA_S,AREA_L);
      c3=NULL;
      c3=New_Command(c2,c3,3,THET,THET_S,THET_L);
      c3=New_Command(c2,c3,3,PHIP,PHIP_S,PHIP_L);
      c3=New_Command(c2,c3,3,MAPP,MAPP_S,MAPP_L);
    c2=New_Command(c1,c2,2,SVOL,SVOL_S,SVOL_L);
 
/* graphics commands                                                      */

  c1=New_Command(NULL,c1,1,PLOT,PLOT_S,PLOT_L);
    c2=NULL;
    c2=New_Command(c1,c2,2,ORTH,ORTH_S,ORTH_L);
    c2=New_Command(c1,c2,2,MOLP,MOLP_S,MOLP_L);
    c2=New_Command(c1,c2,2,CART,CART_S,CART_L);
      c3=NULL;
      c3=New_Command(c2,c3,0,ANGU,ANGU_S,ANGU_L);
      c3=New_Command(c2,c3,0,CONE,CONE_S,CONE_L);
      c3=New_Command(c2,c3,0,TOLM,TOLM_S,TOLM_L);
      c3=New_Command(c2,c3,0,OLDL,OLDL_S,OLDL_L);
#ifdef _RYAN_
      c3=New_Command(c2,c3,0,RYAN,RYAN_S,RYAN_L);
#endif
      c3=New_Command(c2,c3,0,CRAI,CRAI_S,CRAI_L);
      c3=New_Command(c2,c3,0,NUME,NUME_S,NUME_L);
      c3=New_Command(c2,c3,0,VAOV,VAOV_S,VAOV_L);
      c3=New_Command(c2,c3,0,SAOV,SAOV_S,SAOV_L);
      c3=New_Command(c2,c3,0,PROJ,PROJ_S,PROJ_L);
    c2=New_Command(c1,c2,2,POLA,POLA_S,POLA_L);
      c3=NULL;
      c3=New_Command(c2,c3,0,ANGU,ANGU_S,ANGU_L);
      c3=New_Command(c2,c3,0,CONE,CONE_S,CONE_L);
      c3=New_Command(c2,c3,0,TOLM,TOLM_S,TOLM_L);
      c3=New_Command(c2,c3,0,OLDL,OLDL_S,OLDL_L);
#ifdef _RYAN_
      c3=New_Command(c2,c3,0,RYAN,RYAN_S,RYAN_L);
#endif
      c3=New_Command(c2,c3,0,CRAI,CRAI_S,CRAI_L);
      c3=New_Command(c2,c3,0,NUME,NUME_S,NUME_L);
      c3=New_Command(c2,c3,0,VAOV,VAOV_S,VAOV_L);
      c3=New_Command(c2,c3,0,SAOV,SAOV_S,SAOV_L);
      c3=New_Command(c2,c3,0,PROJ,PROJ_S,PROJ_L);
    c2=New_Command(c1,c2,2,STER,STER_S,STER_L);
      c3=NULL;
      c3=New_Command(c2,c3,0,CONE,CONE_S,CONE_L);
      c3=New_Command(c2,c3,0,TOLM,TOLM_S,TOLM_L);
      c3=New_Command(c2,c3,0,OLDL,OLDL_S,OLDL_L);
#ifdef _RYAN_
      c3=New_Command(c2,c3,0,RYAN,RYAN_S,RYAN_L);
#endif
      c3=New_Command(c2,c3,0,CRAI,CRAI_S,CRAI_L);
      c3=New_Command(c2,c3,0,NUME,NUME_S,NUME_L);
      c3=New_Command(c2,c3,0,VAOV,VAOV_S,VAOV_L);
      c3=New_Command(c2,c3,0,SAOV,SAOV_S,SAOV_L);
      c3=New_Command(c2,c3,0,PROJ,PROJ_S,PROJ_L);
      c3=New_Command(c2,c3,0,VOLM,VOLM_S,VOLM_L);
    c2=New_Command(c1,c2,2,CONT,CONT_S,CONT_L);
    c2=New_Command(c1,c2,2,PRFC,PRFC_S,PRFC_L);

/* change data settings                                                   */

  c1=New_Command(NULL,c1,1,CHAN,CHAN_S,CHAN_L);
    c2=NULL;
    c2=New_Command(c1,c2,2,MOLC,MOLC_S,MOLC_L);
      c3=NULL;
      c3=New_Command(c2,c3,3,CMGP,CMGP_S,CMGP_L);
      c3=New_Command(c2,c3,3,PLAN,PLAN_S,PLAN_L);
    c2=New_Command(c1,c2,2,SETT,SETT_S,SETT_L);
      c3=NULL;
      c3=New_Command(c2,c3,3,ORDM,ORDM_S,ORDM_L);
      c3=New_Command(c2,c3,3,RANG,RANG_S,RANG_L);
      c3=New_Command(c2,c3,3,PLTP,PLTP_S,PLTP_L);
      c3=New_Command(c2,c3,3,ROTA,ROTA_S,ROTA_L);
      c3=New_Command(c2,c3,3,SIZE,SIZE_S,SIZE_L);
      c3=New_Command(c2,c3,3,MODE,MODE_S,MODE_L);
      c3=New_Command(c2,c3,3,ACCU,ACCU_S,ACCU_L);
      c3=New_Command(c2,c3,3,VOLG,VOLG_S,VOLG_L);
      c3=New_Command(c2,c3,3,BNDD,BNDD_S,BNDD_L);
    c2=New_Command(c1,c2,2,ORIG,ORIG_S,ORIG_L);
      c3=NULL;
      c3=New_Command(c2,c3,3,ATOM,ATOM_S,ATOM_L);
      c3=New_Command(c2,c3,3,DIST,DIST_S,DIST_L);
      c3=New_Command(c2,c3,3,GRPO,GRPO_S,GRPO_L);
    c2=New_Command(c1,c2,2,PARA,PARA_S,PARA_L);

/* view data settings                                                     */

  c1=New_Command(NULL,c1,1,VIEW,VIEW_S,VIEW_L);
    c2=NULL;
    c2=New_Command(c1,c2,2,MOLE,MOLE_S,MOLE_L);
      c3=NULL;
      c3=New_Command(c2,c3,0,ATMV,ATMV_S,ATMV_L);
      c3=New_Command(c2,c3,0,VGRP,VGRP_S,VGRP_L);
      c3=New_Command(c2,c3,0,SYMV,SYMV_S,SYMV_L);
    c2=New_Command(c1,c2,2,PARA,PARA_S,PARA_L);
    c2=New_Command(c1,c2,2,SETT,SETT_S,SETT_L);

/* help facility                                                          */

  c1=New_Command(NULL,c1,1,HELP,HELP_S,HELP_L);

/* exit steric                                                            */

  c1=New_Command(NULL,c1,1,EXIT,EXIT_S,EXIT_L);

  return(first);
}

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

void Close_All_Commands(Comm *comm)
{
  Comm *last=NULL;
  last=comm;
  if(comm!=NULL)
  {
    while(last->next!=NULL) last=last->next;
    while(last)
    {
      if(last->sub==NULL)
      {
        if(last->prev)
        {
          last=last->prev;
          free(last->next);
          last->next=NULL;
        }
        else
        {
          free(last);
          last=NULL;
        }
      }
      else
      {
        Close_All_Commands(last->sub);
        last->sub=NULL;
      }
    }
  }
}

/**************************************************************************/
/******************  The End ... ******************************************/
/**************************************************************************/
Modified: Fri Dec 8 17:00:00 1995 GMT
Page accessed 5186 times since Sat Apr 17 21:59:51 1999 GMT