playground.darkbyte.sk

Place for ZX Spectrum freaks
It is currently Tue Sep 19, 2017 1:38 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: MDOS3: list bootconf
PostPosted: Tue May 13, 2014 12:22 am 
Offline

Joined: Sun Oct 06, 2013 11:19 pm
Posts: 23
ak by sa niekomu hodilo, mala utilitka na vypis obsahu bootconf.b z bootdisku pre mdos3
Code:
/*
 * Copyright (C) 2014 UB880D
 *
 * 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. See the file COPYING.
 *
 * 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, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

/*

 print list of systems from bootconf file (mdos3)

*/

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#define TITLELEN 32
#define FNAMELEN 10

int main(int argc, char *argv[]) {
  int fd, len, sysnr;
 
  char title[TITLELEN+1];
  unsigned char page;
  char file[FNAMELEN+1];
 
  if (argc < 2) {
    printf("Usage: %s <file>\n", argv[0]);
    return 1;
  }
 
  if ((fd = open(argv[1], O_RDONLY)) < 0) {
    printf("cannot open %s file\n", argv[1]);
    return 1;
  }
 
  sysnr = 0;

  while ((len = read(fd, title, TITLELEN)) > 0) {

    if (!*title) break;
   
    if (len != TITLELEN) {
      len = 0; //to print warning
      break;
    }
   
    title[TITLELEN] = '\0';
   
    printf("[%d] System: %s\n", sysnr, title);
   
    if ((len = read(fd, &page, 1)) < 1) break;
   
    while (!(page&0x80)) {
     
      if ((len = read(fd, file, FNAMELEN)) < FNAMELEN) {
        len = 0; //to print warning
        break;
      }
     
      file[FNAMELEN] = '\0';
     
      printf("  Page %d: %s\n", (page & 0x3), file);
      if ((len = read(fd, &page, 1)) < 1) break;
    }
   
    if (page == 0xff)
      printf("  8k paging, initial page is 0 (legacy)\n\n");
    else {
      if ((page & 0x40))
        printf("  16k paging, initial 16k page is %d\n\n", (page & 0x1));
      else
        printf("  8k paging, initial page is %d\n\n", (page & 0x3));
    }
   
    sysnr++;
   
  }
 
  if (!len) printf("WARNING! premature end of file!\n");
 
  close(fd);

  return 0;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group