Compare commits
4 Commits
19e3db36ed
...
7ee4eb0930
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7ee4eb0930 | ||
![]() |
57973a0bc7 | ||
![]() |
f35170113d | ||
![]() |
61286736e3 |
12
chap/C.tex
12
chap/C.tex
@ -26,7 +26,7 @@ Ces paramètres sont fournis par des mécanismes planquées
|
|||||||
dans la soute du système d'exploitation, et n'ont pas
|
dans la soute du système d'exploitation, et n'ont pas
|
||||||
d'importance pour le moment..
|
d'importance pour le moment..
|
||||||
|
|
||||||
\lstinputlisting[language=c]{code/hello.c}
|
\lstinputlisting[language=c]{code/C/hello.c}
|
||||||
|
|
||||||
Un fois passé l'entrée, nous sommes dans la partie active.
|
Un fois passé l'entrée, nous sommes dans la partie active.
|
||||||
Nous appelons à ce moment une fonction de la bibliothèque
|
Nous appelons à ce moment une fonction de la bibliothèque
|
||||||
@ -53,7 +53,7 @@ un tableau de chaines de caractères contenant ces différents mots.
|
|||||||
|
|
||||||
Ce petit bout de code va nous afficher tout ça~:
|
Ce petit bout de code va nous afficher tout ça~:
|
||||||
|
|
||||||
\lstinputlisting[language=c]{code/arguments.c}
|
\lstinputlisting[language=c]{code/C/arguments.c}
|
||||||
|
|
||||||
Et voici un exemple d'exécution depuis un shell~:\index{shell}
|
Et voici un exemple d'exécution depuis un shell~:\index{shell}
|
||||||
|
|
||||||
@ -75,6 +75,14 @@ En C, les tableaux commencent toujours à l'indice 0.
|
|||||||
Pour le traitement des options, il faut sauter à
|
Pour le traitement des options, il faut sauter à
|
||||||
la page \pageref{getopt}.
|
la page \pageref{getopt}.
|
||||||
|
|
||||||
|
. . .
|
||||||
|
|
||||||
|
\begin{verbatim}
|
||||||
|
if (config->optind < config->argc)
|
||||||
|
for (int i = config->optind; i < config.argc; ++i)
|
||||||
|
process(config->argv[i]);
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
% =========================================================
|
% =========================================================
|
||||||
|
|
||||||
\section{Les variables}
|
\section{Les variables}
|
||||||
|
@ -122,7 +122,7 @@ Comme vous le savez tous, un appel système
|
|||||||
est \textbf{le} moyen de communication qu'utilise un process
|
est \textbf{le} moyen de communication qu'utilise un process
|
||||||
utilisateur pôur demander un service au noyau.
|
utilisateur pôur demander un service au noyau.
|
||||||
|
|
||||||
\lstinputlisting[language=C]{code/hello.c}
|
\lstinputlisting[language=C]{code/C/hello.c}
|
||||||
|
|
||||||
Un exemple canonique, n'est-il pas ? Ce bout de code affichant
|
Un exemple canonique, n'est-il pas ? Ce bout de code affichant
|
||||||
quelque chose à l'écran, il doit bien y avoir un appel au noyau
|
quelque chose à l'écran, il doit bien y avoir un appel au noyau
|
||||||
|
@ -2,8 +2,17 @@
|
|||||||
# exemples pour le chapitre sur le C
|
# exemples pour le chapitre sur le C
|
||||||
# new Sat Feb 11 12:06:34 CET 2023
|
# new Sat Feb 11 12:06:34 CET 2023
|
||||||
|
|
||||||
|
|
||||||
all: no-op slowprint fgets-simple packtest use_envp
|
all: no-op slowprint fgets-simple packtest use_envp
|
||||||
|
|
||||||
|
# simplified version of the canonical first C program
|
||||||
|
hello: hello.c Makefile
|
||||||
|
gcc -Wall $< -o $@
|
||||||
|
|
||||||
|
# please show me the command line
|
||||||
|
arguments: arguments.c Makefile
|
||||||
|
gcc -Wall $< -o $@
|
||||||
|
|
||||||
no-op: no-op.c Makefile
|
no-op: no-op.c Makefile
|
||||||
gcc -Wall $< -o $@
|
gcc -Wall $< -o $@
|
||||||
|
|
||||||
|
16
code/C/arguments.c
Normal file
16
code/C/arguments.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* afficher les arguments.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
for (foo=0; foo<argc; foo++) {
|
||||||
|
printf(" %3d %s\n", foo, argv[foo]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
7
code/C/hello.c
Normal file
7
code/C/hello.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
puts("hello world.");
|
||||||
|
return 0;
|
||||||
|
}
|
@ -10,23 +10,9 @@ ex_curses: ex_curses.c Makefile
|
|||||||
thread-demo: thread-demo.c Makefile
|
thread-demo: thread-demo.c Makefile
|
||||||
gcc -Wall -pthread $< -o $@
|
gcc -Wall -pthread $< -o $@
|
||||||
|
|
||||||
hello: hello.c Makefile
|
|
||||||
gcc -Wall $< -o $@
|
|
||||||
|
|
||||||
arguments: arguments.c Makefile
|
|
||||||
gcc -Wall $< -o $@
|
|
||||||
|
|
||||||
voirenv: voirenv.c Makefile
|
voirenv: voirenv.c Makefile
|
||||||
gcc -Wall $< -o $@
|
gcc -Wall $< -o $@
|
||||||
|
|
||||||
#------------- OSC -----------------------
|
|
||||||
|
|
||||||
osc: send-osc listen-osc
|
|
||||||
|
|
||||||
send-osc: send-osc.c Makefile
|
|
||||||
gcc -Wall $< -llo -o $@
|
|
||||||
listen-osc: listen-osc.c Makefile
|
|
||||||
gcc -Wall $< -llo -o $@
|
|
||||||
|
|
||||||
#------------- IPC -----------------------
|
#------------- IPC -----------------------
|
||||||
|
|
||||||
|
9
code/OSC/Makefile
Normal file
9
code/OSC/Makefile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#------------- OSC -----------------------
|
||||||
|
|
||||||
|
osc: send-osc listen-osc
|
||||||
|
|
||||||
|
send-osc: send-osc.c Makefile
|
||||||
|
gcc -Wall $< -llo -o $@
|
||||||
|
|
||||||
|
listen-osc: listen-osc.c Makefile
|
||||||
|
gcc -Wall $< -llo -o $@
|
0
code/OSC/README.md
Normal file
0
code/OSC/README.md
Normal file
15
code/OSC/listen-osc.c
Normal file
15
code/OSC/listen-osc.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/* LISTEN OSC */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <lo/lo.h>
|
||||||
|
|
||||||
|
#define LOCAL_PORT "9000"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
lo_server_thread st;
|
||||||
|
|
||||||
|
st = lo_server_thread_new(LOCAL_PORT, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
18
code/OSC/send-osc.c
Normal file
18
code/OSC/send-osc.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/* SEND OSC */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <lo/lo.h>
|
||||||
|
|
||||||
|
#define REMOTE_HOST "localhost"
|
||||||
|
#define REMOTE_PORT "9000"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
lo_address loana;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
loana = lo_address_new(REMOTE_HOST, REMOTE_PORT);
|
||||||
|
foo = lo_send(loana, "/dev/kmem", "is", 61, "meg, efface !");
|
||||||
|
fprintf(stderr, "foo %d\n", foo);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user