Changeset 4756:bc0883202f16 in roaraudio
- Timestamp:
- 02/06/11 01:15:32 (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r4754 r4756 5 5 * Disable more stuff in minimal build (Closes: #104) 6 6 * Added time display to roarvorbis (Closes: #102) 7 * Added support to roarshout to read password form user or file (Closes: #101) 7 8 8 9 v. 0.4beta3 - Wed Jan 26 2011 23:26 CET -
doc/man1/roarshout.1
r4013 r4756 43 43 Show this help 44 44 45 .TP 46 \fB\-\-pw\-arg\fR 47 Password is supplied as argument (default). 48 49 .TP 50 \fB\-\-pw\-ask\fR 51 Ask user for password interactively. 52 53 .TP 54 \fB\-\-pw\-dstr\fR 55 Read password from file. Filename is supplied as normal password argument. 56 45 57 .SH "LIBSHOUT OPTIONS" 46 58 -
roarclients/roarshout.c
r4708 r4756 42 42 " --codec CODEC - Set the codec\n" 43 43 " -h --help - Show this help\n" 44 " --pw-arg - Password is supplied as argument (default).\n" 45 " --pw-ask - Ask user for password interactively.\n" 46 " --pw-dstr - Read password from file. Filename is supplied\n" 47 " as normal password argument.\n" 44 48 ); 45 49 … … 55 59 } 56 60 61 char * read_pw_from_file(char * filename, char * buffer, size_t bufferlen) { 62 struct roar_vio_defaults def; 63 struct roar_vio_calls file; 64 ssize_t len; 65 66 if (filename == NULL || buffer == NULL) 67 return NULL; 68 69 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_RDONLY, 0644) == -1 ) 70 return NULL; 71 72 if ( roar_vio_open_dstr(&file, filename, &def, 1) == -1 ) 73 return NULL; 74 75 len = roar_vio_read(&file, buffer, bufferlen - 1); 76 77 if ( len == -1 ) 78 return NULL; 79 80 // strip newlions. 81 for (; buffer[len-1] == '\r' || buffer[len-1] == '\n'; len--); 82 83 buffer[len] = 0; 84 85 roar_vio_close(&file); 86 87 return buffer; 88 } 89 57 90 int main (int argc, char * argv[]) { 91 enum { ARG, ASK, DSTR } pw_source = ARG; 58 92 int rate = 44100; 59 93 int bits = 16; … … 75 109 char buf[BUFSIZE]; 76 110 shout_t * shout; 111 char password_buf[128]; 77 112 78 113 for (i = 1; i < argc; i++) { … … 89 124 } else if ( strcmp(k, "--codec") == 0 ) { 90 125 codec = roar_str2codec(argv[++i]); 126 } else if ( strcmp(k, "--pw-arg") == 0 ) { 127 pw_source = ARG; 128 } else if ( strcmp(k, "--pw-ask") == 0 ) { 129 pw_source = ASK; 130 } else if ( strcmp(k, "--pw-dstr") == 0 ) { 131 pw_source = DSTR; 91 132 } else if ( strcmp(k, "-p") == 0 || strcmp(k, "--public") == 0 ) { 92 133 s_public = 1; … … 117 158 } 118 159 160 switch (pw_source) { 161 case ARG: 162 // nothing to do 163 break; 164 case ASK: 165 if ( roar_passwd_simple_ask_pw(&s_pw, "Password for icecast server?", NULL) == -1 ) { 166 fprintf(stderr, "Error: unabled to read password from user.\n"); 167 return 1; 168 } 169 strncpy(password_buf, s_pw, sizeof(password_buf)-1); 170 roar_mm_free(s_pw); 171 password_buf[sizeof(password_buf)-2] = 0; 172 s_pw = password_buf; 173 break; 174 case DSTR: 175 if ( (s_pw = read_pw_from_file(s_pw, password_buf, sizeof(password_buf))) == NULL ) { 176 fprintf(stderr, "Error: unabled to read password from file.\n"); 177 return 1; 178 } 179 break; 180 } 181 119 182 if ( s_server == NULL ) 120 183 s_server = "localhost";
Note: See TracChangeset
for help on using the changeset viewer.