VirtualBox

Ignore:
Timestamp:
Nov 21, 2023 9:42:06 PM (14 months ago)
Author:
vboxsync
Message:

libs/xpcom: Remove more unused code, bugref:10545

Location:
trunk/src/libs/xpcom18a4/nsprpub/pr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/pr/include/prprf.h

    r102194 r102223  
    6464#define PR_smprintf VBoxNsprPR_smprintf
    6565#define PR_smprintf_free VBoxNsprPR_smprintf_free
    66 #define PR_sprintf_append VBoxNsprPR_sprintf_append
    67 #define PR_sxprintf VBoxNsprPR_sxprintf
    6866#define PR_vsmprintf VBoxNsprPR_vsmprintf
    69 #define PR_vsprintf_append VBoxNsprPR_vsprintf_append
    70 #define PR_vsxprintf VBoxNsprPR_vsxprintf
    7167#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
    7268
     
    9389
    9490/*
    95 ** "append" sprintf into a PR_MALLOC'd buffer. "last" is the last value of
    96 ** the PR_MALLOC'd buffer. sprintf will append data to the end of last,
    97 ** growing it as necessary using realloc. If last is NULL, PR_sprintf_append
    98 ** will allocate the initial string. The return value is the new value of
    99 ** last for subsequent calls, or NULL if there is a malloc failure.
    100 */
    101 NSPR_API(char*) PR_sprintf_append(char *last, const char *fmt, ...);
    102 
    103 /*
    104 ** sprintf into a function. The function "f" is called with a string to
    105 ** place into the output. "arg" is an opaque pointer used by the stuff
    106 ** function to hold any state needed to do the storage of the output
    107 ** data. The return value is a count of the number of characters fed to
    108 ** the stuff function, or (PRUint32)-1 if an error occurs.
    109 */
    110 typedef PRIntn (*PRStuffFunc)(void *arg, const char *s, PRUint32 slen);
    111 
    112 NSPR_API(PRUint32) PR_sxprintf(PRStuffFunc f, void *arg, const char *fmt, ...);
    113 
    114 /*
    11591** va_list forms of the above.
    11692*/
    11793NSPR_API(PRUint32) PR_vsnprintf(char *out, PRUint32 outlen, const char *fmt, va_list ap);
    11894NSPR_API(char*) PR_vsmprintf(const char *fmt, va_list ap);
    119 NSPR_API(char*) PR_vsprintf_append(char *last, const char *fmt, va_list ap);
    120 NSPR_API(PRUint32) PR_vsxprintf(PRStuffFunc f, void *arg, const char *fmt, va_list ap);
    12195
    12296PR_END_EXTERN_C
  • trunk/src/libs/xpcom18a4/nsprpub/pr/include/prtime.h

    r102178 r102223  
    5353#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
    5454#define PR_Now VBoxNsprPR_Now
    55 #define PR_ExplodeTime VBoxNsprPR_ExplodeTime
    56 #define PR_ImplodeTime VBoxNsprPR_ImplodeTime
    57 #define PR_NormalizeTime VBoxNsprPR_NormalizeTime
    5855#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
    5956
     
    8784typedef PRInt64 PRTime;
    8885
    89 /*
    90  * Time zone and daylight saving time corrections applied to GMT to
    91  * obtain the local time of some geographic location
    92  */
    93 
    94 typedef struct PRTimeParameters {
    95     PRInt32 tp_gmt_offset;     /* the offset from GMT in seconds */
    96     PRInt32 tp_dst_offset;     /* contribution of DST in seconds */
    97 } PRTimeParameters;
    98 
    99 /*
    100  * PRExplodedTime --
    101  *
    102  *     Time broken down into human-readable components such as year, month,
    103  *     day, hour, minute, second, and microsecond.  Time zone and daylight
    104  *     saving time corrections may be applied.  If they are applied, the
    105  *     offsets from the GMT must be saved in the 'tm_params' field so that
    106  *     all the information is available to reconstruct GMT.
    107  *
    108  *     Notes on porting: PRExplodedTime corrresponds to struct tm in
    109  *     ANSI C, with the following differences:
    110  *       - an additional field tm_usec;
    111  *       - replacing tm_isdst by tm_params;
    112  *       - the month field is spelled tm_month, not tm_mon;
    113  *       - we use absolute year, AD, not the year since 1900.
    114  *     The corresponding type in NSPR 1.0 is called PRTime.  Below is
    115  *     a table of date/time type correspondence in the three APIs:
    116  *         API          time since epoch          time in components
    117  *       ANSI C             time_t                  struct tm
    118  *       NSPR 1.0           PRInt64                   PRTime
    119  *       NSPR 2.0           PRTime                  PRExplodedTime
    120  */
    121 
    122 typedef struct PRExplodedTime {
    123     PRInt32 tm_usec;                /* microseconds past tm_sec (0-99999)  */
    124     PRInt32 tm_sec;             /* seconds past tm_min (0-61, accomodating
    125                                    up to two leap seconds) */   
    126     PRInt32 tm_min;             /* minutes past tm_hour (0-59) */
    127     PRInt32 tm_hour;            /* hours past tm_day (0-23) */
    128     PRInt32 tm_mday;            /* days past tm_mon (1-31, note that it
    129                                                 starts from 1) */
    130     PRInt32 tm_month;           /* months past tm_year (0-11, Jan = 0) */
    131     PRInt16 tm_year;            /* absolute year, AD (note that we do not
    132                                                 count from 1900) */
    133 
    134     PRInt8 tm_wday;                     /* calculated day of the week
    135                                                 (0-6, Sun = 0) */
    136     PRInt16 tm_yday;            /* calculated day of the year
    137                                                 (0-365, Jan 1 = 0) */
    138 
    139     PRTimeParameters tm_params;  /* time parameters used by conversion */
    140 } PRExplodedTime;
    141 
    142 /*
    143  * PRTimeParamFn --
    144  *
    145  *     A function of PRTimeParamFn type returns the time zone and
    146  *     daylight saving time corrections for some geographic location,
    147  *     given the current time in GMT.  The input argument gmt should
    148  *     point to a PRExplodedTime that is in GMT, i.e., whose
    149  *     tm_params contains all 0's.
    150  *
    151  *     For any time zone other than GMT, the computation is intended to
    152  *     consist of two steps:
    153  *       - Figure out the time zone correction, tp_gmt_offset.  This number
    154  *         usually depends on the geographic location only.  But it may
    155  *         also depend on the current time.  For example, all of China
    156  *         is one time zone right now.  But this situation may change
    157  *         in the future.
    158  *       - Figure out the daylight saving time correction, tp_dst_offset.
    159  *         This number depends on both the geographic location and the
    160  *         current time.  Most of the DST rules are expressed in local
    161  *         current time.  If so, one should apply the time zone correction
    162  *         to GMT before applying the DST rules.
    163  */
    164 
    165 typedef PRTimeParameters (PR_CALLBACK *PRTimeParamFn)(const PRExplodedTime *gmt);
    166 
    16786/**********************************************************************/
    16887/****************************** FUNCTIONS *****************************/
     
    189108PR_Now(void);
    190109
    191 /*
    192  * Expand time binding it to time parameters provided by PRTimeParamFn.
    193  * The calculation is envisoned to proceed in the following steps:
    194  *   - From given PRTime, calculate PRExplodedTime in GMT
    195  *   - Apply the given PRTimeParamFn to the GMT that we just calculated
    196  *     to obtain PRTimeParameters.
    197  *   - Add the PRTimeParameters offsets to GMT to get the local time
    198  *     as PRExplodedTime.
    199  */
    200 
    201 NSPR_API(void) PR_ExplodeTime(
    202     PRTime usecs, PRTimeParamFn params, PRExplodedTime *exploded);
    203 
    204 /* Reverse operation of PR_ExplodeTime */
    205 #if defined(HAVE_WATCOM_BUG_2)
    206 PRTime __pascal __export __loadds
    207 #else
    208 NSPR_API(PRTime)
    209 #endif
    210 PR_ImplodeTime(const PRExplodedTime *exploded);
    211 
    212 /*
    213  * Adjust exploded time to normalize field overflows after manipulation.
    214  * Note that the following fields of PRExplodedTime should not be
    215  * manipulated:
    216  *   - tm_month and tm_year: because the number of days in a month and
    217  *     number of days in a year are not constant, it is ambiguous to
    218  *     manipulate the month and year fields, although one may be tempted
    219  *     to.  For example, what does "a month from January 31st" mean?
    220  *   - tm_wday and tm_yday: these fields are calculated by NSPR.  Users
    221  *     should treat them as "read-only".
    222  */
    223 
    224 NSPR_API(void) PR_NormalizeTime(
    225     PRExplodedTime *exploded, PRTimeParamFn params);
    226 
    227110PR_END_EXTERN_C
    228111
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prprf.c

    r102000 r102223  
    10121012}
    10131013
    1014 /************************************************************************/
    1015 
    1016 static int FuncStuff(SprintfState *ss, const char *sp, PRUint32 len)
    1017 {
    1018     int rv;
    1019 
    1020     rv = (*ss->func)(ss->arg, sp, len);
    1021     if (rv < 0) {
    1022         return rv;
    1023     }
    1024     ss->maxlen += len;
    1025     return 0;
    1026 }
    1027 
    1028 PR_IMPLEMENT(PRUint32) PR_sxprintf(PRStuffFunc func, void *arg,
    1029                                  const char *fmt, ...)
    1030 {
    1031     va_list ap;
    1032     PRUint32 rv;
    1033 
    1034     va_start(ap, fmt);
    1035     rv = PR_vsxprintf(func, arg, fmt, ap);
    1036     va_end(ap);
    1037     return rv;
    1038 }
    1039 
    1040 PR_IMPLEMENT(PRUint32) PR_vsxprintf(PRStuffFunc func, void *arg,
    1041                                   const char *fmt, va_list ap)
    1042 {
    1043     SprintfState ss;
    1044     int rv;
    1045 
    1046     ss.stuff = FuncStuff;
    1047     ss.func = func;
    1048     ss.arg = arg;
    1049     ss.maxlen = 0;
    1050     rv = dosprintf(&ss, fmt, ap);
    1051     return (rv < 0) ? (PRUint32)-1 : ss.maxlen;
    1052 }
    1053 
    10541014/*
    10551015** Stuff routine that automatically grows the malloc'd output buffer
     
    11911151    return n ? n - 1 : n;
    11921152}
    1193 
    1194 PR_IMPLEMENT(char *) PR_sprintf_append(char *last, const char *fmt, ...)
    1195 {
    1196     va_list ap;
    1197     char *rv;
    1198 
    1199     va_start(ap, fmt);
    1200     rv = PR_vsprintf_append(last, fmt, ap);
    1201     va_end(ap);
    1202     return rv;
    1203 }
    1204 
    1205 PR_IMPLEMENT(char *) PR_vsprintf_append(char *last, const char *fmt, va_list ap)
    1206 {
    1207     SprintfState ss;
    1208     int rv;
    1209 
    1210     ss.stuff = GrowStuff;
    1211     if (last) {
    1212         int lastlen = strlen(last);
    1213         ss.base = last;
    1214         ss.cur = last + lastlen;
    1215         ss.maxlen = lastlen;
    1216     } else {
    1217         ss.base = 0;
    1218         ss.cur = 0;
    1219         ss.maxlen = 0;
    1220     }
    1221     rv = dosprintf(&ss, fmt, ap);
    1222     if (rv < 0) {
    1223         if (ss.base) {
    1224             PR_DELETE(ss.base);
    1225         }
    1226         return 0;
    1227     }
    1228     return ss.base;
    1229 }
    1230 
Note: See TracChangeset for help on using the changeset viewer.

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