| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /* 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 <https://www.gnu.org/licenses/>
- */
- #include <stdio.h>
- #include <string.h>
- #include <dirent.h>
- #include <arpa/inet.h>
- #include <vcc/vcc.h>
- #include <vcc/pretty.h>
- #include <vcc/plugin.h>
- #include <vcc/version.h>
- #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;
- }
|