Remove unnecessary whitespace from C program text

This commit is contained in:
Arseny Maslennikov 2018-05-09 15:21:26 +03:00
parent bb48084aa0
commit 2440a17fbe
30 changed files with 192 additions and 192 deletions

4
adsl.c
View File

@ -68,12 +68,12 @@ static enum return_type adsl_connect(char * net_device, char * username, char *
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
close(fd);
setsid();
if (ioctl(0, TIOCSCTTY, NULL))
log_perror("could not set new controlling tty");
printf("\t(exec of pppd)\n");
execve(pppd_launch[0], pppd_launch, grab_env());
log_message("execve of %s failed: %s", pppd_launch[0], strerror(errno));

View File

@ -155,7 +155,7 @@ enum return_type ask_from_entries_auto(char *msg, char ** questions, char *** an
i++;
questions++;
questions_auto++;
}
*answers = memdup(tmp_answers, sizeof(char *) * i);
return RETURN_OK;

View File

@ -151,7 +151,7 @@ static enum return_type try_with_device(char * dev_name, char * dev_model)
if (results == RETURN_OK)
return try_with_device(dev_name, dev_model);
return results;
}
}
remove_wait_message();
return do_with_device(dev_name, dev_model);

View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/

82
dhcp.c
View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/
@ -109,7 +109,7 @@ static unsigned int verify_checksum(void * buf2, int length2)
for (sp = (unsigned short *) buf2; length2 > 0; (length2 -= 2), sp++)
csum += *sp;
while (csum >> 16)
csum = (csum & 0xffff) + (csum >> 16);
@ -122,20 +122,20 @@ static int initial_setup_interface(char * device, int s) {
struct ifreq req;
struct rtentry route;
int true = 1;
addrp = (struct sockaddr_in *) &req.ifr_addr;
strcpy(req.ifr_name, device);
addrp->sin_family = AF_INET;
addrp->sin_port = 0;
memset(&addrp->sin_addr, 0, sizeof(addrp->sin_addr));
req.ifr_flags = 0; /* take it down */
if (ioctl(s, SIOCSIFFLAGS, &req)) {
log_perror("SIOCSIFFLAGS (downing)");
return -1;
}
addrp->sin_family = AF_INET;
addrp->sin_addr.s_addr = htonl(0);
if (ioctl(s, SIOCSIFADDR, &req)) {
@ -151,17 +151,17 @@ static int initial_setup_interface(char * device, int s) {
memset(&route, 0, sizeof(route));
memcpy(&route.rt_gateway, addrp, sizeof(*addrp));
addrp->sin_family = AF_INET;
addrp->sin_port = 0;
addrp->sin_addr.s_addr = INADDR_ANY;
memcpy(&route.rt_dst, addrp, sizeof(*addrp));
memcpy(&route.rt_genmask, addrp, sizeof(*addrp));
route.rt_dev = device;
route.rt_flags = RTF_UP;
route.rt_metric = 0;
if (ioctl(s, SIOCADDRT, &route)) {
if (errno != EEXIST) {
close(s);
@ -169,7 +169,7 @@ static int initial_setup_interface(char * device, int s) {
return -1;
}
}
if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &true, sizeof(true))) {
close(s);
log_perror("setsockopt");
@ -237,7 +237,7 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int
memcpy(&intf->netmask, chptr, sizeof(intf->netmask));
log_message("got netmask %s", inet_ntoa(intf->netmask));
break;
case BOOTP_OPTION_DOMAIN:
memcpy(tmp_str, chptr, length);
tmp_str[length] = '\0';
@ -286,26 +286,26 @@ static char gen_hwaddr[16];
static int prepare_request(struct bootp_request * breq, int sock, char * device)
{
struct ifreq req;
memset(breq, 0, sizeof(*breq));
breq->opcode = BOOTP_OPCODE_REQUEST;
strcpy(req.ifr_name, device);
if (ioctl(sock, SIOCGIFHWADDR, &req)) {
log_perror("SIOCSIFHWADDR");
return -1;
}
breq->hw = 1; /* ethernet */
breq->hwlength = IFHWADDRLEN;
breq->hwlength = IFHWADDRLEN;
memcpy(breq->hwaddr, req.ifr_hwaddr.sa_data, IFHWADDRLEN);
memcpy(gen_hwaddr, req.ifr_hwaddr.sa_data, IFHWADDRLEN);
breq->hopcount = 0;
init_vendor_codes(breq);
return 0;
}
@ -313,7 +313,7 @@ static int get_vendor_code(struct bootp_request * bresp, unsigned char option, v
{
unsigned char * chptr;
unsigned int length, theOption;
chptr = bresp->vendor + 4;
while (*chptr != 0xFF && *chptr != option) {
theOption = *chptr++;
@ -322,13 +322,13 @@ static int get_vendor_code(struct bootp_request * bresp, unsigned char option, v
length = *chptr++;
chptr += length;
}
if (*chptr++ == 0xff)
return 1;
length = *chptr++;
memcpy(data, chptr, length);
return 0;
}
@ -338,9 +338,9 @@ static int currticks(void)
struct timeval tv;
long csecs;
int ticks_per_csec, ticks_per_usec;
/* Note: 18.2 ticks/sec. */
gettimeofday (&tv, 0);
csecs = tv.tv_sec / 10;
ticks_per_csec = csecs * 182;
@ -364,29 +364,29 @@ static void rfc951_sleep(int exp)
long l;
short s[3];
} hw;
if (exp > BACKOFF_LIMIT)
exp = BACKOFF_LIMIT;
if (!seed) {
/* Initialize linear congruential generator. */
memcpy(&hw.c, &gen_hwaddr, sizeof(gen_hwaddr));
seed = currticks() + hw.l + hw.s[2];
}
/* Simplified version of the LCG given in Bruce Scheier's
"Applied Cryptography". */
q = seed / 53668;
if ((seed = 40014 * (seed - 53668 * q) - 12211 * q) < 0)
seed += 2147483563l;
/* Compute mask. */
for (tmo = 63; tmo <= 60 * TICKS_PER_SEC && --exp > 0; tmo = 2 * tmo + 1)
;
/* Sleep. */
log_message("<sleep>");
for (tmo = (tmo & seed) + currticks (); currticks () < tmo;);
}
@ -422,7 +422,7 @@ static int handle_transaction(int s, struct bootp_request * breq, struct bootp_r
log_perror("sendto");
return -1;
}
polls.fd = sin;
polls.events = POLLIN;
@ -432,11 +432,11 @@ static int handle_transaction(int s, struct bootp_request * breq, struct bootp_r
log_perror("recv");
continue;
}
/* We need to do some basic sanity checking of the header */
if (j < (sizeof(*ip_hdr) + sizeof(*udp_hdr)))
continue;
ip_hdr = (void *) eth_packet;
if (!verify_checksum(ip_hdr, sizeof(*ip_hdr)))
continue;
@ -445,28 +445,28 @@ static int handle_transaction(int s, struct bootp_request * breq, struct bootp_r
continue;
j = ntohs(ip_hdr->tot_len);
if (ip_hdr->protocol != IPPROTO_UDP)
continue;
udp_hdr = (void *) (eth_packet + sizeof(*ip_hdr));
if (ntohs(udp_hdr->source) != BOOTP_SERVER_PORT)
continue;
if (ntohs(udp_hdr->dest) != BOOTP_CLIENT_PORT)
continue;
/* Go on with this packet; it looks sane */
/* Originally copied sizeof (*bresp) - this is a security
problem due to a potential underflow of the source
buffer. Also, it trusted that the packet was properly
0xFF terminated, which is not true in the case of the
DHCP server on Cisco 800 series ISDN router. */
memset (bresp, 0xFF, sizeof (*bresp));
memcpy (bresp, (char *) udp_hdr + sizeof (*udp_hdr), j - sizeof (*ip_hdr) - sizeof (*udp_hdr));
/* sanity checks */
if (bresp->id != breq->id)
continue;
@ -489,7 +489,7 @@ static int handle_transaction(int s, struct bootp_request * breq, struct bootp_r
if (timeout > 5)
timeout = 5;
}
return -1;
}

6
disk.c
View File

@ -75,7 +75,7 @@ static const char * detect_partition_type(char * dev)
struct partition_detection_anchor anchor0;
struct partition_detection_anchor anchor1;
struct partition_detection_anchor anchor2;
} partitions_signatures[] = {
} partitions_signatures[] = {
{ "Linux Swap", { 4086, "SWAP-SPACE" }, { 0, NULL }, { 0, NULL } },
{ "Linux Swap", { 4086, "SWAPSPACE2" }, { 0, NULL }, { 0, NULL } },
{ "Ext2", { 0x438, "\x53\xEF" }, { 0, NULL }, { 0, NULL } },
@ -104,7 +104,7 @@ static const char * detect_partition_type(char * dev)
log_perror("open");
return NULL;
}
for (i=0; i<partitions_signatures_nb; i++) {
int results = seek_and_compare(fd, partitions_signatures[i].anchor0);
if (results == -1)
@ -162,7 +162,7 @@ static enum return_type try_with_uuidlabel()
char devname[50];
struct stat statbuf;
int len;
strcpy(device_fullname, "/dev/disk/by-uuid/");
strcat(device_fullname, get_auto_value("uuid"));
if (stat(device_fullname, &statbuf) == 0 && S_ISBLK(statbuf.st_mode) &&

2
disk.h
View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/

32
dns.c
View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/
@ -54,7 +54,7 @@ int mygethostbyname(char * name, struct in_addr * addr)
} else
return -1;
}
if (h->h_addr_list && (h->h_addr_list)[0]) {
memcpy(addr, (h->h_addr_list)[0], sizeof(*addr));
log_message("is-at: %s", inet_ntoa(*addr));
@ -104,7 +104,7 @@ static int do_query(char * query, int queryType, char ** domainName, struct in_a
u_char * data, * end;
char name[MAXDNAME];
union dns_response response;
#ifdef __sparc__
/* from jj: */
/* We have to wait till ethernet negotiation is done */
@ -124,10 +124,10 @@ static int do_query(char * query, int queryType, char ** domainName, struct in_a
ancount = ntohs(response.hdr.ancount);
if (ancount < 1)
return -1;
data = response.buf + sizeof(HEADER);
end = response.buf + len;
/* skip the question */
data += dn_skipname(data, end) + QFIXEDSZ;
@ -161,11 +161,11 @@ static int do_query(char * query, int queryType, char ** domainName, struct in_a
return 0;
}
}
/* move ahead to next RR */
data += len;
}
}
return -1;
}
@ -178,28 +178,28 @@ char * mygethostbyaddr(char * ipnum) {
int i;
_res.retry = 1;
strbuf = alloca(strlen(ipnum) + 1);
strcpy(strbuf, ipnum);
ipnum = alloca(strlen(strbuf) + 20);
for (i = 0; i < 4; i++) {
chptr = strbuf;
while (*chptr && *chptr != '.')
chptr++;
*chptr = '\0';
if (chptr - strbuf > 3) return NULL;
splits[i] = strbuf;
strbuf = chptr + 1;
}
sprintf(ipnum, "%s.%s.%s.%s.in-addr.arpa", splits[3], splits[2], splits[1], splits[0]);
rc = do_query(ipnum, T_PTR, &result, NULL);
if (rc)
if (rc)
return NULL;
else
return result;

4
dns.h
View File

@ -15,12 +15,12 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/
#ifndef H_DNS
#define H_DNS
#define H_DNS
#include <netinet/in.h>

View File

@ -37,7 +37,7 @@ void info_message(char *msg, ...) __attribute__ ((format (printf, 1, 2))); /* (b
void error_message(char *msg, ...) __attribute__ ((format (printf, 1, 2))); /* (blocks program) */
/* (doesn't block program)
/* (doesn't block program)
* (this is not necessarily stackable, e.g. only one wait_message at a time) */
void wait_message(char *msg, ...) __attribute__ ((format (printf, 1, 2)));

View File

@ -347,7 +347,7 @@ static int cpio_mkfile(const char *name, const char *location,
offset += buf.st_size;
push_pad();
rc = 0;
error:
if (filebuf) free(filebuf);
if (file >= 0) close(file);

2
init.c
View File

@ -353,7 +353,7 @@ static void unmount_filesystems(void)
nb = 0;
for (i = 0; i < numfs; i++) {
/*printf("trying with %s\n", fs[i].name);*/
if (fs[i].mounted && umount(fs[i].name) == 0) {
if (fs[i].mounted && umount(fs[i].name) == 0) {
if (strncmp(fs[i].dev + sizeof("/dev/") - 1, "loop",
sizeof("loop") - 1) == 0)
del_loop(fs[i].dev);

4
log.c
View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/
@ -58,7 +58,7 @@ void log_message(const char * s, ...)
va_start(args, s);
vlog_message(s, args);
va_end(args);
return;
}

2
log.h
View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/

View File

@ -69,7 +69,7 @@ set_loop (const char *device, const char *file)
if ((ffd = open (file, mode)) < 0)
return 1;
for (i=3; i && (fd = open(device, mode)) < 0; --i, sleep(1));
if (fd < 0) {
close(ffd);
@ -81,12 +81,12 @@ set_loop (const char *device, const char *file)
loopinfo.lo_name[LO_NAME_SIZE - 1] = 0;
loopinfo.lo_offset = 0;
#ifdef MCL_FUTURE
#ifdef MCL_FUTURE
/*
* Oh-oh, sensitive data coming up. Better lock into memory to prevent
* passwd etc being swapped out and left somewhere on disk.
*/
if(mlockall(MCL_CURRENT|MCL_FUTURE)) {
log_message("CRITICAL Couldn't lock into memory! %s (memlock)", strerror(errno));
return 1;
@ -123,7 +123,7 @@ void del_loop(char *device)
if (ioctl (fd, LOOP_CLR_FD, 0) < 0)
return;
close (fd);
}
@ -133,7 +133,7 @@ static char * where_mounted = NULL;
int
lomount(char *loopfile, char *where)
{
long int flag;
flag = MS_MGC_VAL;
@ -145,7 +145,7 @@ lomount(char *loopfile, char *where)
log_message("set_loop failed on %s (%s)", loopdev, strerror(errno));
return 1;
}
if (my_mount(loopdev, where, "iso9660", 0)) {
del_loop(loopdev);
return 1;

View File

@ -90,7 +90,7 @@ int insmod_call(char *pathname, char *params)
void *file;
unsigned long len;
int rc = -1;
file = grab_file(pathname, &len);
if (!file) {
log_message("insmod: can't read '%s': %s", pathname, strerror(errno));

View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/
@ -52,7 +52,7 @@ int ensure_dev_exists(char *dev)
char * name;
struct stat buf;
char * ptr;
name = &dev[5]; /* we really need that dev be passed as /dev/something.. */
if (!stat(dev, &buf))
@ -86,7 +86,7 @@ int ensure_dev_exists(char *dev)
major = 34, minor = 64;
else
return -1;
if (name[3] && name[4])
minor += 10 + (name[4] - '0');
else if (name[3])
@ -122,7 +122,7 @@ int ensure_dev_exists(char *dev)
log_perror(dev);
return -1;
}
return 0;
}
#endif /* DISABLE_MEDIAS */

View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/

View File

@ -65,19 +65,19 @@ int configure_net_device(struct interface_info * intf)
struct sockaddr_in addr;
struct in_addr ia;
char ip[20], nm[20], nw[20], bc[20];
addr.sin_family = AF_INET;
addr.sin_port = 0;
memcpy(&ia, &intf->ip, sizeof(intf->ip));
strcpy(ip, inet_ntoa(ia));
memcpy(&ia, &intf->netmask, sizeof(intf->netmask));
strcpy(nm, inet_ntoa(ia));
memcpy(&ia, &intf->broadcast, sizeof(intf->broadcast));
strcpy(bc, inet_ntoa(ia));
memcpy(&ia, &intf->network, sizeof(intf->network));
strcpy(nw, inet_ntoa(ia));
@ -106,7 +106,7 @@ int configure_net_device(struct interface_info * intf)
return 1;
}
}
/* sets IP address */
addr.sin_port = 0;
memcpy(&addr.sin_addr, &intf->ip, sizeof(intf->ip));
@ -154,10 +154,10 @@ int configure_net_device(struct interface_info * intf)
memset(&route, 0, sizeof(route));
route.rt_dev = intf->device;
route.rt_flags = RTF_UP;
memcpy(&addr.sin_addr, &intf->network, sizeof(intf->network));
memcpy(&route.rt_dst, &addr, sizeof(addr));
memcpy(&addr.sin_addr, &intf->netmask, sizeof(intf->netmask));
memcpy(&route.rt_genmask, &addr, sizeof(addr));
@ -185,7 +185,7 @@ int configure_net_device(struct interface_info * intf)
return 0;
}
/* host network informations */
/* host network informations */
char * hostname = NULL;
char * domain = NULL;
char * rootpath = NULL;
@ -238,7 +238,7 @@ static int add_default_route(void)
}
close(s);
return 0;
}
@ -246,7 +246,7 @@ static int add_default_route(void)
static int write_resolvconf(void) {
char * filename = "/etc/resolv.conf";
FILE * f;
if (dns_server.s_addr == 0) {
log_message("resolvconf needs a dns server");
return -1;
@ -275,10 +275,10 @@ static int save_netinfo(struct interface_info * intf) {
char mask[12];
unsigned m, hl;
int i;
if (hostname)
add_to_env("HOSTNAME", hostname);
if (domain)
add_to_env("DOMAINNAME", domain);
@ -287,7 +287,7 @@ static int save_netinfo(struct interface_info * intf) {
if (dns_server2.s_addr != 0)
add_to_env("DNS_SERVER2", inet_ntoa(dns_server2));
if (gateway.s_addr != 0)
add_to_env("GATEWAY", inet_ntoa(gateway));
@ -327,12 +327,12 @@ char * guess_netmask(char * ip_addr)
log_message("guessing netmask");
tmp = ntohl(addr.s_addr);
if (((tmp & 0xFF000000) >> 24) <= 127)
return "255.0.0.0";
else if (((tmp & 0xFF000000) >> 24) <= 191)
return "255.255.0.0";
else
else
return "255.255.255.0";
}
@ -363,13 +363,13 @@ static void static_ip_callback(char ** strings)
static enum return_type setup_network_interface(struct interface_info * intf)
{
enum return_type results;
#ifndef DISABLE_ADSL
#ifndef DISABLE_ADSL
char * bootprotos[] = { "Static", "DHCP", "ADSL", NULL };
char * bootprotos_auto[] = { "static", "dhcp", "adsl" };
#else
char * bootprotos[] = { "Static", "DHCP", NULL };
char * bootprotos_auto[] = { "static", "dhcp" };
#endif
#endif
char * choice;
results = ask_from_list_auto("Please choose the desired IP attribution.", bootprotos, &choice, "network", bootprotos_auto);
@ -446,10 +446,10 @@ static enum return_type setup_network_interface(struct interface_info * intf)
return setup_network_interface(intf);
if (results == RETURN_ERROR)
return results;
#endif
#endif
} else
return RETURN_ERROR;
return add_default_route();
}
@ -491,16 +491,16 @@ static enum return_type configure_network(struct interface_info * intf)
char * questions_auto[] = { "hostname", "domain" };
static char ** answers = NULL;
char * boulet;
log_message("reverse name lookup on DNS failed");
results = ask_from_entries_auto("I could not guess hostname and domain name; please fill in this information. "
"Valid answers are for example: `mybox' for hostname and `mynetwork.com' for "
"domain name, for a machine called `mybox.mynetwork.com' on the Internet.",
questions, &answers, 32, questions_auto, NULL);
if (results != RETURN_OK)
return results;
hostname = answers[0];
if ((boulet = strchr(hostname, '.')) != NULL)
boulet[0] = '\0';
@ -515,7 +515,7 @@ static enum return_type bringup_networking(struct interface_info * intf)
{
static struct interface_info loopback;
enum return_type results = RETURN_ERROR;
my_insmod("af_packet", NULL);
while (results != RETURN_OK) {
@ -702,7 +702,7 @@ enum return_type nfs_prepare(void)
if (my_mount(nfsmount_location, IMAGE_LOCATION, "nfs", 0) == -1) {
char location_full[500];
char *s;
/* iso pathname ? */
s = strrchr(nfsmount_location, '/');
if (s == NULL || s == nfsmount_location) {
@ -710,7 +710,7 @@ enum return_type nfs_prepare(void)
results = RETURN_BACK;
continue;
}
*s++ = 0;
log_message("assuming ISO image, NFS path:%s", nfsmount_location);
if (my_mount(nfsmount_location, IMAGE_LOCATION, "nfs", 0) == -1) {
@ -718,11 +718,11 @@ enum return_type nfs_prepare(void)
results = RETURN_BACK;
continue;
}
strcpy(location_full, IMAGE_LOCATION);
strcat(location_full, "/");
strcat(location_full, s);
log_message("assuming ISO image, path:%s", location_full);
if (!stat(location_full, &st) && !S_ISREG(st.st_mode)) {
stg1_error_message("Not a ISO image: %s", location_full);
@ -844,7 +844,7 @@ enum return_type ftp_prepare(void)
}
log_message("FTP: size of download %d bytes", size);
results = load_ramdisk_fd(fd, size);
if (results == RETURN_OK)
ftp_end_data_command(ftp_serv_response);
@ -908,7 +908,7 @@ enum return_type http_prepare(void)
free(tmp);
log_message("HTTP: trying to retrieve %s", location_full);
fd = http_download_file(answers[0], location_full, &size);
if (fd < 0) {
log_message("HTTP: error %d", fd);
@ -921,7 +921,7 @@ enum return_type http_prepare(void)
}
log_message("HTTP: size of download %d bytes", size);
if (load_ramdisk_fd(fd, size) != RETURN_OK)
return RETURN_ERROR;

View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/

View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/
@ -42,9 +42,9 @@ void init_frontend(char * welcome_msg)
for (i=0; i<38; i++) printf("\n");
newtInit();
newtCls();
newtDrawRootText(0, 0, welcome_msg);
newtPushHelpLine(" <Alt-F1> for here, <Alt-F3> to see the logs, <Alt-F4> for kernel msg");
newtRefresh();
}
@ -79,7 +79,7 @@ void vwait_message(char *msg, va_list ap)
char * flowed;
int size = 0;
int i = 0;
do {
size += 1000;
if (buf) free(buf);
@ -88,7 +88,7 @@ void vwait_message(char *msg, va_list ap)
} while (i >= size || i == -1);
flowed = newtReflowText(buf, 60, 5, 5, &width, &height);
c = newtTextbox(-1, -1, width, height, NEWT_TEXTBOX_WRAP);
newtTextboxSetText(c, flowed);
@ -264,7 +264,7 @@ static void default_callback(newtComponent co, void * data)
}
/* only supports up to 50 buttons and entries -- shucks! */
static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int flexDown,
static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int flexDown,
int flexUp, int dataWidth, void (*callback_func)(char ** strings),
struct newtWinEntry * items, char * button1, ...) {
newtComponent buttons[50], result, form, textw;
@ -276,12 +276,12 @@ static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int f
newtComponent entries[50];
va_list args;
textw = newtTextboxReflowed(-1, -1, text, suggestedWidth, flexDown,
flexUp, 0);
for (numItems = 0; items[numItems].text; numItems++);
for (numItems = 0; items[numItems].text; numItems++);
buttonName = button1, numButtons = 0;
va_start(args, button1);
while (buttonName) {
@ -289,12 +289,12 @@ static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int f
numButtons++;
buttonName = va_arg(args, char *);
}
va_end(args);
buttonBar = newtCreateGrid(numButtons, 1);
for (i = 0; i < numButtons; i++) {
newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT,
newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT,
buttons[i],
i ? 1 : 0, 0, 0, 0, 0, 0);
}
@ -305,10 +305,10 @@ static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int f
}
else
callback_real_function = NULL;
subgrid = newtCreateGrid(2, numItems);
for (i = 0; i < numItems; i++) {
newtComponent entr = newtEntry(-1, -1, items[i].value ?
newtComponent entr = newtEntry(-1, -1, items[i].value ?
*items[i].value : NULL, dataWidth,
(const char **) items[i].value, items[i].flags);
@ -323,34 +323,34 @@ static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int f
newtComponentAddCallback(entr, default_callback, entries);
}
}
grid = newtCreateGrid(1, 3);
form = newtForm(NULL, 0, 0);
newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, textw,
newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, textw,
0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, subgrid,
newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, subgrid,
0, 1, 0, 0, 0, 0);
newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttonBar,
newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttonBar,
0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
newtGridAddComponentsToForm(grid, form, 1);
newtGridWrappedWindow(grid, title);
newtGridFree(grid, 1);
result = newtRunForm(form);
for (rc = 0; rc < numItems; rc++)
*items[rc].value = strdup(*items[rc].value);
for (rc = 0; result != buttons[rc] && rc < numButtons; rc++);
if (rc == numButtons)
if (rc == numButtons)
rc = 0; /* F12 */
else
else
rc++;
newtFormDestroy(form);
newtPopWindow();
return rc;
}
@ -386,12 +386,12 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers
}
splash_verbose();
rc = mynewtWinEntries("Please fill entries...", msg, 52, 5, 5, entry_size, callback_func, entries, "Ok", "Cancel", NULL);
rc = mynewtWinEntries("Please fill entries...", msg, 52, 5, 5, entry_size, callback_func, entries, "Ok", "Cancel", NULL);
if (rc == 3)
return RETURN_BACK;
if (rc != 1)
return RETURN_ERROR;
return RETURN_OK;
}

View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/
@ -93,7 +93,7 @@ char * get_net_intf_description(char * intf_name)
char dev[SYSFS_PATH_MAX];
char drv[SYSFS_PATH_MAX];
ssize_t i;
snprintf(dev, SYSFS_PATH_MAX, "/sys/class/net/%s/device/driver", intf_name);
if ((i = readlink(dev, drv, SYSFS_PATH_MAX)) > 0) {
drv[i] = '\0';
@ -273,7 +273,7 @@ static int net_device_available(char * device)
{
struct ifreq req;
int s;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0) {
log_perror(device);

View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/

View File

@ -269,7 +269,7 @@ void sha256_finish( sha256_context *ctx, uint8 digest[32] )
* those are the standard FIPS-180-2 test vectors
*/
static char *msg[] =
static char *msg[] =
{
"abc",
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",

View File

@ -18,7 +18,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/
@ -135,12 +135,12 @@ static void spawn_shell(void)
log_message("cannot open shell - %s doesn't exist", shell_name[0]);
return;
}
if (!(shell_pid = fork())) {
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
close(fd);
setsid();
if (ioctl(0, TIOCSCTTY, NULL))
@ -150,7 +150,7 @@ static void spawn_shell(void)
log_message("execve of %s failed: %s", shell_name[0], strerror(errno));
exit(-1);
}
close(fd);
}
#endif
@ -295,14 +295,14 @@ static enum return_type method_select_and_prepare(void)
if (!strcmp(choice, disk_install))
results = disk_prepare();
#endif
#ifndef DISABLE_NETWORK
if (!strcmp(choice, network_nfs_install))
results = nfs_prepare();
if (!strcmp(choice, network_ftp_install))
results = ftp_prepare();
if (!strcmp(choice, network_http_install))
results = http_prepare();
#endif
@ -317,7 +317,7 @@ void getversion()
{
FILE *f;
char *c;
if (!(f = fopen(VERSION_FILE, "r"))) return;
if (fgets(version, sizeof(version), f)) {
c = strrchr(version, '\n');

View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/

View File

@ -50,7 +50,7 @@ static void get_any_response(void)
while (read(0, &t, 1) > 0);
fcntl(0, F_SETFL, 0);
}
static int get_int_response(void)
{
char s[50];
@ -85,7 +85,7 @@ static char * get_string_response(char * initial_string)
strcpy(s, initial_string);
i = strlen(s);
}
/* from ncurses/tinfo/lib_raw.c:(cbreak) */
tcgetattr(0, &t);
t.c_lflag &= ~ICANON;
@ -127,7 +127,7 @@ static char * get_string_response(char * initial_string)
b_index = 0;
continue;
}
if (b == 13)
break;
if (b == 127) {
@ -154,7 +154,7 @@ static char * get_string_response(char * initial_string)
t.c_lflag |= ICANON;
t.c_lflag |= ECHO;
t.c_iflag |= ICRNL;
t.c_iflag |= ICRNL;
tcsetattr(0, TCSADRAIN, &t);
fcntl(0, F_SETFL, 0);
@ -222,7 +222,7 @@ void update_progression(int current_size)
}
} else
printf("\033[GStatus: [%8d] bytes loaded...", current_size);
fflush(stdout);
}
@ -277,14 +277,14 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
}
if (j == 4)
j = 0;
if (elems_comments)
elems_comments++;
i++;
elems++;
}
printf("\n? ");
printf("\n? ");
j = get_int_response();

12
tools.c
View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/
@ -62,12 +62,12 @@ void process_cmdline(void)
{
char buf[512];
int fd, size, i;
log_message("opening /proc/cmdline... ");
if ((fd = open("/proc/cmdline", O_RDONLY)) == -1)
fatal_error("could not open /proc/cmdline");
size = read(fd, buf, sizeof(buf));
buf[size-1] = '\0'; // -1 to eat the \n
close(fd);
@ -126,7 +126,7 @@ void process_cmdline(void)
break;
i++;
}
log_message("\tgot %d args", param_number);
}
@ -309,7 +309,7 @@ enum return_type load_ramdisk_fd(int source_fd, unsigned long size)
stg1_error_message("Could not open ramdisk device file.");
return RETURN_ERROR;
}
init_progression(wait_msg, (int)size);
while ((actually = read(source_fd, buffer, sizeof(buffer))) > 0) {

View File

@ -15,7 +15,7 @@
/*
* Portions from Erik Troan (ewt@redhat.com)
*
* Copyright 1996 Red Hat Software
* Copyright 1996 Red Hat Software
*
*/

34
url.c
View File

@ -56,15 +56,15 @@
static int ftp_check_response(int sock, char ** str)
{
static char buf[BUFFER_SIZE + 1];
int bufLength = 0;
int bufLength = 0;
struct pollfd polls;
char * chptr, * start;
int bytesRead, rc = 0;
int doesContinue = 1;
char errorCode[4];
errorCode[0] = '\0';
do {
polls.fd = sock;
polls.events = POLLIN;
@ -77,7 +77,7 @@ static int ftp_check_response(int sock, char ** str)
buf[bufLength] = '\0';
/* divide the response into lines, checking each one to see if
/* divide the response into lines, checking each one to see if
we are finished or need to continue */
start = chptr = buf;
@ -98,7 +98,7 @@ static int ftp_check_response(int sock, char ** str)
errorCode[3] = '\0';
if (start[3] != '-') {
doesContinue = 0;
}
}
}
start = chptr + 1;
@ -139,9 +139,9 @@ static int ftp_command(int sock, char * command, char * param)
strcat(buf, " ");
strcat(buf, param);
}
strcat(buf, "\r\n");
if (write(sock, buf, strlen(buf)) != strlen(buf)) {
return FTPERR_SERVER_IO_ERROR;
}
@ -162,7 +162,7 @@ static int get_host_address(char * host, struct in_addr * address)
if (mygethostbyname(host, address))
return FTPERR_BAD_HOSTNAME;
}
return 0;
}
@ -210,7 +210,7 @@ int ftp_open_connection(char * host, char * name, char * password, char * proxy)
}
if ((rc = ftp_check_response(sock, NULL))) {
return rc;
return rc;
}
if ((rc = ftp_command(sock, "USER", name))) {
@ -250,7 +250,7 @@ int ftp_data_command(int sock, char * command, char * param)
chptr = passReply;
while (*chptr && *chptr != '(') chptr++;
if (*chptr != '(') return FTPERR_PASSIVE_ERROR;
if (*chptr != '(') return FTPERR_PASSIVE_ERROR;
chptr++;
passReply = chptr;
while (*chptr && *chptr != ')') chptr++;
@ -263,7 +263,7 @@ int ftp_data_command(int sock, char * command, char * param)
while (*chptr && *chptr != ',') chptr--;
if (*chptr != ',') return FTPERR_PASSIVE_ERROR;
*chptr++ = '\0';
/* now passReply points to the IP portion, and chptr points to the
port number portion */
@ -278,7 +278,7 @@ int ftp_data_command(int sock, char * command, char * param)
if (*chptr == ',') *chptr = '.';
}
if (!inet_aton(passReply, &dataAddress.sin_addr))
if (!inet_aton(passReply, &dataAddress.sin_addr))
return FTPERR_PASSIVE_ERROR;
dataSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
@ -290,15 +290,15 @@ int ftp_data_command(int sock, char * command, char * param)
sprintf(retrCommand, "%s\r\n", command);
else
sprintf(retrCommand, "%s %s\r\n", command, param);
i = strlen(retrCommand);
if (write(sock, retrCommand, i) != i) {
close(dataSocket);
return FTPERR_SERVER_IO_ERROR;
}
if (connect(dataSocket, (struct sockaddr *) &dataAddress,
if (connect(dataSocket, (struct sockaddr *) &dataAddress,
sizeof(dataAddress))) {
close(dataSocket);
return FTPERR_FAILED_DATA_CONNECT;
@ -390,11 +390,11 @@ int ftp_end_data_command(int sock)
{
if (ftp_check_response(sock, NULL))
return FTPERR_BAD_SERVER_RESPONSE;
return 0;
}
int http_download_file(char * hostname, char * remotename, int * size)
{
char * buf;