File: convert.c

package info (click to toggle)
fdutils 5.3-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,004 kB
  • ctags: 621
  • sloc: ansic: 6,098; sh: 2,236; makefile: 279; sed: 4
file content (83 lines) | stat: -rw-r--r-- 1,366 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
75
76
77
78
79
80
81
82
83
/* setfdprm.c  -  Sets user-provided floppy disk parameters, re-activates
		  autodetection and switches diagnostic messages. */

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <linux/fd.h>
#include "oldfdprm.h"
#include "printfdprm.h"

#define FDPRMFILE "/etc/fdprm"
#define MAXLINE   200

static int col = 0;

static int cpm=1;
level_t level = LEV_NONE;

static void print_token(char *fmt, int param)
{
	char buffer[50];
	int l;

	sprintf(buffer, fmt, param);
	l = strlen(buffer);

	if(l + col > 70) {
		printf("\n");
		col = 1;
	}
	printf(" %s", buffer);
	col += l+1;
}


static void _print_params(char *name, char *comment, struct floppy_struct *ft)
{
	printf("\n\"%s\":", name);
	if(comment)
		printf(" #%s", comment);
	else
		printf("\n");
	col = 0;
	print_params(0, ft, level, cpm, print_token);
}

static void usage(char *name)
{
}


void main(int argc,char **argv)
{
	struct floppy_struct ft;
	char *name = argv[0];

	
	if (argc > 1 && *argv[1] == '-') {
		switch (argv[1][1]) {
			case 'e':
				level = LEV_EXPL;
				break;
			case 'm':
				level = LEV_MOST;
				break;
			case 'a':
				level = LEV_ALL;
				break;
			default:
				usage(name);
		}
		argc--;
		argv++;
	}	

	scan_fdprm(stdin, 0, &ft, _print_params);
	exit(0);
}