From 5d7a23e5d38048d72243a18b60b6f5f7f3d805d2 Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Wed, 7 Mar 2018 15:37:11 +0000 Subject: dev c revision --- dev/index.html | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'dev/index.html') diff --git a/dev/index.html b/dev/index.html index e463f6f..2dcc209 100644 --- a/dev/index.html +++ b/dev/index.html @@ -39,8 +39,40 @@ as primary language.

-- cgit 1.4.1-2-gfad0 From 52f5effca30b476b427c2d3a7518c91c0e292fa4 Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Wed, 7 Mar 2018 22:33:00 +0000 Subject: dev c datatypes initial document --- dev/c/datatypes.html | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++- dev/index.html | 2 +- 2 files changed, 107 insertions(+), 2 deletions(-) (limited to 'dev/index.html') diff --git a/dev/c/datatypes.html b/dev/c/datatypes.html index 6d6b76d..a149c24 100644 --- a/dev/c/datatypes.html +++ b/dev/c/datatypes.html @@ -12,12 +12,117 @@

Data types

Integer

+

Allowed types are char and int;

+
+
signed char
+
8 bit, from -128 to 127.
+
unsigned char
+
8 bit, from 0 to 255.
+
char
+
8 bit, used to store ASCII, ex; 'h', '\n', etc...
+
short int
+
16 bit, from -32,768 to 32,767.
+
unsigned short int
+
16 bit, from 0 to 65,535.
+
int
+
32 bit, from -2,147,483,648 to 2,147,483,647.
+
unsigned int
+
32 bit, from 0 to 4,294,967,295.
+
long int
+
32 bit, from -2,147,483,648 to 2,147,483,647.
+
unsigned long int
+
32 bit, from 0 to 4,294,967,295.
+
long long int
+
64 bit, from 9,223,372,036,854,775,808 + to 9,223,372,036,854,775,807.
+
unsigned long long int
+
64 bit, from 0 to 18,446,744,073,709,551,615.
+
+

Real number

+ +

Real numbers are fractional numbers, all floating points + are signed. Check float.h.

+ +
+
float
+
From 1e-37 to 1e37
+
double
+
Largest of floating point.
+
long double
+
The long double data maybe larger than double
+
+

Complex number

-

Enumeration

+ +

Complex Number Types

+ +

Enumeration

+ +
+        enum colors {black, orange, blue} color;
+        enum colors color;
+        
+

Unions

+ +
+        union accounts {
+            int id;
+            float value;
+        } first_account, second_account;
+        
+

Structures

+ +
+        struct point {
+            int x, y;
+        } first_point;
+        struct point second_point;
+        
+

Arrays

+ +
+        int account_array[9];
+        int account_array[] = {0, 1, 2, 3};
+        int account_array[] = {0, 1, 2, [9] = 9};
+        
+ +
+        int account_array[2][9] { {1,2,3},{9,8,7} }
+        
+ +

Initializing string with individual characters the + null character must be defined;

+ +
+        char black[] = {'b', 'l', 'a', 'c', 'k', '\0'}
+        
+ +
+        char black[] = "black";
+        
+ +
+        union accounts {
+            int id;
+            float value;
+        };
+        union accounts accounts_array[9];
+        accounts_array[0].id = 8;
+        
+ +
+        struct point {
+            int x, y;
+        };
+        struct point point_array[9];
+        point_array[0].x=2;
+        point_array[0].y=3;
+        
+

Pointers

Incomplete types

Type qualifiers

diff --git a/dev/index.html b/dev/index.html index d84fa36..afd147e 100644 --- a/dev/index.html +++ b/dev/index.html @@ -62,7 +62,7 @@
  • Integer
  • Real number
  • Complex number
  • -
  • Enumeration
  • +
  • Enumeration
  • Unions
  • Structures
  • Arrays
  • -- cgit 1.4.1-2-gfad0 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 (limited to 'dev/index.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 From 7867e4ea5ca255b610d69a4f47d45083717ac542 Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Tue, 3 Apr 2018 02:12:08 +0100 Subject: dev c lib and index revision --- dev/c/lib.html | 344 ++++++++++++++++++++++++++++++++++++--------------------- dev/index.html | 2 + 2 files changed, 218 insertions(+), 128 deletions(-) (limited to 'dev/index.html') diff --git a/dev/c/lib.html b/dev/c/lib.html index d1c9c28..fb4682b 100644 --- a/dev/c/lib.html +++ b/dev/c/lib.html @@ -1,167 +1,255 @@ - - Libraries + + Libraries - Development Index + Development Index -

    Libraries

    +

    Libraries

    -

    Basic

    +

    Basic

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

    Advanced

    -
    -
    #include <sys/socket.h>
    -
    socket connections
    -
    #include <sys/types.h>
    -
    primitive types like uid_t, pid_t etc
    +

    Advanced

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

    Stdio

    +
    #include <stdatomic.h>
    +
    mutual exclusion locks
    +
    gcc
    +
    -

    File Modes

    +

    Random Numbers

    +
    +        // seed with current time:
    +        // time_t t;
    +        // srand(time(&t));
    +        void srand(unsigned seed);
     
    -	
    -	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.
    -	
    + int rand(void); +
    -
    -	// ERROR: result == NULL (also when EOF is reached)
    -	char *fgets(char *str, int strlen, FILE *stream);
    +        

    Signals

    - // ERROR: result == NULL - FILE *fopen(const char *filename, const char *mode); +
    +        sig_t signal(int sig, sig_t func);
     
    -	// result == EOF when finished reading the stream
    -	// SUCCESS: number of matched items on success
    -	int fscanf(FILE *stream, const char *format, ...);
    +        int raise(int sig);
     
    -	// ERROR: result == EOF
    -	// SUCCESS: result == 0
    -	int fclose(FILE *stream);
    +        int kill(pid_t pid, int sig);
    +        
    - // ERROR: result == -1 - // SUCCESS: number of bytes written - ssize_t write(int fildes, const void *buf, size_t nbyte); +

    Sorting

    - // ERROR: result == -1 - // EOF when finished reading - // SUCCESS: number of bytes read - ssize_t read(int fildes, void *buf, size_t nbyte); +
    +        void qsort(void* values, size_t num_items, size_t item_size, int (*comparefunc)(const void*, const void*));
    +        
    - // SUCCESS: result > 0 - // ERROR: result == EOF - int fputs(const char *restrict s, FILE *restrict stream); -
    +

    Strings

    -

    Strings

    +
    +        // SUCCESS: pointer to destination string
    +        char *strcpy(char *dest, const char *src);
     
    -	
    -	// 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 == 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);
    +        
    + +

    Inter Process Communication

    +
    +        // ERROR: result < 0
    +        // result = 0 inside child
    +        // result > 0 inside parent
    +        pid_t fork(void);
    +
    +        // ERROR: result < 0
    +        // SUCCESS: result == 0
    +        int pipe(int fd[2]);
    +        
    + +

    File IO

    +

    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);
    +        
    - // result == NULL -> no tokens left to retrieve - // else: pointer to last token found - char *strtok(char *str, const char *delim); +

    Shared Memory

    - // 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.

    +
    +        // ERROR: result < 0
    +        // SUCCESS: result == shmid
    +        int shmget(key_t key, size_t size, int shmflg);
    +
    +        // ERROR: result == NULL
    +        void *shmat(int shmid, const void *shmaddr, int shmflg);
    +
    +        // ERROR: result < 0
    +        // SUCCESS: result == 0
    +        int shmdt(const void *shmaddr);
    +        
    + +

    Networking

    + +
    +        $ pkginfo -o socket.h
    +        
    + +
    +        #include "<sys/socket.h>"
    +        
    + +
    +        // 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);
    +        
    + +

    Threads

    + +
    +        // ERROR: result > 0
    +        // SUCCESS: res == 0
    +        // example: pthread_create(&threads[t], NULL, printHello, (void*)t);
    +        int pthread_create(pthread_t *restrict thread, const pthread_attr_t *restrict attr, void *(*start_routine)(void *), void *restrict arg);
    +
    +        // SUCCESS: result == 0
    +        // ERROR: result > 0
    +        int pthread_join(pthread_t tid, void **ret);
    +
    +        void pthread_exit(void *value_ptr);
    +        
    + + 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 ab00a3e..1f11b84 100644 --- a/dev/index.html +++ b/dev/index.html @@ -80,6 +80,8 @@
  • Input & Output
  • Libraries
      +
    • Basic libraries
    • +
    • Advanced libraries
    • Random Numbers
    • Signals
    • Sorting
    • -- cgit 1.4.1-2-gfad0 From e558bcea087aded1cdfac8870f6115e0f4db266b Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Tue, 3 Apr 2018 16:48:07 +0100 Subject: dev php testing --- dev/index.html | 7 ++++++- dev/php/index.html | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) (limited to 'dev/index.html') diff --git a/dev/index.html b/dev/index.html index 1f11b84..f9944d9 100644 --- a/dev/index.html +++ b/dev/index.html @@ -155,7 +155,12 @@

      PHP

        -
      • Hello World
      • +
      • Hello World + +
      • Types & Variables
      • Operators & Expressions
      • Control Flow
      • diff --git a/dev/php/index.html b/dev/php/index.html index a4549f1..45e8f79 100644 --- a/dev/php/index.html +++ b/dev/php/index.html @@ -30,6 +30,51 @@

        Open your browser and browse http://localhost:8000, you should see "Hello World".

        +

        Profiling

        + +

        Testing

        + +

        Create folder tests for phpunit files with settings, inside + create another called tests to create tests to be performed on + the code.

        + +
        +        $ mkdir -p tests/tests
        +        $ cd tests
        +        
        + +

        Create a test tests/EngineTest.php;

        + +
        +       <?php
        +        declare(strict_types=1);
        +
        +        use PHPUnit\Framework\TestCase;
        +
        +        final class EngineTest extends TestCase {
        +
        +            public function testCanBeCreated(){
        +
        +                   $engine = new engine();
        +
        +                   $this->assertInstanceOf(engine::class, $engine);
        +
        +            }
        +        }
        +       
        + +

        Create phpunit.xml;

        + +
        +       $ phpunit --generate-configuration
        +       
        + +

        Run the test;

        + +
        +       $ phpunit
        +       
        + Development Index

        This is part of the c9-doc Manual. -- cgit 1.4.1-2-gfad0