File: strioctl.c

package info (click to toggle)
pload 0.9.5-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 208 kB
  • ctags: 96
  • sloc: ansic: 897; makefile: 88; sh: 63
file content (74 lines) | stat: -rw-r--r-- 2,281 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
    This file is part of pload - a program to monitor ppp activity for X
    Copyright (C) 1999-2000  Matt Smith <mdsmith@engr.utk.edu>

    This program 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 of the License, or
    (at your option) any later version.

    This program 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 this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

/*
 * this function came from pppstats.c in the ppp-2.3.5 distributon
 * with the following copyright
 *
 */
 
/*
 * Copyright (c) 1989 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted
 * provided that the above copyright notice and this paragraph are
 * duplicated in all such forms and that any documentation,
 * advertising materials, and other materials related to such
 * distribution and use acknowledge that the software was developed
 * by the University of California, Berkeley.  The name of the
 * University may not be used to endorse or promote products derived
 * from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */


/* strioctl.c */

#ifdef STREAMS

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stropts.h>

#include "pload.h"

int strioctl(int fd, int cmd, void *ptr, int ilen, int olen)
{
	struct strioctl str;
	
	str.ic_cmd = cmd;
	str.ic_timout = 0;
	str.ic_len = ilen;
	str.ic_dp = ptr;
	
	if (ioctl(fd, I_STR, &str) == -1) return -1;
	
	if (str.ic_len != olen)
		fprintf(stderr,
		"strioctl: expected %d bytes, got %d for cmd 0x%x\n",
		olen, str.ic_len, cmd);
	return 0;
}

#endif