"Fossies" - the Fresh Open Source Software Archive

Member "ms-sys-2.7.0/src/oem_id.c" (20 Jun 2020, 2209 Bytes) of package /linux/privat/ms-sys-2.7.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "oem_id.c" see the Fossies "Dox" file reference documentation.

    1 /******************************************************************
    2     Copyright (C) 2015  Henrik Carlqvist
    3 
    4     This program is free software; you can redistribute it and/or modify
    5     it under the terms of the GNU General Public License as published by
    6     the Free Software Foundation; either version 2 of the License, or
    7     (at your option) any later version.
    8 
    9     This program is distributed in the hope that it will be useful,
   10     but WITHOUT ANY WARRANTY; without even the implied warranty of
   11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12     GNU General Public License for more details.
   13 
   14     You should have received a copy of the GNU General Public License
   15     along with this program; if not, write to the Free Software
   16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   17 ******************************************************************/
   18 #include <stdio.h>
   19 
   20 #include "file.h"
   21 #include "identify.h"
   22 #include "fat12.h"
   23 #include "fat16.h"
   24 #include "fat32.h"
   25 #include "nls.h"
   26 
   27 #include "oem_id.h"
   28 
   29 char *read_oem_id(FILE *fp)
   30 {
   31    static char szOemId[9];
   32    int i;
   33 
   34    szOemId[8] = 0;
   35    if(!read_data(fp, 3, szOemId, 8))
   36       return NULL;
   37    /* sanity check */
   38    for(i=0; i<8; i++)
   39       if(szOemId[i] < ' ')
   40      return NULL;
   41    return szOemId;
   42 } /* read_oem_id */
   43 
   44 int write_oem_id(FILE *fp, const char *szOemId)
   45 {
   46    static char acOemId[8];
   47    int i;
   48 
   49    for(i=0; (i<8) && szOemId[i]; i++)
   50       acOemId[i] = szOemId[i];
   51    while(i<8)
   52       acOemId[i++] = ' ';
   53    return write_data(fp, 3, acOemId, 8);
   54 } /* write_eom_id */
   55 
   56 int ok_to_write_oem_id(FILE *fp, const char *szPath, int bPrintMessages)
   57 {
   58    if(sanity_check(fp, szPath, FAT12_BR, 0) ||
   59       sanity_check(fp, szPath, FAT16_BR, 0) ||
   60       sanity_check(fp, szPath, FAT32_BR, 0))
   61       return 1;
   62    if(bPrintMessages)
   63    {
   64       if(is_fat_12_fs(fp)||is_fat_16_fs(fp)||is_fat_32_fs(fp))
   65       {
   66      printf(
   67         _("%s does not seem to be a floppy or disk partition device,\n"),
   68         szPath);
   69       }
   70       else
   71       {
   72      printf(_("%s does not seem to have a FAT file system,\n"),
   73         szPath);
   74       }
   75       printf(_("use the switch -f to force writing of OEM ID\n"));
   76    }
   77    return 0;
   78 } /* ok_to_write_oem_id */