Sfoglia il codice sorgente

libdpkg: New m_output function

This function makes sure to output the information printed on the file
specified, and ohshites if there's any error.
Guillem Jover 17 anni fa
parent
commit
7121152571
2 ha cambiato i file con 9 aggiunte e 0 eliminazioni
  1. 1 0
      lib/dpkg/dpkg.h
  2. 8 0
      lib/dpkg/mlib.c

+ 1 - 0
lib/dpkg/dpkg.h

@@ -205,6 +205,7 @@ char *m_strdup(const char *str);
 int m_fork(void);
 void m_dup2(int oldfd, int newfd);
 void m_pipe(int fds[2]);
+void m_output(FILE *f, const char *name);
 
 /*** from utils.c ***/
 

+ 8 - 0
lib/dpkg/mlib.c

@@ -116,6 +116,14 @@ void m_pipe(int *fds) {
   ohshite(_("failed to create pipe"));
 }
 
+void
+m_output(FILE *f, const char *name)
+{
+  fflush(f);
+  if (ferror(f))
+    ohshite(_("error writing to '%s'"), name);
+}
+
 void setcloexec(int fd, const char* fn) {
   int f;