nsprpub/pr/tests/depend.c

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /***********************************************************************
michael@0 7 ** 1996 - Netscape Communications Corporation
michael@0 8 **
michael@0 9 **
michael@0 10 ** Name: depend.c
michael@0 11 ** Description: Test to enumerate the dependencies
michael@0 12 *
michael@0 13 ** Modification History:
michael@0 14 ** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
michael@0 15 ** The debug mode will print all of the printfs associated with this test.
michael@0 16 ** The regress mode will be the default mode. Since the regress tool limits
michael@0 17 ** the output to a one line status:PASS or FAIL,all of the printf statements
michael@0 18 ** have been handled with an if (debug_mode) statement.
michael@0 19 ***********************************************************************/
michael@0 20 #include "prinit.h"
michael@0 21
michael@0 22 /***********************************************************************
michael@0 23 ** Includes
michael@0 24 ***********************************************************************/
michael@0 25 /* Used to get the command line option */
michael@0 26 #include "plgetopt.h"
michael@0 27
michael@0 28 #include <stdio.h>
michael@0 29 #include <stdlib.h>
michael@0 30
michael@0 31 static void PrintVersion(
michael@0 32 const char *msg, const PRVersion* info, PRIntn tab)
michael@0 33 {
michael@0 34 static const len = 20;
michael@0 35 static const char *tabs = {" "};
michael@0 36
michael@0 37 tab *= 2;
michael@0 38 if (tab > len) tab = len;
michael@0 39 printf("%s", &tabs[len - tab]);
michael@0 40 printf("%s ", msg);
michael@0 41 printf("%s ", info->id);
michael@0 42 printf("%d.%d", info->major, info->minor);
michael@0 43 if (0 != info->patch)
michael@0 44 printf(".p%d", info->patch);
michael@0 45 printf("\n");
michael@0 46 } /* PrintDependency */
michael@0 47
michael@0 48 static void ChaseDependents(const PRVersionInfo *info, PRIntn tab)
michael@0 49 {
michael@0 50 PrintVersion("exports", &info->selfExport, tab);
michael@0 51 if (NULL != info->importEnumerator)
michael@0 52 {
michael@0 53 const PRDependencyInfo *dependent = NULL;
michael@0 54 while (NULL != (dependent = info->importEnumerator(dependent)))
michael@0 55 {
michael@0 56 const PRVersionInfo *import = dependent->exportInfoFn();
michael@0 57 PrintVersion("imports", &dependent->importNeeded, tab);
michael@0 58 ChaseDependents(import, tab + 1);
michael@0 59 }
michael@0 60 }
michael@0 61 } /* ChaseDependents */
michael@0 62
michael@0 63 static PRVersionInfo hack_export;
michael@0 64 static PRVersionInfo dummy_export;
michael@0 65 static PRDependencyInfo dummy_imports[2];
michael@0 66
michael@0 67 static const PRVersionInfo *HackExportInfo(void)
michael@0 68 {
michael@0 69 hack_export.selfExport.major = 11;
michael@0 70 hack_export.selfExport.minor = 10;
michael@0 71 hack_export.selfExport.patch = 200;
michael@0 72 hack_export.selfExport.id = "Hack";
michael@0 73 hack_export.importEnumerator = NULL;
michael@0 74 return &hack_export;
michael@0 75 }
michael@0 76
michael@0 77 static const PRDependencyInfo *DummyImports(
michael@0 78 const PRDependencyInfo *previous)
michael@0 79 {
michael@0 80 if (NULL == previous) return &dummy_imports[0];
michael@0 81 else if (&dummy_imports[0] == previous) return &dummy_imports[1];
michael@0 82 else if (&dummy_imports[1] == previous) return NULL;
michael@0 83 } /* DummyImports */
michael@0 84
michael@0 85 static const PRVersionInfo *DummyLibVersion(void)
michael@0 86 {
michael@0 87 dummy_export.selfExport.major = 1;
michael@0 88 dummy_export.selfExport.minor = 0;
michael@0 89 dummy_export.selfExport.patch = 0;
michael@0 90 dummy_export.selfExport.id = "Dumbass application";
michael@0 91 dummy_export.importEnumerator = DummyImports;
michael@0 92
michael@0 93 dummy_imports[0].importNeeded.major = 2;
michael@0 94 dummy_imports[0].importNeeded.minor = 0;
michael@0 95 dummy_imports[0].importNeeded.patch = 0;
michael@0 96 dummy_imports[0].importNeeded.id = "Netscape Portable Runtime";
michael@0 97 dummy_imports[0].exportInfoFn = PR_ExportInfo;
michael@0 98
michael@0 99 dummy_imports[1].importNeeded.major = 5;
michael@0 100 dummy_imports[1].importNeeded.minor = 1;
michael@0 101 dummy_imports[1].importNeeded.patch = 2;
michael@0 102 dummy_imports[1].importNeeded.id = "Hack Library";
michael@0 103 dummy_imports[1].exportInfoFn = HackExportInfo;
michael@0 104
michael@0 105 return &dummy_export;
michael@0 106 } /* DummyLibVersion */
michael@0 107
michael@0 108 int main(int argc, char **argv)
michael@0 109 {
michael@0 110 PRIntn tab = 0;
michael@0 111 const PRVersionInfo *info = DummyLibVersion();
michael@0 112 const char *buildDate = __DATE__, *buildTime = __TIME__;
michael@0 113
michael@0 114 printf("Depend.c build time is %s %s\n", buildDate, buildTime);
michael@0 115
michael@0 116 if (NULL != info) ChaseDependents(info, tab);
michael@0 117
michael@0 118 return 0;
michael@0 119 } /* main */
michael@0 120
michael@0 121 /* depend.c */

mercurial