+
+/*
+ * Handler for RBILogin
+ */
+
+static struct uam_obj *papd_uam = NULL;
+static const char *rbiloginok = "0\r";
+static const char *rbiloginbad = "-1\r";
+static const char *rbiloginerrstr = "%%[Error: SecurityError; \
+SecurityViolation: Unknown user, incorrect password or log on is \
+disabled ]%%\r%%[Flushing: rest of job (to end-of-file) will be \
+ignored ]%%\r";
+
+int cq_rbilogin( in, out )
+ struct papfile *in, *out;
+{
+ char *start, *stop, *p, *begin;
+ int linelength, crlflength;
+ char username[9] = "\0";
+ struct papd_comment *comment = compeek();
+ char uamtype[20] = "\0";
+
+ for (;;) {
+ switch ( markline( in, &start, &linelength, &crlflength )) {
+ case 0 :
+ return( 0 );
+
+ case -1 :
+ return( CH_MORE );
+ }
+
+ stop = start + linelength;
+
+ if ( comgetflags() == 0 ) { /* first line */
+ begin = start + strlen(comment->c_begin);
+ p = begin;
+
+ while (*p != ' ') {
+ p++;
+ }
+
+ strncat(uamtype, begin, p - begin);
+
+ if ((papd_uam = auth_uamfind(UAM_SERVER_PRINTAUTH,
+ uamtype, strlen(uamtype))) == NULL) {
+ LOG(log_info, logtype_papd, "Could not find uam: %s", uamtype);
+ append(out, rbiloginbad, strlen(rbiloginbad));
+ append(out, rbiloginerrstr, strlen(rbiloginerrstr));
+ } else {
+ if ( (papd_uam->u.uam_printer(p,stop,username,out)) == 0 ) {
+ lp_person( username );
+ } else {
+ append(out, rbiloginbad, strlen( rbiloginbad));
+ append(out, rbiloginerrstr, strlen(rbiloginerrstr));
+ }
+ }
+ comsetflags( 1 );
+ } else {
+ if ( comcmp( start, stop, comment->c_end, 0 ) == 0 ) {
+ compop();
+ return( CH_DONE );
+ }
+ }
+
+ CONSUME( in, linelength + crlflength );
+ }
+}
+
+