EmbLogic's Blog

Author Archives: Harminder Singh

CHARACTER DRIVER INITIALIZATION, OPENING , WRITING ,CLOSING, and CLEANUP.

RCS FILE OF THE HEADER.H OF THE CHARACTER DRIVER RCS file: header.h,v Working file: header.h head: 1.10 branch: locks: strict root: 1.10 access list: symbolic names: keyword substitution: kv total revisions: 10;    selected revisions: 10 description: This is the header … Continue reading

Posted in Uncategorized | Leave a comment

IPC using sockets AF_INET/ tcp

IPC Using SOCKETS AF_INET RCS file: server.c,v Working file: server.c head: 1.1 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 1;    selected revisions: 1 description: Server implementaton using TCP , AF_INET. >> Calls used : socket(), … Continue reading

Posted in Uncategorized | Leave a comment

IPC using sockets AF_UNIX / TCP

IPC Using SOCKETS AF_UNIX RCS file: server.c,v Working file: server.c head: 1.1 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 1;    selected revisions: 1 description: Server implementaton using TCP , AF_UNIX. >> Calls used : socket(), … Continue reading

Posted in Uncategorized | Leave a comment

Inter Process Communication using MESSAGE QUEUES.

IPC USING MESSAGE QUEUES RCS file: header.h,v Working file: header.h head: 1.1 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 1;    selected revisions: 1 description: included stdio.h, sys/msg.h, stdlib.h, sys/types.h, unistd.h, sys/ipc.h. —————————- revision 1.1 date: … Continue reading

Posted in Uncategorized | Leave a comment

IPC USING FIFOS AND SEMAPHORES.

HEADER FILE *************************************************************** RCS file: ./header.h,v Working file: ./header.h head: 1.1 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 1;    selected revisions: 1 description: Included “stdio.h” , “stdlib.h”, “unistd.h”, “linux/sem.h”, “fcntl.h”, and “signal.h”. Declaration of the … Continue reading

Posted in Uncategorized | Leave a comment

INTER PROCESS COMMUNICATION USING PIPES.(client server based)

INTER PROCESS COMMUNICATION USING PIPES. RCS file: header.h,v Working file: header.h head: 1.1 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 1;    selected revisions: 1 description: Included stdio.h. and fcntl.h. ,sys/types.h, stdlib.h, unistd.h. —————————- revision 1.1 … Continue reading

Posted in Uncategorized | Leave a comment

Implementation of Circular Queue using linked list.

HEADER *************************************************************** #include<stdio.h> #include<stdlib.h> struct cq { int info; struct cq *next; }; int getchoice(); int operation(int, struct cq **, struct cq **, struct cq **); int enqueue( struct cq **, struct cq **, struct cq **); int display( struct … Continue reading

Posted in Uncategorized | Leave a comment

function to detect comon node in two linked lists and correct them.

int fix_cnode(struct node **start, struct node **start1) { struct node *temp,**ma,*temp1; int count = 0,i,flag =1; temp = *start; ma = calloc(sizeof(struct node *),20); while(1) { flag = 1; if(!(temp->next)) { printf(“there is no loop\n”); goto o; } for(i=0; i<count; … Continue reading

Posted in Uncategorized | Leave a comment

function to detect a loop in linked list and remove the loop.

int fix_loop(struct node **start)// pass start as a pass by reference argument { struct node *temp,**ma; int count = 0,i; temp = *start; ma = calloc(sizeof(struct node *),20); while(1) { if(!(temp->next)) { printf(“there is no loop\n”); return -1; } for(i=0; … Continue reading

Posted in Uncategorized | Leave a comment

Program in c to print sin wave.

#include<stdio.h> #include<math.h> int main() { double a,b,i; int j; int count=0; a=22.0/7.0; for(i=0.0; i <= 4.0; i+=0.1) { b= sin(a*i)+ cos(a*i); if(b >= 0) { printf(”          “); for(j =10*b;j >= 0.0; j-=1.0) { printf(” “); } } if(b < 0.0) … Continue reading

Posted in Uncategorized | Leave a comment

a program to read all text files in current directory and merge them all into one text file (assignment13 q6) using

#include<stdio.h> #include<fcntl.h> #include<dirent.h> #include<string.h> int openf(char *); int main() { DIR *i; struct dirent *k; int j,l,s,flag=1,fd,fd1; char *m = “txt.”; char ch; fd1 = openf(“new.txt”); i = opendir(“./test”); printf(“\n%d\n”,i); while(( k = readdir(i)) !=  NULL) { flag=1; l=strlen(k->d_name); for(j … Continue reading

Posted in Uncategorized | Leave a comment

A function foo(int fd, char * buff , int n, int b_size, int skip) that reads to buff from file where file descriptor fd , n blocks of size b_size each , the last argument specifies the number of bits to skip after each block.

#include<stdio.h> #include<fcntl.h> #include<stdlib.h> int foo(int ,  char *, int , int , int, char *); int openf( char *); int main(int argc, char * argv[]) { int fd,pos,skip,b_size,n; char ch,*buff; buff = (char*)malloc(sizeof(char)); printf(“\nBlock size: “); scanf(“%d”,&b_size); printf(“\nNumber of Blocks: … Continue reading

Posted in Uncategorized | Leave a comment

program to make a 4gb file with free space. file with holes.

#include<stdio.h> #include<fcntl.h> int openf(char *); int main(int argc, char * argv[]) { int fd,fd1, pos,i=1000000; char ch=”; fd = openf(argv[1]); pos = lseek(fd,i * 4096, SEEK_SET); write(fd, &ch,1); close(fd); } int openf(char * s) { int fd; fd = open(s,O_RDWR|O_CREAT,0666); … Continue reading

Posted in Uncategorized | Leave a comment

program to read text from a file and store it in reverse order

#include<stdio.h> #include<fcntl.h> int openf(char *); int main(int argc, char * argv[]) { int fd,fd1, pos,i=3; char ch; fd = openf(argv[1]); fd1 = openf(argv[2]); pos = lseek(fd, 0, SEEK_END); printf(“\n%d\n”,pos); for(i=2; i < pos+1;i++) { lseek(fd, pos-i, SEEK_SET); read(fd, &ch, 1); … Continue reading

Posted in Uncategorized | Leave a comment

adding two distances in feet and inches using functions and structure pointers

header file********************************************************************* #include<stdio.h> #include<stdlib.h> struct distance {    int feet; int inches; }; int display(struct distance *,struct distance *,struct distance *); struct distance * add(struct distance *,struct distance *); struct distance * input(); ************************************************************************** main file****************************************************************** #include”header.h” int main() { struct … Continue reading

Posted in Data Structures with C, Project 2: Multiple Data Compression and Encryption | Leave a comment