]>
jfr.im git - irc/gameservirc.git/blob - gameserv/news.cpp
11 List
<string
> todaysnews
;
12 void addNews(List
<string
> &news
, const char *fmt
, ...);
13 void clearNews(List
<string
> &news
) {news
.deleteNodes();};
14 void showNews(char *nick
, List
<string
> &news
);
15 void saveNews(char *filename
, List
<string
> &news
);
16 void loadNews(char *filename
, List
<string
> &news
);
18 void addNews(List
<string
> &news
, const char *fmt
, ...)
25 input
= new char[1024];
26 memset(input
, 0, 1024);
36 case 'd': sprintf(input
, "%s%d", input
, va_arg(args
, int)); break;
37 case 's': sprintf(input
, "%s%s", input
, va_arg(args
, char *)); break;
38 case 'S': sprintf(input
, "%s%s", input
, s_GameServ
); break;
41 sprintf(input
, "%s%ld", input
, va_arg(args
, long int)); break;
46 sprintf(input
, "%s%c", input
, *t
);
51 log("New News Item: %s", input
);
54 notice(s_GameServ
, c_Forest
, "News Flash: %s", input
);
56 nstring
= new string(input
);
57 news
.insertAtBack(nstring
);
65 void showNews(char *nick
, List
<string
> &news
)
72 notice(s_GameServ
, nick
, "The Daily Happenings: ");
75 notice(s_GameServ
, nick
, "%s", it
->getData()->c_str());
78 notice(s_GameServ
, nick
, "End of News");
82 void saveNews(char *filename
, List
<string
> &news
)
85 outfile
.open(filename
);
89 log("Error opening %s", filename
);
97 outfile
<< it
->getData()->c_str() << endl
;
103 void loadNews(char *filename
, List
<string
> &news
)
105 // First clear the old news out
106 ListNode
<string
> *it
, *temp
;
116 // Now load from the file
118 infile
.open(filename
);
121 log("Error opening %s", filename
);
127 buf
= new char [1024];
129 while (infile
.getline(buf
, 1024, '\n'))
131 if (buf
[0] == '\0' || buf
[0] == '\n')
136 str
= new string(buf
);
137 news
.insertAtBack(str
);
144 void do_news(char *u
)
146 showNews(u
, todaysnews
);