Exemplo n.º 1
0
static char *
PrefOptCompletionFunction(const char *text, int state)
{
	char *cp;
	size_t textlen;
	int i, matches;

	if (state >= gNumPrefOpts)
		return (NULL);

	textlen = strlen(text);
	if (textlen == 0) {
		cp = StrDup(gPrefOpts[state].varname);
	} else {
		cp = NULL;
		for (i=0, matches=0; i<gNumPrefOpts; i++) {
			if (ISTRNCMP(gPrefOpts[i].varname, text, textlen) == 0) {
				if (matches >= state) {
					cp = StrDup(gPrefOpts[i].varname);
					break;
				}
				matches++;
			}
		}
	}
	return cp;
}	/* PrefOptCompletionFunction */
Exemplo n.º 2
0
PZNPACTORDATA ZnpActorMakeData(char* dataName, BYTE nDataType, void* data, BYTE dataLen)
{
	if (dataName == NULL)
		return NULL;
	PZNPACTORDATA pData = malloc(sizeof(ZNPACTORDATA));
	pData->dataName = StrDup(dataName);
	pData->nDataType = nDataType;
	switch (nDataType)
	{
	case ZNP_DATA_TYPE_STRING:
		pData->value = (void*)StrDup((char*)data);
		break;
	case ZNP_DATA_TYPE_INTERGER:
		pData->value = malloc(sizeof(int));
		memset(pData->value, 0, sizeof(int));
		CopyMemory(pData->value, data, dataLen);
		break;
	case ZNP_DATA_TYPE_FLOAT:
		pData->value = malloc(sizeof(double));
		memset(pData->value, 0, sizeof(double));
		CopyMemory(pData->value, data, dataLen);
		break;
	default:
		free(pData->dataName);
		free(pData);
		return NULL;
	}
	return pData;
}
Exemplo n.º 3
0
static	void
_CheckDBG(
	char		*name,
	DBG_Struct	*dbg,
	char		*red_name)
{
	DBG_Struct	*red_dbg;
	char *src_port, *dsc_port;
	char *dbg_dbname = "", *red_dbg_dbname = "";
	char	*dbname;
ENTER_FUNC;		
	if		(  dbg->redirect  !=  NULL  ) {
		red_dbg = dbg->redirect;
		if ( strcmp(red_dbg->name, red_name ) == 0 ){
			src_port = StrDup(StringPort(GetDB_Port(dbg,DB_UPDATE)));
			dsc_port = StrDup(StringPort(GetDB_Port(red_dbg,DB_UPDATE)));
			if		(  ( dbname = GetDB_DBname(dbg,DB_UPDATE) )  !=  NULL  ) {
				dbg_dbname = dbname;
			}
			if		(  ( dbname = GetDB_DBname(red_dbg,DB_UPDATE) )  !=  NULL  ) {
				red_dbg_dbname = dbname;
			}
			if ( ( strcmp(dbg->type, red_dbg->type ) == 0 )
				 && ( strcmp(dbg_dbname, red_dbg_dbname ) == 0 )
				 && ( strcmp(src_port, dsc_port) == 0 ) ) {
				Error("The connection destination is same DB");
			}
			xfree(src_port);
			xfree(dsc_port);
		}
	}
LEAVE_FUNC;
}
Exemplo n.º 4
0
void SetDefaultName( CTEXTSTR path, CTEXTSTR name, CTEXTSTR extra )
{
	TEXTCHAR *newpath;
	size_t len;
	static CTEXTSTR filepath;// = GetProgramPath();
	static CTEXTSTR filename;// = GetProgramName();
	if( path )
	{
		if( filepath )
         Release( (POINTER)filepath );
		filepath = StrDup( path );
	}
	if( name )
	{
		if( filename )
			Release( (POINTER)filename );
		filename = StrDup( name );
	}
	if( !filepath )
		filepath = ExpandPath( WIDE("*/") );
	if( !filename )
		filename = StrDup( GetProgramName() );
	if( !filename )
      filename = "org.d3x0r.sack";
	// this has to come from C heap.. my init isn't done yet probably and
   // sharemem will just fai(*syslog_local).  (it's probably trying to log... )
	newpath = (TEXTCHAR*)malloc( len = sizeof(TEXTCHAR)*(9 + StrLen( filepath ) + StrLen( filename ) + (extra?StrLen(extra):0) + 5) );
#ifdef __cplusplus_cli
	tnprintf( newpath, len, WIDE("%s/%s%s.cli.log"), filepath, filename, extra?extra:WIDE("") );
#else
	tnprintf( newpath, len, WIDE("%s/%s%s.log"), filepath, filename, extra?extra:WIDE("") );
#endif
	gFilename = newpath;//( newpath ); // use the C heap.
	//free( newpath ); // get rid of this ...
}
Exemplo n.º 5
0
int 
HeadData::set_attr(const char *attrName, const char *attrValue)
{
    HeadDataNode *it;

    assert(attrName != NULL && attrValue != NULL);

    for(it = head; it != NULL; it = it->next){
        if(strcmp(attrName, it->attrName) == 0)
            break;
    }

    if(it != NULL){
        delete[] it->attrValue;
        it->attrValue = StrDup(attrValue);
        return 0;
    }else{
        it = new HeadDataNode;
        it->attrName = StrDup(attrName);
        it->attrValue = StrDup(attrValue);
        it->next = head;
        head = it;
        return 1;
    }
};
Exemplo n.º 6
0
struct configured_plugin *GetPlugin( CTEXTSTR plugin_mask )
{

	struct configured_plugin *plugin;
	INDEX idx;
	TEXTSTR full_name = StrDup( plugin_mask );
	TEXTSTR extra_path = (TEXTSTR)StrChr( plugin_mask, ';' );
	if( extra_path )
	{
		extra_path[0] = 0;
		extra_path++;
	}
	LIST_FORALL( l.plugins, idx, struct configured_plugin*, plugin )
	{
		if( StrCaseCmp( plugin->plugin_mask, plugin_mask ) == 0 )
			break;
	}

	if( !plugin )
	{
		plugin = New( struct configured_plugin );
		plugin->plugin_full_name = full_name;
		plugin->plugin_mask = StrDup( plugin_mask );
		plugin->plugin_extra_path = StrDup( extra_path );
		plugin->pLoadOn = NULL;
		plugin->pNoLoadOn = NULL;
		plugin->pli = NULL;
		plugin->flags.bDelete = FALSE;
		plugin->flags.bLoaded = FALSE;
		plugin->flags.bNoLoad = FALSE;
		AddLink( &l.plugins, plugin );
	}
Exemplo n.º 7
0
static char *
BookmarkCompletionFunction(const char *text, int state)
{
	char *cp;
	size_t textlen;
	int i, matches;

	if ((gBookmarkTable == NULL) || (state >= gNumBookmarks))
		return (NULL);

	textlen = strlen(text);
	if (textlen == 0) {
		cp = StrDup(gBookmarkTable[state].bookmarkName);
	} else {
		cp = NULL;
		for (i=0, matches=0; i<gNumBookmarks; i++) {
			if (ISTRNCMP(gBookmarkTable[i].bookmarkName, text, textlen) == 0) {
				if (matches >= state) {
					cp = StrDup(gBookmarkTable[i].bookmarkName);
					break;
				}
				matches++;
			}
		}
	}
	return cp;
}	/* BookmarkCompletionFunction */
Exemplo n.º 8
0
extern void InitMessage(char *id, char *fn) {
  char *tempformat, *tempfn;
#ifdef USE_MSGD
  int fd;
  Port *port;
#endif

#ifdef USE_SYSLOG
  static char buff[SIZE_LOG];

  snprintf(buff, SIZE_LOG, "%s/%s", PACKAGE, id);
  openlog(buff, LOG_PID, syslog_facility);
#endif

  if (fn == NULL) {
    tempfn = getenv("LOG_FILE_NAME");
    if (tempfn != NULL) {
      fn = StrDup(tempfn);
    }
  }
  fpLog = NULL;
  Processid = StrDup(id);
  tempformat = getenv("LOG_DATA_FORMAT");
  if (tempformat != NULL) {
    Format = StrDup(tempformat);
  }
#ifdef USE_MSGD
  if (fn != NULL) {
    if (*fn == '@') {
      port = ParPort(fn + 1, PORT_MSGD);
      if ((fd = ConnectSocket(port, SOCK_STREAM)) >= 0) {
        fpLog = SocketToNet(fd);
        if (Format == NULL) {
          Format = "%F:%i:%f:%L:%B";
        }
      }
      DestroyPort(port);
    } else {
      if ((fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0600)) >= 0) {
        fpLog = FileToNet(fd);
      }
    }
  }
  if (fpLog == NULL) {
    if (Format == NULL) {
      Format = "%Y/%M/%D/%h:%m:%s %F:%f:%L:%B";
    }
    fpLog = FileToNet(STDOUT_FILENO);
  }
#else
  if ((fn == NULL) || ((fpLog = fopen(fn, "w+")) == NULL)) {
    fpLog = stdout;
  }
#endif
  if (Format == NULL) {
    Format = "%Y/%M/%D/%h:%m:%s %F:%f:%L:%B";
  }
  MessageFunction = __Message;
}
Exemplo n.º 9
0
static uintptr_t CPROC AddPostInstallCommand( uintptr_t psv, arg_list args ) {
    PARAM( args, CTEXTSTR, cmd );
    PARAM( args, CTEXTSTR, cmd_args );
    struct command *command = New( struct command );
    command->cmd = StrDup( cmd );
    command->args = StrDup( cmd_args );
    AddLink( &l.commands, command );
    return psv;
}
Exemplo n.º 10
0
extern void MCP_RegistHandler(GHashTable *StatusTable, char *status,
                              char *event, void (*handler)(ProcessNode *)) {
  GHashTable *EventTable;

  if ((EventTable = g_hash_table_lookup(StatusTable, status)) == NULL) {
    EventTable = NewNameHash();
    g_hash_table_insert(StatusTable, StrDup(status), EventTable);
  }
  if (g_hash_table_lookup(EventTable, event) == NULL) {
    g_hash_table_insert(EventTable, StrDup(event), handler);
  }
}
Exemplo n.º 11
0
/*  Strip the filename of its prefix and make a new copy.
 */
#ifdef _WIN32
#define PATHSEPCHAR '\\'
#else
#define PATHSEPCHAR '/'
#endif /* _WIN32 */
char *StripPrefix(char *name)

{
    char *ptr, *nptr;

    if ((ptr = strrchr(name, PATHSEPCHAR)) == NULL)
        return StrDup(name);
	if (NULL == (nptr = StrDup(ptr+1))) {
		nptr = acad_malloc(sizeof(""));
		nptr[0] = '\0';
	}
	return nptr;
}
Exemplo n.º 12
0
static void CPROC CheckFiles( uintptr_t psv )
{
	INDEX idx;
	struct input_file *file;
	if( l.flags.bLog )
		lprintf( WIDE("Check Files...") );
	LIST_FORALL( l.files, idx, struct input_file*, file )
	{
		FILE *input;
		static TEXTCHAR buf[256];
		if( l.flags.bLog )
			lprintf( WIDE("check %s"), file->filename );
		input = sack_fopen( 0, file->filename, WIDE("rt") );
		if( input )
		{
			INDEX var_idx = 0;
			while( fgets( buf, sizeof( buf ), input ) )
			{
				size_t end;
				struct variable_tracker *var =(struct variable_tracker*)GetLink( &file->vars, var_idx );
				//lprintf( WIDE("buf .. %s"), buf );
				while( ( end = strlen(buf) ) && ( buf[end-1] == '\n' ) )
					buf[end-1] = 0;
				if( l.flags.bLog )
					lprintf( WIDE("Content %p %s"), var, buf );
				if( !var )
				{
					TEXTCHAR tmp_name[128];
					snprintf( tmp_name, sizeof( tmp_name ), WIDE("<File %s.%d>"), file->varname, var_idx+1 );
					var = New( struct variable_tracker );
					var->var_content = StrDup( buf );
					var->var_name = StrDup( tmp_name );
					lprintf( WIDE("Newvar %s=%s"), tmp_name, buf );
					var->variable = CreateLabelVariable( tmp_name, LABEL_TYPE_STRING, &var->var_content );
					SetLink( &file->vars, var_idx, var );
				}
				else
				{
					if( StrCmp( var->var_content, buf ) )
					{
						Release( var->var_content );
						var->var_content = StrDup( buf );
						lprintf( WIDE("Change var %s=%s"), var->var_name, buf );
 						LabelVariableChanged( var->variable );
					}
				}

				var_idx++;
			}
			sack_fclose( input );
		}
Exemplo n.º 13
0
static void
addServers( char **srv, int bType )
{
	char *name, *class2;
	const char *dtx, *cls;
	struct display *d;

	for (; *srv; srv++) {
		if ((cls = strchr( *srv, '_' ))) {
			if (!StrNDup( &name, *srv, cls - *srv ))
				return;
			if (!StrDup( &class2, cls )) {
				free( name );
				return;
			}
		} else {
			if (!StrDup( &name, *srv ))
				return;
			class2 = 0;
		}
		if ((d = FindDisplayByName( name ))) {
			if (d->class2)
				free( d->class2 );
			dtx = "existing";
		} else {
			if (!(d = NewDisplay( name ))) {
				free( name );
				if (class2)
					free( class2 );
				return;
			}
			dtx = "new";
		}
		d->stillThere = 1;
		d->class2 = class2;
		d->displayType = (*name == ':' ? dLocal : dForeign) | bType;
		if ((bType & d_lifetime) == dReserve) {
			if (d->status == notRunning)
				d->status = reserve;
		} else {
			if (d->status == reserve)
				d->status = notRunning;
		}
		Debug( "found %s %s%s display: %s %s\n", dtx,
		       ((d->displayType & d_location) == dLocal) ? "local" : "foreign",
		       ((d->displayType & d_lifetime) == dReserve) ? " reserve" : "",
		       d->name, d->class2 );
		free( name );
	}
}
Exemplo n.º 14
0
int
ReadPreamble(char **version,	/* version (output) */
	     char **arch,	/* architecture (output) */
	     long *pre_size,	/* preamble size (output) */
	     long *hdr_size,	/* header size (output) */
	     long *rec_size,	/* record size (output) */
	     FILE *file)	/* input file */
{
    char    buf[PREAM_MAX + 1]; /* input string + null */

    /* Check magic number, MAGIC. */

    if (!GetLine(buf, 8, file))
	return FALSE;

    if (strcmp(buf, MAGIC) != 0)
	return FALSE;

    if (!GetLine(buf, 8, file))
	return FALSE;
    if (version != NULL)
	*version = StrDup(buf);

    /* Get architecture. */

    if (!GetLine(buf, 8, file))
	return FALSE;
    if (arch != NULL)
	*arch = StrDup(buf);

    /* Get preamble size */

    if (!GetLong(pre_size, 8, file))
	return FALSE;

    /* Could check *pre_size here. */

    /* Get header size */

    if (!GetLong(hdr_size, 8, file))
	return FALSE;

    /* Get record size */

    if (!GetLong(rec_size, 8, file))
	return FALSE;

    return TRUE;		/* success */
}
Exemplo n.º 15
0
void DigestCacheSet(DigestCache* self, const char* filename, uint32_t hash, uint64_t timestamp, const HashDigest& digest)
{
  ReadWriteLockWrite(&self->m_Lock);

  DigestCacheRecord* r;

  if (nullptr != (r = (DigestCacheRecord*) HashTableLookup(&self->m_Table, hash, filename)))
  {
    r->m_Timestamp     = timestamp;
    r->m_ContentDigest = digest;
    r->m_AccessTime    = self->m_AccessTime;
  }
  else
  {
    r = LinearAllocate<DigestCacheRecord>(&self->m_Allocator);
    r->m_Hash          = hash;
    r->m_ContentDigest = digest;
    r->m_Next          = nullptr;
    r->m_String        = StrDup(&self->m_Allocator, filename);
    r->m_Timestamp     = timestamp;
    r->m_AccessTime    = self->m_AccessTime;
    HashTableInsert(&self->m_Table, r);
  }

  ReadWriteUnlockWrite(&self->m_Lock);
}
Exemplo n.º 16
0
int
Downloader::init_local_file_name(void)
{
	int length;
	char *tmpStr;

	length = task.get_local_dir() ? strlen(task.get_local_dir()) : 1;
	length += task.get_local_file() ? strlen(task.get_local_file()) :
		strlen(task.url.get_file());
	length += 6;

	tmpStr = new char[length];

	snprintf( tmpStr, length, "%s/%s.mg!",
			task.get_local_dir() ? task.get_local_dir() : ".",
			task.get_local_file() ? task.get_local_file() :
				task.url.get_file() );
	delete[] localPath;
	delete[] localMg;
	tmpStr[length - 5] = '\0';
	localPath = StrDup(tmpStr);
	tmpStr[length - 5] = '.';
	localMg = tmpStr;

	return 0;
};
Exemplo n.º 17
0
int main( int argc, TEXTCHAR **argv )
{
   int saveas = 0;
	if( argc < 2 )
	{
		printf( WIDE("Usage: %s <config filename> [optional - set as config filename]\n" ), argv[0] );
      return 1;

	}
	if( argc > 2 )
		saveas = 1;

	{
      TEXTSTR tmp = (TEXTSTR)StrDup( argv[1] );
		TEXTSTR filename = (TEXTSTR)pathrchr( tmp );
		if( !filename )
         filename = tmp;


		{
			uint32_t size = 0;
			POINTER mem = OpenSpace( NULL, argv[1], &size );
			if( mem && size )
			{
#ifndef __NO_SQL__
				SACK_WriteProfileBlob( WIDE("intershell/configuration" ), saveas?argv[2]:filename, (TEXTCHAR*)mem, size );
#endif
				CloseSpace( mem );
			}
		}

	}
   return 1;
}
Exemplo n.º 18
0
static uintptr_t CPROC SetTeamHelmetSticker( uintptr_t psv, arg_list args )
{
	PARAM( args, int64_t, down );
	PARAM( args, CTEXTSTR, data );
	ffl.helmet_sticker_name[down-1] = StrDup( data );
	return psv;
}
Exemplo n.º 19
0
static uintptr_t CPROC SetDownIntro( uintptr_t psv, arg_list args )
{
	PARAM( args, int64_t, down );
	PARAM( args, CTEXTSTR, data );
	ffl.downs[down-1] = StrDup( data );
	return psv;
}
Exemplo n.º 20
0
static char *
CommandCompletionFunction(const char *text, int state)
{
	char *cp;
	size_t textlen;
	int i, matches;
	CommandPtr cmdp;

	textlen = strlen(text);
	if (textlen == 0) {
		cp = NULL;
	} else {
		cp = NULL;
		for (i=0, matches=0; ; i++) {
			cmdp = GetCommandByIndex(i);
			if (cmdp == kNoCommand)
				break;
			if (ISTRNCMP(cmdp->name, text, textlen) == 0) {
				if (matches >= state) {
					cp = StrDup(cmdp->name);
					break;
				}
				matches++;
			}
		}
	}
	return cp;
}	/* CommandCompletionFunction */
Exemplo n.º 21
0
static int GetNextInputChar( prompt_slot slot )
/*********************************************/
{
    int     c;

    c = ReadNextChar( slot );
    /* Redirect input to a response file; cannot be nested. */
    if( c == '@' && !is_quoting ) {
        if( CmdFile->how == COMMANDLINE || CmdFile->how == INTERACTIVE ) {
            char    fname[LINE_BUF_SIZE];
            int     oi;

            for( oi = 0; oi < sizeof( fname ) - 1; ) {
                c = ReadNextChar( slot );
                if( c == '"' )
                    is_quoting ^= true;
                /* Quit loop if not a valid filename character. */
                if( (!is_quoting && (c == ',' || c == '+' || c == ';' || c == ' ')) ||
                    c == '/' || c < ' ' )
                    break;
                if( c != '"' ) {
                    fname[oi++] = c;
                }
            }
            fname[oi] = '\0';
            if( c > ' ' )
                --CmdFile->current;

            /* Open the response file and read next character. */
            StartNewFile( StrDup( fname ) );
            c = ReadNextChar( slot );
        }
    }
    return( c );
}
Exemplo n.º 22
0
char *CGTKBase::GetPassword(const char *str)
{
    const int windoww = 400;
    
    GtkWidget *dialog = gtk_dialog_new_with_buttons(GetTranslation("Password dialog"), NULL, GTK_DIALOG_MODAL,
                                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK,
                                                    NULL);
    gtk_window_set_default_size(GTK_WINDOW(dialog), windoww, -1);
    
    GtkWidget *label = gtk_label_new(str);
    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 15);
    gtk_widget_show(label);

    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
    
    GtkWidget *input = gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(input), FALSE);
    gtk_box_pack_end(GTK_BOX(hbox), input, TRUE, TRUE, 15);
    gtk_widget_show(input);
    
    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
    gtk_widget_show(hbox);
    
    gint dialogret = gtk_dialog_run(GTK_DIALOG(dialog));
    char *ret = (dialogret == GTK_RESPONSE_OK) ? StrDup(gtk_entry_get_text(GTK_ENTRY(input))) : NULL;
    
    gtk_widget_destroy(dialog);

    return ret;
}
Exemplo n.º 23
0
//---------------------------------------------------------------------------
// タイトルの設定
void __fastcall TPrintDlgBox::SetTitle(int col, LPCSTR p)
{
	if( col >= COLMAX ) return;
	if( col >= mColCount ) mColCount = col + 1;
	mTitle[col] = StrDup(p);
    if( mWidthP[col] < int(strlen(p)) ) mWidthP[col] = strlen(p);
}
Exemplo n.º 24
0
Arquivo: hash.C Projeto: emgertz/OOQP
int Insert(HashTable *table, char *name, int index)
{
  List           *ptr;
  int             i;

  /* lookup entry */

  i = hash(table, name);

  for (ptr = table->list[i]; ptr != NULL; ptr = ptr->next)
    if (strcmp(ptr->entry, name) == 0)
      break;

  if (ptr == NULL) {		/* no entry with "name" was found */
    try {
      ptr = new List;
      ptr->entry = StrDup(name, "entry");
      ptr->index = index;
      
      /* put this entry first in the list */
      ptr->next = table->list[i];
      table->list[i] = ptr;
    } catch ( ... ) {
      std::cerr << "Not enought memory to insert an item into the hash table";
      throw;
    }
    return (0);			/* normal */
  } else
    return (1);			/* name was already found in table */
}
Exemplo n.º 25
0
static FunctionMeta* FindFunction(lua_State* L, lua_Debug* ar)
{
  // This is slow, it involves string formatting. It's mostly OK, because we're
  // careful not to include this in the timings. It will of course affect cache
  // and other things. Not that we can make a lot of informed decisions about
  // that in an interpreted language anyway.
  if (!lua_getinfo(L, "Sn", ar))
    Croak("couldn't get debug info for function call");

  char buffer[1024];
  snprintf(buffer, sizeof(buffer), "%s;%s;%s;%d",
      ar->name ? ar->name : "", ar->namewhat ? ar->namewhat : "", ar->source, ar->linedefined);
  buffer[(sizeof buffer)-1] = 0;

  const uint32_t hash = Djb2Hash(buffer);
  HashRecord* r = HashTableLookup(&s_Profiler.m_Functions, hash, buffer);

  if (!r) {
    r = LinearAllocate<FunctionMeta>(s_Profiler.m_Allocator);
    r->m_Hash   = hash;
    r->m_String = StrDup(s_Profiler.m_Allocator, buffer);
    r->m_Next   = nullptr;
    HashTableInsert(&s_Profiler.m_Functions, r);
  }
  
  return static_cast<FunctionMeta*>(r);
}
Exemplo n.º 26
0
int GetSysVar(char const *name, Value *val)
{
    SysVar *v = FindSysVar(name);

    val->type = ERR_TYPE;
    if (!v) return E_NOSUCH_VAR;
    if (v->type == SPECIAL_TYPE) {
	SysVarFunc f = (SysVarFunc) v->value;
	return f(0, val);
    } else if (v->type == STR_TYPE) {
	val->v.str = StrDup(*((char **) v->value));
	if (!val->v.str) return E_NO_MEM;
    } else {
	val->v.val = *((int *) v->value);
    }
    val->type = v->type;

    /* In "verbose" mode, print attempts to test $RunOff */
    if (DebugFlag & DB_PRTLINE) {
	if (v->value == (void *) &RunDisabled) {
	    Eprint("(Security note: $RunOff variable tested.)\n");
	    /* Allow further messages from this line */
	    FreshLine = 1;
	}
    }
    return OK;
}
Exemplo n.º 27
0
static int 					init_VChan_type 					(VChan_type* 					vchan, 
																char 							name[], 
										 						VChanDataFlows 					flowType, 
														 		void* 							VChanOwner, 	
										 				 		DiscardVChanFptr_type 			DiscardFptr,
										 				 		DisconnectVChanFptr_type		DisconnectFptr,
																VChanStateChangeCBFptr_type		VChanStateChangeCBFptr,
																VChanIsConnectedFptr_type		VChanIsConnectedFptr)
{
	// Data
	vchan->name   					= StrDup(name); 
	if (!vchan->name) return -1;
	vchan->dataFlow					= flowType;
	vchan->isActive					= TRUE;
	vchan->isOpen					= FALSE;
	
	vchan->VChanOwner				= VChanOwner;
	
	// Callbacks
	vchan->VChanStateChangeCBFptr	= VChanStateChangeCBFptr;
	
	// Methods
	vchan->DiscardFptr				= DiscardFptr;
	vchan->DisconnectFptr			= DisconnectFptr;
	vchan->VChanIsConnectedFptr		= VChanIsConnectedFptr;
	
	return 0;
}
Exemplo n.º 28
0
char *
Readline(char *prompt)
{
	char *linecopy, *line, *cp;
	char lbuf[256];

	if (gIsTTYr) {
		line = getline(prompt);
	} else {
		line = fgets(lbuf, sizeof(lbuf) - 1, stdin);
		if (line != NULL) {
			cp = line + strlen(line) - 1;
			if (*cp == '\n')
				*cp = '\0';
		}
	}

	if (line != NULL) {
		if (line[0] == '\0')
			return NULL;	/* EOF */
		linecopy = StrDup(line);
		line = linecopy;
	}
	return (line);
}	/* Readline */
Exemplo n.º 29
0
Semaphore_t *CreateSem(const char *name, unsigned value)
{
	Semaphore_t *sem = Malloc(sizeof(Semaphore_t));

	sem->queue.name = StrDup(name);
	sem->value = value;
	return sem;
}
Exemplo n.º 30
0
Monitor_t *
CreateMonitor(const char *name)
{
	Monitor_t *mon = Malloc(sizeof(Monitor_t));

	mon->queue.name = StrDup(name);
	return mon;
}