1 
2 //  ------------------------------------------------------------------
3 //  GoldED+
4 //  Copyright (C) 1990-1999 Odinn Sorensen
5 //  Copyright (C) 1999-2000 Alexander S. Aganichev
6 //  ------------------------------------------------------------------
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License as
9 //  published by the Free Software Foundation; either version 2 of the
10 //  License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 //  General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 //  MA 02111-1307 USA
21 //  ------------------------------------------------------------------
22 //  $Id: geprot.h,v 1.55 2008/01/20 14:45:51 stas_degteff Exp $
23 //  ------------------------------------------------------------------
24 //  Collective header for GE*.CPP source files.
25 //  ------------------------------------------------------------------
26 
27 
28 #ifndef __GEPROT_H
29 #define __GEPROT_H
30 
31 #include "gekeys.h"
32 
33 //  ------------------------------------------------------------------
34 //  GCAREA prototypes
35 
36 void FixEchoid(char* echoid, int type);
37 
38 
39 //  ------------------------------------------------------------------
40 //  GCCFGG prototypes
41 
42 void CfgAddress(char* value);
43 void CfgAddressmacro(char* value);
44 void CfgEvent(char* value);
45 void CfgFrqext(const char* value);
46 void CfgRobotname(const char* value);
47 void CfgUsername(char* value);
48 
49 int SwitchCfgAtoG(word crc, char* val);
50 int SwitchCfgHtoZ(word crc, char* val);
51 
52 int ReadGoldCfg(int force);
53 bool ReadGoldedCfg(int& force);
54 void WriteGoldGed();
55 
56 void InstallDetect(char* path);
57 int InstallFinish();
58 
59 int getgroup(const char *key);
60 
61 
62 //  ------------------------------------------------------------------
63 //  GCKEYS prototypes
64 
65 int ReadKeysCfg(int force);
66 void KeyCmdAdd(gkey cmd, gkey val, int type);
67 void RunMacro(Macro* m);
68 
69 
70 //  ------------------------------------------------------------------
71 //  GCLANG prototypes
72 
73 void LangInit();
74 bool ReadLangCfg(int force);
75 void LoadLanguage(const char* file);
76 
77 
78 //  ------------------------------------------------------------------
79 //  GCMISC prototypes
80 
81 int   ReadHelpCfg(int force);
82 vattr GetColor(char* ink);
83 vattr MakeColor(char* colors);
84 void  GetColors(char* value);
85 void  ReadXlatTables();
86 
87 
88 //  ------------------------------------------------------------------
89 //  GEAREA prototypes
90 
91 int AreaPick(char* title, int wpos, int* idx);
92 void a_closeall();
93 void GetAreaconf();
94 
95 
96 //  ------------------------------------------------------------------
97 //  GECTRL prototypes
98 
99 char* MakeOrigin(GMsg* msg, const char* _origin);
100 char* MakeTearline(GMsg* msg, char* buf);
101 void DoKludges(int mode, GMsg* msg, int kludges = 0);
102 void DoTearorig(int mode, GMsg* msg);
103 void GetRandom(int mode, GMsg* msg);
104 char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file);
105 char* HandleRandomLine(char* buf, size_t bufsize);
106 const char* get_informative_string(void);
107 char* mime_header_encode(char* dest, const char* source, GMsg* msg);
108 
109 
110 //  ------------------------------------------------------------------
111 //  GEDOIT prototypes
112 
113 void CmfMsgs(GMsg* msg, bool torecycle);
114 void LoadText(GMsg* msg, const char* textfile);
115 void SaveLines(int mode, const char* savefile, GMsg* msg, int margin, bool clip=false);
116 
117 
118 //  ------------------------------------------------------------------
119 //  GEDOSS prototypes
120 
121 void Cleanup(void);
122 int ShellToDos(const char* command, char* message, vattr cls, int cursor, int pause=NO);
123 
124 
125 //  ------------------------------------------------------------------
126 //  GEEDIT prototypes
127 
128 int EditMsg(int mode, uint* position, GMsg* msg);
129 void FreePastebuf();
130 
131 
132 //  ------------------------------------------------------------------
133 //  GEFILE prototypes
134 
135 void CreateFileAddr(GMsg* msg);
136 void CreateFileMsgs(int mode, GMsg* msg);
137 void FileSelect(GMsg* msg, char* title, FileSpec* fspec);
138 
139 
140 //  ------------------------------------------------------------------
141 //  GEFIND prototypes
142 
143 bool FindString(GMsg* msg, const char* prompt, int what);
144 void FindAll(GMsg* msg, int& topline, int& keyok);
145 void FindHdr(GMsg* msg, int& topline, int& keyok);
146 bool SearchHighlight(const Line* line, int row, int width, vattr highlight_color);
147 void SearchExit();
148 void AdvancedSearch(GMsg* msg, int& topline, int& keyok);
149 
150 
151 //  ------------------------------------------------------------------
152 //  GEGLOB prototypes
153 
154 void CfgInit();
155 void CfgInit2();
156 void CfgReset(void);
157 int PlayMacro(gkey key, int type);
158 int IsMacro(gkey key, int type);
159 
160 
161 //  ------------------------------------------------------------------
162 //  GEINIT prototypes
163 
164 void Uninitialize();
165 void Initialize(int argc, char* argv[]);
166 
167 
168 //  ------------------------------------------------------------------
169 //  GELINE prototypes
170 
171 char *Latin2ISO(char *iso_encoding, const char *latin_encoding);
172 char *ISO2Latin(char *latin_encoding, const char *iso_encoding);
173 char *MakeQuotedPrintable(const char *encoding);
174 char *ExtractPlainCharset(const char *encoding);
175 bool  IsQuotedPrintable(const char *encoding);
176 int   LoadCharset(const char* imp, const char* exp, int query = 0);
177 Line* AddKludge(Line* line, char* buf, int where=DIR_BELOW);
178 Line* AddLineFast(Line* line, char* text);
179 Line* DeleteLine(Line* line);
180 Line* FirstLine(Line* line);
181 Line* InsertLine(Line* newline, Line* oldline, int pos);
182 Line* LastLine(Line* line);
183 void  MakeLineIndex(GMsg* msg, int rmargin, bool getvalue, bool header_recode);
184 void  MsgLineReIndex(GMsg* msg, int viewhidden=-1, int viewkludge=-1, int viewquote=-1);
185 void  Latin2Local(char *str);
186 void  Latin2Local(std::string &str);
187 char* XlatStr(char* dest, const char* src, int level, Chs* chrtbl, int qpencoded=false, bool i51=false);
188 char* mime_header_decode(char* decoded, const char* encoded, char* charset = NULL);
189 char* strxmimecpy(char* dest, const char* source, int level, int size, bool detect = false);
190 void InvalidateControlInfo(GMsg *msg);
191 #ifdef HAS_ICONV
192 void IconvClear(void);
193 #endif
194 
195 
196 //  ------------------------------------------------------------------
197 //  GEMENU prototypes
198 
199 void DispHeadAttrs(GMsg* msg);
200 void AskAttributes(GMsg* msg);
201 bool ProcessAttrs(gkey &key);
202 void ChgAttrs(int mode, GMsg* msg);
203 int ChangeAka();
204 int ChangeCharsIn();
205 int ChangeCharsOut();
206 int ChangeTagline();
207 int ChangeOrigin();
208 int ChangeTemplate();
209 int ChangeUsername();
210 int ChangeXlatImport();
211 
212 
213 //  ------------------------------------------------------------------
214 //  GEMSGS prototypes
215 
216 void TokenXlat(int mode, std::string &input, GMsg* msg, GMsg* oldmsg, int origarea);
217 void TokenXlat(int mode, char *&input, size_t size, bool resize, GMsg* msg, GMsg* oldmsg, int origarea);
TokenXlat(int mode,char * input,size_t size,GMsg * msg,GMsg * oldmsg,int origarea)218 inline void TokenXlat(int mode, char *input, size_t size, GMsg* msg, GMsg* oldmsg, int origarea)
219 { TokenXlat(mode, input, size, false, msg, oldmsg, origarea); }
220 
221 void Rot13(GMsg* msg);
222 void ResetMsg(GMsg* msg);
223 int DoCarboncopy(GMsg* msg, GMsg** carbon);
224 void DoCrosspost(GMsg* msg, std::vector<int> &postareas);
225 char* ParseInternetAddr(char* __string, char* __name, char* __addr, bool detect_charset = true);
226 
227 
228 //  ------------------------------------------------------------------
229 //  GEMLST prototypes
230 
231 void MsgThreadlist();
232 
233 //  ------------------------------------------------------------------
234 
235 class ThreadEntry
236 {
237 public:
238   uint32_t msgno;
239   uint32_t replyto;
240   uint32_t reply1st;
241   uint32_t replynext;
242   uint32_t replytoindex;
243   uint32_t level;
244   std::string entrytext;
245 };
246 
247 //  ------------------------------------------------------------------
248 
249 class GThreadlist : public gwinpick
250 {
251 private:
252   gwindow     window;
253   GMsg        msg;
254 
255   std::vector<ThreadEntry>  treeEntryList;
256 
257   dword m_OldMsgno;
258   uint m_OldTags;
259   std::string m_OldEchoId;
260 
261   void BuildThreadIndex(dword msgno);
262   void recursive_build(uint32_t msgn, uint32_t rn, uint32_t level, uint32_t index);
263   void GenTree(int idx);
264   void update_title();
265   bool NextThread(bool next);
266 
267 public:
268   void open();                        // Called after window is opened
269   void close();                       // Called after window is closed
270   void print_line(uint idx, uint pos, bool isbar);
271   void do_delayed();
272   bool handle_key();                  // Handles keypress
273 
274   void Run();
275   bool GoNextUnread(bool reader);
276 
GThreadlist()277   GThreadlist()
278   {
279     m_OldMsgno = dword(-1);
280     m_OldTags = uint(-1);
281 
282     memset(&msg, 0, sizeof(GMsg));
283     replylinkfloat = CFG->replylinkfloat;
284   }
285 
~GThreadlist()286   ~GThreadlist() { ResetMsg(&msg); }
287 };
288 
289 
290 //  ------------------------------------------------------------------
291 //  GEMRKS prototypes
292 
293 void MarkMsgs(GMsg* msg);
294 int NextMarkedmsg(int direction, GMsg* msg);
295 
296 
297 //  ------------------------------------------------------------------
298 //  GENODE prototypes
299 
300 void Lookup(GMsg* msg, ftn_addr* addr, char* name, int topline, char* status);
301 bool Lookup2(Addr& addr, char* name, int topline, const char* status);
302 
303 const char *lookup_nodelist(ftn_addr* addr);
304 
305 void LookupNodeLocation(GMsg* msg, std::string &location, int what);
306 void LookupNode(GMsg* msg, const char* name, int what);
307 void LookupNodeClear();
308 void CheckNodelists();
309 
310 
311 //  ------------------------------------------------------------------
312 //  GEPLAY prototypes
313 
314 void InitSound();
315 void FileToGPlay(GPlay* playbuf, char* filename);
316 int HandleGEvent(uint event);
317 int MakeNoise(int type);
318 void SayBibi();
319 
320 
321 //  ------------------------------------------------------------------
322 //  GEHDRE prototypes
323 
324 typedef struct {
325   char *buf;
326   bool update;
327 } gsetaddr;
328 
329 bool set_to_address(GMsg* msg, gsetaddr* toname, gsetaddr* toaddr, gsetaddr* fromaddr, gsetaddr* subj, int pos, char* lng_lookup, bool lookup=true);
330 
331 
332 //  ------------------------------------------------------------------
333 //  GEPOST prototypes
334 
335 void MakeMsg(int mode, GMsg* oldmsg, bool ignore_replyto=false);
336 int EditHeaderinfo(int mode, GMsgHeaderView &view, bool doedithdr = true);
337 void CheckSubject(GMsg* msg, char* subj);
338 
339 
340 //  ------------------------------------------------------------------
341 //  GEQWKS prototypes
342 
343 int ImportQWK();
344 int ExportQWK();
345 
346 
347 //  ------------------------------------------------------------------
348 //  GEREAD prototypes
349 
350 char* GetCurrQuotebuf(char* quotebuf);
351 int MsgIsTwit(GMsg* msg, bool& istwitto, bool& istwitsubj);
352 uint32_t MsgHasReplies(GMsg* msg);
353 gkey ViewMessage(int istwit=NOT_TWIT);
354 int LoadMessage(GMsg* msg, int margin);
355 void LoadRawMsg(GMsg* msg, int margin);
356 
357 void make_pathreport(char* reportfile);
358 void NextArea();
359 void PrevArea();
360 void Reader();
361 void UpdateArea(GMsg* msg);
362 int ExternUtil(GMsg* msg, uint32_t utilno);
363 void ExternUtilMenu(GMsg* msg);
364 void ReadPeekURLs(GMsg* msg);
365 uint next_msg(int direction);
366 
367 void ChangeAttributes();
368 void ChangeMsg();
369 void CommentMsg();
370 void ConfirmMsg();
371 void CopyMoveForward(bool torecycle = false);
372 void DecMargin();
373 void DosShell();
374 void ExitAsk();
375 void FileRequest(GMsg* __msg);
376 void GotoBookMark();
377 void GotoFirstMsg();
378 void GotoLastMsg();
379 void GotoMsgno();
380 void GotoNextMsg();
381 void GotoPrevMsg();
382 void GotoNextUnread();
383 void GotoPrevUnread();
384 void GotoReplies();
385 void GotoReply1st();
386 void GotoReplyNext();
387 void GotoReplyPrev();
388 void GotoThNextUnread();
389 void IncMargin();
390 void MakeUserList();
391 void MakePathreport();
392 void MarkingOptions();
393 void MessageBrowse();
394 void NewArea(bool jumpnext = false);
395 void NewMsg();
396 void OtherAreaQuoteMsg(bool ignore_replyto=false);
397 void OtherAreaCommentMsg();
398 void QuitNow();
399 void QuoteBuf(GMsg* msg);
400 void QuoteMsg(bool ignore_replyto=false);
401 void RenumberArea();
402 void ReplyMsg();
403 void ToggleBookMark();
404 void ToggleHidden();
405 void ToggleHiddKlud();
406 void ToggleKludge();
407 void ToggleStripHTML();
408 void ToggleMark();
409 void ToggleMarkRead();
410 void TogglePageBar();
411 void ToggleQuote();
412 void ToggleRealMsgno();
413 void ToggleROT13();
414 void ToggleTwits();
415 void ToggleStyles();
416 void ToggleXlat();
417 void TouchNetscan(int __popup=true);
418 void UUDecode(GMsg* msg);
419 void WriteMsg(GMsg* msg);
420 void TouchSemaphore();
421 
422 
423 //  ------------------------------------------------------------------
424 //  GESCAN prototypes
425 
426 void CheckSemaphores();
427 
428 
429 //  ------------------------------------------------------------------
430 //  GESOUP prototypes
431 
432 char* CvtMSGIDtoMessageID(char* midbuf, char* msgid, ftn_addr* addr, char* domain, char* from, char* to, char* subject, struct tm* datetime);
433 char* CvtMessageIDtoMSGID(const char* mptr, char* msgidbuf, const char* echoid, char* kludge);
434 
435 int ImportSOUP();
436 int ExportSOUP();
437 
438 
439 //  ------------------------------------------------------------------
440 //  GETPLS prototypes
441 
442 void CookieIndex(char* textfile, char* indexfile);
443 int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origarea);
444 bool is_user(const char* name);
445 
446 
447 //  ------------------------------------------------------------------
448 //  GEUTIL prototypes
449 
450 void ScreenBlankIdle();
451 void IdleCheckSemaphores();
452 int   AkaMatch(ftn_addr* __match, const ftn_addr* __addr);
453 void  call_help();
454 void  CheckTick(gkey quitkey);
455 char* CvtName(char* inp);
456 int   edit_string(char* buf, int buf_size, char* title, int helpcat);
457 bool  edit_pathname(char* buf, int buf_size, char* title, int helpcat);
458 int   GetAkaNo(const ftn_addr& __aka);
459 int   GetQuotestr(const char* ptr, char* qbuf, uint* qlen);
460 int   cmp_quotes(char* q1, char* q2);
461 int   is_quote(const char* ptr);
462 bool  is_quote2(Line* line, const char* ptr);
463 int   IsQuoteChar(const char* s);
464 void  maketitle();
465 int   maketitle_and_status(char *);
466 void  ProgMeter(int mode, int xx, int yy, long len, long barlen, int attr, long pos, long size);
467 int   ReadCfg(const char* cfg, int ignoreunknown=false);
468 void  ScanMsgTxtForAddr(GMsg* msg);
469 gkey  SearchKey(gkey key, std::list<CmdKey>::iterator keys, int totkeys);
470 int   SearchTaglist(Echo* taglist, char* tag);
471 void  set_title(const char* t, int p, vattr a);
472 void  title_shadow();
473 void  update_statusline(const char* info);
474 void  update_statuslinef(const char* format, const char *token, ...) __attribute__ ((format (printf, 1, 3)));
475 void  update_statuslines();
476 void  w_info(const char* info=NULL);
477 void  w_infof(const char* format, ...) __attribute__ ((format (printf, 1, 2)));
478 void  w_progress(int mode, vattr attr, long pos, long size, const char* title);
479 void  w_shadow();
480 void  ZonegateIt(ftn_addr& gate, ftn_addr& orig, ftn_addr& dest);
481 char* strtmp(const char* str);
482 vattr quotecolor(const char* line);
483 void  doinvalidate(char* text, const char* find, const char* replace, bool is_tearline = false);
484 bool find(const std::vector<const char *> &vec, const char *str);
485 bool find(const std::vector<std::string> &vec, const std::string &str);
486 vattr GetColorName(const char *name, Addr &addr, vattr color);
487 
488 
489 //  ------------------------------------------------------------------
490 //  GEUSRBSE prototypes
491 
492 bool lookup_addressbook(GMsg* msg, char* name, char* aka, bool browser = false);
493 void build_pseudo(GMsg* msg, bool direction = true);
494 void update_addressbook(GMsg* msg, bool reverse = false, bool force = false);
495 void edit_addressbook(GMsg* msg);
496 
497 //  ------------------------------------------------------------------
498 
499 bool isuucp(const char *name);
500 
501 
502 //  ------------------------------------------------------------------
503 
504 const char *url_begin(const char *ptr);
505 
506 
507 //  ------------------------------------------------------------------
508 
509 void RemoveHTML(char *&txt);
510 
511 
512 //  ------------------------------------------------------------------
513 
514 #endif
515 
516 //  ------------------------------------------------------------------
517 
518