• Main Page
  • Files
  • File List
  • File Members

/home/developer/harmattan/workspace/applauncherd-3.0.3+0m8/src/invoker/invokelib.c

Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (directui@nokia.com)
00006 **
00007 ** This file is part of applauncherd
00008 **
00009 ** If you have questions regarding the use of this file, please contact
00010 ** Nokia at directui@nokia.com.
00011 **
00012 ** This library is free software; you can redistribute it and/or
00013 ** modify it under the terms of the GNU Lesser General Public
00014 ** License version 2.1 as published by the Free Software Foundation
00015 ** and appearing in the file LICENSE.LGPL included in the packaging
00016 ** of this file.
00017 **
00018 ****************************************************************************/
00019 
00020 #include <stdint.h>
00021 #include <stdbool.h>
00022 #include <stdlib.h>
00023 #include <string.h>
00024 #include <unistd.h>
00025 
00026 #include "report.h"
00027 #include "invokelib.h"
00028 
00029 void invoke_send_msg(int fd, uint32_t msg)
00030 {
00031     debug("%s: %08x\n", __FUNCTION__, msg);
00032     write(fd, &msg, sizeof(msg));
00033 }
00034 
00035 bool invoke_recv_msg(int fd, uint32_t *msg)
00036 {
00037     uint32_t  readBuf = 0;
00038     int len = sizeof(readBuf);
00039     ssize_t numRead = read(fd, &readBuf, len);
00040 
00041     if (numRead == -1)
00042     {
00043         debug("%s: Error reading message: %s\n", __FUNCTION__, strerror(errno));
00044         *msg = 0;
00045         return false;
00046     }
00047     else if (numRead < len)
00048     {
00049         debug("%s: Error: unexpected end-of-file \n", __FUNCTION__);
00050         *msg = 0;
00051         return false;
00052     }
00053     else
00054     {
00055         debug("%s: %08x\n", __FUNCTION__, readBuf);
00056         *msg = readBuf;
00057         return true;
00058     }
00059 }
00060 
00061 void invoke_send_str(int fd, char *str)
00062 {
00063     if (str)
00064     {
00065         uint32_t size;
00066 
00067         /* Send size. */
00068         size = strlen(str) + 1;
00069         invoke_send_msg(fd, size);
00070 
00071         debug("%s: '%s'\n", __FUNCTION__, str);
00072 
00073         /* Send the string. */
00074         write(fd, str, size);
00075     }
00076 }
00077 

Generated on Sat Jan 17 2015 19:23:27 for applauncherd by  doxygen 1.7.1