changeset: 62:8baac73b9c9c
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Mon Mar 05 15:03:34 2007 +0100
summary: eliminated warnings in process.c
diff -r 7b528bbd72b2 -r 8baac73b9c9c process.c
--- a/process.c Mon Mar 05 14:57:47 2007 +0100
+++ b/process.c Mon Mar 05 15:03:34 2007 +0100
@@ -23,6 +23,8 @@ extern int grantpt(int fd);
extern int grantpt(int fd);
extern int unlockpt(int fd);
+/* static */
+
static unsigned char output_buf[512];
static unsigned int startptr = 0; /* index into output_buf to where data starts */
static unsigned int endptr = 0; /* index into output_buf to where data ends */
@@ -31,7 +33,7 @@ static int slave;
static int slave;
char *ptydev, *ttydev;
-void
+static void
sigchld_handler(int a) {
int status = 0;
@@ -51,7 +53,7 @@ sigchld_handler(int a) {
exit(0);
}
-struct passwd *
+static struct passwd *
find_user(void) {
uid_t uid;
struct passwd *pw;
@@ -67,7 +69,7 @@ find_user(void) {
return pw;
}
-int
+static int
get_pty(void) {
extern char *ptsname();
int fd;
@@ -88,16 +90,7 @@ get_pty(void) {
return -1;
}
-int
-resize_app(void) {
- if(ioctl(cmd_fd, TIOCSWINSZ, get_font_dim()) < 0) {
- fprintf(stderr, "Couldn't set window size: %m\n");
- return -1;
- }
- return 0;
-}
-
-int
+static int
get_tty(void) {
int i;
@@ -120,10 +113,65 @@ get_tty(void) {
return 0;
}
+static void
+fill_buffer(int fd) {
+ int len;
+
+ wait_for_input();
+ len = read(fd, &output_buf[0], sizeof(output_buf));
+ if(len < 0) {
+ fprintf(stderr, "Error reading from command: %m\n");
+ exit(1);
+ }
+ if(len == 0) {
+ fprintf(stderr, "No more data! exiting.\n");
+ exit(1);
+ }
+ endptr = len;
+ startptr = 0;
+}
+
+/* extern */
+
+unsigned char
+cmdgetc() {
+ unsigned char r;
+
+ if(startptr >= endptr) /* there is no more data available */
+ fill_buffer(cmd_fd);
+ r = output_buf[startptr];
+#if 0
+ /* For debugging purposes :) Produces quite a lot of output. */
+ fprintf(stderr, " %02x %c ", r, isprint(r)?r:'.');
+ bla++;
+ if(bla % 10 == 0)
+ fprintf(stderr, "\n");
+#endif
+ startptr++;
+ return r;
+}
+
+int
+cmd_write(const char *buf, int len) {
+ if(write(cmd_fd, buf, len) < 0) {
+ fprintf(stderr, "Error writing to process: %m\n");
+ exit(2);
+ }
+ return 0;
+}
+
+int
+resize_app(void) {
+ if(ioctl(cmd_fd, TIOCSWINSZ, get_font_dim()) < 0) {
+ fprintf(stderr, "Couldn't set window size: %m\n");
+ return -1;
+ }
+ return 0;
+}
+
int
execute_command(int argc, const char **argv) {
char **args;
- int master;
struct passwd *pw;
pw = find_user();
@@ -156,7 +204,6 @@ execute_command(int argc, const char **a
void
wait_for_input(void) {
- int len;
fd_set fset;
struct timeval tv;
int r;
@@ -202,49 +249,3 @@ wait_for_input(void) {
}
}
-void
-fill_buffer(int fd) {
- int len;
-
- wait_for_input();
- len = read(fd, &output_buf[0], sizeof(output_buf));
- if(len < 0) {
- fprintf(stderr, "Error reading from command: %m\n");
- exit(1);
- }
- if(len == 0) {
- fprintf(stderr, "No more data! exiting.\n");
- exit(1);
- }
- endptr = len;
- startptr = 0;
-}
-
-unsigned char
-cmdgetc() {
- unsigned char r;
- static int bla = 0;
-
- if(startptr >= endptr) /* there is no more data available */
- fill_buffer(cmd_fd);
- r = output_buf[startptr];
-#if 0
- /* For debugging purposes :) Produces quite a lot of output. */
- fprintf(stderr, " %02x %c ", r, isprint(r)?r:'.');
- bla++;
- if(bla % 10 == 0)
- fprintf(stderr, "\n");
-#endif
- startptr++;
- return r;
-}
-
-int
-cmd_write(const char *buf, int len) {
- if(write(cmd_fd, buf, len) < 0) {
- fprintf(stderr, "Error writing to process: %m\n");
- exit(2);
- }
- return 0;
-}
-
diff -r 7b528bbd72b2 -r 8baac73b9c9c st.h
--- a/st.h Mon Mar 05 14:57:47 2007 +0100
+++ b/st.h Mon Mar 05 15:03:34 2007 +0100
@@ -81,9 +81,12 @@ extern int curr_row, curr_col;
/* event.c */
int handle_x_events(void);
-extern int cmd_write(const char *, int);
-extern unsigned char cmdgetc(void);
-extern int resize_app(void);
+/* process.c */
+int resize_app(void);
+int execute_command(int argc, const char **argv);
+void wait_for_input(void);
+unsigned char cmdgetc(void);
+int cmd_write(const char *, int);
extern int init_screen(void);
extern int init_window(void);
Received on Mon Mar 05 2007 - 15:04:23 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:11 UTC