ftp.nice.ch/pub/next/science/mathematics/hippoplotamus.2.0.s.tar.gz#/hippo2.0/getarg.c

This is getarg.c in view mode; [Download] [Up]

/*
 * getarg, iargc - return to Fortran a command line argument
 *
 * Usage:
 *     
 *    character*N c
 *    integer i,j
 *    integer function iargc
 * 
 *          call getarg(i,c)
 *          j = iargc 
 *   
 *    getarg returns the i-th command line argument of the current process,
 *    filled with trailing blanks as needed.
 *    The 0th command line argument is the full
 *	  pathname of the application's executable file.
 *
 *    iargc returns the index of the last argument.
 *  							
 * restrictions:				
 *		It is up to the FORTRAN programmer to provide	
 *		a character array that is big enough.			
 *													
 * notes:											
 *		The third dummy argument is passed implicitly   
 *		by the compiler. Accessing this argument is     
 * 		somewhat C compiler dependent and probably a	
 *		good place to look if this routine stops 		
 *		working under a different compiler.	
 *
 * Written for NeXT OS 1.0 by Paul Kunz, SLAC, August 1990
 *
 * Copyright (C) 1990 The Board of Trustees of The Leland Stanford
 * Junior University.  All Rights Reserved.
 *
 */			

int iargc( int *dummy )
{
	extern int NXArgc;	/* argc saved in crt0	*/
	
	return (NXArgc-1);
}

void getarg( iarg, carray, dummy, esize )

long *iarg;		/* pointer to fortran integer*4			*/
char *carray;	/* pointer to fortran character array	*/
int dummy;		/* dummy size for iarg					*/
int esize;		/* size of fortran character array		*/

{
extern int    NXArgc;		/* argc saved in crt0	*/
extern char **NXArgv;		/* argv saved in crt0	*/
int i, j;
char *c;

	i = *iarg;
	j = esize;
	if ( i >= 0 && i < NXArgc ) {
		c = NXArgv[i];
		while (*c) {	/* copy characters until null	*/
			*carray++ = *c++;
			j--;
		}
	}
	for ( ; j > 0 ; j-- )	/* add any trailing blanks needed */
		*carray++ = ' ';
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.