ms-sys  2.7.0
About: ms-sys writes Microsoft compatible boot records. Development version.
  Fossies Dox: ms-sys-2.7.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

oem_id.c
Go to the documentation of this file.
1 
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 */
write_data
int write_data(FILE *fp, unsigned long ulPosition, const void *pData, unsigned int uiLen)
Definition: file.c:78
write_oem_id
int write_oem_id(FILE *fp, const char *szOemId)
Definition: oem_id.c:44
nls.h
read_data
int read_data(FILE *fp, unsigned long ulPosition, void *pData, unsigned int uiLen)
Definition: file.c:41
read_oem_id
char * read_oem_id(FILE *fp)
Definition: oem_id.c:29
is_fat_32_fs
int is_fat_32_fs(FILE *fp)
Definition: fat32.c:24
is_fat_12_fs
int is_fat_12_fs(FILE *fp)
Definition: fat12.c:24
FAT12_BR
#define FAT12_BR
Definition: identify.h:9
identify.h
fat16.h
FAT32_BR
#define FAT32_BR
Definition: identify.h:11
fat12.h
_
#define _(String)
Definition: nls.h:9
fat32.h
sanity_check
int sanity_check(FILE *fp, const char *szPath, int iBr, int bPrintMessages)
Definition: identify.c:397
file.h
is_fat_16_fs
int is_fat_16_fs(FILE *fp)
Definition: fat16.c:24
ok_to_write_oem_id
int ok_to_write_oem_id(FILE *fp, const char *szPath, int bPrintMessages)
Definition: oem_id.c:56
FAT16_BR
#define FAT16_BR
Definition: identify.h:10
oem_id.h