/* vcc/plugins/robot/lcn.c
*
* This file is part of vcc.
*
* vcc 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 3 of the License, or
* (at your option) any later version.
*
* vcc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with vcc. If not, see
*/
#include
#include
#include
#include
#include
#include
#include
#include
#define LCN_PATH "/root/lcn-articles/"
int send_msg(char *, char *);
struct cmdtable lcn_cmdtab[] = {
{ NULL, 0, 0 }
};
struct plugin plg_lcn = {
.state = 0,
.name = "lcn",
.descr = "The lcn plugin: read lcn articles online. ",
.cmdtab = lcn_cmdtab
};
#define this_plg (&plg_lcn)
int robot_lslcn(char *s) {
DIR *dir;
struct dirent *dirent;
char p[MSG_SIZE];
(void) s;
if (!(dir = opendir(LCN_PATH))) {
send_msg("Oops! There are something wrong when I tried to finish my work...\n", "robot");
return 1;
}
while ((dirent = readdir(dir))) {
if (dirent->d_type == DT_REG) {
memset(p, 0, MSG_SIZE);
sprintf(p, "%s\n", dirent->d_name);
send_msg(p, "robot");
}
}
closedir(dir);
return 0;
}