Warning: Undefined array key "rss_show_deleted" in /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php on line 86

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 53

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 54

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 55

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 56

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/inc/httputils.php on line 32

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/inc/httputils.php on line 33
wi12.unix7.org - c https://w12.unix7.org/ Wed, 05 Aug 2026 03:48:13 +0000 FeedCreator 1.8 https://w12.unix7.org/_media/wiki/dokuwiki.svg wi12.unix7.org https://w12.unix7.org/ AVR MCU pure C sample https://w12.unix7.org/c/avr-sample c embed AVR MCU pure C sample Sample for Arduino interactive “application”. I wrote for the weekend from chip datasheet and examples. In general, I bought a kit of manipulator for my youngest son, but once I got a micro controller ... I could not miss this chance and anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Callback from thread. A sample/pattern https://w12.unix7.org/c/cb-sample c Callback from thread. A sample/pattern /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <string.h> #include <stdlib.h> #include <pthread.h> #include <stdio.h> typedef struct req { void (*cb)(void*); void* rdata; int rsize; } req_t; void* handler(void* argv) { /* reinterpret args */ req_t* m = (req_t*)argv; /* some work */ char* res = (char*)malloc(1024); memcpy(res, m->rdata, m->rsize); strcat(res, "+world"); /* call call… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 One-way chain sample https://w12.unix7.org/c/chain One-way chain sample /* * Copyright 2020 Oleg Borodin <borodin@unix7.org> */ #include <stdio.h> #include <stdlib.h> struct cell { int data; struct cell* next; }; typedef struct cell cell_t; cell_t* new_chain(int data) { cell_t* cell = malloc(sizeof(cell_t)); cell->next = NULL; cell->data = data; return cell; } cell_t* chain_add(cell_t* root, int data) { cell_t* next = malloc(sizeof(cell_t)); next->data = data; next->next = NULL; cell_t* curr = r… anonymous@undisclosed.example.com (Anonymous) Fri, 09 Dec 2022 17:28:54 +0000 Pure C config reader https://w12.unix7.org/c/config c Pure C config reader /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <regex.h> #define _WITH_GETLINE #include <stdio.h> #include <stdlib.h> #include <string.h> #include "vector.h" typedef struct keyvalue { char* key; char* value; } keyvalue_t; int config_kvmatch(char* str, keyvalue_t** kv) { size_t nmatch = 4; regmatch_t pmatch[5]; char* pattern = "^[\t ]*([A-Za-z0-9_\\.]+)[\t ]*[=:]+[\t ]*([A-Za-z0-9_\\.]+)[\t #;]*"; regex_t preg; in… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Pure C SOAP client sample https://w12.unix7.org/c/csoap-example c Pure C SOAP client sample Library csoap is here <http://csoap.sourceforge.net> #include <nanohttp/nanohttp-logging.h> #include <libcsoap/soap-client.h> static const char *url = "http://rpi2.unix7.org/soap/asterisk.pl"; static const char *urn = "http://rpi2.unix7.org"; static const char *method = "Hello"; int main(int argc, char *argv[]) { SoapCtx *ctx, *ctx2; herror_t err; /* log_set_level(HLOG_VERBOSE); */ err = soap_client_init_args(argc, argv); if (err != H_OK) { log… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Pure C unix daemon example https://w12.unix7.org/c/daemon-example c Pure C unix daemon example The code excluded from mini-project of mail log parser. /* $Id: main.c,v 1.1 2016/08/14 23:47:57 root Exp root $ */ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <err.h> #include <syslog.h> #include <signal.h> #include <syslog.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <sys/stat.h> #include <libgen.h> #include <libpq-fe.h> #include <confuse.h> #include "config.h" #include "parser.h" #inc… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Pure C unix daemon example https://w12.unix7.org/c/daemon-sample c Pure C unix daemon example The code excluded from mini-project of mail log parser. /* $Id: main.c,v 1.1 2016/08/14 23:47:57 root Exp root $ */ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <err.h> #include <syslog.h> #include <signal.h> #include <syslog.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <sys/stat.h> #include <libgen.h> #include <libpq-fe.h> #include <confuse.h> #include "config.h" #include "parser.h" #inc… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 FIFO buffer with readline https://w12.unix7.org/c/fifo-readline c FIFO buffer with readline I wrote this code for Atmel microprocessor line parser. //#include <avr/io.h> //#include <util/delay.h> #include <stddef.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <string.h> #include <unistd.h> struct fifo_t { volatile unsigned head; volatile unsigned tail; volatile uint8_t *buffer; unsigned buffer_len; }; typedef struct fifo_t FIFO; uint8_t fifo_count(const FIFO *b) { if (b) { return (b->head - b->tail… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Golang begin https://w12.unix7.org/c/gobegin Golang begin * task - corointine * yield - schedule =) /* * Copyright 2022 Oleg Borodin <borodin@unix7.org> */ #include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <ucontext.h> #include <assert.h> #include <time.h> typedef struct itask task_t; typedef void (*task_f)(task_t* task); struct itask { int ident; task_f func; ucontext_t* scntx; ucontext_t* tcntx; task_t* next; bool … anonymous@undisclosed.example.com (Anonymous) Wed, 28 Dec 2022 19:49:21 +0000 I2C scanner on Atmel micro-controller https://w12.unix7.org/c/i2c-scanner c embed I2C scanner on Atmel micro-controller From the project “You bought for your son a microcontroller - program it yourself” =) The code can indicate which addresses are used by the I2C bus. I wrote it in one evening. For it I use embedded realization I2C driver for AVR. anonymous@undisclosed.example.com (Anonymous) Sat, 05 Feb 2022 08:21:42 +0000 Example of I2C slave on AVR https://w12.unix7.org/c/i2c-slave c embed Example of I2C slave on AVR I can not just take and leave two boards without communication. =) In this example is implemented a machine for storing/reading 16 registers. #include <avr/io.h> #include <compat/twi.h> #include <avr/interrupt.h> #include <util/delay.h> /* Usage example, on master side. Write to slave device: #define SL_ADDR 0x43 uint8_t regaddr = 0x01; uint8_t regdata = 0x78; i2c_start_wait((SL_ADDR << 1) | I2C_WRITE); data = i2c_write(rega… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Lex Flex parser example https://w12.unix7.org/c/lex-sample c lex flex Lex Flex parser example %{ /* $Id: lexer.l,v 1.4 2016/08/14 22:43:12 root Exp root $ */ #include <stdio.h> #include <stdarg.h> #include <stdio.h> #include <err.h> %} /* %option 8bit noreentrant %option nomain nounput noyy_top_state yywrap warn */ %option outfile="lexer.c" %option nomain noyywrap reentrant /* http://flex.sourceforge.net/manual/Patterns.html http://www.regular-expressions.info/posixbrackets.html http://flex.sourceforge.net/manual/Start-Conditions.html */ %x C… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 https://w12.unix7.org/c/libusb-sample c unix /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <libusb.h> #define VENDOR_ID 0x067b #define PRODUCT_ID 0x2303 #define ACM_CTRL_DTR 0x01 #define ACM_CTRL_RTS 0x02 static struct libusb_device_handle *devh = NULL; static int ep_in_addr = 0x83; static int ep_out_addr = 0x02; void write_char(uint8_t c) { int rsize; if (libusb_bulk_transfer(de… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Libuv web server sample https://w12.unix7.org/c/libuv-ts c Libuv web server sample /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <uv.h> uv_loop_t *loop; struct sockaddr_in addr; void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { buf->base = (char*) malloc(suggested_size); buf->len = suggested_size; } void on_close(uv_handle_t* handle) { free(handle); } void on_write(uv_write_t *req, int status) { if (status) { … anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Pure C Web/PostgreSQL service checker https://w12.unix7.org/c/m5dc c Pure C Web/PostgreSQL service checker I wrote it for support “some big corporate application”. “Pure C” for portability. Out sample # m5dc.exe 2019-02-25 11:52:10 UTC ######## THE BEGIN ######## 2019-02-25 11:52:10 UTC ############################## 2019-02-25 11:52:10 UTC start checking: traceroute for host web.xxxxx.… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 MPU6050 gyroscope https://w12.unix7.org/c/mpu6050 c MPU6050 gyroscope ---------- [<>] anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Message protocol prototype https://w12.unix7.org/c/msg-proto c Message protocol prototype /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #ifndef MSG_H_IUYTR #define MSG_H_IUYTR #include <stdio.h> #include <sys/endian.h> #include <string.h> typedef struct msg_hdr { uint16_t version; uint32_t id; uint16_t type; uint64_t csize; uint16_t pnumber; uint16_t pcount; uint64_t psize; uint64_t poffset; } msg_hdr_t; typedef struct msg { msg_hdr_t header; void* content; } msg_t; void msg_hdr_encode (msg… anonymous@undisclosed.example.com (Anonymous) Thu, 02 Dec 2021 11:32:00 +0000 RPC/IPC prototype/sample https://w12.unix7.org/c/msg-proto2 c RPC/IPC prototype/sample Client zcnt.c /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <stdint.h> #include <stddef.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <pthread.h> #include <sys/event.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <netinet/ip.h> #include <netdb.h> #include "socket.h" #incl… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Example of bin protocol on pure C https://w12.unix7.org/c/msgproto c net Example of bin protocol on pure C message.h /* * Copyright Oleg Borodin <onborodin@gmail.com> */ #define MSG_VER1 ((uint16_t)0x1) #define MSG_TYPE_HELLO ((uint16_t)1) #define MSG_TYPE_BIN ((uint16_t)2) #define MSG_TYPE_JSON ((uint16_t)3) #define MSG_TYPE_JSONREQ ((uint16_t)4) #define MSG_TYPE_JSONRES ((uint16_t)5) #define MSG_HELLO_ID ((uint32_t)0x12345) typedef struct msg_hdr { uint16_t ver; uint32_t id; uint16_t type; … anonymous@undisclosed.example.com (Anonymous) Thu, 02 Dec 2021 11:26:23 +0000 Nano-message next-generation framework sample https://w12.unix7.org/c/nanomsg-nextgen c Nano-message next-generation framework sample It is a good library. IMHO after some my small research, NNG better ZeroMQ (TLS, websockets, thread-safe, “unkillable” req-rep, etc) See RATIONALE * Sources <https://github.com/nanomsg/nng> * Mans <https://nanomsg.github.io/nng/man/v1.1.0/nng.7> PUB-SUB (publisher-subscriber) model sample anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 No-blocked stream reader https://w12.unix7.org/c/nonblk-stream c No-blocked stream reader I wrote it only as rapid illustration for method non-blocked reading from blocked stream. /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <signal.h> #include <pthread.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <sys/time.h> #include <err.h> void msleep(int d… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 PostgresQL C client sample https://w12.unix7.org/c/pg c PostgresQL C client sample For test purpose or as sample. #include <stdio.h> #include <stdlib.h> #include "libpq-fe.h" static void exitNicely(PGconn * conn) { PQfinish(conn); exit(1); } int main(int argc, char **argv) { const char *conninfo = "host=xxxxxxx dbname=xxxxxx user=xxxxxx password=xxxxxxxx"; PGconn *conn = PQconnectdb(conninfo); if (PQstatus(conn) != CONNECTION_OK) { fprintf(stderr, "# connection to database failed: %s\n", PQerrorMessage(conn)); … anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Ping sample https://w12.unix7.org/c/ping c Ping sample I wrote it for test purpose. For Win target I uses MinGW and GCC. /* $Id: ping.c,v 1.1 2019/02/20 13:01:37 ziggi Exp ziggi $ */ #ifdef __WINNT__ #define __WINNT 1 #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include <limits.h> #include <unistd.h> #ifdef __WINNT__ #include <sys/types.h> #include <sys/stat.h> #define _WIN32_WINNT 0x0501 #include <winsock2.h> #include <ws2tcpip.h> #include <pshpack1.h> #else #include <sys/socket.h> … anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Sending file/socket descriptors between pair of processes https://w12.unix7.org/c/sendfd c Sending file/socket descriptors between pair of processes /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #include <sys/wait.h> #include <signal.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdbool.h> ssize_t sendfd(int sock, int fd) { struct msghdr msg; struct cmsghdr* cmsg; union { struct cmsghdr hdr; unsigned c… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Serialzation template https://w12.unix7.org/c/serialize c c Serialzation template Without free(), bound control and etc, it's sample, yes =) /* * Copyright 2021 Oleg Borodin <borodin@unix7.org> */ #include <stdio.h> #include <stdlib.h> #include <string.h> #define TYPE_STR 1 #define TYPE_INT 2 typedef struct { char* key; int type; union { char** cref; int* iref; }; } record_t; typedef struct { record_t **records; size_t size; size_t cap; } maper_t; record_t* new_record(char* key, int t… anonymous@undisclosed.example.com (Anonymous) Wed, 27 Jul 2022 08:06:39 +0000 https://w12.unix7.org/c/string c /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define STRING_INIT_CAPACITY 4 void debug_printf(char *format, ...) { va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args); } typedef struct string { char* items; int capacity; int size; } string_t; void string_init(string_t* s) { s->capacity = STRING_INIT_CAPACITY; s->size = 0; s-… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Master-slave pair of processes with Unix datagram communication https://w12.unix7.org/c/subserv c Master-slave pair of processes with Unix datagram communication mainserv.c /* * Copyright 2011 Oleg Borodin <onborodin@gmail.com> */ #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #include <sys/wait.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdbool.h> int main(int argc, char **argv) { pid_t pid = fork(); if (pid == 0){ /* in the child */ char subserv[] = "./subserv"; … anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Pure C tail example with usleep https://w12.unix7.org/c/tail-example c Pure C tail example with usleep /* $Id: main.c,v 1.1 2016/08/14 23:47:57 root Exp root $ */ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <err.h> #include <sys/stat.h> struct file_info { FILE *fp; char *filename; struct stat st; }; typedef struct file_info file_info_t; void _log(char* format, const char* str) { fprintf(stderr, format, str); } int main ( int argc, char** argv ) { char* filename = "/var/log/debug.log"; file_info_t* file; s… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Thread pool sample with runtime signal handler https://w12.unix7.org/c/thread-pool-wh c c unix Thread pool sample with runtime signal handler /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <string.h> #include <signal.h> int queue = 0; pthread_mutex_t qmutex; pthread_cond_t cond; pthread_mutex_t mutex; void qpush() { pthread_mutex_lock(&qmutex); queue++; pthread_mutex_unlock(&qmutex); pthread_cond_signal(&cond); } void qpop() { pthread_mutex_lock(&qm… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Pure C thread pool sample https://w12.unix7.org/c/thread-pool c Pure C thread pool sample /* * * Author, Copyright: Oleg Borodin <onborodin@gmail.com> * */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> int queue = 0; pthread_mutex_t qmutex; void qpush() { pthread_mutex_lock(&qmutex); queue++; pthread_mutex_unlock(&qmutex); pthread_cond_signal(&cond); } void qpop() { pthread_mutex_lock(&qmutex); queue--; pthread_mutex_unlock(&qmutex); } int qsize() { pthread_mutex_lock(&qmutex); … anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Threadpool web server with blocked IO https://w12.unix7.org/c/thrsrv-bs c Threadpool web server with blocked IO /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <pthread.h> #include <sys/event.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <sys/time.h> #include <err.h> void msleep(int dur) { usleep(dur * 1000); } typedef struct queue { pthread_mutex_t… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Threadpool web server with kqueue()/kevent() https://w12.unix7.org/c/thrsrv-kqueue c Threadpool web server with kqueue()/kevent() /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <pthread.h> #include <sys/event.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <sys/time.h> #include <err.h> void msleep(int dur) { usleep(dur * 1000); } typedef struct queue { pthread_m… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Tiny multi-thread web server with TLS https://w12.unix7.org/c/thrsrv-ssl c Tiny multi-thread web server with TLS It is blocked mode sample but work. /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <pthread.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <openssl/ssl.h> #include <openssl/err.h> typedef struct queue { int *items; int front; int rear; int size; in… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Tiny Shell sorce https://w12.unix7.org/c/tiny-shell-code c Tiny Shell sorce main.c /* $Id$ */ #include <ctype.h> #include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <stddef.h> #include <stdbool.h> #include <string.h> #include <unistd.h> #include <avr/io.h> #include <avr/wdt.h> #include <avr/interrupt.h> #include <avr/pgmspace.h> #include <util/delay.h> #define BAUD 38400 #include <util/setbaud.h> #include <fifo.h> #include <tools.h> #include <shell.h> void uart_init(void) { /* UBRR - USART Baud Rate Register */ UBRR0… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 AVR Tiny Shell https://w12.unix7.org/c/tiny-shell c embed AVR Tiny Shell Here I present sample arduino micro-application with * ring buffer for input and output with hook to interrupts (wide shared ring buffer code with my adaptation and inmprovement) * extensible tiny sheel for command execution * anonymous@undisclosed.example.com (Anonymous) Sat, 05 Feb 2022 08:21:42 +0000 Ping+Traceroute https://w12.unix7.org/c/traceroute c Ping+Traceroute # cat Ping/pingw3.c /* $Id: ping.c,v 1.1 2019/02/20 13:01:37 ziggi Exp ziggi $ */ #ifdef __WINNT__ #define __WINNT 1 #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include <limits.h> #include <unistd.h> #ifdef __WINNT__ #include <sys/types.h> #include <sys/stat.h> #define _WIN32_WINNT 0x0501 #include <winsock2.h> #include <ws2tcpip.h> #include <pshpack1.h> #else #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/i… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Sample TTY reader https://w12.unix7.org/c/ttyread c Sample TTY reader 8N1 9600 #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <termios.h> #include <string.h> int main(int argc, char **argv) { struct termios tio; int tty_fd; fd_set rdset; unsigned char c = 0; memset(&tio, 0, sizeof(tio)); tio.c_iflag = 0; tio.c_oflag = 0; tio.c_cflag = CS8 | CREAD | CLOCAL; tio.c_lflag = 0; tio.c_cc[VMIN] = 1; tio.c_cc[VTIME] = 5; tio.c_iflag &= ~(ISTRIP | ICRNL ); … anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 Callback worker pool https://w12.unix7.org/c/wrkpoll-reqcb c Callback worker pool /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <unistd.h> #include <string.h> #include <pthread.h> typedef struct req { void (*cb)(void*); void* data; size_t size; } req_t; req_t* req_create(void(*cb)(void*), void* data, size_t size) { req_t* req = (req_t*)malloc(sizeof(req_t)); req->cb = cb; req->data = data; req->size = size; return req; } void re… anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000 X509 pem pack to crt/key convertor https://w12.unix7.org/c/x509conv c X509 pem pack to crt/key convertor I wrote it in one hour for internal corporate usage. * win32 exe: cross-compiled: mingw32-gcc -static -I /usr/local/mingw32/include/ -L/usr/local/mingw32/lib \ -o x509conv.exe x509conv.c \ -lssl -lcrypto -lgdi32 anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:43:16 +0000