aboutsummaryrefslogtreecommitdiffstats
path: root/extension/readdir_test.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2017-03-09 20:44:09 -0500
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2017-03-09 20:44:09 -0500
commit39c46265139aa8faf87160b30710876bde4c6ba9 (patch)
tree7d55e7d483a2e35ec675223cf0b3e5755b693a61 /extension/readdir_test.c
parentfeb12baf11e39f60e57b988d29aa96bda4dddcff (diff)
downloadegawk-39c46265139aa8faf87160b30710876bde4c6ba9.tar.gz
egawk-39c46265139aa8faf87160b30710876bde4c6ba9.tar.bz2
egawk-39c46265139aa8faf87160b30710876bde4c6ba9.zip
For API input field parsing, use an array of structs instead of an array of integers.
Diffstat (limited to 'extension/readdir_test.c')
-rw-r--r--extension/readdir_test.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/extension/readdir_test.c b/extension/readdir_test.c
index cc23081e..e023b67c 100644
--- a/extension/readdir_test.c
+++ b/extension/readdir_test.c
@@ -85,7 +85,7 @@ int plugin_is_GPL_compatible;
typedef struct open_directory {
DIR *dp;
char *buf;
- int field_width[7];
+ awk_input_field_info_t field_width[4];
} open_directory_t;
/* ftype --- return type of file as a single character string */
@@ -169,7 +169,8 @@ get_inode(struct dirent *entry, const char *dirname)
static int
dir_get_record(char **out, awk_input_buf_t *iobuf, int *errcode,
- char **rt_start, size_t *rt_len, const int **field_width)
+ char **rt_start, size_t *rt_len,
+ const awk_input_field_info_t **field_width)
{
DIR *dp;
struct dirent *dirent;
@@ -206,13 +207,13 @@ dir_get_record(char **out, awk_input_buf_t *iobuf, int *errcode,
#else
len = sprintf(the_dir->buf, "%llu", ino);
#endif
- the_dir->field_width[1] = len;
+ the_dir->field_width[0].len = len;
len += (flen = sprintf(the_dir->buf + len, "/%s", dirent->d_name));
- the_dir->field_width[3] = flen-1;
+ the_dir->field_width[1].len = flen-1;
ftstr = ftype(dirent, iobuf->name);
len += (flen = sprintf(the_dir->buf + len, "/%s", ftstr));
- the_dir->field_width[5] = flen-1;
+ the_dir->field_width[2].len = flen-1;
*out = the_dir->buf;
@@ -284,10 +285,10 @@ dir_take_control_of(awk_input_buf_t *iobuf)
emalloc(the_dir, open_directory_t *, sizeof(open_directory_t), "dir_take_control_of");
the_dir->dp = dp;
/* pre-populate the field_width array with constant values: */
- the_dir->field_width[0] = 0; /* no leading space */
- the_dir->field_width[2] = 1; /* single slash sign separator*/
- the_dir->field_width[4] = 1; /* single slash sign separator*/
- the_dir->field_width[6] = -1; /* terminate it after 3 fields */
+ the_dir->field_width[0].skip = 0; /* no leading space */
+ the_dir->field_width[1].skip = 1; /* single '/' separator */
+ the_dir->field_width[2].skip = 1; /* single '/' separator */
+ the_dir->field_width[3].skip = -1; /* terminate after 3 fields */
size = sizeof(struct dirent) + 21 /* max digits in inode */ + 2 /* slashes */;
emalloc(the_dir->buf, char *, size, "dir_take_control_of");