Logo Search packages:      
Sourcecode: epcr version File versions  Download package

gdsutil.cpp

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>

#include "gdsutil.h"



char *newstring(const char *str)
{
      char *string = NULL;
      if (str)
      {
            int len = strlen(str);
            string = new char[1+len];
            strcpy(string,str);
      }
      return string;
}




void chop(char *string)
{
      char *p = (char*) strchr(string,0);
      while (p > string)
      {
            p--;
            if (isspace(*p))
                  *p = 0;
            else
                  break;
      }
}


int split (char *info, char *delim, char **arr, int dim)
{
      int i, n=0;
      char *p = strtok(info,delim);
      while (p)
      {
            if (n==dim) break;
            arr[n++] = p;
            p = strtok(NULL,delim);
      }

      for (i=n; i<dim; i++) 
            arr[i] = NULL;
      
      return n;
}



Generated by  Doxygen 1.6.0   Back to index