## Private installation tree for packagers.
DESTDIR =
+###--------------------------------------------------------------------------
+### Quiet building.
+
+## Verbosity.
+V = 0
+
+## Compilation.
+V_CC = $(V_CC_$(V))$(CC)
+V_CC_0 = @echo " CC $@";
+
+## Linking.
+V_LD = $(V_LD_$(V))$(LD)
+V_LD_0 = @echo " LD $@";
+
+## Generation.
+V_GEN = $(V_GEN_$(V))
+V_GEN_0 = @echo " GEN $@";
+
###--------------------------------------------------------------------------
### Build parameters.
## Building sources.
%.o: %.c
- $(CC) -c $(REAL_CFLAGS) $< -o $@
+ $(V_CC) -c $(REAL_CFLAGS) $< -o $@
## Constructing preload hacks.
noip.so: $(patsubst %.c, %.o, $(NOIP_SOURCES))
- $(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
+ $(V_LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
uopen.so: $(patsubst %.c, %.o, $(UOPEN_SOURCES))
- $(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
+ $(V_LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
## Constructing the scripts.
-$(SCRIPTS): withlib.in
- for i in $(SCRIPTS); do \
- sed "s/@lib@/$$i/" withlib.in >$$i.new || exit 1; \
- chmod +x $$i.new || exit 1; \
- mv $$i.new $$i || exit 1; \
- done
+$(SCRIPTS): %: withlib.in
+ $(V_GEN)sed "s/@lib@/$@/" withlib.in >$@.new && \
+ chmod +x $@.new && mv $@.new $@
###--------------------------------------------------------------------------
### Installation.
_(sendto, ssize_t, (int, const void *buf, size_t, int, \
const struct sockaddr *to, socklen_t tolen)) \
_(recvfrom, ssize_t, (int, void *buf, size_t, int, \
- struct sockaddr *from, socklen_t *fromlen)) \
+ struct sockaddr *from, socklen_t *fromlen)) \
_(sendmsg, ssize_t, (int, const struct msghdr *, int)) \
- _(recvmsg, ssize_t, (int, struct msghdr *, int)) \
- _(close, int, (int))
+ _(recvmsg, ssize_t, (int, struct msghdr *, int))
/* Function pointers to set up. */
#define DECL(imp, ret, args) static ret (*real_##imp) args;
rc = USED;
if ((fp = fopen("/proc/net/unix", "r")) == 0)
goto done;
- fgets(buf, sizeof(buf), fp); /* skip header */
+ if (!fgets(buf, sizeof(buf), fp)) goto done; /* skip header */
len = strlen(sun->sun_path);
while (fgets(buf, sizeof(buf), fp)) {
n = strlen(buf);
{
char buf[INET_ADDRSTRLEN + 16];
char *p;
- size_t n = strlen(sockdir), nn = strlen(sun->sun_path);
+ size_t n = strlen(sockdir), nn;
struct sockaddr_in sin_mine;
unsigned long port;
sin = &sin_mine;
if (sun->sun_family != AF_UNIX)
return (-1);
+ nn = strlen(sun->sun_path);
if (len < sizeof(sun)) ((char *)sun)[len] = 0;
D( fprintf(stderr, "noip: decode (%d) `%s'",
*sun->sun_path, sun->sun_path); )
len = sizeof(ov_); \
if (real_getsockopt(sk, SOL_SOCKET, SO_##opt, &ov_, &len) < 0 || \
real_setsockopt(nsk, SOL_SOCKET, SO_##opt, &ov_, len)) { \
- real_close(nsk); \
+ close(nsk); \
return (-1); \
} \
} while (0);
(fd = fcntl(sk, F_GETFD)) < 0 ||
fcntl(nsk, F_SETFL, f) < 0 ||
dup2(nsk, sk) < 0) {
- real_close(nsk);
+ close(nsk);
return (-1);
}
unlink(sun.sun_path);
- real_close(nsk);
+ close(nsk);
if (fcntl(sk, F_SETFD, fd) < 0) {
perror("noip: fixup_real_ip_socket F_SETFD");
abort();
return;
for (i = n_local_ipaddrs = 0;
n_local_ipaddrs < MAX_LOCAL_IPADDRS &&
- ifn[i].if_name && *ifn[i].if_name;
+ ifn[i].if_name && *ifn[i].if_name;
i++) {
strcpy(ifr.ifr_name, ifn[i].if_name);
if (ioctl(sk, SIOCGIFADDR, &ifr) || ifr.ifr_addr.sa_family != AF_INET)
}
/* Print the given message to standard error. Avoids stdio. */
-static void printerr(const char *p) { write(STDERR_FILENO, p, strlen(p)); }
+static void printerr(const char *p)
+ { int hunoz; hunoz = write(STDERR_FILENO, p, strlen(p)); }
/* Create the socket directory, being careful about permissions. */
static void create_sockdir(void)