Main Page | Directories | File List | Globals

strings.c File Reference

#include <agnix/agnix.h>

Include dependency graph for strings.c:

Go to the source code of this file.

Defines

#define STRINGS_MAX_LEN   4096

Functions

int strlen (char *buf)
int strcmp (char *a, char *b)
int word_len (char *buf, int max_len)
char * word_next (char *buf, int max_len)
int word_cmp (char *a, char *b, int max_len)


Define Documentation

#define STRINGS_MAX_LEN   4096
 

Definition at line 16 of file strings.c.

Referenced by strcmp(), and strlen().


Function Documentation

int strcmp char *  a,
char *  b
 

Definition at line 33 of file strings.c.

References STRINGS_MAX_LEN.

Referenced by adi_chrdev_find_by_name(), device_check_redund(), main(), and vendor_check_redund().

00034 {
00035     int i;
00036 
00037     for (i = 0; i < STRINGS_MAX_LEN; i++, a++, b++) {
00038         if (*a != *b)
00039             return -1;
00040         
00041         if (*a == 0)
00042             return 0;
00043     }
00044     
00045     return 0;
00046 }

int strlen char *  buf  ) 
 

Definition at line 18 of file strings.c.

References STRINGS_MAX_LEN.

Referenced by adi_netdev_set_name(), agnix_console_print_help_name(), main(), and net_addr().

00019 {
00020     int i;
00021 
00022     if (buf[0] == 0)
00023         return 0;
00024 
00025     for(i = 0; i < STRINGS_MAX_LEN; i++) {
00026         if (buf[i] == 0)
00027             return i;// - 1;
00028     }
00029     
00030     return -1;
00031 }

int word_cmp char *  a,
char *  b,
int  max_len
 

Definition at line 82 of file strings.c.

Referenced by adi_netdev_find_by_name(), and agnix_console_command_exec().

00083 {
00084     int len;
00085 
00086     for (len = 0; len < max_len; len++, a++, b++) {
00087         
00088         if (((*a == ' ') || (*a == '\n') || (*a == 0)) && 
00089             ((*b == ' ') || (*b == '\n') || (*b == 0)))
00090             return 0;
00091 
00092         if (*a != *b)
00093             return -1;
00094     }
00095     
00096     return -1;
00097 }

int word_len char *  buf,
int  max_len
 

Definition at line 48 of file strings.c.

00049 {
00050     int len;
00051     
00052     for (len = 0; len < max_len; len++) {
00053         if ((buf[len] == ' ') || (buf[len] == '\n'))
00054             return len;
00055     }
00056     
00057     return len;
00058 }

char* word_next char *  buf,
int  max_len
 

Definition at line 60 of file strings.c.

Referenced by agnix_console_command_exec(), and agnix_console_net_ifconfig().

00061 {
00062     int end;
00063     int len;
00064     
00065     end = 0;
00066     for (len = 0; len < max_len; len++) {
00067         if (buf[len] == ' ') {
00068             end = 1;
00069             continue;
00070         }
00071 
00072         if ((buf[len] == 0) || (buf[len] == '\n'))
00073             return NULL;
00074         
00075         if ((buf[len] != ' ') && (end))
00076             return &buf[len];
00077     }
00078     
00079     return NULL;
00080 }

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix