VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/tests/depend.c@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38/***********************************************************************
39** 1996 - Netscape Communications Corporation
40**
41**
42** Name: depend.c
43** Description: Test to enumerate the dependencies
44*
45** Modification History:
46** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
47** The debug mode will print all of the printfs associated with this test.
48** The regress mode will be the default mode. Since the regress tool limits
49** the output to a one line status:PASS or FAIL,all of the printf statements
50** have been handled with an if (debug_mode) statement.
51***********************************************************************/
52#include "prinit.h"
53
54/***********************************************************************
55** Includes
56***********************************************************************/
57/* Used to get the command line option */
58#include "plgetopt.h"
59
60#include <stdio.h>
61#include <stdlib.h>
62
63static void PrintVersion(
64 const char *msg, const PRVersion* info, PRIntn tab)
65{
66 static const len = 20;
67 static const char *tabs = {" "};
68
69 tab *= 2;
70 if (tab > len) tab = len;
71 printf("%s", &tabs[len - tab]);
72 printf("%s ", msg);
73 printf("%s ", info->id);
74 printf("%d.%d", info->major, info->minor);
75 if (0 != info->patch)
76 printf(".p%d", info->patch);
77 printf("\n");
78} /* PrintDependency */
79
80static void ChaseDependents(const PRVersionInfo *info, PRIntn tab)
81{
82 PrintVersion("exports", &info->selfExport, tab);
83 if (NULL != info->importEnumerator)
84 {
85 const PRDependencyInfo *dependent = NULL;
86 while (NULL != (dependent = info->importEnumerator(dependent)))
87 {
88 const PRVersionInfo *import = dependent->exportInfoFn();
89 PrintVersion("imports", &dependent->importNeeded, tab);
90 ChaseDependents(import, tab + 1);
91 }
92 }
93} /* ChaseDependents */
94
95static PRVersionInfo hack_export;
96static PRVersionInfo dummy_export;
97static PRDependencyInfo dummy_imports[2];
98
99static const PRVersionInfo *HackExportInfo(void)
100{
101 hack_export.selfExport.major = 11;
102 hack_export.selfExport.minor = 10;
103 hack_export.selfExport.patch = 200;
104 hack_export.selfExport.id = "Hack";
105 hack_export.importEnumerator = NULL;
106 return &hack_export;
107}
108
109static const PRDependencyInfo *DummyImports(
110 const PRDependencyInfo *previous)
111{
112 if (NULL == previous) return &dummy_imports[0];
113 else if (&dummy_imports[0] == previous) return &dummy_imports[1];
114 else if (&dummy_imports[1] == previous) return NULL;
115} /* DummyImports */
116
117static const PRVersionInfo *DummyLibVersion(void)
118{
119 dummy_export.selfExport.major = 1;
120 dummy_export.selfExport.minor = 0;
121 dummy_export.selfExport.patch = 0;
122 dummy_export.selfExport.id = "Dumbass application";
123 dummy_export.importEnumerator = DummyImports;
124
125 dummy_imports[0].importNeeded.major = 2;
126 dummy_imports[0].importNeeded.minor = 0;
127 dummy_imports[0].importNeeded.patch = 0;
128 dummy_imports[0].importNeeded.id = "Netscape Portable Runtime";
129 dummy_imports[0].exportInfoFn = PR_ExportInfo;
130
131 dummy_imports[1].importNeeded.major = 5;
132 dummy_imports[1].importNeeded.minor = 1;
133 dummy_imports[1].importNeeded.patch = 2;
134 dummy_imports[1].importNeeded.id = "Hack Library";
135 dummy_imports[1].exportInfoFn = HackExportInfo;
136
137 return &dummy_export;
138} /* DummyLibVersion */
139
140int main(int argc, char **argv)
141{
142 PRIntn tab = 0;
143 const PRVersionInfo *info = DummyLibVersion();
144 const char *buildDate = __DATE__, *buildTime = __TIME__;
145
146 printf("Depend.c build time is %s %s\n", buildDate, buildTime);
147
148 if (NULL != info) ChaseDependents(info, tab);
149
150 return 0;
151} /* main */
152
153/* depend.c */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette