53 lines
1.7 KiB
C
53 lines
1.7 KiB
C
/* *****************************************************************************
|
|
* p7servtest/client.c -- p7servtest virtual client.
|
|
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
*
|
|
* This file is part of p7utils.
|
|
* p7utils is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2.0 of the License,
|
|
* or (at your option) any later version.
|
|
*
|
|
* p7utils is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with p7utils; if not, see <http://www.gnu.org/licenses/>.
|
|
* ************************************************************************** */
|
|
#include "main.h"
|
|
#include <libp7.h>
|
|
#include <libp7/packetio.h>
|
|
#include <libp7/stream.h>
|
|
|
|
int run_client(int in, int out)
|
|
{
|
|
/* make the stream */
|
|
p7_stream_t stream;
|
|
int err = p7_sopen_streams(&stream, NULL, in, out);
|
|
if (err) {
|
|
fprintf(stderr, "Client stream initialization has encountered "
|
|
"an error: %s\n", p7_strerror(err));
|
|
return (1);
|
|
}
|
|
|
|
/* make the handle */
|
|
p7_handle_t *handle = NULL;
|
|
err = p7_sinit(&handle, p7_flag_active | p7_flag_check | p7_flag_term,
|
|
"client", &stream, NULL);
|
|
if (err) {
|
|
fprintf(stderr, "Client initialization has encountered an error: %s\n",
|
|
p7_strerror(err));
|
|
return (1);
|
|
}
|
|
|
|
/* change working directory. */
|
|
p7_seven_send_cmdfls_cwd(handle, "oui", "fls0");
|
|
p7_seven_send_cmdfls_cwd(handle, "non", "fls0");
|
|
|
|
/* we're done. */
|
|
p7_exit(handle);
|
|
return (0);
|
|
}
|