Article.H 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // Article.H -- Manage newsgroup articles
  3. // 1.00 erco@3dsite.com 12/16/02
  4. //
  5. // Copyright 2003-2004 Michael Sweet
  6. // Copyright 2002 Greg Ercolano
  7. //
  8. // This program is free software; you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public Licensse as published by
  10. // the Free Software Foundation; either version 2 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. //
  22. // 80 //////////////////////////////////////////////////////////////////////////
  23. #ifndef ARTICLE_H
  24. #define ARTICLE_H
  25. #include "everything.H"
  26. class Article
  27. {
  28. string group; // group name
  29. string filename; // full path to the article
  30. unsigned long number; // article number
  31. int valid; // article is valid (0=invalid)
  32. // commonly accessed header info
  33. string from; // From: field
  34. string date; // Date: field
  35. string messageid; // Message-ID: field
  36. string subject; // Subject: field
  37. string references; // References: field
  38. string xref; // Xref: field
  39. off_t bytes;
  40. int lines; // Lines: field
  41. string errmsg; // error message
  42. void _Copy(const Article& o)
  43. {
  44. group = o.group;
  45. filename = o.filename;
  46. number = o.number;
  47. valid = o.valid;
  48. from = o.from;
  49. date = o.date;
  50. messageid = o.messageid;
  51. subject = o.subject;
  52. references = o.references;
  53. xref = o.xref;
  54. bytes = o.bytes;
  55. lines = o.lines;
  56. errmsg = o.errmsg;
  57. }
  58. string _ArticlePath(unsigned long num);
  59. int _ParseHeader(string& key, string& val);
  60. public:
  61. Article()
  62. {
  63. group = "";
  64. filename = "";
  65. number = 0;
  66. valid = 0;
  67. from = "";
  68. date = "";
  69. messageid = "";
  70. subject = "";
  71. references = "";
  72. xref = "";
  73. bytes = 0;
  74. lines = 0;
  75. errmsg = "";
  76. }
  77. ~Article() { }
  78. Article(const Article& o)
  79. { _Copy(o); }
  80. Article& operator=(const Article& o)
  81. { _Copy(o); return(*this); }
  82. int IsValid() { return(valid); }
  83. const char *Group() { return(group.c_str()); }
  84. const char *Filename() { return(filename.c_str()); }
  85. const char *From() { return(from.c_str()); }
  86. const char *Date() { return(date.c_str()); }
  87. const char *MessageID() { return(messageid.c_str()); }
  88. const char *Subject() { return(subject.c_str()); }
  89. const char *Xref() { return(xref.c_str()); }
  90. const char *References() { return(references.c_str()); }
  91. off_t Size() { return(bytes); }
  92. int Lines() { return(lines); }
  93. unsigned long Number() { return(number); }
  94. const char *Errmsg() { return(errmsg.c_str()); }
  95. // load info for group/article
  96. int Load(const char *group, unsigned long num);
  97. // load info for article
  98. int Load(unsigned long num);
  99. // send article to remote via fd
  100. int SendArticle(int fd, int head=1, int body=1);
  101. // send article head only
  102. int SendHead(int fd);
  103. // send article body only
  104. int SendBody(int fd);
  105. string Overview(const char *overview[]);
  106. };
  107. #endif /*!ARTICLE_H*/