From 77fe64b172a6d1847ec80b6fa34ac06816a4030d Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Mon, 12 Mar 2018 14:34:16 +0000 Subject: dev c added initial libraries --- dev/c/datatypes.html | 44 ++++++- dev/c/debugging.html | 32 +++++ dev/c/elements.html | 19 +-- dev/c/index.html | 44 ++----- dev/c/lib.html | 167 ++++++++++++++++++++++++++ dev/index.html | 324 +++++++++++++++++++++++++++------------------------ 6 files changed, 419 insertions(+), 211 deletions(-) create mode 100644 dev/c/lib.html diff --git a/dev/c/datatypes.html b/dev/c/datatypes.html index a149c24..35b6ca4 100644 --- a/dev/c/datatypes.html +++ b/dev/c/datatypes.html @@ -9,6 +9,22 @@

Datatypes

+

Types

+ +
+
char
+
Integer, one byte.
+
int
+
Integer.
+
float
+
Single precision floating point.
+
double
+
Double precision floating point.
+
void
+
Absence of type.
+
+ +

Data types

Integer

@@ -128,13 +144,35 @@

Type qualifiers

Storage class

- Development Index +

Format Type Specifiers

-

- This is part of the c9-doc Manual. +

+
%c
+
Character
+
%s
+
String of characters
+
%d
+
Decimal integer
+
%f
+
Decimal floating point
+
%llu
+
unsigned long long
+
%o
+
Signed octal
+
%u
+
Unsigned decimal integer
+
%x
+
Unsigned hexadecimal integer
+
%p
+
Pointer address
+
+ + Development Index +

This is part of the c9 Manual. Copyright (C) 2018 c9 team. See the file Gnu Free Documentation License for copying conditions.

+ diff --git a/dev/c/debugging.html b/dev/c/debugging.html index d1f425b..4e5931f 100644 --- a/dev/c/debugging.html +++ b/dev/c/debugging.html @@ -15,10 +15,42 @@ (gdb)set args -parameter1 -parameter2 +

To start gdb in TUI mode press;

+ +
+
Ctrl-x A
+
Enter or leave TUI.
+
Ctrl-x 0
+
TUI with only one window.
+
Ctrl-x 2
+
TUI with more than two windows.
+
Ctrl-x o
+
Change active window.
+
Ctrl-x s
+
TUI single key mode.
+
Ctrl-L s
+
Refresh screen.
+
Up
+
Scroll
+
Down
+
Scroll
+
Left
+
Scroll
+
Right
+
Scroll
+
+ +
+        (gdb) info win
+        (gdb) fs next
+        (gdb) fs SRC
+        
+
         b - backtrace
         info locals
+        display
         print
         x
         catch syscall open
diff --git a/dev/c/elements.html b/dev/c/elements.html
index d6950d2..c5eb87e 100644
--- a/dev/c/elements.html
+++ b/dev/c/elements.html
@@ -2,27 +2,12 @@
 
     
         
-        Types & Elements
+        Elements
     
     
         Development Index
 
-        

Types & Elements

- -

Types

- -
-
char
-
Integer, one byte.
-
int
-
Integer.
-
float
-
Single precision floating point.
-
double
-
Double precision floating point.
-
void
-
Absence of type.
-
+

Elements

Identifiers

diff --git a/dev/c/index.html b/dev/c/index.html index 3e8651f..aeff035 100644 --- a/dev/c/index.html +++ b/dev/c/index.html @@ -135,39 +135,7 @@ (gdb) s
-

Execute next line;

- -
-	(gdb) n
-	
- -

To start gdb in TUI mode press;

- -
-
Ctrl-x A
-
Enter or leave TUI.
-
Ctrl-x 1
-
TUI with only one window.
-
Ctrl-x 2
-
TUI with more than two windows.
-
Ctrl-x o
-
Change active window.
-
Ctrl-x s
-
TUI single key mode.
-
Ctrl-L s
-
Refresh screen.
-
Up
-
Scroll
-
Down
-
Scroll
-
Left
-
Scroll
-
Right
-
Scroll
-
- -

Run again and step in hello function, to print - variable "name" value and type;

+

Print variable "name" value;

         (gdb) print name
@@ -175,7 +143,7 @@
         (gdb)
         
-

Print variable name type;

+

Print variable "name" type;

         (gdb) ptype name
@@ -183,8 +151,12 @@
         (gdb)
         
-

Variable is a string constant, - continue reading Elements.

+

Variable is a string constant. + Execute next line to end;

+ +
+	(gdb) n
+	
Development Index

diff --git a/dev/c/lib.html b/dev/c/lib.html new file mode 100644 index 0000000..d1c9c28 --- /dev/null +++ b/dev/c/lib.html @@ -0,0 +1,167 @@ + + + + + Libraries + + + Development Index + + +

Libraries

+ +

Basic

+ +
+
include <unistd.h>
+
fork, pipe and I/O primitives (read, write, close, etc.) + + primitve types like uid_t, pid_t etc
+ +
#include <stdlib.h>
+
Standard lib, contains primitves for number conversion + and memory allocation
+
#include <stdio.h>
+
Basic i/o lib: printf etc
+ +
#include <string.h>
+
String manipulations
+ +
#include <time.h>
+
Time related functions
+ +
#include <signal.h>
+
Signal handling
+ +
#include <stdbool.h>
+
Boolean type
+ +
#include <math.h>
+
Math functions
+
+ +

Advanced

+
+
#include <sys/socket.h>
+
socket connections
+
#include <sys/types.h>
+
primitive types like uid_t, pid_t etc
+ +
#include <netinet/in.h>
+
internet address family
+ +
#include <arpa/inet.h>
+
definitions for internet operations
+ +
#include <pthread.h>
+
threads
+ +
#include <stdatomic.h>
+
mutual exclusion locks
+ +
+ +

Stdio

+ +

File Modes

+ +
+	mode    Description
+	"r"     Opens a file for reading. The file must exist.
+	"w"     Creates an empty file for writing. If a file with the same name already exists, its content is erased and the file is considered as a new empty file.
+	"a"     Appends to a file. Writing operations, append data at the end of the file. The file is created if it does not exist.
+	"r"     Opens a file to update both reading and writing. The file must exist.
+	"w"     Creates an empty file for both reading and writing.
+	"a"     Opens a file for reading and appending.
+	
+ +
+	// ERROR: result == NULL (also when EOF is reached)
+	char *fgets(char *str, int strlen, FILE *stream);
+
+	// ERROR: result == NULL
+	FILE *fopen(const char *filename, const char *mode);
+
+	// result == EOF when finished reading the stream
+	// SUCCESS: number of matched items on success
+	int fscanf(FILE *stream, const char *format, ...);
+
+	// ERROR: result == EOF
+	// SUCCESS: result == 0
+	int fclose(FILE *stream);
+
+	// ERROR: result == -1
+	// SUCCESS: number of bytes written
+	ssize_t write(int fildes, const void *buf, size_t nbyte);
+
+	// ERROR: result == -1
+	// EOF when finished reading
+	// SUCCESS: number of bytes read
+	ssize_t read(int fildes, void *buf, size_t nbyte);
+
+	// SUCCESS: result > 0
+	// ERROR: result == EOF
+	int fputs(const char *restrict s, FILE *restrict stream);
+	
+ +

Strings

+ +
+	// SUCCESS: pointer to destination string
+	char *strcpy(char *dest, const char *src);
+
+	// result == 0 -> strings are equal
+	// result < 0 -> str1 less than str2
+	// result > 0 -> str2 less than str1
+	int strcmp(const char *str1, const char *str2);;
+
+
+	// result == NULL -> no tokens left to retrieve
+	// else: pointer to last token found
+	char *strtok(char *str, const char *delim);
+
+	// NULL if no match
+	// else: pointer to first occurence in string
+	char *strstr(const char *string, const char *substring);
+
+	// ERROR: result == 0
+	int atoi(const char *str);
+	
+ +

Networking

+ +
+	// ERROR: result == -1
+	// example: sock = socket(AF_INET, SOCK_STREAM, 0);
+	int socket(int domain, int type, int protocol);
+
+	// sockaddr_in struct (man ip 4)
+	struct sockaddr_in server;
+	server.sin_family = PF_INET;
+	server.sin_addr.s_addr = INADDR_ANY;
+	server.sin_port = htons(8080);
+
+	// ERROR: result < 0
+	// SUCCESS: result == 0
+	// example: bind(sock, (struct sockaddr *) &server, sizeof(server))
+	int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen);
+
+	// ERROR: result < 0
+	// SUCCESS: filedeskriptor for accepted socket
+	// example: fd = accept(sock, (struct sockaddr *) &client, &client_len);
+	int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+
+	// SUCCESS: result == 0
+	// ERROR: result == -1
+	int listen(int socket, int backlog);
+	
+ + Development Index + +

+ This is part of the c9-doc Manual. + Copyright (C) 2018 + c9 team. + See the file Gnu Free Documentation License + for copying conditions.

+ + diff --git a/dev/index.html b/dev/index.html index afd147e..ab00a3e 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,164 +1,178 @@ - - Development + + Development - Documentation Index -

Development

- -

Tools for development and debugging

- -

Git

- -

Git is a distributed version control system, this document is meant to be distributed using git.

- - - -

C & GDB

- -

C is functional compiled language created by Dennis Ritchie. BSD, Linux and Minix kernels use this language - as primary language.

- - - - - -

Shell Script

- -

Script files that start with "#!/bin/sh" use dash (in crux), - /bin/sh is a link to dash, while files that start with "#!/bin/bash" - use bash;

- - - -

Python

- - -

Perl

- - - -

JavaScript

- - -

PHP

- - - - - Documentation Index -

- This is part of the c9-doc Manual. - Copyright (C) 2017 - c9 team. - See the file Gnu Free Documentation License - for copying conditions.

- - + Documentation Index +

Development

+ +

Tools for development and debugging

+ +

Git

+ +

Git is a distributed version control system, this document is meant to be distributed using git.

+ + + +

C & GDB

+ +

C is functional compiled language created by Dennis Ritchie. BSD, Linux and Minix kernels use this language + as primary language.

+ + + + + +

Shell Script

+ +

Script files that start with "#!/bin/sh" use dash (in crux), + /bin/sh is a link to dash, while files that start with "#!/bin/bash" + use bash;

+ + + +

Python

+ + +

Perl

+ + + +

JavaScript

+ + +

PHP

+ + + + + Documentation Index +

+ This is part of the c9-doc Manual. + Copyright (C) 2017 + c9 team. + See the file Gnu Free Documentation License + for copying conditions.

-- cgit 1.4.1-2-gfad0