static int find_type_eol(const char **x, const TYPELIB *typelib, uint flags, const char *eol) { int find,pos; int UNINIT_VAR(findpos); /* guarded by find */ const char *UNINIT_VAR(termptr); const char *i; const char *j; CHARSET_INFO *cs= &my_charset_latin1; DBUG_ENTER("find_type_eol"); DBUG_PRINT("enter",("x: '%s' lib: 0x%lx", *x, (long) typelib)); DBUG_ASSERT(!(flags & ~(FIND_TYPE_NO_PREFIX | FIND_TYPE_COMMA_TERM))); if (!typelib->count) { DBUG_PRINT("exit",("no count")); DBUG_RETURN(0); } find=0; for (pos=0 ; (j=typelib->type_names[pos]) ; pos++) { for (i=*x ; i < eol && !is_field_separator(flags, *i) && my_toupper(cs, *i) == my_toupper(cs, *j) ; i++, j++) ; if (! *j) { while (i < eol && *i == ' ') i++; /* skip_end_space */ if (i >= eol || is_field_separator(flags, *i)) { *x= i; DBUG_RETURN(pos+1); } } if ((i >= eol && !is_field_separator(flags, *i)) && (!*j || !(flags & FIND_TYPE_NO_PREFIX))) { find++; findpos=pos; termptr=i; } } if (find == 0 || *x == eol) { DBUG_PRINT("exit",("Couldn't find type")); DBUG_RETURN(0); } else if (find != 1 || (flags & FIND_TYPE_NO_PREFIX)) { DBUG_PRINT("exit",("Too many possibilities")); DBUG_RETURN(-1); } *x= termptr; DBUG_RETURN(findpos+1); } /* find_type_eol */
int find_type(const char *x, const TYPELIB *typelib, uint flags) { int find,pos; int UNINIT_VAR(findpos); /* guarded by find */ const char *i; const char *j; DBUG_ENTER("find_type"); DBUG_PRINT("enter",("x: '%s' lib: 0x%lx", x, (long) typelib)); DBUG_ASSERT(!(flags & ~(FIND_TYPE_NO_PREFIX | FIND_TYPE_ALLOW_NUMBER | FIND_TYPE_NO_OVERWRITE | FIND_TYPE_COMMA_TERM))); if (!typelib->count) { DBUG_PRINT("exit",("no count")); DBUG_RETURN(0); } find=0; for (pos=0 ; (j=typelib->type_names[pos]) ; pos++) { for (i=x ; *i && (!(flags & FIND_TYPE_COMMA_TERM) || !is_field_separator(*i)) && my_toupper(&my_charset_latin1,*i) == my_toupper(&my_charset_latin1,*j) ; i++, j++) ; if (! *j) { while (*i == ' ') i++; /* skip_end_space */ if (! *i || ((flags & FIND_TYPE_COMMA_TERM) && is_field_separator(*i))) DBUG_RETURN(pos+1); } if ((!*i && (!(flags & FIND_TYPE_COMMA_TERM) || !is_field_separator(*i))) && (!*j || !(flags & FIND_TYPE_NO_PREFIX))) { find++; findpos=pos; } } if (find == 0 && (flags & FIND_TYPE_ALLOW_NUMBER) && x[0] == '#' && strend(x)[-1] == '#' && (findpos=atoi(x+1)-1) >= 0 && (uint) findpos < typelib->count) find=1; else if (find == 0 || ! x[0]) { DBUG_PRINT("exit",("Couldn't find type")); DBUG_RETURN(0); } else if (find != 1 || (flags & FIND_TYPE_NO_PREFIX)) { DBUG_PRINT("exit",("Too many possybilities")); DBUG_RETURN(-1); } DBUG_RETURN(findpos+1); } /* find_type */
int main() { char woord[] = "wooRdje"; char input[100]; my_toupper(woord); printf("After to upper: %s\n",woord); printf("Please enter a string you want to convert to uppercase: "); scanf("%100s",input); my_toupper(input); printf("\nThe word you entered to upper: %s\n",input); }
static int my_strcmpi ( const char * s1, /* string to compare */ const char * s2 /* string to compare <s1> to */ ) { while (my_toupper(*s1++) == my_toupper(*s2++)) if (s1 [-1] == 0) return (0); return (my_toupper(s1 [-1]) - my_toupper(s2 [-1])); }
int find_type(char *x, const TYPELIB *typelib, uint full_name) { int find,pos; int UNINIT_VAR(findpos); /* guarded by find */ reg1 char * i; reg2 const char *j; DBUG_ENTER("find_type"); DBUG_PRINT("enter",("x: '%s' lib: 0x%lx", x, (long) typelib)); if (!typelib->count) { DBUG_PRINT("exit",("no count")); DBUG_RETURN(0); } find=0; for (pos=0 ; (j=typelib->type_names[pos]) ; pos++) { for (i=x ; *i && (!(full_name & 8) || *i != field_separator) && my_toupper(&my_charset_latin1,*i) == my_toupper(&my_charset_latin1,*j) ; i++, j++) ; if (! *j) { while (*i == ' ') i++; /* skip_end_space */ if (! *i || ((full_name & 8) && *i == field_separator)) DBUG_RETURN(pos+1); } if ((!*i && (!(full_name & 8) || *i != field_separator)) && (!*j || !(full_name & 1))) { find++; findpos=pos; } } if (find == 0 && (full_name & 4) && x[0] == '#' && strend(x)[-1] == '#' && (findpos=atoi(x+1)-1) >= 0 && (uint) findpos < typelib->count) find=1; else if (find == 0 || ! x[0]) { DBUG_PRINT("exit",("Couldn't find type")); DBUG_RETURN(0); } else if (find != 1 || (full_name & 1)) { DBUG_PRINT("exit",("Too many possybilities")); DBUG_RETURN(-1); } if (!(full_name & 2)) (void) strmov(x,typelib->type_names[findpos]); DBUG_RETURN(findpos+1); } /* find_type */
int Curl_raw_equal(const char *first, const char *second) { while(*first && *second) { if(my_toupper(*first) != my_toupper(*second)) /* get out of the loop as soon as they don't match */ break; first++; second++; } /* we do the comparison here (possibly again), just to make sure that if the loop above is skipped because one of the strings reached zero, we must not return this as a successful match */ return (my_toupper(*first) == my_toupper(*second)); }
int Curl_raw_nequal(const char *first, const char *second, size_t max) { while(*first && *second && max) { if(my_toupper(*first) != my_toupper(*second)) { break; } max--; first++; second++; } if(0 == max) return 1; /* they are equal this far */ return my_toupper(*first) == my_toupper(*second); }
int check_if_legal_filename(const char *path) { const char *end; const char **reserved_name; DBUG_ENTER("check_if_legal_filename"); path+= dirname_length(path); /* To start of filename */ if (!(end= strchr(path, FN_EXTCHAR))) end= strend(path); if (path == end || (uint) (end - path) > MAX_RESERVED_NAME_LENGTH) DBUG_RETURN(0); /* Simplify inner loop */ for (reserved_name= reserved_names; *reserved_name; reserved_name++) { const char *reserved= *reserved_name; /* never empty */ const char *name= path; do { if (*reserved != my_toupper(&my_charset_latin1, *name)) break; if (++name == end && !reserved[1]) DBUG_RETURN(1); /* Found wrong path */ } while (*++reserved); } DBUG_RETURN(0); }
int main() { /* this is a pointer to the hexadecimal key digits */ char *cp = "1234567890abcdeffedcba09876543211234567890abcdeffedcba0987654321"; char ch; unsigned char key[32]; int i = 0, by = 0, key_len = 0, err = 0; struct aes ctx[1]; //-------------------------- struct my_FILE my_fin; my_fin.data = data; my_fin.size = 31369; my_fin.cur_pos = 0; //-------------------------- i = 0; /* this is a count for the input digits processed */ _Pragma( "loopbound min 64 max 64" ) while(i < 64 && *cp) /* the maximum key length is 32 bytes and */ { /* hence at most 64 hexadecimal digits */ // ch = toupper(*cp++); /* process a hexadecimal digit */ ch = my_toupper(*cp++); /* process a hexadecimal digit */ if(ch >= '0' && ch <= '9') by = (by << 4) + ch - '0'; else if(ch >= 'A' && ch <= 'F') by = (by << 4) + ch - 'A' + 10; else /* error if not hexadecimal */ { //printf("key must be in hexadecimal notation\n"); err = -2; return err; } /* store a key byte for each pair of hexadecimal digits */ if(i++ & 1) key[i / 2 - 1] = by & 0xff; } if(*cp) { //printf("The key value is too long\n"); err = -3; return err; } else if(i < 32 || (i & 15)) { //printf("The key length must be 32, 48 or 64 hexadecimal digits\n"); err = -4; return err; } key_len = i / 2; /* encryption in Cipher Block Chaining mode */ set_key(key, key_len, enc, ctx); err = encfile(&my_fin, ctx); return err; }
int main(void) { char ch; printf("input char : "); scanf("%c",&ch); printf("output char : %c",my_toupper(ch)); printf("\n"); return 0; }
void complex_hello(void) { const char *msg = "hello World!!!"; char *copy; /* my_kstrdup never returns a NULL pointer, no need to check */ copy = my_kstrdup(msg); /* We want 'Hello World!!!', need to capitalise the first letter */ copy[0] = my_toupper(copy[0]); kprintf("%s\n", copy); /* Free the allocated memory */ kfree(copy); }
static char get_scode(CHARSET_INFO * cs,char **ptr, pbool remove_garbage) { uchar ch; if (remove_garbage) { while (**ptr && !my_isalpha(cs,**ptr)) (*ptr)++; } ch=my_toupper(cs,**ptr); if (ch < 'A' || ch > 'Z') { if (my_isalpha(cs,ch)) /* If extended alfa (country spec) */ return '0'; /* threat as vokal */ return 0; /* Can't map */ } return(soundex_map[ch-'A']); } /* get_scode */
/************************************************************************** ... **************************************************************************/ void update_info_label( void ) { GtkWidget *label; const struct player *pplayer = client.conn.playing; label = gtk_frame_get_label_widget(GTK_FRAME(main_frame_civ_name)); if (pplayer != NULL) { char nation[MAX_LEN_NAME]; /* Capitalize the first character of the translated nation * plural name so that the frame label looks good. I assume * that in the case that capitalization does not make sense * (e.g. multi-byte characters or no "upper case" form in * the translation language) my_toupper() will just return * the same value as was passed into it. */ sz_strlcpy(nation, nation_plural_for_player(pplayer)); nation[0] = my_toupper(nation[0]); gtk_label_set_text(GTK_LABEL(label), nation); } else { gtk_label_set_text(GTK_LABEL(label), "-"); } gtk_label_set_text(GTK_LABEL(main_label_info), get_info_label_text()); set_indicator_icons(client_research_sprite(), client_warming_sprite(), client_cooling_sprite(), client_government_sprite()); if (NULL != client.conn.playing) { int d = 0; for (; d < client.conn.playing->economic.luxury /10; d++) { struct sprite *sprite = get_tax_sprite(tileset, O_LUXURY); gtk_image_set_from_pixbuf(GTK_IMAGE(econ_label[d]), sprite_get_pixbuf(sprite)); } for (; d < (client.conn.playing->economic.science + client.conn.playing->economic.luxury) / 10; d++) { struct sprite *sprite = get_tax_sprite(tileset, O_SCIENCE); gtk_image_set_from_pixbuf(GTK_IMAGE(econ_label[d]), sprite_get_pixbuf(sprite)); } for (; d < 10; d++) { struct sprite *sprite = get_tax_sprite(tileset, O_GOLD); gtk_image_set_from_pixbuf(GTK_IMAGE(econ_label[d]), sprite_get_pixbuf(sprite)); } } update_timeout_label(); /* update tooltips. */ gtk_tooltips_set_tip(main_tips, econ_ebox, _("Shows your current luxury/science/tax rates;" "click to toggle them."), ""); gtk_tooltips_set_tip(main_tips, bulb_ebox, get_bulb_tooltip(), ""); gtk_tooltips_set_tip(main_tips, sun_ebox, get_global_warming_tooltip(), ""); gtk_tooltips_set_tip(main_tips, flake_ebox, get_nuclear_winter_tooltip(), ""); gtk_tooltips_set_tip(main_tips, government_ebox, get_government_tooltip(), ""); }
int my_setwd(const char *dir, myf MyFlags) { int res; size_s length; my_string start,pos; #if defined(VMS) || defined(MSDOS) || defined(OS2) char buff[FN_REFLEN]; #endif DBUG_ENTER("my_setwd"); DBUG_PRINT("my",("dir: '%s' MyFlags %d", dir, MyFlags)); start=(my_string) dir; #if defined(MSDOS) || defined(OS2) /* OS2/MSDOS chdir can't change drive */ #if !defined(_DDL) && !defined(WIN32) if ((pos=(char*) strchr(dir,FN_DEVCHAR)) != 0) { uint drive,drives; pos++; /* Skip FN_DEVCHAR */ drive=(uint) (my_toupper(&my_charset_latin1,dir[0])-'A'+1); drives= (uint) -1; if ((pos-(byte*) dir) == 2 && drive > 0 && drive < 32) { #ifdef OS2 _chdrive(drive); drives = _getdrive(); #else _dos_setdrive(drive,&drives); _dos_getdrive(&drives); #endif } if (drive != drives) { *pos='\0'; /* Dir is now only drive */ my_errno=errno; my_error(EE_SETWD,MYF(ME_BELL+ME_WAITTANG),dir,ENOENT); DBUG_RETURN(-1); } dir=pos; /* drive changed, change now path */ } #endif if (*((pos=strend(dir)-1)) == FN_LIBCHAR && pos != dir) { strmov(buff,dir)[-1]=0; /* Remove last '/' */ dir=buff; } #endif /* MSDOS*/ if (! dir[0] || (dir[0] == FN_LIBCHAR && dir[1] == 0)) dir=FN_ROOTDIR; #ifdef VMS { pos=strmov(buff,dir); if (pos[-1] != FN_LIBCHAR) { pos[0]=FN_LIBCHAR; /* Mark as directory */ pos[1]=0; } system_filename(buff,buff); /* Change to VMS format */ dir=buff; } #endif /* VMS */ if ((res=chdir((char*) dir)) != 0) { my_errno=errno; if (MyFlags & MY_WME) my_error(EE_SETWD,MYF(ME_BELL+ME_WAITTANG),start,errno); } else { if (test_if_hard_path(start)) { /* Hard pathname */ pos=strmake(&curr_dir[0],start,(size_s) FN_REFLEN-1); if (pos[-1] != FN_LIBCHAR) { length=(uint) (pos-(char*) curr_dir); curr_dir[length]=FN_LIBCHAR; /* must end with '/' */ curr_dir[length+1]='\0'; } } else curr_dir[0]='\0'; /* Don't save name */ } DBUG_RETURN(res); } /* my_setwd */
function (const char *nptr,char **endptr,int base) { int negative; register ulongtype cutoff; register unsigned int cutlim; register ulongtype i; register const char *s; register uchar c; const char *save; int overflow; if (base < 0 || base == 1 || base > 36) base = 10; s = nptr; /* Skip white space. */ while (my_isspace(&my_charset_latin1, *s)) ++s; if (*s == '\0') { goto noconv; } /* Check for a sign. */ negative= 0; if (*s == '-') { negative = 1; ++s; } else if (*s == '+') { ++s; } if (base == 16 && s[0] == '0' && my_toupper (&my_charset_latin1, s[1]) == 'X') s += 2; /* If BASE is zero, figure it out ourselves. */ if (base == 0) { if (*s == '0') { if (my_toupper (&my_charset_latin1, s[1]) == 'X') { s += 2; base = 16; } else base = 8; } else base = 10; } /* Save the pointer so we can check later if anything happened. */ save = s; cutoff = UTYPE_MAX / (unsigned long int) base; cutlim = (uint) (UTYPE_MAX % (unsigned long int) base); overflow = 0; i = 0; for (c = *s; c != '\0'; c = *++s) { if (my_isdigit (&my_charset_latin1, c)) c -= '0'; else if (my_isalpha (&my_charset_latin1, c)) c = my_toupper (&my_charset_latin1, c) - 'A' + 10; else break; if (c >= base) break; /* Check for overflow. */ if (i > cutoff || (i == cutoff && c > cutlim)) overflow = 1; else { i *= (ulongtype) base; i += c; } } /* Check if anything actually happened. */ if (s == save) goto noconv; /* Store in ENDPTR the address of one character past the last character we converted. */ if (endptr != NULL) *endptr = (char *) s; #ifndef USE_UNSIGNED /* Check for a value that is within the range of `unsigned long int', but outside the range of `long int'. */ if (negative) { if (i > (ulongtype) TYPE_MIN) overflow = 1; } else if (i > (ulongtype) TYPE_MAX) overflow = 1; #endif if (overflow) { my_errno=ERANGE; #ifdef USE_UNSIGNED return UTYPE_MAX; #else return negative ? TYPE_MIN : TYPE_MAX; #endif } /* Return the result of the appropriate sign. */ return (negative ? -((longtype) i) : (longtype) i); noconv: /* There was no number to convert. */ my_errno=EDOM; if (endptr != NULL) *endptr = (char *) nptr; return 0L; }