This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Software tools p.p 146 | |
/* Converted to C by me. All faults are mine. No warranties what so ever. | |
* Most of the code is written by Kernighan or Plaugher, so the code is really | |
* copyrighted by them. I only translated it to C. | |
*/ | |
#include <stdbool.h> | |
#include <ctype.h> | |
#include <stdio.h> | |
#include <stdlib.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* License: | |
* Copyright (C) 2023 - McUsr 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; either | |
* version 2 of the License, or (at your option) any later version. This | |
* program is distributed in the hope that it will be useful, but WITHOUT | |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
* more details. You should have received a copy of the GNU General Public | |
* License along with this program; if not, write to the Free Software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _XOPEN_SOURCE 500 | |
/* | |
* Termios handling stolen from https://www.gnu.org/software/libc/manual/html_node/Noncanon-Example.html_node | |
* Reworked to make a press any key to continue function, which handles SIGCONT in a shell with | |
* job control, so that the message reappears, if we hit SUSP (^Z), while we are waiting for a keypress. | |
* | |
* To compile: | |
* cc -std=c99 -g3 -D_POSIX_SOURCE -o noncanon noncanon.c | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is a demo of sharing memory between parent and child, and | |
to use semaphores to controll access between the processes | |
for the shared memory. | |
Based on: | |
The example with semaphores in `man shm_open`, and | |
the mmap demo shared between parent and child in: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @brief nrcp : makes a numbered copy of a file. | |
* | |
* It finds the ascending number that isn't used | |
* as a suffix for the file, and creates a copy | |
* of the file with that number appended as a | |
* suffix -- in the same directory as the original | |
* file! | |
* | |
* @author McUsr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Basic hash example an example found on the internet | |
* | |
* | |
* I u/McUsr made it work flawlessly with the good help of | |
* r/C_programming: | |
* u/Bitwise_Gamgee, u/No-Adhesiveness-8125 and u/curiously-b2. | |
* I got insights and suggestions from u/t40, u/ThatsMyFavoriteThing. | |
* u/flyingiron, u/Daiktana, and last but not least u/skeeto! | |
* Thanks a bunch guys! | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* K&R p.p 136 | |
* Exercise 6-1 | |
* 2023 (c) McUsr -- Vim licence. | |
* | |
* "Our version of getword does not properly handle underscores, string | |
* constants, comments or preprocesor control lines. Write a better version." | |
* | |
* My solution is a tad different from what I have seen online, probably | |
* because my motivation is that I'd like to have my options open for | |
* including the entities at a later point in time into hash tables, for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 1987 (c) Stephen R. Bourne (from the Unix system V Environment). | |
* I have been true to the style, except for adding typedeclarations in order | |
* for it to compile without warnings on gcc (-std90?) without warnings. | |
* McUsr 14.05.2023 | |
*/ | |
#include <stdio.h> | |
#define MAXF 256 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.TH FIELD 1 1987-1-1 | |
.SH NAME | |
\fBfield\fR \(en select fields or columns from a file. | |
.SH SYNOPSIS | |
\fBfield\fR [\fB n \fR] \fI...\fR | |
.SH DESCRIPTION | |
The \fBfield\fR command copies specified, tab-separated fields from the | |
standard input to the standard output. Fields are numbered from 1 | |
and a field may be requested more than once. | |
.SH BUGS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* chunk.c A combination of head and tail for ease of use. | |
* A derivation of an exercise of writing a tail command in K&R. | |
* | |
* Thank you u/xkcd__386 for pointing out flaws in the comments. | |
* | |
* The largest chunk can be MAXLINES long, and files can be arbitrarily long | |
* (in lines). (see show_help()) | |
* | |
* Arguments: | |
* |
NewerOlder