int protocol_parse(char* msg, int msg_len, clientconn_t *c, hash *clients, char* curr_topic) { char *token = NULL; if (msg_len > MAXTOKENSIZE*3) { client_write(c, "* BAD Do not overflow.\r\n", 24); return 0; } char tag[MAXTOKENSIZE]; char command[MAXTOKENSIZE]; char message[MAXTOKENSIZE]; memset(tag,'\0',MAXTOKENSIZE); memset(command,'\0',MAXTOKENSIZE); memset(message,'\0',MAXTOKENSIZE); // Remove trailing \r \n. if (msg!=NULL && strlen(msg) > 2) { msg=remove_crlf(msg, msg_len); } else { return badly_formed(c, msg); } token=strtok(msg, " "); int tok=0; char is_quoted = 0; while(token!=NULL) { if(strlen(token)+1>MAXTOKENSIZE) { client_write(c, "* BAD Do not overflow.\r\n", 24); return 0; } if(tok==0) { strncpy(tag, token, strlen(token)); } else if(tok==1){ strncpy(command, token, strlen(token)); } else if(tok==2){ if(token[0]=='\''||token[0]=='\"') { is_quoted=token[0]; } strncpy(message, token, strlen(token)); } else { strncat(message, " ", 1); strncat(message, token, strlen(token)); } tok++; token = strtok(NULL, " "); } fprintf(stderr, "TAG [%s]\t COMMAND [%s]\t ARGUMENTS [%s]\n", tag, command, message); return make_action(tag, command, message, c, is_quoted, clients, curr_topic); }
void sdprintf (const char *format, ...) { if (sdebug) { char s[2001] = ""; va_list va; va_start(va, format); egg_vsnprintf(s, sizeof(s), format, va); va_end(va); remove_crlf(s); if (!backgrd) dprintf(DP_STDOUT, "[D:%d] %s%s%s\n", mypid, BOLD(-1), s, BOLD_END(-1)); else printf("[D:%d] %s%s%s\n", mypid, BOLD(-1), s, BOLD_END(-1)); } }
void sdprintf (const char *format, ...) { char s[2001] = ""; va_list va; va_start(va, format); egg_vsnprintf(s, sizeof(s), format, va); va_end(va); remove_crlf(s); ContextNote("dbg", s); if (sdebug) { if (!backgrd) dprintf(DP_STDOUT, "[D:%lu] %s%s%s\n", (unsigned long) mypid, BOLD(-1), s, BOLD_END(-1)); else printf("[D:%lu] %s%s%s\n", (unsigned long) mypid, BOLD(-1), s, BOLD_END(-1)); } #ifdef DEBUG logfile(LOG_DEBUG, s); #endif }
void JavaCatWindow::load() { QString here = QDir::currentPath(); QString start; // note : QFile fp(QDir::home().absFilePath(".doumlcat")) doesn't work // if the path contains non latin1 characters, for instance cyrillic ! QString s = QDir::home().absoluteFilePath(".doumlcat"); FILE * fp = fopen((const char *) s.toLatin1().constData(), "r"); if (fp != 0) { char line[512]; if (fgets(line, sizeof(line) - 1, fp) != 0) { remove_crlf(line); start = line; } fclose(fp); } QString path = QFileDialog::getOpenFileName(this, "", start, "*.cat"); if (! path.isEmpty()) { QApplication::setOverrideCursor(Qt::WaitCursor); QFile f(path); if (f.open(QIODevice::ReadOnly)) { if ((fp = fopen((const char *) s.toLatin1().constData(), "w")) != 0) { fwrite((const char *) path.toLatin1().constData(), 1, path.length(), fp); fputc('\n', fp); fclose(fp); } QDataStream dt(&f); Package::get_root()->restore_children(dt); Package::get_root()->setExpanded(TRUE); } QApplication::restoreOverrideCursor(); } QDir::setCurrent(here); }
int read_boumlrc() { // note : QFile fp(QDir::home().absFilePath(".boumlrc")) doesn't work // if the path contains non latin1 characters, for instance cyrillic ! QString s = QDir::home().absFilePath(".boumlrc"); FILE * fp = fopen((const char *) s, "r"); if (fp == 0) { QMessageBox::critical(0, "Bouml", TR("cannot read '%1'", s)); exit(-1); } set_manual_dir(""); set_navigator_path(""); set_template_project(""); set_editor(""); set_codec(""); UmlDesktop::set_limits(0, 0, 0, 0); int id = -1; char line[512]; bool lang_set = FALSE; bool nolang = FALSE; while (fgets(line, sizeof(line) - 1, fp) != 0) { remove_crlf(line); if (!strncmp(line, "ID ", 3)) sscanf(line+3, "%d", &id); else if (!strncmp(line, "MANUAL ", 7)) set_manual_dir(line+7); else if (!strncmp(line, "NAVIGATOR ", 10)) set_navigator_path(line+10); else if (!strncmp(line, "TEMPLATE ",9 )) set_template_project(line+9); else if (!strncmp(line, "EDITOR ", 7)) set_editor(line+7); else if (!strncmp(line, "CHARSET ", 8)) set_codec(line+8); else if (!strncmp(line, "DESKTOP ", 8)) { int l, t, r, b; if (sscanf(line+8, "%d %d %d %d", &l, &t, &r, &b) == 4) UmlDesktop::set_limits(l, t, r, b); } else if (!strncmp(line, "LANG ", 5)) { set_lang(line+5); lang_set = TRUE; } else if (!strncmp(line, "NOLANG", 6)) { nolang = TRUE; } } fclose(fp); if (! lang_set) { set_lang(""); if (! nolang) propose_lang(); } if (id == -1) { QMessageBox::critical(0, "Bouml", TR("Own identifier missing or invalid")); EnvDialog::edit(FALSE, TRUE); return read_boumlrc(); } return id; }
void Shortcut::load(bool conv) { // default shortcuts add("Delete", FALSE, FALSE, FALSE, "Remove from diagram"); add("Left", FALSE, FALSE, FALSE, "Move left"); add("Right", FALSE, FALSE, FALSE, "Move right"); add("Down", FALSE, FALSE, FALSE, "Move down"); add("Up", FALSE, FALSE, FALSE, "Move up"); add("Return", FALSE, FALSE, FALSE, "Menu"); add("D", FALSE, TRUE, FALSE, "Delete"); add("A", FALSE, TRUE, FALSE, "Select all"); add("C", FALSE, TRUE, FALSE, "Copy"); add("V", FALSE, TRUE, FALSE, "Paste"); add("X", FALSE, TRUE, FALSE, "Cut"); add("U", FALSE, TRUE, FALSE, "Undo"); add("Z", FALSE, TRUE, FALSE, "Undo"); add("R", FALSE, TRUE, FALSE, "Redo"); add("Y", FALSE, TRUE, FALSE, "Redo"); add("S", FALSE, TRUE, FALSE, "Save"); add("W", FALSE, TRUE, FALSE, "Close"); add("Q", FALSE, TRUE, FALSE, "Quit"); add("L", FALSE, TRUE, FALSE, "Arrow geometry"); add("F", FALSE, TRUE, FALSE, "Browser search"); add("O", FALSE, TRUE, FALSE, "Open project"); add("P", FALSE, TRUE, FALSE, "Print"); add("S", TRUE, TRUE, FALSE, "Save as"); QString f = shortcut_file_path(conv); if (!f.isEmpty()) { // note : QFile fp(QDir::home().absFilePath(f)) doesn't work // if the path contains non latin1 characters, for instance cyrillic ! QString s = homeDir().absFilePath(f); FILE * fp = fopen((const char *) s, "r"); if (fp != 0) { char line[512]; while (fgets(line, sizeof(line) - 1, fp) != 0) { remove_crlf(line); bool shift = FALSE; bool control = FALSE; bool alt = FALSE; int index = 0; QString ln = line; if (!strncmp(line, "shift ", 6)) { shift = TRUE; index = 6; } if (!strncmp(line+index, "control ", 8)) { control = TRUE; index += 8; } if (!strncmp(line+index, "alt ", 4)) { alt = TRUE; index += 4; } int index2 = ln.find(' ', index); if (index2 != -1) { QString s = ln.mid(index2 + 1); QString k = ln.mid(index, index2 - index); if (s == "New collaboration diagram") // old s = "New communication diagram"; else if (s == "Remove from view") // old s = "Remove from diagram"; if (k == "Suppr") // old k = "Delete"; add(k, shift, control, alt, s); } } fclose(fp); if (conv) save(); return; } } }
int main(int argc, char ** argv) { QApplication * app = new QApplication(argc, argv); int uid = -1; // note : QFile fp(QDir::home().absFilePath(".boumlrc")) doesn't work // if the path contains non latin1 characters, for instance cyrillic ! QDir homeDir = QDir::home(); QString s = homeDir.absFilePath(".boumlrc"); FILE * fp = fopen((const char *) s, "r"); int cx = -1; int cy = -1; int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height(); if (fp != 0) { char line[512]; while (fgets(line, sizeof(line) - 1, fp) != 0) { remove_crlf(line); if (!strncmp(line, "ID ", 3)) { sscanf(line+3, "%d", &uid); break; } else if (!strncmp(line, "DESKTOP ", 8)) { int l, t, r, b; if (sscanf(line+8, "%d %d %d %d", &l, &t, &r, &b) == 4) { if (!((r == 0) && (t == 0) && (r == 0) && (b == 0)) && !((r < 0) || (t < 0) || (r < 0) || (b < 0)) && !((r <= l) || (b <= t))) { cx = (r + l) / 2; cy = (t + b) / 2; w = r - l; h = b - t; } } } } fclose(fp); } if (uid == -1) QMessageBox::critical(0, "Control project", "Own identifier not defined"); else if ((uid < 2) || (uid > 127)) QMessageBox::critical(0, "Control project", "invalid Identifier"); else { set_user_id(uid, homeDir.dirName()); app->connect(app, SIGNAL(lastWindowClosed()), SLOT(quit()) ); init_pixmaps(); ControlWindow * ww = new ControlWindow(homeDir); ww->resize((w * 3)/5, (h * 3)/5); if (cx != -1) ww->move(ww->x() + cx - (ww->x() + ww->width() / 2), ww->y() + cy - (ww->y() + ww->height() / 2)); ww->show(); app->exec(); } return 0; }
int main(int argc, char ** argv) { if (argc != 2) return 0; if (UmlCom::connect(QCString(argv[1]).toUInt())) { try { //UmlCom::with_ack(FALSE); UmlCom::trace("<b>Java reverse</b> release 2.18<br><hr>"); UmlCom::traceAutoRaise(FALSE); UmlItem * item = UmlCom::targetItem(); if (item->kind() != aPackage) UmlCom::trace("<font face=helvetica><b>must be applied on a <i>package</i></b></font><br><hr><br>"); else { char * argv = 0; int argc = 0; QApplication * app = new QApplication(argc, &argv); Package::init((UmlPackage *) item, app); QString here = QDir::currentDirPath(); QString path; // note : QFile fp(QDir::home().absFilePath(".boumlcat")) doesn't work // if the path contains non latin1 characters, for instance cyrillic ! QString s = QDir::home().absFilePath(".boumlcat"); FILE * fp = fopen((const char *) s, "r"); if (fp != 0) { char line[512]; if (fgets(line, sizeof(line) - 1, fp) != 0) { remove_crlf(line); path = line; } fclose(fp); } while (!(path = QFileDialog::getOpenFileName(path, "*.cat", 0, 0, "select a java catalog file to read it, or cancel")) .isEmpty()) { QFile f(path); if (f.open(IO_ReadOnly)) { if ((fp = fopen((const char *) s, "w")) != 0) { fwrite((const char *) path, 1, path.length(), fp); fputc('\n', fp); fclose(fp); } QDataStream dt(&f); Package::get_root()->restore_children(dt); } } QDir::setCurrent(here); int n; Package * p = Package::scan_dir(n); if (p != 0) { JavaSettings::set_UseDefaults(TRUE); p->send_dir(n); Statistic::produce(); } } } catch (...) { } try { // socket may be already closed UmlCom::message(""); UmlCom::showTrace(); UmlCom::bye(0); // application must not be deleted } catch (...) { } } UmlCom::close(); // application must not be deleted return 0; }