Beispiel #1
0
static int
command_more(int argc, char *argv[])
{
    int         i;
    int         res;
    char	line[80];

    res=0;
    pager_open();
    for (i = 1; (i < argc) && (res == 0); i++) {
	sprintf(line, "*** FILE %s BEGIN ***\n", argv[i]);
	if (pager_output(line))
		break;
        res = page_file(argv[i]);
	if (!res) {
	    sprintf(line, "*** FILE %s END ***\n", argv[i]);
	    res = pager_output(line);
	}
    }
    pager_close();

    if (res == 0)
	return CMD_OK;
    else
	return CMD_ERROR;
}
Beispiel #2
0
void LocalRedirectServer::WriteTemplate(QTcpSocket* socket) const {
  QFile page_file(":oauthsuccess.html");
  page_file.open(QIODevice::ReadOnly);
  QString page_data = QString::fromUtf8(page_file.readAll());

  QRegExp tr_regexp("tr\\(\"([^\"]+)\"\\)");
  int offset = 0;
  forever {
    offset = tr_regexp.indexIn(page_data, offset);
    if (offset == -1) {
      break;
    }

    page_data.replace(offset, tr_regexp.matchedLength(),
                      tr(tr_regexp.cap(1).toUtf8()));
    offset += tr_regexp.matchedLength();
  }

  QBuffer image_buffer;
  image_buffer.open(QIODevice::ReadWrite);
  QApplication::style()
      ->standardIcon(QStyle::SP_DialogOkButton)
      .pixmap(16)
      .toImage()
      .save(&image_buffer, "PNG");
  page_data.replace("@IMAGE_DATA@", image_buffer.data().toBase64());

  socket->write("HTTP/1.0 200 OK\r\n");
  socket->write("Content-type: text/html;charset=UTF-8\r\n");
  socket->write("\r\n\r\n");
  socket->write(page_data.toUtf8());
  socket->flush();
}
Beispiel #3
0
int
readnews()
{
	int ret;

	whole_screen = TRUE;	/* force a docrt(), our first */
	ret = page_file(NEWS, TRUE);
	set_whole_screen();
	return(ret);		/* report whether we did docrt() */
}
Beispiel #4
0
int
dohelp()
{
	char c;

	pline ("Long or short help? ");
	while (((c = readchar ()) != 'l') && (c != 's') && !strchr(quitchars,c))
		hackbell ();
	if (!strchr(quitchars, c))
		(void) page_file((c == 'l') ? HELP : SHELP, FALSE);
	return(0);
}
Beispiel #5
0
void readmail(void)
{
#ifdef DEF_MAILREADER	       // This implies that UNIX is defined
    char *mr = 0;
    more();
    if (!(mr = getenv("MAILREADER")))
	mr = DEF_MAILREADER;
    if (child(1)) {
	execl(mr, mr, (char *) 0);
	exit(1);
    }
#else				// DEF_MAILREADER
    (void) page_file(mailbox, false);
#endif				// DEF_MAILREADER
    // get new stat; not entirely correct: there is a small time window
    // where we do not see new mail
    getmailstatus();
}
void OAuthenticator::NewConnection() {
  QTcpSocket* socket = server_.nextPendingConnection();
  server_.close();

  QByteArray buffer;

  NewClosure(socket, SIGNAL(readyRead()),
             this, SLOT(RedirectArrived(QTcpSocket*, QByteArray)), socket, buffer);

  // Everything is bon.  Prepare and display the success page.
  QFile page_file(":oauthsuccess.html");
  page_file.open(QIODevice::ReadOnly);
  QString page_data = QString::fromLatin1(page_file.readAll());

  // Translate the strings inside
  QRegExp tr_regexp("tr\\(\"([^\"]+)\"\\)");
  int offset = 0;
  forever {
    offset = tr_regexp.indexIn(page_data, offset);
    if (offset == -1) {
      break;
    }

    page_data.replace(offset, tr_regexp.matchedLength(),
                      tr(tr_regexp.cap(1).toAscii()));
    offset += tr_regexp.matchedLength();
  }

  // Add the tick image.
  QBuffer image_buffer;
  image_buffer.open(QIODevice::ReadWrite);
  QApplication::style()->standardIcon(QStyle::SP_DialogOkButton)
      .pixmap(16).toImage().save(&image_buffer, "PNG");

  page_data.replace("@IMAGE_DATA@", image_buffer.data().toBase64());

  socket->write("HTTP/1.0 200 OK\r\n");
  socket->write("Content-type: text/html;charset=UTF-8\r\n");
  socket->write("\r\n\r\n");
  socket->write(page_data.toUtf8());
  socket->flush();
}
Beispiel #7
0
int main(int argc, char* argv[]) {
    int size = argc - 1;

    FILE* files[size];
    if (argc == 1) {
        fprintf(stderr, "No files specified, nothing to do.\n");
    } else {
        int i = 0;
        for (i; i < size; i++) {
            files[i] = get_file(argv[i+1]);
        }
    }

    int i = 0;
    for (i; i < size; i++) {
        page_file(argv[i+1], files[i]); 
    }

    return 0;
}
Beispiel #8
0
void
readmail(void)
{
#ifdef DEF_MAILREADER		/* This implies that UNIX is defined */
	char *mr = NULL;

	more();
	if (!(mr = getenv("MAILREADER")))
		mr = DEF_MAILREADER;
	if (child(1)) {
		execl(mr, mr, NULL);
		exit(1);
	}
#else /* DEF_MAILREADER */
	page_file(mailbox, FALSE);
#endif /* DEF_MAILREADER */
       /* get new stat; not entirely correct: there is a small time
	* window where we do not see new mail */
	getmailstatus();
}