Main Page   Compound List   File List   Compound Members   File Members  

parse_comline.c

Go to the documentation of this file.
00001 
00002 /*=====================================================================
00003                 =======   COPYRIGHT NOTICE   =======
00004 Copyright (C) 1996, Carnegie Mellon University, Cambridge University,
00005 Ronald Rosenfeld and Philip Clarkson.
00006 
00007 All rights reserved.
00008 
00009 This software is made available for research purposes only.  It may be
00010 redistributed freely for this purpose, in full or in part, provided
00011 that this entire copyright notice is included on any copies of this
00012 software and applications and derivations thereof.
00013 
00014 This software is provided on an "as is" basis, without warranty of any
00015 kind, either expressed or implied, as to any matter including, but not
00016 limited to warranty of fitness of purpose, or merchantability, or
00017 results obtained from use of this software.
00018 ======================================================================*/
00019 
00027 #include <string.h>
00028 #include <stdio.h>
00029 #include "rr_libs/general.h"
00030 
00031 void parse_comline(char *input_line,
00032                    int *num_of_args,
00033                    char **args) {
00034 
00035   int next_space;
00036   char next_word[200];
00037 
00038   *num_of_args = 0;
00039 
00040   while (strlen(input_line) > 0) {
00041     
00042     if (input_line[0] == ' ') {
00043       input_line = &(input_line[1]);
00044     }
00045     else {
00046       next_space = strcspn(input_line," ");
00047 
00048       if (input_line[next_space]==' ') {
00049         strncpy(next_word,input_line,next_space);
00050         next_word[next_space] = '\0';
00051         input_line = &(input_line[next_space+1]);
00052       }
00053       else {
00054         strcpy(next_word,input_line);
00055         input_line[0]='\0';
00056       }
00057 
00058       args[*num_of_args] = salloc(next_word);
00059 
00060       (*num_of_args)++;
00061       
00062     }
00063   }
00064   
00065 }

Generated on Tue Dec 21 13:54:45 2004 by doxygen1.2.18