void filenametoshort(char *fname, char rets[12]) { unsigned short i = 0; for(; i < 8; ++i) { if(fname[i] == '.') break; rets[i] = toUpper(fname[i]); } for(; i < 8; ++i) rets[i] = ' '; while(*fname != '.') ++fname; ++fname; for(i = 8; i < 11; ++i) { if(*fname == 0) break; rets[i] = toUpper(*fname++); } for(; i < 11; ++i) rets[i] = ' '; rets[11] = 0; }
/* * MoveFile() * * This function will move a file to a new name and location. */ void MoveFile(char *oldname, char *newname) { char buffer[100]; FILE *infd, *outfd; int s; if (toUpper(*oldname) == toUpper(*newname)) { rename(oldname, newname); if (access(newname, 0) == 0) return; } CitSystem(FALSE, "copy %s %s > nul", oldname, newname); if (access(newname, 0) == 0) { unlink(oldname); } else { if ((infd = fopen(oldname, READ_ANY)) == NULL) return; if ((outfd = fopen(newname, WRITE_ANY)) == NULL) { fclose(infd); return; } while ((s = fread(buffer, sizeof buffer, 1, infd)) > 0) fwrite(buffer, s, 1, outfd); fclose(infd); fclose(outfd); unlink(oldname); } }
void cIPLog::GetLastLogin(const string &who, bool isNick, int limit, ostream &os) { string ip; if(isNick) os << autosprintf(_("Nick %s has lately been in the hub with the following IP"), who.c_str()) << "\n"; else os << autosprintf(_("IP %s has lately been in the hub with following nicknames"), who.c_str()) << "\n"; MakeSearchQuery(who, isNick, 1, limit); SetBaseTo(&mModel); os << "\n "; os << setw(25) << setiosflags(ios::left) << toUpper(_("Date")); os << (isNick ? "IP" : toUpper(_("Nickname"))) << "\n"; os << " " << string(25+20,'=') << endl; db_iterator it; for(it = db_begin(); it != db_end(); ++it) { cBanList::Num2Ip(mModel.mIP, ip); os << " " << setw(25) << setiosflags(ios::left) << cTime(mModel.mDate,0).AsDate(); os << (isNick ? ip : mModel.mNick) << endl; } mQuery.Clear(); }
string toString(PElement element) { if (element == NULL) { return "*"; } string result; PElement child = element->getChild(); while (child != NULL) { if (child->getTagname() == "#text") { // Then this child only contains text, no markup result += child->getText(); } else if (child->getTagname() == "#cdata") { ; } else { // Since only using on <that> and <pattern> // The tag can only be <bot_xxx/> or <bot name="xxx"/> or <name/> if (child->getTagname() == "name") { result += Kernel::respond("BOT NAME", "unknown"); } else if (child->getTagname() == "bot") { // Is a <bot name="xxx"/> predicate result += Kernel::respond("BOT " + toUpper(child->getAttribute("name")), "unknown"); } else { // It is old-skool <bot_xxx/> result += Kernel::respond("BOT " + toUpper(child->getTagname().substr(4)), "unknown"); } } child = child->getNextSibling(); } return trim(toUpper(result));//Substituter::normalize(result); }
ECString auxify(ECString wM, ECString trmM) { char temp[128]; ECString w = toUpper(wM.c_str(),temp); ECString trm = toUpper(trmM.c_str(),temp); cerr << "AUX!!!" << endl; assert(0); if( isVerb( trm ) ) { //cout << "saw verb " << trm << " " << wM << endl; if( isAux( w ) || hasAuxSuf( w ) ) { //cout << "was aux " << w << endl; return "AUX"; } else if( isAuxg( w ) ) { //cout << "was auxg " << w << endl; return "AUXG"; } } if(trm == "BES" || trm == "HVS") //??? strange tags in switchboard { assert(w == "'S" || w == "-S"); return "AUX"; } return trmM; }
int IconvGNUTransService::compareNIString(const XMLCh* const comp1 , const XMLCh* const comp2 , const unsigned int maxChars) { unsigned int n = 0; const XMLCh* cptr1 = comp1; const XMLCh* cptr2 = comp2; while (true && maxChars) { XMLCh c1 = toUpper(*cptr1); XMLCh c2 = toUpper(*cptr2); if (c1 != c2) return (int) (c1 - c2); // If either ended, then both ended, so equal if (!*cptr1 || !*cptr2) break; cptr1++; cptr2++; // Bump the count of chars done. If it equals the count then we // are equal for the requested count, so break out and return // equal. n++; if (n == maxChars) break; } return 0; }
void cIPLog::GetHistory(const string &who, bool isNick, int limit, ostream &os) { string ip; if(isNick) os << autosprintf(_("Last %d events of nick %s:"), limit, who.c_str()) << "\r\n"; else os << autosprintf(_("Last %d events of IP %s:"), limit, who.c_str()) << "\r\n"; MakeSearchQuery(who, isNick, -1, limit); SetBaseTo(&mModel); const char *Actions[]={_("connect"),_("login"),_("logout"),_("disconnect")}; const char *Infos[]={ "--", _("bad nick or nick temporarily banned"), _("used different nick in chat"), _("kicked"), _("redirected"), _("exit from the hub"), _("critical hub load"), _("timeout"), _("user did nothing for too long time"), _("hub full"), _("share limit"), _("no tag or not valid"), _("tag breaks hub rules"), _("wrong password"), _("error in login sequence"), _("syntax error in some messages"), _("invalid key") }; os << "\n "; os << setw(20) << setiosflags(ios::left) << toUpper(_("Date")); os << setw(20) << setiosflags(ios::left) << toUpper(_("Action")); os << setw(15) << setiosflags(ios::left) << (isNick ? "IP" : toUpper(_("Nickname"))); os << toUpper(_("Info")) << "\n"; os << " " << string(20+20+15+25,'=') << endl; db_iterator it; for(it = db_begin(); it != db_end(); ++it) { cBanList::Num2Ip(mModel.mIP, ip); os << " " << setw(20) << setiosflags(ios::left) << cTime(mModel.mDate,0).AsDate(); os << setw(20) << setiosflags(ios::left); if(mModel.mType < 4) os << Actions[mModel.mType]; else os << mModel.mType; os << setw(15) << setiosflags(ios::left) << (isNick ? ip : mModel.mNick.substr(0,14)); if(mModel.mInfo < 16) { if(strlen(Infos[mModel.mInfo]) > 0) os << Infos[mModel.mInfo]; } else os << mModel.mInfo; os << endl; } mQuery.Clear(); }
int Settings::load(const string & filename) { mFileName = filename; ifstream inFile(filename.c_str(), std::istream::in); mMap.clear(); string strLine, strKey, strValue; string::iterator itLine; bool bKey = true; bool bBlanks = false; while (getline(inFile, strLine)) // TODO Errorhandling { if (strLine.find('=') == strLine.npos) continue; strKey.clear(); strValue.clear(); bKey = true; bBlanks = false; for (itLine = strLine.begin(); itLine != strLine.end(); itLine++) { if (!bKey && (*itLine == '"')) { if (!bBlanks) bBlanks = true; else bBlanks = false; continue; } if (!bBlanks && isspace(*itLine)) continue; if (*itLine == '#') break; if (*itLine == '=') { bKey = false; continue; } bKey ? strKey.push_back(*itLine) : strValue.push_back(*itLine); } if (strValue.empty()) continue; switch (mCase) { case KEEP: mMap[strKey] = strValue; break; case UPPER: mMap[toUpper(strKey)] = toUpper(strValue); break; case LOWER: mMap[toLower(strKey)] = toLower(strValue); break; default: break; } } inFile.close(); return 0; }
void cRedirectConsole::ListHead(ostream *os) { (*os) << "\r\n "; (*os) << setw(10) << setiosflags(ios::left) << toUpper(_("Count")); (*os) << setw(35) << setiosflags(ios::left) << toUpper(_("Address")); (*os) << setw(35) << setiosflags(ios::left) << toUpper(_("Type")); (*os) << toUpper(_("Status")) << "\r\n"; (*os) << " " << string(30 + 25 + 25, '='); }
vector<Vertex*> ShortestDistance::shortestDistance(string &airport1, string &airport2) { toUpper(airport1); toUpper(airport2); vector<Vertex*> vec; Vertex* u; set<Vertex*, Prioritize> Q; int starting_airport = -1, destination_airport = -1; for(map<int,Vertex*>::const_iterator mt = table.begin(); mt != table.end(); ++mt) if(!mt->second->airport_iata.empty()) { if(!mt->second->airport_iata.compare(airport1)) starting_airport = mt->second->airport_id; else if(!mt->second->airport_iata.compare(airport2)) destination_airport = mt->second->airport_id; } if(starting_airport == -1) { cout << "Starting airport not found." << endl; return vec; } else if(destination_airport == -1) { cout << "Destination airport not found." << endl; return vec; } table[starting_airport]->cost = 0; Q.insert(table[starting_airport]); while(!Q.empty()) { u = *Q.begin(); if(u->airport_id == destination_airport) { while(table[u->airport_id]->prev) { vec.insert(vec.begin(), table[u->airport_id]->prev); u = table[u->airport_id]->prev; } vec.push_back(table[destination_airport]); return vec; } Q.erase(Q.begin()); for(vector<Routes*>::iterator neighbor = u->routes.begin(); neighbor != u->routes.end(); ++neighbor) { double alt = u->cost + (*neighbor)->distance; if(alt < table[(*neighbor)->nextAirport]->cost) { table[(*neighbor)->nextAirport]->cost = alt; table[(*neighbor)->nextAirport]->prev = u; if(Q.find(table[(*neighbor)->nextAirport]) == Q.end()) Q.insert(table[(*neighbor)->nextAirport]); } } } return vec; }
boolean equalsIgnoreCase(Char *s1_, Char *s2_) { Char s1[256], s2[256]; strcpy(s1, s1_); strcpy(s2, s2_); toUpper(s1); toUpper(s2); return (strcmp(s1, s2) == 0); }
boolean startsWithIgnoreCase(Char *s1_, Char *s2_) { Char s1[256], s2[256]; strcpy(s1, s1_); strcpy(s2, s2_); toUpper(s1); toUpper(s2); return (startsWith(s1, s2)); }
int isLetter(char input){ int ret = 0; if((toUpper(input) >= 'A' && toUpper(input) <= 'Z') || input == ' '){ ret = 1; } return ret; }
int main(int argc, char *argv[]) { printf("%c\n",toUpper('g')); printf("%c\n",toUpper('=')); printf("%c\n",toUpper('Z')); printf("%c\n",toUpper('x')); return(EXIT_SUCCESS); }
void main(){ char word[20] = "Hello World!"; int i; for(i = 0; i<20; i++){ if(word[i] == '\0') { printf("%c", toUpper(word[i])); break; } printf("%c", toUpper(word[i])); } printf("\n"); }
ostream& operator << (ostream &os, const cPlug &plug) { os << " [*] " << setw(PADDING) << setiosflags(ios::left) << _("Name") << plug.mNick.c_str() << " [" << (plug.IsLoaded() ? toUpper(_("On")) : toUpper(_("Off"))) << "]"; os << " [" << (plug.mLoadOnStartup ? toUpper(_("Auto")) : toUpper(_("Manual"))) << "]" << endl; os << " [*] " << setw(PADDING) << setiosflags(ios::left) << _("Path") << plug.mPath.c_str() << endl; if (!plug.mDesc.empty()) os << " [*] " << setw(PADDING) << setiosflags(ios::left) << _("Description") << plug.mDesc.c_str() << endl; if (!plug.mLastError.empty()) os << " [*] " << setw(PADDING) << setiosflags(ios::left) << _("Last error") << plug.mLastError.c_str() << endl; return os; }
int cRegList::ShowUsers(cConnDC *op, ostringstream &os, int cls) { if (op && op->mpUser) { ostringstream oss; oss << "SELECT `nick` FROM " << mMySQLTable.mName << " WHERE `class` = " << cls << " ORDER BY `nick` ASC"; mQuery.OStream() << oss.str(); if (mQuery.Query() <= 0) return 0; int n = mQuery.StoreResult(); cMySQLColumn col; MYSQL_ROW row; cUser *usr = NULL; for (int i = 0; i < n; i++) { row = mQuery.Row(); usr = mS->mUserList.GetUserByNick(row[0]); os << " " << row[0]; if (usr && usr->mxConn) os << " [" << toUpper(_("On")) << "]"; os << "\r\n"; } mQuery.Clear(); return n; } return 0; }
int exec_Line (int conn, int argc, char **argv) { XHCP_command *cmd; int retValue=0; toUpper (argv[0]); for ( cmd = XHCP_commandList; cmd->id != END_CMD; cmd++ ) if ( strcmp (argv[0], cmd->str) == 0 ) break; if ( cmd->id == END_CMD ) { XHCP_printXHCPResponse (conn, RES_COMNOTREC ); // 500 Command not recognised //retValue = 1; } else { if ( cmd->fnct == NULL ) { /*XHCP_printXHCPResponse(conn, RES_INTNERROR ); // 503 Internal error - command not performed ----- Pour l'instant !!!*/ XHCP_printMessage (conn, 500, "Command not implemented" ); //retValue = 1; } else retValue = cmd->fnct (conn, argc, argv); } return retValue; }
int XHCPcmd_CAPABILITIES (int sockd, int argc, char **argv) { int s = 0; if ( argc>1) { toUpper (argv[1]); if ( strcmp (argv[1], "SCRIPTING") == 0 ) s = 1; else { XHCP_printXHCPResponse (sockd, RES_SYNTAXERR ); // Syntax error return XHCP_EXE_ERROR; } } XHCP_printMessage (sockd, s?241:236, "--000U0" ); if (s) XHCP_print (sockd, "." ); return XHCP_EXE_SUCCESS; }
bool cConsole::cfFilesLuaScript::operator()() { DIR *dir = opendir(GetPI()->mScriptDir.c_str()); if (!dir) { (*mOS) << autosprintf(_("Failed loading directory: %s"), GetPI()->mScriptDir.c_str()); return false; } (*mOS) << autosprintf(_("Lua scripts found in: %s"), GetPI()->mScriptDir.c_str()) << "\r\n\r\n "; (*mOS) << setw(6) << setiosflags(ios::left) << _("ID"); (*mOS) << toUpper(_("Script")) << "\r\n"; (*mOS) << " " << string(6 + 20, '=') << "\r\n"; string filename; struct dirent *dent = NULL; int i = 0; while (NULL != (dent = readdir(dir))) { filename = dent->d_name; if ((filename.size() > 4) && (StrCompare(filename, filename.size() - 4, 4, ".lua") == 0)) { (*mOS) << " " << setw(6) << setiosflags(ios::left) << i << filename << "\r\n"; i++; } } closedir(dir); return true; }
/* * CheckArea() * * This function deals with the question of whether the given string is a * directory and to create it if possible and needed. */ char CheckArea(MenuId id, char c, char *drive, char *dir_x) { char work[100]; switch (c) { case IS_DIR: return TRUE; case NO_IDEA: if (strLen(dir_x) != 0) { sprintf(work, "%s does not exist. Create it", dir_x); if (SysopGetYesNo(id, "", work)) { DoBdos(SETDISK, toUpper(*drive) - 'A'); if (mkdir(dir_x) == BAD_DIR) { SysopPrintf(id, "?ERROR CREATING!"); homeSpace(); return FALSE; } else { homeSpace(); return TRUE; } } } else { return TRUE; } return FALSE; default: SysopPrintf(id, "That's not a directory!\n "); return FALSE; } }
String capitalize_sentence(const String& s) { String ret = s;//.Lower(); if (!ret.empty()) { ret[0] = toUpper(ret[0]); } return ret; }
int main(void) { //Prepare server address int fd = socket(AF_INET6, SOCK_DGRAM, 0); struct sockaddr_in6 serveraddr; memset(&serveraddr, 0, sizeof(struct sockaddr_in6)); serveraddr.sin6_family = AF_INET6; serveraddr.sin6_port = htons(PORT); //Bind to server address if( bind(fd, (struct sockaddr*)&serveraddr, sizeof(struct sockaddr_in6)) == -1 ) perror("server bind"); char buf[BUF_SIZE]; char clientstr[INET6_ADDRSTRLEN]; struct sockaddr_in6 clientaddr; socklen_t len = sizeof(struct sockaddr_in6); while(1) { //Wait for messages if( recvfrom(fd, buf, BUF_SIZE, 0, (struct sockaddr*)&clientaddr, &len) == -1) perror("server recvfrom"); inet_ntop(AF_INET6, &clientaddr.sin6_addr, clientstr, INET6_ADDRSTRLEN); printf( "Server-Receive message from: (%s, %u)", clientstr, ntohs(clientaddr.sin6_port) ); //Convert to upper and send back message if(strcmp(buf, "Done") == 0) break; toUpper(buf); if( sendto(fd, buf, strlen(buf)+1, 0,(struct sockaddr*)&clientaddr, sizeof(struct sockaddr_in6) ) != strlen(buf)+1 ) perror("server sendto"); } return 0; }
int main() { char * src = "aafdJfdRJGNjkF12345"; printf("hello\r\n"); printf("%s\r\n", toUpper(src)); return 0; }
static inline UChar32 convertToLowerOrUpper(UChar32 c, ConvertType type) { if (type == ConvertLower) return toLower(c); else return toUpper(c); }
meUShort meGetKeyFromString(meUByte **tp) { meUByte *ss=*tp, cc, dd ; meUShort ii=0 ; for(;;) { if(((cc=*ss++) == '\0') || ((dd=*ss++) != '-')) break ; if (cc == 'C') ii |= ME_CONTROL ; else if(cc == 'S') ii |= ME_SHIFT ; else if(cc == 'A') ii |= ME_ALT ; } if(cc != '\0') { if(!isSpace(dd)) { meUByte *s1=ss ; int skey ; while(((dd=*s1) != '\0') && (dd != ' ')) s1++ ; *s1 = '\0' ; skey = biChopFindString(ss-2,13,specKeyNames,SKEY_MAX) ; *s1 = dd ; if(skey >= 0) { if(skey == SKEY_space) ii |= 32 ; else ii |= (skey|ME_SPECIAL) ; *tp = s1 ; return ii ; } /* duff key string - fail */ return 0 ; } if(ii) { cc = toUpper(cc) ; if((ii == ME_CONTROL) && (cc >= 'A') && (cc <= '_')) ii = cc - '@' ; else { cc = toLower(cc) ; ii |= cc ; } } else ii |= cc ; } *tp = ss-1 ; return ii ; }
JNIEXPORT void JNICALL Java_ToUpperExample_toUpper (JNIEnv *env, jobject jobj, jbyteArray jBuf) { jbyte *cpu_buf = env->GetByteArrayElements(jBuf, 0); toUpper((uint8_t *)cpu_buf); env->ReleaseByteArrayElements(jBuf, cpu_buf, 0); }
// --------------------------------------------------------------------------- // IconvGNUTransService: The virtual transcoding service API // --------------------------------------------------------------------------- int IconvGNUTransService::compareIString(const XMLCh* const comp1 , const XMLCh* const comp2) { const XMLCh* cptr1 = comp1; const XMLCh* cptr2 = comp2; XMLCh c1 = toUpper(*cptr1); XMLCh c2 = toUpper(*cptr2); while ( (*cptr1 != 0) && (*cptr2 != 0) ) { if (c1 != c2) break; c1 = toUpper(*(++cptr1)); c2 = toUpper(*(++cptr2)); } return (int) ( c1 - c2 ); }
RowFilter::Comparison RowFilter::getComparison(const std::string& comp) const { Comparisons::const_iterator it = _comparisons.find(toUpper(comp)); if (it == _comparisons.end()) throw NotFoundException("Comparison not found", comp); return it->second; }
int _fMemiCmp(const byte far * dest, const byte far * src, unsigned length) { int d; DBG_ENTER("_fMemiCmp", Suppl_farmem) if(!length) DBG_RETURN_I( 0) if(dest == 0) DBG_RETURN_I(src != 0) if(src == 0) DBG_RETURN_I(-1) while((d = toUpper(*dest++) - toUpper(*src++)) == 0 && --length); DBG_RETURN_I( d) }