Changeset 2045:372a02360fff in roaraudio for roarclients/roarmon.c
- Timestamp:
- 06/22/09 19:55:41 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarmon.c
r1897 r2045 2 2 3 3 /* 4 * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008 4 * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008, 2009 5 5 * 6 6 * This file is part of roarclients a part of RoarAudio, … … 56 56 char * server = NULL; 57 57 char * k; 58 int fh;59 58 int i; 60 int out = -1; 61 char buf[BUFSIZE]; 62 struct roar_connection con; 63 struct roar_stream s; 59 struct roar_connection con; 60 struct roar_stream s; 61 struct roar_vio_calls file, stream; 62 struct roar_vio_defaults def; 63 int file_opened = 0; 64 65 if ( roar_vio_open_fh(&file, ROAR_STDOUT) == -1 ) 66 return 1; 67 68 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_CREAT|O_TRUNC|O_WRONLY, 0644) == -1 ) 69 return 1; 64 70 65 71 for (i = 1; i < argc; i++) { … … 104 110 usage(); 105 111 return 0; 106 } else if ( out == -1 ) { 107 if ( (out = open(k, O_CREAT|O_TRUNC|O_WRONLY, 0644)) == -1 ) { 112 } else if ( !file_opened ) { 113 file_opened = 1; 114 if ( roar_vio_open_dstr(&file, k, &def, 1) == -1 ) { 108 115 fprintf(stderr, "Error: can not open file: %s: %s\n", k, strerror(errno)); 109 116 return 1; … … 115 122 } 116 123 } 117 118 if ( out == -1 )119 out = ROAR_STDOUT;120 124 121 125 if ( roar_simple_connect(&con, server, "roarmon") == -1 ) { … … 150 154 } 151 155 152 if ( (fh = roar_get_connection_fh(&con)) == -1 ) {153 fprintf(stderr, "Error: can not get stream fh\n");156 if ( roar_get_connection_vio(&con, &stream) == -1 ) { 157 fprintf(stderr, "Error: can not get stream vio\n"); 154 158 roar_disconnect(&con); 155 159 return 13; 156 160 } 157 161 158 ROAR_SHUTDOWN(fh, SHUT_WR); 162 // TODO: FIXME: 163 // ROAR_SHUTDOWN(fh, SHUT_WR); // we need to have something do do shutdowns here... 159 164 160 while((i = read(fh, buf, BUFSIZE))) 161 if (write(out, buf, i) != i) 162 break; 165 roar_vio_copy_data(&file, &stream); 163 166 164 roar_simple_close(fh); 167 roar_vio_close(&stream); 168 roar_vio_close(&file); 165 169 166 170 return 0;
Note: See TracChangeset
for help on using the changeset viewer.