Пример #1
0
int main()
{
	sayhello();
	greet();

	return 0;
}
Пример #2
0
int hello_service_handler(struct binder_state *bs,
                   struct binder_transaction_data *txn,
                   struct binder_io *msg,
                   struct binder_io *reply)
{
	/* 根据txn->code知道要调用哪一个函数
	 * 如果需要参数, 可以从msg取出
	 * 如果要返回结果, 可以把结果放入reply
	 */

	/* sayhello
	 * sayhello_to
	 */
	 
    uint16_t *s;
	char name[512];
    size_t len;
    uint32_t handle;
    uint32_t strict_policy;
	int i;

    // Equivalent to Parcel::enforceInterface(), reading the RPC
    // header with the strict mode policy mask and the interface name.
    // Note that we ignore the strict_policy and don't propagate it
    // further (since we do no outbound RPCs anyway).
    strict_policy = bio_get_uint32(msg);

    switch(txn->code) {
    case HELLO_SVR_CMD_SAYHELLO:
		sayhello();
		return 0;
		
    case HELLO_SVR_CMD_SAYHELLO_TO:
		/* 从msg里取出字符串 */
		s = bio_get_string16(msg, &len);
		if (s == NULL) {
        	return -1;
    	}
		for(i=0; i<len; i++)
			name[i] = s[i];
		name[i] = '\0';

		/* 处理 */
      	i = sayhello_to(name);

		/* 把结果放入reply */
		bio_put_uint32(reply, i);
		
		break;
		
    default:
        fprintf(stderr, "unknown code %d\n", txn->code);
        return -1;
    }

    return 0;
}
Пример #3
0
int main(int argc, string argv[])
{
    printf("Please enter your name: ");
    string yourName = GetString();

    // TODO
    // this function isn't defined yet!!
    sayhello(yourName);

    int y = 5
    int ans = add(y);
    printf("ans = %i\n", ans);

    return 0;
}
Пример #4
0
static PyObject *
hw_sayhello(PyObject *self, PyObject *args)
{
  PyObject *py_comm = NULL;
  MPI_Comm *comm_p  = NULL;

  if (!PyArg_ParseTuple(args, "O:sayhello", &py_comm))
    return NULL;

  comm_p = PyMPIComm_Get(py_comm);
  if (comm_p == NULL)
    return NULL;

  sayhello(*comm_p);

  Py_INCREF(Py_None);
  return Py_None;
}
Пример #5
0
/* ./test_client hello
*  ./test_client hello <name>
*/
int main(int argc, char **argv)
{
    int fd;
    struct binder_state *bs;
    uint32_t svcmgr = BINDER_SERVICE_MANAGER;
    uint32_t handle;
	int ret;

	if(argc < 2){
		fprintf(stderr, "Usage:\n");
		fprintf(stderr, "%s <hello|goodbye>\n", argv[0]);
		fprintf(stderr, "%s <hello|goodbye> <name>\n", argv[0]);
		return -1;
	}

    bs = binder_open(128*1024);
    if (!bs) {
        fprintf(stderr, "failed to open binder driver\n");
        return -1;
    }
	g_bs = bs;

	handle = svcmgr_lookup(bs, svcmgr, "goodbye");
	if(!handle){
		fprintf(stderr, "failed to get goodbye service\n");
        return -1;
	}
	g_goodbye_handle = handle;
	fprintf(stderr, "Handle for goodbye service = %d\n", g_goodbye_handle);

	/* get service */
	handle = svcmgr_lookup(bs, svcmgr, "hello");
	if(!handle){
		fprintf(stderr, "failed to get hello service\n");
        return -1;
	}
	g_hello_handle = handle;
	fprintf(stderr, "Handle for hello service = %d\n", g_hello_handle);
	
	/* send data to server */
	if(!strcmp(argv[1], "hello"))
	{	
		if(argc == 2){
				sayhello();
			}else if(argc == 3){
				ret = sayhello_to(argv[2]);
				fprintf(stderr, "get ret of sayhello_to = %d\n",ret);
			}
	}
	else if(!strcmp(argv[1], "goodbye"))
	{	
		if(argc == 2){
				saygoodbye();
			}else if(argc == 3){
				ret = saygoodbye_to(argv[2]);
				fprintf(stderr, "get ret of saygoodbye_to = %d\n",ret);
			}
	}
	
	binder_release(bs, handle);
    return 0;
}
Пример #6
0
int main(void) {
	sayhello();

	return 0;
}
Пример #7
0
int main(char *argc[], int argv)
{
	char *buf = malloc(1024);
	printf("%s", sayhello(buf, 1024, "world"));
}
Пример #8
0
int main ( int argc, char *argv[] )
{
	sayhello();
	return(0);
}