示例#1
0
文件: archive.c 项目: mstorsjo/vlc
static int archive_extractor_reset( stream_extractor_t* p_extractor )
{
    private_sys_t* p_sys = p_extractor->p_sys;

    if( vlc_stream_Seek( p_extractor->source, 0 )
        || archive_clean( p_sys )
        || archive_init( p_sys, p_extractor->source )
        || archive_seek_subentry( p_sys, p_extractor->identifier ) )
    {
        p_sys->b_dead = true;
        return VLC_EGENERIC;
    }

    p_sys->i_offset = 0;
    p_sys->b_eof = false;
    p_sys->b_dead = false;
    return VLC_SUCCESS;
}
示例#2
0
文件: archive.c 项目: mstorsjo/vlc
static private_sys_t* CommonOpen( vlc_object_t* p_obj, stream_t* source  )
{
    if( probe( source ) )
        return NULL;

    private_sys_t* p_sys = setup( p_obj, source );

    if( p_sys == NULL )
        return NULL;

    if( archive_init( p_sys, source ) )
    {
        CommonClose( p_sys );
        return NULL;
    }

    return p_sys;
}
示例#3
0
文件: archive.c 项目: Ivan1234/qemacs
static int archive_compress_init(void)
{
    return archive_init() || compress_init() || wget_init();
}
示例#4
0
centernode_t * centernode_init (const char *progname, const char *cfgfile)
{
    char filename[100];

    centernode_t *cn = (centernode_t *) calloc(sizeof(centernode_t), sizeof(char));
    if (!cn) abort();

    //Initialize the global mutex.
    pthread_mutex_init(&cn->seqlock, 0);
    pthread_mutex_init(&cn->objlock, 0);
    pthread_mutex_init(&cn->reglock, 0);
    pthread_mutex_init(&cn->evtlock, 0);
    pthread_mutex_init(&cn->glock, 0);
    pthread_mutex_init(&cn->sqllock, 0);

    //Initialiaze and load the config file.
    cn->config = calloc(sizeof(config_t), sizeof(char));
    if (!cn->config) abort();
    config_init(cn->config); /* initialize configuration */
    if (!config_read_file(cn->config, cfgfile)) {
#ifdef CDNDEBUG
        fprintf(stderr, "%s.\n", config_error_text(cn->config));
#endif
        return (free(cn), NULL);
    }
    if (centernode_config(cn))  /* load config */
        return NULL;
    strncpy(cn->confile, cfgfile, sizeof(cn->confile) -1);
    if (archive_init(cn->homepath, progname, ATASR|ATLOG, (cbsink_t)NULL, cn))
        return NULL; /* archive module */
    /*    
          if (mysqldb_init(cn->dbhost, cn->dbname, cn->dbuser, cn->dbpasswd)) // db 
          return (centernode_cleanup(cn), NULL);
          */  
    mongoc_init ();
    cn->MongoNum = cn->threads;
    cn->Mongo = (struct Mongo*)calloc (sizeof(struct Mongo)*cn->MongoNum, sizeof(char));
    int i = 0;
    for (i=0; i<cn->MongoNum; i++) {
        cn->Mongo[i].MongoClient = mongoc_client_new (cn->mongoString);
        cn->Mongo[i].MongoCollection = mongoc_client_get_collection (cn->Mongo[i].MongoClient, "mydb", "mycoll");
        pthread_mutex_init (&cn->Mongo[i].MongoLock, 0);
        if (cn->Mongo[i].MongoClient == NULL )
            abort();
    }
    cn->rdb_conn = (redisContext *) redisConnect(cn->rdb_host, cn->rdb_port);//, cn->rdb_pswd);
    printf("init cn %p rdb %p\n", cn, cn->rdb_conn);
    if (cn->rdb_conn == NULL)
    {
        LOG("WR", "Conn redis er\n");
        abort();
        return NULL;
    }
    pthread_mutex_init (&cn->rdb_lk, 0);
    redis_get_udpinfo(cn, (char **)&cn->udp_addr, &cn->udp_port);


    //Allocate management object
    cn->accesses = gdsl_hash_alloc(NULL, NULL, NULL, (gdsl_key_func_t)keyHash,
            (gdsl_hash_func_t)hashHash, (gdsl_hash_comp_t)compHash, 20000);
    cn->events = gdsl_queue_alloc(NULL, NULL, NULL);
    cn->registration = gdsl_queue_alloc(NULL, NULL, NULL);
    cn->oemconfig_lt = gdsl_list_alloc(NULL, NULL, NULL);
    cn->service_lt = gdsl_list_alloc(NULL,NULL,NULL);

    if (!(cn->tpool = threadpool_init(cn->threads, 4))) 
        return NULL;

    cn->rdbInterval = 0;
    cn->rdbLastNull = time(NULL);
    cn->rdbStatus   = 0;
    //Bind the network interface.
    cnaccess_t *ca = NULL;
    //Connect management server
    for (i=0; i<cn->local_num; ++i) 
    { /* Bind the network devices */
        ca = centernode_server(cn, cn->local[i].host, cn->local[i].port, NT_INETSRV, cn->local[i].isp);
        if (!ca) 
        {    
            return NULL;
        }    
    }  

#if 0
    if ((cn->isservice & 0x02) > 0) {
        for( i=0; i<cn->service_num; ++i )
        {
            ca = centernode_connect(cn, cn->service[i].host, cn->service[i].port, 0, NT_SERVICE_CLIENT, 0);
            if( ca )
            {
                centernode_cmd_service_startup(cn, ca,NULL,i);
                //break;
            }
        }
        if( !ca )
            return (centernode_cleanup(cn), NULL);    
    }
#endif
    sprintf(filename, "%s/%s.pid", cn->homepath, progname);
    FILE *fp = fopen(filename, "w+"); /* version number */
    assert(fp && fprintf(fp, "%u", getpid()) > 0);
    fclose(fp);

    kill(getpid(), SIGUSR1);
#ifdef CDNDEBUG
    LOG("WR", "Service CCN %s startup.\n", cn->nodeid);
#endif

    //if (appinit(cn) != 0)
    //return (centernode_cleanup(cn), NULL);
    return cn;
}