Files
mars-dosutils/teste.c
Mario Fetka 50524cf759 dosutils: add GPL-2 headers and file descriptions
Add GPL-2-or-later license headers to the DOS utility source files and
document the purpose and local dependencies of each C, header and assembler
file.

Preserve the original Martin Stover copyright attribution for the historic
MARS-NWE utility sources, including files that did not previously carry an
explicit header but are part of the original tool set. Add Mario Fetka as the
2026 copyright holder for the current maintenance work, and use Mario-only
headers for files without original Martin Stover ownership.

Also add a root-level COPYING file containing the GPL-2 license text.
2026-05-29 08:07:09 +02:00

122 lines
3.4 KiB
C
Raw Blame History

/*
* mars-nwe-dosutils - NetWare/DOS utility tools.
*
* Copyright (C) 2026 Mario Fetka
* Copyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/*
* Purpose: Small historical standalone test program.
* Depends on: DOS C runtime only; it is independent from the main NET multicall utility modules.
*/
int main()
{
char *fn="F.$LN";
char *string="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";
int result;
struct stat stbuff;
long offset;
char buff[1024];
char readbuff[500];
int j;
int fd=creatnew(fn, S_IREAD |S_IWRITE);
if (fd > -1) {
printf("Konnte Date erzeugen\n");
close(fd);
} else {
printf("Konnte Datei nicht erzeugen\n");
}
fd = open(fn, O_RDWR|O_CREAT|O_TRUNC|O_DENYNONE, 0666);
memset(buff, 0, sizeof(buff) );
strcpy(buff, string);
write(fd, buff, strlen(buff));
close(fd);
_chmod(fn, 1, _chmod(fn, 0) | 0x80 );
stat(fn, &stbuff);
printf("Filesize <20>ber stat =%ld\n", stbuff.st_size);
fd = open(fn, O_RDWR | O_BINARY |O_DENYNONE);
offset = lseek(fd, 0L, SEEK_END);
printf("Filesize <20>ber lseek =%ld\n", offset);
write(fd, buff, strlen(buff));
lseek(fd, 0L, SEEK_SET);
for (j=0; j < strlen(buff)*2; j++){
read(fd, readbuff, 1);
printf("BUFF = %c\n", readbuff[0]);
}
lseek(fd, 1L, SEEK_SET);
for (j = 0; j < 20; j++){
write(fd, buff+j, 1);
}
for (j=0; j <60; j++){
lseek(fd, (long) j, SEEK_SET);
read(fd, readbuff, 2);
printf("BUFF = %c, %c \n", readbuff[0], readbuff[1]);
}
lseek(fd, 10L, SEEK_SET);
read(fd, buff, 1);
printf("BUFF[10] = %c\n", buff[0]);
result=lock(fd, 100L, 1L);
printf("lock result = %d\n", result);
result=unlock(fd, 100L, 1L);
printf("unlock result = %d\n", result);
close(fd);
fd = open(fn, O_BINARY|O_RDWR|O_CREAT|O_TRUNC|O_DENYNONE, 0666);
if (fd > -1) {
int bufflen;
strcpy(buff, "d:..\\marlib\\c0l.obj+");
strcat(buff, "\r\n");
strcat(buff, "x");
strcat(buff, "\r\n");
strcat(buff, "x");
strcat(buff, "\r\n");
strcat(buff, "/c/x");
strcat(buff, "\r\n");
strcat(buff, "d:..\\marlib\\EMU.LIB+");
strcat(buff, "\r\n");
strcat(buff, "d:..\\marlib\\mathl.lib+");
strcat(buff, "\r\n");
strcat(buff, "d:..\\marlib\\cl.lib");
bufflen=strlen(buff);
printf("bufflen = %d, buff=%s\n", bufflen, buff);
write(fd, buff, bufflen);
close(fd);
fd = open(fn, O_TEXT|O_RDONLY);
if (fd > -1) {
char *p=readbuff;
int anz = 0;
memset(readbuff, 0, sizeof(readbuff) );
while (read(fd, p, 1) == 1){
anz++;
p++;
}
printf("read = %d, buff=%s\n", anz, readbuff);
close(fd);
}
}
/*
result = detach(1);
printf("Detach result=0x%x", result);
*/
return(0);
}