#include <pwd.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
#include <string.h>
#include <syslog.h>
#include <limits.h>
((cdbvisit->len > sizeof(struct visit)) ?
sizeof(struct visit) : cdbvisit->len));
cdb_free(cdbvisit);
- return;
+ }
+
+ /* Set v_seen if necessary */
+ if (vbuf->v_seen[0] == 0) {
+ sprintf(vbuf->v_seen, "*:%ld", vbuf->v_lastseen);
}
}
{
struct cdbdata *cdbus;
- cdb_begin_transaction();
cdb_rewind(CDB_USERSUPP);
while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
sizeof(struct usersupp) : cdbus->len));
cdb_free(cdbus);
if (usbuf->usernum == number) {
- cdb_end_transaction();
+ cdb_close_cursor(CDB_USERSUPP);
return (0);
}
}
- cdb_end_transaction();
return (-1);
}
long newlr;
struct visit vbuf;
- if (CtdlAccessCheck(ac_logged_in))
+ if (CtdlAccessCheck(ac_logged_in)) {
return;
+ }
if (!strncasecmp(new_ptr, "highest", 7)) {
newlr = CC->quickroom.QRhighest;
CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
vbuf.v_lastseen = newlr;
+ sprintf(vbuf.v_seen, "*:%ld", newlr);
CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
lputuser(&CC->usersupp);
}
+void cmd_seen(char *argbuf) {
+ long target_msgnum = 0L;
+ int target_setting = 0;
+
+ if (CtdlAccessCheck(ac_logged_in)) {
+ return;
+ }
+
+ if (num_parms(argbuf) != 2) {
+ cprintf("%d Invalid parameters\n", ERROR);
+ return;
+ }
+
+ target_msgnum = extract_long(argbuf, 0);
+ target_setting = extract_int(argbuf, 1);
+
+ CtdlSetSeen(target_msgnum, target_setting);
+ cprintf("%d OK\n", OK);
+}
+
+
/*
* INVT and KICK commands
*/
/*
- * forget (Zap) the current room
+ * Forget (Zap) the current room (API call)
+ * Returns 0 on success
*/
-void cmd_forg(void)
-{
+int CtdlForgetThisRoom(void) {
struct visit vbuf;
- if (CtdlAccessCheck(ac_logged_in)) {
- return;
- }
-
+ /* On some systems, Aides are not allowed to forget rooms */
if (is_aide() && (config.c_aide_zap == 0)) {
- cprintf("%d Aides cannot forget rooms.\n", ERROR);
- return;
+ return(1);
}
lgetuser(&CC->usersupp, CC->curr_user);
CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
lputuser(&CC->usersupp);
- cprintf("%d Ok\n", OK);
+
+ /* Return to the Lobby, so we don't end up in an undefined room */
usergoto(BASEROOM, 0, NULL, NULL);
+ return(0);
+
+}
+
+
+/*
+ * forget (Zap) the current room
+ */
+void cmd_forg(void)
+{
+
+ if (CtdlAccessCheck(ac_logged_in)) {
+ return;
+ }
+
+ if (CtdlForgetThisRoom() == 0) {
+ cprintf("%d Ok\n", OK);
+ }
+ else {
+ cprintf("%d You may not forget this room.\n", ERROR);
+ }
}
/*
/* There are unvalidated users. Traverse the usersupp database,
* and return the first user we find that needs validation.
*/
- cdb_begin_transaction();
cdb_rewind(CDB_USERSUPP);
while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
memset(&usbuf, 0, sizeof(struct usersupp));
if ((usbuf.flags & US_NEEDVALID)
&& (usbuf.axlevel > 0)) {
cprintf("%d %s\n", MORE_DATA, usbuf.fullname);
- cdb_end_transaction();
+ cdb_close_cursor(CDB_USERSUPP);
return;
}
}
- cdb_end_transaction();
/* If we get to this point, there are no more unvalidated users.
* Therefore we clear the "users need validation" flag.