~ubuntu-branches/ubuntu/raring/vice/raring

« back to all changes in this revision

Viewing changes to src/arch/unix/solaris/convertprototype.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2009-03-31 00:37:15 UTC
  • mfrom: (1.1.7 upstream) (9.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090331003715-i5yisvcfv7mgz3eh
Tags: 2.1.dfsg-1
* New major upstream release (closes: #495937).
* Add desktop files (closes: #501181).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * convertprototype.c - Helper program for the solaris package creation.
3
 
 *
4
 
 * Written by
5
 
 *  Marco van den Heuvel <blackystardust68@yahoo.com>
6
 
 *
7
 
 * This file is part of VICE, the Versatile Commodore Emulator.
8
 
 * See README for copyright notice.
9
 
 *
10
 
 *  This program is free software; you can redistribute it and/or modify
11
 
 *  it under the terms of the GNU General Public License as published by
12
 
 *  the Free Software Foundation; either version 2 of the License, or
13
 
 *  (at your option) any later version.
14
 
 *
15
 
 *  This program is distributed in the hope that it will be useful,
16
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 *  GNU General Public License for more details.
19
 
 *
20
 
 *  You should have received a copy of the GNU General Public License
21
 
 *  along with this program; if not, write to the Free Software
22
 
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
 
 *  02111-1307  USA.
24
 
 *
25
 
 */
26
 
 
27
 
#include <stdio.h>
28
 
#include <sys/stat.h>
29
 
 
30
 
static void convertprototype(unsigned char *readbuffer, int filesize)
31
 
{
32
 
  int counter=0;
33
 
 
34
 
  while (counter<filesize)
35
 
  {
36
 
    while (!isspace(readbuffer[counter]) || !isdigit(readbuffer[counter+1]))
37
 
    {
38
 
      printf("%c",readbuffer[counter]);
39
 
      counter++;
40
 
    }
41
 
    printf("%c",readbuffer[counter]);
42
 
    printf("%c",readbuffer[counter+1]);
43
 
    printf("%c",readbuffer[counter+2]);
44
 
    printf("%c",readbuffer[counter+3]);
45
 
    counter+=4;
46
 
    printf(" bin bin\n");
47
 
    while (readbuffer[counter] != '\n')
48
 
      counter++;
49
 
    counter++;
50
 
  }
51
 
}
52
 
 
53
 
int main(int argc, char **argv)
54
 
{
55
 
  struct stat statbuf;
56
 
  FILE *infile;
57
 
  unsigned char *buffer=NULL;
58
 
 
59
 
  if (argc==2)
60
 
  {
61
 
    if (stat(argv[1], &statbuf)>=0)
62
 
    {
63
 
      if (statbuf.st_size>0)
64
 
      {
65
 
        buffer=(unsigned char*)malloc(statbuf.st_size);
66
 
        if (buffer!=NULL)
67
 
        {
68
 
          infile=fopen(argv[1],"rb");
69
 
          if (infile)
70
 
          {
71
 
            if (fread(buffer,1,statbuf.st_size,infile)==statbuf.st_size)
72
 
            {
73
 
              convertprototype(buffer,statbuf.st_size);
74
 
            }
75
 
            else
76
 
              fclose(infile);
77
 
          }
78
 
        }
79
 
      }
80
 
    }
81
 
  }
82
 
  return 0;
83
 
}