©2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

c5/builtin.c

Go to the documentation of this file.
00001 /*
00002     asg and set built-in commands (used in shells)
00003     AUP2, Sec. 5.04
00004 
00005     Copyright 2003 by Marc J. Rochkind. All rights reserved.
00006     May be copied only for purposes and under conditions described
00007     on the Web page www.basepath.com/aup/copyright.htm.
00008 
00009     The Example Files are provided "as is," without any warranty;
00010     without even the implied warranty of merchantability or fitness
00011     for a particular purpose. The author and his publisher are not
00012     responsible for any damages, direct or incidental, resulting
00013     from the use or non-use of these Example Files.
00014 
00015     The Example Files may contain defects, and some contain deliberate
00016     coding mistakes that were included for educational reasons.
00017     You are responsible for determining if and how the Example Files
00018     are to be used.
00019 
00020 */
00021 #include "defs.h"
00022 #include "builtin.h"
00023 #include "setenv.h"
00024 
00025 /*[asg]*/
00026 void asg(int argc, char *argv[])
00027 {
00028     char *name, *val;
00029 
00030     if (argc != 1)
00031         printf("Extra args\n");
00032     else {
00033         name = strtok(argv[0], "=");
00034         val = strtok(NULL, ""); /* get all that's left */
00035         if (name == NULL || val == NULL)
00036             printf("Bad command\n");
00037         else
00038             ec_neg1( setenv(name, val, true) )
00039     }
00040     return;
00041 
00042 EC_CLEANUP_BGN
00043     EC_FLUSH("asg")
00044 EC_CLEANUP_END
00045 }
00046 /*[set]*/
00047 extern char **environ;
00048 
00049 void set(int argc, char *argv[])
00050 {
00051     int i;
00052 
00053     if (argc != 1)
00054         printf("Extra args\n");
00055     else
00056         for (i = 0; environ[i] != NULL; i++)
00057             printf("%s\n", environ[i]);
00058 }
00059 /*[]*/

Generated on Fri Apr 23 10:56:56 2004 for AUP2 Example Source by doxygen 1.3.1