temp.c File Reference

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

Include dependency graph for temp.c:

Go to the source code of this file.

Functions

int get_n_token (char *s)
int main (int argc, char **argv)
void strip_string (char *)


Function Documentation

int get_n_token ( char *  s  ) 

Definition at line 87 of file temp.c.

Referenced by strip_string().

00088 {
00089   int i, n;
00090   int l = strlen (s);
00091   printf ("l = %d\n", l);
00092   for (i = 0, n = 0; s[i] != '\0'; i++)
00093     if ((i != (l-1)) && s[i] == '/') n++;
00094   return n;
00095 }

int main ( int  argc,
char **  argv 
)

Definition at line 36 of file temp.c.

References strip_string().

00037 {
00038   int n = 0;
00039   printf ("argv[1] = %s (request)\n", argv[1]);
00040   printf ("argv[2] = %s (service)\n", argv[2]);
00041   
00042   n = strcmp (argv[1], argv[2]);
00043   if (n < 0) {
00044     printf ("less \n");
00045     if (!strcmp (argv[1], "/")) {
00046       printf ("object path /\n");
00047     } else {
00048       printf ("\n");
00049     }
00050       strip_string (argv[1]);
00051   } else if (n > 0) {
00052     printf ("greater \n");
00053   } else {
00054     printf ("equal \n");
00055   }
00056 
00057   return 0;
00058 }

Here is the call graph for this function:

void strip_string ( char *  s  ) 

Definition at line 60 of file temp.c.

References get_n_token().

Referenced by main().

00061 {
00062   int i, n_token;
00063   int n = 0;
00064   char *n_s, *tmp;
00065   char *token;
00066   char **lt;
00067   printf ("S = %s\n", s);
00068   
00069   n = strlen(s) +1;
00070   tmp = (char *) malloc(n);
00071   memset (tmp, 0, n);
00072   memcpy (tmp, s, n);
00073   n_token = get_n_token (s);
00074   lt = (char **) malloc (sizeof (char *[n_token]));
00075   
00076   for (i = 0, token = strtok_r (tmp, "/", &n_s); token;
00077        token = strtok_r (n_s, "/", &n_s), i++) 
00078     lt[i] = token;
00079 
00080   for (i = 0; i < n_token; i++)
00081     printf ("token%d = %s\n", i, lt[i]);
00082   free (tmp);
00083   free (lt);
00084   printf ("S = %s, n = %d\n", s, i);
00085 }

Here is the call graph for this function:


Generated on Thu Apr 10 10:01:00 2008 for EasyDbus-0.2 by  doxygen 1.5.4