/* CCL qualifiers
* Europagate, 1995
*
- * $Id: cclqfile.c,v 1.2 2004-08-18 10:03:01 adam Exp $
+ * $Id: cclqfile.c,v 1.3 2004-09-22 11:21:51 adam Exp $
*
* Old Europagate Log:
*
ccl_qual_field(bibset, cp, qual_name);
}
+void ccl_qual_buf(CCL_bibset bibset, const char *buf)
+{
+ const char *cp1 = buf;
+ char line[256];
+ while (1)
+ {
+ const char *cp2 = cp1;
+ int len;
+ while (*cp2 && !strchr("\r\n", *cp2))
+ cp2++;
+ len = cp2 - cp1;
+ if (len > 0)
+ {
+ if (len >= (sizeof(line)-1))
+ len = sizeof(line)-1;
+ memcpy(line, cp1, len);
+ line[len] = '\0';
+ ccl_qual_line(bibset, line);
+ }
+ if (!*cp2)
+ break;
+ cp1 = cp2+1;
+ }
+}
+
void ccl_qual_line(CCL_bibset bibset, char *line)
{
int no_scan = 0;
* Copyright (c) 2002-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: tstccl.c,v 1.2 2004-08-11 12:01:22 adam Exp $
+ * $Id: tstccl.c,v 1.3 2004-09-22 11:21:51 adam Exp $
*/
/* CCL test */
{0, 0}
};
-void tst1(void)
+void tst1(int pass)
{
CCL_parser parser = ccl_parser_create ();
CCL_bibset bibset = ccl_qual_mk();
int i;
+ char tstline[128];
- ccl_qual_fitem(bibset, "u=4 s=pw t=l,r", "ti");
- ccl_qual_fitem(bibset, "1=1016 s=al,pw", "term");
- ccl_qual_fitem(bibset, "1=/my/title", "dc.title");
+ switch(pass)
+ {
+ case 0:
+ ccl_qual_fitem(bibset, "u=4 s=pw t=l,r", "ti");
+ ccl_qual_fitem(bibset, "1=1016 s=al,pw", "term");
+ ccl_qual_fitem(bibset, "1=/my/title", "dc.title");
+ break;
+ case 1:
+ strcpy(tstline, "ti u=4 s=pw t=l,r");
+ ccl_qual_line(bibset, tstline);
+
+ strcpy(tstline, "term 1=1016 s=al,pw # default term");
+ ccl_qual_line(bibset, tstline);
+
+ strcpy(tstline, "dc.title 1=/my/title");
+ ccl_qual_line(bibset, tstline);
+ break;
+ case 2:
+ ccl_qual_buf(bibset, "ti u=4 s=pw t=l,r\n"
+ "term 1=1016 s=al,pw\r\n"
+ "\n"
+ "dc.title 1=/my/title\n");
+ break;
+ default:
+ exit(23);
+ }
parser->bibset = bibset;
int main(int argc, char **argv)
{
- tst1();
+ tst1(0);
+ tst1(1);
+ tst1(2);
exit(0);
}