コード例 #1
0
ファイル: lsd.c プロジェクト: vperron/lsd
//  ---------------------------------------------------------------------
//  Publish file
void lsd_publish(lsd_handle_t* self, const char* filename) 
{
	char* short_name;
	char buffer[1024];
	char full_name[1024];
	char virtual_name[1024];

	assert(self);
	assert(filename);

	memset(buffer,0,sizeof(buffer));
	memset(virtual_name,0,sizeof(virtual_name));
	memset(full_name,0,sizeof(full_name));

	if(filename[0] != '/' && getcwd(buffer, sizeof(buffer)) != NULL) {
		snprintf(full_name, sizeof(full_name), "%s/%s", buffer, filename);
	} else {
		strncpy(full_name, filename, sizeof(full_name));
	}

	short_name = basename(full_name);
	snprintf(virtual_name, sizeof(virtual_name), "/%s", short_name);

	zre_node_publish (self->interface, full_name, virtual_name);
}
コード例 #2
0
ファイル: sender.c プロジェクト: JuanCerezuela/zyre
int main (int argc, char *argv [])
{
    if (argc < 2) {
        puts ("Syntax: sender filename virtualname");
        return 0;
    }
    printf ("Publishing %s as %s\n", argv [1], argv [2]);
    zre_node_t *node = zre_node_new ();
    zre_node_publish (node, argv [1], argv [2]);
    while (true) {
        zmsg_t *incoming = zre_node_recv (node);
        if (!incoming)
            break;
        zmsg_dump (incoming);
        zmsg_destroy (&incoming);
    }
    zre_node_destroy (&node);
    return 0;
}