Ejemplo n.º 1
0
static TACommandVerdict wcpncpy_cmd(TAThread thread,TAInputStream stream)
{
    wchar_t* dest;
    wchar_t* src;
    size_t n;
    wchar_t* res;

    // Prepare
    dest = (wchar_t*)readPointer(&stream);
    src = (wchar_t*)readPointer(&stream);
    n = readSize(&stream);

    START_TARGET_OPERATION(thread);

    // Execute
    res = wcpncpy(dest, src, n);

    END_TARGET_OPERATION(thread);

    // Response
    writePointer(thread, res);
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 2
0
static TACommandVerdict wcsncpy_cmd(TAThread thread, TAInputStream stream)
{
    wchar_t* ws1;
    wchar_t* ws2;
    size_t n;
    wchar_t* res;

    // Prepare
    ws1 = (wchar_t*)readPointer(&stream);
    ws2 = (wchar_t*)readPointer(&stream);
    n = readSize(&stream);

    START_TARGET_OPERATION(thread);

    // Execute
    res = wcsncpy(ws1, ws2, n);

    END_TARGET_OPERATION(thread);

    // Response
    writePointer(thread, res);
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 3
0
static TACommandVerdict wcstok_cmd(TAThread thread,TAInputStream stream)
{
    wchar_t* stringp, *buff, *delim, *res;

/*
    freopen(NULL, "a+", stdout);
    orient=fwide(stdout, 0);
    wprintf(L"Before wcstok(wprintf): mode==%ls\n", orient>0?L"Wide": orient<0?L"Byte":L"Non oriented");
    wprintf(L"Test==%ls\n", test);
    ta_debug_printf("Before wcstok(printf): mode==%s\n", orient>0?"Wide": orient<0?"Byte":"Non oriented");
*/    

    // Prepare       
    stringp=(wchar_t*)readPointer(&stream);
    delim=(wchar_t*)readPointer(&stream);
    buff=(wchar_t*)readPointer(&stream);    

    // Execute    
    START_TARGET_OPERATION(thread);
    res = wcstok(stringp, delim, &buff);
    END_TARGET_OPERATION(thread);

    // Response    
    writePointer(thread, res);
    writePointer(thread, buff);

    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 4
0
static TACommandVerdict wcscmp_cmd(TAThread thread, TAInputStream stream)
{
    wchar_t* ws1;
    wchar_t* ws2;
    int res;

    // Prepare
    ws1 = (wchar_t*)readPointer(&stream);
    ws2 = (wchar_t*)readPointer(&stream);


    START_TARGET_OPERATION(thread);
	print_wstring(ws1);
	print_wstring(ws2);

    // Execute
    res = wcscmp(ws1, ws2);
	ta_debug_printf("res %d\n", res);

    END_TARGET_OPERATION(thread);

    // Response
    writeInt(thread, res);
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 5
0
static TACommandVerdict strtok_r_cmd(TAThread thread,TAInputStream stream)
{
    char* stringp, *buff;
    char *delim, *res;

    // Prepare       
    stringp=(char*)readPointer(&stream);
    delim=(char*)readPointer(&stream);
    buff=(char*)readPointer(&stream);    

    ta_debug_printf("strtok_r...\n");
    ta_debug_printf("stringp==%s\n", stringp);  
    ta_debug_printf("delim==%s\n", delim);
    
    // Execute    
    START_TARGET_OPERATION(thread);
    res = strtok_r(stringp, delim, &buff);
    END_TARGET_OPERATION(thread);

    ta_debug_printf("After...\n");
    ta_debug_printf("stringp==%s\n", stringp);
    ta_debug_printf("delim==%s\n", delim);
    ta_debug_printf("buff==%s\n", buff);

    // Response    
    writePointer(thread, res);
    writePointer(thread, buff);

    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 6
0
static TACommandVerdict gzgets_cmd(TAThread thread,TAInputStream stream)
{
    void* file;
    char* buf, *res;
    int len, errnum;

    file = readPointer(&stream);
    buf = (char*)readPointer(&stream);
    len = readInt(&stream);

    START_TARGET_OPERATION(thread);

    res = gzgets(file, buf, len);

    END_TARGET_OPERATION(thread);

    gzerror(file, &errnum);

    writeInt(thread, errnum);
    writePointer(thread, (void*)res);

    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 7
0
static TACommandVerdict compress_cmd(TAThread thread,TAInputStream stream)
{
    Bytef * dest, *source;
    uLongf destLen, sourceLen;
    int res;

    dest = readPointer(&stream);
    destLen = readULong(&stream);
    source = readPointer(&stream);
    sourceLen=readULong(&stream);

    START_TARGET_OPERATION(thread);

    res = compress(dest, &destLen, source, sourceLen);

    END_TARGET_OPERATION(thread);

    writePointer(thread, dest);
    writeULong(thread, destLen);
    writeInt(thread, res);

    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 8
0
static TACommandVerdict compress2_cmd(TAThread thread,TAInputStream stream)
{
    Bytef * dest, *source;
    uLongf destLen, sourceLen;
    int res, level;

    dest = readPointer(&stream);
    destLen = readULong(&stream);
    source = readPointer(&stream);
    sourceLen = readULong(&stream);
    level = readInt(&stream);

    ta_debug_printf("level==%d\n", level);
    ta_debug_printf("source==%s\n", source);

    START_TARGET_OPERATION(thread);

    if(level==-1)
        res = compress2(dest, &destLen, source, sourceLen,
                                                Z_DEFAULT_COMPRESSION);
    else
        res = compress2(dest, &destLen, source, sourceLen, level);

    END_TARGET_OPERATION(thread);

    ta_debug_printf("dest==%s\n", dest);

    writePointer(thread, dest);
    writeULong(thread, destLen);
    writeInt(thread, res);

    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 9
0
Archivo: animnode.c Proyecto: HJvT/hat
/**
 * Attempt to read a value applicaiton expression type node at a certain offset.
 *
 * @param  hatFile The file to read the node from.
 * @param  offset  The offset where the start of the node should be.
 * @return A node construct containing the read values.
 */
node* readExpValueApp(FILE *hatFile, unsigned long offset)
{
    int  argIndex;
    node *newNode = (node *)malloc(sizeof(node));
    char tag;
    
    newNode->nodeType = ExpValueApp;
    newNode->offset = offset;
    
    setFilePos(hatFile, offset);
    tag = readByte(hatFile);
    if (newNode->params.expValueApp.hasUse = hasSrcPos(tag))
    {
        newNode->params.expValueApp.use = readPointer(hatFile);
    }
    newNode->params.expValueApp.parent = readPointer(hatFile);
    newNode->params.expValueApp.function = readPointer(hatFile);
    newNode->params.expValueApp.arity = readArity(hatFile);
    newNode->params.expValueApp.args = (unsigned long *)malloc(newNode->params.expValueApp.arity * sizeof(unsigned long));
    for (argIndex = 0; argIndex < newNode->params.expValueApp.arity; argIndex++)
    {
        newNode->params.expValueApp.args[argIndex] = readPointer(hatFile);
    }
    
    return newNode;
}
Ejemplo n.º 10
0
static TACommandVerdict gzread_cmd(TAThread thread,TAInputStream stream)
{
    void* file, *buf;
    unsigned int len;
    int errnum, res;

    file = readPointer(&stream);
    buf = readPointer(&stream);
    len = readUInt(&stream);

    START_TARGET_OPERATION(thread);

    errno = 0;
    res = gzread(file, buf, len);

    END_TARGET_OPERATION(thread);

    gzerror(file, &errnum);

    writeInt(thread, errnum);
    writeInt(thread, errno);
    writeInt(thread, res);

    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 11
0
static TACommandVerdict strncpy_cmd(TAThread thread, TAInputStream stream)
{
    char* s1;
    char* s2;
    size_t n;
    char* res;

    // Prepare
    s1 = (char*)readPointer(&stream);
    s2 = (char*)readPointer(&stream);
    n = readSize(&stream);

    START_TARGET_OPERATION(thread);

    // Execute
    res = strncpy(s1, s2, n);

    END_TARGET_OPERATION(thread);

    // Response
    writePointer(thread, res);
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 12
0
Archivo: animnode.c Proyecto: HJvT/hat
/**
 * Attempt to read an atom constructor type node at a certain offset.
 *
 * @param  hatFile The file to read the node from.
 * @param  offset  The offset where the start of the node should be.
 * @return A node construct containing the read values.
 */
node* readAtomConstructor(FILE *hatFile, unsigned long offset)
{
    int  argIndex;
    char tag;
    node *newNode = (node *)malloc(sizeof(node));
    
    newNode->nodeType = AtomConstructor;
    newNode->offset = offset;
    
    setFilePos(hatFile, offset);
    tag = readByte(hatFile);
    newNode->params.atomConstructor.module = readPointer(hatFile);
    newNode->params.atomConstructor.filePos = readPosition(hatFile);
    readPosition(hatFile);  /* skip position end */
    newNode->params.atomConstructor.fix = readFixPri(hatFile);
    newNode->params.atomConstructor.arity = readArity(hatFile);
    newNode->params.atomConstructor.name = readString(hatFile);
    if (newNode->params.atomConstructor.hasFields = hasFields(tag))
    {
        newNode->params.atomConstructor.args = (unsigned long *)malloc(newNode->params.atomConstructor.arity * sizeof(unsigned long));
        for (argIndex = 0; argIndex < newNode->params.atomConstructor.arity; argIndex++)
        {
            newNode->params.atomConstructor.args[argIndex] = readPointer(hatFile);
        }
    }
    
    return newNode;
}
Ejemplo n.º 13
0
Archivo: animnode.c Proyecto: HJvT/hat
/**
 * Attempt to read a hidden expression type node at a certain offset.
 *
 * @param  hatFile The file to read the node from.
 * @param  offset  The offset where the start of the node should be.
 * @return A node construct containing the read values.
 */
node* readExpHidden(FILE *hatFile, unsigned long offset)
{
    node *newNode = (node *)malloc(sizeof(node));
    
    newNode->nodeType = ExpHidden;
    newNode->offset = offset;
    
    setFilePos(hatFile, offset + 1);
    newNode->params.expHidden.parent = readPointer(hatFile);
    newNode->params.expHidden.result = readPointer(hatFile);
    
    return newNode;
}
Ejemplo n.º 14
0
static TACommandVerdict crc32_cmd(TAThread thread,TAInputStream stream)
{
    uLong crc, res;
    uInt len;
    Bytef* buf;

    // Prepare
    crc = readULong(&stream);
    buf = readPointer(&stream);
    len = readUInt(&stream);

    START_TARGET_OPERATION(thread);

    res = crc32(crc, buf, len);

    END_TARGET_OPERATION(thread);

    if(buf==0)
        ta_debug_printf("res==%u\n", res);

    // Response
    writeULong(thread, res);

    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 15
0
static TACommandVerdict mvwhline_cmd(TAThread thread,TAInputStream stream)
{
    WINDOW *win;
    chtype ch;
    int n;
    int y;
    int x;
    int res;

    win = readPointer(&stream);
    y = readInt(&stream);
    x = readInt(&stream);
    ch = readChType(&stream);
    n = readInt(&stream);
    
    START_TARGET_OPERATION(thread);
    
    res = mvwhline(win, y, x, ch, n);
    
    END_TARGET_OPERATION(thread);
    
    writeInt(thread, res);
    sendResponse(thread);
    
    return taDefaultVerdict;
}
Ejemplo n.º 16
0
static TACommandVerdict gzputs_cmd(TAThread thread,TAInputStream stream)
{
    void* file;
    char* s;
    int res, errnum;

    file = readPointer(&stream);
    s = readString(&stream);

    START_TARGET_OPERATION(thread);

    res = gzputs(file, s);

    END_TARGET_OPERATION(thread);

    gzerror(file, &errnum);

    writeInt(thread, errnum);
    writeInt(thread, errno);
    writeInt(thread, res);

    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 17
0
void File::readHeader(File::Block& block) {
	block.code = readString(4);

	//clean the code of potential 0s at end
	string cleanCode = "";
	for(char c: block.code) {
		if(c != 0)
			cleanCode += c;
	}
	block.code = cleanCode;

	if(block.code != "ENDB") {
		block.size = read<unsigned int>();
		block.address = readPointer();
		block.SDNAIndex = read<unsigned int>();
		block.count = read<unsigned int>();
		block.offset = file.tellg();
	} else {
		block.size = read<unsigned int>();
		block.address = 0;
		block.SDNAIndex = 0;
		block.count = 0;
		block.offset = file.tellg();
	}
}
Ejemplo n.º 18
0
static TACommandVerdict iconv_close_cmd(TAThread thread, TAInputStream stream)
{
    iconv_t cd;
    int res;
    int save_errno;

    // Prepare
    cd = (iconv_t)readPointer(&stream);

	errno = 0;

    START_TARGET_OPERATION(thread);

    // Execute
    res = iconv_close(cd);
    save_errno = errno;

    END_TARGET_OPERATION(thread);

    // Response
    writeInt(thread, res);
    writeInt(thread, save_errno);
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 19
0
static TACommandVerdict confstr_cmd(TAThread thread,TAInputStream stream)
{
    int name;
    size_t res;
    char * buf;
    size_t len;

    /* Prepare */
    name = readInt(&stream);
    buf = (char*)readPointer(&stream);
    len = readSize(&stream);

    /* [ Set errno ] */
    errno = readInt(&stream);

    START_TARGET_OPERATION(thread);

    /* Execute */
    res = confstr(name,buf,len);

    END_TARGET_OPERATION(thread);

    /* Response */
    writeSize(thread, res);
    writeInt(thread, errno);

    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 20
0
static TACommandVerdict strndup_cmd(TAThread thread, TAInputStream stream)
{
    char* s;
    size_t n;
    char* res;

    // Prepare
    s = (char*)readPointer(&stream);
    n = readSize(&stream);
    
   START_TARGET_OPERATION(thread);

    // Execute
    errno = 0;
    res = strndup(s,n);

    END_TARGET_OPERATION(thread);
    // Execute

    // Response
    writePointer(thread, res);
    writeInt(thread, errno);
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 21
0
static TACommandVerdict read_fifo_cmd(TAThread thread,TAInputStream stream)
{
    int fildes;
    void* buf;
    size_t nbyte;

    ssize_t res;

    // Prepare
    fildes = readInt(&stream);
    buf    = readPointer(&stream);
    nbyte  = readSize(&stream);

    BEFORE_BLOCKED_TARGET_OPERATION(thread);

    writeString(thread,"Ok");
    sendResponse(thread);
    errno = 0;


    START_TARGET_OPERATION(thread);
    res = read(fildes, buf, nbyte);
    END_TARGET_OPERATION(thread);


    writeDeferredReaction(thread, "read_fifo_return");

    // Response
    writeSSize(thread, res);
    writeInt(thread, errno);
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 22
0
static TACommandVerdict pthread_rwlock_rdlock_cmd(TAThread thread, TAInputStream stream)
{
    pthread_rwlock_t* rwlock;
    int res;

    // Prepare
    rwlock = readPointer(&stream);

    BEFORE_BLOCKED_TARGET_OPERATION(thread);

    writeString(thread,"Ok");
    sendResponse(thread);

    START_TARGET_OPERATION(thread);

    // Execute
    res = pthread_rwlock_rdlock(rwlock);

    END_TARGET_OPERATION(thread);

    // Response
    writeDeferredReaction(thread,"pthread_rwlock_rdlock_return");
    writeInt(thread,res);
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 23
0
static TACommandVerdict pthread_rwlock_timedwrlock_bad_cmd(TAThread thread, TAInputStream stream)
{
    pthread_rwlock_t* rwlock;
    int               nsec;
    struct timespec   timeout;
    int res;

    // Prepare
    rwlock = readPointer(&stream);
    nsec   = readInt(&stream);

    timeout = thread->start_time;
    timeout.tv_sec += 2;
    timeout.tv_nsec = nsec;

    START_TARGET_OPERATION(thread);

    // Execute
    res = pthread_rwlock_timedwrlock(rwlock, &timeout);

    END_TARGET_OPERATION(thread);

    // Response
    writeInt(thread, res);
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 24
0
static TACommandVerdict pthread_rwlock_timedwrlock_cmd(TAThread thread, TAInputStream stream)
{
    pthread_rwlock_t* rwlock;
    TimeUnit          delta;
    struct timespec   timeout;
    int res;

    // Prepare
    rwlock  = readPointer(&stream);
    delta   = readTimeUnit(&stream);        // Reading the relative time

    BEFORE_BLOCKED_TARGET_OPERATION(thread);

    timeout = addTimeUnit(thread->start_time, delta);       // Get the absolute timeout value

    writeString(thread, "Ok");
    sendResponse(thread);

    START_TARGET_OPERATION(thread);

    // Execute
    res = pthread_rwlock_timedwrlock(rwlock, &timeout);

    END_TARGET_OPERATION(thread);

    // Response
    writeDeferredReaction(thread, "pthread_rwlock_timedwrlock_return");
    writeInt(thread, res);
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 25
0
static TACommandVerdict realloc_cmd(TAThread thread,TAInputStream stream)
{
    void* ptr;    
    size_t size;
    void* res;

    // Prepare
    ptr = readPointer(&stream);
    size = readSize(&stream);

    START_TARGET_OPERATION(thread);

    // Execute
    errno = 0;    
    res = realloc(ptr, size);

    END_TARGET_OPERATION(thread);

    // Response
    writePointer(thread, res);
    writeInt(thread, errno); 
    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 26
0
static TACommandVerdict gzseek_cmd(TAThread thread,TAInputStream stream)
{
    void* file;
    z_off_t offset, res;
    int errnum, whence;

    file = readPointer(&stream);
    offset = (off_t)readLLong(&stream);
    whence = readInt(&stream);

    START_TARGET_OPERATION(thread);

    res = gzseek(file, offset, whence);

    END_TARGET_OPERATION(thread);

    gzerror(file, &errnum);

    writeInt(thread, errnum);
    writeLLong(thread, (long long)res);

    sendResponse(thread);

    return taDefaultVerdict;
}
Ejemplo n.º 27
0
Archivo: animnode.c Proyecto: HJvT/hat
node* readExpDoStmt(FILE *hatFile, unsigned long offset)
{
    node *newNode = (node *)malloc(sizeof(node));
    char tag;
    
    newNode->nodeType = ExpDoStmt;
    newNode->offset = offset;
    
    setFilePos(hatFile, offset);
    tag = readByte(hatFile);
    if (newNode->params.expDoStmt.hasUse = hasSrcPos(tag))
    {
        newNode->params.expDoStmt.use = readPointer(hatFile);
    }
    newNode->params.expDoStmt.statement = readPointer(hatFile);
    
    return newNode;
}
Ejemplo n.º 28
0
Archivo: animnode.c Proyecto: HJvT/hat
node* readExpInteger(FILE *hatFile, unsigned long offset)
{
    node *newNode = (node *)malloc(sizeof(node));
    char tag;
    
    newNode->nodeType = ExpInteger;
    newNode->offset = offset;
    
    setFilePos(hatFile, offset);
    tag = readByte(hatFile);
    if (newNode->params.expInteger.hasUse = hasSrcPos(tag))
    {
        newNode->params.expInteger.use = readPointer(hatFile);
    }
    newNode->params.expInteger.parent = readPointer(hatFile);
    newNode->params.expInteger.value = readString(hatFile);
    
    return newNode;
}
Ejemplo n.º 29
0
TACommandVerdict fwreadFile_cmd( TAThread thread, TAInputStream stream ) {
    FILE * file     = (FILE *)readPointer( & stream );
    char * fileName =         readString ( & stream );
    char * fileMode =         readString ( & stream );
    wchar_t * result = fwreadFile( & file, fileName, fileMode );
    writeWString( thread, result );
    writePointer( thread, file   );
    sendResponse( thread );
    if ( result != NULL ) { ta_dealloc_memory( result ); }
    return taDefaultVerdict;
}
Ejemplo n.º 30
0
Archivo: animnode.c Proyecto: HJvT/hat
/**
* Attempt to read a value use expression type node at a certain offset.
 *
 * @param  hatFile The file to read the node from.
 * @param  offset  The offset where the start of the node should be.
 * @return A node construct containing the read values.
 */
node* readExpValueUse(FILE *hatFile, unsigned long offset)
{
    node *newNode = (node *)malloc(sizeof(node));
    char tag;
    
    newNode->nodeType = ExpValueUse;
    newNode->offset = offset;
    
    setFilePos(hatFile, offset);
    tag = readByte(hatFile);
    if (newNode->params.expValueUse.hasUse = hasSrcPos(tag))
    {
        newNode->params.expValueUse.use = readPointer(hatFile);
    }
    newNode->params.expValueUse.parent = readPointer(hatFile);
    newNode->params.expValueUse.value = readPointer(hatFile);
    newNode->params.expValueUse.isLambda = (newNode->params.expValueUse.value == 4);
    
    return newNode;
}