tags 586300 patch thanks See attached. This solution relies on vcquery printing more than two tab-separated field and including the value of NICKNAME in the third column. The m_vcf script greps across the entire line, but then only returns the first two fields.
-- .''`. martin f. krafft <madd...@d.o> Related projects: : :' : proud Debian developer http://debiansystem.info `. `'` http://people.debian.org/~madduck http://vcs-pkg.org `- Debian - when you have better things to do than fixing systems
From 83b1e735d11c08eefb7f8bead7ae3055430aa833 Mon Sep 17 00:00:00 2001 From: martin f. krafft <madd...@madduck.net> Date: Mon, 21 Jun 2010 12:17:46 +0200 Subject: [PATCH] search nickname field too Signed-off-by: martin f. krafft <madd...@madduck.net> --- m_vcf.sh.in | 4 ++-- vcquery.c | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/m_vcf.sh.in b/m_vcf.sh.in index 561970f..14ef0f3 100644 --- a/m_vcf.sh.in +++ b/m_vcf.sh.in @@ -39,9 +39,9 @@ m_vcf_query() fi $cmd | grep -i "$QUERY" | ( - while read match + while read match1 match2 rest do - echo "$match (VCF)" + echo "$match1 $match2 (VCF)" done ) done diff --git a/vcquery.c b/vcquery.c index 25f67fe..51aad42 100644 --- a/vcquery.c +++ b/vcquery.c @@ -37,7 +37,8 @@ int main(int argc, char** argv) VF_OBJECT_T* vfobj; VF_PROP_T* prop; char* propval; - char* fullname; + char* fullname; /* TODO: initialise */ + char* nickname; if (parse_opts(&opts, argc, argv)) return 1; @@ -73,18 +74,32 @@ int main(int argc, char** argv) if (available < STRING) fullname = strdup(name); } + /* TODO: fullname may actually still be NULL! */ + + nickname = NULL; + if (vf_get_property(&prop, vfobj, VFGP_FIND, NULL, "NICKNAME", NULL)) { + propval = vf_get_prop_value_string(prop, 0); + if (propval) + nickname = strdup(propval); + } if (vf_get_property(&prop, vfobj, VFGP_FIND, NULL, "EMAIL", NULL)) { do { int props = 0; - while ((propval = vf_get_prop_value_string(prop, props++))) - printf("%s\t%s\n", propval, fullname); + while ((propval = vf_get_prop_value_string(prop, props++))) { + printf("%s\t%s", propval, fullname); + if (nickname) printf("\t%s", nickname); + putchar('\n'); + } } while (vf_get_next_property(&prop)); } if (fullname) free(fullname); + if (nickname) + free(nickname); + } while (vf_get_next_object(&vfobj)); return 0; -- 1.7.1
digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)