開源協議是指開放源代碼的軟件授權協議,該協議規定了對開發人員、使用人員及其他第三方在使用軟件時所需遵守的條件。開放源代碼的軟件授權方式旨在促進軟件的自由和創新,使得開發人員和其他人員可以自由地獲取和使用軟件。
一、GPL協議
GPL是最受歡迎的開源協議之一,最初由Richard Stallman為GNU項目編寫,其開源模式基於重要概念之一:共享,GPL強制規定,任何以GPL協議發佈的軟件或其他衍生作品,必須以同樣的方式分發,以便使其他人可以免費訪問同樣的信息。
同樣重要的是:任何將GPL代碼合併到自己的代碼庫中,都必須遵守GPL協議。因此,如果有人想將GPL代碼用於商業目的,那麼他必須將自己的代碼同樣以GPL方式發佈。
以下是一個使用GPL協議的代碼示例:
/* This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation */
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
二、MIT協議
MIT協議是一種更靈活的開源協議,以其更小、更鬆散的代碼結構而聞名。該協議授權人員允許自由使用他們的軟件,並且沒有義務將任何代碼更改或演變傳回原作者。這使得MIT協議非常適用於各種不同的授權模型,包括商業授權和非官方開源授權的混合使用。
以下是一個使用MIT協議的代碼示例:
/* Copyright (c) 2021
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. */
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
三、Apache協議
Apache協議是用於Apache軟件基金會的開源授權方式。該許可證需要用戶遵守類似於MIT許可證引用和消費約定。不同於MIT許可證的是,Apache許可證要求所有變更或改進的代碼都必須公開,以便其他人可以參考或使用,無論其是否是微小或重大的變化。
以下是一個使用Apache協議的代碼示例:
/* Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at */
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
四、BSD協議
BSD協議是用於BSD操作系統的開源授權方式,類似於MIT和Apache許可證的自由使用模式,但也有一些區別。這些包括它的使用必須符合原來的BSD許可證,並同樣要求用戶在進行產品推廣時必須提供相應的傳達信息。
以下是一個使用BSD協議的代碼示例:
/* Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. */
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
五、Eclipse協議
Eclipse協議是一個專門用於Eclipse開源項目的許可證,強調了保護知識產權、享有自由和保障核心建設的原則,與GPL和BSD等其他許可證有所不同。不過,Eclipse可以和其他開源許可證混合使用,可在可移植的軟件系統和網絡應用中廣泛使用。
以下是一個使用Eclipse協議的代碼示例:
/*
SPDX-License-Identifier: EPL-2.0
Eclipse Public License - v 2.0
*/
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/181918.html