ubuntu kernelversion number/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: ubuntu kernelversion number/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Zurück zur Seite [[code examples/de|Code Beispiele]]. | |
| 2 | + | ||
| 3 | + | Dieser Artikel beschäftigt sich mit der Linuxprogrammierung (Ubuntu). | |
| 4 | + | ||
| 5 | + | Die Prozedur ermittelt die aktuelle Versionsnummer des Kernels. | |
| 6 | + | ||
| 7 | + | ``` pascal | |
| 8 | + | uses | |
| 9 | + | SysUtils, ...; | |
| 10 | + | ||
| 11 | + | ... | |
| 12 | + | ||
| 13 | + | function funLeseDatei: string; | |
| 14 | + | var | |
| 15 | + | txtDatei: Textfile; | |
| 16 | + | begin | |
| 17 | + | Assignfile(txtDatei, '/proc/version'); // weist txtDatei die Datei zu | |
| 18 | + | reset(txtDatei); // oeffnet die Datei zum Lesen | |
| 19 | + | readln(txtDatei, Result); // liest die erste Zeile | |
| 20 | + | Closefile(txtDatei); // schliesst die Datei | |
| 21 | + | end; | |
| 22 | + | ||
| 23 | + | function funKernelversionsNummer: string; | |
| 24 | + | var | |
| 25 | + | intI: integer = 0; | |
| 26 | + | intZaehler: integer = 0; | |
| 27 | + | strProcVersion: string = ''; | |
| 28 | + | ||
| 29 | + | begin | |
| 30 | + | ||
| 31 | + | Result := ''; | |
| 32 | + | ||
| 33 | + | strProcVersion := funLeseDatei(); | |
| 34 | + | if strProcVersion = '' then | |
| 35 | + | exit; | |
| 36 | + | ||
| 37 | + | for intI := 1 to Length(strProcVersion) do | |
| 38 | + | begin | |
| 39 | + | ||
| 40 | + | if (strProcVersion[intI] = '-') then | |
| 41 | + | begin | |
| 42 | + | intZaehler := intZaehler + 1; | |
| 43 | + | if intZaehler > 1 then break; | |
| 44 | + | end; | |
| 45 | + | ||
| 46 | + | if (strProcVersion[intI] in ['0'..'9', '.', '-']) then | |
| 47 | + | Result := Result + strProcVersion[intI]; | |
| 48 | + | ||
| 49 | + | end; | |
| 50 | + | ||
| 51 | + | end; | |
| 52 | + | ||
| 53 | + | ... | |
| 54 | + | ``` | |
| 55 | + | ||
| 56 | + | Das ganze läßt sich strukturierter mit [`FPUname`](https://www.freepascal.org/docs-html/rtl/baseunix=identifier=fpuname/index.html) ermitteln: | |
| 57 | + | ||
| 58 | + | ``` pascal | |
| 59 | + | program kerninfo(input, output, stderr); | |
| 60 | + | ||
| 61 | + | uses | |
| 62 | + | // baseUnix for fpUname | |
| 63 | + | baseunix, | |
| 64 | + | // sysutils for format | |
| 65 | + | sysutils, | |
| 66 | + | // gettext for internationalization | |
| 67 | + | gettext; | |
| 68 | + | ||
| 69 | + | resourcestring | |
| 70 | + | unameFailure = 'uname(2) failed'; | |
| 71 | + | releaseNumber = 'release number: %0:s'; | |
| 72 | + | versionNumber = 'version number: %0:s'; | |
| 73 | + | ||
| 74 | + | var | |
| 75 | + | kernelInfo: utsName; | |
| 76 | + | begin | |
| 77 | + | translateResourceStrings('./' + applicationName() + '.%s.mo'); | |
| 78 | + | ||
| 79 | + | if fpUname(kernelInfo) <> 0 then | |
| 80 | + | begin | |
| 81 | + | writeLn(stderr, unameFailure); | |
| 82 | + | halt(1); | |
| 83 | + | end; | |
| 84 | + | ||
| 85 | + | writeLn(format(releaseNumber, [kernelInfo.release])); | |
| 86 | + | writeLn(format(versionNumber, [kernelInfo.version])); | |
| 87 | + | end. | |
| 88 | + | ``` | |
| 89 | + | ||
| 90 | + | --- | |
| 91 | + | *From the Free Pascal wiki, page "ubuntu kernelversion number/de", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 92 | + | Category: Code Snippets/de | |
| 93 | + | Category: Deutsch |
