1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
28 * generate a license comment -- see proto(1)
30 * NOTE: coded for minimal library dependence
31 * not so for the legal department
40 #undef BSD /* guess who defines this */
59 #define NONEXCLUSIVE 13
60 #define NONCOMMERCIAL 14
61 #define PROPRIETARY 15
69 #define INCORPORATION 6
73 #define ORGANIZATION 10
86 #define COMLINE (COMDATA+4)
87 #define COMLONG (COMDATA-32)
88 #define COMMENT(x,b,s,u) comment(x,b,s,sizeof(s)-1,u)
90 #define PUT(b,c) (((b)->nxt<(b)->end)?(*(b)->nxt++=(c)):((c),(-1)))
91 #define BUF(b) ((b)->buf)
92 #define USE(b) ((b)->siz=(b)->nxt-(b)->buf,(b)->nxt=(b)->buf,(b)->siz)
93 #define SIZ(b) ((b)->nxt-(b)->buf)
94 #define END(b) (*((b)->nxt>=(b)->end?((b)->nxt=(b)->end-1):(b)->nxt)=0,(b)->nxt-(b)->buf)
97 #define NiL ((char*)0)
100 typedef struct Buffer_s
108 typedef struct Item_s
122 * NOTE: key[] element order must match the corresponding macro
125 #define KEY(s) {s,sizeof(s)-1,0}
127 static const Item_t key
[] =
135 KEY("incorporation"),
151 #define ITEMS (sizeof(key)/sizeof(key[0])-1)
153 #define LIC(s,c) {s,sizeof(s)-1,c}
155 static const Item_t lic
[] =
158 LIC("inline", SPECIAL
),
160 LIC("verbose", VERBOSE
),
169 LIC("special", SPECIAL
),
170 LIC("nonexclusive", SPECIAL
),
171 LIC("noncommercial", SPECIAL
),
172 LIC("proprietary", PROPRIETARY
),
176 typedef struct Notice_s
188 * return index given <name,size>
192 lookup(register const Item_t
* item
, const char* name
, int size
)
198 for (i
= 0; item
[i
].data
; i
++)
199 if (c
== item
[i
].data
[0] && size
== item
[i
].size
&& !strncmp(name
, item
[i
].data
, size
))
205 * copy s of size n to b
206 * n<0 means 0 terminated string
210 copy(register Buffer_t
* b
, register char* s
, int n
)
219 * center and copy comment line s to p
221 * n>0 first frame line
223 * n<0 last frame line
224 * if u>0 then s converted to upper case
225 * if u<0 then s is left justified
229 comment(Notice_t
* notice
, register Buffer_t
* b
, register char* s
, register int n
, int u
)
241 PUT(b
, notice
->cc
[n
> 0 ? 0 : 1]);
242 for (i
= 0; i
< COMDATA
; i
++)
244 PUT(b
, notice
->cc
[n
> 0 ? 1 : 2]);
254 m
= (u
< 0) ? 1 : (COMDATA
- n
) / 2;
255 if ((x
= COMDATA
- m
- n
) < 0)
262 if (u
> 0 && i
>= 'a' && i
<= 'z')
274 * expand simple ${...}
278 expand(Notice_t
* notice
, register Buffer_t
* b
, const Item_t
* item
)
294 if (*t
== '$' && t
< (e
+ 2) && *(t
+ 1) == '{')
298 while (t
< e
&& (c
= *t
++) != '}')
306 if ((c
= lookup(key
, x
, t
- x
- 1)) >= 0 && (x
= notice
->item
[c
].data
))
308 z
= x
+ notice
->item
[c
].size
;
312 if (!m
|| c
>= '0' && c
<= '9')
317 while (t
< e
&& *t
++ != '}');
319 else if (q
> 0 && *t
== '\\' && (*(t
+ 1) == q
|| *(t
+ 1) == '\\'))
328 * generate a copright notice
332 copyright(Notice_t
* notice
, register Buffer_t
* b
)
338 copy(b
, "Copyright (c) ", -1);
340 clock
= (time_t)1000212300;
343 t
= ctime(&clock
) + 20;
344 if ((x
= notice
->item
[SINCE
].data
) && strncmp(x
, t
, 4))
346 expand(notice
, b
, ¬ice
->item
[SINCE
]);
350 if (notice
->item
[PARENT
].data
)
353 expand(notice
, b
, ¬ice
->item
[PARENT
]);
355 if (notice
->item
[CORPORATION
].data
)
358 expand(notice
, b
, ¬ice
->item
[CORPORATION
]);
359 if (notice
->item
[INCORPORATION
].data
)
362 expand(notice
, b
, ¬ice
->item
[INCORPORATION
]);
365 else if (notice
->item
[COMPANY
].data
)
368 expand(notice
, b
, ¬ice
->item
[COMPANY
]);
373 * read the license file and generate a comment in p, length size
374 * license length in p returned, -1 on error
375 * -1 return places 0 terminated error string in p
379 astlicense(char* p
, int size
, char* file
, char* options
, int cc1
, int cc2
, int cc3
)
394 char tmpbuf
[COMLINE
];
401 buf
.end
= (buf
.buf
= buf
.nxt
= p
) + size
;
402 tmp
.end
= (tmp
.buf
= tmp
.nxt
= tmpbuf
) + sizeof(tmpbuf
);
405 if ((i
= open(file
, O_RDONLY
)) < 0)
407 copy(&buf
, file
, -1);
408 copy(&buf
, ": cannot open", -1);
412 n
= read(i
, info
, sizeof(info
) - 1);
416 copy(&buf
, file
, -1);
417 copy(&buf
, ": cannot read", -1);
438 for (i
= 0; i
< ITEMS
; i
++)
439 notice
.item
[i
].data
= 0;
440 notice
.item
[STYLE
] = notice
.item
[CLASS
] = lic
[notice
.type
];
441 notice
.item
[STYLE
].quote
= notice
.item
[CLASS
].quote
= 0;
442 contributor
= i
= k
= 0;
449 while (c
== ' ' || c
== '\t' || c
== '\n' && ++line
|| c
== '\r' || c
== ',' || c
== ';' || c
== ')')
455 while (*++s
&& *s
!= '\n');
471 while (c
&& c
!= '=' && c
!= ']' && c
!= ')' && c
!= ',' && c
!= ' ' && c
!= '\t' && c
!= '\n' && c
!= '\r')
474 h
= lookup(key
, x
, n
);
478 if (c
== '=' || first
)
482 q
= ((c
= *++s
) == '"' || c
== '\'') ? *s
++ : 0;
488 else if (h
== CONTRIBUTOR
)
513 else if (i
== *(s
- 1))
517 if (*s
== i
&& i
== '"')
532 while ((c
= *s
) && (q
== '"' && (c
== '\\' && (*(s
+ 1) == '"' || *(s
+ 1) == '\\') && s
++ && (quote
= q
)) || q
&& c
!= q
|| !q
&& c
!= ' ' && c
!= '\t' && c
!= '\n' && c
!= '\r' && c
!= ',' && c
!= ';'))
548 for (i
= 0; i
< notice
.ids
; i
++)
549 if (n
== notice
.id
[i
].name
.size
&& !strncmp(x
, notice
.id
[i
].name
.data
, n
))
553 notice
.id
[i
].name
.data
= x
;
554 notice
.id
[i
].name
.size
= n
;
555 notice
.id
[i
].name
.quote
= 0;
556 notice
.id
[i
].value
.data
= v
;
557 notice
.id
[i
].value
.size
= s
- v
;
558 notice
.id
[i
].value
.quote
= quote
;
565 if ((s
- v
) == 3 && v
[0] == 'a' && v
[1] == 'l' && v
[2] == 'l')
567 for (i
= 0; i
< ITEMS
; i
++)
568 if (notice
.item
[i
].size
)
570 expand(¬ice
, &buf
, &key
[i
]);
573 if (h
>= notice
.item
[i
].size
)
578 else if (notice
.item
[i
].data
[h
] == ' ' || notice
.item
[i
].data
[h
] == '\t')
582 expand(¬ice
, &buf
, ¬ice
.item
[i
]);
590 if ((h
= lookup(key
, v
, s
- v
)) < 0)
595 expand(¬ice
, &buf
, &item
);
598 expand(¬ice
, &buf
, ¬ice
.item
[h
]);
606 switch (c
= lookup(lic
, v
, s
- v
))
627 notice
.item
[CLASS
].data
= lic
[lic
[c
].quote
].data
;
628 notice
.item
[CLASS
].size
= lic
[lic
[c
].quote
].size
;
633 notice
.item
[h
].data
= (notice
.item
[h
].size
= s
- v
) ? v
: (char*)0;
634 notice
.item
[h
].quote
= quote
;
643 copy(&buf
, "\"", -1);
644 copy(&buf
, file
, -1);
645 copy(&buf
, "\", line ", -1);
646 x
= &tmpbuf
[sizeof(tmpbuf
)];
649 do *--x
= ("0123456789")[line
% 10]; while (line
/= 10);
651 copy(&buf
, ": ", -1);
653 copy(&buf
, "option error: assignment expected", -1);
661 if (!options
|| !*(s
= options
))
667 if (notice
.type
== INLINE
&& (!notice
.verbose
|| !notice
.item
[NOTICE
].data
))
669 if (notice
.type
!= USAGE
)
672 notice
.type
= SPECIAL
;
673 comment(¬ice
, &buf
, NiL
, 1, 0);
674 comment(¬ice
, &buf
, NiL
, 0, 0);
675 if (notice
.item
[PACKAGE
].data
)
677 copy(&tmp
, "This software is part of the ", -1);
678 expand(¬ice
, &tmp
, ¬ice
.item
[PACKAGE
]);
679 copy(&tmp
, " package", -1);
680 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
682 if (notice
.type
>= OPEN
)
684 copyright(¬ice
, &tmp
);
685 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
686 if (notice
.type
>= SPECIAL
)
687 COMMENT(¬ice
, &buf
, "All Rights Reserved", 0);
689 if (notice
.type
== CPL
|| notice
.type
== EPL
)
691 copy(&tmp
, notice
.item
[PACKAGE
].data
? "and" : "This software", -1);
692 copy(&tmp
, " is licensed under the", -1);
693 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
694 if (notice
.type
== EPL
)
695 copy(&tmp
, "Eclipse Public License", -1);
697 copy(&tmp
, "Common Public License", -1);
698 if (notice
.item
[VERSION
].data
)
700 copy(&tmp
, ", Version ", -1);
701 expand(¬ice
, &tmp
, ¬ice
.item
[VERSION
]);
703 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
704 if (notice
.item
[CORPORATION
].data
|| notice
.item
[COMPANY
].data
)
706 copy(&tmp
, "by ", -1);
707 if (notice
.item
[PARENT
].data
)
709 expand(¬ice
, &tmp
, ¬ice
.item
[PARENT
]);
712 if (notice
.item
[CORPORATION
].data
)
714 expand(¬ice
, &tmp
, ¬ice
.item
[CORPORATION
]);
715 if (notice
.item
[INCORPORATION
].data
)
718 expand(¬ice
, &tmp
, ¬ice
.item
[INCORPORATION
]);
721 else if (notice
.item
[COMPANY
].data
)
722 expand(¬ice
, &tmp
, ¬ice
.item
[COMPANY
]);
723 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
725 comment(¬ice
, &buf
, NiL
, 0, 0);
726 COMMENT(¬ice
, &buf
, "A copy of the License is available at", 0);
727 if (notice
.item
[URL
].data
)
729 expand(¬ice
, &tmp
, ¬ice
.item
[URL
]);
730 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
731 if (notice
.item
[URLMD5
].data
)
733 copy(&tmp
, "(with md5 checksum ", -1);
734 expand(¬ice
, &tmp
, ¬ice
.item
[URLMD5
]);
736 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
739 else if (notice
.type
== EPL
)
740 COMMENT(¬ice
, &buf
, "http://www.eclipse.org/org/documents/epl-v10.html", 0);
742 COMMENT(¬ice
, &buf
, "http://www.opensource.org/licenses/cpl", 0);
743 comment(¬ice
, &buf
, NiL
, 0, 0);
745 else if (notice
.type
== OPEN
)
747 copy(&tmp
, notice
.item
[PACKAGE
].data
? "and it" : "This software", -1);
748 copy(&tmp
, " may only be used by you under license from", -1);
749 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
750 if (notice
.item
[i
= CORPORATION
].data
)
752 if (notice
.item
[PARENT
].data
)
754 expand(¬ice
, &tmp
, ¬ice
.item
[i
= PARENT
]);
757 expand(¬ice
, &tmp
, ¬ice
.item
[CORPORATION
]);
758 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
760 else if (notice
.item
[i
= COMPANY
].data
)
762 if (notice
.item
[PARENT
].data
)
764 expand(¬ice
, &tmp
, ¬ice
.item
[i
= PARENT
]);
767 expand(¬ice
, &tmp
, ¬ice
.item
[COMPANY
]);
768 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
772 if (notice
.item
[URL
].data
)
774 COMMENT(¬ice
, &buf
, "A copy of the Source Code Agreement is available", 0);
775 copy(&tmp
, "at the ", -1);
777 expand(¬ice
, &tmp
, ¬ice
.item
[i
]);
778 copy(&tmp
, " Internet web site URL", -1);
779 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
780 comment(¬ice
, &buf
, NiL
, 0, 0);
781 expand(¬ice
, &tmp
, ¬ice
.item
[URL
]);
782 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
783 if (notice
.item
[URLMD5
].data
)
785 copy(&tmp
, "(with an md5 checksum of ", -1);
786 expand(¬ice
, &tmp
, ¬ice
.item
[URLMD5
]);
788 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
790 comment(¬ice
, &buf
, NiL
, 0, 0);
792 COMMENT(¬ice
, &buf
, "If you have copied or used this software without agreeing", 0);
793 COMMENT(¬ice
, &buf
, "to the terms of the license you are infringing on", 0);
794 COMMENT(¬ice
, &buf
, "the license and copyright and are violating", 0);
796 expand(¬ice
, &tmp
, ¬ice
.item
[i
]);
797 copy(&tmp
, "'s", -1);
799 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
802 copy(&tmp
, "intellectual property rights.", -1);
803 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
804 comment(¬ice
, &buf
, NiL
, 0, 0);
806 else if (notice
.type
== GPL
)
808 comment(¬ice
, &buf
, NiL
, 0, 0);
809 COMMENT(¬ice
, &buf
, "This is free software; you can redistribute it and/or", 0);
810 COMMENT(¬ice
, &buf
, "modify it under the terms of the GNU General Public License", 0);
811 COMMENT(¬ice
, &buf
, "as published by the Free Software Foundation;", 0);
812 COMMENT(¬ice
, &buf
, "either version 2, or (at your option) any later version.", 0);
813 comment(¬ice
, &buf
, NiL
, 0, 0);
814 COMMENT(¬ice
, &buf
, "This software is distributed in the hope that it", 0);
815 COMMENT(¬ice
, &buf
, "will be useful, but WITHOUT ANY WARRANTY;", 0);
816 COMMENT(¬ice
, &buf
, "without even the implied warranty of MERCHANTABILITY", 0);
817 COMMENT(¬ice
, &buf
, "or FITNESS FOR A PARTICULAR PURPOSE.", 0);
818 COMMENT(¬ice
, &buf
, "See the GNU General Public License for more details.", 0);
819 comment(¬ice
, &buf
, NiL
, 0, 0);
820 COMMENT(¬ice
, &buf
, "You should have received a copy of the", 0);
821 COMMENT(¬ice
, &buf
, "GNU General Public License", 0);
822 COMMENT(¬ice
, &buf
, "along with this software (see the file COPYING.)", 0);
823 COMMENT(¬ice
, &buf
, "If not, a copy is available at", 0);
824 COMMENT(¬ice
, &buf
, "http://www.gnu.org/copyleft/gpl.html", 0);
825 comment(¬ice
, &buf
, NiL
, 0, 0);
827 else if (notice
.type
== BSD
)
829 comment(¬ice
, &buf
, NiL
, 0, 0);
830 COMMENT(¬ice
, &buf
, "Redistribution and use in source and binary forms, with or", -1);
831 COMMENT(¬ice
, &buf
, "without modification, are permitted provided that the following", -1);
832 COMMENT(¬ice
, &buf
, "conditions are met:", -1);
833 comment(¬ice
, &buf
, NiL
, 0, 0);
834 COMMENT(¬ice
, &buf
, " 1. Redistributions of source code must retain the above", -1);
835 COMMENT(¬ice
, &buf
, " copyright notice, this list of conditions and the", -1);
836 COMMENT(¬ice
, &buf
, " following disclaimer.", -1);
837 comment(¬ice
, &buf
, NiL
, 0, 0);
838 COMMENT(¬ice
, &buf
, " 2. Redistributions in binary form must reproduce the above", -1);
839 COMMENT(¬ice
, &buf
, " copyright notice, this list of conditions and the", -1);
840 COMMENT(¬ice
, &buf
, " following disclaimer in the documentation and/or other", -1);
841 COMMENT(¬ice
, &buf
, " materials provided with the distribution.", -1);
842 comment(¬ice
, &buf
, NiL
, 0, 0);
843 copy(&tmp
, " 3. Neither the name of ", -1);
844 if (notice
.item
[i
= PARENT
].data
|| notice
.item
[i
= CORPORATION
].data
|| notice
.item
[i
= COMPANY
].data
)
845 expand(¬ice
, &tmp
, ¬ice
.item
[i
]);
847 copy(&tmp
, "the copyright holder", -1);
848 copy(&tmp
, " nor the", -1);
849 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), -1);
850 COMMENT(¬ice
, &buf
, " names of its contributors may be used to endorse or", -1);
851 COMMENT(¬ice
, &buf
, " promote products derived from this software without", -1);
852 COMMENT(¬ice
, &buf
, " specific prior written permission.", -1);
853 comment(¬ice
, &buf
, NiL
, 0, 0);
854 COMMENT(¬ice
, &buf
, "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND", -1);
855 COMMENT(¬ice
, &buf
, "CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,", -1);
856 COMMENT(¬ice
, &buf
, "INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF", -1);
857 COMMENT(¬ice
, &buf
, "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE", -1);
858 COMMENT(¬ice
, &buf
, "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS", -1);
859 COMMENT(¬ice
, &buf
, "BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,", -1);
860 COMMENT(¬ice
, &buf
, "EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED", -1);
861 COMMENT(¬ice
, &buf
, "TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,", -1);
862 COMMENT(¬ice
, &buf
, "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON", -1);
863 COMMENT(¬ice
, &buf
, "ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,", -1);
864 COMMENT(¬ice
, &buf
, "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY", -1);
865 COMMENT(¬ice
, &buf
, "OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE", -1);
866 COMMENT(¬ice
, &buf
, "POSSIBILITY OF SUCH DAMAGE.", -1);
867 comment(¬ice
, &buf
, NiL
, 0, 0);
869 else if (notice
.type
== ZLIB
)
871 comment(¬ice
, &buf
, NiL
, 0, 0);
872 COMMENT(¬ice
, &buf
, "This software is provided 'as-is', without any express or implied", -1);
873 COMMENT(¬ice
, &buf
, "warranty. In no event will the authors be held liable for any", -1);
874 COMMENT(¬ice
, &buf
, "damages arising from the use of this software.", -1);
875 comment(¬ice
, &buf
, NiL
, 0, 0);
876 COMMENT(¬ice
, &buf
, "Permission is granted to anyone to use this software for any", -1);
877 COMMENT(¬ice
, &buf
, "purpose, including commercial applications, and to alter it and", -1);
878 COMMENT(¬ice
, &buf
, "redistribute it freely, subject to the following restrictions:", -1);
879 comment(¬ice
, &buf
, NiL
, 0, 0);
880 COMMENT(¬ice
, &buf
, " 1. The origin of this software must not be misrepresented;", -1);
881 COMMENT(¬ice
, &buf
, " you must not claim that you wrote the original software. If", -1);
882 COMMENT(¬ice
, &buf
, " you use this software in a product, an acknowledgment in the", -1);
883 COMMENT(¬ice
, &buf
, " product documentation would be appreciated but is not", -1);
884 COMMENT(¬ice
, &buf
, " required.", -1);
885 comment(¬ice
, &buf
, NiL
, 0, 0);
886 COMMENT(¬ice
, &buf
, " 2. Altered source versions must be plainly marked as such,", -1);
887 COMMENT(¬ice
, &buf
, " and must not be misrepresented as being the original", -1);
888 COMMENT(¬ice
, &buf
, " software.", -1);
889 comment(¬ice
, &buf
, NiL
, 0, 0);
890 COMMENT(¬ice
, &buf
, " 3. This notice may not be removed or altered from any source", -1);
891 COMMENT(¬ice
, &buf
, " distribution.", -1);
892 comment(¬ice
, &buf
, NiL
, 0, 0);
894 else if (notice
.type
== MIT
)
896 comment(¬ice
, &buf
, NiL
, 0, 0);
897 COMMENT(¬ice
, &buf
, "Permission is hereby granted, free of charge, to any person", 0);
898 COMMENT(¬ice
, &buf
, "obtaining a copy of this software and associated", 0);
899 COMMENT(¬ice
, &buf
, "documentation files (the \"Software\"), to deal in the", 0);
900 COMMENT(¬ice
, &buf
, "Software without restriction, including without limitation", 0);
901 COMMENT(¬ice
, &buf
, "the rights to use, copy, modify, merge, publish, distribute,", 0);
902 COMMENT(¬ice
, &buf
, "sublicense, and/or sell copies of the Software, and to", 0);
903 COMMENT(¬ice
, &buf
, "permit persons to whom the Software is furnished to do so,", 0);
904 COMMENT(¬ice
, &buf
, "subject to the following conditions:", 0);
905 comment(¬ice
, &buf
, NiL
, 0, 0);
906 COMMENT(¬ice
, &buf
, "The above copyright notice and this permission notice shall", 0);
907 COMMENT(¬ice
, &buf
, "be included in all copies or substantial portions of the", 0);
908 COMMENT(¬ice
, &buf
, "Software.", 0);
909 comment(¬ice
, &buf
, NiL
, 0, 0);
910 COMMENT(¬ice
, &buf
, "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY", 0);
911 COMMENT(¬ice
, &buf
, "KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE", 0);
912 COMMENT(¬ice
, &buf
, "WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR", 0);
913 COMMENT(¬ice
, &buf
, "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS", 0);
914 COMMENT(¬ice
, &buf
, "OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR", 0);
915 COMMENT(¬ice
, &buf
, "OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR", 0);
916 COMMENT(¬ice
, &buf
, "OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE", 0);
917 COMMENT(¬ice
, &buf
, "SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", 0);
918 comment(¬ice
, &buf
, NiL
, 0, 0);
922 if (notice
.type
== PROPRIETARY
)
924 if (notice
.item
[i
= PARENT
].data
|| notice
.item
[i
= CORPORATION
].data
|| notice
.item
[i
= COMPANY
].data
)
926 expand(¬ice
, &tmp
, ¬ice
.item
[i
]);
927 copy(&tmp
, " - ", -1);
931 copy(&tmp
, "Proprietary", -1);
932 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 1);
933 comment(¬ice
, &buf
, NiL
, 0, 0);
934 if (notice
.item
[URL
].data
)
936 copy(&tmp
, "This is proprietary source code", -1);
938 copy(&tmp
, " licensed by", -1);
939 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 1);
940 if (notice
.item
[PARENT
].data
)
942 expand(¬ice
, &tmp
, ¬ice
.item
[PARENT
]);
945 if (notice
.item
[CORPORATION
].data
)
947 expand(¬ice
, &tmp
, ¬ice
.item
[CORPORATION
]);
948 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 1);
950 else if (notice
.item
[COMPANY
].data
)
952 expand(¬ice
, &tmp
, ¬ice
.item
[COMPANY
]);
953 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 1);
958 copy(&tmp
, "This is unpublished proprietary source code", -1);
960 copy(&tmp
, " of", -1);
961 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 1);
962 if (notice
.item
[i
= PARENT
].data
|| notice
.item
[i
= CORPORATION
].data
)
963 expand(¬ice
, &tmp
, ¬ice
.item
[i
]);
964 if (notice
.item
[COMPANY
].data
)
968 expand(¬ice
, &tmp
, ¬ice
.item
[COMPANY
]);
971 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 1);
972 COMMENT(¬ice
, &buf
, "and is not to be disclosed or used except in", 1);
973 COMMENT(¬ice
, &buf
, "accordance with applicable agreements", 1);
975 comment(¬ice
, &buf
, NiL
, 0, 0);
977 else if (notice
.type
== NONEXCLUSIVE
)
979 COMMENT(¬ice
, &buf
, "For nonexclusive individual use", 1);
980 comment(¬ice
, &buf
, NiL
, 0, 0);
982 else if (notice
.type
== NONCOMMERCIAL
)
984 COMMENT(¬ice
, &buf
, "For noncommercial use", 1);
985 comment(¬ice
, &buf
, NiL
, 0, 0);
987 if (notice
.type
>= PROPRIETARY
&& !notice
.item
[URL
].data
)
989 COMMENT(¬ice
, &buf
, "Unpublished & Not for Publication", 0);
990 comment(¬ice
, &buf
, NiL
, 0, 0);
992 if (notice
.item
[URL
].data
)
994 copy(&tmp
, "This software is licensed", -1);
995 if (notice
.item
[CORPORATION
].data
|| notice
.item
[COMPANY
].data
)
997 copy(&tmp
, " by", -1);
998 if ((notice
.item
[PARENT
].size
+ (notice
.item
[CORPORATION
].data
? (notice
.item
[CORPORATION
].size
+ notice
.item
[INCORPORATION
].size
) : notice
.item
[COMPANY
].size
)) >= (COMLONG
- 6))
999 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
1002 if (notice
.item
[PARENT
].data
)
1004 expand(¬ice
, &tmp
, ¬ice
.item
[PARENT
]);
1005 copy(&tmp
, " ", -1);
1007 if (notice
.item
[CORPORATION
].data
)
1009 expand(¬ice
, &tmp
, ¬ice
.item
[CORPORATION
]);
1010 if (notice
.item
[INCORPORATION
].data
)
1012 copy(&tmp
, " ", -1);
1013 expand(¬ice
, &tmp
, ¬ice
.item
[INCORPORATION
]);
1016 else if (notice
.item
[COMPANY
].data
)
1017 expand(¬ice
, &tmp
, ¬ice
.item
[COMPANY
]);
1019 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
1020 COMMENT(¬ice
, &buf
, "under the terms and conditions of the license in", 0);
1021 expand(¬ice
, &tmp
, ¬ice
.item
[URL
]);
1022 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
1023 if (notice
.item
[URLMD5
].data
)
1025 copy(&tmp
, "(with an md5 checksum of ", -1);
1026 expand(¬ice
, &tmp
, ¬ice
.item
[URLMD5
]);
1027 copy(&tmp
, ")", -1);
1028 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
1030 comment(¬ice
, &buf
, NiL
, 0, 0);
1032 else if (notice
.type
== PROPRIETARY
)
1034 COMMENT(¬ice
, &buf
, "The copyright notice above does not evidence any", 0);
1035 COMMENT(¬ice
, &buf
, "actual or intended publication of such source code", 0);
1036 comment(¬ice
, &buf
, NiL
, 0, 0);
1039 if (v
= notice
.item
[NOTICE
].data
)
1041 x
= v
+ notice
.item
[NOTICE
].size
;
1044 item
.quote
= notice
.item
[NOTICE
].quote
;
1047 for (item
.data
= v
; v
< x
&& *v
!= '\n'; v
++);
1048 if ((item
.size
= v
- item
.data
) && *item
.data
== '\t')
1056 expand(¬ice
, &tmp
, &item
);
1057 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), h
);
1060 comment(¬ice
, &buf
, NiL
, 0, 0);
1062 if (notice
.item
[ORGANIZATION
].data
)
1064 expand(¬ice
, &tmp
, ¬ice
.item
[ORGANIZATION
]);
1065 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
1066 if (notice
.item
[i
= PARENT
].data
|| notice
.item
[i
= CORPORATION
].data
)
1067 expand(¬ice
, &tmp
, ¬ice
.item
[i
]);
1068 if (notice
.item
[COMPANY
].data
)
1072 expand(¬ice
, &tmp
, ¬ice
.item
[COMPANY
]);
1075 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
1076 if (notice
.item
[LOCATION
].data
)
1078 expand(¬ice
, &tmp
, ¬ice
.item
[LOCATION
]);
1079 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
1081 comment(¬ice
, &buf
, NiL
, 0, 0);
1084 if (v
= notice
.item
[AUTHOR
].data
)
1086 x
= v
+ notice
.item
[AUTHOR
].size
;
1087 q
= (x
- v
) == 1 && (*v
== '*' || *v
== '-');
1088 k
= q
&& notice
.type
!= USAGE
? -1 : 0;
1093 while (v
< x
&& (*v
== ' ' || *v
== '\t' || *v
== '\r' || *v
== '\n' || *v
== ',' || *v
== '+'))
1098 while (v
< x
&& *v
!= ',' && *v
!= '+' && *v
++ != '>');
1099 item
.size
= v
- item
.data
;
1100 item
.quote
= notice
.item
[AUTHOR
].quote
;
1103 for (i
= 0; i
< notice
.ids
; i
++)
1104 if (q
|| item
.size
== notice
.id
[i
].name
.size
&& !strncmp(item
.data
, notice
.id
[i
].name
.data
, item
.size
))
1107 if (notice
.type
== USAGE
)
1109 copy(&buf
, "[-author?", -1);
1110 expand(¬ice
, &buf
, ¬ice
.id
[i
].value
);
1117 COMMENT(¬ice
, &buf
, "CONTRIBUTORS", 0);
1118 comment(¬ice
, &buf
, NiL
, 0, 0);
1121 expand(¬ice
, &tmp
, ¬ice
.id
[i
].value
);
1122 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
1131 if (notice
.type
== USAGE
)
1133 copy(&buf
, "[-author?", -1);
1134 expand(¬ice
, &buf
, &item
);
1141 COMMENT(¬ice
, &buf
, "CONTRIBUTORS", 0);
1142 comment(¬ice
, &buf
, NiL
, 0, 0);
1145 expand(¬ice
, &tmp
, &item
);
1146 comment(¬ice
, &buf
, BUF(&tmp
), USE(&tmp
), 0);
1151 comment(¬ice
, &buf
, NiL
, 0, 0);
1153 if (notice
.type
== USAGE
)
1155 copy(&buf
, "[-copyright?", -1);
1156 copyright(¬ice
, &buf
);
1158 if (notice
.item
[URL
].data
)
1160 copy(&buf
, "[-license?", -1);
1161 expand(¬ice
, &buf
, ¬ice
.item
[URL
]);
1167 comment(¬ice
, &buf
, NiL
, -1, 0);