2016-03-03 08:33:07 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Julien Palard.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2011-08-28 19:48:33 +00:00
|
|
|
#include <stdlib.h>
|
2011-08-31 07:00:24 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <utmp.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <pty.h>
|
|
|
|
#include <stdio.h>
|
2011-10-15 12:44:23 +00:00
|
|
|
#include "hl_vt100.h"
|
2011-09-14 22:03:30 +00:00
|
|
|
|
2011-09-22 07:22:04 +00:00
|
|
|
void disp(struct vt100_headless *vt100)
|
2011-08-31 22:12:25 +00:00
|
|
|
{
|
|
|
|
unsigned int y;
|
2011-09-21 17:36:54 +00:00
|
|
|
const char **lines;
|
2011-08-31 22:12:25 +00:00
|
|
|
|
2011-10-16 11:27:09 +00:00
|
|
|
lines = vt100_headless_getlines(vt100);
|
2011-09-22 18:17:27 +00:00
|
|
|
write(1, "\n", 1);
|
2011-09-22 18:14:43 +00:00
|
|
|
for (y = 0; y < vt100->term->height; ++y)
|
2011-08-31 22:12:25 +00:00
|
|
|
{
|
2011-10-22 14:45:31 +00:00
|
|
|
write(1, "|", 1);
|
2011-09-22 18:14:43 +00:00
|
|
|
write(1, lines[y], vt100->term->width);
|
2011-10-22 14:45:31 +00:00
|
|
|
write(1, "|\n", 2);
|
2011-08-31 22:12:25 +00:00
|
|
|
}
|
2011-08-31 07:00:24 +00:00
|
|
|
}
|
2011-09-22 18:14:43 +00:00
|
|
|
|
2011-09-19 07:03:12 +00:00
|
|
|
int main(int ac, char **av)
|
|
|
|
{
|
2011-09-22 07:22:04 +00:00
|
|
|
struct vt100_headless *vt100_headless;
|
2011-08-31 07:00:24 +00:00
|
|
|
|
2011-09-10 18:59:22 +00:00
|
|
|
if (ac == 1)
|
|
|
|
{
|
2011-09-19 07:03:12 +00:00
|
|
|
puts("Usage: test PROGNAME");
|
2011-09-10 18:59:22 +00:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2011-10-22 14:45:31 +00:00
|
|
|
vt100_headless = new_vt100_headless();
|
2011-09-22 07:22:04 +00:00
|
|
|
vt100_headless->changed = disp;
|
|
|
|
vt100_headless_fork(vt100_headless, av[1], (av + 1));
|
2011-10-22 14:45:31 +00:00
|
|
|
vt100_headless_main_loop(vt100_headless);
|
2011-08-28 19:48:33 +00:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|