示例#1
0
文件: buddy.c 项目: GunioRobot/naim
void	bgoing(conn_t *conn, const char *buddy) {
	buddywin_t	*bwin = conn->curbwin;
	buddylist_t	*blist = NULL;

	assert(buddy != NULL);

	if (bwin == NULL)
		return;

	if ((blist = rgetlist(conn, buddy)) != NULL) {
		if ((blist->peer <= 0) && (blist->crypt != NULL))
			echof(conn, NULL, "Strangeness while marking %s offline: no autopeer negotiated, but autocrypt set!\n",
				buddy);
		blist->docrypt = blist->peer = 0;
		if (blist->crypt != NULL) {
			free(blist->crypt);
			blist->crypt = NULL;
		}
		if (blist->tzname != NULL) {
			free(blist->tzname);
			blist->tzname = NULL;
		}

		status_echof(conn, "<font color=\"#00FFFF\">%s</font> <font color=\"#800000\">[<B>%s</B>]</font> has just logged off :(\n", 
			user_name(NULL, 0, conn, blist), USER_GROUP(blist));
		blist->offline = 1;
		blist->warnval = blist->typing = blist->isadmin = blist->ismobile = blist->isidle = blist->isaway = 0;
	} else
		return;

	do {
		if ((bwin->et == BUDDY) && (firetalk_compare_nicks(conn->conn, buddy, bwin->winname) == FE_SUCCESS)) {
			int	autoclose = getvar_int(conn, "autoclose"),
				beeponsignon = getvar_int(conn, "beeponsignon");

			assert(bwin->e.buddy == blist);
			window_echof(bwin, "<font color=\"#00FFFF\">%s</font> <font color=\"#800000\">[<B>%s</B>]</font> has just logged off :(\n",
				user_name(NULL, 0, conn, blist), USER_GROUP(blist));
			if ((beeponsignon > 1) || ((awaytime == 0) && (beeponsignon == 1)))
				beep();
			FREESTR(bwin->blurb);
			FREESTR(bwin->status);

			if (bwin->keepafterso == 1) {
				if ((autoclose > 0) && !USER_PERMANENT(bwin->e.buddy) && (bwin->waiting == 0))
					bwin->closetime = now + 60*autoclose;
			} else {
				/* assert(bwin->waiting == 0); */
				bclose(conn, bwin, 1);
				bwin = NULL;
				if ((autoclose > 0) && !USER_PERMANENT(blist)) {
					rdelbuddy(conn, buddy);
					firetalk_im_remove_buddy(conn->conn, buddy);
				}
			}
			bupdate();
			return;
		}
	} while ((bwin = bwin->next) != conn->curbwin);
}
示例#2
0
文件: buddy.c 项目: GunioRobot/naim
static void
	bclearall_bwin(conn_t *conn, buddywin_t *bwin, int force) {
	FREESTR(bwin->blurb);
	FREESTR(bwin->status);
	switch (bwin->et) {
	  case BUDDY:
		assert(bwin->e.buddy != NULL);
		if (bwin->e.buddy->offline == 0) {
			bwin->e.buddy->offline = 1;
			window_echof(bwin, "<font color=\"#00FFFF\">%s</font> <font color=\"#800000\">[<B>%s</B>]</font> is no longer available :/\n",
				user_name(NULL, 0, conn, bwin->e.buddy), USER_GROUP(bwin->e.buddy));
		}
		if (bwin->keepafterso == 0) {
			bclose(conn, bwin, 1);
			bwin = NULL;
			return;
		}
		break;
	  case CHAT:
		bwin->e.chat->isoper = 0;
		if (bwin->e.chat->offline == 0) {
			bwin->e.chat->offline = 1;
			window_echof(bwin, "Chat <font color=\"#00FFFF\">%s</font> is no longer available :/\n",
				bwin->winname);
		}
		break;
	  case TRANSFER:
		break;
	}
	if (force) {
		bclose(conn, bwin, 1);
		bwin = NULL;
	}
}
示例#3
0
文件: buddy.c 项目: GunioRobot/naim
static void
	bremove(buddywin_t *bwin) {
	int	i;

	assert(bwin != NULL);
	nw_delwin(&(bwin->nwin));
	for (i = 0; i < bwin->pouncec; i++) {
		free(bwin->pouncear[i]);
		bwin->pouncear[i] = NULL;
	}
	free(bwin->pouncear);
	bwin->pouncear = NULL;
	FREESTR(bwin->winname);
	FREESTR(bwin->blurb);
	FREESTR(bwin->status);

	if (bwin->nwin.logfile != NULL) {
		struct tm	*tmptr;

		tmptr = localtime(&now);
		fprintf(bwin->nwin.logfile, "<I>-----</I> <font color=\"#FFFFFF\">Log file closed %04i-%02i-%02iT%02i:%02i</font> <I>-----</I><br>\n",
			1900+tmptr->tm_year, 1+tmptr->tm_mon, tmptr->tm_mday, tmptr->tm_hour, tmptr->tm_min);
		fclose(bwin->nwin.logfile);
		bwin->nwin.logfile = NULL;
	}

	free(bwin);
}
示例#4
0
文件: buddy.c 项目: GunioRobot/naim
void	baway(conn_t *conn, const char *buddy, int isaway) {
	buddywin_t	*bwin = NULL;
	buddylist_t	*blist = NULL;

	assert(buddy != NULL);
	bwin = bgetwin(conn, buddy, BUDDY);
	if (bwin == NULL)
		blist = rgetlist(conn, buddy);
	else
		blist = bwin->e.buddy;
	assert(blist != NULL);

	if (bwin != NULL) {
		if (isaway == 0)
			FREESTR(bwin->blurb);
		if ((isaway == 1) && (blist->isaway == 0)) {
			if ((conn->online+30) < now) {
				awayc++;
				awayar = realloc(awayar, awayc*sizeof(*awayar));
				awayar[awayc-1].name = strdup(buddy);
				awayar[awayc-1].gotaway = 0;
				firetalk_im_get_info(conn->conn, buddy);
			} else
				window_echof(bwin, "<font color=\"#00FFFF\">%s</font> is now away.\n",
					user_name(NULL, 0, conn, blist));
		} else if ((isaway == 0) && (blist->isaway == 1)) {
			if (bwin->status != NULL)
				window_echof(bwin, "<font color=\"#00FFFF\">%s</font> is now available: %s\n",
					user_name(NULL, 0, conn, blist), bwin->status);
			else
				window_echof(bwin, "<font color=\"#00FFFF\">%s</font> is no longer away!\n",
					user_name(NULL, 0, conn, blist));
		}
	}

	blist->isaway = isaway;
}
示例#5
0
__END_DECLS
#endif

/*
 *	Control-files (cf*) have the following format.
 *
 *	Each control-file describes a single job.  It will list one or more
 *	"datafiles" (df*) which should be copied to some printer.  Usually
 *	there is only one datafile per job.  For the curious, RFC 1179 is an
 *	informal and out-of-date description of lpr/lpd circa 1990.
 *
 *	Each line in the file gives an attribute of the job as a whole, or one
 *	of the datafiles in the job, or a "command" indicating something to do
 *	with one of the datafiles.  Each line starts with an 'id' that indicates
 *	what that line is there for.  The 'id' is historically a single byte,
 *	but may be multiple bytes (obviously it would be best if multi-byte ids
 *	started with some letter not already used as a single-byte id!).
 *	After the 'id', the remainder of the line will be the value of the
 *	indicated attribute, or a name of the datafile to be operated on.
 *
 *	In the following lists of ids, the ids with a '!' in front of them are
 *	NOT explicitly supported by this version of lpd, or at least "not yet
 *	supported".  They are only listed for reference purposes, so people
 *	won't be tempted to reuse the same id for a different purpose.
 *
 *	The following are attributes of the job which should not appear more
 *	than once in a control file.  Only the 'H' and 'P' lines are required
 *	by the RFC, but some implementations of lpr won't even get that right.
 *
 *	! A   - [used by lprNG]
 *	  B   - As far as I know, this is never used as a single-byte id.
 *		Therefore, I intend to use it for multi-byte id codes.
 *	  C   - "class name" to display on banner page (this is sometimes
 *		used to hold options for print filters)
 *	! D   - [in lprNG, "timestamp" of when the job was submitted]
 *	! E   - "environment variables" to set [some versions of linux]
 *	  H   - "host name" of machine where the original 'lpr' was done
 *	  I   - "indent", the amount to indent output
 *	  J   - "job name" to display on banner page
 *	  L   - "literal" user's name as it should be displayed on the
 *		banner page (it is the existence of an 'L' line which
 *		indicates that a job should have a banner page).
 *	  M   - "mail", userid to mail to when done printing (with email
 *		going to 'M'@'H', so to speak).
 *	  P   - "person", the user's login name (e.g. for accounting)
 *	! Q   - [used by lprNG for queue-name]
 *	  R   - "resolution" in dpi, for some laser printer queues
 *	  T   - "title" for files sent thru 'pr'
 *	  W   - "width" to use for printing plain-text files
 *	  Z   - In BSD, "locale" to use for datafiles sent thru 'pr'.
 *		(this BSD usage should move to a different id...)
 *		[in lprNG - this line holds the "Z options"]
 *	  1   - "R font file" for files sent thru troff
 *	  2   - "I font file" for files sent thru troff
 *	  3   - "B font file" for files sent thru troff
 *	  4   - "S font file" for files sent thru troff
 *
 *	The following are attributes attached to a datafile, and thus may
 *	appear multiple times in a control file (once per datafile):
 *
 *	  N   - "name" of file (for display purposes, used by 'lpq')
 *	  S   - "stat() info" used for symbolic link ('lpr -s')
 *		security checks.
 *
 *	The following indicate actions to take on a given datafile.  The same
 *	datafile may appear on more than one "print this file" command in the
 *	control file.  Note that ALL ids with lowercase letters are expected
 *	to be actions to "print this file":
 *
 *	  c   - "file name", cifplot file to print.  This action appears
 *		when the user has requested 'lpr -c'.
 *	  d   - "file name", dvi file to print, user requested 'lpr -d'
 *	  f   - "file name", a plain-text file to print = "standard"
 *	  g   - "file name", plot(1G) file to print, ie 'lpr -g'
 *	  l   - "file name", text file with control chars which should
 *		be printed literally, ie 'lpr -l'  (note: some printers
 *		take this id as a request to print a postscript file,
 *		and because of *that* some OS's use 'l' to indicate
 *		that a datafile is a postscript file)
 *	  n   - "file name", ditroff(1) file to print, ie 'lpr -n'
 *	  o   - "file name", a postscript file to print.  This id is
 *		described in the original RFC, but not much has been
 *		done with it.  This 'lpr' does not generate control
 *		lines with 'o'-actions, but lpd's printjob processing
 *		will treat it the same as 'l'.
 *	  p   - "file name", text file to print with pr(1), ie 'lpr -p'
 *	  t   - "file name", troff(1) file to print, ie 'lpr -t'
 *	  v   - "file name", plain raster file to print
 *
 *	  U   - "file name" of datafile to unlink (ie, remove file
 *		from spool directory.  To be done in a 'Pass 2',
 *		AFTER having processed all datafiles in the job).
 *
 */

void
ctl_freeinf(struct cjobinfo *cjinf)
{
#define FREESTR(xStr) \
	if (xStr != NULL) { \
		free(xStr); \
		xStr = NULL;\
	}

    struct cjprivate *cpriv;

    if (cjinf == NULL)
        return;
    cpriv = cjinf->cji_priv;
    if ((cpriv == NULL) || (cpriv != cpriv->pub.cji_priv)) {
        syslog(LOG_ERR, "in ctl_freeinf(%p): invalid cjinf (cpriv %p)",
               (void *)cjinf, (void *)cpriv);
        return;
    }

    FREESTR(cpriv->pub.cji_accthost);
    FREESTR(cpriv->pub.cji_acctuser);
    FREESTR(cpriv->pub.cji_class);
    FREESTR(cpriv->pub.cji_curqueue);
    /* [cpriv->pub.cji_fname is part of cpriv-malloced area] */
    FREESTR(cpriv->pub.cji_jobname);
    FREESTR(cpriv->pub.cji_mailto);
    FREESTR(cpriv->pub.cji_headruser);

    if (cpriv->cji_fstream != NULL) {
        fclose(cpriv->cji_fstream);
        cpriv->cji_fstream = NULL;
    }

    cjinf->cji_priv = NULL;
    free(cpriv);
#undef FREESTR
}