summaryrefslogtreecommitdiff
blob: 16fc85962ffe3ca33187091a13e1ca8f14ddbbb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#define _POSIX_C_SOURCE 200809L
#include <stdlib.h>
#include <string.h>
#include <stdint.h> /* defines SIZE_MAX */

#include "../core/char.h"
#include "../core/index.h"

#include "../cli/cli.h"

#include "../knowledge/knowledge.h"

#include "sequence.h"

/* TODO */
static int add_word
(
   const ZoO_index word_id,
   const size_t destination_size,
   struct ZoO_knowledge k [const restrict static 1],
   ZoO_char destination [const restrict static max_destination_length],
   size_t destination_used_size [const restrict static 1],
   const struct ZoO_pipe io [const restrict static 1]
)
{
	const ZoO_char * word;
	size_t word_size;

	(void) ZoO_knowledge_lock_access(k, io);
	ZoO_knowledge_get_word(k, word_id, &word, &word_size, io);
	(void) ZoO_knowledge_unlock_access(k, io);

	if ((destination_used_size + word_size) > max_destination_length)
	{
	}

	if
	(
		(word_size == 2)
		&& ZoO_char_is_punctuation(word[0])
	)
	{
		snprintf
		(
			(destination + *destination_used_size),
			word_size,
			ZoO_CHAR_STRING_SYMBOL,
			current_sentence
		);
	}
	else
	{
	}

   return 0;
}
/******************************************************************************/
/** EXPORTED ******************************************************************/
/******************************************************************************/

int ZoO_sequence_to_undercase_string
(
   const ZoO_index sequence [const restrict static 1],
   const ZoO_index sequence_length,
   const ZoO_index max_destination_length,
   struct ZoO_knowledge k [const restrict static 1],
   ZoO_char destination [const restrict static max_destination_length],
   ZoO_index destination_length [const restrict static 1],
   const struct ZoO_pipe io [const restrict static 1]
)
{
   ZoO_index i;
   const ZoO_index actual_length = (sequence_length - 1);

   for (i = 0; i < actual_length; ++i)
   {
      if
      (
         add_word
         (
            sequence[i],
            max_destination_length,
            k,
            destination,
            destination_length,
            io
         ) < 0
      )
      {
         *destination_length = 0;

         return -1;
      }
   }

   return 0;
}