Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <types.h>
Link against: libc.lib

Typedef u_char

typedef unsigned char u_char;

Description

unsigned char

[Top]


Typedef u_short

typedef unsigned short u_short;

Description

unsigned short

[Top]


Typedef u_int

typedef unsigned int u_int;

Description

unsigned int

[Top]


Typedef u_long

typedef unsigned long u_long;

Description

unsigned long

[Top]


Typedef clock_t

Interface status: externallyDefinedApi

typedef __clock_t clock_t;

Description

Used for system times in clock ticks or CLOCKS_PER_SEC

[Top]


Typedef clockid_t

Interface status: externallyDefinedApi

typedef __clockid_t clockid_t;

Description

Used for clock ID type in the clock and timer functions.

[Top]


Typedef critical_t

typedef __critical_t critical_t;

Description

Critical section value

[Top]


Typedef daddr_t

typedef __int64_t daddr_t;

Description

disk address

[Top]


Typedef fixpt_t

Interface status: externallyDefinedApi

typedef __fixpt_t fixpt_t;

Description

fixed point number

[Top]


Typedef fsblkcnt_t

Interface status: externallyDefinedApi

typedef __fsblkcnt_t fsblkcnt_t;

Description

Used for file system block counts.

[Top]


Typedef fsfilcnt_t

Interface status: externallyDefinedApi

typedef __fsfilcnt_t fsfilcnt_t;

Description

Used for file system file counts.

[Top]


Typedef id_t

Interface status: externallyDefinedApi

typedef __id_t id_t;

Description

Used as a general identifier; can be used to contain at least a pid_t, uid_t, or gid_t.

[Top]


Typedef key_t

Interface status: externallyDefinedApi

typedef __key_t key_t;

Description

Used for XSI interprocess communication.

[Top]


Typedef lwpid_t

typedef __lwpid_t lwpid_t;

Description

Thread ID

[Top]


Typedef register_t

Interface status: externallyDefinedApi

typedef __register_t register_t;

Description

register size

[Top]


Typedef segsz_t

Interface status: externallyDefinedApi

typedef __segsz_t segsz_t;

Description

segment size (in Pages)

[Top]


Typedef timer_t

Interface status: externallyDefinedApi

typedef __timer_t timer_t;

Description

Used for timer ID returned by timer_create().

[Top]


Typedef u_register_t

Interface status: externallyDefinedApi

typedef __u_register_t u_register_t;

Description

register type

[Top]


Typedef useconds_t

Interface status: externallyDefinedApi

typedef __useconds_t useconds_t;

Description

Used for time in microseconds

[Top]


ftruncate(int,off_t)

Interface status: externallyDefinedApi

IMPORT_C int ftruncate(int, off_t);

Description

Parameters

int

off_toff_t

Refer to truncate(const char *,off_t)truncate(const char *,off_t) for documentation

Return value

int

[Top]


lseek(int,off_t,int)

Interface status: externallyDefinedApi

IMPORT_C off_t lseek(int, off_t, int);

Description

The lseek system call repositions the offset of the file descriptor fildes to the argument offset according to the directive whence. The argument fildes must be an open file descriptor. The lseek system call repositions the file position pointer associated with the file descriptor fildes as follows: If whence is SEEK_SET, the offset is set to offset bytes. If whence is SEEK_CUR, the offset is set to its current location plus offset bytes. If whence is SEEK_END, the offset is set to the size of the file plus offset bytes. Some devices are incapable of seeking. The value of the pointer associated with such a device is undefined.

Note : lseek function allows the file offset to be set beyond the existing end-of-file, data in the seeked slot is undefined, and hence the read operation in seeked slot is undefined untill data is actually written into it. lseek beyond existing end-of-file increases the file size accordingly.

Errors:

The lseek system call will fail and the file position pointer will remain unchanged if: [EBADF] The fildes argument is not an open file descriptor. [EINVAL] The whence argument is not a proper value or the resulting file offset would be negative for a non-character special file. [EOVERFLOW] The resulting file offset would be a value which cannot be represented correctly in an object of type off_t(Not supported). [ESPIPE] The fildes argument is associated with a pipe, socket, or FIFO.

Examples:

/*
 Detailed description  : Example for lseek usage.
 */
# 787 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 788 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 789 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
# 790 "d:/EPOC/release/9.4/common/generic/openenv/core/include/unistd.dosc" 2
int main()
{
int fd = 0;
 fd = open("lseek.txt"  ,  0x0200  |  0x0002  , 0666);
  if(lseek(fd , 0 ,  0 ) < 0 ) {
     printf("Lseek on file lseek.txt failed \n");
      return -1;
  }
  printf("Lseek on lseek.txt passed ");
 return 0;
}

Output

Lseek on lseek.txt passed

Parameters

int

off_toff_t

int

Return value

off_toff_t

Upon successful completion, lseek returns the resulting offset location as measured in bytes from the beginning of the file. Otherwise, a value of -1 is returned and errno is set to indicate the error.

[Top]


mmap(void *,size_t,int,int,int,off_t)

Interface status: externallyDefinedApi

IMPORT_C void* mmap(void *, size_t, int, int, int, off_t);

Description

The mmap system call causes the pages starting at addr and continuing for at most len bytes to be mapped from the object described by fildes, starting at byte offset offset. If len is not a multiple of the pagesize, the mapped region may extend past the specified range. Any such extension beyond the end of the mapped object will be zero-filled.

If addr is non-zero, it is used as a hint to the system. (As a convenience to the system, the actual address of the region may differ from the address supplied). If addr is zero, an address will be selected by the system. The actual starting address of the region is returned. A successful mmap deletes any previous mapping in the allocated address range.

The protections (region accessibility) are specified in the prot argument by or'ing the following values:

PROT_READ  Pages may be read.
PROT_WRITE     Pages may be written.
PROT_EXEC  Pages may be executed.
PROT_NONE  This protection mode is currently not supported.

The flags argument specifies the type of the mapped object, mapping options and whether modifications made to the mapped copy of the page are private to the process or are to be shared with other references. Sharing, mapping type and options are specified in the flags argument by or'ing the following values:

MAP_PRIVATE    Modifications are private.
MAP_SHARED     Modifications are shared.
MAP_FIXED, MAP_FILE, MAP_ANON, MAP_HASSEMAPHORE, MAP_STACK, MAP_NOSYNC -- These flags are currently not supported.

The close system call does not unmap pages, see munmap for further information.

The current design does not allow a process to specify the location of swap space. In the future we may define an additional mapping type, MAP_SWAP, in which the file descriptor argument specifies a file or device to which swapping should be done.

Examples:

/* Detailed description  : Example to create a mapped memory to a file region.
 Precondition : None              
 /
#include <unistd.h>
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
int main(void)
{
    int fd = -1;
    char* mapaddr;
    int len = getpagesize();
    int prot = PROT_WRITE | PROT_READ;
    if((fd = open("C:\Test.txt", O_RDWR | O_CREAT, 0666) ) < 0){
        printf("File open failed");
    }
    mapaddr = (char*)mmap((void*)0, len, prot, MAP_SHARED, fd, 0);
    if(mapaddr == MAP_FAILED){
        printf("mmap on file failed");
    }
    printf("mmap on file succeeded");
}

Parameters

void *

Represents the parameter addr

size_tsize_t

int

int

int

off_toff_t

See also:

[Top]


truncate(const char *,off_t)

Interface status: externallyDefinedApi

IMPORT_C int truncate(const char *, off_t);

Description

The truncate system call causes the file named by file or referenced by filedesc to be truncated to length bytes in size. If the file was larger than this size, the extra data is lost. If the file was smaller than this size, it will be extended as if by writing bytes with the value zero. With ftruncate, the file must be open for writing.

Examples:

//example for truncate
#include<unistd.h>
#include<stdio.h>
#include <sys/stat.h>
int test_truncate()
{
        int retVal, retVal2, retSize, retSize2;
        struct stat buf;
        ssize_t size;
        char *buffer = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx";
        int fp = open("c:\test.txt", O_RDWR|O_CREAT);
        size = write(fp,buffer,50);
        close(fp);
        retVal2 = stat("c:\test.txt", &buf );
        if ( !retVal2 )
        {
        retSize = buf.st_size;
        printf("Size before: %d", retSize);
        retVal = truncate("c:\test.txt", retSize/2 );
        }
        else
        {
        printf("Failed");
        }
        retVal2 = stat( "c:\test.txt", &buf );
        if ( !retVal2 )
                {
                retSize2 = buf.st_size;
                if( retSize2 == (retSize/2 ) )
                        {
                        printf("\nSize after: %d\n", retSize2);
                        printf("Truncate passed");
                        return 0;
                        }
                else
                        {
                        printf("Failed");
                        return -1;
                        }
                }
        else
                {
                printf("Failed");
                return -1;
                }
}

Output

Size before: 50
Size after: 25
Ttruncate Passed

Errors:

The truncate and ftruncate succeed unless: [EBADF] The filedesc argument is not a valid descriptor for a regular file. [EINVAL] The filedesc argument references to an object other than a file. [EINVAL] The filedesc descriptor is not open for writing.

Bugs:

These calls should be generalized to allow ranges of bytes in a file to be discarded. Use of truncate to extend a file is not portable.

Parameters

const char *

off_toff_t

Return value

int

Upon successful completion, both truncate(const char *,off_t)truncate(const char *,off_t) and ftruncate(int,off_t)ftruncate(int,off_t) shall return 0; otherwise, -1 shall be returned and errno set to indicate the error.