[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gdiscuss] Solaris port



Dear gdis developers,

First, thank you for taking the time to work on the first free
software crystal structure viewer and editor I have been able to
find.  I particularly like the GULP and MARVIN'S interfaces.

Since I use Sun sparc solaris machines, I needed to port dismol, which
was not too hard.  I have attached a patch file of my changes, which
also contains (a) a fix for a bug in space.c and (b) also includes
code to recognise ".res" as a GULP file extension.

You may not wish to use the Makfile changes as they are mostly local
customization.  The one other thing you need for Solaris are the
functions "scandir" "alphasort" since Solaris doesn't have them.

Here's the source, courtesy of Joerg Rudiger-Hill.

/*******************************************************************************
*                                                                              *
*                                   Viewmol                                    *
*                                                                              *
*                              S C A N D I R . C                               *
*                                                                              *
*                 Copyright (c) Joerg-R. Hill, December 2000                   *
*                                                                              *
********************************************************************************
*
* $Id: scandir.c,v 1.2 2000/12/10 15:37:02 jrh Exp $
* $Log: scandir.c,v $
* Revision 1.2  2000/12/10 15:37:02  jrh
* Release 2.3
*
* Revision 1.1  1999/05/24 01:29:43  jrh
* Initial revision
*
*/
#include<dirent.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>

/* This function is only required for SunOS, all other supported OS
   have this function in their system library */

int scandir(const char *dir, struct dirent ***namelist,
            int (*select)(const struct dirent *),
            int (*compar)(const struct dirent **, const struct dirent **))
{
  DIR *d;
  struct dirent *entry;
  register int i=0;
  size_t entrysize;

  if ((d=opendir(dir)) == NULL)
     return(-1);

  *namelist=NULL;
  while ((entry=readdir(d)) != NULL)
  {
    if (select == NULL || (select != NULL && (*select)(entry)))
    {
      *namelist=(struct dirent **)realloc((void *)(*namelist),
                 (size_t)((i+1)*sizeof(struct dirent *)));
	if (*namelist == NULL) return(-1);
	entrysize=sizeof(struct dirent)-sizeof(entry->d_name)+strlen(entry->d_name)+1;
	(*namelist)[i]=(struct dirent *)malloc(entrysize);
	if ((*namelist)[i] == NULL) return(-1);
	memcpy((*namelist)[i], entry, entrysize);
	i++;
    }
  }
  if (closedir(d)) return(-1);
  if (i == 0) return(-1);
  if (compar != NULL)
    qsort((void *)(*namelist), (size_t)i, sizeof(struct dirent *), compar);
    
  return(i);
}

int alphasort(const struct dirent **a, const struct dirent **b)
{
  return(strcmp((*a)->d_name, (*b)->d_name));
}

I keep this as a library, but perhaps you will wish to include in the
compile.

sincerely

Keith Refson

-- 
Dr Keith Refson,        "Paradigm is a word too often used by those who would
Dept of Earth Sciences      like to have a new idea but cannot think of one." 
Parks Road,                  -- Mervyn King, Deputy Governor, Bank of England
Oxford OX1 3PR, UK        
Keith.Refson@                       Tel: 01865 272026
             earth.ox.ac.uk         Fax: 01865 272072