Debian Codegraph @

texmf-dist/bibtex/bst/directory/address-ldif.bst

raw
1 %% address-ldif.bst
2 %% Copyright 2003 Christophe Geuzaine <[email protected]>
3 %
4 % $Id: address-ldif.bst,v 1.7 2003/09/16 07:18:07 geuzaine Exp $
5 %
6 % This program can be redistributed and/or modified under the terms
7 % of the LaTeX Project Public License distributed from CTAN
8 % archives in directory macros/latex/base/lppl.txt; either
9 % version 1 of the License, or (at your option) any later version.
10 %
11 % BibTeX bibliography style `address-ldif.bst'
12 % 'directory' database: all fields
13 %
14 % This is definitively a hack... To get a working ldif file if the bib
15 % file contains special characters (ISO Latin 1, etc.) you must
16 % convert the output bbl file to UTF8. You can do it e.g. with the
17 % following C code (found on the web, don't know who wrote it):
18 %
19 % /* Read Latin-1 (ISO-8859-1) characters from stdin, convert them
20 % to UTF-8, and write the converted characters to stdout.
21 % UTF-8 is defined by RFC 2044.
22 % */
23 % #include <errno.h>
24 % #include <stdio.h>
25 %
26 % int
27 % main (int argc, char** argv)
28 % {
29 % register int c;
30 % while ((c = getchar()) != EOF) {
31 % if ((c & 0x80) == 0) {
32 % putchar (c);
33 % } else {
34 % putchar (0xC0 | (0x03 & (c >> 6)));
35 % putchar (0x80 | (0x3F & c));
36 % }
37 % }
38 % if ( ! feof (stdin)) {
39 % errno = ferror (stdin);
40 % perror (argv[0]);
41 % }
42 % return 0;
43 % }
44 %
45
46 INTEGERS { nameptr namesleft numnames numaux len }
47 STRINGS { s t u v }
48
49 % ------------------------------------------------------------
50 % E N T R I E S
51 % ------------------------------------------------------------
52
53 ENTRY
54 { name
55 nickname
56 birthday
57 birthyear
58 address % if empty, use street, city, ...
59 street
60 city
61 state
62 zip
63 country
64 phone
65 cellular
66 fax
67 email
68 url
69 account
70 p.address % if empty, use p.street, p.city, ...
71 p.street
72 p.city
73 p.state
74 p.zip
75 p.country
76 p.phone
77 p.cellular
78 p.fax
79 p.email
80 p.url
81 p.account
82 r.address % if empty, use r.street, r.city, ...
83 r.street
84 r.city
85 r.state
86 r.zip
87 r.country
88 r.phone
89 r.cellular
90 r.fax
91 r.email
92 r.url
93 r.account
94 w.title
95 w.name
96 w.address % if empty, use w.street, w.city, ...
97 w.street
98 w.city
99 w.state
100 w.zip
101 w.country
102 w.phone
103 w.cellular
104 w.fax
105 w.email
106 w.url
107 w.account
108 note
109 }
110 {}
111 {
112 }
113
114 % ------------------------------------------------------------
115 % G E N E R A L
116 % ------------------------------------------------------------
117
118 FUNCTION {output}
119 { 's :=
120 s empty$
121 {}
122 { s write$
123 newline$
124 }
125 if$
126 }
127
128 FUNCTION {not}
129 { { #0 }
130 { #1 }
131 if$
132 }
133
134 FUNCTION {and}
135 { 'skip$
136 { pop$ #0 }
137 if$
138 }
139
140 FUNCTION {or}
141 { { pop$ #1 }
142 'skip$
143 if$
144 }
145
146 % ------------------------------------------------------------
147 % P R E - A N D P O S T - H E A D E R S
148 % ------------------------------------------------------------
149
150 FUNCTION {begin.bib}
151 {
152 }
153
154 FUNCTION {end.bib}
155 {
156 }
157
158 % ------------------------------------------------------------
159 % G E N E R A L F O R M A T T I N G F U N C T I O N S
160 % ------------------------------------------------------------
161
162 FUNCTION {format.names}
163 { 's :=
164 #1 'nameptr :=
165 s num.names$ 'numnames :=
166 numnames 'namesleft :=
167 { namesleft #0 > }
168 {
169 s nameptr "{ff{ } }{vv{ } }{ll{ }}{, jj{ }}" format.name$ 't :=
170 nameptr #1 >
171 { namesleft #1 >
172 { ", " * t * }
173 { " and " * t * }
174 if$
175 }
176 't
177 if$
178 nameptr #1 + 'nameptr :=
179 namesleft #1 - 'namesleft :=
180 }
181 while$
182 }
183
184 FUNCTION {format.first.names}
185 { 's :=
186 #1 'nameptr :=
187 s num.names$ 'numnames :=
188 numnames 'namesleft :=
189 { namesleft #0 > }
190 {
191 s nameptr "{ff{ }}" format.name$ 't :=
192 nameptr #1 >
193 { namesleft #1 >
194 { ", " * t * }
195 { " and " * t * }
196 if$
197 }
198 't
199 if$
200 nameptr #1 + 'nameptr :=
201 namesleft #1 - 'namesleft :=
202 }
203 while$
204 }
205
206 FUNCTION {format.last.names}
207 { 's :=
208 #1 'nameptr :=
209 s num.names$ 'numnames :=
210 numnames 'namesleft :=
211 { namesleft #0 > }
212 {
213 s nameptr "{vv{ } }{ll{ }}{, jj{ }}" format.name$ 't :=
214 nameptr #1 >
215 { namesleft #1 >
216 { ", " * t * }
217 { " and " * t * }
218 if$
219 }
220 't
221 if$
222 nameptr #1 + 'nameptr :=
223 namesleft #1 - 'namesleft :=
224 }
225 while$
226 }
227
228 FUNCTION {format.dates}
229 {
230 's :=
231 #1 'nameptr :=
232 s num.names$ 'numnames :=
233 numnames 'namesleft :=
234
235 birthyear empty$
236 { #0 'numaux := }
237 { birthyear num.names$ 'numaux :=
238 numnames numaux =
239 { }
240 { " birthdays and birthyears don't match in entry '" cite$ * "'" * warning$ }
241 if$
242 }
243 if$
244
245 { namesleft #0 > }
246 { s nameptr "{ff}" format.name$ 't :=
247 s nameptr "{ll}" format.name$ 'u :=
248
249 numaux #0 > not
250 { }
251 { birthyear nameptr "{ll}" format.name$ 'v :=
252 v * "-" * }
253 if$
254
255 nameptr #1 >
256 { ";" * u * "-" * t * }
257 { u "-" * t * }
258 if$
259
260 nameptr #1 + 'nameptr :=
261 namesleft #1 - 'namesleft :=
262 numaux #1 - 'numaux :=
263 }
264 while$
265 }
266
267 % ------------------------------------------------------------
268 % V C A R D F I E L D F O R M A T S
269 % ------------------------------------------------------------
270
271 FUNCTION {format.name}
272 { name empty$
273 { "" }
274 { "cn: " name format.names * }
275 if$
276 }
277
278 FUNCTION {format.first.name}
279 { name empty$
280 { "" }
281 { "givenName: " name format.first.names * }
282 if$
283 }
284
285 FUNCTION {format.last.name}
286 { name empty$
287 { "" }
288 { "sn: " name format.last.names * }
289 if$
290 }
291
292 FUNCTION {format.simple.name}
293 { name empty$
294 { "" }
295 { "cn: " name * }
296 if$
297 }
298
299 FUNCTION {format.simple.last.name}
300 { name empty$
301 { "" }
302 { "sn: " name * }
303 if$
304 }
305
306 FUNCTION {format.nickname}
307 { nickname empty$
308 { "" }
309 { "xmozillanickname: " nickname * }
310 if$
311 }
312
313 FUNCTION {format.birthday}
314 { birthday empty$
315 {
316 birthyear empty$
317 { "" }
318 { "custom1: birthyear=" birthyear * }
319 if$
320 }
321 { "custom1: birthday=" birthday format.dates * }
322 if$
323 }
324
325 FUNCTION {format.address}
326 { address empty$
327 {
328 % ugly, but we need a new line after each field
329 street empty$ { skip$ } { "postalAddress: " street * output } if$
330 city empty$ { skip$ } { "l: " city * output } if$
331 state empty$ { skip$ } { "st: " state * output } if$
332 zip empty$ { skip$ } { "postalCode: " zip * output } if$
333 country empty$ { skip$ } { "c: " country * output } if$
334 ""
335 }
336 { "postalAddress: " address * }
337 if$
338 }
339
340 FUNCTION {format.account}
341 { account empty$
342 { "" }
343 { "custom2: account=" account * }
344 if$
345 }
346
347 FUNCTION {format.phone}
348 { phone empty$
349 { "" }
350 { "telephoneNumber: " phone * }
351 if$
352 }
353
354 FUNCTION {format.cellular}
355 { cellular empty$
356 { "" }
357 { "mobile: " cellular * }
358 if$
359 }
360
361 FUNCTION {format.fax}
362 { fax empty$
363 { "" }
364 { "facsimileTelephoneNumber: " fax * }
365 if$
366 }
367
368 FUNCTION {format.email}
369 { email empty$
370 { "" }
371 { "mail: " email * }
372 if$
373 }
374
375 FUNCTION {format.url}
376 { url empty$
377 { "" }
378 { "workurl: " url * }
379 if$
380 }
381
382 FUNCTION {format.p.address}
383 { p.address empty$
384 {
385 % ugly, but we need a new line after each field
386 p.street empty$ { skip$ } { "homePostalAddress: " p.street * output } if$
387 p.city empty$ { skip$ } { "mozillaHomeLocalityName: " p.city * output } if$
388 p.state empty$ { skip$ } { "mozillaHomeState: " p.state * output } if$
389 p.zip empty$ { skip$ } { "mozillaHomePostalCode: " p.zip * output } if$
390 p.country empty$ { skip$ } { "mozillaHomeCountryName: " p.country * output } if$
391 ""
392 }
393 { "homePostalAddress: " p.address * }
394 if$
395 }
396
397 FUNCTION {format.p.phone}
398 { p.phone empty$
399 { "" }
400 { "homePhone: " p.phone * }
401 if$
402 }
403
404 FUNCTION {format.p.cellular}
405 { p.cellular empty$
406 { "" }
407 { "mobile: " p.cellular * }
408 if$
409 }
410
411 FUNCTION {format.p.fax}
412 { p.fax empty$
413 { "" }
414 { "facsimileTelephoneNumber: " p.fax * }
415 if$
416 }
417
418 FUNCTION {format.p.email}
419 { p.email empty$
420 { "" }
421 { "mail: " p.email * }
422 if$
423 }
424
425 FUNCTION {format.p.url}
426 { p.url empty$
427 { "" }
428 { "homeurl: " p.url * }
429 if$
430 }
431
432 FUNCTION {format.p.account}
433 { p.account empty$
434 { "" }
435 { "custom2: account=" p.account * }
436 if$
437 }
438
439 FUNCTION {format.r.address}
440 { r.address empty$
441 {
442 % ugly, but we need a new line after each field
443 r.street empty$ { skip$ } { "homePostalAddress: " r.street * output } if$
444 r.city empty$ { skip$ } { "mozillaHomeLocalityName: " r.city * output } if$
445 r.state empty$ { skip$ } { "mozillaHomeState: " r.state * output } if$
446 r.zip empty$ { skip$ } { "mozillaHomePostalCode: " r.zip * output } if$
447 r.country empty$ { skip$ } { "mozillaHomeCountryName: " r.country * output } if$
448 ""
449 }
450 { "homePostalAddress: " r.address * }
451 if$
452 }
453
454 FUNCTION {format.r.phone}
455 { r.phone empty$
456 { "" }
457 { "homePhone: " r.phone * }
458 if$
459 }
460
461 FUNCTION {format.r.cellular}
462 { r.cellular empty$
463 { "" }
464 { "mobile: " r.cellular * }
465 if$
466 }
467
468 FUNCTION {format.r.fax}
469 { r.fax empty$
470 { "" }
471 { "facsimileTelephoneNumber: " r.fax * }
472 if$
473 }
474
475 FUNCTION {format.r.email}
476 { r.email empty$
477 { "" }
478 { "mail: " r.email * }
479 if$
480 }
481
482 FUNCTION {format.r.url}
483 { r.url empty$
484 { "" }
485 { "homeurl: " r.url * }
486 if$
487 }
488
489 FUNCTION {format.r.account}
490 { r.account empty$
491 { "" }
492 { "custom2: account=" r.account * }
493 if$
494 }
495
496 FUNCTION {format.w.title}
497 { w.title empty$
498 { "" }
499 { "title: " w.title * }
500 if$
501 }
502
503 FUNCTION {format.w.name}
504 { w.name empty$
505 { "" }
506 { "o: " w.name * }
507 if$
508 }
509
510 FUNCTION {format.w.address}
511 { w.address empty$
512 {
513 % ugly, but we need a new line after each field
514 w.street empty$ { skip$ } { "postalAddress: " w.street * output } if$
515 w.city empty$ { skip$ } { "l: " w.city * output } if$
516 w.state empty$ { skip$ } { "st: " w.state * output } if$
517 w.zip empty$ { skip$ } { "postalCode: " w.zip * output } if$
518 w.country empty$ { skip$ } { "c: " w.country * output } if$
519 ""
520 }
521 { "postalAddress: " w.address * }
522 if$
523 }
524
525 FUNCTION {format.w.phone}
526 { w.phone empty$
527 { "" }
528 { "telephoneNumber: " w.phone * }
529 if$
530 }
531
532 FUNCTION {format.w.cellular}
533 { w.cellular empty$
534 { "" }
535 { "mobile: " w.cellular * }
536 if$
537 }
538
539 FUNCTION {format.w.fax}
540 { w.fax empty$
541 { "" }
542 { "facsimileTelephoneNumber: " w.fax * }
543 if$
544 }
545
546 FUNCTION {format.w.email}
547 { w.email empty$
548 { "" }
549 { "mail: " w.email * }
550 if$
551 }
552
553 FUNCTION {format.w.url}
554 { w.url empty$
555 { "" }
556 { "workurl: " w.url * }
557 if$
558 }
559
560 FUNCTION {format.w.account}
561 { w.account empty$
562 { "" }
563 { "custom2: account=" w.account * }
564 if$
565 }
566
567 FUNCTION {format.note}
568 { note empty$
569 { "" }
570 { "description: " note * }
571 if$
572 }
573
574 % ------------------------------------------------------------
575 % P E R S O N E N T R Y
576 % ------------------------------------------------------------
577
578 FUNCTION { person }
579 {
580 "objectclass: top" output
581 "objectclass: person" output
582 "objectclass: organizationalPerson" output
583 "objectclass: inetOrgPerson" output
584 "objectclass: mozillaAbPersonObsolete" output
585
586 format.first.name output
587 format.last.name output
588 format.name output
589 format.nickname output
590 format.birthday output
591
592 format.p.address output
593 format.p.phone output
594 format.p.cellular output
595 format.p.fax output
596 format.p.email output
597 format.p.url output
598 format.p.account output
599
600 format.r.address output
601 format.r.phone output
602 format.r.cellular output
603 format.r.fax output
604 format.r.email output
605 format.r.url output
606 format.r.account output
607
608 format.w.title output
609 format.w.name output
610 format.w.address output
611 format.w.phone output
612 format.w.cellular output
613 format.w.fax output
614 format.w.email output
615 format.w.url output
616 format.w.account output
617
618 format.note output
619
620 newline$
621 }
622
623 % ------------------------------------------------------------
624 % C O M P A N Y E N T R Y
625 % ------------------------------------------------------------
626
627 FUNCTION { company }
628 {
629 "objectclass: top" output
630 "objectclass: person" output
631 "objectclass: organizationalPerson" output
632 "objectclass: inetOrgPerson" output
633 "objectclass: mozillaAbPersonObsolete" output
634
635 format.simple.last.name output
636 format.simple.name output
637 format.address output
638 format.phone output
639 format.cellular output
640 format.fax output
641 format.email output
642 format.url output
643 format.account output
644 format.note output
645
646 newline$
647 }
648
649 % ------------------------------------------------------------
650 % P L A C E E N T R Y
651 % ------------------------------------------------------------
652
653 FUNCTION { place }
654 {
655 "objectclass: top" output
656 "objectclass: person" output
657 "objectclass: organizationalPerson" output
658 "objectclass: inetOrgPerson" output
659 "objectclass: mozillaAbPersonObsolete" output
660
661 format.simple.last.name output
662 format.simple.name output
663 format.address output
664 format.phone output
665 format.cellular output
666 format.fax output
667 format.note output
668
669 newline$
670 }
671
672 % ------------------------------------------------------------
673 % M A I N
674 % ------------------------------------------------------------
675
676 READ
677 EXECUTE {begin.bib}
678 ITERATE {call.type$}
679 EXECUTE {end.bib}