Main Page   Modules   Data Structures   File List   Data Fields   Globals  

C_libs/gen/strings.c

Go to the documentation of this file.
00001 /* === Doxygen File Comment ============================== */
00010 /* ======================================================= */
00011 
00012 #include <strings.h>
00013 #include <string.h>
00014 #include <ctype.h>
00015 
00016 /* --- Doxygen Function Comment -------------------------- */
00020                 /* @{ ***** Starting group3 ***** */
00026 /* ------------------------------------------------------- */
00027 
00028 int 
00029 first_blk(char *string)
00030 {
00031         long    n;
00032 
00033         n = strcspn(string, " ");
00034         if (n >= 0 && n < strlen(string))       
00035                 string[n] = '\0';
00036         return (n);
00037 }
00038 
00039 /* --- Doxygen Function Comment -------------------------- */
00046 /* ------------------------------------------------------- */
00047 
00048 int 
00049 last_char(char *string)
00050 {
00051         long    n;
00052 
00053         for (n=strlen(string)-1;string[n] == ' ' && n>=0; n--)
00054                 string[n] = '\0';
00055         return(n+1);
00056 }
00057 
00058 /* --- Doxygen Function Comment -------------------------- */
00065 /* ------------------------------------------------------- */
00066 
00067 int 
00068 fill_blk(char *string, int nb_blk)
00069 {
00070         long    i,n;
00071 
00072         n = strlen(string);
00073     for (i=0; (i+n) <nb_blk; i++)
00074                 string[n+i] = ' ';
00075         return (0);
00076 }
00077 
00078 /* --- Doxygen Function Comment -------------------------- */
00085 /* ------------------------------------------------------- */
00086 
00087 int 
00088 string_compar(char *string1, char *string2)
00089 {
00090         char   *pt1, *pt2;
00091         long    n;
00092 
00093         for (n = 0, pt1 = string1, pt2 = string2; *pt1 == *pt2 && *pt1 != '\0'; 
00094                                                                    pt1++, pt2++, n++);
00095         return (n);
00096 }
00097 
00098 /* --- Doxygen Function Comment -------------------------- */
00105                 /* @{ ***** Starting group4 ***** */
00111 /* ------------------------------------------------------- */
00112 
00113 int 
00114 is_upper_string(char *string)
00115 {
00116         char   *pt;
00117 
00118         for (pt = string; *pt != '\0'; pt++) {
00119                 if (islower(*pt)) return 0; 
00120         }
00121         return(1);
00122 }
00123 
00124 
00125 /* --- Doxygen Function Comment -------------------------- */
00131 /* ------------------------------------------------------- */
00132 
00133 int 
00134 is_lower_string(char *string)
00135 {
00136         char   *pt;
00137 
00138         for (pt = string; islower(*pt) && *pt != '\0'; pt++);
00139         if (*pt != '\0') 
00140                 return(0);
00141         else
00142                 return(1);
00143 }
00144 
00145 /* --- Doxygen Function Comment -------------------------- */
00151 /* ------------------------------------------------------- */
00152 void 
00153 lower_strg(char *string)
00154 {
00155         int len, i;
00156 
00157         if (is_lower_string(string))
00158                 return;
00159 
00160         len = strlen(string);
00161         for (i=0; i<len; i++)
00162                 string[i] = tolower(string[i]);
00163         return;
00164 }
00165 
00166 /* --- Doxygen Function Comment -------------------------- */
00172 /* ------------------------------------------------------- */
00173 
00174 void 
00175 upper_strg(char *string)
00176 {
00177         int len, i;
00178 
00179         if (is_upper_string(string))
00180                 return;
00181 
00182         len = strlen(string);
00183         for (i=0; i<len; i++)
00184                 string[i] = toupper(string[i]);
00185         return;
00186 }

Generated on Tue Jul 1 17:35:44 2003 for IFU_C_iolibs by doxygen1.3