Summary: | ASTERISK-02958: [patch] app_read Addition | ||
Reporter: | Anthony Minessale (anthm) | Labels: | |
Date Opened: | 2004-12-09 22:06:34.000-0600 | Date Closed: | 2008-01-15 15:18:45.000-0600 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Core/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) anthmfix.txt ( 1) app_read.diff ( 2) app_read.rev2.diff ( 3) appread.txt ( 4) parse_args.diff | |
Description: | This patch adds [|attempts][|timeout] to the end of the arg list. If attempts is greater than 1, that many attempts will be made in the event no data is entered. If timeout is greater than 0, that value will override the default timeout. E.G. Read(MYVAR|enter-ext||3|5) try 3 times waiting 5 sec for input into MYVAR with file enter-ext The arg list on this one is a little ugly cos option is right in the middle and not always needed plus it should be just 1 char like 's' and 'n' not whole words for no reason. but I didnt want to mess with back compat. ****** ADDITIONAL INFORMATION ****** Disclaimer on file. anthmct@yahoo.com | ||
Comments: | By: Mark Spencer (markster) 2004-12-11 00:04:48.000-0600 What's wrong with strsep, btw? By: Anthony Minessale (anthm) 2004-12-11 08:14:34.000-0600 strsep is ok i just wanted to break it down more logicly, if it's more efficient or something you can implement it that way. Hey how bout ast_seperate_app_args(char *buf, char **array) in your appp: char *args[25]; char *mydata; mydata = ast_strdupa((char *)data); ast_seprtate_app_args(mydata,&args); printf("a uniform way to parse stuff, arg 1 = %s",args[0]); just popped in my head as I was replying , *shrug* By: Mark Spencer (markster) 2004-12-11 18:21:48.000-0600 you'd have to pass the max size of the array of course, but other than that, seems reasonable to me! By: Anthony Minessale (anthm) 2004-12-12 09:52:36.000-0600 See parse_args.diff static int myapp_exec(struct ast_channel *chan, void *data) { char *args[25]; int x = 0; int defined = 0; if (defined = (ast_seperate_app_args(ast_strdupa((char *)data), '|', args, sizeof(args) / sizeof(char *)))) for(x=0; x < defined; x++) ast_verbose("a uniform way to parse stuff, arg %d = %s\n",x+1, args[x]); return 0; } edited on: 12-12-04 09:55 By: Anthony Minessale (anthm) 2004-12-14 11:01:49.000-0600 rev2 is the original patch using the new arg parsing call patch By: Mark Spencer (markster) 2004-12-14 23:36:49.000-0600 If you want, you can change them to single character options, but retain backwards compatibility with the whole word... e.g.: if (!strcasecmp(options, "skip")) option_skip = 1; else if (!strcasecmp(options, "foo")) option_foo = 1; else { if (strchr(options, 's')) option_skip = 1; if (strchr(options, 'f')) option_foo = 1; } By: Anthony Minessale (anthm) 2004-12-15 08:57:35.000-0600 another idea i had was since the only 2 legal options atm are skip and answer and you can't have both cos they are mutually exclusive option_skip = (options[0] == 's') ? 1 : 0; option_answer = (options[0] == 'a') ? 1 : 0; of corse that would allow "sky" as a valid option so *shrug* By: Olle Johansson (oej) 2004-12-27 12:06:49.000-0600 Where are we with this patch? ---housekeeping By: Anthony Minessale (anthm) 2004-12-28 13:23:44.000-0600 its good to go as soon as it's approved By: Mark Spencer (markster) 2004-12-29 08:12:26.000-0600 Fixed in CVS with some small bug fixes and adding the options I had discuseed earlier in the patch. By: Olle Johansson (oej) 2004-12-29 08:26:02.000-0600 Watch the formatting :-) By: Mark Spencer (markster) 2004-12-29 08:29:28.000-0600 k By: Olle Johansson (oej) 2004-12-29 08:44:15.000-0600 added another patch for app_read By: Mark Spencer (markster) 2004-12-29 08:48:08.000-0600 The bug that never dies. By: Digium Subversion (svnbot) 2008-01-15 15:18:42.000-0600 Repository: asterisk Revision: 4587 U trunk/app.c U trunk/apps/app_read.c ------------------------------------------------------------------------ r4587 | markster | 2008-01-15 15:18:41 -0600 (Tue, 15 Jan 2008) | 2 lines Merge anthm's app_read addition, somewhat modified (bug ASTERISK-2958) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=4587 By: Digium Subversion (svnbot) 2008-01-15 15:18:43.000-0600 Repository: asterisk Revision: 4588 U trunk/app.c ------------------------------------------------------------------------ r4588 | markster | 2008-01-15 15:18:43 -0600 (Tue, 15 Jan 2008) | 2 lines Fix anthm formatting (bug ASTERISK-2958) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=4588 By: Digium Subversion (svnbot) 2008-01-15 15:18:45.000-0600 Repository: asterisk Revision: 4590 U trunk/apps/app_read.c ------------------------------------------------------------------------ r4590 | markster | 2008-01-15 15:18:44 -0600 (Tue, 15 Jan 2008) | 2 lines Various oej fixes (bug ASTERISK-2958) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=4590 |