Esempio n. 1
0
static void for_each_child_callback(const char *filename, int attrib, int param)
{
#ifdef WORKAROUND_64BITS_SUPPORT
  FileItem* fileitem = for_each_child_callback_param;
#else
  FileItem* fileitem = (FileItem*)param;
#endif
  FileItem* child;
  const char *filename_without_path = get_filename(filename);

  if (*filename_without_path == '.' &&
      (ustrcmp(filename_without_path, ".") == 0 ||
       ustrcmp(filename_without_path, "..") == 0))
    return;

  child = get_fileitem_by_path(filename, false);
  if (!child) {
    ASSERT(fileitem != NULL);
    child = new FileItem(fileitem);

    child->filename = filename;
    child->displayname = filename_without_path;
    child->attrib = attrib;

    put_fileitem(child);
  }
  else {
    ASSERT(child->parent == fileitem);
  }

  fileitem->insertChildSorted(child);
}
Esempio n. 2
0
int cmd_time_debug(int argc, char **argv)
{
    if( ( argc == 2 )
     && ( ( !ustrcmp( argv[1], "on"  ) )
       || ( !ustrcmp( argv[1], "off" ) ) ) )
    {
        unsigned char toggle;
        toggle = !ustrcmp( argv[1], "on" );

        clock_debug_toggle(toggle);
    }

    return 0;
}
Esempio n. 3
0
/* TRUE returned means LineIsMode handled it */
BOOLEAN LineIsMode(UNCH * inp, BOOLEAN & suc, UNCH & md, UNCH * seq,
						 ExtCodeNames ecn, BOOLEAN FOUNDXDT, ostream & s){
	suc = FALSE;
	int i = 0, j = 0; UNCH t[11]; UNCH * p;
	while (inp[i] == ' ') i++;
	if (!inp[i]) return FALSE;

	for (j = 0; (j < 11) && isalpha(inp[i]); j++) t[j] = toupper(inp[i++]);
	t[j] = '\0';
	if (ustrcmp(t, MODEText)!=0) return FALSE;
	if (!FOUNDXDT) return TRUE;
	while (inp[i] == ' ') i++;
	if (!isdigit(inp[i])){
		ResFile->ResMessage(MalFormedRes, s);
		return TRUE;
		}
	md = inp[i++];

	while (inp[i] == ' ') i++;
	if (!inp[i]) {
		ResFile->ResMessage(MalFormedRes, s);
		return TRUE;
		}
	p = &inp[i];
	suc = ecn.ExtToSeq(p,FILEText, seq, MAXCHARSINSEQ, s);
	return TRUE;
}
Esempio n. 4
0
Widget* load_widget_from_xmlfile(const char* xmlFilename, const char* widgetName)
{
  Widget* widget = NULL;

  TiXmlDocument doc;
  if (!doc.LoadFile(xmlFilename))
    throw XmlException(&doc);

  // search the requested widget
  TiXmlHandle handle(&doc);
  TiXmlElement* xmlElement = handle
    .FirstChild("jinete")
    .FirstChildElement().ToElement();

  while (xmlElement) {
    const char* nodename = xmlElement->Attribute("name");

    if (nodename && ustrcmp(nodename, widgetName) == 0) {
      widget = convert_xmlelement_to_widget(xmlElement, NULL);
      break;
    }

    xmlElement = xmlElement->NextSiblingElement();
  }

  return widget;
}
Esempio n. 5
0
/* Initialize TCP listener socket for a single port
 * rgerhards, 2009-05-21
 */
static inline rsRetVal
initTCPListener(tcpsrv_t *pThis, tcpLstnPortList_t *pPortEntry)
{
	DEFiRet;
	uchar *TCPLstnPort;

	ISOBJ_TYPE_assert(pThis, tcpsrv);
	assert(pPortEntry != NULL);

	if(!ustrcmp(pPortEntry->pszPort, UCHAR_CONSTANT("0")))
		TCPLstnPort = UCHAR_CONSTANT("514");
		/* use default - we can not do service db update, because there is
		 * no IANA-assignment for syslog/tcp. In the long term, we might
		 * re-use RFC 3195 port of 601, but that would probably break to
		 * many existing configurations.
		 * rgerhards, 2007-06-28
		 */
	else
		TCPLstnPort = pPortEntry->pszPort;

	// pPortEntry->pszAddr = NULL ==> bind to all interfaces
        CHKiRet(netstrm.LstnInit(pThis->pNS, (void*)pPortEntry, addTcpLstn, TCPLstnPort, pPortEntry->pszAddr, pThis->iSessMax));

finalize_it:
	RETiRet;
}
Esempio n. 6
0
char eof_song_contains_event(EOF_SONG *sp, const char *text, unsigned long track, unsigned long flags, unsigned char track_specific)
{
	unsigned long i;

	if(sp && text)
	{
		for(i = 0; i < sp->text_events; i++)
		{
			if((sp->text_event[i]->flags & flags) == 0)
			{	//If the specified flags filters out this event
				continue;	//Skip this event
			}
			if(track_specific)
			{	//If the track specific flag is to be matched
				if(sp->text_event[i]->track != track)
				{	//If this event isn't in the specified track
					continue;	//Skip this event
				}
			}
			if(!ustrcmp(sp->text_event[i]->text, text))
			{
				return 1;	//Return match found
			}
		}
	}
	return 0;	//Return no match found
}
Esempio n. 7
0
/* Utility routine:

   Compares, the token TOKEN to the NUL-terminated string STRING.
   TOKEN must be a CPP_NAME.  Returns 1 for equal, 0 for unequal.  */
int
cpp_ideq (const cpp_token *token, const char *string)
{
  if (token->type != CPP_NAME)
    return 0;

  return !ustrcmp (NODE_NAME (token->val.node), (const uchar *) string);
}
Esempio n. 8
0
void js_open(_js *joy) {
	joy->fd = 0;
	if (joy->dev[0] && ustrcmp(joy->dev, uL("NULL"))) {
		joy->fd = uopen(joy->dev, O_RDONLY | O_NONBLOCK);
		if (joy->fd < 0) {
			joy->fd = 0;
		}
	}
}
//*****************************************************************************
//
// The "setproxy" command allows the user to change their proxy behavior
//
//*****************************************************************************
int
Cmd_setproxy(int argc, char *argv[])
{
    char pcProxyPort[10];

    //
    // Check the number of arguments.
    //
    if((argc == 2) && (ustrcmp("off",argv[1]) == 0 ))
    {
        g_bUseProxy = false;
        g_pcProxyAddress[0] = 0;
        g_ui16ProxyPort = 0;

        UARTprintf("Attempting to re-establish link with Exosite.\n\n");
        g_bOnline = LocateValidCIK();
    }
    else if(argc == 3)
    {
        //
        // Otherwise, copy the user-defined location into the global variable.
        //
        ustrncpy(g_pcProxyAddress, argv[1], 49);
        ustrncpy(pcProxyPort, argv[2], 9);

        //
        // Make sure that the global string remains terminated with a zero.
        //
        g_pcProxyAddress[49] = 0;
        pcProxyPort[9] = 0;
        g_ui16ProxyPort = ustrtoul(pcProxyPort, NULL, 0);
        g_bUseProxy = true;

        UARTprintf("New Proxy Address: %s\n", g_pcProxyAddress);
        UARTprintf("New Proxy Port: %d\n\n", g_ui16ProxyPort);

        UARTprintf("Attempting to re-establish link with Exosite.\n\n");
        g_bOnline = LocateValidCIK();

    }
    else
    {
        UARTprintf("\nProxy configuration help:\n");
        UARTprintf("    The setproxy command changes the proxy behavior of"
                   "this board.\n");
        UARTprintf("    To disable the proxy, type:\n\n");
        UARTprintf("    setproxy off\n\n");
        UARTprintf("    To enable the proxy with a specific proxy name and "
                   "port, type\n");
        UARTprintf("    setproxy <proxyaddress> <portnumber>. For "
                   "example:\n\n");
        UARTprintf("    setproxy your.proxy.address 80\n\n");
    }

    return 0;
}
Esempio n. 10
0
void TileRepository::exportBitmap(const char *filename, int tile_w, int tile_h, int tile_spacing, int tiles_in_row)
{
	list<TileType*> tiles_to_save;
	map<const char*, TileType*, ltstr>::iterator i;
	list<TileType*>::iterator j;
	char tempTilename[256];
	char tempFilename[256];
	replace_extension(tempFilename, get_filename(filename), "", 256);

	if (!(tiles_in_row > 0 && tile_w > 0 && tile_h > 0)) {
		allegro_message("WARNING: tiles_in_row (%d), tile_w (%d) and tile_h (%d) must all be larger than 0.", tiles_in_row, tile_w, tile_h);
		return;
	}

	for (i = tileTypes.begin(); i != tileTypes.end(); i++)
	{
		TileType* tempTileType = (*i).second;
		replace_extension(tempTilename, tempTileType->getName(), "", 256);
		if (ustrcmp(tempFilename, tempTilename) == 0) {
			tiles_to_save.push_back(tempTileType);
		}
	}

	if (tiles_to_save.empty()) {
		allegro_message("WARNING: No tiles to save in %s.", filename);
		return;
	}

	BITMAP *tile_bitmap;
	PALETTE pal;

	tile_bitmap = create_bitmap
	(
		tiles_in_row * tile_w,
		(tiles_to_save.size() / tiles_in_row +
		 tiles_to_save.size() % tiles_in_row) * tile_h
	);
	int x = 0;
	int y = 0;

	for (j = tiles_to_save.begin(); j != tiles_to_save.end(); j++)
	{
		blit((*j)->getBitmap(), tile_bitmap, 0, 0, x * tile_w, y * tile_h, tile_w, tile_h);
		x++;
		if (x == tiles_in_row) {
			y++;
			x = 0;
		}
	}

	get_palette(pal);
	save_bitmap(filename, tile_bitmap, pal);

	destroy_bitmap(tile_bitmap);
}
Esempio n. 11
0
/* find a lookup table. This is a naive O(n) algo, but this really
 * doesn't matter as it is called only a few times during config
 * load. The function returns either a pointer to the requested
 * table or NULL, if not found.
 */
lookup_t *
lookupFindTable(uchar *name)
{
	lookup_t *curr;

	for(curr = loadConf->lu_tabs.root ; curr != NULL ; curr = curr->next) {
		if(!ustrcmp(curr->name, name))
			break;
	}
	return curr;
}
Esempio n. 12
0
DBWORD js_from_name(const uTCHAR *name, const _js_element *list, const DBWORD length) {
	DBWORD js = 0;
	BYTE index;

	for (index = 0; index < length; index++) {
		if (!ustrcmp(name, list[index].name)) {
			return (list[index].value);
		}
	}
	return (js);
}
Esempio n. 13
0
	UNCH ExtCodeNames::Lookup(UNCH * n){
		int u = MaxBASICEntries - 1,i,l = 0,c;
		capstr(n);
		do {
			if (u < l) return '\0';
			i = (l+u)/2;
			c = ustrcmp(n,Btb[i].name);
			if (c < 0) u = i-1; else l = i+1;}
		while (c != 0);
		if (Btb[i].ext) return '\0';
		return Btb[i].cde;
	}
Esempio n. 14
0
void* GLAPIENTRY AMesaGetProcAddress(AL_CONST char *name)
{
	int i = 0;
	
	while (amesa_extension[i].proc) {
		if (ustrcmp(amesa_extension[i].name, name) == 0)
			return amesa_extension[i].proc;
		i++;
	}
	
	return NULL;
}
Esempio n. 15
0
/* do the physical open() call on a file.
 */
static rsRetVal
doPhysOpen(strm_t *pThis)
{
	int iFlags = 0;
	DEFiRet;
	ISOBJ_TYPE_assert(pThis, strm);

	/* compute which flags we need to provide to open */
	switch(pThis->tOperationsMode) {
		case STREAMMODE_READ:
			iFlags = O_CLOEXEC | O_NOCTTY | O_RDONLY;
			break;
		case STREAMMODE_WRITE:	/* legacy mode used inside queue engine */
			iFlags = O_CLOEXEC | O_NOCTTY | O_WRONLY | O_CREAT;
			break;
		case STREAMMODE_WRITE_TRUNC:
			iFlags = O_CLOEXEC | O_NOCTTY | O_WRONLY | O_CREAT | O_TRUNC;
			break;
		case STREAMMODE_WRITE_APPEND:
			iFlags = O_CLOEXEC | O_NOCTTY | O_WRONLY | O_CREAT | O_APPEND;
			break;
		default:assert(0);
			break;
	}
	if(pThis->sType == STREAMTYPE_NAMED_PIPE) {
		DBGPRINTF("Note: stream '%s' is a named pipe, open with O_NONBLOCK\n", pThis->pszCurrFName);
		iFlags |= O_NONBLOCK;
	}

	pThis->fd = open((char*)pThis->pszCurrFName, iFlags, pThis->tOpenMode);
	DBGPRINTF("file '%s' opened as #%d with mode %d\n", pThis->pszCurrFName, pThis->fd, pThis->tOpenMode);
	if(pThis->fd == -1) {
		char errStr[1024];
		int err = errno;
		rs_strerror_r(err, errStr, sizeof(errStr));
		DBGOPRINT((obj_t*) pThis, "open error %d, file '%s': %s\n", errno, pThis->pszCurrFName, errStr);
		if(err == ENOENT)
			ABORT_FINALIZE(RS_RET_FILE_NOT_FOUND);
		else
			ABORT_FINALIZE(RS_RET_IO_ERROR);
	} else {
		if(!ustrcmp(pThis->pszCurrFName, UCHAR_CONSTANT(_PATH_CONSOLE)) || isatty(pThis->fd)) {
			DBGPRINTF("file %d is a tty-type file\n", pThis->fd);
			pThis->bIsTTY = 1;
		} else {
			pThis->bIsTTY = 0;
		}
	}

finalize_it:
	RETiRet;
}
Esempio n. 16
0
UNCH LookupIntName(UNCH * n){
	int u = NumberChars - 1,i,l = 0,c;
	if (!n[0]) return '\0';
	UNCH n1[50];
	ustrcpy(n1,n);
	capstr(n1+1);
	do {
		if (u < l) return '\0';
		i = (l+u)/2;
		c = ustrcmp(n1,SortedCharNames[i].cname);
		if (c < 0) u = i-1; else l = i+1;}
	while (c != 0);
	return SortedCharNames[i].codept;
}
Esempio n. 17
0
/* check if the provided IP is (already) in the allowed list
 */
static int
isAllowed(uchar *pszIP)
{
	allowedip_t *pallow;
	int ret = 0;

	for(pallow = root ; pallow != NULL ; pallow = pallow->next) {
		if(!ustrcmp(pallow->pszIP, pszIP)) {
			ret = 1;
			goto finalize_it;
		}
	}
finalize_it: return ret;
}
Esempio n. 18
0
static int convert_align_value_to_flags(const char *value)
{
  char *tok, *ptr = base_strdup(value);
  int flags = 0;

  for (tok=ustrtok(ptr, " ");
       tok != NULL;
       tok=ustrtok(NULL, " ")) {
    if (ustrcmp(tok, "horizontal") == 0) {
      flags |= JI_HORIZONTAL;
    }
    else if (ustrcmp(tok, "vertical") == 0) {
      flags |= JI_VERTICAL;
    }
    else if (ustrcmp(tok, "left") == 0) {
      flags |= JI_LEFT;
    }
    else if (ustrcmp(tok, "center") == 0) {
      flags |= JI_CENTER;
    }
    else if (ustrcmp(tok, "right") == 0) {
      flags |= JI_RIGHT;
    }
    else if (ustrcmp(tok, "top") == 0) {
      flags |= JI_TOP;
    }
    else if (ustrcmp(tok, "middle") == 0) {
      flags |= JI_MIDDLE;
    }
    else if (ustrcmp(tok, "bottom") == 0) {
      flags |= JI_BOTTOM;
    }
    else if (ustrcmp(tok, "homogeneous") == 0) {
      flags |= JI_HOMOGENEOUS;
    }
  }

  base_free(ptr);
  return flags;
}
Esempio n. 19
0
BOOLEAN XlateTable::InsertForMode(UNCH mdin, UNCH mdout,
												UNCH * seqin, UNCH * seqout,
												unsigned glen,
												DupHanType DupWhat,
												ostream & s){
	XlateTableRec* trc = FindMode(mdin);
	XlateEntryData* p = trc->InsertEntry(seqin);
	if ((p->s[0] == '\0') || (DupWhat == UpdateEntry)) {
		p->t = STR;
		ustrcpy(p->s, seqout);
		p->m = mdout;
		p->l = glen; }
	else if ((0 != ustrcmp(p->s, seqout)) && (DupWhat == GiveError)) {
		ResFile->ResMessage(CONFLICTMSGRESOURCE, s);
		return FALSE;
		}
	return TRUE;
}
Esempio n. 20
0
/* find a strgen based on the provided name */
static rsRetVal
FindStrgen(strgen_t **ppStrgen, uchar *pName)
{
	strgenList_t *pThis;
	DEFiRet;
	
	for(pThis = pStrgenLstRoot ; pThis != NULL ; pThis = pThis->pNext) {
		if(ustrcmp(pThis->pStrgen->pName, pName) == 0) {
			*ppStrgen = pThis->pStrgen;
			FINALIZE;	/* found it, iRet still eq. OK! */
		}
	}

	iRet = RS_RET_PARSER_NOT_FOUND;

finalize_it:
	RETiRet;
}
Esempio n. 21
0
/* find a parser based on the provided name */
static rsRetVal
FindParser(parser_t **ppParser, uchar *pName)
{
	parserList_t *pThis;
	DEFiRet;
	
	for(pThis = pParsLstRoot ; pThis != NULL ; pThis = pThis->pNext) {
		if(ustrcmp(pThis->pParser->pName, pName) == 0) {
			*ppParser = pThis->pParser;
			FINALIZE;	/* found it, iRet still eq. OK! */
		}
	}

	iRet = RS_RET_PARSER_NOT_FOUND;

finalize_it:
	RETiRet;
}
Esempio n. 22
0
int compare(const void *p1, const void *p2) {
  const entry_t *const *a = p1;
  const entry_t *const *b = p2;

  // 1st: directories alphabetically
  // 2nd: image files alphabetically
  // 3rd: file names alphabetically

  bool a_is_dir = ((*a)->flags & E_DIR);
  bool b_is_dir = ((*b)->flags & E_DIR);
  if (a_is_dir && !b_is_dir) return -1;
  else if (!a_is_dir && b_is_dir) return 1;

  bool a_is_img = ((*a)->flags & E_IMAGE);
  bool b_is_img = ((*b)->flags & E_IMAGE);
  if (a_is_img && !b_is_img) return -1;
  else if (!a_is_img && b_is_img) return 1;

  return ustrcmp((*a)->filename, (*b)->filename);
}
Esempio n. 23
0
static rsRetVal
doLastMessageRepeatedNTimes(ratelimit_t *ratelimit, smsg_t *pMsg, smsg_t **ppRepMsg)
{
	int bNeedUnlockMutex = 0;
	DEFiRet;

	if(ratelimit->bThreadSafe) {
		pthread_mutex_lock(&ratelimit->mut);
		bNeedUnlockMutex = 1;
	}

	if( ratelimit->pMsg != NULL &&
	    getMSGLen(pMsg) == getMSGLen(ratelimit->pMsg) &&
	    !ustrcmp(getMSG(pMsg), getMSG(ratelimit->pMsg)) &&
	    !strcmp(getHOSTNAME(pMsg), getHOSTNAME(ratelimit->pMsg)) &&
	    !strcmp(getPROCID(pMsg, LOCK_MUTEX), getPROCID(ratelimit->pMsg, LOCK_MUTEX)) &&
	    !strcmp(getAPPNAME(pMsg, LOCK_MUTEX), getAPPNAME(ratelimit->pMsg, LOCK_MUTEX))) {
		ratelimit->nsupp++;
		DBGPRINTF("msg repeated %d times\n", ratelimit->nsupp);
		/* use current message, so we have the new timestamp
		 * (means we need to discard previous one) */
		msgDestruct(&ratelimit->pMsg);
		ratelimit->pMsg = pMsg;
		ABORT_FINALIZE(RS_RET_DISCARDMSG);
	} else {/* new message, do "repeat processing" & save it */
		if(ratelimit->pMsg != NULL) {
			if(ratelimit->nsupp > 0) {
				*ppRepMsg = ratelimitGenRepMsg(ratelimit);
				ratelimit->nsupp = 0;
			}
			msgDestruct(&ratelimit->pMsg);
		}
		ratelimit->pMsg = MsgAddRef(pMsg);
	}

finalize_it:
	if(bNeedUnlockMutex)
		pthread_mutex_unlock(&ratelimit->mut);
	RETiRet;
}
Esempio n. 24
0
static int
bs_arrcmp_str(const void *s1, const void *s2)
{
	return ustrcmp((uchar*)s1, *(uchar**)s2);
}
Esempio n. 25
0
static int
qs_arrcmp_ustrs(const void *s1, const void *s2)
{
	return ustrcmp(*(uchar**)s1, *(uchar**)s2);
}
Esempio n. 26
0
/* comparison function for qsort() */
static int
qs_arrcmp_strtab(const void *s1, const void *s2)
{
	return ustrcmp(((lookup_string_tab_entry_t*)s1)->key, ((lookup_string_tab_entry_t*)s2)->key);
}
Esempio n. 27
0
/* Parses an input string to read settings */
static void agl_parse_section(int sec, char *section, char *name) {
	const char *end;
	char *buf;
	char *ptr;
	int strsize;
	int opt = 0;

	end = get_config_string(section, name, "");
	strsize = ustrsizez(end);
	
	buf = (char*)malloc(sizeof(char) * strsize);
	
	if (!buf) {
		TRACE(PREFIX_E "parse_section: Ran out of memory "
		      "while trying to allocate %i bytes!",
		      (int)sizeof(char) * strsize);
		return;
	}

	memcpy(buf, end, strsize);
	end = buf + strsize;
	ptr = buf;

	while (ptr < end) {
		char *s = ustrtok_r(ptr, " ;|+", &ptr);
		
		if (!ustrcmp(s, "allegro_format"))
			opt |= AGL_ALLEGRO_FORMAT;
		if (!ustrcmp(s, "red_depth"))
			opt |= AGL_RED_DEPTH;
		if (!ustrcmp(s, "green_depth"))
			opt |= AGL_GREEN_DEPTH;
		if (!ustrcmp(s, "blue_depth"))
			opt |= AGL_BLUE_DEPTH;
		if (!ustrcmp(s, "alpha_depth"))
			opt |= AGL_ALPHA_DEPTH;
		if (!ustrcmp(s, "color_depth"))
			opt |= AGL_COLOR_DEPTH;
		if (!ustrcmp(s, "accum_red_depth"))
			opt |= AGL_ACC_RED_DEPTH;
		if (!ustrcmp(s, "accum_green_depth"))
			opt |= AGL_ACC_GREEN_DEPTH;
		if (!ustrcmp(s, "accum_blue_depth"))
			opt |= AGL_ACC_BLUE_DEPTH;
		if (!ustrcmp(s, "accum_alpha_depth"))
			opt |= AGL_ACC_ALPHA_DEPTH;
		if (!ustrcmp(s, "double_buffer"))
			opt |= AGL_DOUBLEBUFFER;
		if (!ustrcmp(s, "stereo_display"))
			opt |= AGL_STEREO;
		if (!ustrcmp(s, "aux_buffers"))
			opt |= AGL_AUX_BUFFERS;
		if (!ustrcmp(s, "z_depth"))
			opt |= AGL_Z_DEPTH;
		if (!ustrcmp(s, "stencil_depth"))
			opt |= AGL_STENCIL_DEPTH;
		if (!ustrcmp(s, "window_x"))
			opt |= AGL_WINDOW_X;
		if (!ustrcmp(s, "window_y"))
			opt |= AGL_WINDOW_Y;
		if (!ustrcmp(s, "fullscreen"))
			opt |= AGL_FULLSCREEN;
		if (!ustrcmp(s, "windowed"))
			opt |= AGL_WINDOWED;
		if (!ustrcmp(s, "video_memory_policy"))
			opt |= AGL_VIDEO_MEMORY_POLICY;
		if (!ustrcmp(s, "sample_buffers"))
			opt |= AGL_SAMPLE_BUFFERS;
		if (!ustrcmp(s, "samples"))
			opt |= AGL_SAMPLES;
		if (!ustrcmp(s, "float_color"))
			opt |= AGL_FLOAT_COLOR;
		if (!ustrcmp(s, "float_depth"))
			opt |= AGL_FLOAT_Z;
	}
	
	free(buf);
	
	allegro_gl_set(sec, opt);
}
Esempio n. 28
0
int /* boolean */ EqXE(XlateEntryData *p1, XlateEntryData *p2){
	if (p1==p2) return 1;
	if ((p1 == 0) || (p2 == 0)) return 0;
	return ((0 == ustrcmp(p1->s,p2->s)) && (p1->n == p2->n));
	};
Esempio n. 29
0
/* fs_edit_proc:
  *  Dialog procedure for the file selector editable string.
  */
static int fs_edit_proc(int msg, DIALOG *d, int c)
{
    char *s = (char *) d->dp;
    int size = (d->d1 + 1) * uwidth_max(U_CURRENT);           /* of s (in bytes) */
    int list_size;
    int found = 0;
    char b[1024], tmp[16];
    int ch, attr;
    int i;
    
    if(msg == MSG_START)
    {
        canonicalize_filename(b, s, sizeof(b));
        ustrzcpy(s, size, b);
    }
    
    if(msg == MSG_KEY)
    {
        if((!ugetc(s)) || (ugetat(s, -1) == DEVICE_SEPARATOR))
            ustrzcat(s, size, uconvert_ascii("./", tmp));
            
        canonicalize_filename(b, s, sizeof(b));
        ustrzcpy(s, size - ucwidth(OTHER_PATH_SEPARATOR), b);
        
        ch = ugetat(s, -1);
        
        if((ch != '/') && (ch != OTHER_PATH_SEPARATOR))
        {
            if(file_exists(s, FA_RDONLY | FA_HIDDEN | FA_DIREC, &attr))
            {
                if(attr & FA_DIREC)
                    put_backslash(s);
                else
                    return D_CLOSE;
            }
            else
                return D_CLOSE;
        }
        
        object_message(file_selector+FS_FILES, MSG_START, 0);
        
        /* did we `cd ..' ? */
        if(ustrlen(updir))
        {
            /* now we have to find a directory name equal to updir */
            for(i = 0; i<flist->size; i++)
            {
                if(!ustrcmp(updir, flist->name[i]))                 /* we got it ! */
                {
                    file_selector[FS_FILES].d1 = i;
                    /* we have to know the number of visible lines in the filelist */
                    /* -1 to avoid an off-by-one problem */
                    list_size = (file_selector[FS_FILES].h-4) / text_height(font) - 1;
                    
                    if(i>list_size)
                        file_selector[FS_FILES].d2 = i-list_size;
                    else
                        file_selector[FS_FILES].d2 = 0;
                        
                    found = 1;
                    break;                                            /* ok, our work is done... */
                }
            }
            
            /* by some strange reason, we didn't find the old directory... */
            if(!found)
            {
                file_selector[FS_FILES].d1 = 0;
                file_selector[FS_FILES].d2 = 0;
            }
        }
        
        /* and continue... */
        object_message(file_selector+FS_FILES, MSG_DRAW, 0);
        object_message(d, MSG_START, 0);
        object_message(d, MSG_DRAW, 0);
        
        return D_O_K;
    }
    
    int allegro_lfn = ALLEGRO_LFN; //removes compiler warning
    
    if(msg == MSG_UCHAR)
    {
        if((c >= 'a') && (c <= 'z'))
        {
            if(!allegro_lfn)
                c = utoupper(c);
        }
        else if(c == '/')
        {
            c = OTHER_PATH_SEPARATOR;
        }
        else if(allegro_lfn)
        {
            if((c > 127) || (c < 32))
                return D_O_K;
        }
        else
        {
            if((c != OTHER_PATH_SEPARATOR) && (c != '_') &&
                    (c != DEVICE_SEPARATOR) && (c != '.') &&
                    ((c < 'A') || (c > 'Z')) && ((c < '0') || (c > '9')))
                return D_O_K;
        }
    }
    
    //   return _gui_edit_proc(msg, d, c);
    return jwin_edit_proc(msg, d, c);
}
Esempio n. 30
0
void ngui_render_button(ngui_button_data *d) {

    uint16_t text[100];
    for(int n=0; n<100; n++) text[n] = d->text[n];

    SDL_SetRenderDrawColor(ngui_renderer,0xA0,0xA0,0xA0,0xFF);

    bool notext=false;
    if(ustrcmp(text,"Iclose" ) == 0) {
        draw_close_icon (d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Ikbshow") == 0) {
        draw_kbshow_icon(d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Ipaste" ) == 0) {
        draw_paste_icon (d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Iesc"   ) == 0) {
        draw_esc_icon   (d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Itab"   ) == 0) {
        draw_tab_icon   (d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Ialt"   ) == 0) {
        draw_alt_icon   (d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Ictrl"  ) == 0) {
        draw_ctrl_icon  (d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Iup"    ) == 0) {
        draw_up_icon    (d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Idown"  ) == 0) {
        draw_down_icon  (d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Ileft"  ) == 0) {
        draw_left_icon  (d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Iright" ) == 0) {
        draw_right_icon (d->x,d->y,d->shine);
        notext=true;
    }
    if(ustrcmp(text,"Imenu"  ) == 0) {
        draw_menu_icon  (d->x,d->y,d->shine);
        notext=true;
    }
    if(d->shine > 0) {
        d->shine--;
        ngui_redraw_required();
    }

//  nsdl_rectangle_shade(ngui_screen,d->x-d->x_padding,d->y-d->y_padding,d->x+(strlen(d->text))*8+d->x_padding,d->y+16+d->y_padding,1000,10000);

    if(!notext) {
        SDL_Rect rect;

        rect.x = d->x-d->x_padding;
        rect.y = d->y-d->y_padding;
        rect.w = (strlen(d->text))*8+(d->x_padding*2);
        rect.h = 16+d->y_padding;

        SDL_RenderDrawRect(ngui_renderer,&rect);

        draw_unitext_renderer(ngui_renderer,
                              d->x,
                              d->y,
                              text,
                              0,
                              65535,0,0,0,0);
    }
}