Changeset 4836:684486ae8f9f in roaraudio
- Timestamp:
- 04/03/11 12:44:57 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarvio.c
r4835 r4836 24 24 */ 25 25 26 int g_verbose = 0; 27 #define ROAR_DBG_INFOVAR g_verbose 28 26 29 #include <roaraudio.h> 27 30 #include <errno.h> … … 30 33 enum action { 31 34 READ, 32 WRITE 35 WRITE, 36 EXPLAIN 33 37 }; 34 38 39 35 40 void usage (const char * progname) { 41 } 42 43 int do_explain (struct roar_vio_calls * cur) { 44 struct roar_sockname sockname; 45 int have_sockname; 46 int need_space, need_space2; 47 int level = 0; 48 int fh; 49 char * name; 50 const char * codec; 51 char * content_type; 52 53 while (cur != NULL) { 54 if ( roar_vio_ctl(cur, ROAR_VIO_CTL_GET_NAME, &name) == -1 ) 55 name = "UNKNOWN"; 56 57 if ( g_verbose ) { 58 if ( roar_vio_ctl(cur, ROAR_VIO_CTL_GET_MIMETYPE, &content_type) == -1 ) 59 content_type = "UNKNOWN"; 60 61 codec = roar_codec2str(roar_mime2codec(content_type)); 62 63 if ( roar_vio_ctl(cur, ROAR_VIO_CTL_GET_FH, &fh) == -1 ) 64 fh = -1; 65 66 if ( g_verbose > 1 ) { 67 if ( roar_vio_ctl(cur, ROAR_VIO_CTL_GET_PEERNAME, &sockname) == -1 ) { 68 have_sockname = 0; 69 } else { 70 have_sockname = 1; 71 } 72 } else { 73 have_sockname = 0; 74 } 75 } else { 76 content_type = "UNKNOWN"; 77 codec = "UNKNOWN"; 78 fh = -1; 79 have_sockname = 0; 80 } 81 82 printf("%i: %s", level, name); 83 if ( fh != -1 || !!strcasecmp(codec, "UNKNOWN") || !!strcasecmp(content_type, "UNKNOWN") || have_sockname ) { 84 need_space = 0; 85 printf(" ("); 86 if ( fh != -1 ) { 87 printf("fh=%i", fh); 88 need_space = 1; 89 } 90 91 if ( have_sockname ) { 92 need_space2 = 0; 93 printf("%ssocket={", need_space ? ", " : ""); 94 95 need_space2 = 1; 96 switch (sockname.type) { 97 case ROAR_SOCKET_TYPE_UNIX: printf("af=UNIX"); break; 98 case ROAR_SOCKET_TYPE_DECNET: printf("af=DECnet"); break; 99 case ROAR_SOCKET_TYPE_INET: printf("af=INET"); break; 100 case ROAR_SOCKET_TYPE_INET6: printf("af=INET6"); break; 101 default: 102 need_space2 = 0; 103 break; 104 } 105 106 if ( sockname.addr != NULL ) { 107 printf("%saddr=\"%s\"", need_space2 ? ", " : "", sockname.addr); 108 need_space2 = 1; 109 } 110 111 if ( sockname.port ) { 112 printf("%sport=%i", need_space2 ? ", " : "", sockname.port); 113 need_space2 = 1; 114 } 115 116 printf("}"); 117 need_space = 1; 118 } 119 120 if ( !!strcasecmp(codec, "UNKNOWN") ) { 121 printf("%scodec=%s", need_space ? ", " : "", codec); 122 need_space = 1; 123 } 124 125 if ( !!strcmp(content_type, "UNKNOWN") ) { 126 printf("%scontent-type=\"%s\"", need_space ? ", " : "", content_type); 127 need_space = 1; 128 } 129 printf(")"); 130 } 131 printf("\n"); 132 133 level++; 134 135 if ( have_sockname ) 136 if ( sockname.addr != NULL ) 137 roar_mm_free(sockname.addr); 138 139 if ( roar_vio_ctl(cur, ROAR_VIO_CTL_GET_NEXT, &cur) == -1 ) 140 cur = NULL; 141 } 142 143 return 0; 36 144 } 37 145 … … 44 152 char * file = NULL; 45 153 int o_flags = -1; 154 int ret = 0; 46 155 47 156 for (i = 1; i < argc; i++) { … … 55 164 } else if ( !strcmp(k, "--write") ) { 56 165 action = WRITE; 166 } else if ( !strcmp(k, "--explain") ) { 167 action = EXPLAIN; 168 } else if ( !strcmp(k, "--verbose") ) { 169 g_verbose++; 57 170 } else if ( file == NULL ) { 58 171 file = k; … … 71 184 switch (action) { 72 185 case READ: 186 case EXPLAIN: 73 187 o_flags = O_RDONLY; 74 188 break; … … 100 214 roar_vio_copy_data(&vio, roar_stdin); 101 215 break; 216 case EXPLAIN: 217 if ( do_explain(&vio) == -1 ) 218 ret = 4; 219 break; 102 220 } 103 221 104 222 roar_vio_close(&vio); 105 223 106 return 0;224 return ret; 107 225 } 108 226
Note: See TracChangeset
for help on using the changeset viewer.