--- src/applications/mailer/axmail.h.orig 2013-08-20 13:44:26.129175528 -0700 +++ src/applications/mailer/axmail.h 2013-08-21 16:10:12.555053262 -0700 @@ -6,7 +6,7 @@ #ifndef AXMAIL_H #define AXMAIL_H -#include +#include //Library initialization with default paths void axmail_init(); @@ -134,7 +134,7 @@ char *call; //BBS callsign w/o ssid char *path; //index path int lastnum; //highest known message number - vector messages; //list of messages + std::vector messages; //list of messages void updateList(); //remove deleted messages void clearList(); //clear the list of messages --- src/applications/libaxmail/axmail.cc.orig 2013-08-20 13:44:04.489039478 -0700 +++ src/applications/libaxmail/axmail.cc 2013-08-21 16:08:20.499137385 -0700 @@ -392,7 +392,7 @@ void MessageIndex::updateList() { - vector ::iterator it; + std::vector ::iterator it; for (it = messages.begin(); it < messages.end(); it++) { if ((*it)->isDel()) @@ -406,7 +406,7 @@ void MessageIndex::clearList() { - vector ::iterator it; + std::vector ::iterator it; for (it = messages.begin(); it < messages.end(); it++) delete *it; messages.erase(messages.begin(), messages.end()); @@ -520,7 +520,7 @@ IncommingIndex::~IncommingIndex() { - vector ::iterator it; + std::vector ::iterator it; for (it = messages.begin(); it < messages.end(); it++) delete *it; } @@ -617,7 +617,7 @@ if (!messages.empty()) { int actnum = messages[0]->getNum(); - vector ::iterator it; + std::vector ::iterator it; for (it = messages.begin(); it < messages.end(); it++) { if ((*it)->getNum() > actnum+1) @@ -667,7 +667,7 @@ OutgoingIndex::~OutgoingIndex() { - vector ::iterator it; + std::vector ::iterator it; for (it = messages.begin(); it < messages.end(); it++) delete *it; } @@ -751,7 +751,7 @@ if (!messages.empty()) { int actnum = messages[0]->getNum(); - vector ::iterator it; + std::vector ::iterator it; for (it = messages.begin(); it < messages.end(); it++) { if ((*it)->getNum() > actnum+1) --- src/applications/mailer/mail_filt.h.orig 2013-08-21 16:13:18.955568579 -0700 +++ src/applications/mailer/mail_filt.h 2013-08-21 16:14:07.601962403 -0700 @@ -9,7 +9,7 @@ mail_filter.h - select message destinations */ -#include +#include #include #include "mail_screen.h" #include "mail_input.h" @@ -24,8 +24,8 @@ }; //Vector of selected boards -extern vector bfilter; -extern vector ::iterator bfit; +extern std::vector bfilter; +extern std::vector ::iterator bfit; //Message info struct Msg @@ -50,7 +50,7 @@ class BGroup : public Board { public: - vector content; + std::vector content; bool contains(const char *name); BGroup &operator = (const BGroup &); @@ -75,11 +75,11 @@ screen_obj *old_focused; public: - vector boards; - vector groups; + std::vector boards; + std::vector groups; - BoardList(MessageIndex *ndx, vector &, char *mycall); - BoardList(vector &); + BoardList(MessageIndex *ndx, std::vector &, char *mycall); + BoardList(std::vector &); void init_screen(void *pwin, int height, int width, int wy, int wx); void save_groups(); @@ -95,6 +95,6 @@ }; //Create the sorted list of boards from message list -void create_list(MessageIndex *ndx, vector &, vector &, +void create_list(MessageIndex *ndx, std::vector &, std::vector &, char *mycall); --- src/applications/mailer/mail_filt.cc.orig 2013-08-21 16:14:48.261291058 -0700 +++ src/applications/mailer/mail_filt.cc 2013-08-21 16:15:57.105846494 -0700 @@ -18,8 +18,8 @@ #define COLUMN1 20 #define COLUMN2 40 -vector bfilter; -vector ::iterator bfit; +std::vector bfilter; +std::vector ::iterator bfit; tbname &tbname::operator = (const tbname &src) { @@ -27,10 +27,10 @@ return *this; } -void create_list(MessageIndex *ndx, vector &msgs, - vector &boards, char *mycall) +void create_list(MessageIndex *ndx, std::vector &msgs, + std::vector &boards, char *mycall) { - vector ::iterator it; + std::vector ::iterator it; for (it = msgs.begin(); it < msgs.end(); it++) if (strchr(ndx->getMessage(it->index)->getFlags(), 'B') != NULL) { @@ -51,7 +51,7 @@ //sort it sort(boards.begin(), boards.end()); - vector ::iterator where = unique(boards.begin(), boards.end()); + std::vector ::iterator where = unique(boards.begin(), boards.end()); boards.erase(where, boards.end()); } @@ -81,7 +81,7 @@ bool BGroup::contains(const char *name) { - vector ::iterator it; + std::vector ::iterator it; for (it = content.begin(); it < content.end(); it++) if (strcasecmp(name, it->name) == 0) return true; return false; @@ -98,7 +98,7 @@ //========================================================================= // Class BoardList //========================================================================= -BoardList::BoardList(MessageIndex *ndx, vector &msgs, char *mycall) +BoardList::BoardList(MessageIndex *ndx, std::vector &msgs, char *mycall) { create_list(ndx, msgs, boards, mycall); pos = 0; @@ -116,7 +116,7 @@ load_groups(); } -BoardList::BoardList(vector &bds) +BoardList::BoardList(std::vector &bds) { boards = bds; pos = 0; @@ -156,11 +156,11 @@ f = fopen(fname, "w"); if (f != NULL) { - vector ::iterator it; + std::vector ::iterator it; for (it = groups.begin()+1; it < groups.end(); it++) { fprintf(f, "[%s]\n", it->name); - vector ::iterator bname; + std::vector ::iterator bname; for (bname = it->content.begin(); bname < it->content.end(); bname++) fprintf(f, "%s\n", bname->name); fprintf(f, "\n"); @@ -227,7 +227,7 @@ void BoardList::delete_group(int sel) { - vector ::iterator it = groups.begin(); + std::vector ::iterator it = groups.begin(); for (int i = 0; i < sel; i++) it++; groups.erase(it); } @@ -338,7 +338,7 @@ newgrp.sel = false; tbname newname; - vector ::iterator it; + std::vector ::iterator it; for (it = boards.begin(); it < boards.end(); it++) if (it->sel) { @@ -433,7 +433,7 @@ //select bulletins in group if (col == 0) { - vector ::iterator it; + std::vector ::iterator it; for (it = boards.begin(); it < boards.end(); it++) it->sel = groups[gslct].contains(it->name) || groups[gslct].content.empty(); @@ -451,7 +451,7 @@ if (col == 1 && ev->x == '*') { - vector ::iterator it; + std::vector ::iterator it; for (it = boards.begin(); it < boards.end(); it++) it->sel = !it->sel; } @@ -463,7 +463,7 @@ //update bfilter tbname newname; clear_filter(); - vector ::iterator it; + std::vector ::iterator it; for (it = boards.begin(); it < boards.end(); it++) if (it->sel) { --- src/applications/mailer/mail_list.h.orig 2013-08-21 16:11:23.899634441 -0700 +++ src/applications/mailer/mail_list.h 2013-08-21 16:12:11.963025130 -0700 @@ -9,7 +9,7 @@ mail_list.h - message list viewer and text viewer */ -#include +#include #include "mail_screen.h" #include "mail_filt.h" #include "mail_input.h" @@ -39,7 +39,7 @@ screen_obj *old_focused; public: - vector line; + std::vector line; TheFile(Message *themsg); virtual ~TheFile(); @@ -73,8 +73,8 @@ int folder; //displayed folder MessageIndex *ndx; //message index - vector msg; //filtered message list - vector boards; //list of boards + std::vector msg; //filtered message list + std::vector boards; //list of boards //saved old screen status void *old_focus_window; @@ -101,7 +101,7 @@ bool readable(int index); //is this message readable ? bool check_filter(int index); //is this message visible through filter ? int selected(); //index of selected message - void del_msg(vector ::iterator it); //delete message + void del_msg(std::vector ::iterator it); //delete message void draw_line(int i); //draw a single screen line virtual void handle_event(Event *); --- src/applications/mailer/mail_list.cc.orig 2013-08-21 16:21:36.974570005 -0700 +++ src/applications/mailer/mail_list.cc 2013-08-21 16:51:50.621850529 -0700 @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "mail_list.h" #include "mail_comp.h" @@ -116,7 +117,7 @@ long Messages::max() { - vector ::iterator it; + std::vector ::iterator it; int mx = 0; for (it = msg.begin(); it < msg.end(); it++) { @@ -128,7 +129,7 @@ long Messages::min() { - vector ::iterator it; + std::vector ::iterator it; int mx = -1; for (it = msg.begin(); it < msg.end(); it++) { @@ -140,7 +141,7 @@ long Messages::last_read() { - vector ::iterator it; + std::vector ::iterator it; int m = 0; int i; for (i = 0, it = msg.begin(); it < msg.end(); it++,i++) @@ -183,7 +184,7 @@ return false; } -void Messages::del_msg(vector ::iterator where) //delete message +void Messages::del_msg(std::vector ::iterator where) //delete message { msg.erase(where); } @@ -207,14 +208,14 @@ TheFile::~TheFile() { - vector ::iterator it; + std::vector ::iterator it; for (it = line.begin(); it < line.end(); it++) if (*it != NULL) delete [] (*it); } void TheFile::destroy_message() { - vector ::iterator it; + std::vector ::iterator it; for (it = line.begin(); it < line.end(); it++) if (*it != NULL) delete[] (*it); line.erase(line.begin(), line.end()); @@ -429,7 +430,7 @@ unsigned TheFile::max_len() { unsigned r = 0; - vector ::iterator it; + std::vector ::iterator it; for (it = line.begin(); it < line.end(); it++) if (strlen(*it) > r) r = strlen(*it); return r; @@ -437,7 +438,7 @@ bool TheFile::return_addr(char *result) { - vector ::iterator it; + std::vector ::iterator it; //try to find "Reply-To:" line for (it = line.begin(); it < line.end(); it++) @@ -711,7 +712,7 @@ if (toupper(ev->x) == 'D' && state == STATE_NORM) //Delete messages { - vector ::iterator it; + std::vector ::iterator it; //Count marked messages int sel = 0; @@ -752,7 +753,7 @@ if (ev->x == CTRLX) //Ctrl-X : delete messages { - vector ::iterator it; + std::vector ::iterator it; //Count marked messages int sel = 0; --- src/applications/mailer/mail_list.cc.orig 2013-08-21 16:21:36.974570005 -0700 +++ src/applications/mailer/mail_edit.cc 2003-08-13 11:55:26.000000000 -0700 @@ -1,1250 +1,1008 @@ /* LinPac Mailer - (c) 1998 - 2000 by Radek Burget OK2JBG (xburge01@stud.fee.vutbr.cz) + (c) 1998 - 2001 by Radek Burget OK2JBG (xburge01@stud.fee.vutbr.cz) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the license, or (at your option) any later version. - mail_list.cc - message list viewer and text viewer + mail_edit.cc - message composer classes */ -#include #include +#include #include +#include +#include #include -#include -#include "mail_list.h" -#include "mail_comp.h" -#include "mail_help.h" +#include + +#include "lpapp.h" +#include "mail_edit.h" +#include "mail_call.h" +#include "mail_data.h" +#include "mail_route.h" #include "mail_files.h" -#define MAIL_PATH "/var/ax25/mail" -#define LIST_PATH "/var/ax25/ulistd" +#define LINE_LEN 200 +#define ADDR_LEN 64 +#define SCREEN_LINES (x2-x1-2) -#define GETMSG "getmsg" -#define DELMSG "delmsg" #define TAB_SIZE 8 -#define CTRLX 24 -int atable = 0; //actual translation table -HelpWindow *helper = NULL; //help window +#define SYSLINES 3 + +//uncoment this to make BS to skip to previous line when pressed at the +//begining of line +//#define BS_SKIP_LINES + +//uncoment this to make BS to join the line with the previous one when +//pressed at the begining of line +#define BS_JOIN_LINES + +//uncomment this to add a path to yourself into each message +//#define PATH_TO_OWN -bool comment; +char old_help[80]; -bool isnum(char *s) +//convert string to uppercase +char *strupr(char *s) { - char *p = s; - if (!*p) return false; - while (*p) if (!isdigit(*p)) return false; - else p++; - return true; + char *p = s; + while (*p) { *p = toupper(*p); p++; } + return s; } -char *outbuffer = NULL; - -char *extract(const char *start, const char *stop) +//return true if the string contains at least one digit +bool contains_digit(char *s) { - if (outbuffer != NULL) delete[] outbuffer; - outbuffer = new char[(stop-start)+1]; - int i = 0; - for (char *p = (char *)start; p < stop; p++) + char *p = s; + while (*p) { - outbuffer[i] = *p; - i++; + if (isdigit(*p)) return true; + p++; } - outbuffer[i] = '\0'; - return outbuffer; + return false; } -//========================================================================= -// Class Messages (list of messages) -//========================================================================= -//Possible states -const int STATE_NORM = 0; //normal state (no actions in progress) -const int STATE_WAIT = 1; //waiting for start of download -const int STATE_DNLD = 2; //download in progress - -//Folders -const int FOLDER_INCOMMING = 0; -const int FOLDER_OUTGOING = 1; -const int NUM_FOLDERS = 2; - -Messages::Messages(char *bbs_name, char *call, bool all) +//-------------------------------------------------------------------------- +// Class Edline +//-------------------------------------------------------------------------- +Edline::Edline() { - strcpy(class_name, "MESSAGES"); - bbs = strdup(bbs_name); - mycall = strdup(call); + attr = ED_TEXT; + editable = true; + s = new char[LINE_LEN+1]; + clrline(); +} - folder = FOLDER_INCOMMING; - ndx = new IncommingIndex(bbs); - ndx->checkPresence(); - load_list(all); +Edline::~Edline() +{ + delete[] s; +} - priv = all; - slct = last_read(); - pos = slct; - viewer = NULL; - state = STATE_NORM; +Edline &Edline::operator = (const Edline &source) +{ + strcpy(s, source.s); + attr = source.attr; + editable = source.editable; + return *this; } -void Messages::clear_msgs() +int Edline::lastpos() { - msg.erase(msg.begin(), msg.end()); + int i; + for(i = strlen(s)-1; i>-1 && isspace(s[i]); i--) ; + return i; } -void Messages::load_list(bool all) +void Edline::clrline() { - for (int index = 0; index < ndx->messageCount(); index++) - { - if ((all || readable(index)) && check_filter(index)) - { - Msg newmsg; - newmsg.index = index; - newmsg.select = false; - msg.push_back(newmsg); - } + for (int i=0; i (y2-y1)) {cry = y2 - y1; poz += old_cry - cry;} + delwin(win); + win = newwin(y2-y1+1, x2-x1+1, y1, x1); + redraw(true); +} + +void Editor::handle_event(Event *ev) +{ + char *s; + + if (ev == NULL) return; + + if (ev->type==EV_KEY_PRESS) + { + if (!ev->y) + switch (ev->x) + { + case KEY_LEFT: cr_left(); break; + case KEY_RIGHT: cr_right(); break; + case KEY_UP: cr_up(); break; + case KEY_DOWN: cr_down(); break; + case KEY_PPAGE: cr_pgup(); break; + case KEY_NPAGE: cr_pgdn(); break; + case KEY_HOME: cr_home(); break; + case KEY_END: cr_end(); break; + case KEY_DC: + case '\a': del_ch(); break; + case KEY_DL: + case '\031': delline(); break; + case KEY_BACKSPACE: + case '\b': backspace(); break; + case '\t': cr_tab(); break; + case KEY_ENTER: + case '\r': + case '\n': newline(); break; + case 20 : s = time_stamp(0); /* ^T */ + for (unsigned i=0; ix <= 255) newch(ev->x); + } + wmove(win, cry, crx); + wrefresh(win); } - create_list(ndx, msg, boards, mycall); } -void Messages::reload(bool all) +void Editor::draw(bool all) { - msg.erase(msg.begin(), msg.end()); - load_list(all); + //if (all || err) redraw(false); + if (err) redraw(true); + else if (all) redraw(false); + wrefresh(win); + err = false; } -long Messages::max() +void Editor::redraw(bool update) { - vector ::iterator it; - int mx = 0; - for (it = msg.begin(); it < msg.end(); it++) + if (update) { - int current = ndx->getMessage(it->index)->getNum(); - if (current > mx) mx = current; + wclear(win); + wbkgd(win, ' ' | COLOR_PAIR(ED_TEXT)); + wbkgdset(win, ' '); } - return mx; + draw_lines(); + //if (update) wrefresh(win); } -long Messages::min() +void Editor::draw_lines() { - vector ::iterator it; - int mx = -1; - for (it = msg.begin(); it < msg.end(); it++) - { - int current = ndx->getMessage(it->index)->getNum(); - if (current < mx || mx == -1) mx = current; - } - return mx; + int i; + for (i=0; i<=(y2-y1); i++) + if (poz+i < max) line[i+poz].draw(win, i); + wmove(win, cry, crx); } -long Messages::last_read() +void Editor::draw_line(int n) { - vector ::iterator it; - int m = 0; - int i; - for (i = 0, it = msg.begin(); it < msg.end(); it++,i++) - if (ndx->getMessage(it->index)->isPresent()) m = i; - return m; + if ((n >= poz) && (n <= poz+(y2-y1))) + line[n].draw(win, n-poz); + wmove(win, cry, crx); } -bool Messages::present(int num) +void Editor::cr_right() { - int index = ndx->msgNum(num); - return ((index > 0) && ndx->getMessage(index)->isPresent()); + crx++; + if (crx >= SCREEN_LINES) {crx = 0; cr_down();} + wmove(win, cry, crx); } -bool Messages::readable(int index) +void Editor::cr_left() { - //never display deleted messages - if (strchr(ndx->getMessage(index)->getFlags(), 'D') != NULL) return false; - //always display bulletins - if (strchr(ndx->getMessage(index)->getFlags(), 'B') != NULL) return true; - //display personal messages for the user - unsigned len = strlen(mycall); - char *dest = ndx->getMessage(index)->getDest(); - if ((strncmp(dest, mycall, len) == 0) && - (dest[len] == '@' || strlen(dest) == len)) return true; - return false; + crx--; + if (crx < 0) {cr_up(); cr_end();} + wmove(win, cry, crx); } -bool Messages::check_filter(int index) +void Editor::cr_up(bool update) { - if (bfilter.empty()) return true; - char *dest = strdup(ndx->getMessage(index)->getDest()); - int cmp; - char *p = strchr(dest, '@'); if (p != NULL) *p = 0; - for (bfit = bfilter.begin(); bfit < bfilter.end(); bfit++) - { - cmp = strcasecmp(bfit->name, dest); - if (cmp == 0) return true; - if (cmp > 0) break; + if (poz > 0 || cry > 0) + { + if (cry==0) {poz--; if (update) draw(true);} + else cry--; } - return false; + if (update) wmove(win, cry, crx); } -void Messages::del_msg(vector ::iterator where) //delete message +void Editor::cr_down(bool update) { - msg.erase(where); + if (poz+cry < max-1) + { + if (cry==y2-y1) {poz++; if (update) draw(true);} + else cry++; + } + if (update) wmove(win, cry, crx); } -//======================================================================== -// Class TheFile (message viewer); -//======================================================================== +void Editor::cr_pgup() +{ + for (int i = 0; i < (y2-y1); i++) + if (poz > 0) poz--; + else if (cry > 0) cry--; + draw(true); + wmove(win, cry, crx); +} -TheFile::TheFile(Message *themsg) +void Editor::cr_pgdn() { - strcpy(class_name, "VIEWER"); - xpos = 0; - pos = 0; - head = false; - wrap = true; - wait_reply = false; - wait_sname = false; - msg = themsg; - //load_message(head); + for (int i = 0; i < (y2-y1); i++) + if (poz + (y2-y1) < max-1) poz++; + else if (poz+cry < max-1) cry++; + draw(true); + wmove(win, cry, crx); } -TheFile::~TheFile() +void Editor::delline() { - vector ::iterator it; - for (it = line.begin(); it < line.end(); it++) - if (*it != NULL) delete [] (*it); + if (max-1 > cry+poz) + { + int i; + for (i = cry+poz+1; i < max; i++) line[i-1] = line[i]; + line[max-1].clrline(); + max--; + } + draw(true); } -void TheFile::destroy_message() +void Editor::cr_home() { - vector ::iterator it; - for (it = line.begin(); it < line.end(); it++) - if (*it != NULL) delete[] (*it); - line.erase(line.begin(), line.end()); + crx = 0; + wmove(win, cry, crx); } -void TheFile::load_message(bool head) +void Editor::cr_end() { - char *p1, *p2; + crx = line[cry+poz].lastpos() + 1; + if (crx > x2 - x1 + 1) crx = x2 - x1 + 1; + wmove(win, cry, crx); +} - destroy_message(); - attach = 0; - p1 = msg->getBody(); +void Editor::cr_tab() +{ + if (crx < LINE_LEN) + do crx++; while (crx < LINE_LEN && crx%TAB_SIZE != 0); + wmove(win, cry, crx); +} - if (p1) +void Editor::backspace() +{ + if (line[poz+cry].editable) { - char lastln[256]; - strcpy(lastln, ""); - - bool in7p = false; - char name7p[256]; - - while (*p1) + if (crx > 0) { - p2 = p1; - while (*p2 && *p2 != '\n') p2++; if (*p2) p2++; - - char *s = strdup(extract(p1, p2-1)); - - //detect 7plus - if (strncmp(s, " go_7+.", 7) == 0 && !in7p) - { - in7p = true; - } - if (strncmp(s, " stop_7+.", 9) == 0 && in7p) - { - //find name - strcpy(name7p, ""); - char *p = strchr(s, '('); - if (p) - { - p++; - while (*p && *p != ')' && *p != '/' && strlen(p) < 255) - { - char ch = tolower(*p); - strncat(name7p, &ch, 1); - p++; - } - } - - in7p = false; - attach++; - char msg[100]; - sprintf(msg, "--- Message attachment no. %i", attach); - line.push_back(strdup(msg)); - sprintf(msg, "--- This part of message is 7plus encoded (%.32s)", name7p); - line.push_back(strdup(msg)); - sprintf(msg, "--- Press X to save this part of message"); - line.push_back(strdup(msg)); - delete[] s; - p1 = p2; - continue; - } - - if (!in7p) - { - //expand TABs - char ln[256]; - strcpy(ln, lastln); - for (unsigned i=0; i 0); - else - strncat(ln, &s[i], 1); - } + int i; - //break too long lines - if (strncmp(s, "R:", 2) != 0) - { - bool broken = false; - bool answer = false; - while ((int)strlen(ln) > xsize-3 && wrap) - { - if (ln[0] == '>') answer = true; - char *p = &(ln[xsize-4]); //find the last space on line - while (p > ln && !isspace(*p)) p--; - if (p == ln) p = &(ln[xsize-3]); //no spaces found - *p = '\0'; - char *store = new char[strlen(ln)+1];//store the line - strcpy(store, ln); - line.push_back(store); - p++; //continue next part - //strcpy(ln, p); - memmove(ln, p, strlen(p)+1); - broken = true; - } - if (broken && !answer) - { - strcpy(lastln, ln); - strcat(lastln, " "); - } - else - { - char *store = new char[strlen(ln)+1]; - strcpy(store, ln); - line.push_back(store); - strcpy(lastln, ""); - } - } - else if (head) - { - char *store = new char[strlen(ln)+1]; - strcpy(store, ln); - line.push_back(store); - } - } - - delete[] s; - p1 = p2; //next line + crx--; + for (i = crx; i < LINE_LEN-1; i++) line[poz+cry].s[i] = line[poz+cry].s[i+1]; + line[poz+cry].s[i]=' '; + draw_line(poz+cry); + } + #ifdef BS_SKIP_LINES + else cr_left(); + wmove(win, cry, crx); + #endif + #ifdef BS_JOIN_LINES + else + { + char rem[LINE_LEN+1]; + line[poz+cry].get_text(rem); + delline(); + cr_up(); + cr_end(); + int zcrx = crx; int zcry = cry; + char *p = rem; + while (*p) { newch(*p); p++; } + crx = zcrx; cry = zcry; + wmove(win, cry, crx); } - } - else + #endif + } else cr_left(); +} + +void Editor::del_ch() +{ + int i; + + if (line[poz+cry].editable) { - char *store = new char[32]; - sprintf(store, "Message %i is not present.", msg->getNum()); - line.push_back(store); + for (i = crx; i < LINE_LEN-1; i++) line[poz+cry].s[i] = line[poz+cry].s[i+1]; + line[poz+cry].s[i]=' '; + draw_line(poz+cry); + wmove(win, cry, crx); } } -void TheFile::extract_attach(int num) +void Editor::newline(bool update) { - char *p1, *p2; - - p1 = msg->getBody(); - - if (p1) + if (line[poz+cry].editable || crx > line[poz+cry].lastpos()) { - char lastln[256]; - strcpy(lastln, ""); - - bool in7p = false; - bool saving = false; - FILE *outf; - int atcnt = 0; - char name7p[256]; - char *tmp = strdup("/tmp/lp_mail_ea.XXXXXX"); - int tmpdesc = mkstemp(tmp); - close(tmpdesc); - //char *tmp = strdup(tmpnam(NULL)); - - while (*p1) + if (poz+cry < max-1 || max < limit) { - p2 = p1; - while (*p2 && *p2 != '\n') p2++; if (*p2) p2++; + char next_line[LINE_LEN+1]; - char *s = strdup(extract(p1, p2-1)); - - //detect 7plus - if (strncmp(s, " go_7+.", 7) == 0 && !in7p) - { - in7p = true; - atcnt++; - if (atcnt == num) - { - saving = true; - outf = fopen(tmp, "w"); - if (!outf) errormsg("Cannot create temp file"); - } - } - - if (in7p && saving && outf) - { - fprintf(outf, "%s\n", s); - } - - if (strncmp(s, " stop_7+.", 9) == 0 && in7p) - { - //find name - strcpy(name7p, ""); - char *p = strchr(s, '('); - if (p) - { - p++; - while (*p && *p != ')' && *p != '/' && strlen(p) < 255) - { - char ch = tolower(*p); - strncat(name7p, &ch, 1); - p++; - } - } - - in7p = false; - - if (saving) - { - fclose(outf); - char *name = save_file_path(name7p); - if (rename(tmp, name) == -1) - errormsg("Cannot create %s", name); - else - errormsg("Attachment saved to %s", name); - delete[] name; - saving = false; - } - } - delete[] s; - p1 = p2; //next line + char *p = &(line[poz+cry].s[crx]); + strcpy(next_line, p); + for (int i = crx; i < LINE_LEN; i++) line[poz+cry].s[i] = ' '; + draw_line(poz+cry); + + if (max < limit) max++; + for (int i = max-1; i > cry+poz; i--) + line[i+1] = line[i]; + cr_down(update); + + line[poz+cry].accept(next_line); + if (update) { draw_lines(); wrefresh(win); } } - } else errormsg("Cannot open message file"); + } + cr_home(); + wmove(win, cry, crx); } -unsigned TheFile::max_len() +void Editor::ins_info(char *ch) { - unsigned r = 0; - vector ::iterator it; - for (it = line.begin(); it < line.end(); it++) - if (strlen(*it) > r) r = strlen(*it); - return r; + line[cry+poz].accept(ch); + line[cry+poz].attr = ED_INFO; + line[cry+poz].editable = true; + crx = strlen(ch); + newline(false); } -bool TheFile::return_addr(char *result) +void Editor::ins_nonedit(char *ch) { - vector ::iterator it; + line[cry+poz].accept(ch); + line[cry+poz].attr = ED_TEXT; + line[cry+poz].editable = false; + crx = strlen(ch); + newline(false); +} - //try to find "Reply-To:" line - for (it = line.begin(); it < line.end(); it++) - { - if (strncasecmp(*it, "Reply-To:", 9) == 0) - { - char *p = *it + 9; //read the address - char *q = result; - while (*p) - { - if (!isspace(*p)) //skip spaces - { - *q = *p; - q++; - } - p++; +void Editor::newch(char ch) +{ + if (line[poz+cry].editable) + { + int i; + + line[poz+cry].attr = ED_TEXT; + for (i=LINE_LEN-1; i>crx; i--) line[poz+cry].s[i] = line[poz+cry].s[i-1]; + line[poz+cry].s[crx] = ch; + draw_line(poz+cry); + crx++; + if (line[poz+cry].lastpos() >= SCREEN_LINES) //end of line exceeded + { + int zx, zy=-1; + if (crx < SCREEN_LINES) {zx = crx; zy = cry;} + int p = line[poz+cry].lastpos() - 1; + while (p>0 && !isspace(line[poz+cry].s[p])) p--; + crx = p+1; + newline(); + cr_end(); + if (zy != -1) {crx = zx; cry = zy;} } - *q = '\0'; - return true; + wmove(win, cry, crx); } - } +} - //Reply address not found, use the address from the last R: line - if (!head) load_message(true); //We need the header - char rroute[40]; - it = line.begin(); - while (it < line.end() && strncmp(*it, "R:", 2) == 0) it++; - if (it > line.begin()) - { - it--; //return to the last R: line - char *p = strstr(*it, "@:"); - if (p != NULL) - { - p += 2; - char *q = rroute; - while (*p && !isspace(*p)) - { - *q = *p; p++; q++; - } - *q = '\0'; - sprintf(result, "%s@%s", msg->getSrc(), rroute); - if (!head) load_message(head); - return true; - } - } +void Editor::convert_charset(char *s) +{ + char *p = s; + while (*p) + { + if (*p < convcnt) *p = conv[*p]; + p++; + } +} - //not found anywhere - if (!head) load_message(head); - return false; +void Editor::errormsg(char *msg) +{ + wbkgdset(win, ' ' | COLOR_PAIR(C_ERROR)); + mvwprintw(win, y2-y1, 0, " %s ", msg); + wbkgdset(win, ' ' | COLOR_PAIR(ED_TEXT)); + err = true; + wmove(win, cry, crx); + wrefresh(win); } -//========================================================================== -// Functions using ncurses (conflicting) -//========================================================================== -#include +void Editor::clear_error() +{ + if (err) draw(true); +} -void Messages::init_screen(void *pwin, int height, int width, int wy, int wx) +Editor::~Editor() { - xsize = width; - ysize = height; - x = wx; - y = wy; +} + +//======================================================================== + +Composer::Composer(WINDOW *parent, int wx1, int wy1, int wx2, int wy2, char *toaddr, char *subject) +{ + const int maxlines = 500; //number of editor lines + + x1 = wx1; y1 = wy1; x2 = wx2; y2 = wy2; + bool reply = (toaddr != NULL); + type = 'P'; + from = NULL; + to = new char[ADDR_LEN]; to[ADDR_LEN-1] = '\0'; + if (toaddr != NULL) + { + strncpy(to, toaddr, ADDR_LEN-1); + check_dest(); + } + else strcpy(to, ""); + + subj = new char[LINE_LEN]; + if (subject != NULL) strncpy(subj, subject, LINE_LEN-1); + else strcpy(subj, ""); - WINDOW *win = subwin(reinterpret_cast(pwin), ysize, xsize, y, x); - mwin = win; + //win = subwin(parent, y2-y1+1, x2-x1+1, y1, x1); + win = parent; + if (win == NULL) beep(); keypad(win, true); meta(win, true); nodelay(win, true); - wbkgdset(win, ' ' | COLOR_PAIR(C_TEXT) | A_BOLD); + wbkgdset(win, ' ' | COLOR_PAIR(ED_TEXT) | A_BOLD); werase(win); box(win, ACS_VLINE, ACS_HLINE); - mvwprintw(win, 0, 2, "%s", bbs); - draw(); + mvwprintw(win, 0, 2, "Composer"); - old_focus_window = focus_window; + ed = new Editor(win, x1+1, y1+SYSLINES+3, x2-1, y2-1, maxlines); + load_texts(); + + old_focus_window = (WINDOW *) focus_window; focus_window = win; old_focused = focused; focused = this; - help(HELP_LIST); -} - -void Messages::draw_line(int i) -{ - WINDOW *win = reinterpret_cast(mwin); - - if (i+pos < (int)msg.size()) + crx = 0; + if (!reply) cry = 0; + else {cry = SYSLINES + head_lines + 1; ed->cry = head_lines;} + ttabnum = -1; + ttabsize = 0; + + help(HELP_EDIT); + + draw(true); + if (cry == 0) { - long attr; - int index = msg[i+pos].index; //index of current message - - if (slct == i+pos) - { - attr = COLOR_PAIR(C_SELECT); - if (ndx->getMessage(index)->isPresent()) attr |= A_BOLD; - } - else - { - attr = COLOR_PAIR(C_UNSELECT); - if (ndx->getMessage(index)->isPresent()) attr |= A_BOLD; - } - - wbkgdset(win, ' ' | attr); - - int sl; - if (msg[i+pos].select) sl = ACS_BULLET; - else sl = ' '; - - char subj[256]; - strncpy(subj, ndx->getMessage(index)->getSubj(), 255); subj[255] = '\0'; - for (unsigned j=0; jgetMessage(index)->getNum(), sl, - ndx->getMessage(index)->getFlags(), - ndx->getMessage(index)->getSize(), - ndx->getMessage(index)->getDest(), - ndx->getMessage(index)->getDPath(), - ndx->getMessage(index)->getSrc(), - ndx->getMessage(index)->getDate().toStringShort(), - xsize-49, xsize-50, subj); - if (folder == FOLDER_OUTGOING) - mvwprintw(win, i+2, 2, "%6i%c%2s %-20.20s %-6.6s %6.6s %-*.*s", - ndx->getMessage(index)->getNum(), sl, - ndx->getMessage(index)->getFlags(), - ndx->getMessage(index)->getDest(), - ndx->getMessage(index)->getSrc(), - ndx->getMessage(index)->getDate().toStringShort(), - xsize-49, xsize-50, subj); + wmove(win, 1, 12); + wrefresh(win); } else { - wbkgdset(win, COLOR_PAIR(C_TEXT)); - mvwprintw(win, i+2, 2, "%*s", xsize-4, ""); + wrefresh(win); + ed->cr_home(); //to draw the cursor to the right place + ed->draw(); } + + wait_rname = false; + wait_sname = false; + wait_fname = false; } -void Messages::draw(bool all) +Composer::~Composer() { - WINDOW *win = reinterpret_cast(mwin); - - if (all) - { - wbkgdset(win, ' ' | COLOR_PAIR(C_TEXT) | A_BOLD); - werase(win); - box(win, ACS_VLINE, ACS_HLINE); - - char sf[32]; - if (folder == FOLDER_INCOMMING) strcpy(sf, "Incomming mail"); - if (folder == FOLDER_OUTGOING) strcpy(sf, "Outgoing mail"); - - mvwprintw(win, 0, 2, "%s: %s", bbs, sf); - if (state == STATE_WAIT) mvwprintw(win, 0, 25, " (starting download) "); - if (state == STATE_DNLD) mvwprintw(win, 0, 25, " (downloading messages) "); - } - - for (int i=0; itype == EV_KEY_PRESS) - { - if (ev->x == KEY_DOWN) - { - if (slct < count()-1) - { - slct++; - if (slct-pos >= ysize-3) - { - pos++; - draw(); - } - else - { - draw_line(slct-1-pos); - draw_line(slct-pos); - wrefresh((WINDOW *)mwin); - } - } - } - if (ev->x == KEY_UP) - { - if (slct > 0) - { - slct--; - if (slct-pos < 0) - { - pos--; - draw(); - } - else - { - draw_line(slct+1-pos); - draw_line(slct-pos); - wrefresh((WINDOW *)mwin); - } - } - } - if (ev->x == KEY_NPAGE) - { - for (int j=0; j < (ysize-3); j++) - { - if (slct < count()-1) slct++; - if (slct-pos >= ysize-3) pos++; - } - } - if (ev->x == KEY_PPAGE) - { - for (int j=0; j < (ysize-3); j++) - { - if (slct > 0) slct--; - if (slct-pos < 0) pos--; - } - } - - if (ev->x == ' ' && state == STATE_NORM) - msg[slct].select = !msg[slct].select; - - if (toupper(ev->x) == 'P') - { - int anum = ndx->getMessage(cur)->getNum(); - int aofs = slct - pos; - //reload table - priv = !priv; - reload(priv); - //calculate new cursor position - int i = 0; - while (i < count() && - ndx->getMessage(msg[i].index)->getNum() < anum) i++; - slct = i; //new cursor position - pos = slct - aofs; //new window start position - if (pos < 0) pos = 0; - } - - if (toupper(ev->x) == 'Q') - { - //delwin(reinterpret_cast(mwin)); - focus_window = old_focus_window; - focused = old_focused; - } - - if (toupper(ev->x) == 'D' && state == STATE_NORM) //Delete messages - { - vector ::iterator it; - - //Count marked messages - int sel = 0; - for (it = msg.begin(); it < msg.end(); it++) - { - int cur = it->index; - if (it->select && !ndx->getMessage(cur)->isPresent()) - sel++; - } - - //Some messages selected - if (sel > 0) - { - //Create the command - char *cmd = new char[64 + sel*32]; - strcpy(cmd, GETMSG); - for (it = msg.begin(); it < msg.end(); it++) - { - char num[32]; - int cur = it->index; - if (it->select && !ndx->getMessage(cur)->isPresent()) - { - if (strchr(ndx->getMessage(cur)->getFlags(), 'P') != NULL) - sprintf(num, " P%i", ndx->getMessage(cur)->getNum()); //personal - else - sprintf(num, " %i", ndx->getMessage(cur)->getNum()); //bulletins - strcat(cmd, num); - } - } - - //Start the download - lp_emit_event(lp_channel(), EV_DO_COMMAND, strlen(cmd), cmd); - state = STATE_WAIT; - if (act) draw(true); - delete[] cmd; - } - } - - if (ev->x == CTRLX) //Ctrl-X : delete messages - { - vector ::iterator it; - - //Count marked messages - int sel = 0; - for (it = msg.begin(); it < msg.end(); it++) - if (it->select) sel++; + if (ev == NULL) + { + if (wait_rname) + { + wait_rname = false; + int ch; + char *name = load_file_path(ibuffer); + FILE *f = fopen(name, "r"); + if (f != NULL) + { + while ((ch = fgetc(f)) != EOF) + if (ch == '\n') ed->newline(false); + else ed->newch((char) ch); + fclose(f); + ed->draw(true); + } + else ed->errormsg("File not found"); + delete[] name; + } + if (wait_sname) + { + wait_sname = false; + char *name = save_file_path(ibuffer); + FILE *f = fopen(name, "w"); + if (f != NULL) + { + for (int i = 0; i < ed->max; i++) + { + char s[LINE_LEN+1]; + (ed->line[i]).get_text(s); + fputs(s, f); + fputc('\n', f); + } + fclose(f); + ed->draw(true); + delete[] name; + } + else ed->errormsg("Cannot create file"); + } + if (wait_fname) + { + wait_fname = false; + char *name = load_file_path(ibuffer); + FILE *f = fopen(name, "r"); + if (f != NULL) + { + char msg[256]; + sprintf(msg, "Attached file: "); + strncat(msg, name, 255); + ed->ins_nonedit(msg); + sprintf(msg, "This file will be converted with 7plus and sent in separate message(s)"); + ed->ins_nonedit(msg); + sprintf(msg, "To remove the attachment just delete following line (Ctrl-Y)."); + ed->ins_nonedit(msg); + sprintf(msg, ".attach "); + strncat(msg, name, 255); + ed->ins_nonedit(msg); + + fclose(f); + ed->draw(true); + } + else ed->errormsg("Cannot open file"); + delete[] name; + } + } + else if (ev->type == EV_KEY_PRESS) + { + ed->clear_error(); + if (!ev->y) switch (ev->x) + { + case '\n': + case KEY_DOWN: if (cry > SYSLINES) + { + ed->handle_event(ev); + cry = ed->cry+SYSLINES+1; + } + else + { + if (cry == 0) check_dest(); + cry++; + if (cry > SYSLINES) ed->draw(); + } + break; + case KEY_UP : if (cry > SYSLINES) + { + if (ed->poz != 0 || ed->cry > 0) + ed->handle_event(ev); + else + cry = SYSLINES; + } else if (cry > 0) cry--; + break; + case '\x18' : if (send_message()) /* ^X */ + { + focus_window = old_focus_window; + focused = old_focused; + if (focused != NULL) focused->draw(true); + help(old_help); + return; + } + else + { + beep(); + break; + } + case '\x01' : focus_window = old_focus_window; /* ^A */ + focused = old_focused; + if (focused != NULL) focused->draw(true); + help(old_help); + return; + case '\x12' : if (cry > SYSLINES) /* ^R */ + { + wait_rname = true; + iline = new InputLine(win, 2, y2-y1, x2-x1-1, x2-x1-19, + "Insert file:", ibuffer, INPUT_ALL); + } + break; + case '\x05' : if (cry > SYSLINES) /* ^E */ + { + wait_sname = true; + iline = new InputLine(win, 2, y2-y1, x2-x1-1, x2-x1-16, + "Export to file:", ibuffer, INPUT_ALL); + } + break; + case '\x06' : if (cry > SYSLINES) /* ^F */ + { + wait_fname = true; + iline = new InputLine(win, 2, y2-y1, x2-x1-1, x2-x1-16, + "Attach file:", ibuffer, INPUT_ALL); + } + break; + default : if (cry > SYSLINES) + ed ->handle_event(ev); + else + if (ev->x == KEY_BACKSPACE || ev->x == '\b') + { + if (cry == 0) to[strlen(to)-1] = '\0'; + if (cry == 2) subj[strlen(subj)-1] = '\0'; + } + else if (ev->x == KEY_DC || ev->x == '\a') + { + if (cry == 0) to[strlen(to)-1] = '\0'; + if (cry == 2) subj[strlen(subj)-1] = '\0'; + } + else if (ev->x == ' ' && cry == 3) + { + if (ttabnum < ntables-1) ttabnum++; + else ttabnum = -1; + } + else if (!iscntrl(ev->x)) + { + char c = (char) ev->x; + if (cry == 0) + if (strlen(to)x) == 'P' || + toupper(ev->x) == 'B') type = toupper(ev->x); + if (cry == 2) + if (strlen(to) 0) - { - //Create the command - cmd = new char[64 + sel*32]; - strcpy(cmd, DELMSG); - - for (it = msg.begin(); it < msg.end(); it++) - { - if (it->select) - { - char num[32]; - sprintf(num, " %i", ndx->getMessage(it->index)->getNum()); //bulletins - strcat(cmd, num); - } - } - - //delete the messages from the list - bool deleted = true; - while (deleted) - { - deleted = false; - for (it = msg.begin(); it < msg.end(); it++) - if (it->select) - { - del_msg(it); - deleted = true; - break; - } - } - - - } - else //no messages were selected, delete actual one - { - cmd = new char[128]; - it = msg.begin(); - for (int i = 0; i < slct; i++) it++; - sprintf(cmd, "%s %i", DELMSG, ndx->getMessage(it->index)->getNum()); - del_msg(it); - } - lp_emit_event(lp_channel(), EV_DO_COMMAND, strlen(cmd), cmd); - delete[] cmd; - if (slct >= count()) slct = count()-1; - - if (act) draw(true); - } - - if (toupper(ev->x) == 'T') - { - atable++; - if (atable >= ntables) atable = 0; - load_table(atable); - draw(); - } +void Composer::draw_header() +{ + mvwprintw(win, 1, 2, "To : %-40.40s", to); + mvwprintw(win, 2, 2, "Type : %c", type); + mvwprintw(win, 3, 2, "Subject : %-40.40s", subj); + if (ttabnum == -1) + mvwprintw(win, 4, 2, "Encode : "); + else + mvwprintw(win, 4, 2, "Encode : %-40.40s", tables[ttabnum]); +} - if (toupper(ev->x) == 'I') - { - folder++; - if (folder >= NUM_FOLDERS) folder = 0; - if (folder == FOLDER_INCOMMING) - { - clear_msgs(); - delete ndx; - ndx = new IncommingIndex(bbs); - ndx->checkPresence(); - load_list(priv); - slct = last_read(); - pos = slct; - if (act) draw(true); - } - if (folder == FOLDER_OUTGOING) - { - clear_msgs(); - delete ndx; - ndx = new OutgoingIndex(bbs); - ndx->checkPresence(); - load_list(true); - slct = last_read(); - pos = slct; - if (act) draw(true); - } - } - else if (toupper(ev->x) == 'H') - { - if (helper == NULL) - helper = new HelpWindow(reinterpret_cast(mwin), ysize, xsize, y, x); - else - helper->show(); - } - else if (toupper(ev->x) == 'C') - { - strcpy(old_help, HELP_LIST); - start_composer(mwin, x, y, x+xsize-1, y+ysize-1, NULL, NULL); - } - else if (toupper(ev->x) == 'F') - { - blister = new BoardList(boards); - blister->init_screen(reinterpret_cast(mwin), - ysize, xsize, y, x); - } - else if (ev->x == '\n') - { - viewer = new TheFile(ndx->getMessage(msg[slct].index)); - viewer->init_screen(reinterpret_cast(mwin), - ysize, xsize, y, x); - } - else - if (ev->x != KEY_DOWN && ev->x != KEY_UP) draw(); - } +void Composer::draw(bool all) +{ + if (all) + { + wbkgdset(win, ' ' | COLOR_PAIR(ED_INFO) | A_BOLD); + draw_header(); + mvwhline(win, SYSLINES+2, 1, ACS_HLINE, x2-x1-2); - if (ev->type == EV_APP_MESSAGE) - { - char *p = reinterpret_cast(ev->data); - if (strcmp(p, "getmsg: start") == 0 && state == STATE_WAIT) - { - state = STATE_DNLD; - if (act) draw(true); - } - else if (strcmp(p, "getmsg: done") == 0 && state == STATE_DNLD) - { - state = STATE_NORM; - //reload(priv); //there should't be the need to reload - //if (act) draw(); - } - else if (strncmp(p, "getmsg: got ", 12) == 0 /*&& state == STATE_DNLD*/) - { - char *np = p + 12; - int num = atoi(np); - for (unsigned i = 0; i < msg.size(); i++) - { - int mnum = ndx->getMessage(msg[i].index)->getNum(); - if (mnum == num && msg[i].select) - { - msg[i].select = false; - ndx->getMessage(msg[i].index)->setPresence(true); - if (act && focused == this) draw(); - } - if (mnum >= num) break; - } - } - } + ed->draw(all); + } + wrefresh(win); } -//------------------------------------------------------------------------ +void Composer::edredraw() +{ + ed->draw(true); +} -void TheFile::init_screen(void *pwin, int height, int width, int wy, int wx) +void Composer::load_texts() { - xsize = width; - ysize = height; - x = wx; - y = wy; - - load_message(head); + char fname[256]; + FILE *f; + char *p = lp_get_var(0, "MAIL_PATH"); + int i = 0; - char *subj = strdup(msg->getSubj()); - for (unsigned j=0; j(pwin), ysize, xsize, y, x); - WINDOW *win = reinterpret_cast(pwin); - mwin = win; - keypad(win, true); - meta(win, true); - nodelay(win, true); - - wbkgdset(win, ' ' | COLOR_PAIR(C_MSG) | A_BOLD); - werase(win); - box(win, ACS_VLINE, ACS_HLINE); - mvwprintw(win, 0, 2, "Message %i:%s", msg->getNum(), subj); - draw(); + head_lines = 0; + sprintf(fname, "%s/mail.head", lp_get_var(0, "MAIL_PATH")); + f = fopen(fname, "r"); + if (f != NULL) + { + while (!feof(f)) + { + char s[LINE_LEN+1]; + strcpy(s, ""); + fgets(s, LINE_LEN, f); + if (s[strlen(s)-1] == '\n') s[strlen(s)-1] = '\0'; + replace_macros(lp_channel(), s); + ed->line[i].accept(s); + i++; + head_lines++; + } + fclose(f); + } - old_focus_window = focus_window; - focus_window = win; - old_focused = focused; - focused = this; + i += 2; + sprintf(fname, "%s/mail.tail", lp_get_var(0, "MAIL_PATH")); + f = fopen(fname, "r"); + if (f != NULL) + { + while (!feof(f)) + { + char s[LINE_LEN+1]; + strcpy(s, ""); + fgets(s, LINE_LEN, f); + if (s[strlen(s)-1] == '\n') s[strlen(s)-1] = '\0'; + replace_macros(lp_channel(), s); + ed->line[i].accept(s); + i++; + } + fclose(f); + } - help(HELP_VIEW); - delete[] subj; + ed->max = i; } -void TheFile::draw(bool all) -{ - WINDOW *win = reinterpret_cast(mwin); - char *subj = strdup(msg->getSubj()); - for (unsigned j=0; jgetNum(), subj); + ed->errormsg("No destination address specified"); + return false; } - - for (int i=0; i xpos) - sprintf(s, "%-*.*s", xsize-3, xsize-3, &(line[i+pos][xpos])); - else - sprintf(s, "%-*.*s", xsize-3, xsize-3, ""); - if (s[strlen(s)-1] == '\n') s[strlen(s)-1] = '\0'; - for (unsigned j=0; jerrormsg("No subject specified"); + return false; } - wnoutrefresh(win); - for (int i = 0; i < 5; i++) doupdate(); //must be done many times, don't know why - delete[] subj; -} -void TheFile::handle_event(Event *ev) -{ - if (ev == NULL) - { - if (wait_sname) - { - wait_sname = false; - char *name = save_file_path(ibuffer); - FILE *f = fopen(name, "w"); - if (f != NULL) - { - for (unsigned i = 0; i < line.size(); i++) - { - fputs(line[i], f); - fputc('\n', f); - } - fclose(f); - errormsg("Message saved to %s", name); - } else errormsg("Cannot create %s", name); - delete[] name; - } - if (wait_xnum) - { - wait_xnum = false; - int atnum; - if (attach > 1) atnum = atoi(ibuffer); //more attachments - else atnum = 1; //only one - extract_attach(atnum); + //open the index + OutgoingIndex ndx(home_call); + //get message number + msgnum = ndx.newIndex(); + + if (ttabnum > -1) load_table(ttabnum); + //translate subject + for (unsigned i = 0; i < strlen(subj); i++) + if (subj[i] < ttabsize) subj[i] = ttable[subj[i]]; + + //get source callsign + char *mycall = strdup(call_call(lp_chn_call(lp_channel()))); + //!!!alokace from??? + if (from) delete[] from; + from = new char[strlen(mycall)+strlen(home_addr)+2]; + sprintf(from, "%s@%s", mycall, home_addr); + //complete destination callsign if no destination specified + if (strchr(to, '@') == NULL) + { + strcat(to, "@"); + strcat(to, home_addr); + } + strupr(to); + strupr(from); + + //create message file + char *fname = strdup("/tmp/lp_mail.XXXXXX"); + int tmpdesc = mkstemp(fname); close(tmpdesc); + FILE *f = fopen(fname, "w"); + if (f == NULL) + { + ed->errormsg("Cannot create temp file"); + beep(); + return false; + } + fprintf(f, "%s\n", subj); + + //write header + char date[256]; + sprintf(date, "%02i%02i%02i/%02i%02i", (tim->tm_year+1900)%100, + tim->tm_mon+1, tim->tm_mday, tim->tm_hour, tim->tm_min); + #ifdef PATH_TO_OWN + fprintf(f, "R:%sZ @:%s.\n", date, mycall); + fprintf(f, "\n"); + fprintf(f, "From: %s\n", from); + fprintf(f, "To: %s\n", to); + fprintf(f, "\n"); + #endif + + //write message body + for (int i=0; i < ed->max; i++) + { + char s[LINE_LEN+1]; + ed->line[i].get_text(s); + + if (ed->line[i].editable) + { + for (unsigned i = 0; i < strlen(s); i++) + if (s[i] < ttabsize) s[i] = ttable[s[i]]; + fprintf(f, "%s\n", s); } - return; } - if (ev->type == EV_KEY_PRESS) + + size = ftell(f); + fclose(f); + char *body = NULL; + f = fopen(fname, "r"); + if (f) + { + body = new char[size+1]; + int n = fread(body, 1, size, f); + body[n] = '\0'; + fclose(f); + close(tmpdesc); + } + else { - clear_error(); - if (wait_reply) //waiting for a reply for if to insert original message - { - int ch = toupper(ev->x); - if (ch == 'Y' || ch == 'N') - { - //create new subject with Re: or Re^x: - char *resubj = new char[strlen(msg->getSubj())+10]; - char *p = msg->getSubj(); while (*p && isspace(*p)) p++; - if (strncasecmp(p, "RE", 2) == 0) - { - p += 2; - while (*p && isspace(*p)) p++; - if (*p == ':') sprintf(resubj, "Re^2:%s", p+1); - else if (*p == '^') - { - char *endptr; - p++; - int n = strtol(p, &endptr, 10); - sprintf(resubj, "Re^%i%s", n+1, endptr); - } - else sprintf(resubj, "Re:%s", msg->getSubj()); - } - else sprintf(resubj, "Re:%s", msg->getSubj()); - - //determine reply address - char reply_addr[50]; - if (!comment) - { - if (!return_addr(reply_addr)) - strcpy(reply_addr, msg->getSrc()); - } - else - { - if (*(msg->getDPath()) == '@') - snprintf(reply_addr, 49, "%s%s", msg->getDest(), msg->getDPath()); - else - snprintf(reply_addr, 49, "%s@", msg->getDest()); - reply_addr[49] = '\0'; - //strcpy(reply_addr, msg->getDest()); - } - - strcpy(old_help, HELP_VIEW); - start_composer(mwin, x, y, x+xsize-1, y+ysize-1, reply_addr, resubj); - if (ch == 'Y') - { - unsigned i, j; - bool hdr = false; - - //find first line of the message - j = 0; - for (i = 0; i < line.size(); i++) - { - if (strncmp("R:", line[i], 2) == 0) j = i; - if (strncmp("From:", line[i], 5) == 0) hdr = true; - if (hdr && strlen(line[i]) == 0) {j = i; break;} - } - - //insert the lines - for (i = j; i < line.size(); i++) - { - //convert charset - char *newl = strdup(line[i]); - for (unsigned u=0; ux == KEY_DOWN) - { - if (pos < line.size()-ysize+3) pos++; - } - if (ev->x == KEY_UP) - { - if (pos > 0) pos--; - } - if (ev->x == KEY_RIGHT) - { - if (xpos < max_len()-xsize+4) xpos++; - } - if (ev->x == KEY_LEFT) - { - if (xpos > 0) xpos--; - } - if (ev->x == KEY_NPAGE || ev->x == ' ') - { - for (int j=0; j < (ysize-3); j++) - if (pos < line.size()-ysize+3) pos++; - } - if (ev->x == KEY_PPAGE) - { - for (int j=0; j < (ysize-3); j++) - if (pos > 0) pos--; - } - - if (toupper(ev->x) == 'H') - { - head = !head; - load_message(head); - } - - if (toupper(ev->x) == 'W') - { - wrap = !wrap; - load_message(head); - } - - if (toupper(ev->x) == 'T') - { - atable++; - if (atable >= ntables) atable = 0; - load_table(atable); - draw(); - } + ed->errormsg("Cannot create temp file"); + beep(); + return false; + } + unlink(fname); + free(fname); + + //create MID + sprintf(mid, "%06i%s", msgnum, mycall); + while (strlen(mid) < 12) strcat(mid, "0"); + + //add to index + Message newmsg(msgnum, + type=='P'?"PO":"BO", + mid, from, to, date, subj); + newmsg.setBody(body); + ndx.addMessage(newmsg); + ndx.writeIndex(); + delete[] body; + + //scan for inserted commands + for (int i=0; i < ed->max; i++) + { + char s[LINE_LEN+1]; + ed->line[i].get_text(s); - if (toupper(ev->x) == 'Q') + if (!ed->line[i].editable && s[0] == '.') { - focused = NULL; //exit immediatelly - } + char cmd[LINE_LEN+1]; + char par[LINE_LEN+1]; + sscanf(s+1, "%s %s", cmd, par); - if (toupper(ev->x) == 'R') - { - WINDOW *win = (WINDOW *)mwin; - wbkgdset(win, ' ' | COLOR_PAIR(C_ERROR)); - mvwprintw(win, ysize-2, 1, " Include original message in reply ? "); - wmove(win, ysize-2, 38); - wbkgdset(win, ' ' | COLOR_PAIR(C_MSG)); - wrefresh(win); - wait_reply = true; - comment = false; - } - else if (toupper(ev->x) == 'C') - { - WINDOW *win = (WINDOW *)mwin; - wbkgdset(win, ' ' | COLOR_PAIR(C_ERROR)); - mvwprintw(win, ysize-2, 1, " Include original message in comment ? "); - wmove(win, ysize-2, 39); - wbkgdset(win, ' ' | COLOR_PAIR(C_MSG)); - wrefresh(win); - wait_reply = true; - comment = true; - } - else if (toupper(ev->x) == 'F') - { - strcpy(old_help, HELP_VIEW); - char *dest = new char[strlen(msg->getDest()) + - strlen(msg->getDPath()) + 2]; - sprintf(dest, "%s%s", msg->getDest(), msg->getDPath()); - start_composer(mwin, x, y, x+xsize-1, y+ysize-1, - dest, msg->getSubj()); - delete[] dest; - - //Copy original contents - unsigned i, j; - bool hdr = false; - //find first line of the message - j = 0; - for (i = 0; i < line.size(); i++) - { - if (strncmp("R:", line[i], 2) == 0) j = i; - if (strncmp("From:", line[i], 5) == 0) hdr = true; - if (hdr && strlen(line[i]) == 0) {j = i; break;} - } - //insert the lines - for (i = j; i < line.size(); i++) + if (strcmp(cmd, "attach") == 0) { - //convert charset - char *newl = strdup(line[i]); - for (unsigned u=0; ux == '\x1b' || toupper(ev->x) == 'L' || - toupper(ev->x) == 'I' || ev->x == '<') - { - view_returned = true; - focus_window = old_focus_window; - focused = old_focused; - focused->draw(true); - help(HELP_LIST); - destroy_message(); } - else if (toupper(ev->x) == 'S') - { - wait_sname = true; - WINDOW *win = (WINDOW *)mwin; - iline = new InputLine(win, 2, ysize-1, xsize-2, xsize-16, - "Save to file:", ibuffer, INPUT_ALL); - } - else if (toupper(ev->x) == 'X') + } + delete[] mycall; + return true; +} + +void Composer::load_table(int n) +{ + FILE *f; + + if (n < ntables) + { + f = fopen(tables[n], "r"); + if (f == NULL) { - if (attach > 1) //more than one attachment - { - wait_xnum = true; - WINDOW *win = (WINDOW *)mwin; - iline = new InputLine(win, 2, ysize-1, xsize-2, 5, - "Attachment no. to save:", ibuffer, INPUT_NUM); - } - else if (attach == 1) extract_attach(1); - else errormsg("No attachments"); + fprintf(stderr, "Cannot load translation table\n"); + beep(); + return; } - else draw(); + fseek(f, 0, SEEK_END); + long size = ftell(f); + fseek(f, size/2, SEEK_SET); + ttabsize = fread(ttable, 1, 256, f); + fclose(f); } } -void TheFile::errormsg(const char *fmt, ...) +void Composer::check_dest() { - va_list argptr; - char buf[256]; - - va_start(argptr, fmt); - vsprintf(buf, fmt, argptr); - va_end(argptr); - - WINDOW *win = (WINDOW *)mwin; - wbkgdset(win, ' ' | COLOR_PAIR(C_ERROR)); - mvwprintw(win, ysize-2, 1, " %s ", buf); - wbkgdset(win, ' ' | COLOR_PAIR(ED_TEXT)); - err = true; - //wrefresh(win); - wnoutrefresh(win); - for (int i = 0; i < 5; i++) doupdate(); //must be done many times, don't know why + strupr(to); + if (!contains_digit(to)) type = 'B'; + if (strchr(to, '@') == NULL) + { + char route[256]; + if (find_route(to, route)) + { + strcat(to, "@"); + strcat(to, route); + } + strupr(to); + } } -void TheFile::clear_error() +void Composer::insert(char *s, bool quote) { - if (err) draw(true); + char ln[LINE_LEN+1]; + char *p = s; + + unsigned limit; + if (quote) + limit = x2-x1-5 < LINE_LEN-2 ? x2-x1-5 : LINE_LEN-2; + else + limit = x2-x1-5 < LINE_LEN ? x2-x1-5 : LINE_LEN; + + while (strlen(p) > limit) + { + char *q = p + limit; + while (q > p && !isspace(*q)) q--; + *q = '\0'; + if (quote) sprintf(ln, "> %s", p); + else strcpy(ln, p); + ed->ins_info(ln); + p = q+1; + } + + if (strlen(p) > 0) + { + if (quote) sprintf(ln, "> %s", p); + else strcpy(ln, p); + ed->ins_info(ln); + } } --- src/applications/mailer/mail_route.cc.orig 2013-08-21 16:53:35.189661964 -0700 +++ src/applications/mailer/mail_route.cc 2013-08-21 16:54:22.631029416 -0700 @@ -10,7 +10,7 @@ mail_route.h - mail routes database */ #include -#include +#include #include #include #include @@ -56,7 +56,7 @@ } -vector routes; +std::vector routes; //----------------------------------------------------------------------- @@ -93,8 +93,8 @@ bool find_route(char *call, char *result) { - vector cands; - vector ::iterator it, home; + std::vector cands; + std::vector ::iterator it, home; bool found = false; //select candidates --- src/data.h.orig 2013-08-21 16:58:38.950007529 -0700 +++ src/data.h 2013-08-21 16:58:15.455826709 -0700 @@ -16,7 +16,7 @@ #ifndef DATA_H #define DATA_H -#include +#include #include "constants.h" #include "version.h" #include "event.h" @@ -145,7 +145,7 @@ operator char*(); }; -extern vector aclist[MAX_CHN+1]; +extern std::vector aclist[MAX_CHN+1]; //------------------------------------------------------------------------ // Miscelancelous data @@ -227,7 +227,7 @@ class Cooker : public Object { private: - vector tasks; + std::vector tasks; int newhandle; char expr[256]; char lastline[MAX_CHN+1][256]; //last line received (for %< macro) --- src/data.cc.orig 2013-08-21 16:58:46.750067540 -0700 +++ src/data.cc 2013-08-21 17:05:02.221944006 -0700 @@ -17,8 +17,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -311,7 +313,7 @@ return name; } -vector aclist[MAX_CHN+1]; +std::vector aclist[MAX_CHN+1]; //Misc @@ -763,7 +765,7 @@ } if (ev.type == EV_CMD_RESULT) { - vector ::iterator it; + std::vector ::iterator it; for (it = tasks.begin(); it < tasks.end(); it++) if ((*it)->handle == ev.x) break; if (it < tasks.end()) @@ -795,7 +797,7 @@ Cooker::~Cooker() { - vector ::iterator it; + std::vector ::iterator it; for (it = tasks.begin(); it < tasks.end(); it++) { delete (*it)->args; --- src/event.h.orig 2013-08-21 17:00:44.278970483 -0700 +++ src/event.h 2013-08-21 17:01:03.326116592 -0700 @@ -18,7 +18,7 @@ #define OWN_DATA -#include +#include #include "tevent.h" //------------------------------------------------------------------------- @@ -39,8 +39,8 @@ { private: unsigned next_oid; //next free object id - vector children; //list of inserted objects - vector active; //active objects (receive events) + std::vector children; //list of inserted objects + std::vector active; //active objects (receive events) public: bool quit; --- src/event.cc.orig 2013-08-21 17:01:21.886258907 -0700 +++ src/event.cc 2013-08-21 17:02:24.876741470 -0700 @@ -98,7 +98,7 @@ void Obj_man::find_oid() { - vector ::iterator it; + std::vector ::iterator it; unsigned old_value = next_oid; bool ok; do @@ -122,7 +122,7 @@ void Obj_man::remove(Object *obj) { - vector ::iterator it; + std::vector ::iterator it; //Remove from object list for (it=children.begin(); it < children.end(); it++) if (*it==obj) break; if (it != children.end()) @@ -141,7 +141,7 @@ void Obj_man::remove(unsigned aoid) { - vector ::iterator it; + std::vector ::iterator it; //Remove from object list for (it=children.begin(); it < children.end(); it++) if ((*it)->oid == aoid) break; @@ -294,7 +294,7 @@ void Obj_man::stop() { - vector ::iterator it; + std::vector ::iterator it; for (it=children.begin(); it < children.end(); it++) delete *it; children.erase(children.begin(), children.end()); @@ -313,7 +313,7 @@ #endif #endif fprintf(stderr, " oid class_name\n"); - vector ::iterator it; + std::vector ::iterator it; for (it=children.begin(); it < children.end(); it++) { fprintf(stderr, "%5i %s\n", (*it)->oid, (*it)->class_name); @@ -323,7 +323,7 @@ void Obj_man::deactivate(char *obj_name) { - vector ::iterator it; + std::vector ::iterator it; //Remove from active objects for (it=active.begin(); it < active.end(); it++) if (strcmp((*it)->class_name, obj_name) == 0) break; @@ -336,7 +336,7 @@ void Obj_man::activate(char *obj_name) { - vector ::iterator objs, act; + std::vector ::iterator objs, act; //Find the right position for an object in active objects act = active.begin(); for (objs = children.begin(); --- src/sources.h.orig 2013-08-21 17:05:58.446372739 -0700 +++ src/sources.h 2013-08-21 17:08:22.380468028 -0700 @@ -126,8 +126,8 @@ int sock; char data[MAX_EVENT_DATA]; int pid; //what PID is this gate for ? (0 = base gate) - vector *pids; - vector children; //sockets of child gates + std::vector *pids; + std::vector children; //sockets of child gates fd_set rfds; //child descriptors int maxdesc; //maximal descriptor value EventGate *parent_gate; //parent gate @@ -165,7 +165,7 @@ bool parse_event_cmd(); public: - EventGate(int socknum, EventGate *parent = NULL, vector *ppids = NULL); + EventGate(int socknum, EventGate *parent = NULL, std::vector *ppids = NULL); virtual ~EventGate(); virtual void handle_event(const Event &); --- src/sources.cc.orig 2013-08-21 17:06:55.845809916 -0700 +++ src/sources.cc 2013-08-21 17:07:36.472119031 -0700 @@ -922,7 +922,7 @@ //-------------------------------------------------------------------------- // Class EventGate //-------------------------------------------------------------------------- -EventGate::EventGate(int socknum, EventGate *parent, vector *ppids) +EventGate::EventGate(int socknum, EventGate *parent, std::vector *ppids) { sprintf(class_name, "EventGt?"); rbuff = NULL; @@ -944,7 +944,7 @@ if (socknum == 0) { pid = 0; //we are the base gate - pids = new vector; + pids = new std::vector; sock = socket(AF_INET, SOCK_STREAM, 0); if (sock == -1) Error(errno, "EventGate: cannot create socket"); @@ -1291,7 +1291,7 @@ bool fnd = false; bool cont = true; - vector ::iterator it; + std::vector ::iterator it; for (it = pids->begin(); it < pids->end(); it++) if (it->pid == ev.x) { @@ -1420,7 +1420,7 @@ if (rc>0) { if (FD_ISSET(sock, &rdset)) data_arrived(); - vector ::iterator it; + std::vector ::iterator it; for (it = children.begin(); it < children.end(); it++) if (FD_ISSET((*it)->get_sock(), &rdset)) (*it)->data_arrived(); @@ -1474,7 +1474,7 @@ } //check waiting gates - vector ::iterator it; + std::vector ::iterator it; for (it = pids->begin(); it < pids->end(); it++) if (it->gate && time(NULL) > it->started + MAX_GATE_WAIT) { //waiting too long - application probably won't start @@ -1497,7 +1497,7 @@ if (ev.type == EV_PROCESS_FINISHED && pid == 0) { //remove the application entry from PID list - vector ::iterator it; + std::vector ::iterator it; for (it = pids->begin(); it < pids->end(); it++) if (it->pid == ev.x) {pids->erase(it); break;} } @@ -1604,7 +1604,7 @@ void EventGate::child_finished(EventGate *child) { - vector ::iterator it; + std::vector ::iterator it; maxdesc = 0; for (it = children.begin(); it < children.end(); it++) if (*it == child) @@ -1618,7 +1618,7 @@ void EventGate::change_child(EventGate *from, EventGate *to) { - vector ::iterator it; + std::vector ::iterator it; maxdesc = 0; for (it = children.begin(); it < children.end(); it++) if (*it == from) --- src/watch.h.orig 2013-08-21 17:11:38.812041696 -0700 +++ src/watch.h 2013-08-21 17:11:57.366194122 -0700 @@ -18,7 +18,7 @@ #define WATCH_BUFFER_SIZE 1024 -#include +#include #include "event.h" #include "constants.h" @@ -32,7 +32,7 @@ class Watch : public Object { private: - vector watch; //list of autorun entries + std::vector watch; //list of autorun entries char buf[MAX_CHN+1][WATCH_BUFFER_SIZE]; int buflen[MAX_CHN+1]; bool disabled[MAX_CHN+1]; //watching is disabled (binary transfer) --- src/watch.cc.orig 2013-08-21 17:12:17.672360865 -0700 +++ src/watch.cc 2013-08-21 17:12:30.502466177 -0700 @@ -55,7 +55,7 @@ buflen[ev.chn]++; } //try to find all keys in bufer - vector ::iterator it; + std::vector ::iterator it; for (it = watch.begin(); it < watch.end(); it++) { if ((it->chn == ev.chn || it->chn == 0) && key_found(ev.chn, it->key)) --- src/commands.h.orig 2013-08-21 17:13:06.064757913 -0700 +++ src/commands.h 2013-08-21 17:13:30.221955948 -0700 @@ -13,7 +13,7 @@ Last update 24.6.2002 =========================================================================*/ -#include +#include #include "event.h" #include "sources.h" #include "data.h" @@ -38,7 +38,7 @@ int chn; int pos; //line position int max; //number of lines - vector prg; //lines + std::vector prg; //lines char s[256]; Arguments args; //for sending arguments of macro bool macro; //translating from 'macro' notation @@ -56,7 +56,7 @@ void index_conds(); //index conditions int compare(const char *s1, const char *s2); //compare strings or numbers bool true_condition(char *s); //return true, when condition is true - void clear_prg(vector &); //clear prg structure + void clear_prg(std::vector &); //clear prg structure virtual ~Macro(); }; @@ -72,10 +72,10 @@ bool secure; //command from secure source - do not check permissions bool send_res; //result must be sent back bool remote_disabled[MAX_CHN+1]; //remote commands are disabled due to binary transfer - vector reg; //registered commands handled by ext. application - vector bin; //commands found in ./bin - vector mac; //commands found in ./macro (default language) - vector lmac; //macro commands for selected language + std::vector reg; //registered commands handled by ext. application + std::vector bin; //commands found in ./bin + std::vector mac; //commands found in ./macro (default language) + std::vector lmac; //macro commands for selected language ExternCmd *ext; Macro *mcm; int res_hnd; //result handle (when send_res == true) 227c227 < vector ::iterator it; --- > std::vector ::iterator it; 245c245 < vector ::iterator it; --- > std::vector ::iterator it; 348c348 < vector ::iterator it; --- > std::vector ::iterator it; 926c926 < vector ::iterator it; --- > std::vector ::iterator it; 969c969 < vector ::iterator it; --- > std::vector ::iterator it; 988c988 < vector ::iterator it; --- > std::vector ::iterator it; 1018c1018 < vector ::iterator it; --- > std::vector ::iterator it; 1254c1254 < vector ::iterator it; --- > std::vector ::iterator it; 1378c1378 < vector ::iterator it; --- > std::vector ::iterator it; 1485,1486c1485,1486 < vector ::iterator it; < vector newprg; --- > std::vector ::iterator it; > std::vector newprg; 1647c1647 < void Macro::clear_prg(vector &prg) --- > void Macro::clear_prg(std::vector &prg) 1649c1649 < vector ::iterator it; --- > std::vector ::iterator it; --- src/screen.h.orig 2013-08-21 17:15:26.950911305 -0700 +++ src/screen.h 2013-08-21 17:15:46.010067051 -0700 @@ -17,7 +17,7 @@ #ifndef SCREEN_H #define SCREEN_H -#include +#include #include #include "event.h" #include "constants.h" @@ -41,7 +41,7 @@ { private: WINDOW *mainwin; - vector children; //list of inserted objects + std::vector children; //list of inserted objects public: Screen(); --- src/screen.cc.orig 2013-08-21 17:16:13.263289639 -0700 +++ src/screen.cc 2013-08-21 17:16:27.150403009 -0700 @@ -39,7 +39,7 @@ void Screen::redraw() { - vector ::iterator it; + std::vector ::iterator it; for (it=children.begin(); itdraw(); } --- src/windows.h.orig 2013-08-21 17:16:54.967629992 -0700 +++ src/windows.h 2013-08-21 17:24:17.311221164 -0700 @@ -6,11 +6,11 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the license, or (at your option) any later version. - + windows.h - + This module contains objects for terminal output windows - + Last update 29.10.2001 =========================================================================*/ #ifndef WINDOWS_H @@ -19,6 +19,7 @@ #include "infoline.h" #include #include +#include #include "screen.h" #include "constants.h" @@ -212,7 +213,7 @@ { private: WINDOW *win; - vector lines; + std::vector lines; int nlines; int mychn; bool act; --- src/windows.cc.orig 2013-08-21 17:17:39.774995318 -0700 +++ src/windows.cc 2013-08-21 17:20:52.079559173 -0700 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -1349,7 +1350,7 @@ void StatLines::handle_event(const Event &ev) { - vector ::iterator it; + std::vector ::iterator it; switch(ev.type) { --- src/infoline.h.orig 2013-08-21 17:18:35.465448873 -0700 +++ src/infoline.h 2013-08-21 17:19:03.911680332 -0700 @@ -13,7 +13,7 @@ Last update 19.9.1998 =========================================================================*/ -#include +#include class info_line { @@ -27,4 +27,4 @@ //This fixes the stupid ncurses 'erase' macro that overrides all //vector::erase() functions -void info_line_erase(vector &v, vector ::iterator it); +void info_line_erase(std::vector &v, std::vector ::iterator it); --- src/infoline.cc.orig 2013-08-21 17:19:16.262780786 -0700 +++ src/infoline.cc 2013-08-21 17:19:38.341960292 -0700 @@ -15,7 +15,7 @@ =========================================================================*/ #include "infoline.h" -void info_line_erase(vector &v, vector ::iterator it) +void info_line_erase(std::vector &v, std::vector ::iterator it) { v.erase(it); } --- src/editor.cc.orig 2013-08-21 17:25:20.199729050 -0700 +++ src/editor.cc 2013-08-21 17:25:53.207995370 -0700 @@ -6,14 +6,14 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the license, or (at your option) any later version. - + editor.cc - + Text/command editor objects - + Last update 29.1.2001 =========================================================================*/ -#include +#include #include #include "constants.h" --- src/keyboard.cc.orig 2013-08-21 17:26:53.281479615 -0700 +++ src/keyboard.cc 2013-08-21 17:39:11.449386066 -0700 @@ -20,6 +20,7 @@ #include "keyboard.h" #include +#include //-------------------------------------------------------------------------- // Class Keyscan @@ -46,7 +47,7 @@ { int ch = wgetch(reinterpret_cast(keywin)); //int ch = getch(); - cout.flush(); + std::cout.flush(); if (ch != ERR) { Event re;