File at-3.1.8-joblist.patch of Package at.import4150

--- at.c.orig
+++ at.c
@@ -133,8 +133,10 @@ static void sigc(int signo);
 static void alarmc(int signo);
 static char *cwdname(void);
 static void writefile(time_t runtimer, char queue);
-static void list_jobs(void);
+static void list_jobs(long *, int);
 static time_t ttime(const char *arg);
+static int in_job_list(long, long *, int);
+static long *get_job_list(int, char *[], int *);
 
 /* Signal catching functions */
 
@@ -526,8 +528,20 @@ writefile(time_t runtimer, char queue)
     return;
 }
 
+static int
+in_job_list(long job, long *joblist, int len)
+{
+    int i;
+
+    for (i = 0; i < len; i++)
+        if (job == joblist[i])
+            return 1;
+
+    return 0;
+}
+
 static void
-list_jobs()
+list_jobs(long *joblist, int len)
 {
     /* List all a user's jobs in the queue, by looping through ATJOB_DIR, 
      * or everybody's if we are root
@@ -566,6 +580,10 @@ list_jobs()
 	if (sscanf(dirent->d_name, "%c%5lx%8lx", &queue, &jobno, &ctm) != 3)
 	    continue;
 
+	/* If jobs are given, only list those jobs */
+	if (joblist && !in_job_list(jobno, joblist, len))
+	    continue;
+
 	if (atqueue && (queue != atqueue))
 	    continue;
 
@@ -743,6 +761,28 @@ terr:
 	    "out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]");
 }
 
+static long *
+get_job_list(int argc, char *argv[], int *joblen)
+{
+    int i, len;
+    long *joblist;
+    char *ep;
+
+    joblist = NULL;
+    len = argc;
+    if (len > 0) {
+	joblist = (long *) mymalloc(len * sizeof(*joblist));
+	for (i = 0; i < argc; i++) {
+	    errno = 0;
+	    if ((joblist[i] = strtol(argv[i], &ep, 10)) < 0 ||
+		ep == argv[i] || *ep != '\0' || errno)
+		panic("invalid job number");
+        }
+    }
+
+    *joblen = len;
+    return joblist;
+}
 
 /* Global functions */
 
@@ -769,9 +809,13 @@ main(int argc, char **argv)
     char *options = "q:f:t:MmvldrhVc";	/* default options for at */
     int disp_version = 0;
     time_t timer;
+    long *joblist;
+    int joblen;
     struct passwd *pwe;
     struct group *ge;
 
+    joblist = NULL;
+    joblen = 0;
     timer = -1;
     RELINQUISH_PRIVS
 
@@ -901,7 +945,9 @@ main(int argc, char **argv)
     case ATQ:
 
 	REDUCE_PRIV(daemon_uid, daemon_gid)
-	    list_jobs();
+	    if (queue_set == 0)
+		joblist = get_job_list(argc - optind, argv + optind, &joblen);
+	    list_jobs(joblist, joblen);
 	break;
 
     case ATRM:
--- panic.c.orig
+++ panic.c
@@ -95,6 +95,8 @@ usage(void)
 	    "       at [-V] -c job [job ...]\n"
 	    "       at [-V] -r job [job ...]\n"
 	    "       at [-V] [-f file] -t [[CC]YY]MMDDhhmm[.SS]\n"
+	    "       at [-V] -l -q queuename\n"
+	    "       at [-V] -l [job ...]\n"
 	    "       atq [-V] [-q x]\n"
 	    "       atrm [-V] [-q x] job ...\n"
 	    "       batch [-V] [-f file] [-m]\n");