00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <string.h>
00012 #include "vmsopt.h"
00013
00014
00015
00016
00017
00018
00019
00020
00021 int vmsopt_parse( int argc, char **argv )
00022 {
00023 extern
00024 char *vms_optstr,
00025 *vms_optarg;
00026 char *ptr;
00027 int i;
00028
00029
00030 for( i = 1; i < argc; i++ )
00031 {
00032
00033 if( argv[i][0] == 0 )
00034 continue;
00035
00036 if( argv[i][0] != '/' ) {
00037 vms_optstr = (char*) malloc ( strlen(argv[i]) + 1);
00038 strcpy( vms_optstr, argv[i] );
00039
00040 argv[i][0]=0;
00041 vms_optarg = NULL;
00042 return(VMSOPT_ARG_PL);
00043 }
00044
00045 if( strchr( argv[i], ':' ) == NULL )
00046 {
00047 vms_optstr = (char*) malloc ( strlen(argv[i]) + 1 );
00048 strcpy( vms_optstr, argv[i] );
00049 vms_optstr++;
00050 argv[i][0] = 0;
00051 vms_optarg = NULL;
00052 return(VMSOPT_NOARG);
00053 }
00054
00055 vms_optarg = (char*) malloc( strlen(strchr( argv[i], ':' )) + 1 );
00056 vms_optstr = (char*) malloc( ( strlen(argv[i] -
00057 strlen(strchr( argv[i], ':')) )) );
00058 strcpy( vms_optarg, strchr( argv[i], ':' ) );
00059 vms_optarg++;
00060 ptr = strchr(argv[i],':');
00061 ptr[0] = 0;
00062 strcpy( vms_optstr, argv[i] );
00063 argv[i][0] = 0;
00064 vms_optstr++;
00065 return(VMSOPT_ARG_CO);
00066 }
00067
00068 return(VMSOPT_DONE);
00069 }
00070
00071