Example #1
0
/*
 * Control operation to convert received syllables into notes
 * and send resulting notes back to client.
 *
 * Returns:
 *  Success: SUCCESS
 *  Failure: ERR_INVALID_SYLLABLE, ERR_TOO_MANY_SYLLABLES, 
 *			 ERR_NO_SYLLABLES, ERR_NO_NOTES
 */
int to_notes(char *syllables_buf, char *notes_buf) {

	int ret = 0;
	int total_bytes_written = 0;

	uint32_t bytes_count = recv_bytes_count();

	if (0 >= bytes_count) {
		return ERR_NO_SYLLABLES;
	}

	if (MAX_SYLLABLES_BYTES < bytes_count) {
		return ERR_TOO_MANY_SYLLABLES;
	}

	RECV(syllables_buf, bytes_count);

	total_bytes_written = process_syllables(bytes_count, syllables_buf, notes_buf);

	if (0 < total_bytes_written) {
		send_notes(total_bytes_written, notes_buf);
		ret = SUCCESS;
	} else if (0 == total_bytes_written) {
		ret = ERR_NO_NOTES;
	} else {
		ret = total_bytes_written;
	}

	return ret;
}
Example #2
0
pointer list_to_undef(pointer a) {
  char *dispatch;
  if (is_symbol(car(a))) {
    dispatch=sym_name(car(a));
    if (!strcmp(dispatch,"send-notes"))
      return send_notes(cadr(a));
    return Error_1("list>undef: unknown dispatch type:",car(a));
  }
  else
    return Error_1("list>undef: no symbol:",car(a));
}