static int eb_custom_msg_timeout_callback(void *data) { static long file_time; struct stat s; int fd, n, i; char buf[1024]; if (!enable_plugin) return 1; if (!custom_away_msg[0]) return 1; stat(custom_away_msg, &s); if (file_time >= s.st_mtime) return 1; file_time = s.st_mtime; fd = open(custom_away_msg, O_RDONLY); n = read(fd, buf, sizeof(buf) - 1); buf[n] = 0; for (i = n - 1; buf[i] == '\n'; i--) buf[i] = 0; close(fd); set_away(buf); return 1; }
/* SYNTAX: AWAY [-one | -all] [away|dnd|xa|chat] [<reason>] */ static void cmd_away(const char *data, XMPP_SERVER_REC *server) { GHashTable *optlist; char *reason; void *free_arg; CMD_XMPP_SERVER(server); if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST, "away", &optlist, &reason)) return; if (g_hash_table_lookup(optlist, "one") != NULL) set_away(server, reason); else g_slist_foreach(servers, (GFunc)set_away, reason); cmd_params_free(free_arg); }