Skip the RV printing test under threads until fixed.
[p5sagit/p5-mst-13.2.git] / epoc / epocish.c
CommitLineData
3a2f06e9 1/*
2 * Copyright (c) 1999 Olaf Flebbe o.flebbe@gmx.de
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Artistic License, as specified in the README file.
6 *
7 */
8
b250498f 9/* This is C++ Code !! */
3a2f06e9 10
11#include <e32std.h>
d5ff79b3 12#include <stdlib.h>
13#include <estlib.h>
14#include <string.h>
3a2f06e9 15
16extern "C" {
17
d5ff79b3 18#if 1
19int
3a2f06e9 20epoc_spawn( char *cmd, char *cmdline) {
21 RProcess p;
22 TRequestStatus status;
23 TInt rc;
24
25 rc = p.Create( _L( cmd), _L( cmdline));
d5ff79b3 26 if (rc != KErrNone) {
3a2f06e9 27 return -1;
d5ff79b3 28 }
3a2f06e9 29
30 p.Resume();
31
32 p.Logon( status);
33 User::WaitForRequest( status);
d5ff79b3 34 p.Kill( 0);
3a2f06e9 35 if (status!=KErrNone) {
36 return -1;
37 }
38 return 0;
39}
d5ff79b3 40#else
41int
42epoc_spawn( char *cmd, char *cmdline) {
43 int len = strlen(cmd) + strlen(cmdline) + 4;
44 char *n = (char *) malloc( len);
45 int r;
46 strcpy( n, cmd);
47 strcat( n, " ");
48 strcat( n, cmdline);
49 r = system( n);
50 free( n);
51 return r;
52}
53#endif
3a2f06e9 54
d5ff79b3 55/* Workaround for defect strtoul(). Values with leading + are zero */
56
57unsigned long int epoc_strtoul(const char *nptr, char **endptr,
58 int base) {
59 if (nptr && *nptr == '+')
60 nptr++;
61 return strtoul( nptr, endptr, base);
62}
b250498f 63
d5ff79b3 64/* Workaround for defect atof(), see java defect list for epoc */
65double epoc_atof( char* str) {
b250498f 66 TReal64 aRes;
fa6a1c44 67
68 while (TChar( *str).IsSpace()) {
69 str++;
70 }
b250498f 71
72 TLex lex( _L( str));
73 TInt err = lex.Val( aRes, TChar( '.'));
74 return aRes;
d5ff79b3 75}
b250498f 76
d5ff79b3 77void epoc_gcvt( double x, int digits, unsigned char *buf) {
b250498f 78 TRealFormat trel;
79
80 trel.iPlaces = digits;
81 trel.iPoint = TChar( '.');
82
83 TPtr result( buf, 80);
84
85 result.Num( x, trel);
86 result.Append( TChar( 0));
87 }
3a2f06e9 88}
d5ff79b3 89
90#if 0
91void epoc_spawn_posix_server() {
92 SpawnPosixServerThread();
93}
94#endif