int main() { /* * Initialize variables. */ char string[512]; do { int i = 0; char ch; /* * Prompt for and store a string. */ putchar('\n'); printf("Enter word or Q to quit: "); while((ch = getchar()) != '\n') { string[i++] = ch; } string[i] = '\0'; /* * Compare string for Q to quit. */ if((strcmp(string,"Q")) == 0) { putchar('\n'); return 0; } else { makeupper(string); // call makeupper() printf("%s\n",string); // print the string in caps. } } while(1); putchar('\n'); return 0; }
static void have_letter(void) { char buff[MAX_LENGTH]; int count; count = 0; buff[count++] = ' '; /* Required initial blank */ buff[count++] = makeupper(Char); for (new_char() ; isalpha(Char) || Char == '\'' || Char == '_'; new_char()) { buff[count++] = makeupper(Char); if (count > MAX_LENGTH-2) { buff[count++] = ' '; buff[count++] = '\0'; dmk_word(buff); count = 1; } } buff[count++] = ' '; /* Required terminating blank */ buff[count++] = '\0'; /* Check for AAANNN type abbreviations */ if (isdigit(Char)) { dmk_spell_word(buff); return; } else if (strlen(buff) == 3) /* one character, two spaces */ dmk_say_ascii(buff[1]); else if (Char == '.') /* Possible abbreviation */ abbrev(buff); else dmk_word(buff); if (Char == '-' && isalpha(Char1)) new_char(); /* Skip hyphens */ }
bool TemplateMetaData::exists ( const char* key ) { if (!key) return false; std::string keyName = makeupper(key); return data.find(keyName) != data.end(); }
void TemplateMetaData::add ( const char* key, const char* val ) { if (!key || !val) return; std::string keyName = makeupper(key); if (!exists(key)) { std::vector<std::string> t; data[keyName] = t; } data[keyName].push_back(std::string(val)); }
std::vector<std::string> TemplateMetaData::get ( const char* key ) { std::vector<std::string> vals; if (key) { std::string keyName = makeupper(key); if ( data.find(keyName) != data.end()) vals = data[keyName]; } return vals; }
std::string TemplateMetaData::getFirst ( const char* key ) { std::string val; if (key) { std::string keyName = makeupper(key); if ( data.find(keyName) != data.end()) { if (data[keyName].size()) val = data[keyName][0]; } } return val; }
static void extract_content(FILE *fp, const char *p) { char *ns = buf + 3; char *name; FILE *fo; while(*ns && isspace(*ns)) ns++; name = ns; while(*name && *name != '(') { if (!isalnum(*name) && *name != '_') goto bad; name++; } if (*name != '(' || name[2] != ')' || !isalnum(name[1])) goto bad; *name = '.'; name[2] = 0; fo = fopen(ns, "w"); if (fo == NULL) { perror(ns); exit(1); } fprintf(fo, "%s\n", makeupper(ns)); while(fgets(buf, 512, fp)) { if (strncmp(buf, "|*/", 3) == 0) { fclose(fo); return; } fputs(buf, fo); } fprintf(stderr, "%s: unexpected EOF\n", p); exit(1); bad: fprintf(stderr, "%s: invalid manual name: %s", p, buf); exit(1); }
static void have_number(void) { long int value; int lastdigit; value = Char - '0'; lastdigit = Char; for (new_char() ; isdigit(Char) ; new_char()) { value = 10 * value + (Char-'0'); lastdigit = Char; } /* Recognize ordinals based on last digit of number */ switch (lastdigit) { case '1': /* ST */ if (makeupper(Char) == 'S' && makeupper(Char1) == 'T' && !isalpha(Char2) && !isdigit(Char2)) { dmk_say_ordinal(value); new_char(); /* Used Char */ new_char(); /* Used Char1 */ return; } break; case '2': /* ND */ if (makeupper(Char) == 'N' && makeupper(Char1) == 'D' && !isalpha(Char2) && !isdigit(Char2)) { dmk_say_ordinal(value); new_char(); /* Used Char */ new_char(); /* Used Char1 */ return; } break; case '3': /* RD */ if (makeupper(Char) == 'R' && makeupper(Char1) == 'D' && !isalpha(Char2) && !isdigit(Char2)) { dmk_say_ordinal(value); new_char(); /* Used Char */ new_char(); /* Used Char1 */ return; } break; case '0': /* TH */ case '4': /* TH */ case '5': /* TH */ case '6': /* TH */ case '7': /* TH */ case '8': /* TH */ case '9': /* TH */ if (makeupper(Char) == 'T' && makeupper(Char1) == 'H' && !isalpha(Char2) && !isdigit(Char2)) { dmk_say_ordinal(value); new_char(); /* Used Char */ new_char(); /* Used Char1 */ return; } break; } dmk_say_cardinal(value); /* Recognize decimal points */ if (Char == '.' && isdigit(Char1)) { dmk_outstring("pOYnt "); for (new_char() ; isdigit(Char) ; new_char()) { dmk_say_ascii(Char); } } /* Spell out trailing abbreviations */ if (isalpha(Char)) { while (isalpha(Char)) { dmk_say_ascii(Char); new_char(); } } return; }
// Convert a Unix-style filename to a VMS-style name // No return code because this routine cannot fail :-) void make_vms_filespec(const char *unixname, char *vmsname, bool full) { char fullname[PATH_MAX]; int i; char *lastslash; struct stat st; int slashes = 0; char *slash2; // Resolve all relative bits and symbolic links realpath(unixname, fullname); // Find the last slash in the name lastslash = fullname + strlen(fullname); while (*(--lastslash) != '/') ; // If the filename has no extension then add one. VMS seems to // expect one as does dapfs. if (!strchr(lastslash, '.')) strcat(fullname, "."); // If it's a directory then add .DIR;1 if (lstat(unixname, &st)==0 && S_ISDIR(st.st_mode)) { // Take care of dots embedded in directory names (/etc/rc.d) if (fullname[strlen(fullname)-1] != '.') strcat(fullname, "."); strcat(fullname, "DIR;1"); // last dot has already been added } else // else just add a version number unless the file already has one { if (!strchr(fullname, ';')) strcat(fullname, ";1"); } // If we were only asked for the short name then return that bit now if (!full) { i=strlen(fullname); while (fullname[i--] != '/') ; strcpy(vmsname, &fullname[i+2]); // Make it all uppercase makeupper(vmsname); return; } // Count the slashes. If there is one slash we emit a filename like: // SYSDISK:[000000]filename // For two we use: // SYSDISK:[DIR]filename // for three or more we use: // DIR:[DIR1]filename // and so on... // Oh, also make it all upper case for VMS's benefit. for (i=0; i<(int)strlen(fullname); i++) { if (islower(fullname[i])) fullname[i] = toupper(fullname[i]); if (fullname[i] == '/') { slashes++; } } // File is in the root directory if (slashes == 1) { sprintf(vmsname, "%s:[000000]%s", sysdisk_name, fullname+1); return; } // File is in a directory immediately below the root directory if (slashes == 2) { char *second_slash = strchr(fullname+1, '/'); *second_slash = '\0'; strcpy(vmsname, sysdisk_name); strcat(vmsname, ":["); strcat(vmsname, fullname+1); strcat(vmsname, "]"); strcat(vmsname, second_slash+1); return; } // Most user filenames end up here slash2 = strchr(fullname+1, '/'); *slash2 = '\0'; strcpy(vmsname, fullname+1); strcat(vmsname, ":["); // Do the directory depth lastslash = slash2; for (i=1; i<slashes-1; i++) { char *slash = strchr(lastslash+1, '/'); if (slash) { *slash = '\0'; strcat(vmsname, lastslash+1); strcat(vmsname, "."); lastslash = slash; } } vmsname[strlen(vmsname)-1] = ']'; strcat(vmsname, lastslash+1); }