Whitespace fixes. Indented the code following Linux styleguide to fix

the mess between tabs and spaces.
This commit is contained in:
Oliver Hartkopp
2008-06-03 08:46:57 +00:00
parent 8a5c0365e6
commit adbe6f9bee
12 changed files with 2560 additions and 2560 deletions
+51 -51
View File
@@ -60,66 +60,66 @@
int main(int argc, char **argv)
{
int s; /* can raw socket */
int nbytes;
struct sockaddr_can addr;
struct can_frame frame;
struct ifreq ifr;
int s; /* can raw socket */
int nbytes;
struct sockaddr_can addr;
struct can_frame frame;
struct ifreq ifr;
/* check command line options */
if (argc != 3) {
fprintf(stderr, "Usage: %s <device> <can_frame>.\n", argv[0]);
return 1;
}
/* check command line options */
if (argc != 3) {
fprintf(stderr, "Usage: %s <device> <can_frame>.\n", argv[0]);
return 1;
}
/* parse CAN frame */
if (parse_canframe(argv[2], &frame)){
fprintf(stderr, "\nWrong CAN-frame format!\n\n");
fprintf(stderr, "Try: <can_id>#{R|data}\n");
fprintf(stderr, "can_id can have 3 (SFF) or 8 (EFF) hex chars\n");
fprintf(stderr, "data has 0 to 8 hex-values that can (optionally)");
fprintf(stderr, " be seperated by '.'\n\n");
fprintf(stderr, "e.g. 5A1#11.2233.44556677.88 / 123#DEADBEEF / ");
fprintf(stderr, "5AA# /\n 1F334455#1122334455667788 / 123#R ");
fprintf(stderr, "for remote transmission request.\n\n");
return 1;
}
/* parse CAN frame */
if (parse_canframe(argv[2], &frame)){
fprintf(stderr, "\nWrong CAN-frame format!\n\n");
fprintf(stderr, "Try: <can_id>#{R|data}\n");
fprintf(stderr, "can_id can have 3 (SFF) or 8 (EFF) hex chars\n");
fprintf(stderr, "data has 0 to 8 hex-values that can (optionally)");
fprintf(stderr, " be seperated by '.'\n\n");
fprintf(stderr, "e.g. 5A1#11.2233.44556677.88 / 123#DEADBEEF / ");
fprintf(stderr, "5AA# /\n 1F334455#1122334455667788 / 123#R ");
fprintf(stderr, "for remote transmission request.\n\n");
return 1;
}
/* open socket */
if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
perror("socket");
return 1;
}
/* open socket */
if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
perror("socket");
return 1;
}
addr.can_family = AF_CAN;
addr.can_family = AF_CAN;
strcpy(ifr.ifr_name, argv[1]);
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
perror("SIOCGIFINDEX");
return 1;
}
addr.can_ifindex = ifr.ifr_ifindex;
strcpy(ifr.ifr_name, argv[1]);
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
perror("SIOCGIFINDEX");
return 1;
}
addr.can_ifindex = ifr.ifr_ifindex;
/* disable default receive filter on this RAW socket */
/* This is obsolete as we do not read from the socket at all, but for */
/* this reason we can remove the receive list in the Kernel to save a */
/* little (really a very little!) CPU usage. */
setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0);
/* disable default receive filter on this RAW socket */
/* This is obsolete as we do not read from the socket at all, but for */
/* this reason we can remove the receive list in the Kernel to save a */
/* little (really a very little!) CPU usage. */
setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0);
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("bind");
return 1;
}
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("bind");
return 1;
}
/* send frame */
if ((nbytes = write(s, &frame, sizeof(frame))) != sizeof(frame)) {
perror("write");
return 1;
}
/* send frame */
if ((nbytes = write(s, &frame, sizeof(frame))) != sizeof(frame)) {
perror("write");
return 1;
}
//fprint_long_canframe(stdout, &frame, "\n", 0);
//fprint_long_canframe(stdout, &frame, "\n", 0);
close(s);
close(s);
return 0;
return 0;
}