This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
common-tools-tcp-burst/src/fragroute/mod_echo.c
2019-07-10 17:54:02 +08:00

58 lines
780 B
C

/*
* mod_echo.c
*
* Copyright (c) 2001 Dug Song <dugsong@monkey.org>
*
* $Id: mod_echo.c 2000 2008-04-27 06:17:35Z aturner $
*/
#include "config.h"
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "argv.h"
#include "mod.h"
void *
echo_open(int argc, char *argv[])
{
char *p;
if (argc < 2)
return (NULL);
if ((p = argv_copy(argv + 1)) == NULL)
return (NULL);
return (p);
}
int
echo_apply(void *d, struct pktq *pktq)
{
char *p = (char *)d;
printf("%s\n", p);
return (0);
}
void *
echo_close(void *d)
{
if (d != NULL)
free(d);
return (NULL);
}
struct mod mod_echo = {
"echo", /* name */
"echo <string> ...", /* usage */
echo_open, /* open */
echo_apply, /* apply */
echo_close /* close */
};