Exemple #1
0
static void get_with_expansion(const char *prompt, char *buffer,
			       char *expanded_buffer, const char *sourcebuf)
{
	char savecopy[SLEN];

	/** This is used to prompt for a new value of the specified field.
	    If expanded_buffer == NULL then we won't bother trying to expand
	    this puppy out!  (sourcebuf could be an initial addition)
	**/

	PutLine(-1, -1, prompt);

	if (sourcebuf != NULL) {
	  while (!whitespace(*sourcebuf) && *sourcebuf != '\0')
	    sourcebuf++;
	  if (*sourcebuf != '\0') {
	    while (whitespace(*sourcebuf))
	      sourcebuf++;
	    if (strlen(sourcebuf) > 0) {
	      strcat(buffer, " ");
	      strcat(buffer, sourcebuf);
	    }
	  }
	}

	(void) strfcpy(savecopy, buffer, sizeof(savecopy));
	if (enter_string(buffer, SLEN, -1, -1, ESTR_UPDATE) < 0) {
	    /* undo */
	    (void) strcpy(buffer, savecopy);
	    PutLine(-1, -1, prompt);
	    PutLine(-1, -1, buffer);
	    NewLine();
	    return;
	}

	if(expanded_buffer != NULL) {
	  build_address(strip_commas(buffer), expanded_buffer);
	  if(*expanded_buffer != '\0') {
	    if (*prompt != '\n')
	      NewLine();
	    PutLine(-1, -1, prompt);
	    PutLine(-1, -1, expanded_buffer);
	  }
	}
	NewLine();

	return;
}
Exemple #2
0
static switch_status_t hr_say_general_count(switch_core_session_t *session,	char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
	int in;
	int x = 0;
	int places[9] = { 0 };
	char sbuf[128] = "";
	int number;
	switch_status_t status;

	if (say_args->method == SSM_ITERATED) {
		if ((tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1))) {
			char *p;
			for (p = tosay; p && *p; p++) {
				say_file("digits/%c.wav", *p);
			}
		} else {
			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
			return SWITCH_STATUS_GENERR;
		}
		return SWITCH_STATUS_SUCCESS;
	}

	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
		return SWITCH_STATUS_GENERR;
	}

	in = atoi(tosay);
	number = in;

	if (in != 0) {
		for (x = 8; x >= 0; x--) {
			int num = (int) pow(10, x);
			if ((places[(uint32_t) x] = in / num)) {
				in -= places[(uint32_t) x] * num;
			}
		}

		switch (say_args->method) {
		case SSM_COUNTED:
		case SSM_PRONOUNCED:
			if ((status =
				 play_group(SSM_PRONOUNCED, "", places[8], places[7], places[6], "digits/million.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
				return status;
			}
			if ((status =
				 play_group(SSM_PRONOUNCED, "", places[5], places[4], places[3], "digits/thousand.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
				return status;
			}
			if ((status = play_group(say_args->method, "", places[2], places[1], places[0], NULL, number, session, args)) != SWITCH_STATUS_SUCCESS) {
				return status;
			}
			break;
		default:
			break;
		}
	} else {
		say_file("digits/0.wav");
	}

	return SWITCH_STATUS_SUCCESS;
}
Exemple #3
0
int build_address(char *to, char *full_to)
{
	/** loop on all words in 'to' line...append to full_to as
	    we go along, until done or length > len.  Modified to
	    know that stuff in parens are comments...Returns non-zero
	    if it changed the information as it copied it across...
	**/

	int	i, j, k, l,
			in_parens = 0, a_in_parens,
			expanded_information = 0,
			eliminated = 0;
	int too_long = FALSE;
	int to_len;
	char word[SLEN], next_word[SLEN], *ptr;
	char elim_list[SLEN], word_a[SLEN], next_word_a[SLEN];
	char *gecos;

	full_to[0] = '\0';
	to_len = 0;

	elim_list[0] = '\0';

	i = get_word(to, 0, word, sizeof(word));

	/** Look for addresses to be eliminated from aliases **/
	while (i > 0) {

	  j = get_word(to, i, next_word, sizeof(next_word));

	  if(word[0] == '(')
	    in_parens++;

	  if (in_parens) {
	    if(word[strlen(word)-1] == ')')
	      in_parens--;
	  }

	  else if (word[0] == '-') {
	    for (k = 0; word[k] != '\0'; word[k] = word[k+1], k++);
	    if (elim_list[0] != '\0')
	      strcat(elim_list, " ");
	    /*  expand alias and eliminate all members */
	    if ((ptr = get_alias_address(word, TRUE, &too_long)) != NULL) {
	      /*  ignores overflow, like every bloody other place in elm */
	      strcat(elim_list, ptr);
	      too_long = FALSE;
	    } else
	      strcat(elim_list, word);
	  }

	  if ((i = j) > 0)
	    strcpy(word, next_word);
	}

	if (elim_list[0] != '\0')
	  eliminated++;

	i = get_word(to, 0, word, sizeof(word));

	while (i > 0) {

	  j = get_word(to, i, next_word, sizeof(next_word));

	  if(word[0] == '(')
	    in_parens++;

	  if (in_parens) {
	    if(word[strlen(word)-1] == ')')
	      in_parens--;
	    strcpy(full_to+to_len, " ");
	    strcpy(full_to+to_len+1, word);
	    to_len += strlen(word)+1;
	  }

	  else if (word[0] == '-') {
		; /* huh??? I don't understand this  (*FOO*) */
	  }

	  else if (qstrpbrk(word,"!@:") != NULL) {
	    if (to_len > 0) {
		(void) strcpy(full_to+to_len, ", ");
		to_len += 2;
	    }
	    (void) strcpy(full_to+to_len, word);
	    to_len += strlen(word);
	  }
	  else if ((ptr = get_alias_address(word, TRUE, &too_long)) != NULL) {

	    /** check aliases for addresses to be eliminated **/
	    if (eliminated) {
	      k = get_word(strip_commas(ptr), 0, word_a, sizeof(word_a));

	      while (k > 0) {
		l = get_word(ptr, k, next_word_a, sizeof(next_word_a));
		if (in_list(elim_list, word_a) == 0) {

		if (to_len > 0) {
		    (void) strcpy(full_to+to_len, ", ");
		    to_len += 2;
		}
		(void) strcpy(full_to+to_len, word_a);
		to_len += strlen(word_a);

		  /** copy possible () comment **/
		  if (next_word_a[0] == '(') {
		    a_in_parens = 0;

		    while (l > 0) {
		      if (to_len > 0) {
			(void) strcpy(full_to+to_len, " ");
			++to_len;
		      }
		      (void) strcpy(full_to+to_len, next_word_a);
		      to_len += strlen(next_word_a);
		      if (next_word_a[0] == '(')
			++a_in_parens;
		      if (next_word_a[strlen(next_word_a)-1] == ')')
			--a_in_parens;
		      l = get_word(ptr, l, next_word_a, sizeof(next_word_a));
		      if (! a_in_parens)
			break;
		    }
		  }
		}
		else {
		  /** skip possible () comment **/
                  if (next_word_a[0] == '(') {
                    a_in_parens = 0;

                    while (l > 0) {
                      if (next_word_a[0] == '(')
                        ++a_in_parens;
                      if (next_word_a[strlen(next_word_a)-1] == ')')
                        --a_in_parens;
                      l = get_word(ptr, l, next_word_a, sizeof(next_word_a));
                      if (! a_in_parens)
                        break;
                    }
                  }
		}

		if ((k = l) > 0)
		  strcpy(word_a, next_word_a);
	      }
	    } else {
	      if (to_len > 0) {
		  (void) strcpy(full_to+to_len, ", ");
		  to_len += 2;
	      }
	      (void) strcpy(full_to+to_len, ptr);
	      to_len += strlen(ptr);
	    }
	    expanded_information++;
	  }
	  else if (too_long) {
	 /*
	  *   We don't do any real work here.  But we need some
	  *   sort of test in this line of tests to make sure
	  *   that none of the other else's are tried if the
	  *   alias expansion failed because it was too long.
	  */
	      dprint(2,(debugfile,"Overflowed alias expansion for %s\n", word));
	  }
	  else if (word[0] != '\0') {
	    if (to_len > 0) {
	      (void) strcpy(full_to+to_len, ", ");
	      to_len += 2;
	    }
	    if (valid_name(word)) {
	      (void) strcpy(full_to+to_len, word);
	      to_len += strlen(word);

	      if (next_word[0] != '(')
		if ((gecos = get_full_name(word)) != NULL && *gecos != '\0') {
		  sprintf(full_to+to_len, " (%s)", gecos);
		  to_len += strlen(gecos)+3;
		}
	    } else {
	      (void) strcpy(full_to+to_len, word);
	      to_len += strlen(word);
	    }
	  }

	  if((i = j) > 0)
	    strcpy(word, next_word);
	}

	return( expanded_information > 0 ? 1 : 0 );
}
Exemple #4
0
static switch_status_t hr_say_count(switch_core_session_t *session, char* gen,
											char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
	int in;
	int x = 0;
	int places[9] = { 0 };
	char sbuf[13] = "";
	char milion[64] = "";
	char tisucu[64] = "";
	char tgen[8] = "";
	char mgen[8] = "";
	
	
	int number;
	switch_status_t status;

	strcpy(tgen, gen);
	
	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf)-1)) || strlen(tosay) > 9) {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
		return SWITCH_STATUS_GENERR;
	}

	in = atoi(tosay);
	number = in;

	if (in != 0) {
		for (x = 8; x >= 0; x--) {
			int num = (int) pow(10, x);
			if ((places[(uint32_t) x] = in / num)) {
				in -= places[(uint32_t) x] * num;
			}
		}

		switch (say_args->method) {
		case SSM_COUNTED:
		case SSM_PRONOUNCED:
			{
				if (places[6] == 1)
					strcpy(milion, "digits/milijun.wav");
				else
					strcpy(milion, "digits/milijuna.wav");
				
				if (places[4] == 1)	
				{
					strcpy(tisucu, "digits/thousands-a.wav");
				}
				else if (places[4] == 0)
				{
					switch(places[3])
					{
						case 1:
							strcpy(tisucu, "digits/thousands-a.wav");
							strcpy(tgen, "a");
							break;
							
						case 5:
						case 6:
						case 7:
						case 8:
						case 9:
							strcpy(tisucu, "digits/thousands-a.wav");
							break;
							
						case 2:
							strcpy(tgen, "je");
							strcpy(tisucu, "digits/thousands-e.wav");
							break;
							
						case 3:
						case 4:
							strcpy(tisucu, "digits/thousands-e.wav");
							break;
					}
				}
				else
				{
					switch(places[3])
					{
						case 1:
							strcpy(tisucu, "digits/thousands-a.wav");
							strcpy(tgen, "a");
							break;
							
						case 5:
						case 6:
						case 7:
						case 8:
						case 9:
							strcpy(tisucu, "digits/thousands-a.wav");
							break;
							
						case 2:
							strcpy(tisucu, "digits/thousands-e.wav");
							strcpy(tgen, "je");
							break;
							
						case 3:
						case 4:
							strcpy(tisucu, "digits/thousands-e.wav");
							break;
					}
				}

				
				if ((status =
					 play_group(SSM_PRONOUNCED, mgen, places[8], places[7], places[6], milion, number, session, args)) != SWITCH_STATUS_SUCCESS) {
					return status;
				}
				if ((status =
					 play_group(SSM_PRONOUNCED, tgen, places[5], places[4], places[3], tisucu, number, session, args)) != SWITCH_STATUS_SUCCESS) {
					return status;
				}
				if ((status = play_group(say_args->method, gen, places[2], places[1], places[0], NULL, number, session, args)) != SWITCH_STATUS_SUCCESS) {
					return status;
				}
		}
			break;
		case SSM_ITERATED:
			{
				char *p;
				for (p = tosay; p && *p; p++) {
					say_file("digits/%c.wav", *p);
				}
			}
			break;
		default:
			break;
		}
	}
	/* else {
		say_file("digits/0.wav");
	}*/

	return SWITCH_STATUS_SUCCESS;
}