コード例 #1
0
ファイル: mapfile.c プロジェクト: cdaffara/symbiandump-mw1
static Param
createmapfilehash()
{
    Param pm;
    HashTable ht;

    unsetparam(mapfile_nam);
    mapfile_pm = NULL;

    if (!(pm = createparam(mapfile_nam, PM_SPECIAL|PM_HIDE|PM_HIDEVAL|
			   PM_REMOVABLE|PM_HASHED)))
	return NULL;

    pm->level = pm->old ? locallevel : 0;
    pm->gsu.h = &mapfiles_gsu;
    pm->u.hash = ht = newhashtable(7, mapfile_nam, NULL);

    ht->hash        = hasher;
    ht->emptytable  = (TableFunc) shempty;
    ht->filltable   = NULL;
    ht->addnode     = (AddNodeFunc) shempty;
    ht->getnode     = ht->getnode2 = getpmmapfile;
    ht->removenode  = (RemoveNodeFunc) shempty;
    ht->disablenode = NULL;
    ht->enablenode  = NULL;
    ht->freenode    = (FreeNodeFunc) shempty;
    ht->printnode   = printparamnode;
    ht->scantab     = scanpmmapfile;

    return (mapfile_pm = pm);
}
コード例 #2
0
ファイル: tablestructure.c プロジェクト: pombredanne/Frontier
boolean tablenewtable (hdltablevariable *hvariable, hdlhashtable *htable) {
	
	/*
	create a new hashtable variable with an empty hashtable linked into it.
	*/
	
	register hdltablevariable hv;
	register hdlhashtable ht;
	
	if (!newtablevariable (true, 0L, hvariable, false))
		return (false);
	
	hv = *hvariable; /*copy into register*/
	
	if (!newhashtable (htable)) {
		
		disposehandle ((Handle) hv);
		
		return (false);
		}
	
	ht = *htable; /*copy into register*/
	
	(**ht).timecreated = (**ht).timelastsave = timenow (); // 5.0a23 dmb
	
	/*leave the hashtableformats record unallocated, handle == nil*/
	
	(**hv).variabledata = (long) ht; /*link the table into the variable rec*/
	
	(**ht).hashtablerefcon = (long) hv; /*the pointing is mutual*/
	
	(**ht).fldirty = true; /*it's never been saved*/
	
	return (true);
	} /*tablenewtable*/
コード例 #3
0
ファイル: hashtable.c プロジェクト: prabirshrestha/winzsh
void
createreswdtable(void)
{
    Reswd rw;

    reswdtab = newhashtable(23);

    reswdtab->hash        = hasher;
    reswdtab->emptytable  = NULL;
    reswdtab->filltable   = NULL;
    reswdtab->addnode     = addhashnode;
    reswdtab->getnode     = gethashnode;
    reswdtab->getnode2    = gethashnode2;
    reswdtab->removenode  = NULL;
    reswdtab->disablenode = disablehashnode;
    reswdtab->enablenode  = enablehashnode;
    reswdtab->freenode    = NULL;
    reswdtab->printnode   = printreswdnode;
#ifdef ZSH_HASH_DEBUG
    reswdtab->printinfo   = printhashtabinfo;
    reswdtab->tablename   = ztrdup("reswdtab");
#endif

    for (rw = reswds; rw->nam; rw++)
	reswdtab->addnode(reswdtab, rw->nam, rw);
}
コード例 #4
0
ファイル: hashtable.c プロジェクト: prabirshrestha/winzsh
void
createaliastable(void)
{
    aliastab = newhashtable(23);

    aliastab->hash        = hasher;
    aliastab->emptytable  = NULL;
    aliastab->filltable   = NULL;
    aliastab->addnode     = addhashnode;
    aliastab->getnode     = gethashnode;
    aliastab->getnode2    = gethashnode2;
    aliastab->removenode  = removehashnode;
    aliastab->disablenode = disablehashnode;
    aliastab->enablenode  = enablehashnode;
    aliastab->freenode    = freealiasnode;
    aliastab->printnode   = printaliasnode;
#ifdef ZSH_HASH_DEBUG
    aliastab->printinfo   = printhashtabinfo;
    aliastab->tablename   = ztrdup("aliastab");
#endif

    /* add the default aliases */
    aliastab->addnode(aliastab, ztrdup("run-help"), createaliasnode(ztrdup("man"), 0));
    aliastab->addnode(aliastab, ztrdup("which-command"), createaliasnode(ztrdup("whence"), 0));
}
コード例 #5
0
ファイル: hashtable.c プロジェクト: prabirshrestha/winzsh
void
createbuiltintable(void)
{
    Builtin bn;

    builtintab = newhashtable(85);

    builtintab->hash        = hasher;
    builtintab->emptytable  = NULL;
    builtintab->filltable   = NULL;
    builtintab->addnode     = addhashnode;
    builtintab->getnode     = gethashnode;
    builtintab->getnode2    = gethashnode2;
    builtintab->removenode  = NULL;
    builtintab->disablenode = disablehashnode;
    builtintab->enablenode  = enablehashnode;
    builtintab->freenode    = NULL;
    builtintab->printnode   = printbuiltinnode;
#ifdef ZSH_HASH_DEBUG
    builtintab->printinfo   = printhashtabinfo;
    builtintab->tablename   = ztrdup("builtintab");
#endif

    for (bn = builtins; bn->nam; bn++)
	builtintab->addnode(builtintab, bn->nam, bn);
}
コード例 #6
0
ファイル: claycallbacks.c プロジェクト: pombredanne/Frontier
boolean claygetspecialfolder (void *foldername, boolean flcreate, tybrowserspec *fsspecialfolder) {

	/*
	a bottleneck for finding special Clay Basket folders. it actually works
	for files too -- it's used to locate the preferences file.
	
	if flcreate is true, and the folder doesn't exist, we create it.
	
	DW 3/12/95: Add another level, the Clay Basket folder is contained within
	the UserLand folder.
	*/
	
	#if filebrowser
		tybrowserspec fsuserland, fsfolder;
		
		if (!filegetprefsspec (BIGSTRING ("\x08" "UserLand"), &fsuserland)) 
			return (false);
			
		if (!clayfileexists (&fsuserland, &flfolder)) {
			
			if (!filecreatefolder (&fsuserland))
				return (false);
			}
		
		if (!claygetsubitemspec (&fsuserland, BIGSTRING ("\x12" "Clay Basket Folder"), &fsfolder))
			return (false);
			
		if (!clayfileexists (&fsfolder, &flfolder)) { 
		
			if (!filecreatefolder (&fsfolder))
				return (false);
			}
		
		if (!claygetsubitemspec (&fsfolder, foldername, fsspecialfolder))
			return (false);
	#endif

	#if odbbrowser
		static hdlhashtable hclaybaskettable = nil;
		
		if (hclaybaskettable == nil) { // first time called
			
			if (!newhashtable (&hclaybaskettable))
				return (false);
			}

		claymakespec (nil, hclaybaskettable, foldername, fsspecialfolder);
	#endif
	
	if (!flcreate)
		return (true);
		
	if (!clayfileexists (fsspecialfolder, &flfolder)) /*doesn't exist*/
		return (filecreatefolder (fsspecialfolder));
		
	return (true);
	} /*claygetspecialfolder*/
コード例 #7
0
ファイル: hashtable.c プロジェクト: cdaffara/symbiandump-mw1
void
createaliastables(void)
{
    /* Table for regular and global aliases */

    aliastab = newhashtable(23, "aliastab", NULL);

    createaliastable(aliastab);

    /* add the default aliases */
    aliastab->addnode(aliastab, ztrdup("run-help"), createaliasnode(ztrdup("man"), 0));
    aliastab->addnode(aliastab, ztrdup("which-command"), createaliasnode(ztrdup("whence"), 0));


    /* Table for suffix aliases --- make this smaller */

    sufaliastab = newhashtable(11, "sufaliastab", NULL);

    createaliastable(sufaliastab);
}
コード例 #8
0
ファイル: rtp_server.c プロジェクト: passoir/rtsp_rtp_server
int initialize_rtp_globals() {
    int i;
    int st;
    srand(time(0));
    /* Initialize globals */
    n_workers = 0;
    workers_hash = 0;
    sockfd = -1;

    main_pid = getpid();

    /* Intialize workers array */
    for (i = 0; i < MAX_RTP_WORKERS; ++i)
        workers[i]->used = 0;

    signal(SIGINT, rtp_server_stop);
    signal(SIGUSR1, rtp_worker_stop_eos);

    /* Initialize message queue */
    msg_queue = msgget(MSG_IDENTIFIER/*TODO: Don't hardcode this */, IPC_CREAT /*| IPC_EXCL */| 0700);
    if (msg_queue == -1)
        return(0);
    /* Initialize hash table */
    workers_hash = newhashtable(longhash, longequal, MAX_RTP_WORKERS * 2, 1);
    if (!workers_hash) {
        msgctl(msg_queue, IPC_RMID, 0);
        return(0);
    }

    /* Initialize hash table mutex */
    if (pthread_mutex_init(&workers_mutex, 0)) {
        msgctl(msg_queue, IPC_RMID, 0);
        clearhashtable(&workers_hash);
        freehashtable(&workers_hash);
        return(0);
    }
    if (pthread_mutex_init(&play_state_mutex, 0)) {
        pthread_mutex_destroy(&workers_mutex);
        msgctl(msg_queue, IPC_RMID, 0);
        clearhashtable(&workers_hash);
        freehashtable(&workers_hash);
        return(0);
    }


    /* Create thread that checks idle workers */
    st = pthread_create(&worker_comm, 0, worker_comm_fun, 0);
    if (st)
        kill(getpid(), SIGINT);


    return(1);
}
コード例 #9
0
ファイル: zle_thingy.c プロジェクト: AMDmi3/zsh
static void
createthingytab(void)
{
    thingytab = newhashtable(199, "thingytab", NULL);

    thingytab->hash        = hasher;
    thingytab->emptytable  = emptythingytab;
    thingytab->filltable   = NULL;
    thingytab->cmpnodes    = strcmp;
    thingytab->addnode     = addhashnode;
    thingytab->getnode     = gethashnode;
    thingytab->getnode2    = gethashnode2;
    thingytab->removenode  = removehashnode;
    thingytab->disablenode = NULL;
    thingytab->enablenode  = NULL;
    thingytab->freenode    = freethingynode;
    thingytab->printnode   = NULL;
}
コード例 #10
0
ファイル: hashtable.c プロジェクト: cdaffara/symbiandump-mw1
void
createshfunctable(void)
{
    shfunctab = newhashtable(7, "shfunctab", NULL);

    shfunctab->hash        = hasher;
    shfunctab->emptytable  = NULL;
    shfunctab->filltable   = NULL;
    shfunctab->cmpnodes    = strcmp;
    shfunctab->addnode     = addhashnode;
    shfunctab->getnode     = gethashnode;
    shfunctab->getnode2    = gethashnode2;
    shfunctab->removenode  = removeshfuncnode;
    shfunctab->disablenode = disableshfuncnode;
    shfunctab->enablenode  = enableshfuncnode;
    shfunctab->freenode    = freeshfuncnode;
    shfunctab->printnode   = printshfuncnode;
}
コード例 #11
0
ファイル: hashtable.c プロジェクト: cdaffara/symbiandump-mw1
void
createhisttable(void)
{
    histtab = newhashtable(599, "histtab", NULL);

    histtab->hash        = histhasher;
    histtab->emptytable  = emptyhisttable;
    histtab->filltable   = NULL;
    histtab->cmpnodes    = histstrcmp;
    histtab->addnode     = addhistnode;
    histtab->getnode     = gethashnode2;
    histtab->getnode2    = gethashnode2;
    histtab->removenode  = removehashnode;
    histtab->disablenode = NULL;
    histtab->enablenode  = NULL;
    histtab->freenode    = freehistnode;
    histtab->printnode   = NULL;
}
コード例 #12
0
ファイル: hashtable.c プロジェクト: cdaffara/symbiandump-mw1
void
createcmdnamtable(void)
{
    cmdnamtab = newhashtable(201, "cmdnamtab", NULL);

    cmdnamtab->hash        = hasher;
    cmdnamtab->emptytable  = emptycmdnamtable;
    cmdnamtab->filltable   = fillcmdnamtable;
    cmdnamtab->cmpnodes    = strcmp;
    cmdnamtab->addnode     = addhashnode;
    cmdnamtab->getnode     = gethashnode2;
    cmdnamtab->getnode2    = gethashnode2;
    cmdnamtab->removenode  = removehashnode;
    cmdnamtab->disablenode = NULL;
    cmdnamtab->enablenode  = NULL;
    cmdnamtab->freenode    = freecmdnamnode;
    cmdnamtab->printnode   = printcmdnamnode;

    pathchecked = path;
}
コード例 #13
0
ファイル: hashtable.c プロジェクト: cdaffara/symbiandump-mw1
void
createnameddirtable(void)
{
    nameddirtab = newhashtable(201, "nameddirtab", NULL);

    nameddirtab->hash        = hasher;
    nameddirtab->emptytable  = emptynameddirtable;
    nameddirtab->filltable   = fillnameddirtable;
    nameddirtab->cmpnodes    = strcmp;
    nameddirtab->addnode     = addnameddirnode;
    nameddirtab->getnode     = gethashnode;
    nameddirtab->getnode2    = gethashnode2;
    nameddirtab->removenode  = removenameddirnode;
    nameddirtab->disablenode = NULL;
    nameddirtab->enablenode  = NULL;
    nameddirtab->freenode    = freenameddirnode;
    nameddirtab->printnode   = printnameddirnode;

    allusersadded = 0;
    finddir(NULL);		/* clear the finddir cache */
}
コード例 #14
0
ファイル: hashtable.c プロジェクト: prabirshrestha/winzsh
void
createcompctltable(void)
{
    compctltab = newhashtable(23);

    compctltab->hash        = hasher;
    compctltab->emptytable  = NULL;
    compctltab->filltable   = NULL;
    compctltab->addnode     = addhashnode;
    compctltab->getnode     = gethashnode2;
    compctltab->getnode2    = gethashnode2;
    compctltab->removenode  = removehashnode;
    compctltab->disablenode = NULL;
    compctltab->enablenode  = NULL;
    compctltab->freenode    = freecompctlp;
    compctltab->printnode   = printcompctlp;
#ifdef ZSH_HASH_DEBUG
    compctltab->printinfo   = printhashtabinfo;
    compctltab->tablename   = ztrdup("compctltab");
#endif
}
コード例 #15
0
ファイル: hashtable.c プロジェクト: prabirshrestha/winzsh
void
createshfunctable(void)
{
    shfunctab = newhashtable(7);

    shfunctab->hash        = hasher;
    shfunctab->emptytable  = NULL;
    shfunctab->filltable   = NULL;
    shfunctab->addnode     = addhashnode;
    shfunctab->getnode     = gethashnode;
    shfunctab->getnode2    = gethashnode2;
    shfunctab->removenode  = removeshfuncnode;
    shfunctab->disablenode = disableshfuncnode;
    shfunctab->enablenode  = enableshfuncnode;
    shfunctab->freenode    = freeshfuncnode;
    shfunctab->printnode   = printshfuncnode;
#ifdef ZSH_HASH_DEBUG
    shfunctab->printinfo   = printhashtabinfo;
    shfunctab->tablename   = ztrdup("shfunctab");
#endif
}
コード例 #16
0
ファイル: hashtable.c プロジェクト: prabirshrestha/winzsh
void
createvikeybindtable(void)
{
    vikeybindtab = newhashtable(INITIAL_VIKEYBINDTAB);

    vikeybindtab->hash        = hasher;
    vikeybindtab->emptytable  = emptyvikeybindtable;
    vikeybindtab->filltable   = NULL;
    vikeybindtab->addnode     = addhashnode;
    vikeybindtab->getnode     = gethashnode2;
    vikeybindtab->getnode2    = gethashnode2;
    vikeybindtab->removenode  = removehashnode;
    vikeybindtab->disablenode = NULL;
    vikeybindtab->enablenode  = NULL;
    vikeybindtab->freenode    = freekeynode;

    /* need to combine printbinding and printfuncbinding for this */
    vikeybindtab->printnode   = NULL;
#ifdef ZSH_HASH_DEBUG
    vikeybindtab->printinfo   = printhashtabinfo;
    vikeybindtab->tablename   = ztrdup("vikeybindtab");
#endif
}
コード例 #17
0
ファイル: options.c プロジェクト: koreden/oh-my-zsh
void
createoptiontable(void)
{
    Optname on;

    optiontab = newhashtable(101, "optiontab", NULL);

    optiontab->hash        = hasher;
    optiontab->emptytable  = NULL;
    optiontab->filltable   = NULL;
    optiontab->cmpnodes    = strcmp;
    optiontab->addnode     = addhashnode;
    optiontab->getnode     = gethashnode;
    optiontab->getnode2    = gethashnode2;
    optiontab->removenode  = NULL;
    optiontab->disablenode = disablehashnode;
    optiontab->enablenode  = enablehashnode;
    optiontab->freenode    = NULL;
    optiontab->printnode   = printoptionnode;

    for (on = optns; on->node.nam; on++)
	optiontab->addnode(optiontab, on->node.nam, on);
}
コード例 #18
0
ファイル: hashtable.c プロジェクト: cdaffara/symbiandump-mw1
void
createreswdtable(void)
{
    Reswd rw;

    reswdtab = newhashtable(23, "reswdtab", NULL);

    reswdtab->hash        = hasher;
    reswdtab->emptytable  = NULL;
    reswdtab->filltable   = NULL;
    reswdtab->cmpnodes    = strcmp;
    reswdtab->addnode     = addhashnode;
    reswdtab->getnode     = gethashnode;
    reswdtab->getnode2    = gethashnode2;
    reswdtab->removenode  = NULL;
    reswdtab->disablenode = disablehashnode;
    reswdtab->enablenode  = enablehashnode;
    reswdtab->freenode    = NULL;
    reswdtab->printnode   = printreswdnode;

    for (rw = reswds; rw->nam; rw++)
	reswdtab->addnode(reswdtab, rw->nam, rw);
}
コード例 #19
0
ファイル: hashtable.c プロジェクト: prabirshrestha/winzsh
void
createcmdnamtable(void)
{
    cmdnamtab = newhashtable(INITIAL_CMDNAMTAB);

    cmdnamtab->hash        = hasher;
    cmdnamtab->emptytable  = emptycmdnamtable;
    cmdnamtab->filltable   = fillcmdnamtable;
    cmdnamtab->addnode     = addhashnode;
    cmdnamtab->getnode     = gethashnode2;
    cmdnamtab->getnode2    = gethashnode2;
    cmdnamtab->removenode  = removehashnode;
    cmdnamtab->disablenode = NULL;
    cmdnamtab->enablenode  = NULL;
    cmdnamtab->freenode    = freecmdnamnode;
    cmdnamtab->printnode   = printcmdnamnode;
#ifdef ZSH_HASH_DEBUG
    cmdnamtab->printinfo   = printhashtabinfo;
    cmdnamtab->tablename   = ztrdup("cmdnamtab");
#endif

    pathchecked = path;
}
コード例 #20
0
ファイル: hashtable.c プロジェクト: prabirshrestha/winzsh
void
createnameddirtable(void)
{
    nameddirtab = newhashtable(INITIAL_NAMEDDIR);

    nameddirtab->hash        = hasher;
    nameddirtab->emptytable  = emptynameddirtable;
    nameddirtab->filltable   = fillnameddirtable;
    nameddirtab->addnode     = addnameddirnode;
    nameddirtab->getnode     = gethashnode;
    nameddirtab->getnode2    = gethashnode2;
    nameddirtab->removenode  = removenameddirnode;
    nameddirtab->disablenode = NULL;
    nameddirtab->enablenode  = NULL;
    nameddirtab->freenode    = freenameddirnode;
    nameddirtab->printnode   = printnameddirnode;
#ifdef ZSH_HASH_DEBUG
    nameddirtab->printinfo   = printhashtabinfo;
    nameddirtab->tablename   = ztrdup("nameddirtab");
#endif

    allusersadded = 0;
    finddir(NULL);		/* clear the finddir cache */
}
コード例 #21
0
ファイル: tablepack.c プロジェクト: dvincent/frontier
boolean tableunpacktable (Handle hpacked, boolean flmemory, hdlhashtable *htable) {
	
	/*
	9/24/91 dmb: don't treat format unpacking failure as a fatal error.
	
	10/16/91 dmb: clear table's dirty bit after unpacking.
	
	3.0.4b8 dmb: use scratchport for the duration; port is unknown
	
	4.0b7 dmb: don't set scratchport while unpacking the table; too many
	nested pushports result. Just set it when we care, and leave each table
	entry to fend for itself.
	
	5.0a23 dmb: don't create table formats if none are packed
	
	5.0a25 dmb: don't clear table's fldirty flag anymore.
	*/
	
	Handle hpackedtable = nil;
	Handle hpackedformats = nil;
	hdlhashtable ht = nil;
	hdltableformats hformats = nil;
	
	if (!unmergehandles (hpacked, &hpackedtable, &hpackedformats)) /*comsumes hpacked*/
		return (false);
	
	if (!newhashtable (htable)) {
		
		disposehandle (hpackedtable);
		
		goto error; /*will dispose of everything but hpackedtable*/
		}
	
	ht = *htable; /*move into register*/
	
	if (!hashunpacktable (hpackedtable, flmemory, ht)) /*always disposes of hpackedtable*/
		goto error;
	
	if (hpackedformats != nil) {
	
		if (!newtableformats (&hformats))
			goto error;
		
		tablelinkformats (ht, hformats);
		
		pushscratchport ();
		
		if (!tableunpackformats (hpackedformats, hformats)) {
			
		//	tablesetdimension (hformats, false, 0, fixedctcols);
			}
		
		popport ();
		
		disposehandle (hpackedformats);
		
		if ((**hformats).fldirty) /*formats were out of date*/
			(**ht).fldirty = true;
		}
	
	return (true);
	
	error: {
		
		disposehandle (hpackedformats);
		
		disposetableformats (hformats);
		
		disposehashtable (ht, false);
		
		return (false);
		}
	} /*tableunpacktable*/