/* $Id: g,v 1.1.1.1 2008/11/28 17:57:26 kiesling Exp $ -*-c-*-**/

/*
  This file is part of ctalk.
  Copyright  2005-2008 Robert Kiesling, ctalk@ctalklang.org.
  Permission is granted to copy this software provided that this copyright
  notice is included in all source code modules.

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/*
 *  Template for C library functions getc, getchar, and getpid.
 */

#define getc \n\
cGetc (FILE *f) { \n\
	return NULL; \n\
} \n\

#define getchar \n\
cGetchar (void) { \n\
  OBJECT *result; \n\
  char buf[2]; \n\
\n\
  sprintf (buf, "%d", getchar ()); \n\
\n\
  result = __ctalkCreateObjectInit ("result", "Integer", \n\
		       "Magnitude", LOCAL_VAR, buf); \n\
\n\
  return result; \n\
} \n\

#define getpid \n\
cGetPID (void) { \n\
  OBJECT *result; \n\
  char buf[MAXLABEL]; \n\
\n\
  sprintf (buf, "%d", getpid ()); \n\
\n\
  result = __ctalkCreateObjectInit ("result", "Integer", \n\
		       "Magnitude", LOCAL_VAR, buf); \n\
\n\
  return result; \n\
} \n\

#define getenv \n\
cGetEnv (char *s) { \n\
  OBJECT *result; \n\
  char buf[MAXLABEL]; \n\
\n\
  strcpy (buf, (getenv (__ctalk_to_c_char_ptr(__ctalk_arg_internal(0))) ? \
    getenv(__ctalk_to_c_char_ptr(__ctalk_arg_internal(0))) : NULLSTR)); \n\
\n\
  result = __ctalkCreateObjectInit ("result", "String", \n\
		       "Character", LOCAL_VAR, buf); \n\
\n\
  return result; \n\
} \n\

#define getcwd \n\
cGetCwd (void) { \n\
  char buf[FILENAME_MAX]; \n\
  getcwd (buf, FILENAME_MAX);   \n\
  return __ctalkCreateObjectInit ("result", "String", \n\
                                  "Character", LOCAL_VAR, buf); \n\
}\n\
