Summer Training Report
Summer Training Report
TECHNOLOGY
(Guru Gobind Singh Indraprastha University)
Submitted by:
Pavas Sah
04796402710
PROJECT
Scientific Calculator using .NET
SUBMITTED IN PARTIAL FULFILLMENT OF THE DEGREE
OF
BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE ENGINEERING
CONTENTS
1. Acknowledgement
2. Company Profile
3. Activities
4. About Embedded Linux with ARM
5. About Linux
6. C with data structures
7. Shell scripting
8. Linux internals & system programming
9. Project: Multiple data compression and
encryption Using Iterative method
10. Source code of Project
ACKNOWLEDGEMENT
I hereby take this opportunity to thank all those people whose knowledge
and experience helped me bring this report in its present form. It would
have been a tough task for me to complete report without their help.
I express my sincere thanks and gratitude to My Guide Mr. (Project
Manager), R Systems International Ltd. for providing me the opportunity
to pursue my training at the institute.
I would like to express my gratitude to my group member, for helping me
in every aspect during the training phase as well as in carrying out the
whole project.
Finally I would like to express my deep appreciation to my family and
friends who have been a constant source of inspiration. I am internally
grateful to them for always encouraging me wherever and whenever I
needed them.
Pavas Sah
04796402710
INSTITUTE PROFILE
ABOUT RSI
R Systems (founded in 1993) is a specialized IT Services &
Solutions and IT-enabled Services provider catering to a wide
range of global customers. We are endowed with some of the
industrys highest quality certifications and standards, including
SEI CMMI Level 5, PCMM Level 5, ISO 27001:2005 and ISO
9001:2008. Our IT services and solutions span five major verticals
which include Telecom & Digital Media, Banking & Finance,
HealthCare, Manufacturing & Logistics, and Government
Services.
Ever since our inception, we have grown in size and capability
and currently operate from 13 development and service centers
spread across Asia Pacific, Europe, and North America. We serve
customers worldwide using our global delivery model and 2500+
expert resources. We have won countless accolades from global
customers for our benchmarked delivery track record, quality
standards, and adaptability to technological challenges.
Our strength lies in our quality procedures, delivery and
operational excellence, customer-centric approach, intellectual
capital, and culture of innovation. With a rich legacy spread over
two decades, we generate Value that helps organizations
transcend to higher levels of efficiency and growth. Quite like the
Oyster Delivering the Pearl!
Innovating
Transforming
LINUX
Linux is a Unix-like computer operating system assembled under the
model of free and open source software development and distribution. The
defining component of any Linux system is the Linux kernel, an operating
system kernel first released October 5, 1991 by Linus Torvalds. Linux
system distributions may vary in many details of system operation,
configuration, and software package selections.
Linux runs on a wide variety of computer hardware, including mobile
phones, tablet computers, network routers, televisions, video game
consoles, desktop computers, mainframes and supercomputers. Linux is a
leading server operating system, and runs the 10 fastest supercomputers in
the world. In addition, more than 90% of today's supercomputers run some
variant of Linux.
Most Linux distributions support dozens of programming languages. The
original development tools used for building both Linux applications and
operating system programs are found within the GNU toolchain, which
includes the GNU Compiler Collection (GCC) and the GNU build system.
Amongst others, GCC provides compilers for Ada, C, C++, Java, and
Fortran. The whole Linux kernel is written in C language.
SHELL SCRIPTING
A shell script is a script written for the shell, or command line interpreter,
of an operating system. It is often considered a simple domain-specific
programming language. Typical operations performed by shell scripts
include file manipulation, program execution, and printing text.
Many shell script interpreters double as command line interface, such as
the various Unix shells, C Shell and bash shell etc.
In their most basic form, a shell script can provide a convenient variation of
a system command where special environment settings, command options,
or post processing is applied automatically, but in a way that allows the
new script to still act as a fully normal LINUX command.
Objective
This short course is designed to ensure that we, the students of Engineering
College with academic capabilities will have the skill set needed to deal
with the challenges involved in real-world Scripting to meet the needs of
industries both today and in the future.
Contents:
LINUX INTERNALS
AND
SYSTEM PROGRAMMING
This is advanced/internals-based knowledge required for the true
understanding of the advanced topics and supporting a UNIX or Linux
system. It consists, how the internals of the operating system hangs
together - it is intended to assist with the administration of the operating
system itself and the theory can be applied to both the UNIX and the Linux
operating systems.
Linux is a freely distributed implementation of UNIX-like kernel, low-level
core of an operating system. All programs written for UNIX can be
compiled and run on Linux. Linux applications are represented by two
special types of files: executable and scripts.
Executable files are programs that can be run directly by the compiler; they
correspond to windows .exe files.
Scripts are collections of instructions for another program, an interpreter, to
follow. There correspond to Windows .bat or .cmd files, or interpreted
BASIC programs.
Linux does not require executables or scripts to have a specific filename or
any extension whatsoever. File system attributes, are used to indicate that a
file is a program that may be run.
In linux, we can replace scripts with compiled programs without affecting
other programs, is comes under the system programming in which user
prepares software for system or kernel of operating systems.
Objective
This short course is designed to ensure that we, the students of Engineering
College with academic Capabilities will have the skill set needed to deal
with the challenges involved in real-world Programming to meet the needs
of industries both today and in the future.
The course is taught mainly using the gcc compiler, with Linux operating
system.
Course Contents:
PROJECT
MULTIPLE DATA COMPRESSION
AND
ENCRYPTION
USING
ITERATIVE METHOD
Description :
It is a C program developed for COMPRESSION & ENCRYPTION of a
text file. Whole code is written in C language (GNU standard) using GCC
compiler in LINUX environment. It should required to work on Terminal
(Linux based Shell) for invoking this project.
Scope:
Scope of this project is in the field of communication where the
same information can be transmitted in less number of Bytes as
compared to original text. Since the information is also in the encrypted
format so no one can understand the actual information contained in
the text. So it has many application in the Military Forces where
information should be secured also in the transmission from one site to
another.
How to invoke :
For invoking this project we required the executable file of this
project only. NO need of whole C program.
I have named the compiled code as compress which is a
executable file.
You should run this file in terminal as:
$ ./compress <your file name>
It will compress and also encrypt your file. The new compressed file
named as
<your file name>.7zip
Now if we want to decompress this file on another location or site we
should required again only the executable code compress only. We
can decompress and de-encrypt our compressed file named as
<your file name>.7zip just by writing in terminal as:
$ ./compress <your file name>.7zip -d
(here we need to pass an argument -d for decompressing it.)
Mutliple compression:
By the use of multiple compression, we can compress our file to
many levels (limited). We can compress our pre-compressed file to
another level. The new file will get another .7zip extension. Means
number of times .7zip extension tells you the level of compression.
--> <your file name>.7zip.7zip
(contains two level of compression)
But you can compress under a certain limit because after a certain
limit the compressed file size can be more than the normal file size.
For example:
Open the terminal.
$ cd compress_project
$ ls
$ vi nik
(show the content of nik)
$ ./compress nik
$ vi nik.7zip
(Multiple compression)
SOURCE CODE
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *compress_name;
/**************Function declarations**************/
void compress2(unsigned char*,int);
void compress3(unsigned char*,int);
void compress4(unsigned char*,int);
void compress5(unsigned char*,int);
void compress6(unsigned char*,int);
void compress7(unsigned char*,int);
void decompress2(unsigned char*,char*);
void decompress3(unsigned char*,char*);
void decompress4(unsigned char*,char*);
void decompress5(unsigned char*,char*);
void decompress6(unsigned char*,char*);
void decompress7(unsigned char*,char*);
/****************start of Main********************/
int main(int argc, char* argv[])
{
char *p,*m,*m1,*ar,*co,ch;
int i,j,l1,l,l2,k,flag,*as;
FILE *fd,*f,*fopen();
int SIZE;
SIZE=0;
if(argv[2]==NULL)
{
fd= fopen(argv[1],"r");
if(fd==NULL)
{
printf("error : No such file or directory.\n");
exit(EXIT_FAILURE);
}
while((ch=getc(fd))!=EOF)
{
SIZE++;
}
m=malloc(sizeof(char)*127); //master array
p=malloc(sizeof(char)*SIZE); //main string
ar=malloc(sizeof(char)*SIZE);
i=0;
fclose(fd);
fd=fopen(argv[1],"r");
while((ch=getc(fd))!=EOF)
{
*(p+i)=ch;
i++;
}
i--;
l=strlen(p);
compress_name=malloc(sizeof(char)*50);
compress_name=argv[1];
strcat(compress_name,".7zip");
/****************************Generating master array*****************/
for(i=0,j=0;i<l;i++)
{
flag=0;
for(k=0;k<j;k++)
{
if(*(p+i)==*(m+k))
{
flag=1;
break;
}
}
if(flag==0)
{
*(m+j)=*(p+i);
j++;
}
}
l1=strlen(m);
//length of master array
char lm;
lm=(char)l1;
f=fopen(compress_name,"w");
putc(lm,f);
for(i=0;i<l1;i++)
{
putc(*(m+i),f);
}
fclose(f);
/**************generating original array with ASCII values**************/
for(i=0;i<l;i++)
{
for(j=0;j<l1;j++)
{
if(*(m+j)==*(p+i))
*(ar+i)=j+1;
}
}
fclose(fd);
/****************************calling of function*******************/
if(l1>=2 && l1<=4)
compress2(ar,l-1);
if(l1>=5 && l1<=8)
compress3(ar,l-1);
if(l1>=9 && l1<=16)
compress4(ar,l-1);
if(l1>=17 && l1<=32)
compress5(ar,l-1);
if(l1>=33 && l1<=64)
compress6(ar,l-1);
if(l1>=65 && l1<=128)
compress7(ar,l-1);
if(l1>128)
printf("Hey you, file should be in ASCII characters\n");
printf("File compressed successfully with the extension of
.7zip...\n");
}
/**********************Reading of file for decompression**************/
else
{
FILE *fd1,*fopen();
char lm2;
fd1=fopen(argv[1],"r");
if(fd1==NULL)
{
printf("error : No such file or directory.\n");
exit(EXIT_FAILURE);
}
SIZE=0;
while((ch=getc(fd1))!=EOF)
{
SIZE++;
}
fclose(fd1);
co=malloc(sizeof(char)*SIZE);
m1=malloc(sizeof(char)*127);
i=0;
fd1=fopen(argv[1],"r");
lm2=getc(fd1);
for(i=0;i<lm2;i++)
{
ch=getc(fd1);
*(m1+i)=ch;
}
*(m1+i)='\0';
i=0;
while((ch=getc(fd1))!=EOF)
{
*(co+i)=ch;
i++;
}
i--;
fclose(fd1);
/**************************Decompression***********************/
if(lm2>=2 && lm2<=4)
decompress2(co,m1);
if(lm2>=5 && lm2<=8)
decompress3(co,m1);
if(lm2>=9 && lm2<=16)
decompress4(co,m1);
if(lm2>=17 && lm2<=32)
decompress5(co,m1);
if(lm2>=33 && lm2<=64)
decompress6(co,m1);
if(lm2>=65 && lm2<=128)
decompress7(co,m1);
if(lm2>128)
printf("Hey you, file should be in ASCII characters\n");
printf("File decompressed successfully.\n File name is :
hemnew\n");
}
return 0;
}
//end of main
/***********************compression functions***************************/
void compress2(unsigned char *temp,int len)
{
int i;
FILE *f,*fopen();
f = fopen(compress_name,"a");
for(i=0;i<len;i=i+4)
//performing compression
{
unsigned char a,b,c,d,e;
d=*(temp+i)<<6;
c=(*(temp+i+1)<<4)&(48);
b=(*(temp+i+2)<<2)&(12);
a=(*(temp+i+3))&(3);
e=a|b|c|d;
putc(e,f);
}
fclose(f);
}
c=((*(temp+i+4)<<7))|((*(temp+i+5)<<2)&124)|((*(temp+i+6)
>>3)&3);
putc(c,f);
c=((*(temp+i+6)<<5))|((*(temp+i+7)&31));
putc(c,f);
}
fclose(f);
}
void compress6(unsigned char *temp,int len)
{
int i;
unsigned char c,d,e;
FILE *f,*fopen();
f=fopen(compress_name,"a");
for (i=0;i<len;i+=4)
{
c= ((*(temp+i)<<2)&(252)|(*(temp+i+3))&(3));
putc(c,f);
d=((*(temp+i+1)<<2)&(252)|(*(temp+i+3)>>2)&(3));
putc(d,f);
e=((*(temp+i+2)<<2)&(252)|(*(temp+i+3)>>4)&(3));
putc(e,f);
}
fclose(f);
}
void compress7(unsigned char *temp,int len)
{
int i;
unsigned char c;
FILE *f,*fopen();
f=fopen(compress_name,"a");
for(i=0;i<len;i+=8)
{
c= ((*(temp+i)<<1)&(254)|(*(temp+i+7)>>6)&(1));
putc(c,f);
c= ((*(temp+i+1)<<1)&(254)|(*(temp+i+7)>>5)&(1));
putc(c,f);
c= ((*(temp+i+2)<<1)&(254)|(*(temp+i+7)>>4)&(1));
putc(c,f);
c= ((*(temp+i+3)<<1)&(254)|(*(temp+i+7)>>3)&(1));
putc(c,f);
c= ((*(temp+i+4)<<1)&(254)|(*(temp+i+7)>>2)&(1));
putc(c,f);
c= ((*(temp+i+5)<<1)&(254)|(*(temp+i+7)>>1)&(1));
putc(c,f);
c= ((*(temp+i+6)<<1)&(254)|(*(temp+i+7))&(1));
putc(c,f);
}
fclose(f);
}
/************************Decompression function**********************/
void decompress2(unsigned char *temp,char *m)
{
int l,l1,i,j;
unsigned char ch;
l=strlen(temp);
l1=strlen(m);
FILE *f,*fopen();
f=fopen("hemnew","w");
for(i=0;i<l;i++)
{
ch=*(temp+i)>>6;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i)>>4)&(3);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i)>>2)&(3);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=*(temp+i)&(3);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
}
fclose(f);
}
void decompress3(unsigned char *temp,char *m)
{
int l,l1,i,j;
unsigned char ch;
l=strlen(temp);
l1=strlen(m);
FILE *f,*fopen();
f=fopen("hemnew","w");
for(i=0;i<l;i+=3)
{
ch=*(temp+i)>>5;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i)>>2)&(7);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch= (*(temp+i)<<1)&(6)|(*(temp+i+1)>>7)&(1);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i+1)>>4)&(7);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i+1)>>1)&(7);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i+1)<<2)&(4)|(*(temp+i+2)>>6)&(3);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i+2)>>3)&(7);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch= *(temp+i+2)&(7);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
}
fclose(f);
}
void decompress4(unsigned char *temp,char *m)
{
int l,l1,i,j;
unsigned char ch;
l=strlen(temp);
l1=strlen(m);
FILE *f,*fopen();
f=fopen("hemnew","w");
for(i=0;i<l;i++)
{
ch=(*(temp+i)>>4)&(15);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=*(temp+i)&(15);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
}
fclose(f);
}
void decompress5(unsigned char *temp,char *m)
{
int l,l1,i,j;
unsigned char ch;
l=strlen(temp);
l1=strlen(m);
FILE *f,*fopen();
f=fopen("hemnew","w");
for(i=0;i<l;i+=5)
{
ch=(*(temp+i)>>3);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=((*(temp+i)&7)<<2)|((*(temp+i+1)>>6));
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i+1)>>1)&(31);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i+1)<<4)&(16)|((*(temp+i+2)>>4));
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=((*(temp+i+2)<<1)&(31))|(*(temp+i+3)>>7);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=((*(temp+i+3)>>2)&(31));
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=((*(temp+i+3)<<3)&(31))|((*(temp+i+4)>>5));
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=((*(temp+i+4)&(31)));
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
}
fclose(f);
}
void decompress6(unsigned char *temp,char *m)
{
int l,l1,i,j;
unsigned char ch;
l=strlen(temp);
l1=strlen(m);
FILE *f,*fopen();
f=fopen("hemnew","w");
for(i=0;i<l;i+=3)
{
ch=*(temp+i)>>2;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch =*(temp+i+1)>>2;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=*(temp+i+2)>>2;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i)&(3))|(*(temp+i+1)<<2)&(12)|(*(temp+i+2)<<4)&(48);
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
}
fclose(f);
}
void decompress7(unsigned char *temp,char *m)
{
int l,l1,i,j;
unsigned char ch;
l=strlen(temp);
l1=strlen(m);
FILE *f,*fopen();
f=fopen("hemnew","w");
for(i=0;i<l;i+=7)
{
ch=*(temp+i)>>1;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=*(temp+i+1)>>1;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch= *(temp+i+2)>>1;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=*(temp+i+3)>>1;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=*(temp+i+4)>>1;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=*(temp+i+5)>>1;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=*(temp+i+6)>>1;
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
ch=(*(temp+i)<<6)&(64)|(*(temp+i+1)<<5)&(32)|(*(temp+i+2)<<4)&(16)|(
*(temp+i+3)<<3)&(8)|(*(temp+i+4)<<2)&(4)|(*(temp+i+5)<<1)&(2)|(*(temp+i+6)
&(1));
for(j=0;j<l1;j++)
{
if(ch==(j+1))
{
putc(*(m+j),f);
break;
}
}
}
fclose(f);
}
//*****************End of decompressing functions***************//