I am creating a project I am thinking about open sourcing but I am concerned about the licensing issue of what exactly is trivial code. I am concerned because if I did not know how to do something I would just look online or in books for examples. If I was looking to learn how to implement some logical concept like a merge sort I would translate some pseudo-code into C or on the other hand if I was looking for the syntax form I would look at code snippets that does a certain operation i was interested in such as:
int copyfile(char *sourcepath,char *destpath)
{
int dest_fd;
int source_fd;
int errorcode = 0;
if((source_fd = open(sourcepath,O_RDONLY)) < 0)
return 1;
if((dest_fd = open(destpath,O_WRONLY|O_CREAT|O_TRUNC,0755)) <0)
return 1;
char *buf[4096];
ssize_t readval;
while((readval = read(source_fd,buf,sizeof(buf)) > 0))
{
if(write(dest_fd,buf,readval) > 0)
errorcode = 1;
}
close(source_fd);
close(dest_fd);
return errorcode;
}
Would something like this cause me an issue in licensing my project?
Addendum: I have a follow up question in the same vein and I thought that I should add it to this one over creating a whole new question. If this an incorrect conclusion let me know in the comments.
Basically the project im working on in my spare time to learn the in's and out's of a POSIX compliant system and the POSIX C library is basically reading the Single Unix Specification documents and trying to clean room re-implement them with the eventual goal of having a small fully compliant POSIX system capable of boot strapping itself without the dependency of the GNU tools and under a single license.
In this endeavor I've started to read classic UNIX and C works like the K & R book in which they explain fundamental concepts of the C language creating examples that are stripped down versions of Unix utilities and C stdlib function and more importantly some of the algorithms behind these functions as well as some what in my mind seem to be fundamental concepts of computer science.
Breaking this into two subquestions one dealing with what I would describe as fundamental concepts and the other dealing with well known algorithms.
1.a What is the delineation point between basic logical concepts and copyrighted code. Giving a few examples: (also these are off the top of my head from what I remember not directly copied just in case).
1.a.1 The standard library function strlen which returns the length of a string minus the null can be described like
int strlen(char *string)
{
int i;
for(i = 1;string[i] != NULL;i++)
;
return i;
}
(Also I know strlen is of type size_t in the stdlib)
1.a.2
void swap(char *old,char *new)
{
char *tmp = old;
old = new;
new = tmp;
return;
}
Example 1.a.1 when boiled down to a simplistic child like definition is count each position until x is found.
Example 1.a.2 basically swap x with y and y with x.
Extracting the idea to the world of the physical my examples are respectively, count up a set number of items until you run out then stop leaving the last number said / though as how many items you have, and take one item and swap places with a second item. Which describe two skills / concepts a young child can understand.
Thus dove tailing back into my first subquestion. At what level does something go from programming something that is so fundamentally logically simplistic to something licensable. Would using a commonly used loop variable name like i or logical names like temp / tmp for temporary storage or string / str / s for string cause an issue or are these things so simplistic that it is classified as what someone in the comments below mentioned de minimis or the merger doctrine ?
1.b
This second subquestion falls under the category of seeing example implementations of basic algorithms I.e the type of things taught first or second year students in a principles of algorithmic design 101 class such as quick sort or binary search of which there are a very finite number of ways in which to go about implementing.
xargs 3 5 7
, that may be hard to license, as your trying to claim creator ship of a program and a few odd numbers. I believe that is what is meant by "trivial".