Skip to content

Commit

Permalink
Screw it, I'm using C++-style comments. If a compelling reason comes …
Browse files Browse the repository at this point in the history
…up to

 limit myself to pre-C99 standards, I'll push everything through a perl
 script, but really, install GCC.  :)
  • Loading branch information
icculus committed Mar 25, 2006
1 parent d15122a commit 4070388
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 51 deletions.
2 changes: 1 addition & 1 deletion buildver.c
Expand Up @@ -50,5 +50,5 @@

const char *GBuildVer = MAKEBUILDVERSTRINGLITERAL(APPID, APPREV);

/* end of buildver.c ... */
// end of buildver.c ...

14 changes: 7 additions & 7 deletions fileio.h
Expand Up @@ -19,17 +19,17 @@ extern "C" {
* abstraction could be extended to network connections and such, too.
*/

/* Abstract input interface. Files, memory, archive entries, etc. */
// Abstract input interface. Files, memory, archive entries, etc.
typedef struct MojoInput MojoInput;
struct MojoInput
{
/*public*/
// public
size_t (*read)(MojoInput *io, void *buf, size_t bufsize);
boolean (*seek)(MojoInput *io, uint64 pos);
uint64 (*tell)(MojoInput *io);
void (*close)(MojoInput *io);

/*private*/
// private
void *opaque;
};

Expand All @@ -43,7 +43,7 @@ typedef enum
MOJOARCHIVE_ENTRY_SYMLINK,
} MojoArchiveEntryType;

/* Abstract archive interface. Archives, directories, etc. */
// Abstract archive interface. Archives, directories, etc.
typedef struct MojoArchiveEntryInfo MojoArchiveEntryInfo;
struct MojoArchiveEntryInfo
{
Expand All @@ -55,13 +55,13 @@ struct MojoArchiveEntryInfo
typedef struct MojoArchive MojoArchive;
struct MojoArchive
{
/*public*/
// public
void (*restartEnumeration)(MojoArchive *ar);
const MojoArchiveEntryInfo* (*enumEntry)(MojoArchive *ar);
MojoInput* (*openCurrentEntry)(MojoArchive *ar);
void (*close)(MojoArchive *ar);

/*private*/
// private
MojoInput *io;
MojoArchiveEntryInfo lastEnumInfo;
void *opaque;
Expand All @@ -76,5 +76,5 @@ MojoArchive *MojoArchive_newFromInput(MojoInput *io, const char *origfname);

#endif

/* end of fileio.h ... */
// end of fileio.h ...

10 changes: 5 additions & 5 deletions gui.h
Expand Up @@ -7,7 +7,7 @@
extern "C" {
#endif

/* Increment this value when binary compatibility changes. */
// Increment this value when binary compatibility changes.
#define MOJOGUI_INTERFACE_REVISION 1

typedef enum
Expand All @@ -28,19 +28,19 @@ typedef enum
typedef struct MojoGui_rev1 MojoGui_rev1;
struct MojoGui_rev1
{
/*public*/
// public
uint8 (*priority)(MojoGui_rev1 *gui);
boolean (*init)(MojoGui_rev1 *gui);
void (*deinit)(MojoGui_rev1 *gui);
void (*msgbox)(MojoGui_rev1 *gui, const char *title, const char *text);
boolean (*promptyn)(MojoGui_rev1 *gui, const char *title, const char *text);

/*private*/
// private
void *opaque;
};


/* Tapdance to handle interface revisions... */
// Tapdance to handle interface revisions...

/*
* The latest revision struct is just called "MojoGui" for convenience
Expand Down Expand Up @@ -87,5 +87,5 @@ MOJOGUI_STRUCT *MOJOGUI_ENTRY_POINT(void) \

#endif

/* end of gui.h ... */
// end of gui.h ...

4 changes: 2 additions & 2 deletions gui/gui_stdio.c
Expand Up @@ -38,12 +38,12 @@ static boolean MojoGui_stdio_promptyn(MojoGui_rev1 *gui, const char *title, cons
return 0;
else if (c == 'Y')
return 1;
} /* while */
} // while

return 0;
}

CREATE_MOJOGUI_ENTRY_POINT(stdio)

/* gui_stdio.c ... */
// gui_stdio.c ...

50 changes: 23 additions & 27 deletions mojosetup.c
Expand Up @@ -4,7 +4,7 @@
#include "fileio.h"
#include "gui.h"

/* !!! FIXME: None of these should be here. */
// !!! FIXME: None of these should be here.
#include <dlfcn.h>
#include <unistd.h>
#include <time.h>
Expand Down Expand Up @@ -36,26 +36,26 @@ static boolean mojoInputToPhysicalFile(MojoInput *in, const char *fname)
{
br = in->read(in, buf, sizeof (buf));
STUBBED("how to detect read failures?");
if (br == 0) /* we're done! */
if (br == 0) // we're done!
break;
else if (br < 0)
iofailure = true;
else
{
if (fwrite(buf, br, 1, out) != 1)
iofailure = true;
} /* else */
} /* while */
} // else
} // while

fclose(out);
if (iofailure)
{
unlink(fname);
return false;
} /* if */
} // if

return true;
} /* mojoInputToPhysicalFile */
} // mojoInputToPhysicalFile


static void *loadGuiPlugin(MojoArchive *ar)
Expand Down Expand Up @@ -87,18 +87,18 @@ static void *loadGuiPlugin(MojoArchive *ar)
{
STUBBED("abstract out dlsym, too. :)");
void *entry = dlsym(retval, MOJOGUI_ENTRY_POINT_STR);
if (entry == NULL) /* not a compatible plugin. */
if (entry == NULL) // not a compatible plugin.
{
STUBBED("aaaaaaand, dlclose")
dlclose(retval);
unlink(fname);
retval = NULL;
} /* if */
} /* if */
} /* if */
} // if
} // if
} // if

return retval;
} /* loadGuiPlugin */
} // loadGuiPlugin


typedef struct S_DLLLIST { void *lib; struct S_DLLLIST *next; } DllList;
Expand All @@ -113,10 +113,8 @@ static boolean findGuiPlugin(void)

STUBBED("DllList should track filename, isstatic, and entrypoint, too");

/*
* !!! FIXME: Have a global MojoArchive that represents the install
* !!! FIXME: (either an archive, a physical dir, etc.)
*/
// !!! FIXME: Have a global MojoArchive that represents the install
// !!! FIXME: (either an archive, a physical dir, etc.)
STUBBED("use a global MojoArchive for basedir");
MojoArchive *dir = MojoArchive_newFromDirectory(".");
if (dir == NULL)
Expand All @@ -128,11 +126,10 @@ static boolean findGuiPlugin(void)
void *lib;
DllList *item;

/* Not a file? */
if (entinfo->type != MOJOARCHIVE_ENTRY_FILE)
continue;

/* not in the gui dir? */
// not in the gui dir?
if (strncmp(entinfo->filename, "guiplugins/", 4) != 0)
continue;

Expand All @@ -147,7 +144,7 @@ static boolean findGuiPlugin(void)
item->lib = lib;
item->next = plugins.next;
plugins.next = item;
} /* while */
} // while

STUBBED("Add static plugins to the list");
STUBBED("Choose plugin by priority");
Expand All @@ -161,21 +158,20 @@ static boolean findGuiPlugin(void)
{
GGui = gui;
break;
} /* if */
} /* if */
} /* for */
} // if
} // if
} // for

STUBBED("close libs, delete tmp files, free list.");

STUBBED("Don't close this when it's a global.");
dir->close(dir);

return (GGui != NULL);
} /* findGuiPlugin */
} // findGuiPlugin

/*
* This is called from main()/WinMain()/whatever.
*/

// This is called from main()/WinMain()/whatever.
int MojoSetup_main(int argc, char **argv)
{
GArgc = argc;
Expand All @@ -189,7 +185,7 @@ int MojoSetup_main(int argc, char **argv)
STUBBED("cleanup gui lib, etc.\n");

return 0;
} /* MojoSetup_main */
} // MojoSetup_main

/* end of mojosetup.c ... */
// end of mojosetup.c ...

4 changes: 2 additions & 2 deletions platform.h
Expand Up @@ -7,7 +7,7 @@
extern "C" {
#endif

/* this is called by your mainline. */
// this is called by your mainline.
int MojoSetup_main(int argc, char **argv);

#ifdef __cplusplus
Expand All @@ -16,5 +16,5 @@ int MojoSetup_main(int argc, char **argv);

#endif

/* end of platform.h ... */
// end of platform.h ...

4 changes: 2 additions & 2 deletions platform/unix.c
Expand Up @@ -3,7 +3,7 @@
int main(int argc, char **argv)
{
return MojoSetup_main(argc, argv);
} /* main */
} // main

/* end of unix.c ... */
// end of unix.c ...

10 changes: 5 additions & 5 deletions universal.h
@@ -1,9 +1,9 @@
#ifndef _INCL_UNIVERSAL_H_
#define _INCL_UNIVERSAL_H_

/* Include this file from everywhere...it provides basic type sanity, etc. */
// Include this file from everywhere...it provides basic type sanity, etc.

/* Include the Holy Trinity. */
// Include the Holy Trinity...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -36,7 +36,7 @@ extern char **GArgv;
#else
#define __EXPORT__
#endif
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
#endif // DOXYGEN_SHOULD_IGNORE_THIS

#if 1
#define STUBBED(x) \
Expand All @@ -52,7 +52,7 @@ extern char **GArgv;
#define STUBBED(x)
#endif

/* !!! FIXME: make this a real function. */
// !!! FIXME: make this a real function.
#define dbgprintf printf

#ifdef __cplusplus
Expand All @@ -61,5 +61,5 @@ extern char **GArgv;

#endif

/* end of universal.h ... */
// end of universal.h ...

0 comments on commit 4070388

Please sign in to comment.