#define NUM_ELEMENTS(a) (sizeof(a)/sizeof(a[0]))
#define ASSERT(a)
-const TCHAR* const usage_strings[] = {
+const TCHAR* const usage_strings[] = {
_T("Device Status: MODE [device] [/STATUS]"),
_T("Select code page: MODE CON[:] CP SELECT=yyy"),
_T("Code page status: MODE CON[:] CP [/STATUS]"),
_T(" [rts=on|off|hs|tg] [idsr=on|off]"),
};
-const TCHAR* const parity_strings[] = {
+const TCHAR* const parity_strings[] = {
_T("None"), // default
_T("Odd"), // only symbol in this set to have a 'd' in it
_T("Even"), // ... 'v' in it
TCHAR buffer[10240];
int len;
TCHAR* ptr = buffer;
-
+
*ptr = '\0';
if (QueryDosDevice(NULL, buffer, NUM_ELEMENTS(buffer))) {
while (*ptr != '\0') {
return 0;
}
-static
+static
BOOL SerialPortQuery(int nPortNum, LPDCB pDCB, LPCOMMTIMEOUTS pCommTimeouts, BOOL bWrite)
{
BOOL result;
return 0;
}
-static
+static
int ExtractModeSerialParams(const TCHAR* param)
{
if ( _tcsstr(param, _T("OFF"))) {
goto show_status;
} else if (_tcsstr(param1, _T("lpt"))) {
nPortNum = find_portnum(param1);
- if (nPortNum != -1)
+ if (nPortNum != -1)
return ShowParallelStatus(nPortNum);
} else if (_tcsstr(param1, _T("con"))) {
return ShowConsoleStatus();
-/*
+/*
* MORE.C - external command.
*
* clone from 4nt more command
*
* 26 Sep 1999 - Paolo Pantaleo <paolopan@freemail.it>
- * started
+ * started
* Oct 2003 - Timothy Schepens <tischepe at fastmail dot fm>
* use window size instead of buffer size.
*/
-/*
+/*
* TEE.C - external command.
*
* clone from 4nt tee command
*
* 01 Sep 1999 - Paolo Pantaleo <paolopan@freemail.it>
- * started
+ * started
*
*
*/
/*handle for file and console*/
HANDLE hConsoleIn,hConsoleOut;
-
+
/*bytes written by WriteFile and ReadFile*/
DWORD dwRead,dwWritten;
INT i;
BOOL bQuote;
- /*file list implementation*/
+ /*file list implementation*/
LPTSTR *files;
INT iFileCounter=0;
HANDLE *hFile;
/*
if( iFileCounter >= sizeof(files) / sizeof(*files) )
{
- ConErrPrintf("too many files, maximum is %d\n",sizeof(files) / sizeof(*files));
+ ConErrPrintf("too many files, maximum is %d\n",sizeof(files) / sizeof(*files));
return 1;
}
*/
/*open file(s)*/
for(i=0;i<iFileCounter;i++)
- {
+ {
//l=0;
hFile[i] = CreateFile(files[i],GENERIC_WRITE,
0,NULL,
{
struct tm *t;
int yearset;
- char *p;
+ char *p;
/* Start with the current time. */
if ((t = localtime(&tvp[0])) == NULL)
- err(1, "localtime"); DbgPrint("[%s]", "[23]");
+ err(1, "localtime"); DbgPrint("[%s]", "[23]");
/* [[CC]YY]MMDDhhmm[.SS] */
if ((p = strchr(arg, '.')) == NULL)
t->tm_sec = 0; /* Seconds defaults to 0. */
*p++ = '\0';
t->tm_sec = ATOI2(p);
}
-
+
yearset = 0;
switch(strlen(arg)) {
case 12: /* CCYYMMDDhhmm */
for (i = 1; i < argc; i++)
{
hFind=FindFirstFile(argv[i],&FindData);
-
+
if (hFind==INVALID_HANDLE_VALUE)
{
ConErrPrintf("File not found - %s\n",argv[i]);
if (dwRead>0 && bRet)
WriteFile(hConsoleOut,buff,dwRead,&dwWritten,NULL);
-
+
} while(dwRead>0 && bRet);
CloseHandle(hFile);
* screenhack stuff. There's still some work that could
* be done on this, particularly allowing a resource to
* specify how big the squares are.
- * modified: [ 10-4-88 ] Richard Hess ...!uunet!cimshop!rhess
+ * modified: [ 10-4-88 ] Richard Hess ...!uunet!cimshop!rhess
* [ Revised primary execution loop within main()...
* [ Extended X event handler, check_events()...
- * modified: [ 1-29-88 ] Dave Lemke lemke@sun.com
+ * modified: [ 1-29-88 ] Dave Lemke lemke@sun.com
* [ Hacked for X11...
- * [ Note the word "hacked" -- this is extremely ugly, but at
- * [ least it does the job. NOT a good programming example
+ * [ Note the word "hacked" -- this is extremely ugly, but at
+ * [ least it does the job. NOT a good programming example
* [ for X.
* original: [ 6/21/85 ] Martin Weiss Sun Microsystems [ SunView ]
*
******************************************************************************
Copyright 1988 by Sun Microsystems, Inc. Mountain View, CA.
-
+
All Rights Reserved
-
+
Permission to use, copy, modify, and distribute this software and its
- documentation for any purpose and without fee is hereby granted,
+ documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
- both that copyright notice and this permission notice appear in
+ both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Sun or MIT not be
used in advertising or publicity pertaining to distribution of the
- software without specific prior written permission. Sun and M.I.T.
- make no representations about the suitability of this software for
+ software without specific prior written permission. Sun and M.I.T.
+ make no representations about the suitability of this software for
any purpose. It is provided "as is" without any express or implied warranty.
-
+
SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT SHALL SUN BE LIABLE FOR ANY SPECIAL, INDIRECT
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THIS SOFTWARE.
*****************************************************************************/
unsigned char x;
unsigned char y;
unsigned char dir;
- unsigned char dummy;
+ unsigned char dummy;
} move_list[MOVE_LIST_SIZE], save_path[MOVE_LIST_SIZE], path[MOVE_LIST_SIZE];
static int maze_size_x, maze_size_y;
initialize_maze() /* draw the surrounding wall and start/end squares */
{
register int i, j, wall;
-
+
/* initialize all squares */
for ( i=0; i<maze_size_x; i++) {
for ( j=0; j<maze_size_y; j++) {
maze[i][j] = 0;
}
}
-
+
/* top wall */
for ( i=0; i<maze_size_x; i++ ) {
maze[i][0] |= WALL_TOP;
}
-
+
/* right wall */
for ( j=0; j<maze_size_y; j++ ) {
maze[maze_size_x-1][j] |= WALL_RIGHT;
}
-
+
/* bottom wall */
for ( i=0; i<maze_size_x; i++ ) {
maze[i][maze_size_y-1] |= WALL_BOTTOM;
}
-
+
/* left wall */
for ( j=0; j<maze_size_y; j++ ) {
maze[0][j] |= WALL_LEFT;
}
-
+
/* set start square */
wall = get_random(4);
switch (wall) {
- case 0:
+ case 0:
i = get_random(maze_size_x);
j = 0;
break;
- case 1:
+ case 1:
i = maze_size_x - 1;
j = get_random(maze_size_y);
break;
- case 2:
+ case 2:
i = get_random(maze_size_x);
j = maze_size_y - 1;
break;
- case 3:
+ case 3:
i = 0;
j = get_random(maze_size_y);
break;
start_y = j;
start_dir = wall;
sqnum = 0;
-
+
/* set end square */
wall = (wall + 2)%4;
switch (wall) {
{
register int i, newdoor = 0;
HDC hDC;
-
+
hDC = GetDC(hWnd);
do {
move_list[sqnum].x = cur_sq_x;
return; /* done ... return */
}
}
-
+
/* mark the out door */
maze[cur_sq_x][cur_sq_y] |= ( DOOR_OUT_TOP >> newdoor );
-
+
switch (newdoor) {
case 0: cur_sq_y--;
break;
break;
}
sqnum++;
-
+
/* mark the in door */
maze[cur_sq_x][cur_sq_y] |= ( DOOR_IN_TOP >> ((newdoor+2)%4) );
-
+
/* if end square set path length and save path */
if ( maze[cur_sq_x][cur_sq_y] & END_SQUARE ) {
path_length = sqnum;
save_path[i].dir = move_list[i].dir;
}
}
-
+
} while (1);
-
+
}
{
int candidates[3];
register int num_candidates;
-
+
num_candidates = 0;
-
+
/* top wall */
if ( maze[cur_sq_x][cur_sq_y] & DOOR_IN_TOP )
goto rightwall;
goto rightwall;
}
candidates[num_candidates++] = 0;
-
+
rightwall:
/* right wall */
if ( maze[cur_sq_x][cur_sq_y] & DOOR_IN_RIGHT )
goto bottomwall;
}
candidates[num_candidates++] = 1;
-
+
bottomwall:
/* bottom wall */
if ( maze[cur_sq_x][cur_sq_y] & DOOR_IN_BOTTOM )
goto leftwall;
}
candidates[num_candidates++] = 2;
-
+
leftwall:
/* left wall */
if ( maze[cur_sq_x][cur_sq_y] & DOOR_IN_LEFT )
goto donewall;
}
candidates[num_candidates++] = 3;
-
+
donewall:
if (num_candidates == 0)
return ( -1 );
if (num_candidates == 1)
return ( candidates[0] );
return ( candidates[ get_random(num_candidates) ] );
-
+
}
RECT rc;
switch (dir) {
- case 0:
+ case 0:
rc.left = border_x + bw + grid_width * i;
rc.right = rc.left + grid_width - (bw + bw);
rc.top = border_y - bw + grid_height * j;
rc.bottom = rc.top + grid_height;
break;
- case 1:
+ case 1:
rc.left = border_x + bw + grid_width * i;
rc.right = rc.left + grid_width;
rc.top = border_y + bw + grid_height * j;
rc.bottom = rc.top + grid_height - (bw + bw);
break;
- case 2:
+ case 2:
rc.left = border_x + bw + grid_width * i;
rc.right = rc.left + grid_width - (bw + bw);
rc.top = border_y + bw + grid_height * j;
{
register int i, j;
HBRUSH hBrush;
-
-
+
+
for ( i=0; i<maze_size_x; i++) {
if ( maze[i][0] & WALL_TOP ) {
MoveToEx(hDC, border_x + grid_width * i, border_y, NULL);
switch (dir) {
case 0:
MoveToEx(hDC, border_x + grid_width * i, border_y + grid_height * j, NULL);
- (void) LineTo(hDC, border_x + grid_width * (i+1),
+ (void) LineTo(hDC, border_x + grid_width * (i+1),
border_y + grid_height * j);
break;
case 1:
case 2:
MoveToEx(hDC, border_x + grid_width * i, border_y + grid_height * (j+1),
NULL);
- (void) LineTo(hDC, border_x + grid_width * (i+1),
+ (void) LineTo(hDC, border_x + grid_width * (i+1),
border_y + grid_height * (j+1));
break;
case 3:
MoveToEx(hDC, border_x + grid_width * i, border_y + grid_height * j,
NULL);
- (void) LineTo(hDC, border_x + grid_width * i,
+ (void) LineTo(hDC, border_x + grid_width * i,
border_y + grid_height * (j+1));
break;
}
0xaaaaaaaa
};
static RGBQUAD argbq[] = {
- { 0, 0, 255, 0 },
+ { 0, 0, 255, 0 },
{ 255, 255, 255, 0 }
};
BITMAPINFO *pbmi;
-
+
hDC = GetDC(hWnd);
pbmi = malloc(sizeof(BITMAPINFOHEADER) + sizeof(argbq) + sizeof(grayPattern));
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
/* plug up the surrounding wall */
maze[start_x][start_y] |= (WALL_TOP >> start_dir);
maze[end_x][end_y] |= (WALL_TOP >> end_dir);
-
+
/* initialize search path */
pathi = 0;
path[pathi].x = end_x;
path[pathi].y = end_y;
path[pathi].dir = -1;
}
-
+
static int
solve_maze() /* solve it with graphical feedback */
{
int ret;
int action_done;
-
+
do {
action_done = 1;
if ( ++path[pathi].dir >= 4 ) {
pathi--;
- draw_solid_square( (int)(path[pathi].x), (int)(path[pathi].y),
+ draw_solid_square( (int)(path[pathi].x), (int)(path[pathi].y),
(int)(path[pathi].dir), hDC, hBrushDead);
ret = 0;
}
- else if ( ! (maze[path[pathi].x][path[pathi].y] &
- (WALL_TOP >> path[pathi].dir)) &&
- ( (pathi == 0) || ( (path[pathi].dir !=
+ else if ( ! (maze[path[pathi].x][path[pathi].y] &
+ (WALL_TOP >> path[pathi].dir)) &&
+ ( (pathi == 0) || ( (path[pathi].dir !=
(int)(path[pathi-1].dir+2)%4) ) ) ) {
enter_square(pathi, hDC, hBrushLiving);
pathi++;
} while (! action_done);
return ret;
-}
+}
static void
enter_square(int n, HDC hDC, HBRUSH hBrush) /* move into a neighboring square */
{
- draw_solid_square( (int)path[n].x, (int)path[n].y,
+ draw_solid_square( (int)path[n].x, (int)path[n].y,
(int)path[n].dir, hDC, hBrush);
-
+
path[n+1].dir = -1;
switch (path[n].dir) {
case 0: path[n+1].x = path[n].x;
//
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <tchar.h>
-
+
#include "main.h"
#include "framewnd.h"
#include <tchar.h>
#include <stdlib.h>
#include <stdio.h>
-
+
#include "main.h"
#include "framewnd.h"
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_ZOOMIN, szFrameClass, MAX_LOADSTRING);
-
+
// Store instance handle in our global variable
hInst = hInstance;
if (wnd->StatusBar != NULL) {
if (p1 && *(char *)p1)
DfSendMessage(wnd->StatusBar, DFM_SETTEXT, p1, 0);
- else
+ else
DfSendMessage(wnd->StatusBar, DFM_CLEARTEXT, 0, 0);
DfSendMessage(wnd->StatusBar, DFM_PAINT, 0, 0);
}
DfInFocus = p1 ? wnd : NULL;
if (DfIsVisible(wnd))
DfSendMessage(wnd, DFM_BORDER, 0, 0);
- else
+ else
DfSendMessage(wnd, DFM_SHOW_WINDOW, 0, 0);
}
if (DfDialogBox(wnd, &Display, TRUE, NULL)) {
if (DfInFocus == wnd->MenuBarWnd || DfInFocus == wnd->StatusBar)
oldFocus = DfApplicationWindow;
- else
+ else
oldFocus = DfInFocus;
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
SelectColors(wnd);
{
if (DfGetClass(wnd) == DF_DIALOG)
return ((DF_DBOX *)(wnd->extension))->HelpName;
- else
+ else
return "Untitled";
}
else
* You must add entries to the DfColor tables in
* DFCONFIG.C for new classes.
*
- * Class Name Base Class Processor Attribute
+ * Class Name Base Class Processor Attribute
* ------------ --------- --------------- -----------
*/
DfClassDef( DF_NORMAL, -1, DfNormalProc, 0 )
cp = strrchr(path, '\\');
if (cp == NULL)
cp = path;
- else
+ else
cp++;
strcpy(cp, DFlatApplication);
strcat(cp, ext);
int oldattr = DfGetAttribute(wnd);
if (wnd->wlines > DfClientHeight(wnd))
DfAddAttribute(wnd, DF_VSCROLLBAR);
- else
+ else
DfClearAttribute(wnd, DF_VSCROLLBAR);
if (wnd->textwidth > DfClientWidth(wnd))
DfAddAttribute(wnd, DF_HSCROLLBAR);
- else
+ else
DfClearAttribute(wnd, DF_HSCROLLBAR);
if (DfGetAttribute(wnd) != oldattr)
DfSendMessage(wnd, DFM_BORDER, 0, 0);
{
if (ct->class != DF_SPINBUTTON && ct->class != DF_COMBOBOX)
{
- wnd->WindowColors[DF_FRAME_COLOR][DF_FG] =
+ wnd->WindowColors[DF_FRAME_COLOR][DF_FG] =
DfGetParent(wnd)->WindowColors[DF_FRAME_COLOR][DF_FG];
- wnd->WindowColors[DF_FRAME_COLOR][DF_BG] =
+ wnd->WindowColors[DF_FRAME_COLOR][DF_BG] =
DfGetParent(wnd)->WindowColors[DF_FRAME_COLOR][DF_BG];
if (ct->class != DF_EDITBOX && ct->class != DF_LISTBOX)
{
- wnd->WindowColors[DF_STD_COLOR][DF_FG] =
+ wnd->WindowColors[DF_STD_COLOR][DF_FG] =
DfGetParent(wnd)->WindowColors[DF_STD_COLOR][DF_FG];
- wnd->WindowColors[DF_STD_COLOR][DF_BG] =
+ wnd->WindowColors[DF_STD_COLOR][DF_BG] =
DfGetParent(wnd)->WindowColors[DF_STD_COLOR][DF_BG];
}
}
DfGetItemText(wnd, DF_ID_PATH, FileSpec, 65);
strcat(FileSpec, FileName);
}
- else
+ else
strcpy(FileSpec, FileName);
}
break;
}
static int ExtendSelections(DFWINDOW wnd, int sel, int shift)
-{
+{
if (shift & (DF_LEFTSHIFT | DF_RIGHTSHIFT) &&
wnd->AnchorPoint != -1) {
int i = sel;
case DF_ID_PRINT:
PrintPad(DfInFocus);
return TRUE;
- case DF_ID_EXIT:
+ case DF_ID_EXIT:
if (!DfYesNoBox("Exit Memopad?"))
return FALSE;
break;
FixTabMenu();
return TRUE;
case DF_ID_TAB6:
- DfCfg.Tabs = 6;
+ DfCfg.Tabs = 6;
FixTabMenu();
return TRUE;
case DF_ID_TAB8:
}
DfSendMessage(wwnd, DFM_CLOSE_WINDOW, 0, 0);
DfSendMessage(wnd1, DFM_SETFOCUS, TRUE, 0);
- DfSendMessage(wnd1, DFM_MAXIMIZE, 0, 0);
+ DfSendMessage(wnd1, DFM_MAXIMIZE, 0, 0);
}
/* --- Load the notepad file into the editor text buffer --- */
rtn = DfDefaultWndProc(wnd, msg, p1, p2);
if ((int)p1 == FALSE)
DfSendMessage(DfGetParent(wnd), DFM_ADDSTATUS, 0, 0);
- else
+ else
ShowPosition(wnd);
return rtn;
case DFM_KEYBOARD_CURSOR:
#define DF_INACTIVE 1
#define DF_CHECKED 2
#define DF_TOGGLE 4
-#define DF_CASCADED 8
+#define DF_CASCADED 8
/* --------- the standard menus ---------- */
extern DF_MBAR DfMainMenu;
if (mwnd != NULL)
DfSendMessage(wnd, DFM_MB_SELECTION,
DfActiveMenuBar->ActiveSelection, 0);
- else
+ else
DfSendMessage(wnd, DFM_PAINT, 0, 0);
break;
case DF_BS:
if (mwnd != NULL)
DfSendMessage(wnd, DFM_MB_SELECTION,
DfActiveMenuBar->ActiveSelection, 0);
- else
+ else
DfSendMessage(wnd, DFM_PAINT, 0, 0);
break;
default:
while (EventQueueCtr > 0)
{
struct events ev;
-
+
ev = EventQueue[EventQueueOffCtr];
if (++EventQueueOffCtr == DF_MAXMESSAGES)
EventQueueOffCtr = 0;
InputText = text;
TextLength = len;
InputBoxDB.dwnd.title = ttl;
- InputBoxDB.dwnd.w = 4 +
+ InputBoxDB.dwnd.w = 4 +
max(20, max(len, max((int)strlen(ttl), (int)strlen(msg))));
InputBoxDB.ctl[1].dwnd.x = (InputBoxDB.dwnd.w-2-len)/2;
InputBoxDB.ctl[0].dwnd.w = strlen(msg);
coll = 0;
else if (rc.lf+x == rcc.rt)
coll = 2;
- else
+ else
coll = 1;
}
}
coll = 0;
else if (rc.tp+y == rcc.bt)
coll = 2;
- else
+ else
coll = 1;
}
}
case DF_F1:
if (ActivePopDown == NULL)
DfSendMessage(DfGetParent(wnd), DFM_KEYBOARD, p1, p2);
- else
+ else
DfDisplayHelp(wnd,
(ActivePopDown+wnd->selection)->help);
return TRUE;
if ((int)p1 == DF_CTRL_F4)
return TRUE;
break;
- case DFM_PAINT:
+ case DFM_PAINT:
if (!DfIsVisible(wnd))
break;
statusbar = DfCalloc(1, DfWindowWidth(wnd)+1);
int lf, tp, ht, wd;
DFWINDOW SystemMenuWnd;
- DfSystemMenu.PullDown[0].Selections[6].Accelerator =
+ DfSystemMenu.PullDown[0].Selections[6].Accelerator =
(DfGetClass(wnd) == DF_APPLICATION) ? DF_ALT_F4 : DF_CTRL_F4;
lf = DfGetLeft(wnd)+1;
if (*(lp+i) && i < wnd->wleft+3) {
if (wnd->wleft+4 > lnlen)
trunc = TRUE;
- else
+ else
lp += 4;
}
else {
#define IDM_HELP_ABOUT 40006
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
if (wnd->StatusBar != NULL) {
if (p1 && *(char *)p1)
DfSendMessage(wnd->StatusBar, SETTEXT, p1, 0);
- else
+ else
DfSendMessage(wnd->StatusBar, CLEARTEXT, 0, 0);
DfSendMessage(wnd->StatusBar, PAINT, 0, 0);
}
inFocus = p1 ? wnd : NULL;
if (isVisible(wnd))
DfSendMessage(wnd, BORDER, 0, 0);
- else
+ else
DfSendMessage(wnd, SHOW_WINDOW, 0, 0);
}
if (DfDialogBox(wnd, &Display, TRUE, NULL)) {
if (inFocus == wnd->MenuBarWnd || inFocus == wnd->StatusBar)
oldFocus = ApplicationWindow;
- else
+ else
oldFocus = inFocus;
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
SelectColors(wnd);
{
if (GetClass(wnd) == DIALOG)
return ((DBOX *)(wnd->extension))->HelpName;
- else
+ else
return "Untitled";
}
else
cp = strrchr(path, '\\');
if (cp == NULL)
cp = path;
- else
+ else
cp++;
strcpy(cp, DFlatApplication);
strcat(cp, ext);
int oldattr = GetAttribute(wnd);
if (wnd->wlines > ClientHeight(wnd))
AddAttribute(wnd, VSCROLLBAR);
- else
+ else
ClearAttribute(wnd, VSCROLLBAR);
if (wnd->textwidth > ClientWidth(wnd))
AddAttribute(wnd, HSCROLLBAR);
- else
+ else
ClearAttribute(wnd, HSCROLLBAR);
if (GetAttribute(wnd) != oldattr)
DfSendMessage(wnd, BORDER, 0, 0);
{
if (ct->class != SPINBUTTON && ct->class != COMBOBOX)
{
- wnd->WindowColors[FRAME_COLOR][FG] =
+ wnd->WindowColors[FRAME_COLOR][FG] =
GetParent(wnd)->WindowColors[FRAME_COLOR][FG];
- wnd->WindowColors[FRAME_COLOR][BG] =
+ wnd->WindowColors[FRAME_COLOR][BG] =
GetParent(wnd)->WindowColors[FRAME_COLOR][BG];
if (ct->class != EDITBOX && ct->class != LISTBOX)
{
- wnd->WindowColors[STD_COLOR][FG] =
+ wnd->WindowColors[STD_COLOR][FG] =
GetParent(wnd)->WindowColors[STD_COLOR][FG];
- wnd->WindowColors[STD_COLOR][BG] =
+ wnd->WindowColors[STD_COLOR][BG] =
GetParent(wnd)->WindowColors[STD_COLOR][BG];
}
}
-/*
+/*
* ReactOS DFLAT32.DLL
*/
}
static int ExtendSelections(DFWINDOW wnd, int sel, int shift)
-{
+{
if (shift & (LEFTSHIFT | RIGHTSHIFT) &&
wnd->AnchorPoint != -1) {
int i = sel;
if (mwnd != NULL)
DfSendMessage(wnd, MB_SELECTION,
ActiveMenuBar->ActiveSelection, 0);
- else
+ else
DfSendMessage(wnd, PAINT, 0, 0);
break;
case BS:
if (mwnd != NULL)
DfSendMessage(wnd, MB_SELECTION,
ActiveMenuBar->ActiveSelection, 0);
- else
+ else
DfSendMessage(wnd, PAINT, 0, 0);
break;
default:
while (EventQueueCtr > 0)
{
struct events ev;
-
+
ev = EventQueue[EventQueueOffCtr];
if (++EventQueueOffCtr == MAXMESSAGES)
EventQueueOffCtr = 0;
InputText = text;
TextLength = len;
InputBoxDB.dwnd.title = ttl;
- InputBoxDB.dwnd.w = 4 +
+ InputBoxDB.dwnd.w = 4 +
max(20, max(len, max((int)strlen(ttl), (int)strlen(msg))));
InputBoxDB.ctl[1].dwnd.x = (InputBoxDB.dwnd.w-2-len)/2;
InputBoxDB.ctl[0].dwnd.w = strlen(msg);
coll = 0;
else if (rc.lf+x == rcc.rt)
coll = 2;
- else
+ else
coll = 1;
}
}
coll = 0;
else if (rc.tp+y == rcc.bt)
coll = 2;
- else
+ else
coll = 1;
}
}
case F1:
if (ActivePopDown == NULL)
DfSendMessage(GetParent(wnd), KEYBOARD, p1, p2);
- else
+ else
DisplayHelp(wnd,
(ActivePopDown+wnd->selection)->help);
return TRUE;
if ((int)p1 == CTRL_F4)
return TRUE;
break;
- case PAINT:
+ case PAINT:
if (!isVisible(wnd))
break;
statusbar = DFcalloc(1, WindowWidth(wnd)+1);
/* These are functions that are supposed to be part of the application
* not part of the dflat32.dll
*
- * - Fixme
+ * - Fixme
*/
char DFlatApplication[] = "none"; //edit.c
int lf, tp, ht, wd;
DFWINDOW SystemMenuWnd;
- SystemMenu.PullDown[0].Selections[6].Accelerator =
+ SystemMenu.PullDown[0].Selections[6].Accelerator =
(GetClass(wnd) == APPLICATION) ? ALT_F4 : CTRL_F4;
lf = GetLeft(wnd)+1;
/* This is the configuration file for the Midnight Commander. It was generated
by autoconf's configure.
-
+
Configure for Midnight Commander
Copyright (C) 1994, 1995 Janne Kukonlehto
Copyright (C) 1994, 1995 Miguel de Icaza
Copyright (C) 1995 Jakub Jelinek
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
+
#include <VERSION>
#undef HAVE_SUBSHELL_SUPPORT
/* If you don't have gcc, define this */
-#undef OLD_TOOLS
+#undef OLD_TOOLS
/* Are you using other type of curses? */
#undef OTHER_CURSES
#undef USE_NETCODE
/* If defined, use .netrc for FTP connections */
-#undef USE_NETRC
+#undef USE_NETRC
/* If your operating system does not have enough space for a file name
* in a struct dirent, then define this
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* This is the configuration file for the Midnight Commander. It was generated
by autoconf's configure.
-
+
Configure for Midnight Commander
Copyright (C) 1994, 1995 Janne Kukonlehto
Copyright (C) 1994, 1995 Miguel de Icaza
Copyright (C) 1995 Jakub Jelinek
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
+
#include <VERSION>
#define HAVE_SUBSHELL_SUPPORT 1
/* If you don't have gcc, define this */
-/* #undef OLD_TOOLS */
+/* #undef OLD_TOOLS */
/* Is the subshell the default or optional? */
/* #undef SUBSHELL_OPTIONAL */
#define USE_NETCODE 1
/* If defined, use .netrc for FTP connections */
-/* #undef USE_NETRC */
+/* #undef USE_NETRC */
/* If your operating system does not have enough space for a file name
* in a struct dirent, then define this
/* editor low level data handling and cursor fundamentals.
Copyright (C) 1996, 1997 the Free Software Foundation
-
+
Authors: 1996, 1997 Paul Sheer
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/*
*
* here's a quick sketch of the layout: (don't run this through indent.)
- *
+ *
* (b1 is buffers1 and b2 is buffers2)
- *
+ *
* |
* \0\0\0\0\0m e _ f i l e . \nf i n . \n|T h i s _ i s _ s o\0\0\0\0\0\0\0\0\0
* ______________________________________|______________________________________
* file end|||file beginning
* |
* |
- *
+ *
* _
* This_is_some_file
* fin.
/* cursor set to start of file */
int init_dynamic_edit_buffers (WEdit * edit, const char *filename, const char *text)
{
-
+
#if defined CR_LF_TRANSLATION
/* Variables needed for safe handling of Translation from Microsoft CR/LF EOL to
Unix Style LF EOL - Franco */
long bytes_wanted,bytes_read,bytes_missing;
char *p;
#endif
-
+
long buf;
int j, file = 0, buf2;
edit->buffers2[buf2] = CMalloc (EDIT_BUF_SIZE);
/*
-_read returns the number of bytes read,
-which may be less than count if there are fewer than count bytes left in the file
-or if the file was opened in text mode,
-in which case each carriage return\96linefeed (CR-LF) pair is replaced
-with a single linefeed character. Only the single linefeed character is counted
+_read returns the number of bytes read,
+which may be less than count if there are fewer than count bytes left in the file
+or if the file was opened in text mode,
+in which case each carriage return\96linefeed (CR-LF) pair is replaced
+with a single linefeed character. Only the single linefeed character is counted
in the return value. The replacement does not affect the file pointer.
-_eof returns 1 if the current position is end of file, or 0 if it is not.
-A return value of -1 indicates an error; in this case, errno is set to EBADF,
+_eof returns 1 if the current position is end of file, or 0 if it is not.
+A return value of -1 indicates an error; in this case, errno is set to EBADF,
which indicates an invalid file handle.
*/
if (filename){
dir = strdup (edit->dir);
else
dir = 0;
-
+
edit_clean (edit);
if (!edit_init (edit, lines, columns, 0, "", dir, 0))
return 0;
return is_blank (edit, p);
}
-/* moves up until a blank line is reached, or until just
+/* moves up until a blank line is reached, or until just
before a non-blank line is reached */
static void edit_move_up_paragraph (WEdit * edit, int scroll)
{
if (option_fake_half_tabs) {
if (is_in_indent (edit)) {
/*insert a half tab (usually four spaces) unless there is a
- half tab already behind, then delete it and insert a
+ half tab already behind, then delete it and insert a
full tab. */
if (right_of_four_spaces (edit)) {
for (i = 1; i <= HALF_TAB_SIZE; i++)
void edit_mail_dialog (WEdit * edit);
-/*
+/*
This executes a command at a lower level than macro recording.
It also does not push a key_press onto the undo stack. This means
that if it is called many times, a single undo command will undo
# include "../src/tty.h"
# include <sys/stat.h>
# include <errno.h>
-
+
# ifdef HAVE_FCNTL_H
# include <fcntl.h>
# endif
-
+
# include <stdlib.h>
# include <malloc.h>
# include <stdio.h>
# include <stdarg.h>
# include <sys/types.h>
-
+
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
-
+
# include <my_string.h>
# include <sys/stat.h>
-
+
# ifdef HAVE_FCNTL_H
# include <fcntl.h>
# endif
-
+
# include <stdlib.h>
# include <stdarg.h>
# include <time.h>
# endif
# endif
-
+
# include "regex.h"
#endif
# include "../src/menu.h"
# include "../src/regex.h"
# define WANT_WIDGETS
-
+
# define WIDGET_COMMAND (WIDGET_USER + 10)
# define N_menus 5
deleted at all since last load or save */
#ifdef MIDNIGHT
int delete_file; /* has the file been created in edit_load_file? Delete
- it at end of editing when it hasn't been modified
+ it at end of editing when it hasn't been modified
or saved */
-#endif
+#endif
unsigned char highlight;
long prev_col; /*recent column position of the curser - used when moving
up or down past lines that are shorter than the current line */
# define FONT_PIX_PER_LINE 1
# define FONT_MEAN_WIDTH 1
-
+
# define get_sys_error(s) (s)
# define open mc_open
# define close(f) mc_close(f)
# define edit_get_load_file(d,f,h) input_dialog (h, _(" Enter file name: "), f)
# define edit_get_save_file(d,f,h) input_dialog (h, _(" Enter file name: "), f)
# define CMalloc(x) malloc(x)
-
+
# define set_error_msg(s) edit_init_error_msg = strdup(s)
# ifdef _EDIT_C
# define MY_O_TEXT 0
# define WIN_MESSAGES edit->widget->mainid, 20, 20
-
+
# define edit_get_load_file(d,f,h) CGetLoadFile(WIN_MESSAGES,d,f,h)
# define edit_get_save_file(d,f,h) CGetSaveFile(WIN_MESSAGES,d,f,h)
# define edit_error_dialog(h,t) CErrorDialog(WIN_MESSAGES,h,"%s",t)
KEY_F (17), CK_Find_Again,
ALT ('<'), CK_Beginning_Of_Text,
ALT ('>'), CK_End_Of_Text,
-
+
0, 0};
static long key_pad_map[10] =
goto fin;
/* Function still not found for this key, so try macro's */
-/* This allows the same macro to be
+/* This allows the same macro to be
enabled by either eg "ALT('f')" or "XCTRL('f')" or "XCTRL('a'), 'f'" */
/* key.h: #define ALT(x) (0x200 | (x)) */
different_filename = 1;
if ((file = open ((char *) exp, O_RDONLY)) != -1) { /* the file exists */
close (file);
- if (edit_query_dialog2 (_(" Warning "),
- _(" A file already exists with this name. "),
+ if (edit_query_dialog2 (_(" Warning "),
+ _(" A file already exists with this name. "),
/* Push buttons to over-write the current file, or cancel the operation */
_("Overwrite"), _("Cancel")))
return 0;
edit->modified = 0;
#ifdef MIDNIGHT
edit->delete_file = 0;
-#endif
+#endif
if (different_filename && !edit->explicit_syntax)
edit_load_syntax (edit, 0, 0);
return 1;
}
/* gets a raw key from the keyboard. Passing cancel = 1 draws
- a cancel button thus allowing c-c etc.. Alternatively, cancel = 0
+ a cancel button thus allowing c-c etc.. Alternatively, cancel = 0
will return the next key pressed */
int edit_raw_key_query (char *heading, char *query, int cancel)
{
command = CK_Macro (edit_raw_key_query (_(" Delete Macro "), _(" Press macro hotkey: "), 1));
#else
/* This heads the 'Delete Macro' dialog box */
- command = CK_Macro (CKeySymMod (CRawkeyQuery (0, 0, 0, _(" Delete Macro "),
+ command = CK_Macro (CKeySymMod (CRawkeyQuery (0, 0, 0, _(" Delete Macro "),
/* Input line for a single key press follows the ':' */
_(" Press macro hotkey: "))));
#endif
edit->modified = 0;
#ifdef MIDNIGHT
edit->delete_file = 0;
-#endif
+#endif
return 1;
}
}
edit_scroll_screen_over_cursor (edit);
- edit_cursor_move (edit, current - edit->curs1
+ edit_cursor_move (edit, current - edit->curs1
- (((current - edit->curs1) > 0) ? end_mark - start_mark : 0));
edit_scroll_screen_over_cursor (edit);
0, 0, XV_WLAY_DONTCARE, NULL},
{quick_checkbox, 25, 50, 9, REPLACE_DLG_HEIGHT, "Pr&ompt on replace", 0, 0,
0, 0, XV_WLAY_DONTCARE, NULL},
- {quick_checkbox, 4, 50, 11, REPLACE_DLG_HEIGHT, "&Backwards", 0, 0,
+ {quick_checkbox, 4, 50, 11, REPLACE_DLG_HEIGHT, "&Backwards", 0, 0,
0, 0, XV_WLAY_DONTCARE, NULL},
{quick_checkbox, 4, 50, 10, REPLACE_DLG_HEIGHT, "&Regular exprssn", 0, 0,
0, 0, XV_WLAY_DONTCARE, NULL},
p++;
}
edit->force |= REDRAW_COMPLETELY;
- q = edit_query_dialog4 (_(" Replace "),
+ q = edit_query_dialog4 (_(" Replace "),
/* This is for the confirm replace dialog box. The replaced string comes after the ':' */
- catstrs (_(" Replace with: "), r, 0),
+ catstrs (_(" Replace with: "), r, 0),
/* Buttons for the confirm replace dialog box. */
_("Replace"), _("Skip"), _("Replace all"), _("Cancel"));
if (r)
}
} else { /* regexp matching */
long offset = 0;
- int found_start, match_bol, move_win = 0;
+ int found_start, match_bol, move_win = 0;
while (start + offset < last_byte) {
match_bol = (offset == 0 || (*get_byte) (data, start + offset - 1) == '\n');
while (repl_str[++i])
edit_insert (edit, repl_str[i]);
} else {
- edit_error_dialog (_(" Replace "),
+ edit_error_dialog (_(" Replace "),
/* "Invalid regexp string or scanf string" */
_(" Error in replacement format string. "));
replace_continue = 0;
case -1:
return;
}
- }
+ }
#ifdef MIDNIGHT
else if (edit->delete_file)
unlink (catstrs (edit->dir, edit->filename, 0));
exp = old ? old : "";
- exp = input_dialog (_(" Run Sort "),
+ exp = input_dialog (_(" Run Sort "),
/* Not essential to translate */
_(" Enter sort options (see manpage) separated by whitespace: "), "");
e = system (catstrs (" sort ", exp, " ", home_dir, BLOCK_FILE, " > ", home_dir, TEMP_FILE, 0));
if (e) {
if (e == -1 || e == 127) {
- edit_error_dialog (_(" Sort "),
+ edit_error_dialog (_(" Sort "),
/* Not essential to translate */
get_sys_error (_(" Error trying to execute sort command ")));
} else {
char q[8];
sprintf (q, "%d ", e);
- edit_error_dialog (_(" Sort "),
+ edit_error_dialog (_(" Sort "),
/* Not essential to translate */
catstrs (_(" Sort returned non-zero: "), q, 0));
}
if (block) {
if (eval_marks (edit, &start_mark, &end_mark)) {
- edit_error_dialog (_(" Process block "),
+ edit_error_dialog (_(" Process block "),
/* Not essential to translate */
_(" You must first highlight a block of text. "));
return;
}
} else {
/* Not essential to translate */
- edit_error_dialog (_(" Process block "),
+ edit_error_dialog (_(" Process block "),
/* Not essential to translate */
get_sys_error (_(" Error trying to stat file ")));
return;
extern int fixed_font;
void rerender_text (CWidget * wdt);
-
+
void edit_status (WEdit * edit)
{
if ((edit->widget->options & EDITOR_NO_TEXT)) {
#endif
render_edit_text (edit, row_start, col_start, row_end, col_end);
- if (edit->force) /* edit->force != 0 means a key was pending and the redraw
+ if (edit->force) /* edit->force != 0 means a key was pending and the redraw
was halted, so next time we must redraw everything in case stuff
was left undrawn from a previous key press */
edit->force |= REDRAW_PAGE;
#undef edit_message_dialog
#define edit_message_dialog(w,x,y,h,s) query_dialog (h, s, 0, 1, "&Ok")
-#define CFocus(x)
+#define CFocus(x)
static void menu_cmd (int i)
{
char *f;
char s[12];
sprintf (s, "%d", option_word_wrap_line_length);
- f = input_dialog (_(" Word wrap "),
+ f = input_dialog (_(" Word wrap "),
/* Not essential to translate */
_(" Enter line length, 0 for off: "), s);
if (f) {
}
}
-/*
+/*
This section comes from rxvt-2.21b1/src/screen.c by
Robert Nation <nation@rocket.sanders.lockheed.com> &
mods by mj olesen <olesen@me.QueensU.CA>
#define CURRENT_SYNTAX_RULES_VERSION "22"
-char *syntax_text =
+char *syntax_text =
"# syntax rules version " CURRENT_SYNTAX_RULES_VERSION "\n"
"# Allowable colors for mc are\n"
"# (after the slash is a Cooledit color, 0-26 or any of the X colors in rgb.txt)\n"
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
#ifndef MIDNIGHT
int edit_width_of_long_printable (int c);
#endif
-/*
- This is a copy of the function
+/*
+ This is a copy of the function
int calc_text_pos (WEdit * edit, long b, long *q, int l)
in propfont.c :(
It calculates the number of chars in a line specified to length l in pixels
break;
p = word_start (t, q, size);
if (p == -1)
- q = next_word_start (t, q, size); /* Return the end of the word if the beginning
- of the word is at the beginning of a line
+ q = next_word_start (t, q, size); /* Return the end of the word if the beginning
+ of the word is at the beginning of a line
(i.e. a very long word) */
else
q = p;
WCheck *check;
} check_perm[PERMISSIONS] = {
- {
+ {
FILE_ARCHIVED, N_("Archive"), 0, 0,
},
{
ch_dlg = create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
chmod_callback, _("[Chmod]"), _("chmod"), DLG_CENTER);
-
+
x_set_dialog_title (ch_dlg, _("Chmod command"));
#define XTRACT(i) BY+chmod_but[i].y-single_set, BX+chmod_but[i].x, \
statl = label_new (FY+4, FX+2, buffer, NULL);
add_widget (ch_dlg, statl);
tk_end_frame ();
-
+
run_dlg (ch_dlg); /* retrieve an action */
-
+
/* do action */
switch (ch_dlg->ret_value){
case B_ENTER:
mk_chmod (fname, c_stat); /*.ado */
need_update = 1;
break;
-
+
case B_CANCEL:
end_chmod = 1;
break;
-
+
case B_ALL:
case B_MARKED:
and_mask = or_mask = 0;
apply_mask (sf_stat);
break;
-
+
case B_SETMRK:
and_mask = or_mask = 0;
and_mask = ~and_mask;
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
----------------------------------------------------------------------------
Changes:
/* Client interface for General purpose Win32 console save/restore server
Having the same interface as its Linux counterpart:
- Copyright (C) 1994 Janne Kukonlehto <jtklehto@stekt.oulu.fi>
-
+ Copyright (C) 1994 Janne Kukonlehto <jtklehto@stekt.oulu.fi>
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
Note:
show_console_contents doesn't know how to write to its window
the rest works fine.
unsigned char end_line)
{
COORD c0 = { 0, 0 };
- COORD csize;
+ COORD csize;
SMALL_RECT rect;
CHAR_INFO *pchar;
/* FIXME: this should've work,
but refresh() is called after this write :-( */
win32APICALL(WriteConsoleOutput (hNew, pchar, csize, c0, &rect));
-
+
free (pchar);
}
/* Client interface for General purpose OS/2 console save/restore server.
1997 Alexander Dong <ado@software-ag.de>
Having the same interface as its Linux counterpart:
- Copyright (C) 1994 Janne Kukonlehto <jtklehto@stekt.oulu.fi>
-
+ Copyright (C) 1994 Janne Kukonlehto <jtklehto@stekt.oulu.fi>
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
*/
#include <config.h>
n = col * row * 2;
VioWrtCellStr ((PCH) scr_buffer, (USHORT) n, 0, 0, 0); /* Write it back */
break;
- default:
+ default:
/* This is not possible, but if we are here, just save the screen */
handle_console(CONSOLE_SAVE);
break;
char *c_dir = malloc (strlen(a_dir) + 4);
strcpy (c_dir, a_dir);
strcat (c_dir, "\\*");
-
+
dd_dir->d_handle = FindFirstFile (c_dir, &wfd);
if (dd_dir->d_handle == INVALID_HANDLE_VALUE) {
err = GetLastError();
dd_dir->d_size = wfd.nFileSizeLow;
strcpy (dd_dir->d_name, wfd.cFileName);
dd_dir->d_first = 1;
-
+
free (c_dir);
return dd_dir;
}
{
int err;
WIN32_FIND_DATA wfd;
-
+
if (dd_dir->d_first) {
dd_dir->d_first = 0;
return dd_dir;
}
-
+
if(!FindNextFile (dd_dir->d_handle, &wfd)) {
err = GetLastError();
switch (err) {
dd_dir->d_size = wfd.nFileSizeLow;
strcpy (dd_dir->d_name, wfd.cFileName);
return dd_dir;
-}
+}
int closedir (DIR *dd_dir)
{
strcpy (c_dir, a_dir);
strcat (c_dir, "\\*.*");
dd_dir->d_handle = (unsigned long*) HDIR_CREATE;
-
- rc = DosFindFirst(c_dir,
+
+ rc = DosFindFirst(c_dir,
(PHDIR) &dd_dir->d_handle,
FILE_SYSTEM | FILE_HIDDEN | FILE_DIRECTORY,
(PVOID) &FindBuffer,
case ERROR_BUFFER_OVERFLOW:
errno = ENOMEM;
break;
- default:
+ default:
errno = EINVAL;
break;
}
return NULL;
}
dd_dir->d_attr = FindBuffer.attrFile;
- dd_dir->d_time = dd_dir->d_date = 10;
+ dd_dir->d_time = dd_dir->d_date = 10;
dd_dir->d_size = FindBuffer.cbFile;
strcpy (dd_dir->d_name, FindBuffer.achName);
dd_dir->d_first = 1;
-
+
free (c_dir);
return dd_dir;
}
FILEFINDBUF3 FindBuffer = {0};
ULONG FileCount = 1;
DIR *ret_dir = (DIR*) malloc (sizeof(DIR));
-
+
if (dd_dir->d_first) {
dd_dir->d_first = 0;
return dd_dir;
}
- rc = DosFindNext((HDIR) dd_dir->d_handle,
+ rc = DosFindNext((HDIR) dd_dir->d_handle,
(PVOID) &FindBuffer,
sizeof(FILEFINDBUF3),
&FileCount);
case ERROR_BUFFER_OVERFLOW:
errno = ENOMEM;
break;
- default:
+ default:
errno = EINVAL;
break;
}
return NULL;
}
- ret_dir->d_attr = FindBuffer.attrFile;
+ ret_dir->d_attr = FindBuffer.attrFile;
ret_dir->d_time = ret_dir->d_date = 10;
ret_dir->d_size = FindBuffer.cbFile;
strcpy (ret_dir->d_name, FindBuffer.achName);
return ret_dir;
-}
+}
int closedir (DIR *dd_dir)
{
/* Ch-Drive command for Windows NT and OS/2
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
Bug:
the code will not work if you have more drives than those that
- can fit in a panel.
+ can fit in a panel.
*/
#include <config.h>
#define B_DRIVE_BASE 100
#define MAX_LGH 13 /* Length for drives */
-static void drive_cmd()
+static void drive_cmd()
{
int i, nNewDrive, nDrivesAvail;
char szTempBuf[7], szDrivesAvail[27*4], *p;
/* Create Dialog */
do_refresh ();
-
+
m_drv = ((nDrivesAvail > MAX_LGH) ? MAX_LGH: nDrivesAvail);
/* Center on x, relative to panel */
x_pos = this_panel->widget.x + (this_panel->widget.cols - m_drv*3)/2 + 2;
XV_WLAY_RIGHTOF);
}
- run_dlg(drive_dlg);
+ run_dlg(drive_dlg);
/* do action */
if (drive_dlg->ret_value != B_CANCEL) {
int errocc = 0; /* no error */
int rtn;
char drvLetter;
-
+
/* Set the Panel to Directory listing mode first */
int is_right=(this_panel==right_panel);
#else
rtn = DosSetDefaultDisk(nNewDrive + 1);
#endif
- if (rtn == -1)
+ if (rtn == -1)
errocc = 1;
else {
getcwd (this_panel->cwd, sizeof (this_panel->cwd)-2);
}
void drive_cmd_b()
-{
+{
this_panel = right_panel;
drive_cmd();
}
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Bugs:
Have trouble with non-US keyboards, "Alt-gr"+keys (API tells CTRL-ALT is pressed)
{ KEY_F(10), VK_F10 },
{ KEY_F(11), VK_F11 },
{ KEY_F(12), VK_F12 },
- { KEY_F(13), VK_F13 },
+ { KEY_F(13), VK_F13 },
{ KEY_F(14), VK_F14 },
{ KEY_F(15), VK_F15 },
{ KEY_F(16), VK_F16 },
{ KEY_F(17), VK_F17 },
{ KEY_F(18), VK_F18 },
{ KEY_F(19), VK_F19 },
- { KEY_F(20), VK_F20 },
- { KEY_IC, VK_INSERT },
+ { KEY_F(20), VK_F20 },
+ { KEY_IC, VK_INSERT },
{ KEY_DC, VK_DELETE },
{ KEY_BACKSPACE, VK_BACK },
{ ALT('*'), VK_MULTIPLY },
{ ALT('+'), VK_ADD },
{ ALT('-'), VK_SUBTRACT },
-
+
{ ALT('\t'), VK_PAUSE }, /* Added to make Complete work press Pause */
{ ESC_CHAR, VK_ESCAPE },
{ 0, 0}
-};
+};
/* init_key - Called in main.c to initialize ourselves
Get handle to console input
int ctrl_pressed ()
{
- if(dwSaved_ControlState & RIGHT_ALT_PRESSED) return 0;
+ if(dwSaved_ControlState & RIGHT_ALT_PRESSED) return 0;
/* The line above fixes the BUG with the AltGr Keys*/
return dwSaved_ControlState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED);
}
int shift_pressed ()
{
- if(dwSaved_ControlState & RIGHT_ALT_PRESSED) return 0;
+ if(dwSaved_ControlState & RIGHT_ALT_PRESSED) return 0;
/* The line above fixes the BUG with the AltGr Keys*/
return dwSaved_ControlState & SHIFT_PRESSED;
}
{
int i;
- for (i = 0; key_table[i].vkcode != 0; i++)
+ for (i = 0; key_table[i].vkcode != 0; i++)
if (a_vkc == key_table[i].vkcode) {
return key_table[i].key_code;
}
if (!dw)
return 0;
}
-
+
do {
win32APICALL(ReadConsoleInput(hConsoleInput, &ir, 1, &dw));
switch (ir.EventType) {
evSaved_Event.type = GPM_DOWN | GPM_DOUBLE;
break;
};
- return 0;
+ return 0;
}
} while (!no_delay);
return 0;
dirty++;
vfs_timeout_handler ();
-
+
c = block ? getch_with_delay () : get_key_code (1);
if (!c) {
{
Gpm_Event ev;
int key;
-
+
while ((key = get_event (&ev, 0, 1)) == 0)
;
return key;
}
-/*
+/*
is_idle - A function to check if we're idle.
- It checks for any waiting event (that can be a Key, Mouse event,
- and other internal events like focus or menu)
+ It checks for any waiting event (that can be a Key, Mouse event,
+ and other internal events like focus or menu)
*/
int is_idle (void)
{
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
ALT(F12): 8c00
Mapping for ALT(key_code):
- For Mapping with normal keys, only the scan code can be
+ For Mapping with normal keys, only the scan code can be
used. (see struct ALT_table)
-
+
Special keys:
ENTER (number block): 0xaaaaE00D
+ (number block): 0xaaaa4E2B Normal: 1B2B
{ KEY_F(11), 0x85 },
{ KEY_F(12), 0x86 },
{ 0, 0}
-};
+};
struct {
{ ALT(KEY_F(11)), 0x8B },
{ ALT(KEY_F(12)), 0x8C },
{ 0, 0}
-};
+};
struct {
{ KEY_HOME, 0x47 },
{ KEY_END, 0x4F },
{ 0, 0}
-};
+};
/* init_key -- to make linker happy */
{
if (!seq_append)
seq_append = seq_buffer;
-
+
if (seq_append == &(seq_buffer [sizeof (seq_buffer)-2]))
return 0;
*(seq_append++) = c;
if (inp_ch == 0) {
return 0;
}
- }
+ }
if (no_delay) {
return (VKtoCurses(inp_ch));
{
int ctrlState = 0;
int altState = 0;
-
+
int fsState;
char scanCode;
char asciiCode;
scanCode = (char) ((a_vkc & 0x0000FFFF) >> 8);
asciiCode = (char) (a_vkc & 0x000000FF);
-
+
ctrlState = (fsState & CTRL_PRESSED);
altState = (fsState & ALT_PRESSED);
/* Scan Movement codes */
if (asciiCode == 0) {
/* Replace key code with that in table */
- for (i=0; movement[i].vkcode != 0 || movement[i].key_code != 0; i++)
- if (scanCode == movement[i].vkcode)
+ for (i=0; movement[i].vkcode != 0 || movement[i].key_code != 0; i++)
+ if (scanCode == movement[i].vkcode)
return (movement[i].key_code);
}
if (asciiCode == 0) {
/* Function-key detected */
- for (i=0; fkt_table[i].vkcode != 0 || fkt_table[i].key_code != 0; i++)
- if (scanCode == fkt_table[i].vkcode)
+ for (i=0; fkt_table[i].vkcode != 0 || fkt_table[i].key_code != 0; i++)
+ if (scanCode == fkt_table[i].vkcode)
return (fkt_table[i].key_code);
/* ALT - KEY */
/* if (altState) */ {
- for (i=0; ALT_table[i].vkcode != 0 || ALT_table[i].key_code != 0; i++)
- if (scanCode == ALT_table[i].vkcode)
+ for (i=0; ALT_table[i].vkcode != 0 || ALT_table[i].key_code != 0; i++)
+ if (scanCode == ALT_table[i].vkcode)
return (ALT_table[i].key_code);
}
}
dirty++;
vfs_timeout_handler ();
-
+
c = block ? getch_with_delay () : get_key_code (1);
if (!c) {
/* Code is 0, so this is a Control key or mouse event */
{
Gpm_Event ev;
int key;
-
+
while ((key = get_event (&ev, 0, 1)) == 0)
;
return key;
}
-/*
+/*
is_idle - A function to check if we're idle.
- It checks for any waiting event (that can be a Key, Mouse event,
- and other internal events like focus or menu)
+ It checks for any waiting event (that can be a Key, Mouse event,
+ and other internal events like focus or menu)
*/
int is_idle (void)
{
/* Slang interface to the Midnight Commander for Windows NT and OS/2
This emulates some features of ncurses on top of slang
S-lang is not fully consistent between its Unix and non-Unix versions.
-
-
+
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
void slang_init (void)
{
SLtt_get_terminfo ();
- SLang_init_tty (XCTRL('c'), 1, 0);
+ SLang_init_tty (XCTRL('c'), 1, 0);
slang_prog_mode ();
load_terminfo_keys ();
}
last_x = SLsmg_get_column ();
last_y = SLsmg_get_row ();
-
+
if (ch == 0)
ch = ACS_HLINE;
/* No terminals on NT, make default color */
if (!disable_colors)
SLtt_Use_Ansi_Colors = 1;
-
+
/* Setup emulated colors */
if (SLtt_Use_Ansi_Colors){
/* DO NOT TRANSLATE WITH gettext SYNTAX coloring will be broken */
SLsmg_set_color (color);
return;
}
-
+
if (color & A_BOLD){
if (color == A_BOLD)
SLsmg_set_color (A_BOLD);
else
SLsmg_set_color (color);
}
-
+
void load_terminfo_keys ()
{
}
/* trace_nt.c - Debugging routines
for Midnight Commander, under Win32
-
+
Written 951215 by Juan Grigera <grigera@isis.unlp.edu.ar>
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
#ifdef HAVE_TRACE
#include "trace_nt.h"
/* Global variables */
-int __win32_tracing_enabled = 1;
+int __win32_tracing_enabled = 1;
static int _win32_tracing_started = 0;
static FILE *__win32_trace_f = NULL;
/*
void _win32InitTrace()
- This func will open file TRACE_FILE for output and add _win32EndTrace to onexit
+ This func will open file TRACE_FILE for output and add _win32EndTrace to onexit
list of funcs.
*/
static void _win32InitTrace()
_win32_tracing_started = 0;
if (__win32_trace_f)
fclose (__win32_trace_f);
- }
+ }
}
#endif
#endif
- if(__win32_trace_f)
+ if(__win32_trace_f)
fprintf (__win32_trace_f, "%s\n", vp);
}
/*
- void SetTrace (int trace)
+ void SetTrace (int trace)
Control debug output. Turn it of or on.
trace: 0 = off, 1 = on.
*/
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* ------------------------------------------------------------------------------------------ *
/************************/
/* Macros
- ------
+ ------
win32Trace(x) - Trace macro. Use double in parenthesis for x. Same args as printf.
- win32ASSERT(x) - assert macro, but will not abort program and output sent to trace routine.
- win32APICALL(x) - Use to enclose a Win32 system call that should return TRUE.
- win32APICALL_HANDLE(h,api) - Use to enclose a Win32 system call that should return a handle.
+ win32ASSERT(x) - assert macro, but will not abort program and output sent to trace routine.
+ win32APICALL(x) - Use to enclose a Win32 system call that should return TRUE.
+ win32APICALL_HANDLE(h,api) - Use to enclose a Win32 system call that should return a handle.
*/
#define win32Trace(x) if (__win32_tracing_enabled) _win32Trace x
#define win32ASSERT(x) if (!(x)) _win32DebugAssertionFailed (#x, __LINE__, __FILE__)
#define TraceOff _win32TraceOff
/* Global variables */
-extern int __win32_tracing_enabled;
+extern int __win32_tracing_enabled;
#else
/************************/
/************************/
/* Wipe-out these macros */
-#define win32Trace(x)
-#define win32ASSERT(x)
+#define win32Trace(x)
+#define win32ASSERT(x)
#define win32APICALL(x) x
#define win32APICALL_HANDLE(h,api) h=api;
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* .ado: temp. turn out */
if (as_shell_command) {
/* It is only the shell, /c will not work */
- if (command)
+ if (command)
spawnlp (P_WAIT, shell, shell, "/c", command, (char *) 0);
else
spawnlp (P_WAIT, shell, (char *) 0);
#endif
if (as_shell_command) {
if (!access(command, 0)) {
- switch(win32_GetEXEType (shell)) {
+ switch(win32_GetEXEType (shell)) {
case EXE_win16: /* Windows 3.x archive or OS/2 */
case EXE_win32GUI: /* NT or Chicago GUI API */
spawnlp (P_NOWAIT, shell, shell, "/c", command, (char *) 0); /* don't wait for GUI programs to end */
- break;
+ break;
case EXE_otherCUI: /* DOS COM, MZ, ZM, Phar Lap */
case EXE_win32CUI: /* NT or Chicago Console API, also OS/2 */
case EXE_Unknown:
*/
char* get_default_shell()
{
- if (win32_GetPlatform() == OS_WinNT)
+ if (win32_GetPlatform() == OS_WinNT)
return "cmd.exe";
else
return "command.com";
continue;
}
- /* Handle `../' or trailing `..' by itself.
+ /* Handle `../' or trailing `..' by itself.
Remove the previous ?/ part with the exception of
../, which we should leave intact. */
if (path[i + 1] == '.' && (path[i + 2] == PATH_SEP || !path[i + 2])) {
}
#ifndef USE_VFS
-/*
+/*
int mc_rmdir (char *path);
Fix for Win95 UGLY BUG in rmdir: it will return ENOACCESS instead
of ENOTEMPTY.
return errCode;
}
-/*
+/*
int mc_unlink (char *pathName)
For Windows 95 and NT, files should be able to be deleted even
if they don't have write-protection. We should build a question box
}
}
if (rc == TRUE) return 0;
- else
+ else
return -1;
}
#endif /*USE_VFS*/
/* KBytes available */
myfs_stats->avail = (unsigned int)( ((double)lpSectorsPerCluster * lpBytesPerSector * lpFreeClusters) / 1024 );
-
+
/* KBytes total */
- myfs_stats->total = (unsigned int)( ((double)lpSectorsPerCluster * lpBytesPerSector * lpClusters) / 1024 );
+ myfs_stats->total = (unsigned int)( ((double)lpSectorsPerCluster * lpBytesPerSector * lpClusters) / 1024 );
myfs_stats->nfree = lpFreeClusters;
myfs_stats->nodes = lpClusters;
int gettimeofday (struct timeval* tvp, void *p)
{
if (p != NULL)
- return 0;
-
- /* Since MC only calls this func from get_random_hint we return
+ return 0;
+
+ /* Since MC only calls this func from get_random_hint we return
some value, not exactly the "correct" one */
tvp->tv_sec = GetTickCount()/1000; /* Number of milliseconds since Windows //started*/
tvp->tv_usec = GetTickCount();
/* FAKE functions */
-int
+int
look_for_exe(const char* pathname)
{
int j;
for (j=0; j<lgh-4; j++) {
p++;
} /* endfor */
- if (!stricmp(p, ".exe") ||
- !stricmp(p, ".bat") ||
- !stricmp(p, ".com") ||
+ if (!stricmp(p, ".exe") ||
+ !stricmp(p, ".bat") ||
+ !stricmp(p, ".com") ||
!stricmp(p, ".cmd")) {
return 1;
}
return 0;
}
-int
+int
lstat (const char* pathname, struct stat *buffer)
{
int rc = stat (pathname, buffer);
return rc;
}
-int getuid ()
+int getuid ()
{
/* SID sid;
LookupAccountName (NULL, &sid...
return 0;
}
-int getgid ()
+int getgid ()
{
return 0;
}
// Duplicate copy of original stdout back into stdout
if(_dup2(std_sav[1], _fileno(stdout)) != 0)
exit (1);
- // Close duplicate copy of original stdout and stdin
+ // Close duplicate copy of original stdout and stdin
close(std_sav[0]);
close(std_sav[1]);
while ((i = _read (inhandle, buffer,
- (inlen == -1 || inlen > 8192)
+ (inlen == -1 || inlen > 8192)
? 8192 : inlen)) > 0) {
write (pipe0 [1], buffer, i);
if (inlen != -1) {
int mc_doublepclose (int pipe, pid_t pid)
{
int status = 0;
-
+
close (pipe);
_cwait ( &status, pid, 0);
- return status;
+ return status;
}
/*hacks to get it compile, remove these after vfs works */
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* Creates a pipe to hold standard error for a later analysis. */
/* The pipe can hold 4096 bytes. Make sure no more is written */
/* or a deadlock might occur. */
-void
+void
open_error_pipe (void)
{
return;
}
-void
+void
close_error_pipe (int error, char *text)
{
return;
}
-void
+void
check_error_pipe (void)
{
char error[MAX_PIPE_SIZE];
}
-static int
+static int
StartWindowsProg (char *name, SHORT type)
{
#if 0 /* FIXME: PM DDL's should be loaded (or not loaded) at run time */
pDetails.progt.progc = PROG_31_ENHSEAMLESSCOMMON ;
break;
}
- WinStartApp(NULLHANDLE,
- &pDetails,
- NULL,
- NULL,
+ WinStartApp(NULLHANDLE,
+ &pDetails,
+ NULL,
+ NULL,
SAF_INSTALLEDCMDLINE|SAF_STARTCHILDAPP) ;
#endif
return 0;
}
-static int
+static int
os2_system (int as_shell_command, const char *shell, const char *command, char *parm);
-/*
+/*
as_shell_command = 1: If a program is started during input line, CTRL-O
- or RETURN
+ or RETURN
= 0: F3, F4
*/
-int
+int
my_system (int as_shell_command, const char *shell, const char *command)
{
char *sh; /* This is the shell -- always! */
sh = get_default_shell();
if (strcmp(sh, shell)) {
- /*
+ /*
Not equal -- That means: shell is the program and command is the
- parameter
+ parameter
*/
cmd = (char *) shell;
parm = (char *) command;
if (command[i] == ' ') {
temp[i] = (char) 0;
length--;
- } else
+ } else
break;
}
if (i==-1) {
return os2_system (as_shell_command, sh, cmd, parm);
}
-static int
-ux_startp (const char *shell, const char *command, const char *parm)
+static int
+ux_startp (const char *shell, const char *command, const char *parm)
{
if (parm) {
- spawnlp (P_WAIT,
- (char *) shell,
- (char *) shell,
- "/c",
- (char *) command,
+ spawnlp (P_WAIT,
+ (char *) shell,
+ (char *) shell,
+ "/c",
+ (char *) command,
(char *) parm,
(char *) 0);
} else {
- spawnlp (P_WAIT,
- (char *) shell,
- (char *) shell,
- "/c",
- (char *) command,
+ spawnlp (P_WAIT,
+ (char *) shell,
+ (char *) shell,
+ "/c",
+ (char *) command,
(char *) 0);
}
return 0;
}
-static int
+static int
os2_system (int as_shell_command, const char *shell, const char *command, char *parm)
{
register int i, j;
APIRET rc = NO_ERROR; /* Return Code */
char pathValue[5] = "PATH"; /* For DosSearchPath */
UCHAR searchResult[MC_MAXPATHLEN * 2 + 1]; /* For DosSearchPath */
-
+
char *cmdString;
char *postFix[3];
char *line;
if (command == NULL) {
/* .ado: just start a shell, we don't need the parameter */
- spawnl (P_WAIT,
- (char *) shell,
- (char *) shell,
- (char *) command, (char *) 0);
+ spawnl (P_WAIT,
+ (char *) shell,
+ (char *) shell,
+ (char *) command, (char *) 0);
return 0;
}
memset(&StartData, 0, sizeof(StartData)) ;
- StartData.Length = sizeof(StartData);
+ StartData.Length = sizeof(StartData);
StartData.Related = SSF_RELATED_CHILD;
StartData.FgBg = SSF_FGBG_BACK;
- StartData.TraceOpt = SSF_TRACEOPT_NONE;
- StartData.PgmTitle = NULL;
- StartData.TermQ = NULL;
+ StartData.TraceOpt = SSF_TRACEOPT_NONE;
+ StartData.PgmTitle = NULL;
+ StartData.TermQ = NULL;
StartData.InheritOpt = SSF_INHERTOPT_PARENT;
- StartData.IconFile = 0;
- StartData.PgmHandle = 0;
- StartData.PgmControl = SSF_CONTROL_VISIBLE ;
- StartData.ObjectBuffer = ObjBuf;
- StartData.ObjectBuffLen = 100;
+ StartData.IconFile = 0;
+ StartData.PgmHandle = 0;
+ StartData.PgmControl = SSF_CONTROL_VISIBLE ;
+ StartData.ObjectBuffer = ObjBuf;
+ StartData.ObjectBuffLen = 100;
StartData.PgmInputs = parm;
postFix[0] = ".exe";
sizeof(searchResult));
}
free (line);
- } else {
+ } else {
/* Just search */
rc = DosSearchPath((SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY),
(PSZ) pathValue,
} else {
/* It's not a known exe type or it's a CMD/BAT file */
i = strlen(searchResult);
- if ((toupper(searchResult[--i]) == 'T') &&
- (toupper(searchResult[--i]) == 'A') &&
- (toupper(searchResult[--i]) == 'B') &&
+ if ((toupper(searchResult[--i]) == 'T') &&
+ (toupper(searchResult[--i]) == 'A') &&
+ (toupper(searchResult[--i]) == 'B') &&
(searchResult[--i] == '.') ) {
StartData.SessionType = PROG_WINDOWEDVDM;
rc = DosStartSession(&StartData, &SessionID, &pid) ;
continue;
}
- /* Handle `../' or trailing `..' by itself.
+ /* Handle `../' or trailing `..' by itself.
Remove the previous ?/ part with the exception of
../, which we should leave intact. */
if (path[i + 1] == '.' && (path[i + 2] == PATH_SEP || !path[i + 2])) {
}
-void
+void
my_statfs (struct my_statfs *myfs_stats, char *path)
{
PFSALLOCATE pBuf;
/* KBytes available */
myfs_stats->avail = pBuf->cSectorUnit * pBuf->cUnitAvail * pBuf->cbSector / 1024;
/* KBytes total */
- myfs_stats->total = pBuf->cSectorUnit * pBuf->cUnit * pBuf->cbSector / 1024;
+ myfs_stats->total = pBuf->cSectorUnit * pBuf->cUnit * pBuf->cbSector / 1024;
myfs_stats->nfree = pBuf->cUnitAvail;
myfs_stats->nodes = pBuf->cbSector;
lghBuf = sizeof(FSINFO);
pFsInfo = (PFSINFO) malloc(lghBuf);
- rc = DosQueryFSInfo(0L,
- FSIL_VOLSER,
- (PVOID) pFsInfo,
+ rc = DosQueryFSInfo(0L,
+ FSIL_VOLSER,
+ (PVOID) pFsInfo,
lghBuf);
/* Get name */
myfs_stats->device = strdup(pFsInfo->vol.szVolLabel); /* Label of the Disk */
szDeviceName[0] = (UCHAR) (diskNum + (ULONG) 'A' - 1);
/* Now get the type of the disk */
- rc = DosQueryFSAttach(szDeviceName,
- 0L,
- FSAIL_QUERYNAME,
- pfsqBuffer,
+ rc = DosQueryFSAttach(szDeviceName,
+ 0L,
+ FSAIL_QUERYNAME,
+ pfsqBuffer,
&cbBuffer);
pszFSDName = pfsqBuffer->szName + pfsqBuffer->cbName + 1;
free(pFsInfo);
}
-int
+int
gettimeofday (struct timeval* tvp, void *p)
{
DATETIME pdt = {0};
if (p != NULL) /* what is "p"? */
- return 0;
-
- /* Since MC only calls this func from get_random_hint we return
+ return 0;
+
+ /* Since MC only calls this func from get_random_hint we return
* some value, not exactly the "correct" one
*/
DosGetDateTime(&pdt);
/* FAKE functions */
-int
+int
look_for_exe(const char* pathname)
{
int j;
for (j=0; j<lgh-4; j++) {
p++;
}
- if (!stricmp(p, ".exe") ||
- !stricmp(p, ".bat") ||
- !stricmp(p, ".com") ||
+ if (!stricmp(p, ".exe") ||
+ !stricmp(p, ".bat") ||
+ !stricmp(p, ".com") ||
!stricmp(p, ".cmd")) {
return 1;
}
return 0;
}
-int
+int
lstat (const char* pathname, struct stat *buffer)
{
int rc = stat (pathname, buffer);
return rc;
}
-int
-getuid ()
+int
+getuid ()
{
return 0;
}
-int
-getgid ()
+int
+getgid ()
{
return 0;
}
-int
+int
readlink (char* path, char* buf, int size)
{
return -1;
}
-int
+int
symlink (char *n1, char *n2)
{
return -1;
}
-int
+int
link (char *p1, char *p2)
{
return -1;
}
-int
+int
chown (char *path, int owner, int group)
{
return -1;
}
-int
+int
mknod (char *path, int mode, int dev)
{
return -1;
}
-void
+void
init_uid_gid_cache (void)
{
return;
}
-int
+int
mc_doublepopen (int inhandle, int inlen, pid_t *the_pid, char *command, ...)
{
return 0;
}
-int
+int
mc_doublepclose (int pipe, pid_t pid)
{
return 0;
return NULL;
}
-int
+int
vfs_current_is_extfs (void)
{
return 0;
}
-int
+int
vfs_file_is_ftp (char *filename)
{
return 0;
/* First set the default drive */
if (lgh > 1) {
if (pathname[1] == ':') {
- ret = DosSetDefaultDisk(toupper(pathname[0]) - 'A' + 1);
+ ret = DosSetDefaultDisk(toupper(pathname[0]) - 'A' + 1);
}
}
/* After that, set the current dir! */
}
return ret;
}
-
+
int
mc_chmod(char *pathName, int unxmode)
{
case ERROR_INVALID_PARAMETER:
errCode = EINVAL;
break;
- default:
+ default:
errCode = EINVAL;
break;
}
int
mc_unlink(char *pathName)
{
- /* Use OS/2 API to delete a file, if the file is set as read-only,
+ /* Use OS/2 API to delete a file, if the file is set as read-only,
the file will be deleted without asking the user! */
APIRET rc;
rc = DosDelete(pathName);
APIRET rc;
char pathValue[5] = "PATH";
UCHAR searchResult[MC_MAXPATHLEN + 1];
-
+
/* EPM is not always be installed */
rc = DosSearchPath((SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY),
(PSZ) pathValue,
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
return (platform ? platform : (platform = win32_GetVersionEx()) );
}
-/* int win32_GetVersionEx ()
- intended for use by win32_GetPlatform only
+/* int win32_GetVersionEx ()
+ intended for use by win32_GetPlatform only
*/
int win32_GetVersionEx ()
{
return EXE_Unknown; /* FIXME: what is "NATIVE??" */
default:
win32Trace(("Unknown type %u.\n", image_optional_header.Subsystem));
- return EXE_Unknown;
+ return EXE_Unknown;
}
#else
return EXE_Unknown;
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Prototypes */
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
#include <windows.h>
0 if not
Note: Code taken from MSKbase Number: Q118626.
-
+
To determine whether or not a user is an administrator, you need to examine
the user's access token with GetTokenInformation(). The access token
represents the user's privileges and the groups to which the user belongs.
}
-int geteuid ()
+int geteuid ()
{
if (winnt_IsAdministrator())
return 0;
need. Use slang.h for that purpose. */
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
/* These quantities are main_types for byte-compiled code. They are used
- * by the inner_interp routine. The ones commented out with a // are
+ * by the inner_interp routine. The ones commented out with a // are
* actually defined in slang.h because they are also used as the main_type in
* the name table.
*/
{
unsigned char main_type;
unsigned char sub_type;
- union
+ union
{
struct SLBlock_Type *blk;
int i_blk;
extern void SLadd_variable(char *);
extern void SLang_clear_error(void);
extern void SLarray_info (void);
-extern int SLPreprocess_Only; /* preprocess instead of
+extern int SLPreprocess_Only; /* preprocess instead of
* bytecompiling
*/
#ifndef _JD_MACROS_H_
#define _JD_MACROS_H_
-/* This file defines some macros that I use with programs that link to
+/* This file defines some macros that I use with programs that link to
* the slang library.
*/
#ifdef HAVE_MEMORY_H
# include <memory.h>
-#endif
+#endif
#ifndef SLMEMSET
# ifdef HAVE_MEMSET
/* -*- mode: C; mode: fold; -*- */
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
# define VOID unsigned char
# endif
#endif
-
+
#if 1
typedef int (*FVOID_STAR)(void);
#else
# define FVOID_STAR VOID_STAR
#endif
-
+
#if defined(msdos) && !defined(DOS386) && !defined(__GO32__) && !defined(__WIN32__)
# define SLFREE(buf) farfree((void far *)(buf))
# define SLMALLOC(x) farmalloc((unsigned long) (x))
# define SLCALLOC(n, m) SLdebug_calloc((unsigned long) (n), (unsigned long)(m))
# define SLREALLOC(p, x) SLdebug_realloc((unsigned char *)(p), (unsigned long)(x))
#endif /* SL_MALLOC_DEBUG */
-
+
extern unsigned char *SLdebug_malloc (unsigned long);
extern unsigned char *SLdebug_calloc (unsigned long, unsigned long);
extern unsigned char *SLdebug_realloc (unsigned char *, unsigned long);
extern char *SLstrcpy(register char *, register char *);
extern int SLstrcmp(register char *, register char *);
extern char *SLstrncpy(char *, register char *, register int);
-
+
extern void SLmemset (char *, char, int);
extern char *SLmemchr (register char *, register char, register int);
extern char *SLmemcpy (char *, char *, int);
#ifdef float64
# undef float64
#endif
-
+
#ifndef FLOAT64_TYPEDEFED
# define FLOAT64_TYPEDEFED
typedef double float64;
char name[SLANG_MAX_NAME_LEN + 2]; /* [0] is hash */
unsigned char sub_type;
-
+
/* Values for main_type may be as follows. The particlular values are
* for compatability.
*/
{
long name; /* file name, string address, ... */
long handle; /* FILE *, string address, etc... */
-
+
char *ptr; /* input pointer to next line in object
- * to be read.
+ * to be read.
*/
/* Things below here are used by S-Lang. */
int type; /* 'F' = file, 'S' = String, etc.. */
int n; /* line number, etc... */
char token[256]; /* token to be parsed */
int ofs; /* offset from buf where last read
- * took place
+ * took place
*/
int top_level; /* 1 if at top level of parsing */
} SLang_Load_Type;
# define NO_PROTOTYPES
# endif
#endif
-
-#ifndef NO_PROTOTYPES
+
+#ifndef NO_PROTOTYPES
# define _PROTO(x) x
#else
# define _PROTO(x) ()
typedef struct SL_OOBinary_Type
{
unsigned char sub_type; /* partner type for binary op */
-
+
/* The function take the binary op as first argument, the operand types
- * form the second and third parameters and the last two parameters are
+ * form the second and third parameters and the last two parameters are
* pointers to the objects themselves. It is up to the function to push
- * the result on the stack. It must return 1 if it handled the operation
+ * the result on the stack. It must return 1 if it handled the operation
* return zero if the operation is not defined.
*/
- int (*binary_function)_PROTO((int, unsigned char, unsigned char,
+ int (*binary_function)_PROTO((int, unsigned char, unsigned char,
VOID_STAR, VOID_STAR));
struct SL_OOBinary_Type *next;
int (*unary_function)_PROTO((int, unsigned char, VOID_STAR));
/* unary operation function */
SL_OOBinary_Type *binary_ops;
-
+
int (*copy_function)_PROTO((unsigned char, VOID_STAR));
/* This function is called do make a copy of the object */
} SLang_Class_Type;
extern SLang_Class_Type *SLang_Registered_Types[256];
-
+
typedef struct
{
unsigned char main_type; /* SLANG_RVARIABLE, etc.. */
}
SLuser_Object_Type;
-
+
/*}}}*/
/*{{{ Interpreter Function Prototypes */
/* Non zero if error occurs. Must be reset to zero to continue. */
extern int SLang_Traceback;
- /* If non-zero, dump an S-Lang traceback upon error. Available as
+ /* If non-zero, dump an S-Lang traceback upon error. Available as
_traceback in S-Lang. */
extern char *SLang_User_Prompt;
extern void (*SLang_Exit_Error_Hook)(char *);
extern void SLang_exit_error (char *);
extern void (*SLang_Dump_Routine)(char *);
- /* Called if S-Lang traceback is enabled as well as other debugging
+ /* Called if S-Lang traceback is enabled as well as other debugging
routines (e.g., trace). By default, these messages go to stderr. */
-
+
extern void (*SLang_Interrupt)(void);
- /* function to call whenever inner interpreter is entered. This is
+ /* function to call whenever inner interpreter is entered. This is
a good place to set SLang_Error to USER_BREAK. */
extern void (*SLang_User_Clear_Error)(void);
/* function that gets called when '_clear_error' is called. */
- extern int (*SLang_User_Open_Slang_Object)(SLang_Load_Type *);
+ extern int (*SLang_User_Open_Slang_Object)(SLang_Load_Type *);
extern int (*SLang_User_Close_Slang_Object)(SLang_Load_Type *);
/* user defined loading routines. */
/* Functions: */
- extern int init_SLang(void);
+ extern int init_SLang(void);
/* This function is mandatory and must be called by all applications */
extern int init_SLfiles(void);
/* called if fputs, fgets, etc are need in S-Lang */
/* unix system functions chmod, stat, etc... */
extern int init_SLmatrix(void);
-
+
extern int SLang_add_table(SLang_Name_Type *, char *);
- /* add application dependent function table p1 to S-Lang. A name p2 less
- * than 32 characters must also be supplied.
+ /* add application dependent function table p1 to S-Lang. A name p2 less
+ * than 32 characters must also be supplied.
* Returns 0 upon failure or 1 upon success. */
extern int SLang_add_global_variable (char *);
extern void SLang_restart(int);
/* should be called if an error occurs. If the passed integer is
- * non-zero, items are popped off the stack; otherwise, the stack is
+ * non-zero, items are popped off the stack; otherwise, the stack is
* left intact. Any time the stack is believed to be trashed, this routine
* should be called with a non-zero argument (e.g., if setjmp/longjmp is
- * called). */
+ * called). */
extern void SLang_byte_compile_file(char *, int *);
/* takes a file of S-Lang code and ``byte-compiles'' it for faster
* loading. The new filename is equivalent to the old except that a `c' is
- * appended to the name. (e.g., init.sl --> init.slc). If the second
+ * appended to the name. (e.g., init.sl --> init.slc). If the second
* parameter is non-zero, preprocess the file only.
*/
extern void SLang_autoload(char *, char *);
/* Automatically load S-Lang function p1 from file p2. This function
is also available via S-Lang */
-
+
extern char *SLang_load_string(char *);
/* Like SLang_load_file except input is from a null terminated string. */
-
+
extern void SLang_do_pop(void);
/* pops item off stack and frees any memory associated with it */
-
+
extern int SLang_pop_integer(int *);
/* pops integer *p0 from the stack. Returns 0 upon success and non-zero
* if the stack is empty or a type mismatch occurs, setting SLang_Error.
/* pops string *p0 from stack. If *p1 is non-zero, the string must be
* freed after its use. DO NOT FREE p0 if *p1 IS ZERO! Returns 0 upon
* success */
-
+
extern int SLang_pop_float(float64 *, int *, int *);
/* Pops float *p1 from stack. If *p3 is non-zero, *p1 was derived
from the integer *p2. Returns zero upon success. */
-
+
extern SLuser_Object_Type *SLang_pop_user_object (unsigned char);
extern void SLang_free_user_object (SLuser_Object_Type *);
extern void SLang_free_intrinsic_user_object (SLuser_Object_Type *);
extern void SLang_push_user_object (SLuser_Object_Type *);
extern SLuser_Object_Type *SLang_create_user_object (unsigned char);
-
+
extern int SLang_add_unary_op (unsigned char, FVOID_STAR);
extern int SLang_add_binary_op (unsigned char, unsigned char, FVOID_STAR);
extern int SLang_register_class (unsigned char, FVOID_STAR, FVOID_STAR);
extern int SLang_add_copy_operation (unsigned char, FVOID_STAR);
extern long *SLang_pop_pointer(unsigned char *, unsigned char *, int *);
- /* Returns a pointer to object of type *p1,*p2 on top of stack.
+ /* Returns a pointer to object of type *p1,*p2 on top of stack.
If *p3 is non-zero, the Object must be freed after use. */
extern void SLang_push_string(char *);
/* Push string p1 onto stack */
-
+
extern void SLang_push_integer(int);
/* push integer p1 on stack */
extern int SLang_is_defined(char *);
/* Return non-zero is p1 is defined otherwise returns 0. */
-
+
extern int SLang_run_hooks(char *, char *, char *);
/* calls S-Lang function p1 pushing strings p2 and p3 onto the stack
* first. If either string is NULL, it is not pushed. If p1 is not
* defined, 0 is returned. */
extern int SLang_execute_function(char *);
- /* Call S-Lang function p1. Returns 0 if the function is not defined
+ /* Call S-Lang function p1. Returns 0 if the function is not defined
* and 1 if it is.
*/
extern char *SLang_find_name(char *);
/* Return a pointer to p1 in table if it is defined. Returns NULL
- * otherwise. This is useful when one wants to avoid redundant strings.
+ * otherwise. This is useful when one wants to avoid redundant strings.
*/
extern char *SLang_rpn_interpret(char *);
extern void SLang_doerror(char *);
/* set SLang_Error and display p1 as error message */
-
- extern SLuser_Object_Type *SLang_add_array(char *, long *,
- int, int, int, int,
+
+ extern SLuser_Object_Type *SLang_add_array(char *, long *,
+ int, int, int, int,
unsigned char, unsigned char);
- /* This function has not been tested thoroughly yet. Its purpose is to
- * allow a S-Lang procedure to access a C array. For example, suppose that
+ /* This function has not been tested thoroughly yet. Its purpose is to
+ * allow a S-Lang procedure to access a C array. For example, suppose that
* you have an array of 100 ints defined as:
- *
+ *
* int c_array[100];
*
* By calling something like:
* SLang_add_array ("array_name", (long *) c_array, 1, 100, 0, 0,
* 'i', SLANG_IVARIABLE);
*
- * the array can be accessed by the name 'array_name'. This function
- * returns -1 upon failure. The 3rd argument specifies the dimension
+ * the array can be accessed by the name 'array_name'. This function
+ * returns -1 upon failure. The 3rd argument specifies the dimension
* of the array, the 4th, and 5th arguments specify how many elements
- * there are in the x,y, and z directions. The last argument must
- * be one of:
- *
+ * there are in the x,y, and z directions. The last argument must
+ * be one of:
+ *
* SLANG_IVARIABLE: indicates array is writable
* SLANG_RVARIABLE: indicates array is read only
- *
+ *
* Returns NULL upon failure.
*/
extern int SLang_free_array_handle (int);
-/* This routine may be called by application to free array handle created by
+/* This routine may be called by application to free array handle created by
* the application. Returns 0 upon success, -1 if the handle is invalid and
* -2 if the handle is not associated with a C array.
*/
extern char *SLang_extract_list_element(char *, int *, int*);
- extern void SLexpand_escaped_string (register char *, register char *,
+ extern void SLexpand_escaped_string (register char *, register char *,
register char *);
extern SLang_Name_Type *SLang_get_function (char *);
-/* The parameter is the name of a user defined S-Lang function. This
+/* The parameter is the name of a user defined S-Lang function. This
* routine returns NULL if the function does not exist or it returns the
* a pointer to it in an internal S-Lang table. This pointer can be used
* by 'SLexecute_function' to call the function directly from C.
*/
-
+
extern void SLexecute_function(SLang_Name_Type *);
/* This function allows an application to call a S-Lang function from within
- * the C program. The parameter must be non-NULL and must have been
+ * the C program. The parameter must be non-NULL and must have been
* previously obtained by a call to 'SLang_get_function'.
*/
extern void SLroll_stack (int *);
extern int SLatoi(unsigned char *);
extern int SLang_extract_token(char **, char *, int);
-/* returns 0 upon failure and non-zero upon success. The first parameter
- * is a pointer to the input stream which this function will bump along.
- * The second parameter is the buffer where the token is placed. The third
+/* returns 0 upon failure and non-zero upon success. The first parameter
+ * is a pointer to the input stream which this function will bump along.
+ * The second parameter is the buffer where the token is placed. The third
* parameter is used internally by the S-Lang library and should be 0 for
* user applications.
*/
/*}}}*/
/*{{{ SLang getkey interface Functions */
-
+
#ifdef REAL_UNIX_SYSTEM
extern int SLang_TT_Baud_Rate;
extern int SLang_TT_Read_FD;
#endif
-
+
extern int SLang_init_tty (int, int, int);
/* Initializes the tty for single character input. If the first parameter *p1
* is in the range 0-255, it will be used for the abort character;
extern void SLang_set_abort_signal (void (*)(int));
/* If SIGINT is generated, the function p1 will be called. If p1 is NULL
- * the SLang_default signal handler is called. This sets SLang_Error to
+ * the SLang_default signal handler is called. This sets SLang_Error to
* USER_BREAK. I suspect most users will simply want to pass NULL.
*/
extern char *SLang_process_keystring(char *);
-#ifdef SLKEYMAP_OBSOLETE
+#ifdef SLKEYMAP_OBSOLETE
extern int SLang_define_key1(char *, VOID_STAR, unsigned int, SLKeyMap_List_Type *);
/* define key p1 in keymap p4 to invoke function p2. If type p3 is given by
* SLKEY_F_INTRINSIC, p2 is an intrinsic function, else it is a string to be
* passed to the interpreter for evaluation. The return value is important.
- * It returns 0 upon success, -1 upon malloc error, and -2 if the key is
+ * It returns 0 upon success, -1 upon malloc error, and -2 if the key is
* inconsistent. SLang_Error is set upon error. */
#else
extern int SLkm_define_key (char *, FVOID_STAR, SLKeyMap_List_Type *);
#endif
-
+
extern int SLang_define_key(char *, char *, SLKeyMap_List_Type *);
-/* Like define_key1 except that p2 is a string that is to be associated with
+/* Like define_key1 except that p2 is a string that is to be associated with
* a function in the functions field of p3. This routine calls define_key1.
*/
/* Maximum size of display */
#define SLRL_DISPLAY_BUFFER_SIZE 256
-typedef struct
+typedef struct
{
SLang_Read_Line_Type *root, *tail, *last;
unsigned char *buf; /* edit buffer */
int point; /* current editing point */
int tab; /* tab width */
int len; /* current line size */
-
+
/* display variables */
int edit_width; /* length of display field */
int curs_pos; /* current column */
int start_column; /* column offset of display */
int dhscroll; /* amount to use for horiz scroll */
char *prompt;
-
+
FVOID_STAR last_fun; /* last function executed by rl */
/* These two contain an image of what is on the display */
unsigned char upd_buf2[SLRL_DISPLAY_BUFFER_SIZE];
unsigned char *old_upd, *new_upd; /* pointers to previous two buffers */
int new_upd_len, old_upd_len; /* length of output buffers */
-
+
SLKeyMap_List_Type *keymap;
/* tty variables */
void (*tt_insert)(char);
void (*update_hook)(unsigned char *, int, int);
/* The update hook is called with a pointer to a buffer p1 that contains
- * an image of what the update hook is suppoed to produce. The length
+ * an image of what the update hook is suppoed to produce. The length
* of the buffer is p2 and after the update, the cursor is to be placed
* in column p3.
*/
extern int SLang_init_readline (SLang_RLine_Info_Type *);
extern int SLang_read_line (SLang_RLine_Info_Type *);
extern int SLang_rline_insert (char *);
-extern void SLrline_redraw (SLang_RLine_Info_Type *);
+extern void SLrline_redraw (SLang_RLine_Info_Type *);
extern int SLang_Rline_Quit;
/*}}}*/
#if defined(REAL_UNIX_SYSTEM)
extern int SLtt_Force_Keypad_Init;
#endif
-
+
#ifndef __GO32__
#if defined(VMS) || defined(REAL_UNIX_SYSTEM)
extern int SLtt_Blink_Mode;
#ifdef msdos
extern int SLtt_Msdos_Cheap_Video;
#endif
-
-
+
+
extern int SLtt_flush_output (void);
extern void SLtt_set_scroll_region(int, int);
extern void SLtt_reset_scroll_region(void);
extern void SLtt_get_terminfo(void);
extern void SLtt_get_screen_size (void);
extern int SLtt_set_cursor_visibility (int);
-
+
#if defined(VMS) || defined(REAL_UNIX_SYSTEM)
extern void SLtt_enable_cursor_keys(void);
extern void SLtt_set_term_vtxxx(int *);
extern int SLtt_tigetnum (char *, char **);
# endif
#endif
-
+
extern SLtt_Char_Type SLtt_get_color_object (int);
extern void SLtt_set_color_object (int, SLtt_Char_Type);
extern void SLtt_set_color (int, char *, char *, char *);
extern void SLtt_set_mono (int, char *, SLtt_Char_Type);
extern void SLtt_add_color_attribute (int, SLtt_Char_Type);
extern void SLtt_set_color_fgbg (int, SLtt_Char_Type, SLtt_Char_Type);
-
+
/*}}}*/
/*{{{ SLang Preprocessor Interface */
-typedef struct
+typedef struct
{
int this_level;
int exec_level;
/* Adds a string to the SLang #ifdef preparsing defines. SLang already
defines MSDOS, UNIX, and VMS on the appropriate system. */
extern int (*SLprep_exists_hook) (char *, char);
-
-
+
+
/*}}}*/
/*{{{ SLsmg Screen Management Functions */
extern void SLsmg_write_color_chars (unsigned short *, unsigned int);
extern unsigned int SLsmg_read_raw (unsigned short *, unsigned int);
extern unsigned int SLsmg_write_raw (unsigned short *, unsigned int);
-
+
extern int SLsmg_Display_Eight_Bit;
extern int SLsmg_Tab_Width;
extern int SLsmg_Newline_Moves;
/* This function must be called AFTER SLtt_get_terminfo and not before. */
extern int SLkp_init (void);
-/* This function uses SLang_getkey and assumes that what ever initialization
+/* This function uses SLang_getkey and assumes that what ever initialization
* is required for SLang_getkey has been performed.
*/
extern int SLkp_getkey (void);
}
SLscroll_Type;
-typedef struct
+typedef struct
{
unsigned int flags;
SLscroll_Type *top_window_line; /* list element at top of window */
/* This is not ready yet. */
# define SLANG_NOOP 9
#endif
-
-/* Everything above string should correspond to a pointer in the object
+
+/* Everything above string should correspond to a pointer in the object
* structure. See do_binary (slang.c) for exploitation of this fact.
*/
#define STRING_TYPE 10
#define MAKE_INTRINSIC(n, f, out, in) \
{0, n, (out | (in << 4)), SLANG_INTRINSIC, (long) f}
-
+
#define MAKE_VARIABLE(n, v, t, r) \
{0, n, t, (SLANG_IVARIABLE + r), (long) v}
#else
#define MAKE_INTRINSIC(n, f, out, in) \
{n, (out | (in << 4)), SLANG_INTRINSIC, (long) f}
-
+
#define MAKE_VARIABLE(n, v, t, r) \
{n, t, (SLANG_IVARIABLE + r), (long) v}
#endif
int beg_matches[10]; /* offset of start of \( */
unsigned int end_matches[10]; /* length of nth submatch
* Note that the entire match corresponds
- * to \0
+ * to \0
*/
int offset; /* offset to be added to beg_matches */
} SLRegexp_Type;
-extern unsigned char *SLang_regexp_match(unsigned char *,
- unsigned int,
+extern unsigned char *SLang_regexp_match(unsigned char *,
+ unsigned int,
SLRegexp_Type *);
extern int SLang_regexp_compile (SLRegexp_Type *);
extern char *SLregexp_quote_string (char *, char *, unsigned int);
} SLsearch_Type;
extern int SLsearch_init (char *, int, int, SLsearch_Type *);
-/* This routine must first be called before any search can take place.
- * The second parameter specifies the direction of the search: greater than
- * zero for a forwrd search and less than zero for a backward search. The
+/* This routine must first be called before any search can take place.
+ * The second parameter specifies the direction of the search: greater than
+ * zero for a forwrd search and less than zero for a backward search. The
* third parameter specifies whether the search is case sensitive or not.
- * The last parameter is a pointer to a structure that is filled by this
+ * The last parameter is a pointer to a structure that is filled by this
* function and it is this structure that must be passed to SLsearch.
*/
unsigned char *SLsearch (unsigned char *, unsigned char *, SLsearch_Type *);
-/* To use this routine, you must first call 'SLsearch_init'. Then the first
+/* To use this routine, you must first call 'SLsearch_init'. Then the first
* two parameters p1 and p2 serve to define the region over which the search
* is to take place. The third parameter is the structure that was previously
* initialized by SLsearch_init.
- *
- * The routine returns a pointer to the match if found otherwise it returns
+ *
+ * The routine returns a pointer to the match if found otherwise it returns
* NULL.
*/
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
* characters) can not be written directly to the terminal, when the
* alt-char-set is activated, because writing these characters doesn't cause
* an implicit/temporary switching-back to the standard char-set!
- *
+ *
* The original code in SLang assumes that space, NL, CR, etc. can be
* printed when alt-char-set is activated. If SLTT_TRANSP_ACS_PATCH is
* defined, the modified code will not use this assumption.
- * [Remark: the patch-code is not the most exact solution, but works...]
+ * [Remark: the patch-code is not the most exact solution, but works...]
*/
/*#define SLTT_TRANSP_ACS_PATCH 1*/
#include <signal.h>
-/* Colors: These definitions are used for the display. However, the
+/* Colors: These definitions are used for the display. However, the
* application only uses object handles which get mapped to this
* internal representation. The mapping is performed by the Color_Map
* structure below. */
static int Worthless_Highlight;
#define HP_GLITCH_CODE
#ifdef HP_GLITCH_CODE
-/* This glitch is exclusive to HP term. Basically it means that to clear
+/* This glitch is exclusive to HP term. Basically it means that to clear
* attributes, one has to erase to the end of the line.
*/
static int Has_HP_Glitch;
/* It is crucial that JMAX_COLORS must be less than 128 since the high bit
* is used to indicate a character from the ACS (alt char set). The exception
- * to this rule is if SLtt_Use_Blink_For_ACS is true. This means that of
- * the highbit is set, we interpret that as a blink character. This is
+ * to this rule is if SLtt_Use_Blink_For_ACS is true. This means that of
+ * the highbit is set, we interpret that as a blink character. This is
* exploited by DOSemu.
*/
#define JMAX_COLORS 256
#define JNORMAL_COLOR 0
-typedef struct
+typedef struct
{
SLtt_Char_Type fgbg;
SLtt_Char_Type mono;
#define RGB1(r, g, b) ((r) | ((g) << 1) | ((b) << 2))
#define RGB(r, g, b, br, bg, bb) ((RGB1(r, g, b) << 8) | (RGB1(br, bg, bb) << 16))
-static Ansi_Color_Type Ansi_Color_Map[JMAX_COLORS] =
+static Ansi_Color_Type Ansi_Color_Map[JMAX_COLORS] =
{
{RGB(1, 1, 1, 0, 0, 0), 0x00000000, NULL}, /* white/black */
{RGB(0, 1, 0, 0, 0, 0), SLTT_REV_MASK, NULL}, /* green/black */
static char *Color_Escape_Sequence = "\033[3%dm\033[4%dm";
#else
/* Believe it or not, this is what is in the linux terminfo database. It
- * produces the same escape sequence but it is much more CPU intensive.
+ * produces the same escape sequence but it is much more CPU intensive.
* Why not just encode it as "\033[3%p1%dm\033[4%p2%dm" ???
*/
/* static char *Color_Escape_Sequence = "\033[%p1%{30}%+%dm\033[%p2%{40}%+%dm"; */
char *SLtt_Graphics_Char_Pairs; /* ac termcap string -- def is vt100 */
-
+
/* 1 if terminal lacks the ability to do into insert mode or into delete
mode. Currently controlled by S-Lang but later perhaps termcap. */
int nwrite = 0;
unsigned int total;
int n = (int) (Output_Bufferp - Output_Buffer);
-
+
SLtt_Num_Chars_Output += n;
-
+
total = 0;
while (n > 0)
{
{
nwrite = 0;
#ifdef EAGAIN
- if (errno == EAGAIN)
+ if (errno == EAGAIN)
{
sl_usleep (100000); /* 1/10 sec */
continue;
static int total;
unsigned long now;
unsigned int ndiff;
-
+
if ((str == NULL) || (n == 0)) return;
total += n;
-
+
while (1)
{
ndiff = MAX_OUTPUT_BUFFER_SIZE - (int) (Output_Bufferp - Output_Buffer);
n -= ndiff;
str += ndiff;
}
- else
+ else
{
SLMEMCPY ((char *) Output_Bufferp, str, n);
Output_Bufferp += n;
break;
}
}
-
+
if (((SLtt_Baud_Rate > 150) && (SLtt_Baud_Rate <= 9600))
&& (10 * total > SLtt_Baud_Rate))
{
#ifdef SLTT_TRANSP_ACS_PATCH
int restore_acs = 0;
#endif
-
+
SLtt_normal_video ();
if (Cursor_Set == 1)
{
if (ch >= ' ') Cursor_c++;
#ifndef SLTT_TRANSP_ACS_PATCH
else if (ch == '\b') Cursor_c--;
-#else
+#else
if (ch <= ' ' && SLtt_ACS_Active)
{
SLtt_set_alt_char_set (0);
#endif
else if (ch == '\r') Cursor_c = 0;
else Cursor_Set = 0;
-
- if ((Cursor_c + 1 == SLtt_Screen_Cols)
+
+ if ((Cursor_c + 1 == SLtt_Screen_Cols)
&& Automatic_Margins) Cursor_Set = 0;
}
-
+
if (Output_Bufferp < Output_Buffer + MAX_OUTPUT_BUFFER_SIZE)
{
*Output_Bufferp++ = (unsigned char) ch;
}
else tt_write (&ch, 1);
-
+
#ifdef SLTT_TRANSP_ACS_PATCH
if (restore_acs)
{
#endif
}
-/* this is supposed to be fast--- also handles
+/* this is supposed to be fast--- also handles
termcap: %d, &i, %., %+, %r strings as well as terminfo stuff */
static unsigned int tt_sprintf(char *buf, char *fmt, int x, int y)
{
int stack[10];
int i = 0, z;
stack[0] = y; stack[1] = x; i = 2;
-
+
b = (unsigned char *) buf;
if (fmt != NULL) while ((ch = *f++) != 0)
{
if (ch != '%') *b++ = ch;
- else
+ else
{
ch = *f++;
if (tinfo)
/* map it to termcap. Since this is terminfo,
* it must be one of:
* %2d, %3d, %02d, %03d
- *
+ *
* I am assuming that a terminal that understands
* %2d form will also understand the %02d form. These
* only differ by a space padding the field.
*/
-
+
/* skip the 'd'-- hope it is there */
- if (ch == '0')
+ if (ch == '0')
{
ch = *f;
f += 2;
else f++;
}
}
-
+
switch (ch)
{
case 'p':
ch = *f++;
if (ch == '1') stack[i++] = x; else stack[i++] = y;
break;
-
+
case '\'': /* 'x' */
stack[i++] = *f++;
f++;
break;
-
+
case '{': /* literal constant, e.g. {30} */
z = 0;
while (((ch = *f) <= '9') && (ch >= '0'))
stack[i++] = z;
if (ch == '}') f++;
break;
-
+
case 'd':
case '2':
case '3':
z = z % 100;
goto ten;
}
- else if (ch == 3)
+ else if (ch == 3)
{
*b++ = '0';
ch = '2';
}
-
+
if (z >= 10)
{
ten:
z = z % 10;
}
else if (ch == 2) *b++ = '0';
-
+
*b++ = z + '0';
break;
-
+
case 'i':
offset = 1;
break;
-
+
case '+':
- if (tinfo)
+ if (tinfo)
{
z = stack[--i];
stack[i-1] += z;
*b++ = ch;
}
break;
-
+
case 'r':
stack[0] = x;
stack[1] = y;
break;
-
+
case '.':
case 'c':
ch = (unsigned char) stack[--i];
if (ch == '\n') ch++;
*b++ = ch;
break;
-
+
default:
*b++ = ch;
}
{
if ((Cursor_Visible_Str == NULL) || (Cursor_Invisible_Str == NULL))
return -1;
-
+
SLtt_write_string (show ? Cursor_Visible_Str : Cursor_Invisible_Str);
return 0;
}
-
+
/* the goto_rc function moves to row relative to scrolling region */
void SLtt_goto_rc(int r, int c)
{
#ifdef SLTT_TRANSP_ACS_PATCH
int check_alt_acs = 0;
#endif
-
+
if (c < 0)
{
c = -c - 1;
Cursor_Set = 0;
}
-
+
/* if (No_Move_In_Standout && Current_Fgbg) SLtt_normal_video (); */
r += Scroll_r1;
-
+
if ((Cursor_Set > 0) || ((Cursor_Set < 0) && !Automatic_Margins))
{
n = r - Cursor_r;
- if ((n == -1) && (Cursor_Set > 0) && (Cursor_c == c)
+ if ((n == -1) && (Cursor_Set > 0) && (Cursor_c == c)
&& (Curs_Up_Str != NULL))
{
s = Curs_Up_Str;
}
else if ((n >= 0) && (n <= 4))
{
- if ((n == 0) && (Cursor_Set == 1)
+ if ((n == 0) && (Cursor_Set == 1)
&& ((c > 1) || (c == Cursor_c)))
{
if (Cursor_c == c) return;
- if (Cursor_c == c + 1)
+ if (Cursor_c == c + 1)
{
s = buf;
*s++ = '\b'; *s = 0;
}
/* Will fail on VMS */
#ifndef VMS
- else if (SLtt_Newline_Ok && (Cursor_Set == 1) &&
+ else if (SLtt_Newline_Ok && (Cursor_Set == 1) &&
(Cursor_c >= c) && (c + 3 > Cursor_c))
{
s = buf;
#ifdef SLTT_TRANSP_ACS_PATCH
int restore_acs = 0;
#endif
-
+
if (n <= 0) return;
SLtt_normal_video ();
if (Del_N_Lines_Str != NULL) tt_printf(Del_N_Lines_Str,n, 0);
void SLtt_reverse_index (int n)
{
if (!n) return;
-
+
SLtt_normal_video();
if (Add_N_Lines_Str != NULL) tt_printf(Add_N_Lines_Str,n, 0);
else
void SLtt_beep (void)
{
if (SLtt_Ignore_Beep & 0x1) SLtt_putchar('\007');
-
+
if (SLtt_Ignore_Beep & 0x2)
{
if (Visible_Bell_Str != NULL) SLtt_write_string (Visible_Bell_Str);
if ((obj < 0) || (obj >= JMAX_COLORS))
{
return;
- }
+ }
Ansi_Color_Map[obj].mono = mask & ATTR_MASK;
}
{
unsigned int i, ich;
char *s = color;
-
+
i = 0;
while ((ich = (int) *s) != 0)
{
if ((ich < '0') || (ich > '9'))
return color;
-
+
i = i * 10 + (ich - '0');
s++;
}
-
+
if (i < MAX_COLOR_NAMES)
color = Color_Defs[i].name;
-
+
return color;
}
static char fg_buf[16], bg_buf[16], *bg, *fg;
static int already_parsed;
char *p, *pmax;
-
+
if (already_parsed == -1)
return -1;
*bgp = bg;
return 0;
}
-
+
already_parsed = -1;
-
+
bg = getenv ("COLORFGBG");
if (bg == NULL)
if (bg == NULL)
return -1;
}
-
+
p = fg_buf;
pmax = p + (sizeof (fg_buf) - 1);
-
+
while ((*bg != 0) && (*bg != ';'))
{
if (p < pmax) *p++ = *bg;
bg++;
}
*p = 0;
-
+
if (*bg) bg++;
-
+
p = bg_buf;
pmax = p + (sizeof (bg_buf) - 1);
-
+
/* Mark suggested allowing for extra spplication specific stuff following
* the background color. That is what the check for the semi-colon is for.
*/
void SLtt_set_color_object (int obj, SLtt_Char_Type attr)
{
char *cust_esc;
-
+
if ((obj < 0) || (obj >= JMAX_COLORS)) return;
-
+
cust_esc = Ansi_Color_Map[obj].custom_esc;
- if (cust_esc != NULL)
+ if (cust_esc != NULL)
{
SLFREE (cust_esc);
FgBg_Stats[(Ansi_Color_Map[obj].fgbg >> 8) & 0x7F] -= 1;
Ansi_Color_Map[obj].custom_esc = NULL;
}
-
+
Ansi_Color_Map[obj].fgbg = attr;
if (obj == 0) Color_0_Modified = 1;
}
void SLtt_add_color_attribute (int obj, SLtt_Char_Type attr)
{
if ((obj < 0) || (obj >= JMAX_COLORS)) return;
-
+
Ansi_Color_Map[obj].fgbg |= (attr & ATTR_MASK);
if (obj == 0) Color_0_Modified = 1;
}
static SLtt_Char_Type fb_to_fgbg (SLtt_Char_Type f, SLtt_Char_Type b)
-{
+{
SLtt_Char_Type attr = 0;
if ((f & 0xF0) == 0)
f &= 0x7;
}
else f = 9;
-
+
if ((b & 0xF0) == 0)
{
if (b & 0x8) attr |= SLTT_BLINK_MASK;
b &= 0x7;
}
else b = 9;
-
+
return ((f << 8) | (b << 16) | attr);
}
SLtt_Char_Type f = 0xFFFFFFFFU, b = 0xFFFFFFFFU;
char *dfg, *dbg;
unsigned int i;
-
+
if ((fg != NULL) && (*fg == 0)) fg = NULL;
if ((bg != NULL) && (*bg == 0)) bg = NULL;
-
+
if ((fg == NULL) || (bg == NULL))
{
if (-1 == get_default_colors (&dfg, &dbg))
return -1;
-
+
if (fg == NULL) fg = dfg;
if (bg == NULL) bg = dbg;
}
-
+
for (i = 0; i < MAX_COLOR_NAMES; i++)
{
if (strcmp(fg, Color_Defs[i].name)) continue;
b = Color_Defs[i].color;
break;
}
-
+
if ((f == 0xFFFFFFFFU) || (b == 0xFFFFFFFFU))
return -1;
-
+
*fgbg = fb_to_fgbg (f, b);
return 0;
}
char *cust_esc;
SLtt_Char_Type fgbg = 0;
int i;
-
+
if ((obj < 0) || (obj >= JMAX_COLORS))
{
return;
}
-
+
cust_esc = Ansi_Color_Map[obj].custom_esc;
- if (cust_esc != NULL)
+ if (cust_esc != NULL)
{
SLFREE (cust_esc);
FgBg_Stats[(Ansi_Color_Map[obj].fgbg >> 8) & 0x7F] -= 1;
}
-
+
cust_esc = (char *) SLMALLOC (strlen(esc) + 1);
if (cust_esc != NULL) strcpy (cust_esc, esc);
-
+
Ansi_Color_Map[obj].custom_esc = cust_esc;
if (cust_esc == NULL) fgbg = 0;
else
for (i = 0; i < JMAX_COLORS; i++)
{
if (FgBg_Stats[i] == 0) fgbg = i;
-
+
if (obj == i) continue;
if ((Ansi_Color_Map[i].custom_esc) == NULL) continue;
if (!strcmp (Ansi_Color_Map[i].custom_esc, cust_esc))
}
FgBg_Stats[fgbg] += 1;
}
-
+
fgbg |= 0x80;
Ansi_Color_Map[obj].fgbg = (fgbg | (fgbg << 8)) << 8;
if (obj == 0) Color_0_Modified = 1;
if (SLtt_Has_Alt_Charset == 0) return;
if (i == last_i) return;
SLtt_write_string (i ? Start_Alt_Chars_Str : End_Alt_Chars_Str );
- /* if (i) Current_Fgbg |= SLTT_ALTC_MASK;
+ /* if (i) Current_Fgbg |= SLTT_ALTC_MASK;
else Current_Fgbg &= ~SLTT_ALTC_MASK; */
last_i = i;
#ifdef SLTT_TRANSP_ACS_PATCH
if (Worthless_Highlight) return;
if (fgbg == Current_Fgbg) return;
-
+
/* Before spitting out colors, fix attributes */
if ((fgbg & ATTR_MASK) != (Current_Fgbg & ATTR_MASK))
{
{
SLtt_write_string(Norm_Vid_Str);
/* In case normal video turns off ALL attributes: */
- if (fgbg & SLTT_ALTC_MASK)
+ if (fgbg & SLTT_ALTC_MASK)
Current_Fgbg &= ~SLTT_ALTC_MASK;
SLtt_set_alt_char_set (0);
}
-
- if ((fgbg & SLTT_ALTC_MASK)
+
+ if ((fgbg & SLTT_ALTC_MASK)
!= (Current_Fgbg & SLTT_ALTC_MASK))
{
SLtt_set_alt_char_set ((int) (fgbg & SLTT_ALTC_MASK));
}
-
+
if (fgbg & SLTT_ULINE_MASK) SLtt_write_string (UnderLine_Vid_Str);
if (fgbg & SLTT_BOLD_MASK) SLtt_bold_video ();
if (fgbg & SLTT_REV_MASK) SLtt_write_string (Rev_Vid_Str);
if (SLtt_Blink_Mode) SLtt_write_string (Blink_Vid_Str);
}
}
-
+
if (SLtt_Use_Ansi_Colors)
{
fg0 = (int) GET_FG(fgbg);
{
SLtt_Char_Type fgbg;
char *esc;
-
+
if (Worthless_Highlight) return;
if ((color < 0) || (color >= JMAX_COLORS)) return;
-
+
if (Video_Initialized == 0)
{
if (color == JNORMAL_COLOR)
Current_Fgbg = 0xFFFFFFFFU;
return;
}
-
- if (SLtt_Use_Ansi_Colors)
+
+ if (SLtt_Use_Ansi_Colors)
{
fgbg = Ansi_Color_Map[color].fgbg;
if ((esc = Ansi_Color_Map[color].custom_esc) != NULL)
static void write_string_with_care (char *str)
{
unsigned int len;
-
+
if (str == NULL) return;
-
+
len = strlen (str);
if (Automatic_Margins && (Cursor_r + 1 == SLtt_Screen_Rows))
{
register SLtt_Char_Type attr;
register unsigned short sh;
int color, last_color = -1;
-
+
p = out;
while (0 != (sh = *s++))
{
{
if (SLtt_Use_Ansi_Colors) attr = Ansi_Color_Map[color & 0x7F].fgbg;
else attr = Ansi_Color_Map[color & 0x7F].mono;
-
+
/* sh => color */
if (color & 0x80) /* alternate char set */
{
{
if (SLtt_Blink_Mode) attr |= SLTT_BLINK_MASK;
}
- else attr |= SLTT_ALTC_MASK;
+ else attr |= SLTT_ALTC_MASK;
}
-
-
+
+
if (attr != Current_Fgbg)
{
#ifndef SLTT_TRANSP_ACS_PATCH
Current_Fgbg = attr;
}
else write_attributes (attr);
-
+
last_color = color;
}
}
static void forward_cursor (unsigned int n, int row)
{
char buf[30];
-
-
- if (n <= 4)
+
+
+ if (n <= 4)
{
SLtt_normal_video ();
SLMEMSET (buf, ' ', n);
}
-#define SPACE_CHAR (0x20 | (JNORMAL_COLOR << 8))
+#define SPACE_CHAR (0x20 | (JNORMAL_COLOR << 8))
void SLtt_smart_puts(unsigned short *neww, unsigned short *oldd, int len, int row)
{
#ifdef HP_GLITCH_CODE
int handle_hp_glitch = 0;
#endif
-
+
q = oldd; p = neww;
qmax = oldd + len;
pmax = p + len;
-
+
/* Find out where to begin --- while they match, we are ok */
while (1)
{
if (q == qmax) return;
#if SLANG_HAS_KANJI_SUPPORT
- if (*p & 0x80)
+ if (*p & 0x80)
{ /* new is kanji */
if ((*q & 0x80) && ((q + 1) < qmax))
{ /* old is also kanji */
if (((0xFF & *q) != (0xFF & *p))
|| ((0xFF & q[1]) != (0xFF & p[1])))
break; /* both kanji, but not match */
-
- else
+
+ else
{ /* kanji match ! */
if (!COLOR_EQS(*q, *p)) break;
q++; p++;
}
else break; /* old is not kanji */
}
- else
+ else
{ /* new is not kanji */
if (*q & 0x80) break; /* old is kanji */
}
}
#endif
/* Find where the last non-blank character on old/new screen is */
-
+
while (qmax > q)
{
qmax--;
- if (!CHAR_EQS(*qmax, SPACE_CHAR))
+ if (!CHAR_EQS(*qmax, SPACE_CHAR))
{
qmax++;
break;
}
}
-
+
while (pmax > p)
{
pmax--;
break;
}
}
-
+
last_buffered_match = buf = buffer; /* buffer is empty */
#ifdef HP_GLITCH_CODE
{
if (CHAR_EQS(*q,SPACE_CHAR) && CHAR_EQS(*p, SPACE_CHAR))
{
- /* If *q is not a space, we would have to overwrite it.
- * However, if *q is a space, then while *p is also one,
+ /* If *q is not a space, we would have to overwrite it.
+ * However, if *q is a space, then while *p is also one,
* we only need to skip over the blank field.
*/
space_match = p;
p++; q++;
- while ((p < pmax)
- && CHAR_EQS(*q,SPACE_CHAR)
+ while ((p < pmax)
+ && CHAR_EQS(*q,SPACE_CHAR)
&& CHAR_EQS(*p, SPACE_CHAR))
{
p++;
#if SLANG_HAS_KANJI_SUPPORT
if ((*p & 0x80) && ((p + 1) < pmax))
{ /* new is kanji */
- if (*q & 0x80)
+ if (*q & 0x80)
{ /* old is also kanji */
- if (((0xFF & *q) != (0xFF & *p))
+ if (((0xFF & *q) != (0xFF & *p))
|| ((0xFF & q[1]) != (0xFF & p[1])))
{
/* both kanji, but not match */
q += 2;
continue;
}
- else
+ else
{ /* kanji match ? */
- if (!COLOR_EQS(*q, *p) || !COLOR_EQS(*(q+1), *(p+1)))
+ if (!COLOR_EQS(*q, *p) || !COLOR_EQS(*(q+1), *(p+1)))
{
/* code is match ,but color is diff */
*buf++ = *p++;
break;
}
}
- else
+ else
{ /* old is not kanji */
*buf++ = *p++;
*buf++ = *p++;
continue;
}
}
- else
+ else
{ /* new is not kanji */
- if (*q & 0x80)
+ if (*q & 0x80)
{ /* old is kanji */
*buf++ = *p++;
q++;
q++;
}
*buf = 0;
-
+
if (buf != buffer) send_attr_str (buffer);
buf = buffer;
-
- if (n_spaces && (p < pmax))
+
+ if (n_spaces && (p < pmax))
{
forward_cursor (n_spaces, row);
}
-
- /* Now we overwrote what we could and cursor is placed at position
- * of a possible match of new and old. If this is the case, skip
+
+ /* Now we overwrote what we could and cursor is placed at position
+ * of a possible match of new and old. If this is the case, skip
* some more.
*/
-#if !SLANG_HAS_KANJI_SUPPORT
+#if !SLANG_HAS_KANJI_SUPPORT
while ((p < pmax) && CHAR_EQS(*p, *q))
{
*buf++ = *p++;
}
#else
/* Kanji */
- while (p < pmax)
+ while (p < pmax)
{
if ((*p & 0x80) && ((p + 1) < pmax))
{ /* new is kanji */
- if (*q & 0x80)
+ if (*q & 0x80)
{ /* old is also kanji */
- if (((0xFF & *q) == (0xFF & *p))
+ if (((0xFF & *q) == (0xFF & *p))
&& ((0xFF & q[1]) == (0xFF & p[1])))
{
/* kanji match ? */
- if (!COLOR_EQS(*q, *p)
+ if (!COLOR_EQS(*q, *p)
|| !COLOR_EQS(q[1], p[1]))
break;
-
+
*buf++ = *p++;
q++;
- if (p >= pmax)
+ if (p >= pmax)
{
*buf++ = SPACE_CHAR;
p++;
break;
}
- else
+ else
{
*buf++ = *p++;
q++;
}
else break; /* old is not kanji */
}
- else
+ else
{ /* new is not kanji */
if (*q & 0x80) break; /* old is kanji */
if (!CHAR_EQS(*q, *p)) break;
#endif
last_buffered_match = buf;
if (p >= pmax) break;
-
+
/* jump to new position is it is greater than 5 otherwise
* let it sit in the buffer and output it later.
*/
- if ((int) (buf - buffer) >= 5)
+ if ((int) (buf - buffer) >= 5)
{
forward_cursor ((unsigned int) (buf - buffer), row);
last_buffered_match = buf = buffer;
{
if (q < qmax)
{
- if ((buf == last_buffered_match)
+ if ((buf == last_buffered_match)
&& ((int) (buf - buffer) >= 5))
{
forward_cursor ((unsigned int) (buf - buffer), row);
}
if (q < qmax) SLtt_del_eol ();
if (Automatic_Margins && (Cursor_c + 1 >= SLtt_Screen_Cols)) Cursor_Set = 0;
-}
+}
static void get_color_info (void)
{
char *fg, *bg;
-
+
SLtt_Use_Ansi_Colors = (NULL != getenv ("COLORTERM"));
-
+
if (-1 == get_default_colors (&fg, &bg))
return;
-
+
/* Check to see if application has already set them. */
if (Color_0_Modified)
return;
-
+
SLtt_set_color (0, NULL, fg, bg);
SLtt_set_color (1, NULL, bg, fg);
}
/* Check for AIX brain-damage */
if (*what == '@')
return NULL;
-
+
/* lose pad info --- with today's technology, term is a loser if
it is really needed */
- while ((*what == '.') ||
+ while ((*what == '.') ||
((*what >= '0') && (*what <= '9'))) what++;
- if (*what == '*') what++;
-
+ if (*what == '*') what++;
+
/* lose terminfo padding--- looks like $<...> */
w = what;
while (*w) if ((*w++ == '$') && (*w == '<'))
while ((*w1++ = *w++) != 0);
w = wsave;
}
- if (*what == 0) what = NULL;
+ if (*what == 0) what = NULL;
}
return(what);
}
char *term, *t, ch;
int is_xterm;
int almost_vtxxx;
-
+
get_color_info ();
-
+
if (NULL == (term = (char *) getenv("TERM")))
{
SLang_exit_error("TERM environment variable needs set.");
}
-
+
Linux_Console = (!strncmp (term, "linux", 5)
#ifdef linux
|| !strncmp(term, "con", 3)
#endif
);
-
+
t = term;
-
+
if (strcmp(t, "vt52") && (*t++ == 'v') && (*t++ == 't')
- && (ch = *t, (ch >= '1') && (ch <= '9'))) Vt100_Like = 1;
+ && (ch = *t, (ch >= '1') && (ch <= '9'))) Vt100_Like = 1;
is_xterm = !strncmp (term, "xterm", 5);
almost_vtxxx = (Vt100_Like
|| Linux_Console
|| is_xterm
|| !strcmp (term, "screen"));
-
+
#ifndef USE_TERMCAP
- if (NULL == (Tbuf = tgetent (term)))
+ if (NULL == (Tbuf = tgetent (term)))
{
char err_buf[512];
if (almost_vtxxx) /* Special cases. */
#else /* USE_TERMCAP */
if (1 != tgetent(Tbuf, term)) SLang_exit_error("Unknown terminal.");
#endif /* NOT USE_TERMCAP */
-
- if ((NULL == (Cls_Str = SLtt_tgetstr("cl")))
+
+ if ((NULL == (Cls_Str = SLtt_tgetstr("cl")))
|| (NULL == (Curs_Pos_Str = SLtt_tgetstr("cm"))))
{
SLang_exit_error("Terminal not powerful enough for SLang.");
}
-
+
if ((NULL == (Ins_Mode_Str = SLtt_tgetstr("im")))
|| ( NULL == (Eins_Mode_Str = SLtt_tgetstr("ei")))
|| ( NULL == (Del_Char_Str = SLtt_tgetstr("dc"))))
SLtt_Term_Cannot_Insert = 1;
-
+
Visible_Bell_Str = SLtt_tgetstr ("vb");
Curs_Up_Str = SLtt_tgetstr ("up");
Rev_Scroll_Str = SLtt_tgetstr("sr");
Del_N_Lines_Str = SLtt_tgetstr("DL");
Add_N_Lines_Str = SLtt_tgetstr("AL");
-
- /* Actually these are used to initialize terminals that use cursor
+
+ /* Actually these are used to initialize terminals that use cursor
* addressing. Hard to believe.
*/
Term_Init_Str = SLtt_tgetstr ("ti");
Term_Reset_Str = SLtt_tgetstr ("te");
- /* If I do this for vtxxx terminals, arrow keys start sending ESC O A,
+ /* If I do this for vtxxx terminals, arrow keys start sending ESC O A,
* which I do not want. This is mainly for HP terminals.
*/
if ((almost_vtxxx == 0) || SLtt_Force_Keypad_Init)
if (Del_N_Lines_Str == NULL) Del_N_Lines_Str = "\033[%dM";
if (Add_N_Lines_Str == NULL) Add_N_Lines_Str = "\033[%dL";
}
-
+
Scroll_R_Str = SLtt_tgetstr("cs");
-
+
SLtt_get_screen_size ();
- if ((Scroll_R_Str == NULL)
+ if ((Scroll_R_Str == NULL)
|| (((NULL == Del_N_Lines_Str) || (NULL == Add_N_Lines_Str))
&& (NULL == Rev_Scroll_Str)))
{
}
else SLtt_Term_Cannot_Scroll = 1;
}
-
+
Del_Eol_Str = SLtt_tgetstr("ce");
Rev_Vid_Str = SLtt_tgetstr("mr");
if (Rev_Vid_Str == NULL) Rev_Vid_Str = SLtt_tgetstr("so");
-
+
Bold_Vid_Str = SLtt_tgetstr("md");
/* Although xterm cannot blink, it does display the blinking characters
if ((NULL == (Blink_Vid_Str = SLtt_tgetstr("mb")))
&& is_xterm)
Blink_Vid_Str = "\033[5m";
-
+
UnderLine_Vid_Str = SLtt_tgetstr("us");
-
+
Start_Alt_Chars_Str = SLtt_tgetstr ("as"); /* smacs */
End_Alt_Chars_Str = SLtt_tgetstr ("ae"); /* rmacs */
Enable_Alt_Char_Set = SLtt_tgetstr ("eA"); /* enacs */
#ifndef NCURSES_BRAIN_DAMAGE_CONTROL
# define NCURSES_BRAIN_DAMAGE_CONTROL 0
#endif
-
+
#if NCURSES_BRAIN_DAMAGE_CONTROL
if (Linux_Console)
{
Enable_Alt_Char_Set = NULL;
# else
char *lgcp = "`\004a\261f\370g\361h\260j\331k\277l\332m\300n\305o\302q\304r\362s_t\303u\264v\301w\302x\263y\371z\372{\373|\374}\375~";
-
+
SLtt_Graphics_Char_Pairs = lgcp;
Start_Alt_Chars_Str = "\033[11m";
End_Alt_Chars_Str = "\033[10m";
# endif
}
#endif
-
+
if (NULL == SLtt_Graphics_Char_Pairs)
{
/* make up for defective termcap/terminfo */
Enable_Alt_Char_Set = "\033)0";
}
}
-
+
/* aixterm added by willi */
if (is_xterm || !strncmp (term, "aixterm", 7))
{
End_Alt_Chars_Str = "\017";
Enable_Alt_Char_Set = "\033(B\033)0";
}
-
- if ((SLtt_Graphics_Char_Pairs == NULL) &&
+
+ if ((SLtt_Graphics_Char_Pairs == NULL) &&
((Start_Alt_Chars_Str == NULL) || (End_Alt_Chars_Str == NULL)))
{
SLtt_Has_Alt_Charset = 0;
Enable_Alt_Char_Set = NULL;
}
else SLtt_Has_Alt_Charset = 1;
-
+
/* status line capabilities */
if ((SLtt_Has_Status_Line == -1)
Num_Status_Line_Columns = TGETNUM("ws");
if (Num_Status_Line_Columns < 0) Num_Status_Line_Columns = 0;
}
-
- if (NULL == (Norm_Vid_Str = SLtt_tgetstr("me")))
+
+ if (NULL == (Norm_Vid_Str = SLtt_tgetstr("me")))
{
Norm_Vid_Str = SLtt_tgetstr("se");
}
-
+
Cursor_Invisible_Str = SLtt_tgetstr("vi");
Cursor_Visible_Str = SLtt_tgetstr("ve");
-
+
Curs_F_Str = SLtt_tgetstr("RI");
-
+
#if 0
if (NULL != Curs_F_Str)
{
}
else Len_Curs_F_Str = strlen(Curs_Pos_Str);
#endif
-
+
Automatic_Margins = TGETFLAG ("am");
/* No_Move_In_Standout = !TGETFLAG ("ms"); */
#ifdef HP_GLITCH_CODE
if (Worthless_Highlight)
SLtt_Has_Alt_Charset = 0;
-
+
/* Check for color information in the termcap. A program should not
* rely on this information being accurate.
*/
if (SLtt_Use_Ansi_Colors == 0)
{
Reset_Color_String = SLtt_tgetstr ("op");
-
+
SLtt_Use_Ansi_Colors = ((NULL != Reset_Color_String)
|| (NULL != SLtt_tgetstr ("Sf"))
|| (NULL != SLtt_tgetstr ("Sb"))
|| (NULL != SLtt_tgetstr ("AB"))
|| (-1 != SLtt_tgetnum ("Co"))
|| (-1 != SLtt_tgetnum ("pa")));
-
+
}
-
+
#if defined(__QNX__) && defined(QNX_QANSI_SLANG_COMPAT_ACS)
/*
* Override the alt-char-set handling string in case of a
End_Alt_Chars_Str = "\017"; /* rmacs/ae (^O) */
SLtt_Graphics_Char_Pairs = /* acsc/ac */
"``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~O\141";
-
- /*
+
+ /*
* it would be required to modify the sgr/sa entry also, if it
* would be used (->embedded as/ae sequences)...
*/
void SLtt_get_terminfo ()
{
int zero = 0;
-
+
get_color_info ();
SLtt_set_term_vtxxx(&zero);
End_Alt_Chars_Str = "\017";
SLtt_Has_Alt_Charset = 1;
SLtt_Graphics_Char_Pairs = "aaffgghhjjkkllmmnnooqqssttuuvvwwxx";
- Enable_Alt_Char_Set = "\033(B\033)0";
+ Enable_Alt_Char_Set = "\033(B\033)0";
SLtt_get_screen_size ();
}
#endif
/* This sets term for vt102 terminals it parameter vt100 is 0. If vt100
- * is non-zero, set terminal appropriate for a only vt100
+ * is non-zero, set terminal appropriate for a only vt100
* (no add line capability). */
-
+
void SLtt_set_term_vtxxx(int *vt100)
{
Norm_Vid_Str = "\033[m";
-
- Scroll_R_Str = "\033[%i%d;%dr";
+
+ Scroll_R_Str = "\033[%i%d;%dr";
Cls_Str = "\033[2J\033[H";
Rev_Vid_Str = "\033[7m";
Bold_Vid_Str = "\033[1m";
Current_Fgbg = 0xFFFFFFFFU;
SLtt_set_alt_char_set (0);
- if (SLtt_Use_Ansi_Colors)
+ if (SLtt_Use_Ansi_Colors)
{
if (Reset_Color_String == NULL)
{
int SLtt_set_mouse_mode (int mode, int force)
{
char *term;
-
+
if (force == 0)
{
if (NULL == (term = (char *) getenv("TERM"))) return -1;
SLtt_write_string ("\033[?9h");
else
SLtt_write_string ("\033[?9l");
-
+
return 0;
}
|| (Goto_Status_Line_Str == NULL)
|| (Return_From_Status_Line_Str == NULL))
return -1;
-
+
tt_printf (Goto_Status_Line_Str, col, 0);
SLtt_write_string (s);
SLtt_write_string (Return_From_Status_Line_Str);
return 0;
}
-
+
void SLtt_get_screen_size (void)
-{
+{
#ifdef VMS
int status, code;
unsigned short chan;
VIOMODEINFO vioModeInfo;
#endif
int r = 0, c = 0;
-
+
#if defined(TIOCGWINSZ) && !defined(SCO_FLAVOR)
struct winsize wind_struct;
-
+
do
{
if ((ioctl(1,TIOCGWINSZ,&wind_struct) == 0)
}
}
while (errno == EINTR);
-
+
#endif
#ifdef VMS
vioModeInfo.cb = sizeof(vioModeInfo);
VioGetMode (&vioModeInfo, 0);
c = vioModeInfo.col;
- r = vioModeInfo.row;
+ r = vioModeInfo.row;
#endif
-
+
if (r <= 0)
{
char *s = getenv ("LINES");
if (s != NULL) r = atoi (s);
}
-
+
if (c <= 0)
{
char *s = getenv ("COLUMNS");
if (s != NULL) c = atoi (s);
}
-
+
if ((r <= 0) || (r > 200)) r = 24;
if ((c <= 0) || (c > 250)) c = 80;
SLtt_Screen_Rows = r;
/* error handling common to all routines. */
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
char *str = NULL;
*err = 0;
-
+
str = "Slang/Midnight Commander unknown error";
sprintf(err, "S-Lang Error: %s", str);
-
+
if (SLang_Error_Routine == NULL)
{
fputs (err, stderr);
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
int SLang_Ignore_User_Abort = 0;
/* This has the effect of mapping all characters in the range 128-169 to
- * ESC [ something
+ * ESC [ something
*/
#ifndef __GO32__
# if defined(__unix__) || defined(vms)
{
unsigned int imax;
unsigned int ch;
-
+
if (SLang_Input_Buffer_Len)
{
ch = (unsigned int) *SLang_Input_Buffer;
SLang_Input_Buffer_Len--;
imax = SLang_Input_Buffer_Len;
-
- SLMEMCPY ((char *) SLang_Input_Buffer,
+
+ SLMEMCPY ((char *) SLang_Input_Buffer,
(char *) (SLang_Input_Buffer + 1), imax);
}
else if (0xFFFF == (ch = SLsys_getkey ())) return ch;
-
+
#ifdef DEC_8BIT_HACK
if (ch & 0x80)
{
{
if (n + SLang_Input_Buffer_Len + 3 > MAX_INPUT_BUFFER_LEN) return;
-
- SLMEMCPY ((char *) SLang_Input_Buffer + SLang_Input_Buffer_Len,
+
+ SLMEMCPY ((char *) SLang_Input_Buffer + SLang_Input_Buffer_Len,
(char *) s, n);
SLang_Input_Buffer_Len += n;
}
int n;
unsigned char c;
if (SLang_Input_Buffer_Len) return (int) SLang_Input_Buffer_Len;
-
+
n = SLsys_input_pending (tsecs);
-
+
if (n <= 0) return 0;
-
+
c = (unsigned char) SLang_getkey ();
SLang_ungetkey_string (&c, 1);
-
+
return n;
}
#endif /* OS2_NT */
void SLang_flush_input (void)
{
int quit = SLKeyBoard_Quit;
-
+
SLang_Input_Buffer_Len = 0;
- SLKeyBoard_Quit = 0;
- while (SLsys_input_pending (0) > 0)
+ SLKeyBoard_Quit = 0;
+ while (SLsys_input_pending (0) > 0)
{
(void) SLsys_getkey ();
/* Set this to 0 because SLsys_getkey may stuff keyboard buffer if
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
use system rouines. For msdos, I use inline assembly. */
/* The current versions only work in the forward direction only!! */
-
+
#include "config.h"
#include <stdio.h>
asm mov si, bx
asm mov di, dx
return(s1);
-
+
#else
register char *smax, *s = s1;
int n2;
-
+
n2 = n % 4;
smax = s + (n - 4);
- while (s <= smax)
+ while (s <= smax)
{
*s = *s2; *(s + 1) = *(s2 + 1); *(s + 2) = *(s2 + 2); *(s + 3) = *(s2 + 3);
s += 4;
s2 += 4;
}
while (n2--) *s++ = *s2++;
- return(s1);
+ return(s1);
#endif
}
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
use system rouines. For msdos, I use inline assembly. */
/* The current versions only work in the forward direction only!! */
-
+
#include "config.h"
#include <stdio.h>
pmax = p + (n - 4);
n = n % 4;
- while (p <= pmax)
+ while (p <= pmax)
{
*p++ = space; *p++ = space; *p++ = space; *p++= space;
}
- while (n--) *p++ = space;
+ while (n--) *p++ = space;
#endif
}
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
{
unsigned int c;
unsigned char scan;
-
+
int tsecs = 300;
-
- if (!keyWaiting())
+
+ if (!keyWaiting())
while (!SLsys_input_pending(tsecs));
/* read codes from buffer */
{
#ifdef SLANG_POSIX_SIGNALS
struct sigaction old_sa, new_sa;
-
+
# ifdef SIGALRM
/* We want system calls to be interrupted by SIGALRM. */
if (sig == SIGALRM) return SLsignal_intr (sig, f);
sigemptyset (&new_sa.sa_mask);
new_sa.sa_handler = f;
-
+
new_sa.sa_flags = 0;
# ifdef SA_RESTART
new_sa.sa_flags |= SA_RESTART;
# endif
-
+
if (-1 == sigaction (sig, &new_sa, &old_sa))
return (SLSig_Fun_Type *) SIG_ERR;
-
+
return old_sa.sa_handler;
#else
/* Not POSIX. */
#endif
}
-/* This function will NOT cause system calls to be restarted after
- * signal if possible
+/* This function will NOT cause system calls to be restarted after
+ * signal if possible
*/
SLSig_Fun_Type *SLsignal_intr (int sig, SLSig_Fun_Type *f)
{
#ifdef SLANG_POSIX_SIGNALS
struct sigaction old_sa, new_sa;
-
+
sigemptyset (&new_sa.sa_mask);
new_sa.sa_handler = f;
-
+
new_sa.sa_flags = 0;
# ifdef SA_INTERRUPT
new_sa.sa_flags |= SA_INTERRUPT;
# endif
-
+
if (-1 == sigaction (sig, &new_sa, &old_sa))
return (SLSig_Fun_Type *) SIG_ERR;
-
+
return old_sa.sa_handler;
#else
/* Not POSIX. */
}
-/* We are primarily interested in blocking signals that would cause the
+/* We are primarily interested in blocking signals that would cause the
* application to reset the tty. These include suspend signals and
* possibly interrupt signals.
*/
#ifdef SLANG_POSIX_SIGNALS
sigset_t new_mask;
#endif
-
+
Blocked_Depth++;
if (Blocked_Depth != 1)
{
return 0;
}
-
+
#ifdef SLANG_POSIX_SIGNALS
sigemptyset (&new_mask);
# ifdef SIGQUIT
# ifdef SIGTTOU
sigaddset (&new_mask, SIGTTOU);
# endif
-
+
(void) sigprocmask (SIG_BLOCK, &new_mask, &Old_Signal_Mask);
return 0;
#else
{
if (Blocked_Depth == 0)
return -1;
-
+
Blocked_Depth--;
-
+
if (Blocked_Depth != 0)
return 0;
-
+
#ifdef SLANG_POSIX_SIGNALS
(void) sigprocmask (SIG_SETMASK, &Old_Signal_Mask, NULL);
return 0;
/* SLang Screen management routines */
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
register unsigned short color_ch;
color_ch = (This_Color << 8) | (unsigned short) ch;
-
+
while (p < pmax)
{
*p++ = color_ch;
{
int i;
int imax = row + n;
-
+
if (imax > Screen_Rows) imax = Screen_Rows;
for (i = row; i < imax; i++)
{
void SLsmg_erase_eol (void)
{
int r, c;
-
+
c = This_Col - Start_Col;
r = This_Row - Start_Row;
-
+
if ((r < 0) || (r >= Screen_Rows)) return;
if (c < 0) c = 0; else if (c >= Screen_Cols) return;
blank_line (SL_Screen[This_Row].neew + c , Screen_Cols - c, ' ');
This_Row--;
}
-
+
void SLsmg_gotorc (int r, int c)
*/
if (i) This_Alt_Char = ALT_CHAR_FLAG;
else This_Alt_Char = 0;
-
+
This_Color &= 0x7F;
This_Color |= This_Alt_Char;
}
{
return ((This_Row >= Start_Row) && (This_Row < Start_Row + Screen_Rows)
&& ((col_too == 0)
- || ((This_Col >= Start_Col)
+ || ((This_Col >= Start_Col)
&& (This_Col < Start_Col + Screen_Cols))));
}
-
+
void SLsmg_printf (char *fmt, ...)
{
char p[1000];
va_start(ap, fmt);
(void) vsprintf(p, fmt, ap);
va_end(ap);
-
+
SLsmg_write_string (p);
}
int width;
char blank = ' ';
if (str == NULL) width = 0;
- else
+ else
{
width = strlen (str);
if (width > n) width = n;
{
register char ch, *p;
int maxc = dc;
-
+
if ((dr == 0) || (dc == 0)) return;
p = s;
dc = 0;
if ((ch == 0) || (ch == '\n'))
{
int diff;
-
+
diff = maxc - dc;
-
+
SLsmg_gotorc (r, c);
SLsmg_write_nchars (s, dc);
if (fill && (diff > 0))
while (diff--) SLsmg_write_char (' ');
}
if ((ch == 0) || (dr == 1)) break;
-
+
r++;
dc = 0;
dr--;
}
}
-
+
int SLsmg_Tab_Width = 8;
int newline_flag;
#ifndef pc_system
int alt_char_set_flag;
-
- alt_char_set_flag = ((SLtt_Use_Blink_For_ACS == 0)
+
+ alt_char_set_flag = ((SLtt_Use_Blink_For_ACS == 0)
&& (This_Color & ALT_CHAR_FLAG));
#endif
str_max = str + n;
color = This_Color << 8;
-
+
top: /* get here only on newline */
-
+
newline_flag = 0;
start_len = Start_Col;
-
+
if (point_visible (0) == 0) return;
-
+
len = This_Col;
max_len = start_len + Screen_Cols;
p = SL_Screen[This_Row].neew;
if (len > start_len) p += (len - start_len);
-
+
flags = SL_Screen[This_Row].flags;
while ((len < max_len) && (str < str_max))
- {
+ {
ch = (unsigned char) *str++;
#ifndef pc_system
p++;
}
}
-
+
else if ((ch == '\t') && (SLsmg_Tab_Width > 0))
{
n = len;
len += 1;
if (len > start_len)
{
- if (*p != neew)
+ if (*p != neew)
{
flags |= TOUCHED;
*p = neew;
ch &= 0x7F;
}
}
-
+
len += 1;
if (len > start_len)
{
p++;
if (len == max_len) break;
}
-
+
if (ch == 127) ch = '?'; else ch = ch + '@';
len++;
if (len > start_len)
}
}
}
-
+
SL_Screen[This_Row].flags = flags;
This_Col = len;
-
+
if (SLsmg_Newline_Moves == 0)
return;
-
+
if (newline_flag == 0)
{
while (str < str_max)
if (str == str_max) return;
str++;
}
-
+
This_Row++;
This_Col = 0;
if (This_Row == Start_Row + Screen_Rows)
static void do_copy (unsigned short *a, unsigned short *b)
{
unsigned short *amax = a + Screen_Cols;
-
+
while (a < amax) *a++ = *b++;
}
#endif
register unsigned long sum = 0;
register unsigned short *smax, ch;
int is_blank = 2;
-
+
s += SLsmg_Scroll_Hash_Border;
smax = s + (n - SLsmg_Scroll_Hash_Border);
- while (s < smax)
+ while (s < smax)
{
ch = *s++;
if (is_blank && ((ch & 0xFF) != 32)) is_blank--;
-
+
sum += ch;
-
+
h = sum + (h << 3);
if ((g = h & 0xE0000000UL) != 0)
{
int color, did_scroll = 0;
unsigned short *tmp;
int ignore;
-
+
/* find region limits. */
-
+
for (rmax = Screen_Rows - 1; rmax > 0; rmax--)
{
if (SL_Screen[rmax].new_hash != SL_Screen[rmax].old_hash)
if ((r1 == 0)
|| (SL_Screen[r1].new_hash != SL_Screen[r1].old_hash))
break;
-
+
rmax = r1;
}
}
-
+
for (rmin = 0; rmin < rmax; rmin++)
{
if (SL_Screen[rmin].new_hash != SL_Screen[rmin].old_hash)
if ((r1 == rmax)
|| (SL_Screen[r1].new_hash != SL_Screen[r1].old_hash))
break;
-
+
rmin = r1;
}
}
-
+
for (i = rmax; i > rmin; i--)
{
hash = SL_Screen[i].new_hash;
if (hash == Blank_Hash) continue;
-
- if ((hash == SL_Screen[i].old_hash)
+
+ if ((hash == SL_Screen[i].old_hash)
|| ((i + 1 < Screen_Rows) && (hash == SL_Screen[i + 1].old_hash))
|| ((i - 1 > rmin) && (SL_Screen[i].old_hash == SL_Screen[i - 1].new_hash)))
continue;
-
+
for (j = i - 1; j >= rmin; j--)
{
if (hash == SL_Screen[j].old_hash) break;
}
if (j < rmin) continue;
-
+
r2 = i; /* end scroll region */
-
+
di = i - j;
j--;
ignore = 0;
j--;
}
r1 = j + 1;
-
+
/* If this scroll only scrolls this line into place, don't do it.
*/
if ((di > 1) && (r1 + di + ignore == r2)) continue;
-
- /* If there is anything in the scrolling region that is ok, abort the
+
+ /* If there is anything in the scrolling region that is ok, abort the
* scroll.
*/
}
}
if (j <= r2) continue;
-
+
color = This_Color; This_Color = 0;
did_scroll = 1;
SLtt_normal_video ();
SLtt_goto_rc (0, 0);
SLtt_reverse_index (di);
SLtt_reset_scroll_region ();
- /* Now we have a hole in the screen. Make the virtual screen look
+ /* Now we have a hole in the screen. Make the virtual screen look
* like it.
*/
for (j = r1; j <= r2; j++) SL_Screen[j].flags = TOUCHED;
-
+
while (di--)
{
tmp = SL_Screen[r2].old;
This_Color = color;
}
if (did_scroll) return;
-
+
/* Try other direction */
for (i = rmin; i < rmax; i++)
hash = SL_Screen[i].new_hash;
if (hash == Blank_Hash) continue;
if (hash == SL_Screen[i].old_hash) continue;
-
+
/* find a match further down screen */
for (j = i + 1; j <= rmax; j++)
{
if (hash == SL_Screen[j].old_hash) break;
}
if (j > rmax) continue;
-
+
r1 = i; /* beg scroll region */
di = j - i; /* number of lines to scroll */
j++; /* since we know this is a match */
-
+
/* find end of scroll region */
ignore = 0;
while ((j <= rmax) && (SL_Screen[j].old_hash == SL_Screen[j - di].new_hash))
j++;
}
r2 = j - 1; /* end of scroll region */
-
+
/* If this scroll only scrolls this line into place, don't do it.
*/
if ((di > 1) && (r1 + di + ignore == r2)) continue;
- /* If there is anything in the scrolling region that is ok, abort the
+ /* If there is anything in the scrolling region that is ok, abort the
* scroll.
*/
-
+
for (j = r1; j <= r2; j++)
{
if ((SL_Screen[j].old_hash != Blank_Hash)
if ((j - di < r1) || (SL_Screen[j].old_hash != SL_Screen[j - di].new_hash))
break;
}
-
+
}
if (j <= r2) continue;
-
+
color = This_Color; This_Color = 0;
SLtt_normal_video ();
SLtt_set_scroll_region (r1, r2);
SLtt_goto_rc (0, 0); /* relative to scroll region */
SLtt_delete_nlines (di);
SLtt_reset_scroll_region ();
- /* Now we have a hole in the screen. Make the virtual screen look
+ /* Now we have a hole in the screen. Make the virtual screen look
* like it.
*/
for (j = r1; j <= r2; j++) SL_Screen[j].flags = TOUCHED;
-
+
while (di--)
{
tmp = SL_Screen[r1].old;
}
#endif /* NOT pc_system */
-
-
-
+
+
+
static int Smg_Inited;
void SLsmg_refresh (void)
{
int i;
-
+
if (Smg_Inited == 0) return;
#ifndef pc_system
for (i = 0; i < Screen_Rows; i++)
SL_Screen[i].new_hash = compute_hash (SL_Screen[i].neew, Screen_Cols);
}
#endif
-
- if (Cls_Flag)
+
+ if (Cls_Flag)
{
SLtt_normal_video (); SLtt_cls ();
}
for (i = 0; i < Screen_Rows; i++)
{
int trashed;
-
+
if (SL_Screen[i].flags == 0) continue;
-
+
if (SL_Screen[i].flags & TRASHED)
{
SLtt_goto_rc (i, -1); /* Force cursor to move */
trashed = 1;
}
else trashed = 0;
-
- if (Cls_Flag || trashed)
+
+ if (Cls_Flag || trashed)
{
int color = This_Color;
This_Color = 0;
blank_line (SL_Screen[i].old, Screen_Cols, ' ');
This_Color = color;
}
-
+
SL_Screen[i].old[Screen_Cols] = 0;
SL_Screen[i].neew[Screen_Cols] = 0;
-
+
SLtt_smart_puts (SL_Screen[i].neew, SL_Screen[i].old, Screen_Cols, i);
- SLMEMCPY ((char *) SL_Screen[i].old, (char *) SL_Screen[i].neew,
+ SLMEMCPY ((char *) SL_Screen[i].old, (char *) SL_Screen[i].neew,
Screen_Cols * sizeof (short));
SL_Screen[i].flags = 0;
SL_Screen[i].old_hash = SL_Screen[i].new_hash;
#endif
}
-
+
if (point_visible (1)) SLtt_goto_rc (This_Row - Start_Row, This_Col - Start_Col);
SLtt_flush_output ();
Cls_Flag = 0;
int *rmin, int *rmax)
{
int row_max;
-
+
if (n < 0) return 0;
if (row >= box_end) return 0;
row_max = row + n;
if (row_max <= box_start) return 0;
-
+
if (row < box_start) row = box_start;
if (row_max >= box_end) row_max = box_end;
*rmin = row;
{
int i;
int r1, r2;
-
+
if (0 == compute_clip (row, n, Start_Row, Start_Row + Screen_Rows, &r1, &r2))
return;
-
+
r1 -= Start_Row;
r2 -= Start_Row;
for (i = r1; i < r2; i++)
{
int i;
unsigned char *p, *pmax, ch;
-
+
if (Alt_Char_Set[128] == 128) return;
i = 32;
memset ((char *)Alt_Char_Set, ' ', i);
- while (i <= 128)
+ while (i <= 128)
{
Alt_Char_Set [i] = i;
i++;
}
-
+
/* Map to VT100 */
if (SLtt_Has_Alt_Charset)
{
}
else p = (unsigned char *) Fake_Alt_Char_Pairs;
pmax = p + strlen ((char *) p);
-
+
/* Some systems have messed up entries for this */
while (p < pmax)
{
SLtt_reset_video ();
Smg_Suspended = 1;
}
-
+
UNBLOCK_SIGNALS
}
int i;
BLOCK_SIGNALS
- if (Smg_Suspended == 0)
+ if (Smg_Suspended == 0)
{
UNBLOCK_SIGNALS
return;
}
-
+
Smg_Suspended = 0;
SLtt_init_video ();
Cls_Flag = 1;
for (i = 0; i < Screen_Rows; i++)
SL_Screen[i].flags |= TRASHED;
SLsmg_refresh ();
-
+
UNBLOCK_SIGNALS
}
int i, len;
unsigned short *old, *neew;
BLOCK_SIGNALS
-
+
if (Smg_Inited) SLsmg_reset_smg ();
SLtt_init_video ();
Screen_Cols = SLtt_Screen_Cols;
{
int i;
BLOCK_SIGNALS
-
- if (Smg_Inited == 0)
+
+ if (Smg_Inited == 0)
{
UNBLOCK_SIGNALS
return;
SLtt_reset_video ();
This_Alt_Char = This_Color = 0;
Smg_Inited = 0;
-
+
UNBLOCK_SIGNALS
}
void SLsmg_vprintf (char *fmt, va_list ap)
{
char p[1000];
-
+
(void) vsprintf(p, fmt, ap);
-
+
SLsmg_write_string (p);
}
void SLsmg_set_screen_start (int *r, int *c)
{
int or = Start_Row, oc = Start_Col;
-
+
if (c == NULL) Start_Col = 0;
else
{
void SLsmg_draw_object (int r, int c, unsigned char object)
{
This_Row = r; This_Col = c;
-
+
if (point_visible (1))
{
int color = This_Color;
int cmin, cmax;
int final_col = This_Col + n;
int save_color;
-
- if ((This_Row < Start_Row) || (This_Row >= Start_Row + Screen_Rows)
+
+ if ((This_Row < Start_Row) || (This_Row >= Start_Row + Screen_Rows)
|| (0 == compute_clip (This_Col, n, Start_Col, Start_Col + Screen_Cols,
&cmin, &cmax)))
{
This_Col = final_col;
return;
}
-
+
if (hbuf[0] == 0)
{
SLMEMSET ((char *) hbuf, SLSMG_HLINE_CHAR, 16);
}
-
+
n = cmax - cmin;
count = n / 16;
-
+
save_color = This_Color;
This_Color |= ALT_CHAR_FLAG;
This_Col = cmin;
-
+
SLsmg_write_nchars ((char *) hbuf, n % 16);
while (count-- > 0)
{
SLsmg_write_nchars ((char *) hbuf, 16);
}
-
+
This_Color = save_color;
This_Col = final_col;
}
int c = This_Col, rmin, rmax;
int final_row = This_Row + n;
int save_color;
-
+
if (((c < Start_Col) || (c >= Start_Col + Screen_Cols)) ||
(0 == compute_clip (This_Row, n, Start_Row, Start_Row + Screen_Rows,
&rmin, &rmax)))
This_Row = final_row;
return;
}
-
+
save_color = This_Color;
This_Color |= ALT_CHAR_FLAG;
-
+
for (This_Row = rmin; This_Row < rmax; This_Row++)
{
This_Col = c;
SLsmg_write_nchars ((char *) &ch, 1);
}
-
+
This_Col = c; This_Row = final_row;
This_Color = save_color;
}
void SLsmg_draw_box (int r, int c, int dr, int dc)
{
- if (!dr || !dc) return;
+ if (!dr || !dc) return;
This_Row = r; This_Col = c;
dr--; dc--;
- SLsmg_draw_hline (dc);
+ SLsmg_draw_hline (dc);
SLsmg_draw_vline (dr);
This_Row = r; This_Col = c;
SLsmg_draw_vline (dr);
- SLsmg_draw_hline (dc);
+ SLsmg_draw_hline (dc);
SLsmg_draw_object (r, c, SLSMG_ULCORN_CHAR);
SLsmg_draw_object (r, c + dc, SLSMG_URCORN_CHAR);
SLsmg_draw_object (r + dr, c, SLSMG_LLCORN_CHAR);
SLsmg_draw_object (r + dr, c + dc, SLSMG_LRCORN_CHAR);
This_Row = r; This_Col = c;
}
-
+
void SLsmg_fill_region (int r, int c, int dr, int dc, unsigned char ch)
{
static unsigned char hbuf[16];
int count;
int dcmax, rmax;
-
-
+
+
if ((dc < 0) || (dr < 0)) return;
-
+
SLsmg_gotorc (r, c);
r = This_Row; c = This_Col;
-
+
dcmax = Screen_Cols - This_Col;
if (dc > dcmax) dc = dcmax;
-
+
rmax = This_Row + dr;
if (rmax > Screen_Rows) rmax = Screen_Rows;
ch = Alt_Char_Set[ch];
#endif
if (ch != hbuf[0]) SLMEMSET ((char *) hbuf, (char) ch, 16);
-
+
for (This_Row = r; This_Row < rmax; This_Row++)
{
This_Col = c;
SLsmg_write_nchars ((char *) hbuf, 16);
}
}
-
+
This_Row = r;
}
unsigned short *smax, sh;
char buf[32], *b, *bmax;
int color, save_color;
-
+
smax = s + len;
b = buf;
bmax = b + sizeof (buf);
-
+
save_color = This_Color;
while (s < smax)
{
sh = *s++;
-
+
color = sh >> 8;
if ((color != This_Color) || (b == bmax))
{
- if (b != buf)
+ if (b != buf)
{
SLsmg_write_nchars (buf, (int) (b - buf));
b = buf;
}
*b++ = (char) (sh & 0xFF);
}
-
+
if (b != buf)
SLsmg_write_nchars (buf, (int) (b - buf));
-
+
This_Color = save_color;
}
unsigned int r, c;
if (0 == point_visible (1)) return 0;
-
+
r = (unsigned int) (This_Row - Start_Row);
c = (unsigned int) (This_Col - Start_Col);
-
+
if (c + len > (unsigned int) Screen_Cols)
len = (unsigned int) Screen_Cols - c;
-
+
memcpy ((char *) buf, (char *) (SL_Screen[r].neew + c), len * sizeof (short));
return len;
}
{
unsigned int r, c;
unsigned short *dest;
-
+
if (0 == point_visible (1)) return 0;
-
+
r = (unsigned int) (This_Row - Start_Row);
c = (unsigned int) (This_Col - Start_Col);
-
+
if (c + len > (unsigned int) Screen_Cols)
len = (unsigned int) Screen_Cols - c;
-
+
dest = SL_Screen[r].neew + c;
-
+
if (0 != memcmp ((char *) dest, (char *) buf, len * sizeof (short)))
- {
+ {
memcpy ((char *) dest, (char *) buf, len * sizeof (short));
SL_Screen[r].flags |= TOUCHED;
}
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
* The majority of the comments found in the file were taken from the
* term(4) man page on an SGI.
*/
-
+
/* Short integers are stored in two 8-bit bytes. The first byte contains
* the least significant 8 bits of the value, and the second byte contains
* the most significant 8 bits. (Thus, the value represented is
* tic, and read by the routine setupterm [see curses(3X).] The file is
* divided into six parts in the following order: the header, terminal
* names, boolean flags, numbers, strings, and string table.
- *
+ *
* The header section begins the file. This section contains six short
* integers in the format described below. These integers are (1) the magic
* number (octal 0432); (2) the size, in bytes, of the names section; (3)
#define MAGIC 0432
-/* In this structure, all char * fields are malloced EXCEPT if the
+/* In this structure, all char * fields are malloced EXCEPT if the
* structure is SLTERMCAP. In that case, only terminal_names is malloced
* and the other fields are pointers into it.
*/
unsigned int name_section_size;
char *terminal_names;
-
+
unsigned int boolean_section_size;
unsigned char *boolean_flags;
-
+
unsigned int num_numbers;
unsigned char *numbers;
-
+
unsigned int num_string_offsets;
unsigned char *string_offsets;
-
+
unsigned int string_table_size;
char *string_table;
-
+
} Terminfo_Type;
static char *tcap_getstr (char *, Terminfo_Type *);
{
FILE *fp;
unsigned char buf[12];
-
+
fp = fopen (file, "rb");
if (fp == NULL) return NULL;
-
+
if ((12 == fread ((char *) buf, 1, 12, fp) && (MAGIC == make_integer (buf))))
{
h->name_section_size = make_integer (buf + 2);
h->num_string_offsets = make_integer (buf + 8);
h->string_table_size = make_integer (buf + 10);
}
- else
+ else
{
fclose (fp);
fp = NULL;
}
return fp;
}
-
-/*
+
+/*
* The terminal names section comes next. It contains the first line of the
* terminfo description, listing the various names for the terminal,
* separated by the bar ( | ) character (see term(5)). The section is
static unsigned char *read_terminfo_section (FILE *fp, unsigned int size)
{
char *s;
-
+
if (NULL == (s = (char *) SLMALLOC (size))) return NULL;
if (size != fread (s, 1, size, fp))
{
* even byte offset. All short integers are aligned on a short word
* boundary.
*/
-
+
unsigned int size = (t->name_section_size + t->boolean_section_size) % 2;
size += t->boolean_section_size;
-
+
return t->boolean_flags = read_terminfo_section (fp, size);
}
-/*
+/*
* The numbers section is similar to the boolean flags section. Each
* capability takes up two bytes, and is stored as a short integer. If the
* value represented is -1 or -2, the capability is taken to be missing.
*/
#define MAX_TI_DIRS 7
-static char *Terminfo_Dirs [MAX_TI_DIRS] =
+static char *Terminfo_Dirs [MAX_TI_DIRS] =
{
NULL,
"/usr/lib/terminfo",
char *SLtt_tigetent (char *term)
{
- char *tidir;
+ char *tidir;
int i;
FILE *fp = NULL;
char file[256];
Terminfo_Type *ti;
if (
- (term == NULL)
+ (term == NULL)
#ifdef SLANG_UNTIC
&& (SLang_Untic_Terminfo_File == NULL)
#endif
)
return NULL;
-
+
if (NULL == (ti = (Terminfo_Type *) SLMALLOC (sizeof (Terminfo_Type))))
{
return NULL;
}
-
+
#ifdef SLANG_UNTIC
if (SLang_Untic_Terminfo_File != NULL)
{
#endif
/* If we are on a termcap based system, use termcap */
if (0 == tcap_getent (term, ti)) return (char *) ti;
-
+
Terminfo_Dirs[0] = getenv ("TERMINFO");
i = 0;
while (i < MAX_TI_DIRS)
#ifdef SLANG_UNTIC
fp_open_label:
#endif
-
- if (fp != NULL)
+
+ if (fp != NULL)
{
if (NULL != read_terminal_names (fp, ti))
{
}
fclose (fp);
}
-
+
SLFREE (ti);
return NULL;
}
# define UNTIC_COMMENT(x)
#endif
-typedef struct
+typedef struct
{
char name[3];
int offset;
(void) t;
cha = *cap++; chb = *cap;
-
+
while (*map->name != 0)
{
if ((cha == *map->name) && (chb == *(map->name + 1)))
return -1;
}
-
+
char *SLtt_tigetstr (char *cap, char **pp)
{
int offset;
Terminfo_Type *t;
-
+
if ((pp == NULL) || (NULL == (t = (Terminfo_Type *) *pp))) return NULL;
-
+
if (t->flags == SLTERMCAP) return tcap_getstr (cap, t);
-
+
offset = compute_cap_offset (cap, t, Tgetstr_Map, t->num_string_offsets);
if (offset < 0) return NULL;
offset = make_integer (t->string_offsets + 2 * offset);
{
int offset;
Terminfo_Type *t;
-
+
if ((pp == NULL) || (NULL == (t = (Terminfo_Type *) *pp))) return -1;
if (t->flags == SLTERMCAP) return tcap_getnum (cap, t);
{
int offset;
Terminfo_Type *t;
-
+
if ((pp == NULL) || (NULL == (t = (Terminfo_Type *) *pp))) return -1;
if (t->flags == SLTERMCAP) return tcap_getflag (cap, t);
-
+
offset = compute_cap_offset (cap, t, Tgetflag_Map, t->boolean_section_size);
-
+
if (offset < 0) return -1;
return (int) *(t->boolean_flags + offset);
}
char a, b;
char *f = (char *) t->boolean_flags;
char *fmax;
-
+
if (f == NULL) return 0;
fmax = f + t->boolean_section_size;
{
unsigned char c0, c1;
unsigned char *caps_max;
-
+
c0 = cap[0];
c1 = cap[1];
-
+
if (caps == NULL) return NULL;
caps_max = caps + len;
while (caps < caps_max)
return NULL;
}
-
+
static int tcap_getnum (char *cap, Terminfo_Type *t)
{
cap = tcap_get_cap ((unsigned char *) cap, t->numbers, t->num_numbers);
unsigned char *buf, *b;
unsigned char *t;
int len;
-
+
if (SLtt_Try_Termcap == 0) return -1;
#if 1
/* XFREE86 xterm sets the TERMCAP environment variable to an invalid
#endif
termcap = (unsigned char *) getenv ("TERMCAP");
if ((termcap == NULL) || (*termcap == '/')) return -1;
-
- /* We have a termcap so lets use it provided it does not have a reference
+
+ /* We have a termcap so lets use it provided it does not have a reference
* to another terminal via tc=. In that case, user terminfo. The alternative
* would be to parse the termcap file which I do not want to do right now.
* Besides, this is a terminfo based system and if the termcap were parsed
return -1;
t += (len + 1);
}
-
+
/* malloc some extra space just in case it is needed. */
len = strlen ((char *) termcap) + 256;
if (NULL == (buf = (unsigned char *) SLMALLOC ((unsigned int) len))) return -1;
b = buf;
-
+
/* The beginning of the termcap entry contains the names of the entry.
- * It is terminated by a colon.
+ * It is terminated by a colon.
*/
-
+
ti->terminal_names = (char *) b;
t = termcap;
len = tcap_extract_field (t);
b[len] = 0;
b += len + 1;
ti->name_section_size = len;
-
-
- /* Now, we are really at the start of the termcap entries. Point the
+
+
+ /* Now, we are really at the start of the termcap entries. Point the
* termcap variable here since we want to refer to this a number of times.
*/
termcap = t + (len + 1);
-
-
+
+
/* Process strings first. */
ti->string_table = (char *) b;
t = termcap;
{
unsigned char *b1;
unsigned char *tmax;
-
+
/* We are looking for: XX=something */
if ((len < 4) || (t[2] != '=') || (*t == '.'))
{
}
tmax = t + len;
b1 = b;
-
+
while (t < tmax)
{
ch = *t++;
b1[2] = (unsigned char) len; /* replace the = by the length */
/* skip colon to next field. */
t++;
- }
+ }
ti->string_table_size = (int) (b - (unsigned char *) ti->string_table);
/* Now process the numbers. */
{
unsigned char *b1;
unsigned char *tmax;
-
+
/* We are looking for: XX#NUMBER */
if ((len < 4) || (t[2] != '#') || (*t == '.'))
{
}
tmax = t + len;
b1 = b;
-
+
while (t < tmax)
{
*b++ = *t++;
len = (int) (b - b1);
b1[2] = (unsigned char) len; /* replace the # by the length */
t++;
- }
+ }
ti->num_numbers = (int) (b - ti->numbers);
-
+
/* Now process the flags. */
t = termcap;
ti->boolean_flags = b;
while (-1 != (len = tcap_extract_field (t)))
{
/* We are looking for: XX#NUMBER */
- if ((len != 2) || (*t == '.') || (*t <= ' '))
+ if ((len != 2) || (*t == '.') || (*t <= ' '))
{
t += len + 1;
continue;
b[1] = t[1];
t += 3;
b += 2;
- }
+ }
ti->boolean_section_size = (int) (b - ti->boolean_flags);
ti->flags = SLTERMCAP;
return 0;
int i = 0;
int max = 0, num, base = 0;
char ch1;
-
+
ch1 = *p++;
-
+
switch (ch1)
{
default: num = ch1; break;
case 'r': num = '\r'; break;
case 'f': num = '\f'; break;
case 'E': case 'e': num = 27; break;
- case 'a': num = 7;
+ case 'a': num = 7;
break;
-
+
/* octal */
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- max = '7';
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ max = '7';
base = 8; i = 2; num = ch1 - '0';
break;
-
+
case 'd': /* decimal -- S-Lang extension */
- base = 10;
+ base = 10;
i = 3;
max = '9';
num = 0;
break;
-
+
case 'x': /* hex */
base = 16;
max = '9';
num = 0;
break;
}
-
+
while (i--)
{
ch1 = *p;
-
+
if ((ch1 <= max) && (ch1 >= '0'))
{
num = base * num + (ch1 - '0');
else break;
p++;
}
-
+
*ch = (char) num;
return p;
}
-void SLexpand_escaped_string (register char *s, register char *t,
+void SLexpand_escaped_string (register char *s, register char *t,
register char *tmax)
{
char ch;
-
+
while (t < tmax)
{
ch = *t++;
int string;
char ch1;
char *word_max;
-
+
word_max = word + 250;
-
+
line = *linep;
/* skip white space */
- while (((ch = *line) == ' ')
+ while (((ch = *line) == ' ')
|| (ch == '\t')) line++;
if ((!ch) || (ch == '\n'))
*linep = line;
return(0);
}
-
+
*word++ = ch;
line++;
-
+
/* Look for -something and rule out --something and -= something */
- if ((ch == '-') &&
+ if ((ch == '-') &&
(*line != '-') && (*line != '=') && ((*line > '9') || (*line < '0')))
{
*word = 0;
*linep = line;
return 1;
}
-
-
+
+
if (ch == '"') string = 1; else string = 0;
if (ch == '\'')
{
if ((ch = *line++) != 0)
{
- if (ch == '\\')
+ if (ch == '\\')
{
line = SLexpand_escaped_char(line, &ch1);
ch = ch1;
}
else if (!special_chars[(unsigned char) ch])
{
- while (ch = *line++,
- (ch > '"') ||
+ while (ch = *line++,
+ (ch > '"') ||
((ch != '\n') && (ch != 0) && (ch != '"')))
{
if (string)
ch = *line++;
if ((ch == 0) || (ch == '\n')) break;
if (byte_comp) *word++ = '\\';
- else
+ else
{
line = SLexpand_escaped_char(line - 1, &ch1);
ch = ch1;
line--;
break;
}
-
+
*word++ = ch;
if (word > word_max)
{
}
}
}
-
+
if ((!ch) || (ch == '\n')) line--;
if ((ch == '"') && string) *word++ = '"'; else if (string) SLang_Error = SYNTAX_ERROR;
*word = 0;
if (*t == '-') t++;
p = t;
#ifdef FLOAT_TYPE
- if (*p != '.')
+ if (*p != '.')
{
#endif
while ((*p >= '0') && (*p <= '9')) p++;
if ((*p == 'x') && (p == t + 1)) /* 0x?? */
{
p++;
- while (ch = *p,
+ while (ch = *p,
((ch >= '0') && (ch <= '9'))
|| (((ch | 0x20) >= 'a') && ((ch | 0x20) <= 'f'))) p++;
}
return(STRING_TYPE);
#else
}
-
+
/* now down to float case */
if (*p == '.')
{
register unsigned char ch;
register unsigned int value;
register int base;
-
+
if (*s != '0') return atoi((char *) s);
/* look for 'x' which indicates hex */
s++;
- if ((*s | 0x20) == 'x')
+ if ((*s | 0x20) == 'x')
{
base = 16;
s++;
- if (*s == 0)
+ if (*s == 0)
{
SLang_Error = SYNTAX_ERROR;
return -1;
}
}
else base = 8;
-
-
+
+
value = 0;
while ((ch = *s++) != 0)
{
case '7':
ch1 -= '0';
break;
-
+
case 'a':
case 'b':
case 'c':
/* slutty.c --- Unix Low level terminal (tty) functions for S-Lang */
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
static TTY_Termio_Type Old_TTY;
#ifdef HAVE_TERMIOS_H
-static struct
+static struct
{
speed_t key;
int value;
-} Baud_Rates[] =
+} Baud_Rates[] =
{
{B0, 0},
- {B50, 50},
- {B75, 75},
- {B110, 110},
- {B134, 134},
- {B150, 150},
- {B200, 200},
- {B300, 300},
- {B600, 600},
- {B1200, 1200},
- {B1800, 1800},
- {B2400, 2400},
- {B4800, 4800},
- {B9600, 9600},
- {B19200, 19200},
+ {B50, 50},
+ {B75, 75},
+ {B110, 110},
+ {B134, 134},
+ {B150, 150},
+ {B200, 200},
+ {B300, 300},
+ {B600, 600},
+ {B1200, 1200},
+ {B1800, 1800},
+ {B2400, 2400},
+ {B4800, 4800},
+ {B9600, 9600},
+ {B19200, 19200},
{B38400, 38400}
#ifdef B57600
, {B57600, 57600}
speed_t2baud_rate (speed_t s)
{
int i;
-
+
for (i = 0; i < sizeof (Baud_Rates)/sizeof (Baud_Rates[0]); i++)
if (Baud_Rates[i].key == s)
return (Baud_Rates[i].value);
int SLang_init_tty (int abort_char, int no_flow_control, int opost)
{
TTY_Termio_Type newtty;
-
+
SLsig_block_signals ();
-
- if (TTY_Inited)
+
+ if (TTY_Inited)
{
SLsig_unblock_signals ();
return 0;
}
-
+
TTY_Open = 0;
-
+
if ((SLang_TT_Read_FD == -1)
|| (1 != isatty (SLang_TT_Read_FD)))
{
#if 0
/* In the Midnight Commander we bind stderr sometimes to a pipe. If we
use stderr for terminal input and call SLang_getkey while stderr is
- bound to a pipe MC will hang completly in SLsys_input_pending.
+ bound to a pipe MC will hang completly in SLsys_input_pending.
NOTE: There's an independent fix for this problem in src/slint.c for
- the case that the Midnight Commander is linked against a shared slang
+ the case that the Midnight Commander is linked against a shared slang
library compiled from different sources.
*/
SLang_TT_Read_FD = fileno (stderr);
if (1 != isatty (SLang_TT_Read_FD))
-#endif
+#endif
{
SLang_TT_Read_FD = fileno (stdin);
if (1 != isatty (SLang_TT_Read_FD))
}
}
}
-
+
SLang_Abort_Char = abort_char;
-
- /* Some systems may not permit signals to be blocked. As a result, the
+
+ /* Some systems may not permit signals to be blocked. As a result, the
* return code must be checked.
*/
while (-1 == GET_TERMIOS(SLang_TT_Read_FD, &Old_TTY))
return -1;
}
}
-
+
while (-1 == GET_TERMIOS(SLang_TT_Read_FD, &newtty))
{
if (errno != EINTR)
return -1;
}
}
-
+
#ifndef HAVE_TERMIOS_H
newtty.s.sg_flags &= ~(ECHO);
newtty.s.sg_flags &= ~(CRMOD);
newtty.lt.t_lnextc = 255;
newtty.s.sg_flags |= CBREAK; /* do I want cbreak or raw????? */
#else
-
+
/* get baud rate */
-
+
/* [not only QNX related !?!]
* ECHO(0x08) is a c_lflag bit, it means here PARMRK(0x08) in c_iflag!!!
*/
if (SLang_TT_Baud_Rate == 0)
{
-/* Note: if this generates an compiler error, simply remove
+/* Note: if this generates an compiler error, simply remove
the statement */
#ifdef HAVE_CFGETOSPEED
SLang_TT_Baud_Rate = cfgetospeed (&newtty);
-#endif
+#endif
SLang_TT_Baud_Rate = speed_t2baud_rate (SLang_TT_Baud_Rate);
}
if (no_flow_control) newtty.c_iflag &= ~IXON; else newtty.c_iflag |= IXON;
newtty.c_cc[VSWTCH] = NULL_VALUE; /* to ignore who knows what */
#endif
#endif /* NOT HAVE_TERMIOS_H */
-
+
while (-1 == SET_TERMIOS(SLang_TT_Read_FD, &newtty))
{
if (errno != EINTR)
return -1;
}
}
-
+
TTY_Inited = 1;
SLsig_unblock_signals ();
return 0;
void SLtty_set_suspend_state (int mode)
{
TTY_Termio_Type newtty;
-
+
SLsig_block_signals ();
-
+
if (TTY_Inited == 0)
{
SLsig_unblock_signals ();
return;
}
-
+
while ((-1 == GET_TERMIOS (SLang_TT_Read_FD, &newtty))
&& (errno == EINTR))
;
-
+
#ifndef HAVE_TERMIOS_H
if (mode == 0) newtty.lt.t_suspc = 255;
else newtty.lt.t_suspc = Old_TTY.lt.t_suspc;
if (mode == 0) newtty.c_cc[VSUSP] = NULL_VALUE;
else newtty.c_cc[VSUSP] = Old_TTY.c_cc[VSUSP];
#endif
-
+
while ((-1 == SET_TERMIOS (SLang_TT_Read_FD, &newtty))
&& (errno == EINTR))
;
void SLang_reset_tty (void)
{
SLsig_block_signals ();
-
+
if (TTY_Inited == 0)
{
SLsig_unblock_signals ();
return;
}
-
+
while ((-1 == SET_TERMIOS(SLang_TT_Read_FD, &Old_TTY))
&& (errno == EINTR))
;
-
+
if (TTY_Open)
{
while ((-1 == close (SLang_TT_Read_FD))
&& (errno == EINTR))
;
-
+
TTY_Open = 0;
SLang_TT_Read_FD = -1;
}
-
+
TTY_Inited = 0;
SLsig_unblock_signals ();
}
static void default_sigint (int sig)
{
sig = errno; /* use parameter */
-
+
SLKeyBoard_Quit = 1;
if (SLang_Ignore_User_Abort == 0) SLang_Error = USER_BREAK;
SLsignal_intr (SIGINT, default_sigint);
void SLang_set_abort_signal (void (*hand)(int))
{
int save_errno = errno;
-
+
if (hand == NULL) hand = default_sigint;
SLsignal_intr (SIGINT, hand);
-
+
errno = save_errno;
}
long usecs, secs;
if (TTY_Inited == 0) return -1;
-
+
if (tsecs >= 0)
{
secs = tsecs / 10;
secs = tsecs / 1000;
usecs = (tsecs % 1000) * 1000;
}
-
+
wait.tv_sec = secs;
wait.tv_usec = usecs;
FD_ZERO(&Read_FD_Set);
FD_SET(SLang_TT_Read_FD, &Read_FD_Set);
-
+
return select(SLang_TT_Read_FD + 1, &Read_FD_Set, NULL, NULL, &wait);
}
if (SLang_getkey_intr_hook != NULL)
{
int save_tty_fd = SLang_TT_Read_FD;
-
+
if (-1 == (*SLang_getkey_intr_hook) ())
return -1;
-
+
if (save_tty_fd != SLang_TT_Read_FD)
return -1;
}
-
+
return 0;
}
unsigned int SLsys_getkey (void)
{
unsigned char c;
-
+
if (TTY_Inited == 0)
{
int ic = fgetc (stdin);
if (ic == EOF) return SLANG_GETKEY_ERROR;
return (unsigned int) ic;
}
-
+
while (1)
{
int ret;
-
- if (SLKeyBoard_Quit)
+
+ if (SLKeyBoard_Quit)
return SLang_Abort_Char;
-
+
if (0 == (ret = SLsys_input_pending (100)))
continue;
-
+
if (ret != -1)
break;
-
- if (SLKeyBoard_Quit)
+
+ if (SLKeyBoard_Quit)
return SLang_Abort_Char;
-
+
if (errno == EINTR)
{
if (-1 == handle_interrupt ())
return SLANG_GETKEY_ERROR;
-
+
continue;
}
-
+
break; /* let read handle it */
}
-
+
while (-1 == read(SLang_TT_Read_FD, (char *) &c, 1))
{
- if (errno == EINTR)
+ if (errno == EINTR)
{
if (-1 == handle_interrupt ())
return SLANG_GETKEY_ERROR;
-
- if (SLKeyBoard_Quit)
+
+ if (SLKeyBoard_Quit)
return SLang_Abort_Char;
-
+
continue;
}
#ifdef EAGAIN
- if (errno == EAGAIN)
+ if (errno == EAGAIN)
{
sleep (1);
continue;
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
#define JNORMAL_COLOR 0
#define JNO_COLOR -1
-static unsigned char Color_Map [JMAX_COLORS] =
+static unsigned char Color_Map [JMAX_COLORS] =
{
0x7, 0x70, 0x70, 0x70, 0x70, 0x7, 0x7, 0x7,
0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7,
static void save_screen (void)
{
int row, col;
-
+
if (Saved_Screen_Buffer != NULL)
{
SLFREE (Saved_Screen_Buffer);
Saved_Screen_Buffer = NULL;
}
-#ifdef GO32_VIDEO
- Saved_Screen_Buffer = SLMALLOC (sizeof (short) *
+#ifdef GO32_VIDEO
+ Saved_Screen_Buffer = SLMALLOC (sizeof (short) *
ScreenCols () * ScreenRows ());
if (Saved_Screen_Buffer == NULL)
return;
-
+
ScreenRetrieve (Saved_Screen_Buffer);
ScreenGetCursor (&row, &col);
Saved_Cursor_Row = row;
#endif
-
+
}
static void restore_screen (void)
ScreenUpdate (Saved_Screen_Buffer);
SLtt_goto_rc (Saved_Cursor_Row, 0);
#endif
-
+
}
#endif /* HAS_SAVE_SCREEN */
/*----------------------------------------------------------------------*\
{
#ifdef WIN32
unsigned long bytes;
-
+
(void) WriteConsole(hStdout, str, strlen(str), &bytes, NULL);
#else
fputs (str, stdout);
newPosition.X = col;
newPosition.Y = row;
#endif
-
+
#if !defined (USE_ASM)
if (row > SLtt_Screen_Rows) row = SLtt_Screen_Rows;
if (col > SLtt_Screen_Cols) col = SLtt_Screen_Cols;
unsigned char *p, *pmax;
int w = mkSpaceChar ();
int count = SLtt_Screen_Cols - x;
-
+
p = Line_Buffer;
pmax = p + 2 * count;
-
+
while (p < pmax)
{
*p++ = (unsigned char) w;
slvid_getxy ();
n = SLtt_Screen_Cols - Cursor_Col;
/* Msdos_Insert_Mode = 1; */
-
+
# ifndef WIN32
# if defined (EMX_VIDEO)
v_getline (Line_Buffer, Cursor_Col, Cursor_Row, n);
VioWrtCellStr ((PCH)Line_Buffer, n, Cursor_Row, Cursor_Col + 1, 0);
# else /* __os2__ */
p = mkScreenPointer (Cursor_Row, SLtt_Screen_Cols - 1);
-
+
# if defined (HAS_LINEAR_SCREEN)
/* pmin = p - (n-1); */
pmin = mkScreenPointer (Cursor_Row, Cursor_Col);
asm mov ax, ds
asm mov bx, di
asm mov dx, si
-
+
asm mov cx, n
asm les di, p
asm lds si, p
asm sub si, 2
asm std
asm rep movsw
-
+
asm mov ds, ax
asm mov di, bx
asm mov si, dx
# endif /* HAS_LINEAR_SCREEN */
# endif /* __os2__ */
# endif /* EMX_VIDEO */
-
+
# endif /* WIN32 */
-
+
#endif /* not GO32_VIDEO */
}
# endif
# endif
int n;
-
+
slvid_getxy ();
n = SLtt_Screen_Cols - Cursor_Col - 1;
-
+
# ifndef WIN32
-
+
# if defined (EMX_VIDEO)
v_getline (Line_Buffer, Cursor_Col+1, Cursor_Row, n);
v_putline (Line_Buffer, Cursor_Col, Cursor_Row, n);
return;
# else /* __os2__ */
p = mkScreenPointer (Cursor_Row, Cursor_Col);
-
+
# if defined (HAS_LINEAR_SCREEN)
while (n--)
{
asm mov ax, ds
asm mov bx, si
asm mov dx, di
-
+
asm mov cx, n
asm les di, p
asm lds si, p
asm add si, 2
asm cld
asm rep movsw
-
+
asm mov ds, ax
asm mov si, bx
asm mov di, dx
# endif /* HAS_LINEAR_SCREEN */
# endif /* __os2__ */
# endif /* EMX_VIDEO */
-
+
# endif /* WIN32 */
-
+
#endif /* not GO32_VIDEO */
}
\*----------------------------------------------------------------------*/
void SLtt_erase_line (void)
{
-
+
#ifndef WIN32
-
+
# if defined (GO32_VIDEO) || defined (EMX_VIDEO)
Attribute_Byte = 0x07;
slvid_deleol (0);
unsigned short *p = mkScreenPointer (Cursor_Row, 0);
# if defined (HAS_LINEAR_SCREEN)
register unsigned short *pmax = p + SLtt_Screen_Cols;
-
+
Attribute_Byte = 0x07;
w = mkSpaceChar ();
while (p < pmax) *p++ = w;
# endif /* __os2__ */
# endif /* GO32_VIDEO or EMX_VIDEO */
Current_Color = JNO_COLOR; /* since we messed with attribute byte */
-
+
#endif /* WIN32 */
-
+
}
/*----------------------------------------------------------------------*\
void SLtt_delete_nlines (int nlines)
{
SLtt_normal_video ();
-
+
#ifndef WIN32
-
+
# if defined (EMX_VIDEO)
v_attrib (Attribute_Byte);
v_scroll (0, Scroll_r1, SLtt_Screen_Cols-1, Scroll_r2, nlines, V_SCROLL_UP);
# endif /* USE_ASM */
# endif /* __os2__ */
# endif /* EMX_VIDEO */
-
+
#endif /* WIN32 */
-
+
}
/*----------------------------------------------------------------------*\
void SLtt_reverse_index (int nlines)
{
SLtt_normal_video ();
-
+
#ifndef WIN32
-
+
# if defined (EMX_VIDEO)
v_attrib (Attribute_Byte);
v_scroll (0, Scroll_r1, SLtt_Screen_Cols-1, Scroll_r2, nlines,
# endif /* USE_ASM */
# endif /* __os2__ */
# endif /* EMX_VIDEO */
-
+
#endif /* WIN32 */
-
+
}
/*----------------------------------------------------------------------*\
\*----------------------------------------------------------------------*/
static void slvid_invert_region (int top_row, int bot_row)
{
-
+
#ifndef WIN32
-
+
# if defined (EMX_VIDEO)
int row, col;
-
+
for (row = top_row; row < bot_row; row++)
{
v_getline (Line_Buffer, 0, row, SLtt_Screen_Cols);
# ifdef __os2__
int row, col;
USHORT length = SLtt_Screen_Cols * 2;
-
+
for (row = top_row; row < bot_row; row++)
{
VioReadCellStr ((PCH)Line_Buffer, &length, row, 0, 0);
# if defined (__GO32__) || defined (__WATCOMC__)
unsigned char buf [2 * 180 * 80]; /* 180 cols x 80 rows */
unsigned char *b, *bmax;
-
+
b = buf + 1 + 2 * SLtt_Screen_Cols * top_row;
bmax = buf + 1 + 2 * SLtt_Screen_Cols * bot_row;
ScreenRetrieve (buf);
register unsigned short ch, sh;
register unsigned short *pmin = mkScreenPointer (top_row, 0);
register unsigned short *pmax = mkScreenPointer (bot_row, 0);
-
+
while (pmin < pmax)
{
sh = *pmin;
# endif /* __GO32__ or __WATCOMC__ */
# endif /* __os2__ */
# endif /* EMX_VIDEO */
-
+
#endif /* WIN32 */
-
+
}
/*----------------------------------------------------------------------*\
int special = 0; /* first row to invert */
int visual = 0; /* final row to invert */
if (!SLtt_Ignore_Beep) return;
-
+
audible = (SLtt_Ignore_Beep & 1);
if ( (SLtt_Ignore_Beep & 4) )
{
{
visual = SLtt_Screen_Rows;
}
-
+
if (visual) slvid_invert_region (special, visual);
#if defined (EMX_VIDEO)
if (audible) /*sound (1500)*/; _sleep2 (100); if (audible) /* nosound () */;
#else
# ifdef __os2__
if (audible) DosBeep (1500, 100); else DosSleep (100);
-
+
# elif defined(WIN32)
-
+
# else
if (audible) sound (1500); delay (100); if (audible) nosound ();
# endif
\*----------------------------------------------------------------------*/
void SLtt_del_eol (void)
{
-
+
#ifndef WIN32
-
+
# if defined (GO32_VIDEO) || defined (EMX_VIDEO)
if (Current_Color != JNO_COLOR) SLtt_normal_video ();
slvid_deleol (Cursor_Col);
unsigned short w;
# if defined (HAS_LINEAR_SCREEN)
unsigned short *pmax = p + n;
-
+
if (Current_Color != JNO_COLOR) SLtt_normal_video ();
w = mkSpaceChar ();
while (p < pmax) *p++ = w;
asm mov cx, n
asm cld
asm rep stosw
-
+
asm mov di, dx
# endif /* HAS_LINEAR_SCREEN */
# endif /* __os2__ */
# endif /* GO32_VIDEO or EMX_VIDEO */
-
+
#endif /* WIN32 */
-
+
}
/*----------------------------------------------------------------------*\
register unsigned short *pos)
{
int n = (int) (p - pp); /* num of characters of PP to write */
-
+
asm push si
asm push ds
asm push di
-
+
/* set up register for BOTH fast and slow */
asm mov bx, SLtt_Msdos_Cheap_Video
-
+
/* These are the registers needed for both fast AND slow */
asm mov ah, byte ptr Attribute_Byte
asm mov cx, n
asm lds si, dword ptr pp
asm les di, dword ptr pos
asm cld
-
+
asm cmp bx, 0 /* cheap video test */
asm je L_fast
asm mov bx, ax
asm mov dx, CGA_STATUS
asm jg L_slow_blank
-
+
/* slow video */
asm cli
-
+
/* wait for retrace */
L_slow:
asm in al, dx
asm test al, 1
asm jnz L_slow
-
+
L_slow1:
asm in al, dx
asm test al, 1
asm jz L_slow1
-
+
/* move a character out */
asm mov ah, bh
asm lodsb
asm stosw
asm loop L_slow
-
+
asm sti
asm jmp done
-
+
/* -------------- slow video, vertical retace and pump --------------*/
L_slow_blank:
L_slow_blank_loop:
asm in al, dx
asm test al, 8
asm jnz L_slow_blank_loop
-
+
L_slow_blank1:
asm in al, dx
asm test al, 8
asm lodsb
asm stosw
asm loop L_slow_blank2
-
+
asm jmp done
/*-------------- Fast video --------------*/
-
+
L_fast:
asm lodsb
asm stosw
register unsigned short *pos = mkScreenPointer (Cursor_Row, 0);
# endif
int n = count;
-
+
/* write into a character/attribute pair */
while (n-- > 0)
{
# endif
# endif
}
-
+
# if !defined (HAS_LINEAR_SCREEN)
# if defined (EMX_VIDEO)
v_putline (Line_Buffer, Cursor_Col, Cursor_Row, count);
coord.X = Cursor_Col;
coord.Y = Cursor_Row;
WriteConsoleOutputCharacter(hStdout, p, count, coord, &bytes);
-
+
/* write color attributes */
p = Line_Buffer;
n = count;
src = (unsigned short*)org_src; /* restart the src pointer */
-
+
/* write into attributes only */
while (n-- > 0)
{
*(p++) = Attribute_Byte; /* attribute byte */
*(p++) = 0; /* what's this for? */
}
-
+
WriteConsoleOutputAttribute(hStdout, (WORD*)Line_Buffer, count, coord, &bytes);
# else /* __os2__ */
/* ScreenUpdateLine (void *virtual_screen_line, int row); */
#else /* not USE_ASM */
unsigned char ch, color;
register unsigned short *pos = mkScreenPointer (Cursor_Row, 0);
-
+
while (count--)
{
pair = *(src++); /* character/color pair */
/* clear the WIN32 screen in one shot */
coord.X = 0;
coord.Y = 0;
-
+
ch = ' ';
-
+
(void) FillConsoleOutputCharacter(hStdout,
ch,
csbiInfo.dwMaximumWindowSize.Y * csbiInfo.dwMaximumWindowSize.X,
coord,
&bytes);
-
+
/* now set screen to the current attribute */
ch = Attribute_Byte;
(void) FillConsoleOutputAttribute(hStdout,
long bytes;
# endif
#endif
-
+
if (Current_Color) SLtt_normal_video ();
slvid_getxy (); /* get current position */
switch (ch)
# else /* GO32_VIDEO */
pp = mkScreenPointer (Cursor_Row, Cursor_Col);
p = (Attribute_Byte << 8) | (unsigned char) ch;
-
+
# ifdef USE_ASM
SNOW_CHECK;
# endif
#ifdef WIN32
int newcolor;
#endif
-
+
(void) what;
-
+
if ( !IsColor || (obj < 0) || (obj >= JMAX_COLORS))
return;
-
+
for (i = 0; i < JMAX_COLOR_NAMES; i++ )
{
if (!strcmp (fg, Color_Names [i]))
break;
}
}
-
+
for (i = 0; i < JMAX_COLOR_NAMES; i++)
{
if (!strcmp (bg, Color_Names [i]))
#if 1
Color_Map [obj] = (b << 4) | f;
#else
-
+
/*
0 1 2 3
"black", "blue", "green", "cyan",
12 13 14 15
"brightred", "brightmagenta", "yellow", "white"
*/
-
+
/* these aren't all right yet */
- switch (f)
+ switch (f)
{
case 0: newcolor = 0; break;
case 1: newcolor = FOREGROUND_BLUE; break;
case 2: newcolor = FOREGROUND_GREEN; break;
case 3: newcolor = FOREGROUND_GREEN | FOREGROUND_BLUE; break;
-
+
case 4: newcolor = FOREGROUND_RED; break;
case 5: newcolor = FOREGROUND_RED | FOREGROUND_BLUE; break;
case 6: newcolor = FOREGROUND_GREEN | FOREGROUND_RED; break;
case 7: newcolor = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break;
-
+
case 8: newcolor = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN; break;
case 9: newcolor = FOREGROUND_BLUE | FOREGROUND_INTENSITY; break;
case 10: newcolor = FOREGROUND_GREEN | FOREGROUND_INTENSITY; break;
case 11: newcolor = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break;
-
+
case 12: newcolor = FOREGROUND_RED | FOREGROUND_INTENSITY; break;
case 13: newcolor = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break;
case 14: newcolor = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break;
case 15: newcolor = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break;
}
// switch
-
+
/*
0 1 2 3
"black", "blue", "green", "cyan",
12 13 14 15
"brightred", "brightmagenta", "yellow", "white"
*/
-
- switch (b)
+
+ switch (b)
{
case 0: newcolor |= 0; break;
case 1: newcolor |= BACKGROUND_BLUE; break;
case 2: newcolor |= BACKGROUND_GREEN; break;
case 3: newcolor |= BACKGROUND_GREEN | BACKGROUND_BLUE; break;
-
+
case 4: newcolor |= BACKGROUND_RED; break;
case 5: newcolor |= BACKGROUND_RED | BACKGROUND_BLUE; break;
case 6: newcolor |= BACKGROUND_GREEN | BACKGROUND_RED; break;
case 7: newcolor |= BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY; break;
-
+
case 8: newcolor |= BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE; break;
case 9: newcolor |= BACKGROUND_BLUE | BACKGROUND_INTENSITY; break;
case 10: newcolor |= BACKGROUND_GREEN | BACKGROUND_INTENSITY; break;
case 11: newcolor |= BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY; break;
-
+
case 12: newcolor |= BACKGROUND_RED | BACKGROUND_INTENSITY; break;
case 13: newcolor |= BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY; break;
case 14: newcolor |= BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY; break;
case 15: newcolor |= BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY; break;
}
// switch
-
+
Color_Map [obj] = newcolor;
-
+
#endif
/* if we're setting the normal color, and the attribute byte hasn't
been set yet, set it to the new color */
- if ((obj == 0) && (Attribute_Byte == 0))
+ if ((obj == 0) && (Attribute_Byte == 0))
SLtt_reverse_video (0);
}
#if defined (EMX_VIDEO)
int OldCol, OldRow;
#endif
-
+
#ifdef HAS_SAVE_SCREEN
save_screen ();
#endif
Cursor_Row = Cursor_Col = 0;
-
+
#if defined (EMX_VIDEO)
-
+
v_init ();
if ( v_hardware () != V_MONOCHROME ) IsColor = 1; else IsColor = 0;
Blink_Killed = 1; /* seems to work */
}
}
-
+
if (!Attribute_Byte)
{
/* find the attribute currently under the cursor */
Attribute_Byte = Line_Buffer[1];
set_color_from_attribute (Attribute_Byte);
}
-
+
v_attrib (Attribute_Byte);
/* SLtt_Term_Cannot_Insert = 1; */
#else /* EMX_VIDEO */
VioSetState (&RequestBlock, 0); /* nop if !fullscreen */
Blink_Killed = 1;
}
-
+
if (!Attribute_Byte)
{
/* find the attribute currently under the cursor */
# endif
if (!Attribute_Byte) Attribute_Byte = 0x17;
IsColor = 1; /* is it really? */
-
+
if (IsColor)
{
union REGS r;
IsColor = 1;
}
}
-
+
/* test for video adapter type. Of primary interest is whether there is
* snow or not. Assume snow if the card is color and not EGA or greater.
*/
-
+
/* Use Ralf Brown test for EGA or greater */
asm mov ah, 0x12
asm mov bl, 0x10
asm int 10h
asm cmp bh, 0xFF
asm je L1
-
+
/* (V)EGA */
asm xor bx, bx
asm mov SLtt_Msdos_Cheap_Video, bx
asm mov ax, 0x17
asm mov Attribute_Byte, ax
asm jmp L2
-
+
L1:
/* Not (V)EGA */
asm mov ah, 0x0F
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
- *
+ *
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
if (flags & ENABLE_PROCESSED_INPUT) {
return -1;
}
- }
+ }
- (void) SetConsoleCursorPosition(hStdout, newPosition);
+ (void) SetConsoleCursorPosition(hStdout, newPosition);
/* success */
return 0;
while (1)
{
- if (PeekConsoleInput(hStdin, &record, 1, &bytesRead))
+ if (PeekConsoleInput(hStdin, &record, 1, &bytesRead))
{
- if (bytesRead == 1)
+ if (bytesRead == 1)
{
if ((record.EventType == KEY_EVENT)
- && record.Event.KeyEvent.bKeyDown)
+ && record.Event.KeyEvent.bKeyDown)
{
/* ok, there is a keypress here */
return 1;
- }
- else
+ }
+ else
{
/* something else is here, so read it and try again */
(void) ReadConsoleInput(hStdin, &record, 1, &bytesRead);
if (keyWaiting()) return 1;
while (count > 0)
{
- delay (20); 20 ms or 1/50 sec
+ delay (20); 20 ms or 1/50 sec
if (keyWaiting()) break;
count--;
}
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
m |= (s [1] == '-') ? 0 :
((s[1] == '+') ? (1 << (base + 1)) : (1 << (base + 1)) & ch_cmode);
-
+
m |= (s [2] == '-') ? 0 :
((s[2] == '+') ? (1 << base) : (1 << base) & ch_cmode);
dlg_move (ch_dlg, BY+1, 9+i);
addch (ch_flags [i]);
}
-
+
for (i = 0; i < 3; i++){
dlg_move (ch_dlg, BY + 1, 17 + i);
addch (ch_flags [i+3]);
}
-
+
for (i = 0; i < 3; i++){
dlg_move (ch_dlg, BY + 1, 25 + i);
addch (ch_flags [i+6]);
dlg_erase (h);
draw_box (h, 0, 0, 13, 17);
break;
-
+
case DLG_KEY:
switch (Par) {
case KEY_LEFT:
struct group *chl_grp;
WLEntry *fe;
int lxx, lyy, chl_end, b_pos;
-
+
do {
lxx = (COLS - 74) / 2 + ((f_pos == 3) ? 35 : 53);
lyy = (LINES - 13) / 2;
chl_end = 0;
-
+
chl_dlg = create_dlg (lyy, lxx, 13, 17, dialog_colors, chl_callback,
"[Chown-advanced]", "achown_enter", DLG_NONE);
-
+
/* get new listboxes */
chl_list = listbox_new (1, 1, 15, 11, 0, l_call, NULL);
-
+
listbox_add_item (chl_list, 0, 0, "<Unknown>", NULL);
-
+
if (f_pos == 3) {
/* get and put user names in the listbox */
setpwent ();
else
{
/* get and put group names in the listbox */
- setgrent ();
+ setgrent ();
while ((chl_grp = getgrent ())) {
listbox_add_item (chl_list, 0, 0, chl_grp->gr_name, NULL);
}
endgrent ();
fe = listbox_search_text (chl_list, get_group (sf_stat->st_gid));
}
-
+
if (fe)
listbox_select_entry (chl_list, fe);
-
+
b_pos = chl_list->pos;
add_widget (chl_dlg, chl_list);
-
+
run_dlg (chl_dlg);
-
+
if (b_pos != chl_list->pos){
int ok = 0;
if (f_pos == 3){
addstr (_("group"));
dlg_move (ch_dlg, BY - 1, 24);
addstr (_("other"));
-
+
dlg_move (ch_dlg, BY - 1, 35);
addstr (_("owner"));
dlg_move (ch_dlg, BY - 1, 53);
addstr (_("group"));
-
+
dlg_move (ch_dlg, 3, 4);
addstr (_("On"));
dlg_move (ch_dlg, BY + 1, 4);
addstr (_("Flag"));
dlg_move (ch_dlg, BY + 2, 4);
addstr (_("Mode"));
-
+
if (!single_set){
dlg_move (ch_dlg, 3, 54);
{
/* display file info */
attrset (COLOR_NORMAL);
-
+
/* name && mode */
dlg_move (ch_dlg, 3, 8);
printw ("%s", name_trunc (fname, 45));
dlg_move (ch_dlg, BY + 2, 9);
printw ("%12o", get_mode ());
-
+
/* permissions */
set_perm (b_att[0]->text, sf_stat->st_mode >> 6);
set_perm (b_att[1]->text, sf_stat->st_mode >> 3);
chown_refresh ();
chown_info_update ();
return 1;
-
+
case DLG_POST_KEY:
if (f_pos < 3)
b_setpos (f_pos);
case DLG_KEY:
switch (Par) {
-
+
case XCTRL('b'):
case KEY_LEFT:
if (f_pos < 5)
return (dec_flag_pos (f_pos));
break;
-
+
case XCTRL('f'):
case KEY_RIGHT:
if (f_pos < 5)
return (inc_flag_pos (f_pos));
break;
-
+
case ' ':
if (f_pos < 3)
return 1;
break;
-
+
case '\n':
case KEY_ENTER:
if (f_pos <= 2 || f_pos >= 5)
break;
do_enter_key (h, f_pos);
return 1;
-
+
case ALT ('x'):
i++;
-
+
case ALT ('w'):
i++;
-
+
case ALT ('r'):
Par = i + 3;
for (i = 0; i < 3; i++)
dlg_broadcast_msg (h, WIDGET_DRAW, 0);
send_message (h, h->current->widget, WIDGET_FOCUS, 0);
break;
-
+
case XCTRL ('x'):
i++;
-
+
case XCTRL ('w'):
i++;
-
+
case XCTRL ('r'):
Par = i;
for (i = 0; i < 3; i++)
dlg_broadcast_msg (h, WIDGET_DRAW, 0);
send_message (h, h->current->widget, WIDGET_FOCUS, 0);
break;
-
+
case 'x':
i++;
-
+
case 'w':
i++;
-
+
case 'r':
if (f_pos > 2)
break;
case '4':
i++;
-
+
case '2':
i++;
-
+
case '1':
if (f_pos > 2)
break;
ch_flags[flag_pos] = '=';
update_mode (h);
break;
-
+
case '-':
if (f_pos > 2)
break;
-
+
case '*':
if (Par == '*')
Par = '=';
-
+
case '=':
case '+':
if (f_pos > 4)
/* Background support.
Copyright (C) 1996 The Free Software Foundation
-
+
Written by: 1996 Miguel de Icaza
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#define mymsg "Desde el hijo\n\r"
struct TaskList *task_list = NULL;
-
+
void
register_task_running (pid_t pid, int fd, char *info)
{
{
int comm [2]; /* control connection stream */
int pid;
-
+
if (socketpair (AF_UNIX, SOCK_STREAM, 0, comm) == -1)
return -1;
-
+
if ((pid = fork ()) == -1)
return -1;
-
+
if (pid == 0){
int nullfd;
parent_fd = comm [1];
we_are_background = 1;
-
+
/* Make stdin/stdout/stderr point somewhere */
close (0);
close (1);
/* To make it obvious if it fails, there is a bug report on this */
write (2, mymsg, sizeof (mymsg));
write (1, mymsg, sizeof (mymsg));
-
+
/* Just for debugging the background back end */
if (background_wait){
volatile int i = 1;
-
+
while (i)
;
}
real_message_1s (enum OperationMode mode, int *flags, char *title, char *str1)
{
char *full_title;
-
+
if (mode == Background)
full_title = background_title (title);
else
full_title = title;
-
+
message (*flags, title, str1);
if (title != full_title)
real_message_2s (enum OperationMode mode, int *flags, char *title, char *str1, char *str2)
{
char *full_title;
-
+
if (mode == Background)
full_title = background_title (title);
else
full_title = title;
-
+
message (*flags, title, str1, str2);
-
+
if (title != full_title)
free (full_title);
}
real_message_3s (enum OperationMode mode, int *flags, char *title, char *str1, char *str2, const char *str3)
{
char *full_title;
-
+
if (mode == Background)
full_title = background_title (title);
else
full_title = title;
-
+
message (*flags, title, str1, str2, str3);
-
+
if (title != full_title)
free (full_title);
}
*/
/*
* Receive requests from background process and invoke the
- * specified routine
+ * specified routine
*/
int
int bytes;
enum ReturnType type;
char *background_process_error = _(" Background process error ");
-
+
bytes = read (fd, &routine, sizeof (routine));
if (bytes < (sizeof (routine))){
if (errno == ECHILD)
waitpid (pid, &status, 0);
return 0;
}
-
+
read (fd, &argc, sizeof (argc));
if (argc > MAXCALLARGS){
message (1, _(" Background protocol error "),
" than we can handle. \n"));
}
read (fd, &type, sizeof (type));
-
+
for (i = 0; i < argc; i++){
int size;
-
+
read (fd, &size, sizeof (size));
data [i] = xmalloc (size+1, "RPC Arguments");
read (fd, data [i], size);
-
+
data [i][size] = 0; /* NULL terminate the blocks (they could be strings) */
}
(Background, data [0], data [1], data [2], data [3]);
break;
}
-
+
/* Send the result code and the value for shared variables */
write (fd, &result, sizeof (int));
write (fd, &do_append, sizeof (do_append));
write (fd, &recursive_result, sizeof (recursive_result));
-
+
} else if (type == Return_String) {
int len;
{
va_list ap;
int i;
-
+
va_start (ap, argc);
parent_call_header (routine, argc, Return_Integer);
for (i = 0; i < argc; i++){
write (parent_fd, &len, sizeof (int));
write (parent_fd, value, len);
}
- /* Besides the regular result, get the value for
+ /* Besides the regular result, get the value for
* variables that may be modified in the parent that affect our behaviour
*/
read (parent_fd, &i, sizeof (int));
va_list ap;
char *str;
int i;
-
+
va_start (ap, argc);
parent_call_header (routine, argc, Return_String);
for (i = 0; i < argc; i++){
{
if (we_are_background)
return parent_call ((void *)routine, 1, strlen (str), str);
- else
+ else
return (*routine)(Foreground, str);
}
/* Some misc dialog boxes for the program.
-
+
Copyright (C) 1994, 1995 the Free Software Foundation
-
+
Authors: 1994, 1995 Miguel de Icaza
1995 Jakub Jelinek
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#ifndef HAVE_X
char *text;
WInput *input;
-
+
switch (Msg){
case DLG_DRAW:
attrset (COLOR_NORMAL);
input_set_point (status, 0);
}
break;
-
+
case DLG_KEY:
if (id == '\n'){
if((WRadio *) h->current->widget == my_radio){
dlg_stop (h);
break;
}
-
+
if ((WInput *) h->current->widget == user){
h->ret_value = B_USER + 6;
dlg_stop (h);
break;
}
-
+
if ((WInput *) h->current->widget == status){
h->ret_value = B_USER + 7;
dlg_stop (h);
return MSG_HANDLED;
}
}
-#endif
+#endif
return MSG_NOT_HANDLED;
}
char* user_mini_status = _("user &Mini status");
char* ok_button = _("&Ok");
char* cancel_button = _("&Cancel");
-
+
static int button_start = 30;
-
+
displays_status = _status;
if (!i18n_displays_flag){
i = strlen (user_mini_status) + 13;
if (i > DISPLAY_X)
DISPLAY_X = i;
-
+
i = strlen (display_title) + 8;
if (i > DISPLAY_X)
DISPLAY_X = i;
button_start = DISPLAY_X - l - 5;
-
+
/* get hotkey of user-defined format string */
cp = strchr(displays[LIST_TYPES-1],'&');
if (cp != NULL && *++cp != '\0')
x_set_dialog_title (dd, _("Listing mode"));
add_widgetl (dd,
- button_new (4, button_start, B_CANCEL,
+ button_new (4, button_start, B_CANCEL,
NORMAL_BUTTON, cancel_button, 0, 0, "cancel-button"),
XV_WLAY_RIGHTOF);
add_widgetl (dd,
- button_new (3, button_start, B_ENTER,
+ button_new (3, button_start, B_ENTER,
DEFPUSH_BUTTON, ok_button, 0, 0, "ok-button"),
XV_WLAY_CENTERROW);
check_status = check_new (9, 5, _check_status, user_mini_status, "mini-status");
add_widgetl (dd, check_status, XV_WLAY_NEXTROW);
-
+
user = input_new (7, 9, INPUT_COLOR, DISPLAY_X-14, init_text, "user-fmt-input");
add_widgetl (dd, user, XV_WLAY_RIGHTDOWN);
input_set_point (user, 0);
}
current_mode = panel->list_type;
- display_init (current_mode, panel->user_format,
+ display_init (current_mode, panel->user_format,
panel->user_mini_status, panel->user_status_format);
-
+
run_dlg (dd);
result = -1;
-
+
if (section) {
free (panel->user_format);
for (i = 0; i < LIST_TYPES; i++)
free (panel->user_status_format [i]);
free (panel);
}
-
+
if (dd->ret_value != B_CANCEL){
result = my_radio->sel;
*userp = strdup (user->buffer);
i = strlen (case_label) + 4;
if (i > r)
r = i;
-
+
l = strlen (ok_button) + 6;
i = strlen (cancel_button) + 4;
if (i > l)
l = i;
-
+
i = check_pos + max(r,l) + 2;
if (i > SORT_X)
}
result = 0;
-
+
for (i = 0; i < SORT_TYPES; i++)
if ((sortfn *) (sort_orders [i].sort_fn) == sort_fn){
current_mode = i;
break;
}
-
+
dd = create_dlg (0, 0, SORT_Y, SORT_X, dialog_colors, common_dialog_callback,
"[Left and Right Menus]", "sort", DLG_CENTER | DLG_GRID);
-
+
x_set_dialog_title (dd, sort_title);
- add_widgetl (dd,
- button_new (10, button_pos, B_CANCEL, NORMAL_BUTTON, cancel_button,
+ add_widgetl (dd,
+ button_new (10, button_pos, B_CANCEL, NORMAL_BUTTON, cancel_button,
0, 0, "cancel-button"), XV_WLAY_CENTERROW);
- add_widgetl (dd,
+ add_widgetl (dd,
button_new (9, button_pos, B_ENTER, DEFPUSH_BUTTON, ok_button,
0, 0, "ok-button"), XV_WLAY_RIGHTDOWN);
my_radio = radio_new (3, 3, SORT_TYPES, sort_orders_names, 1, "radio-1");
my_radio->sel = my_radio->pos = current_mode;
-
+
add_widget (dd, my_radio);
run_dlg (dd);
#ifdef ENABLE_NLS
static int i18n_flag = 0;
-
+
if (!i18n_flag)
{
register int i = sizeof(conf_widgets)/sizeof(QuickWidget) - 1;
confirmation.xlen = i;
confirmation.title = _(confirmation.title);
-
+
i18n_flag = confirmation.i18n = 1;
}
l1 = strlen (display_widgets [2].text);
if (l1 > maxlen)
maxlen = l1;
-
+
display_bits.xlen = (maxlen + 5) * 6 / 4;
dlg_stop (h);
}
return MSG_HANDLED;
-
+
case DLG_DRAW:
common_dialog_repaint (h);
break;
tree_colors [3] = dialog_colors [0];
tree_colors [1] = dialog_colors [1];
-
+
/* Create the components */
dlg = create_dlg (0, 0, TREE_Y, TREE_X, tree_colors,
tree_callback, "[Directory Tree]", "tree", DLG_CENTER);
add_widget (dlg, bar);
bar->widget.x = 0;
bar->widget.y = LINES - 1;
-
+
run_dlg (dlg);
if (dlg->ret_value == B_ENTER)
val = strdup (mytree->selected_ptr->name);
else
val = 0;
-
+
destroy_dlg (dlg);
return val;
}
{ quick_label, 4, VFSX, 8, VFSY, N_("ftp anonymous password:"),
0, 0, 0, 0, XV_WLAY_NEXTROW, "label-pass"},
#endif
-{ quick_input, 26, VFSX, 6, VFSY, "", 10, 0, 0, &ret_limit,
+{ quick_input, 26, VFSX, 6, VFSY, "", 10, 0, 0, &ret_limit,
XV_WLAY_RIGHTDOWN, "input-limit" },
{ quick_radio, 4, VFSX, 5, VFSY, "", 2, 0,
&vfs_use_limit, confvfs_str, XV_WLAY_BELOWCLOSE, "radio" },
-{ quick_label, 4, VFSX, 4, VFSY, N_("Gzipped tar archive extract:"),
+{ quick_label, 4, VFSX, 4, VFSY, N_("Gzipped tar archive extract:"),
0, 0, 0, 0, XV_WLAY_NEXTROW, "label-tar" },
{ quick_label, 46, VFSX, 3, VFSY, "sec",
0, 0, 0, 0, XV_WLAY_RIGHTOF, "label-sec2" },
-{ quick_input, 35, VFSX, 3, VFSY, "", 10, 0, 0, &ret_timeout,
+{ quick_input, 35, VFSX, 3, VFSY, "", 10, 0, 0, &ret_timeout,
XV_WLAY_RIGHTOF, "input-timo-vfs" },
-{ quick_label, 4, VFSX, 3, VFSY, N_("Timeout for freeing VFSs:"),
+{ quick_label, 4, VFSX, 3, VFSY, N_("Timeout for freeing VFSs:"),
0, 0, 0, 0, XV_WLAY_BELOWCLOSE, "label-vfs" },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, XV_WLAY_DONTCARE, 0 }
};
if (quick_dialog (&confvfs_dlg) != B_CANCEL) {
char *p;
-
+
vfs_timeout = atoi (ret_timeout);
free (ret_timeout);
if (vfs_timeout < 0 || vfs_timeout > 10000)
{ quick_input, 6, 57, 5, 0, "", 50, 0, 0, 0, XV_WLAY_RIGHTOF, "input" },
{ quick_label, 3, 57, 2, 0, "", 0, 0, 0, 0, XV_WLAY_DONTCARE, "label" },
{ 0 } };
-
+
char *my_str;
int len;
-
+
Quick_input.xlen = 57;
Quick_input.title = _("Quick cd");
Quick_input.help = "[Quick cd]";
len = strlen (quick_widgets [INPUT_INDEX+1].text);
quick_widgets [INPUT_INDEX+1].relative_x = 3;
- quick_widgets [INPUT_INDEX].relative_x =
+ quick_widgets [INPUT_INDEX].relative_x =
quick_widgets [INPUT_INDEX+1].relative_x + len + 1;
Quick_input.xlen = len + quick_widgets [INPUT_INDEX].hotkey_pos + 7;
Quick_input.ypos = LINES - 2 - Quick_input.ylen;
quick_widgets [INPUT_INDEX].relative_y = 2;
quick_widgets [INPUT_INDEX].str_result = &my_str;
-
+
Quick_input.widgets = quick_widgets;
if (quick_dialog (&Quick_input) != B_CANCEL){
return *(quick_widgets [INPUT_INDEX].str_result);
return 0;
}
-void symlink_dialog (char *existing, char *new, char **ret_existing,
+void symlink_dialog (char *existing, char *new, char **ret_existing,
char **ret_new)
{
QuickDialog Quick_input;
{ quick_input, 6, 80, 3, 8, "", 58, 0, 0, 0, XV_WLAY_BELOWCLOSE, "input-2" },
{ quick_label, 6, 80, 2, 8, "", 0, 0, 0, 0, XV_WLAY_DONTCARE, "label-2" },
{ 0 } };
-
+
Quick_input.xlen = 64;
Quick_input.ylen = 8;
Quick_input.title = "Symbolic link";
Quick_input.xpos = -1;
quick_widgets [INPUT_INDEX].str_result = ret_new;
quick_widgets [INPUT_INDEX+2].str_result = ret_existing;
-
+
Quick_input.widgets = quick_widgets;
if (quick_dialog (&Quick_input) == B_CANCEL){
*ret_new = NULL;
state_str [0] = _("Running ");
state_str [1] = _("Stopped");
}
-
+
while (tl){
char *s;
tl = tl->next;
}
}
-
+
static int
task_cb (int action, void *ignored)
{
TaskList *tl;
int sig;
-
+
if (!bg_list->list)
return 0;
/* Get this instance information */
tl = (TaskList *) bg_list->current->data;
-
+
if (action == B_STOP){
sig = SIGSTOP;
tl->state = Task_Stopped;
} else if (action == B_KILL){
sig = SIGKILL;
}
-
+
if (sig == SIGINT)
unregister_task_running (tl->pid, tl->fd);
/* This can be optimized to just redraw this widget :-) */
dlg_redraw (jobs_dlg);
-
+
return 0;
}
-static struct
+static struct
{
char* name;
int xpos;
int value;
int (*callback)();
char* tkname;
-}
+}
job_buttons [] =
{
{N_("&Stop"), 3, B_STOP, task_cb, "button-stop"},
common_dialog_callback, "[Background jobs]", "jobs",
DLG_CENTER | DLG_GRID);
x_set_dialog_title (jobs_dlg, _("Background Jobs"));
-
+
bg_list = listbox_new (2, 3, JOBS_X-7, JOBS_Y-9, listbox_nothing, 0, "listbox");
add_widget (jobs_dlg, bg_list);
i = n_buttons;
while (i--)
{
- add_widget (jobs_dlg, button_new (JOBS_Y-4,
+ add_widget (jobs_dlg, button_new (JOBS_Y-4,
job_buttons [i].xpos, job_buttons [i].value,
- NORMAL_BUTTON, job_buttons [i].name,
+ NORMAL_BUTTON, job_buttons [i].name,
job_buttons [i].callback, 0,
job_buttons [i].tkname));
}
-
+
/* Insert all of task information in the list */
jobs_fill_listbox ();
run_dlg (jobs_dlg);
-
+
destroy_dlg (jobs_dlg);
}
#endif
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
char *text;
int selected;
WCheck *check;
-} check_perm[PERMISSIONS] =
+} check_perm[PERMISSIONS] =
{
{ S_IXOTH, N_("execute/search by others"), 0, 0, },
{ S_IWOTH, N_("write by others"), 0, 0, },
struct {
int ret_cmd, flags, y, x;
char *text;
-} chmod_but[BUTTONS] =
+} chmod_but[BUTTONS] =
{
{ B_CANCEL, NORMAL_BUTTON, 2, 33, N_("&Cancel") },
{ B_ENTER, DEFPUSH_BUTTON, 2, 17, N_("&Set") },
#ifdef HAVE_TK
char *wn = (char *) ch_dlg->current->widget->wdata;
int id = ch_dlg->current->dlg_id -BUTTONS + single_set * 2;
-
+
check_perm [id].selected ^= 1;
tk_evalf ("%s configure -color $setup(%s)",
{
attrset (COLOR_NORMAL);
dlg_erase (ch_dlg);
-
+
draw_box (ch_dlg, 1, 2, 20 - single_set, 66);
draw_box (ch_dlg, PY, PX, PERMISSIONS + 2, 33);
draw_box (ch_dlg, FY, FX, 10, 25);
addstr (_("Owner name"));
dlg_move (ch_dlg, FY + 7, FX + 2);
addstr (_("Group name"));
-
+
attrset (title_color);
dlg_move (ch_dlg, 1, 28);
addstr (_(" Chmod command "));
addstr (_(" Permission "));
dlg_move (ch_dlg, FY, FX + 1);
addstr (_(" File "));
-
+
attrset (selection_color);
dlg_move (ch_dlg, TY, TX);
static int chmod_callback (Dlg_head *h, int Par, int Msg)
{
char buffer [10];
-
+
switch (Msg) {
case DLG_ACTION:
if (Par >= BUTTONS - single_set * 2){
title_color = SELECTED_COLOR;
selection_color = SELECTED_COLOR;
}
-
+
ch_dlg = create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
chmod_callback, "[Chmod]", "chmod", DLG_CENTER);
-
+
x_set_dialog_title (ch_dlg, _("Chmod command"));
#define XTRACT(i) BY+chmod_but[i].y-single_set, BX+chmod_but[i].x, \
destroy_dlg (ch_dlg);
break;
}
-
+
c_stat = sf_stat.st_mode;
mode_change = 0; /* clear changes flag */
statl = label_new (FY+4, FX+2, buffer, NULL);
add_widget (ch_dlg, statl);
tk_end_frame ();
-
+
run_dlg (ch_dlg); /* retrieve an action */
-
+
/* do action */
switch (ch_dlg->ret_value){
case B_ENTER:
fname, unix_error_string (errno));
need_update = 1;
break;
-
+
case B_CANCEL:
end_chmod = 1;
break;
-
+
case B_ALL:
case B_MARKED:
and_mask = or_mask = 0;
apply_mask (&sf_stat);
break;
-
+
case B_SETMRK:
and_mask = or_mask = 0;
and_mask = ~and_mask;
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
{ B_SETALL, NORMAL_BUTTON, 0, 3, N_("Set &all") },
};
-#define LABELS 5
+#define LABELS 5
static struct {
int y, x;
WLabel *l;
addstr (N_(" Size "));
dlg_move (ch_dlg, TY + 9, TX + 1);
addstr (N_(" Permission "));
-
+
attrset (COLOR_HOT_NORMAL);
dlg_move (ch_dlg, 1, 28);
addstr (N_(" Chown command "));
do_refresh ();
end_chown = need_update = current_file = 0;
- single_set = (cpanel->marked < 2) ? 3 : 0;
+ single_set = (cpanel->marked < 2) ? 3 : 0;
ch_dlg = create_dlg (0, 0, 18, 74, dialog_colors, chown_callback,
"[Chown]", "chown", DLG_CENTER);
listbox_add_item (l_user, 0, 0, l_pass->pw_name, NULL);
}
endpwent ();
-
+
setgrent (); /* get and put group names in the listbox */
while ((l_grp = getgrent ())) {
listbox_add_item (l_group, 0, 0, l_grp->gr_name, NULL);
}
endgrent ();
-
+
tk_new_frame (ch_dlg, "f.");
add_widget (ch_dlg, l_group);
tk_new_frame (ch_dlg, "g.");
static void apply_chowns (uid_t u, gid_t g)
{
char *fname;
-
+
need_update = end_chown = 1;
do_chown (u,g);
-
+
do {
fname = next_file ();
-
+
do_chown (u,g);
} while (cpanel->marked);
}
fname = next_file (); /* next marked file */
else
fname = selection (cpanel)->fname; /* single file */
-
+
if (!stat_file (fname, &sf_stat)){ /* get status of file */
destroy_dlg (ch_dlg);
break;
}
-
+
/* select in listboxes */
fe = listbox_search_text (l_user, get_owner(sf_stat.st_uid));
if (fe)
listbox_select_entry (l_user, fe);
-
+
fe = listbox_search_text (l_group, get_group(sf_stat.st_gid));
if (fe)
listbox_select_entry (l_group, fe);
chown_label (4, string_perm (sf_stat.st_mode));
run_dlg (ch_dlg);
-
+
switch (ch_dlg->ret_value) {
case B_CANCEL:
end_chown = 1;
break;
-
+
case B_SETUSR:
{
struct passwd *user;
apply_chowns (new_user, new_group);
}
break;
- }
+ }
case B_SETGRP:
{
struct group *grp;
{
struct group *grp;
struct passwd *user;
-
+
grp = getgrnam (l_group->current->text);
if (grp)
new_group = grp->gr_gid;
break;
}
}
-
+
if (cpanel->marked && ch_dlg->ret_value != B_CANCEL){
do_file_mark (cpanel, current_file, 0);
need_update = 1;
}
destroy_dlg (ch_dlg);
} while (cpanel->marked && !end_chown);
-
+
chown_done ();
}
/* Routines invoked by a function key
They normally operate on the current panel.
-
+
Copyright (C) 1994, 1995 Miguel de Icaza
Copyright (C) 1994, 1995 Janne Kukonlehto
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
int changed_hex_mode = 0;
int changed_nroff_flag = 0;
int changed_magic_flag = 0;
-
+
altered_hex_mode = 0;
altered_nroff_flag = 0;
altered_magic_flag = 0;
sprintf (view_entry, "View:%d", start_line);
else
strcpy (view_entry, "View");
-
+
if (!regex_command (filename, view_entry, NULL, &move_dir)){
view (0, filename, &move_dir, start_line);
repaint_screen ();
}
} else {
char *localcopy;
-
+
if (!viewer){
viewer = getenv ("PAGER");
if (!viewer)
}
execute_internal (viewer, localcopy);
mc_ungetlocalcopy (filename, localcopy, 0);
- } else
+ } else
execute_internal (viewer, filename);
}
return move_dir;
{
int dir, file_idx;
panel = get_a_panel (panel);
-
+
/* Directories are viewed by changing to them */
if (S_ISDIR (selection (panel)->buf.st_mode) ||
link_isdir (selection (panel))){
}
do_cd (selection (panel)->fname, cd_exact);
return;
-
+
}
file_idx = panel->selected;
void mkdir_cmd (WPanel *panel)
{
char *dir;
-
+
panel = get_a_panel (panel);
dir = input_expand_dialog (_(" Mkdir "), _(" Enter directory name:") , "");
-
+
if (!dir)
return;
{
char *reg_exp;
char *x;
-
+
x = p->filter ? p->filter : easy_patterns ? "*" : ".";
-
+
reg_exp = input_dialog (_(" Filter "), _(" Set expression for filtering filenames"), x);
if (!reg_exp)
return;
flag = strcmp (cpanel->cwd, opanel->cwd) ? UP_ONLY_CURRENT : 0;
else
flag = UP_ONLY_CURRENT;
-
+
update_panels (UP_RELOAD|flag, UP_KEEPSEL);
repaint_screen ();
}
reg_exp = input_dialog (_(" Select "), "", easy_patterns ? "*" : ".");
if (!reg_exp)
return;
-
+
reg_exp_t = reg_exp;
/* Check if they specified a directory */
reg_exp = input_dialog (_(" Unselect "),"", easy_patterns ? "*" : ".");
if (!reg_exp)
return;
-
+
reg_exp_t = reg_exp;
-
+
/* Check if they specified directory matching */
if (*reg_exp_t == PATH_SEP){
dirflag = 1;
reg_exp_t [strlen(reg_exp_t) - 1] = 0;
}
for (i = 0; i < panel->count; i++){
- if (!strcmp (panel->dir.list [i].fname, ".."))
+ if (!strcmp (panel->dir.list [i].fname, ".."))
continue;
if (S_ISDIR (panel->dir.list [i].buf.st_mode)){
if (!dirflag)
char *buffer;
char *menufile;
int dir = 0;
-
+
dir = query_dialog (
_("Menu file edit"),
- _(" Which menu file will you edit? "),
+ _(" Which menu file will you edit? "),
0, geteuid() ? 2 : 3,
_("&Local"), _("&Home"), _("&System Wide")
);
buffer = concat_dir_and_file (home_dir, MC_HOME_MENU);
check_for_default (menufile, buffer);
break;
-
+
case 2:
buffer = concat_dir_and_file (mc_home, MC_GLOBAL_MENU);
break;
char *src_name, *dst_name;
panel = get_a_panel (panel);
-
+
/* No marks by default */
panel->marked = 0;
panel->total = 0;
panel->dirs_marked = 0;
-
+
/* Handle all files in the panel */
for (i = 0; i < panel->count; i++){
file_entry *source = &panel->dir.list[i];
if (source->buf.st_mtime < target->buf.st_mtime)
continue;
}
-
+
/* Newer version with different size is marked */
if (source->buf.st_size != target->buf.st_size){
do_file_mark (panel, i, 1);
continue;
-
+
}
if (mode == compare_size_only)
continue;
-
+
if (mode == compare_quick){
/* Thorough compare off, compare only time stamps */
/* Mark newer version, don't mark version with the same date */
reset_prog_mode ();
keypad(stdscr, TRUE);
-#ifndef HAVE_X
+#ifndef HAVE_X
if (use_mouse_p)
init_mouse ();
if (alternate_plus_minus)
application_keypad_mode ();
-#endif
+#endif
#ifdef HAVE_SUBSHELL_SUPPORT
if (use_subshell){
if (!S_ISREG (s.st_mode))
return;
}
-
+
if (!symbolic_link){
- src = copy_strings (_(" Link "), name_trunc (fname, 46),
+ src = copy_strings (_(" Link "), name_trunc (fname, 46),
_(" to:"), NULL);
dest = input_expand_dialog (_(" Link "), src, "");
free (src);
/* suggest the full path for symlink */
char s[MC_MAXPATHLEN];
char d[MC_MAXPATHLEN];
-
+
strcpy(s, cpanel->cwd);
if ( ! ((s[0] == '/') && (s[1] == 0)))
strcat(s, "/");
strcpy(d, opanel->cwd);
else
strcpy (d,"");
-
+
if ( ! ((d[0] == '/') && (d[1] == 0)))
strcat(d, "/");
symlink_dialog (s, d, &dest, &src);
char buffer [MC_MAXPATHLEN], *p = selection (cpanel)->fname;
int i;
char *dest, *q = copy_strings (_(" Symlink "), name_trunc (p, 32), _(" points to:"), NULL);
-
+
i = readlink (p, buffer, MC_MAXPATHLEN);
if (i > 0) {
buffer [i] = 0;
return;
p = concat_dir_and_file (cpanel->cwd, selection (cpanel)->fname);
r = concat_dir_and_file (opanel->cwd, selection (cpanel)->fname);
-
+
q = copy_strings (_(" Link symbolically "), name_trunc (p, 32), _(" to:"), NULL);
dest = input_expand_dialog (_(" Relative symlink "), q, r);
if (dest) {
char *hintfile;
int len;
int start;
-
+
/* Do not change hints more often than one minute */
#ifdef SCO_FLAVOR
#else
static int last_sec;
static struct timeval tv;
-
+
gettimeofday (&tv, NULL);
if (!(tv.tv_sec> last_sec+60))
- return strdup ("");
+ return strdup ("");
last_sec = tv.tv_sec;
#endif
/* get a random entry */
len = strlen (data);
start = rand () % len;
-
+
for (;start; start--){
if (data [start] == '\n'){
start++;
if (strncmp (prefix, machine, strlen (prefix)) == 0)
cd_path = copy_strings (machine, to_home ? "/~/" : NULL, NULL);
- else
+ else
cd_path = copy_strings (prefix, machine, to_home ? "/~/" : NULL, NULL);
-
+
if (do_panel_cd (MENU_PANEL, cd_path, 0))
directory_history_add (MENU_PANEL, (MENU_PANEL)->cwd);
else
{
char *source;
struct hostent *hp;
-
+
source = input_dialog (_(" Socket source routing setup "),
_(" Enter host name to use as a source routing hop: ")n,
"");
if (p && *p) {
char *q = copy_strings ("cd ", p, NULL);
-
+
do_cd_command (q);
free (q);
}
strcpy (cmd, dirsizes_command);
p = strchr (cmd, 0);
for (i = 0; i < panel->count; i++)
- if (S_ISDIR (panel->dir.list [i].buf.st_mode) &&
+ if (S_ISDIR (panel->dir.list [i].buf.st_mode) &&
strcmp (panel->dir.list [i].fname, "..")) {
strcpy (p, panel->dir.list [i].fname);
p = strchr (p, 0);
f = popen (cmd, "r");
free (cmd);
if (f != NULL) {
- /* Assume that du will display the directories in the order
- * I've passed to it :(
+ /* Assume that du will display the directories in the order
+ * I've passed to it :(
*/
i = 0;
p = xmalloc (1024, "dirsizes_cmd");
if (!strncmp (q, panel->dir.list [i].fname,
r - q)) {
if (panel->dir.list [i].f.marked)
- panel->total += j -
- ((panel->has_dir_sizes) ? panel->dir.list [i].buf.st_size : 0);
+ panel->total += j -
+ ((panel->has_dir_sizes) ? panel->dir.list [i].buf.st_size : 0);
panel->dir.list [i].buf.st_size = j;
break;
}
message (0, _("Show directory sizes"), _("Pipe close failed"));
else
#else /* SCO_FLAVOR */
- /*
+ /*
** SCO reports about error while all seems to be ok. Just ignore it...
** (alex@bcs.zaporizhzhe.ua)
*/
save_setup_cmd (void)
{
char *str;
-
+
save_setup ();
sync_profiles ();
str = copy_strings ( _(" Setup saved to ~/"), PROFILE_NAME, NULL);
-
+
#ifdef HAVE_GNOME
set_hintbar (str);
#else
configure_panel_listing (WPanel *p, int view_type, int use_msformat, char *user, char *status)
{
int err;
-
- p->user_mini_status = use_msformat;
+
+ p->user_mini_status = use_msformat;
p->list_type = view_type;
-
+
if (view_type == list_user || use_msformat){
free (p->user_format);
p->user_format = user;
-
+
free (p->user_status_format [view_type]);
p->user_status_format [view_type] = status;
-
+
err = set_panel_formats (p);
-
+
if (err){
if (err & 0x01){
free (p->user_format);
p->user_format = strdup (DEFAULT_USER_FORMAT);
}
-
+
if (err & 0x02){
free (p->user_status_format [view_type]);
p->user_status_format [view_type] = strdup (DEFAULT_USER_FORMAT);
set_panel_formats (p);
paint_panel (p);
-
+
do_refresh ();
}
p->list_type = listing_mode;
if (set_panel_formats (p))
return 0;
-
+
paint_panel (p);
do_refresh ();
return 1;
WPanel *p = (WPanel *) get_panel_widget (current);
int list_mode = p->list_type;
int m;
-
+
switch (list_mode){
case list_full:
case list_brief:
void undelete_cmd (void);
void help_cmd (void);
void dirsizes_cmd (void);
-int view_file_at_line (char *filename, int plain_view, int internal,
+int view_file_at_line (char *filename, int plain_view, int internal,
int start_line);
int view_file (char *filename, int normal, int internal);
void view_cmd (WPanel *panel);
/* Color setup
Copyright (C) 1994 Miguel de Icaza.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include "color.h"
#include "x.h"
-/* "$Id: color.c,v 1.1 2001/12/30 09:55:26 sedwards Exp $" */
+/* "$Id$" */
/* To avoid excessive calls to ncurses' has_colors () */
int hascolors = 0;
{ "dfocus=", 0, 0 }, /* Dialog focused */
{ "dhotnormal=", 0, 0 }, /* Dialog normal/hot */
{ "dhotfocus=", 0, 0 }, /* Dialog focused/hot */
-
+
{ "viewunderline=", 0, 0 }, /* _\b? sequence in view */
{ "menusel=", 0, 0 }, /* Menu selected color */
{ "menuhot=", 0, 0 }, /* Color for menu hotkeys */
{ "menuhotsel=", 0, 0 }, /* Menu hotkeys/selected entry */
-
+
{ "helpnormal=", 0, 0 }, /* Help normal */
{ "helpitalic=", 0, 0 }, /* Italic in help */
{ "helpbold=", 0, 0 }, /* Bold in help */
{ "helplink=", 0, 0 }, /* Not selected hyperlink */
{ "helpslink=", 0, 0 }, /* Selected hyperlink */
-
+
{ "gauge=", 0, 0 }, /* Color of the progress bar (percentage) */
{ "input=", 0, 0 },
-
+
/* Per file types colors */
{ "directory=", 0, 0 },
{ "execute=", 0, 0 },
static void get_color (char *cpp, CTYPE *colp)
{
int i;
-
+
for (i = 0; i < ELEMENTS(color_table); i++){
if (strcmp (cpp, color_name (i)) == 0){
*colp = color_value (i);
int state;
state = 0;
-
+
for (; *p; p++){
if (*p == ':'){
*p = 0;
#ifndef HAVE_TK
#ifndef HAVE_XVIEW
extern char *default_edition_colors;
-
+
configure_colors_string (default_edition_colors);
#endif
#endif
init_colors (void)
{
int i;
-
+
use_colors = 1;
start_color ();
configure_colors ();
void init_colors (void)
{
int i;
-
+
hascolors = has_colors ();
if (!disable_colors && hascolors){
if (use_colors) { /* Hack to make COLOR_PAIR(31) be the default fg/bg
of the terminal */
char *Norm_Vid = SLtt_tgetstr ("me");
-
+
if (Norm_Vid == NULL)
Norm_Vid = SLtt_tgetstr ("se");
if (Norm_Vid == NULL)
Norm_Vid = "\033[0m";
SLtt_set_color_esc (31, Norm_Vid);
}
-#endif
+#endif
for (i = 0; i < ELEMENTS (color_map); i++){
init_pair (i+1, color_map_fg(i), color_map_bg(i));
#define HELP_BOLD_COLOR (PORT_COLOR (MY_COLOR_PAIR(18),A_REVERSE))
#define HELP_LINK_COLOR (PORT_COLOR (MY_COLOR_PAIR(19),0))
#define HELP_SLINK_COLOR (PORT_COLOR (MY_COLOR_PAIR(20),A_BOLD))
-
+
extern int sel_mark_color [4];
extern int dialog_colors [4];
-
+
#define COLOR_NORMAL (PORT_COLOR (MY_COLOR_PAIR (8),A_REVERSE))
#define COLOR_FOCUS (PORT_COLOR (MY_COLOR_PAIR (9),A_BOLD))
#define COLOR_HOT_NORMAL (PORT_COLOR (MY_COLOR_PAIR (10),0))
#define COLOR_HOT_FOCUS (PORT_COLOR (MY_COLOR_PAIR (11),0))
-
+
/* Add this to color panel, on BW all pairs are normal */
#define STALLED_COLOR (PORT_COLOR (MY_COLOR_PAIR (12),0))
-
+
#define DIRECTORY_COLOR (PORT_COLOR (MY_COLOR_PAIR (23),0))
#define EXECUTABLE_COLOR (PORT_COLOR (MY_COLOR_PAIR (24),0))
#define LINK_COLOR (PORT_COLOR (MY_COLOR_PAIR (25),0))
Bugs: No quoting occurrs here, so ${VAR} and $VAR will be always
substituted. I think we can encourage users to use in such extreme
cases instead of >cd path< command a >eval cd 'path'< command, which works
-as they might expect :)
+as they might expect :)
FIXME: Perhaps we should do wildcard matching as well? */
static int examine_cd (char *path)
{
}
}
*r = 0;
-
+
result = do_cd (q, cd_parse_command);
/* CDPATH handling */
cmd [len] = 0;
len --;
}
-
+
if (cmd [2] == 0)
cmd = "cd ";
static int enter (WCommand *cmdline)
{
Dlg_head *old_dlg;
-
+
if (command_prompt && strlen (input_w (cmdline)->buffer)){
char *cmd;
new_input (input_w (cmdline));
return MSG_HANDLED;
}
-#endif
+#endif
else {
char *command, *s;
int i, j;
new_input (input_w (cmdline));
execute (command);
free (command);
-
+
#ifdef HAVE_SUBSHELL_SUPPORT
if (quit & SUBSHELL_EXIT){
quiet_quit_cmd ();
cmd->old_callback = (callback_fn) cmd->input.widget.callback;
cmd->input.widget.callback = (int (*) (Dlg_head *, void *, int, int))
command_callback;
-
+
cmd->input.completion_flags |= INPUT_COMPLETE_COMMANDS;
return cmd;
}
/* Input line filename/username/hostname/variable/command completion.
(Let mc type for you...)
-
+
Copyright (C) 1995 The Free Software Foundation
-
+
Written by: 1995 Jakub Jelinek
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
if (dirname)
free (dirname);
- if (filename)
+ if (filename)
free (filename);
if (users_dirname)
free (users_dirname);
{
char *tmp = xmalloc (3 + strlen (dirname) + NLENGTH (entry), "Filename completion");
struct stat tempstat;
-
+
strcpy (tmp, dirname);
strcat (tmp, PATH_SEP_STR);
strcat (tmp, entry->d_name);
if (!stat (tmp, &tempstat)){
uid_t my_uid = getuid ();
gid_t my_gid = getgid ();
-
+
if (!S_ISDIR (tempstat.st_mode)){
isdir = 0;
if ((!my_uid && (tempstat.st_mode & 0111)) ||
return NULL;
} else {
char *temp = xmalloc (3 + strlen (entry->pw_name), "Username completion");
-
+
*temp = '~';
strcpy (temp + 1, entry->pw_name);
strcat (temp, PATH_SEP_STR);
name [i - start] = 0;
{
char **host_p;
-
+
if (hosts_p - hosts >= hosts_alloclen){
int j = hosts_p - hosts;
-
+
hosts = realloc ((void *)hosts, ((hosts_alloclen += 30) + 1) * sizeof (char *));
hosts_p = hosts + j;
}
if (!state){ /* Initialization stuff */
char *p;
-
+
if (hosts != NULL){
for (host_p = hosts; *host_p; host_p++)
free (*host_p);
textstart = (*text == '@') ? 1 : 0;
textlen = strlen (text + textstart);
}
-
+
while (*host_p){
if (!textlen)
break; /* Match all of them */
break;
host_p++;
}
-
+
if (!*host_p){
for (host_p = hosts; *host_p; host_p++)
free (*host_p);
"case", "esac", "for", "select", "while",
"until", "do", "done", "in", "function" , 0};
static char *bash_builtins [] = { "alias", "bg", "bind", "break", "builtin",
- "cd", "command", "continue", "declare",
+ "cd", "command", "continue", "declare",
"dirs", "echo", "enable", "eval", "exec",
"exit", "export", "fc", "fg", "getopts",
"hash", "help", "history", "jobs", "kill",
"let", "local", "logout", "popd", "pushd",
"pwd", "read", "readonly", "return", "set",
- "shift", "source", "suspend", "test",
+ "shift", "source", "suspend", "test",
"times", "trap", "type", "typeset",
"ulimit", "umask", "unalias", "unset",
"wait" , 0};
}
}
}
-
+
if (isabsolute){
p = filename_completion_function (text, state);
if (!p)
return p;
}
- found = NULL;
+ found = NULL;
switch (phase){
case 0: /* Reserved words */
while (*words){
while (!found){
if (!cur_word){
char *expanded;
-
+
if (!*cur_path)
break;
expanded = tilde_expand (cur_path);
}
}
}
-
+
if (!found){
look_for_executables = 0;
if (path)
return p;
}
return found;
-
+
}
int match_compare (const void *a, const void *b)
completions follows.
You have to supply your own CompletionFunction with the word you
want to complete as the first argument and an count of previous matches
- as the second.
+ as the second.
In case no matches were found we return NULL. */
char **completion_matches (char *text, CompletionFunction entry_function)
{
match_list[1] = (char *)NULL;
} else {
int j;
-
+
qsort (match_list + 1, matches, sizeof (char *), match_compare);
/* And compare each member of the list with
- the next, finding out where they stop matching.
+ the next, finding out where they stop matching.
If we find two equal strings, we have to put one away... */
j = i + 1;
for (si = 0;(c1 = match_list [i][si]) && (c2 = match_list [j][si]); si++)
if (c1 != c2) break;
-
+
if (!c1 && !match_list [j][si]){ /* Two equal strings */
free (match_list [j]);
j++;
int check_is_cd (char *text, int start, int flags)
{
char *p, *q = text + start;
-
+
for (p = text; *p && p < q && (*p == ' ' || *p == '\t'); p++);
- if (((flags & INPUT_COMPLETE_COMMANDS) &&
- !strncmp (p, "cd", 2) && (p [2] == ' ' || p [2] == '\t') &&
+ if (((flags & INPUT_COMPLETE_COMMANDS) &&
+ !strncmp (p, "cd", 2) && (p [2] == ' ' || p [2] == '\t') &&
p + 2 < q) ||
(flags & INPUT_COMPLETE_CD))
return 1;
register int this_char, prev_char;
in_command_position++;
-
+
if (i){
/* Handle the two character tokens `>&', `<&', and `>|'.
We are not in a command position after one of these. */
p = strrchr (word, '`');
if (flags & (INPUT_COMPLETE_COMMANDS | INPUT_COMPLETE_VARIABLES))
q = strrchr (word, '$');
- if (flags & INPUT_COMPLETE_HOSTNAMES)
+ if (flags & INPUT_COMPLETE_HOSTNAMES)
r = strrchr (word, '@');
if (q && q [1] == '(' && INPUT_COMPLETE_COMMANDS){
if (q > p)
p = q + 1;
q = NULL;
}
-
+
/* Command substitution? */
if (p > q && p > r){
matches = completion_matches (p + 1, command_completion_function);
*start += q - word;
}
- /* Starts with '@', then look through the known hostnames for
+ /* Starts with '@', then look through the known hostnames for
completion first. */
else if (r > p && r > q){
matches = completion_matches (r, hostname_completion_function);
if (matches)
*start += r - word;
}
-
+
/* Starts with `~' and there is no slash in the word, then
try completing this word as a username. */
if (!matches && *word == '~' && (flags & INPUT_COMPLETE_USERNAMES) && !strchr (word, PATH_SEP))
and command names. */
if (!matches && in_command_position)
matches = completion_matches (word, command_completion_function);
-
+
else if (!matches && (flags & INPUT_COMPLETE_FILENAMES)){
if (is_cd)
ignore_filenames = 1;
ignore_filenames = 0;
if (!matches && is_cd && *word != PATH_SEP && *word != '~'){
char *p, *q = text + *start;
-
+
for (p = text; *p && p < q && (*p == ' ' || *p == '\t'); p++);
if (!strncmp (p, "cd", 2))
for (p += 2; *p && p < q && (*p == ' ' || *p == '\t'); p++);
s = strchr (cdpath, ':');
if (s == NULL)
s = strchr (cdpath, 0);
- c = *s;
+ c = *s;
*s = 0;
if (*cdpath){
r = concat_dir_and_file (cdpath, word);
}
}
}
-
+
if (word)
free (word);
void free_completions (WInput *in)
{
char **p;
-
+
if (!in->completions)
return;
for (p=in->completions; *p; p++)
dlg_erase (h);
draw_box (h, 0, 0, query_height, query_width);
break;
-
+
case DLG_KEY:
switch (Par) {
case KEY_LEFT:
h->ret_value = 0;
dlg_stop (h);
return 1;
-
+
case 0177:
case KEY_BACKSPACE:
case XCTRL('h'):
return 1;
} else {
WLEntry *e, *e1;
-
+
e1 = e = ((WListbox *)(h->current->widget))->list;
do {
if (!strncmp (input->buffer + start, e1->text, end - start - 1)){
} while (e != e1);
}
return 1;
-
+
default:
if (Par > 0xff || !is_printable (Par)){
if (is_in_input_map (input, Par) == 2){
int need_redraw = 0;
int low = 4096;
char *last_text = NULL;
-
+
e1 = e = ((WListbox *)(h->current->widget))->list;
do {
if (!strncmp (input->buffer + start, e1->text, end - start)){
if (e1->text [end - start] == Par){
if (need_redraw){
register int c1, c2, si;
-
- for (si = end - start + 1;
+
+ for (si = end - start + 1;
(c1 = last_text [si]) &&
(c2 = e1->text [si]); si++)
if (c1 != c2)
break;
- if (low > si)
+ if (low > si)
low = si;
last_text = e1->text;
need_redraw = 2;
char **p, *q;
Dlg_head *query_dlg;
WListbox *query_list;
-
+
for (p=in->completions + 1; *p; count++, p++)
if ((i = strlen (*p)) > maxlen)
maxlen = i;
/* Client interface for General purpose Linux console save/restore server
Copyright (C) 1994 Janne Kukonlehto <jtklehto@stekt.oulu.fi>
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#endif /* #ifdef linux */
#ifdef SCO_FLAVOR
-/*
+/*
** SCO console save/restore handling routines
** Copyright (C) 1997 Alex Tkachenko <alex@bcs.zaporizhzhe.ua>
*/
{
struct vt_mode smode;
- /*
+ /*
** User switched out of our vt. Let's wait until we get SIG_ACQUIRE,
** otherwise we could save wrong screen image
*/
console_init();
break;
- case CONSOLE_DONE:
+ case CONSOLE_DONE:
console_shutdown();
break;
This code requires root privileges.
You may want to make the cons.saver setuid root.
The code should be safe even if it is setuid but who knows?
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
both 'open' and 'stat' operate on the same file */
*msg = 0;
-
+
fd = open (filename, O_RDWR);
if (fd == -1)
return -1;
-
+
if (fstat (fd, &stat_buf) == -1)
return -1;
*msg = "Not a console";
return -1;
}
-
+
if ((stat_buf.st_rdev & 0x00ff) > 63){
*msg = "Minor device number too big";
return -1;
}
-
+
/* Must be owned by the user */
if (stat_buf.st_uid != getuid ()){
*msg = "Not a owner";
return -1;
}
}
-
+
/* Everything seems to be okay */
return fd;
}
{
char *msg;
int xlen;
-
+
/* Must be console */
/* Handle the case for /dev/tty?? */
if (tty_name[len-5] == 't')
#ifdef DEBUG
fprintf (stderr, "vcs_fd = %d console_fd = %d\n", vcs_fd, console_fd);
#endif
-
+
if (vcs_fd != -1){
console_flag = 3;
}
unsigned char message;
unsigned short bytes;
int bytes_per_char;
-
+
bytes_per_char = console_flag == 1 ? 1 : 2;
-
+
/* Calculate the number of used lines */
if (console_flag == 2 || console_flag == 1 || console_flag == 3){
index = (2 + rows * columns) * bytes_per_char;
/* Lose the control terminal */
setsid ();
-
+
/* Check that the argument is a legal console */
tty_name = argv [1];
len = strlen(tty_name);
/* If using /dev/vcs*, we don't need anymore the console fd */
if (console_flag == 3)
close (console_fd);
-
+
/* Inform the invoker about the result of the tests */
write (cmd_output, &console_flag, 1);
send_contents ();
break;
} /* switch (action) */
-
+
/* Inform the invoker that command is handled */
write (cmd_output, &console_flag, 1);
} /* while (read ...) */
if (buffer)
free (buffer);
- return 0;
+ return 0;
}
#else
/* Dialog managing.
Copyright (C) 1994 Miguel de Icaza.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include "dlg.h" /* draw_box, yes I know, it's silly */
#include "background.h" /* we_are_background definition */
-/* "$Id: dialog.c,v 1.1 2001/12/30 09:55:26 sedwards Exp $" */
+/* "$Id$" */
Refresh *refresh_list = 0;
void pop_refresh (void)
{
Refresh *old;
-
+
if (!refresh_list)
fprintf (stderr, _("\n\n\nrefresh stack underflow!\n\n\n"));
else {
if (refresh_list->flags != REFRESH_COVERS_ALL)
do_complete_refresh (refresh_list->next);
-
+
(*(refresh_list->refresh_fn))(refresh_list->parameter);
}
while ((p = *text++) != 0){
if (p == '\n')
move (++y, x);
- else
+ else
addch ((unsigned char)p);
}
}
/* Directory routines
Copyright (C) 1994 Miguel de Icaza.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include "tree.h"
#include "../vfs/vfs.h"
-/* "$Id: dir.c,v 1.1 2001/12/30 09:55:26 sedwards Exp $" */
+/* "$Id$" */
/* If true show files starting with a dot */
int show_dot_files = 1;
{
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
-
+
if (ad == bd || mix_all_files)
return string_sortcomp (a->fname, b->fname) * reverse;
return bd-ad;
{
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
-
+
if (ad == bd || mix_all_files)
return string_sortcomp (get_owner (a->buf.st_uid), get_owner (a->buf.st_uid)) * reverse;
return bd-ad;
{
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
-
+
if (ad == bd || mix_all_files)
return string_sortcomp (get_group (a->buf.st_gid), get_group (a->buf.st_gid)) * reverse;
return bd-ad;
file_type_to_num (const file_entry *fe)
{
const struct stat *s = &fe->buf;
-
+
if (S_ISDIR (s->st_mode))
return 0;
if (S_ISLNK (s->st_mode)){
{
int aa = file_type_to_num (a);
int bb = file_type_to_num (b);
-
+
return bb-aa;
}
}
}
-static int
+static int
add_dotdot_to_list (dir_list *list, int index)
{
char buffer [MC_MAXPATHLEN + MC_MAXPATHLEN];
char *p, *s;
int i = 0;
-
+
/* Need to grow the *list? */
if (index == list->size) {
list->list = realloc (list->list, sizeof (file_entry) *
(list->list) [index].cache = NULL;
(list->list) [index].f.link_to_dir = 0;
(list->list) [index].f.stalled_link = 0;
-
+
/* FIXME: We need to get the panel definition! to use file_mark */
(list->list) [index].f.marked = 0;
mc_get_current_wd (buffer, sizeof (buffer) - 1 );
if (S_ISDIR (buf1->st_mode))
tree_check (dp->d_name);
-
+
/* A link to a file or a directory? */
*link_to_dir = 0;
*stalled_link = 0;
return 1;
}
-/* handle_path is a simplified handle_dirent. The difference is that
+/* handle_path is a simplified handle_dirent. The difference is that
handle_path doesn't pay attention to show_dot_files and show_backups.
- Moreover handle_path can't be used with a filemask.
+ Moreover handle_path can't be used with a filemask.
If you change handle_path then check also handle_dirent. */
/* Return values: -1 = failure, 0 = don't add, 1 = add to the list */
int handle_path (dir_list *list, char *path,
if (S_ISDIR (buf1->st_mode))
tree_check (path);
-
+
/* A link to a file or a directory? */
*link_to_dir = 0;
*stalled_link = 0;
int dotdot_found = 0;
start_tree_check (NULL);
-
+
dirp = mc_opendir (".");
if (!dirp){
return set_zero_dir (list);
return next_free;
list->list [next_free].fnamelen = NLENGTH (dp);
list->list [next_free].fname = strdup (dp->d_name);
- list->list [next_free].cache = NULL;
+ list->list [next_free].cache = NULL;
list->list [next_free].f.marked = 0;
list->list [next_free].f.link_to_dir = link_to_dir;
list->list [next_free].f.stalled_link = stalled_link;
}
else
return set_zero_dir (list);
-
+
mc_closedir (dirp);
end_tree_check (NULL);
return next_free;
int link_isdir (file_entry *file)
{
struct stat b;
-
+
if (S_ISLNK (file->buf.st_mode)){
mc_stat (file->fname, &b);
if (S_ISDIR (b.st_mode))
}
return 0;
}
-
+
int if_link_is_exe (file_entry *file)
{
struct stat b;
static void alloc_dir_copy (int size)
{
int i;
-
+
if (dir_copy.size < size){
if (dir_copy.list){
int i, found, status, link_to_dir, stalled_link;
struct stat buf;
int tmp_len; /* For optimisation */
- int dotdot_found = 0;
+ int dotdot_found = 0;
start_tree_check (NULL);
dirp = mc_opendir (".");
continue;
if (status == -1) {
mc_closedir (dirp);
- /* Norbert (Feb 12, 1997):
+ /* Norbert (Feb 12, 1997):
Just in case someone finds this memory leak:
- -1 means big trouble (at the moment no memory left),
+ -1 means big trouble (at the moment no memory left),
I don't bother with further cleanup because if one gets to
this point he will have more problems than a few memory
leaks and because one 'clean_dir' would not be enough (and
- because I don't want to spent the time to make it working,
- IMHO it's not worthwhile).
+ because I don't want to spent the time to make it working,
+ IMHO it's not worthwhile).
clean_dir (&dir_copy, count);
*/
return next_free;
}
-
+
tmp_len = NLENGTH (dp);
for (found = i = 0; i < count; i++)
if (tmp_len == dir_copy.list [i].fnamelen
found = 1;
break;
}
-
+
if (!found)
list->list [next_free].f.marked = 0;
-
+
list->list [next_free].fnamelen = tmp_len;
list->list [next_free].fname = strdup (dp->d_name);
list->list [next_free].cache = NULL;
struct stat buf;
/* Flags */
- struct {
+ struct {
unsigned int marked:1; /* File marked in pane window */
unsigned int exists:1; /* Use for rereading file */
unsigned int link_to_dir:1; /* If this is a link, does it point to directory? */
#ifdef DIR_H_INCLUDE_HANDLE_DIRENT
int handle_dirent (dir_list *list, char *filter, struct dirent *dp,
struct stat *buf1, int next_free, int *link_to_dir, int *stalled_link);
-int handle_path (dir_list *list, char *path, struct stat *buf1, int next_free,
+int handle_path (dir_list *list, char *path, struct stat *buf1, int next_free,
int *link_to_dir, int *stalled_link);
#endif
*/
#include <config.h>
-/* "$Id: dlg.c,v 1.1 2001/12/30 09:55:26 sedwards Exp $" */
+/* "$Id$" */
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include "dlg.h"
#include "dialog.h" /* For push_refresh() and pop_refresh() */
#include "layout.h"
-#include "main.h"
+#include "main.h"
/* This is the current frame, used to group Tk packings */
char *the_frame = "";
void draw_box (Dlg_head *h, int y, int x, int ys, int xs)
{
extern int slow_terminal;
-
+
if (slow_terminal){
slow_box (h, y, x, ys, xs);
return;
}
-
+
#ifndef HAVE_SLANG
waddc (h, y, x, ACS_ULCORNER);
hline (ACS_HLINE, xs - 2);
abort ();
}
/* Almost all widgets want to put the cursor in a suitable place */
- w->options = W_WANT_CURSOR;
+ w->options = W_WANT_CURSOR;
}
int default_proc (Dlg_head *h, int Msg, int Par)
case WIDGET_INIT: /* We could tell if something went wrong */
return 1;
-
+
case WIDGET_KEY:
return 0; /* Didn't use the key */
-
+
case WIDGET_FOCUS: /* We accept FOCUSes */
if (h->current)
x_focus_widget (h->current);
return 1;
-
+
case WIDGET_UNFOCUS: /* We accept loose FOCUSes */
if (h->current)
x_unfocus_widget (h->current);
return 1;
-
+
case WIDGET_DRAW:
return 1;
new_d->wdata = xtoolkit_create_dialog (new_d, flags);
else
new_d->wdata = xtoolkit_get_main_dialog (new_d);
-#endif
+#endif
return (new_d);
}
-
+
void set_idle_proc (Dlg_head *d, int state)
{
d->send_idle_msg = state;
/* Only used by Tk */
widget->frame = the_frame;
-
+
widget->layout = layout;
/* Don't accept 0 widgets, this could be from widgets that could not */
/* initialize properly */
where->current->next = where->current;
where->first = where->current;
}
-
+
where->current->prev = where->first;
where->last = where->current;
where->first->next = where->last;
-
+
}
where->current->dlg_id = where->count;
where->current->widget = what;
where->current->widget->parent = where;
-
+
where->count++;
/* If the widget is inserted in a running dialog */
int remove_widget (Dlg_head *h, void *what)
{
Widget_Item *first, *p;
-
+
first = p = h->current;
-
+
do {
if (p->widget == what){
/* Remove links to this Widget_Item */
p->prev->next = p->next;
p->next->prev = p->prev;
-
+
/* Make sure h->current is always valid */
if (p == h->current){
h->current = h->current->next;
if (!h->current)
return;
-
+
if (reverse)
first = p = h->current->prev;
else
if (!down)
direction = !direction;
-
+
do {
if (direction)
h->current = h->current->next;
else
h->current = h->current->prev;
-
+
(*h->callback) (h, h->current->dlg_id, DLG_ONE_DOWN);
} while (!dlg_focus (h));
}
if (!h)
return 0;
-
+
w = 0;
for (i = 0, item = h->current; i < h->count; i++, item = item->next){
if (item->widget->callback == signature){
/* If it accepts unFOCUSion */
if (!dlg_unfocus(h))
return;
-
+
select_a_widget (h, 0);
if (dlg_overlap (old->widget, h->current->widget)){
send_message (h, h->current->widget, WIDGET_DRAW, 0);
if (!dlg_unfocus (h))
return;
- select_a_widget (h, 1);
+ select_a_widget (h, 1);
if (dlg_overlap (old->widget, h->current->widget)){
send_message (h, h->current->widget, WIDGET_DRAW, 0);
send_message (h, h->current->widget, WIDGET_FOCUS, 0);
send_message (h, h->current->widget, WIDGET_CURSOR, 0);
else {
Widget_Item *p = h->current;
-
+
do {
if (p->widget->options & W_WANT_CURSOR)
if ((*p->widget->callback)(h, p->widget, WIDGET_CURSOR, 0)){
(h->callback)(h, 0, DLG_DRAW);
dlg_broadcast_msg (h, WIDGET_DRAW, 1);
-
+
update_cursor (h);
}
void dlg_stop (Dlg_head *h)
{
h->running = 0;
- x_dialog_stop (h);
+ x_dialog_stop (h);
}
static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
case KEY_UP:
dlg_one_up (h);
break;
-
+
case KEY_RIGHT:
case KEY_DOWN:
dlg_one_down (h);
case XCTRL('z'):
suspend_cmd ();
/* Fall through */
-
+
case XCTRL('l'):
#ifndef HAVE_SLANG
/* Use this if the refreshes fail */
mc_refresh ();
doupdate ();
break;
-
+
case '\n':
case KEY_ENTER:
h->ret_value = B_ENTER;
Widget_Item *previous;
int handled, c;
extern input_event ();
-
+
/*
* Explanation: we don't send letter hotkeys to other widgets if
* the currently selected widget is an input line
if(d_key < 255 && isalpha(d_key))
return 0;
}
-
+
/* If it's an alt key, send the message */
c = d_key & ~ALT(0);
if (d_key & ALT(0) && c < 255 && isalpha(c))
/* .ado: fix problem with file_permission under Win95 */
if (d_key == 0) return 0;
#endif
-
+
handled = 0;
if (h->current->widget->options & W_WANT_HOTKEY)
handled = callback (h) (h, h->current->widget, WIDGET_HOTKEY, d_key);
-
+
/* If not used, send hotkey to other widgets */
if (handled)
return handled;
-
+
hot_cur = h->current;
-
+
/* send it to all widgets */
do {
if (hot_cur->widget->options & W_WANT_HOTKEY)
handled |= (*hot_cur->widget->callback)
(h, hot_cur->widget, WIDGET_HOTKEY, d_key);
-
+
if (!handled)
hot_cur = hot_cur->next;
} while (h->current != hot_cur && !handled);
-
+
if (!handled)
return 0;
previous = h->current;
if (!dlg_unfocus (h))
return handled;
-
+
h->current = hot_cur;
if (!dlg_focus (h)){
h->current = previous;
void dlg_key_event (Dlg_head *h, int d_key)
{
int handled;
-
+
/* TAB used to cycle */
if (!h->raw && (d_key == '\t' || d_key == KEY_BTAB))
if (d_key == '\t')
else
dlg_one_up (h);
else {
-
+
/* first can dlg_callback handle the key */
handled = (*h->callback) (h, d_key, DLG_KEY);
/* next try the hotkey */
if (!handled)
handled = dlg_try_hotkey (h, d_key);
-
+
/* not used - then try widget_callback */
if (!handled)
handled |= callback (h)(h, h->current->widget, WIDGET_KEY, d_key);
-
+
/* not used- try to use the unhandled case */
if (!handled)
handled |= (*h->callback) (h, d_key, DLG_UNHANDLED_KEY);
-
+
if (!handled)
dialog_handle_key (h, d_key);
(*h->callback) (h, d_key, DLG_POST_KEY);
Widget *widget = item->widget;
item = item->next;
-
- if (!((x > widget->x) && (x <= widget->x+widget->cols)
+
+ if (!((x > widget->x) && (x <= widget->x+widget->cols)
&& (y > widget->y) && (y <= widget->y+widget->lines)))
continue;
int refresh_mode;
tk_end_frame ();
-
+
/* Initialize dialog manager and widgets */
(*h->callback) (h, 0, DLG_INIT);
dlg_broadcast_msg (h, WIDGET_INIT, 0);
refresh_mode = REFRESH_COVERS_PART;
push_refresh (dlg_refresh, h, refresh_mode);
h->refresh_pushed = 1;
-
+
/* Initialize direction */
if (!h->direction)
h->current = h->first;
-
+
if (h->initfocus != NULL)
h->current = h->initfocus;
h->previous_dialog = current_dlg;
current_dlg = h;
-
+
/* Initialize the mouse status */
h->mouse_status = 0;
/* Redraw the screen */
dlg_redraw (h);
-
+
while (!dlg_focus (h))
h->current = h->current->next;
else
return;
}
-
+
if (key == EV_MOUSE)
h->mouse_status = dlg_mouse_event (h, event);
else
if (is_idle ()){
if (idle_hook)
execute_hooks (idle_hook);
-
+
while (h->send_idle_msg && is_idle ()){
(*h->callback) (h, 0, DLG_IDLE);
}
Widget_Item *c;
if (h->refresh_pushed)
- pop_refresh ();
+ pop_refresh ();
x_destroy_dlg_start (h);
dlg_broadcast_msg (h, WIDGET_DESTROY, 0);
{
Widget_Item *p = h->current;
int should_focus = 0;
-
+
do {
if (p->widget == old){
if (old == h->current->widget)
should_focus = 1;
-
+
/* We found the widget */
/* First kill the widget */
new->focused = old->focused;
static void tk_frame_proc (Dlg_head *h, char *frame, int new_frame)
{
char *s = strdup (frame);
-
+
if (frame [strlen (frame)-1] != '.'){
fprintf (stderr, "Invalid frame name\n");
exit (1);
}
s [strlen (frame)-1] = 0;
the_frame = frame;
-
+
if (new_frame)
tk_evalf ("frame %s.%s", (char *)h->wdata, s);
}
DLG_KEY, /* Sent on keypress before sending to widget */
DLG_INIT, /* Sent on init */
DLG_END, /* Sent on shutdown */
- DLG_ACTION,
+ DLG_ACTION,
DLG_DRAW, /* Sent for updating dialog managed area */
DLG_FOCUS, /* Sent on give focus to a widget */
DLG_UNFOCUS, /* Sent on remove focus from widget */
void *previous_dialog; /* Pointer to the previously running Dlg_head */
int refresh_pushed; /* Did the dialog actually run? */
-
+
/* position */
int x, y; /* Position relative to screen origin */
-
+
/* Flags */
int running;
int direction;
/* Internal variables */
struct Widget_Item *current, *first, *last;
int (*callback) (struct Dlg_head *, int, int);
-
+
struct Widget_Item *initfocus;
/* Hacks */
int cols;
int lines;
void *data;
-
+
int has_menubar; /* GrossHack: Send events on row 1 to a menubar? */
int raw; /* Should the tab key be sent to the dialog? */
-
+
widget_data wdata;
int grided; /* Does it use the automatic layout? */
#ifdef HAVE_GNOME
/* XView widget layout */
-typedef enum {
+typedef enum {
XV_WLAY_DONTCARE, /* Place the widget wherever it is reasonable */
-
+
XV_WLAY_RIGHTOF, /* Place the widget to the right of the last widget
* created - note: add_widget creates widgets from
* the last to the first one.
*/
-
+
XV_WLAY_BELOWOF, /* Place it in a column like style */
-
+
XV_WLAY_BELOWCLOSE,/* The same, but without any gap between them */
-
+
XV_WLAY_NEXTROW, /* Place it on the left margin with Y bellow all the
* previous widgets
*/
-
+
XV_WLAY_CENTERROW,/* The same as previous, but when the dialog is
* ready to show, tries to center that row of widgets
*/
-
+
XV_WLAY_NEXTCOLUMN, /* Place it on the top margin with X behind all the
* previous widgets
*/
-
+
XV_WLAY_RIGHTDOWN, /* Place the widget to the right of the last one with
* y set so that both y + h and yold + hold are equal.
This is usefull if the previous widget was a radio,
int remove_widget (Dlg_head *dest, void *Widget);
int destroy_widget (Widget *w);
-/* Runs dialog d */
+/* Runs dialog d */
void run_dlg (Dlg_head *d);
-
+
void dlg_run_done (Dlg_head *h);
void dlg_process_event (Dlg_head *h, int key, Gpm_Event *event);
void init_dlg (Dlg_head *h);
/* To activate/deactivate the idle message generation */
void set_idle_proc (Dlg_head *d, int state);
-
+
void dlg_redraw (Dlg_head *h);
void dlg_refresh (void *parameter);
void destroy_dlg (Dlg_head *h);
-
+
void widget_set_size (Widget *widget, int x1, int y1, int x2, int y2);
void dlg_broadcast_msg_to (Dlg_head *h, int message, int reverse, int flags);
/* Extension dependent execution.
Copyright (C) 1994, 1995 The Free Software Foundation
-
+
Written by: 1995 Jakub Jelinek
1994 Miguel de Icaza
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include <sys/wait.h>
#endif /* SCO_FLAVOR */
-/* "$Id: ext.c,v 1.1 2001/12/30 09:55:26 sedwards Exp $" */
+/* "$Id$" */
/* If set, we execute the file command to check the file type */
int use_file_to_check_type = 1;
/* This variable points to a copy of the mc.ext file in memory
- * With this we avoid loading/parsing the file each time we
- * need it
+ * With this we avoid loading/parsing the file each time we
+ * need it
*/
static char *data = NULL;
break;
}
return tmpcmdfilename;
-}
+}
#endif
void
free (data);
data = NULL;
}
-
+
}
typedef char *(*quote_func_t)(const char *name, int i);
tail += temp_len + 1;
free (temp);
}
-
+
return result;
}
-
+
static void
exec_extension (char *filename, char *data, char **drops, int *move_dir, int start_line)
{
do_local_copy = 1;
else
do_local_copy = 0;
-
+
/* Note: this has to be done after the getlocalcopy call,
* since it uses tmpnam as well
*/
file_name = strdup (gettmpcmdname ());
#else
file_name = strdup (tmpnam (NULL));
-#endif
+#endif
if ((cmd_file_fd = open (file_name, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600)) == -1){
message (1, MSG_ERROR, _(" Can't create temporary command file \n %s "),
unix_error_string (errno));
else {
int i = check_format_view (data);
char *v;
-
+
if (i){
data += i - 1;
run_view = 1;
changed_hex_mode = 1;
if (def_nroff_flag != default_nroff_flag)
changed_nroff_flag = 1;
-
+
/* If we've written whitespace only, then just load filename
* into view
*/
- if (written_nonspace)
+ if (written_nonspace)
view (file_name, filename, move_dir, start_line);
else
view (0, filename, move_dir, start_line);
p = buffer;
while (*p == ' ' && *p == '\t')
p++;
-
+
/* Search last non-space character. Start search at the end in order
not to short filenames containing spaces. */
q = p + strlen (p) - 1;
show_console_contents (output_start_y,
LINES-keybar_visible-output_lines-1,
LINES-keybar_visible-1);
-
+
}
}
-
+
#ifdef OLD_CODE
if (vfs_current_is_local ())
shell_execute (file_name, EXECUTE_INTERNAL);
int view_at_line_number;
char *include_target;
int include_target_len;
-
+
#ifdef FILE_STDIN
int file_supports_stdin = 1;
#else
int file_supports_stdin = 0;
-#endif
+#endif
/* Check for the special View:%d parameter */
if (action && strncmp (action, "View:", 5) == 0){
data = NULL;
if (extension_file == buffer) {
home_error = 1;
- goto check_stock_mc_ext;
+ goto check_stock_mc_ext;
} else {
char *msg;
char *msg2;
msg = copy_strings(" ", mc_home, MC_LIB_EXT, _(" file error"), NULL);
- msg2 = copy_strings(_("Format of the "),
- mc_home,
+ msg2 = copy_strings(_("Format of the "),
+ mc_home,
("mc.ext file has changed\n\
with version 3.0. It seems that installation\n\
failed. Please fetch a fresh new copy from the\n\
free (buffer);
}
mc_stat (filename, &mystat);
-
+
if (regex_command_title){
free (regex_command_title);
regex_command_title = NULL;
* keyword/descNL
*/
if (found && action == NULL) /* We have already accumulated all
- * the user actions
+ * the user actions
*/
break;
found = 0;
- q = strchr (p, '\n');
+ q = strchr (p, '\n');
if (q == NULL)
q = strchr (p, 0);
c = *q;
} else if (!strncmp (p, "shell/", 6)) {
p += 6;
if (*p == '.') {
- if (!strncmp (p, filename + file_len - (q - p),
+ if (!strncmp (p, filename + file_len - (q - p),
q - p))
found = 1;
} else {
} else if (!strncmp (p, "type/", 5)) {
int islocal = vfs_file_is_local (filename);
p += 5;
-
+
if (islocal || file_supports_stdin) {
char *pp;
int hasread = use_file_to_check_type;
char *command =
copy_strings (FILE_CMD, tmp, NULL);
FILE *f = popen (command, "r");
-
+
free (tmp);
free (command);
if (f != NULL) {
- hasread = (fgets (content_string, 2047, f)
+ hasread = (fgets (content_string, 2047, f)
!= NULL);
if (!hasread)
content_string [0] = 0;
pclose (f);
#ifdef SCO_FLAVOR
- /*
- ** SCO 3.2 does has a buggy pclose(), so
+ /*
+ ** SCO 3.2 does has a buggy pclose(), so
** <command> become zombie (alex)
*/
waitpid(-1,NULL,WNOHANG);
#else
int pipehandle, remotehandle;
pid_t p;
-
+
remotehandle = mc_open (filename, O_RDONLY);
if (remotehandle != -1) {
/* 8192 is HOWMANY hardcoded value in the file-3.14
* sources. Tell me if any other file uses larger
- * chunk from beginning
+ * chunk from beginning
*/
pipehandle = mc_doublepopen
(remotehandle, 8192, &p,"file", "file", "-", NULL);
if (pipehandle != -1) {
int i;
- while ((i = read (pipehandle, content_string
+ while ((i = read (pipehandle, content_string
+ hasread, 2047 - hasread)) > 0)
hasread += i;
mc_doublepclose (pipehandle, p);
if (hasread) {
if ((pp = strchr (content_string, '\n')) != 0)
*pp = 0;
- if (islocal && !strncmp (content_string,
+ if (islocal && !strncmp (content_string,
filename, file_len)) {
content_shift = file_len;
if (content_string [content_shift] == ':')
- for (content_shift++;
- content_string [content_shift] == ' ';
+ for (content_shift++;
+ content_string [content_shift] == ' ';
content_shift++);
- } else if (!islocal
- && !strncmp (content_string,
+ } else if (!islocal
+ && !strncmp (content_string,
"standard input:", 15)) {
for (content_shift = 15;
content_string [content_shift] == ' ';
content_shift++);
}
- if (content_string &&
- regexp_match (p, content_string +
+ if (content_string &&
+ regexp_match (p, content_string +
content_shift, match_normal)){
found = 1;
}
*r = c;
p = q;
found = 0;
-
+
if (!*p)
break;
continue;
}
if (action == NULL) {
- if (strcmp (p, "Open") &&
+ if (strcmp (p, "Open") &&
strcmp (p, "View") &&
strcmp (p, "Edit") &&
strcmp (p, "Drop") &&
strcmp (p, "Title")) {
/* I.e. this is a name of a user defined action */
static char *q;
-
+
if (to_return == NULL) {
to_return = xmalloc (512, "Action list");
q = to_return;
- } else
+ } else
*(q++) = '='; /* Mark separator */
strcpy (q, p);
q = strchr (q, 0);
* filename parameter invalid (ie, most of the time,
* we get filename as a pointer from cpanel->dir).
*/
- if (p < q) {
+ if (p < q) {
char *filename_copy = strdup (filename);
exec_extension (filename_copy, r + 1, drops, move_dir, view_at_line_number);
free (filename_copy);
-
+
to_return = "Success";
}
break;
char *regex_command (char *filename, char *action, char **drops, int *move_dir);
-/* Call it after the user has edited the mc.ext file,
+/* Call it after the user has edited the mc.ext file,
* to flush the cached mc.ext file
*/
void flush_extension_file (void);
/* {{{ Copyright */
/* File managing. Important notes on this file:
-
+
About the use of dialogs in this file:
If you want to add a new dialog box (or call a routine that pops
up a dialog box), you have to provide a wrapper for background
/* File managing
Copyright (C) 1994, 1995, 1996 The Free Software Foundation
-
+
Written by: 1994, 1995 Janne Kukonlehto
1994, 1995 Fred Leeflang
1994, 1995, 1996 Miguel de Icaza
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include <stdio.h>
#ifdef OS2_NT
# include <io.h>
-#endif
+#endif
#include <errno.h>
#include "tty.h"
int dive_into_subdirs = 0;
/* When moving directories cross filesystem boundaries delete the successfull
- copied files when all files below the directory and its subdirectories
- were processed.
+ copied files when all files below the directory and its subdirectories
+ were processed.
If erase_at_end is zero files will be deleted immediately after their
successful copy (Note: this behaviour is not tested and at the moment
it can't be changed at runtime) */
/* the files-to-be-erased list */
struct link *erase_list;
-/* In copy_dir_dir we use two additional single linked lists: The first -
- variable name `parent_dirs' - holds information about already copied
- directories and is used to detect cyclic symbolic links.
- The second (`dest_dirs' below) holds information about just created
- target directories and is used to detect when an directory is copied
- into itself (we don't want to copy infinitly).
+/* In copy_dir_dir we use two additional single linked lists: The first -
+ variable name `parent_dirs' - holds information about already copied
+ directories and is used to detect cyclic symbolic links.
+ The second (`dest_dirs' below) holds information about just created
+ target directories and is used to detect when an directory is copied
+ into itself (we don't want to copy infinitly).
Both lists don't use the linkcount and name structure members of struct
link. */
struct link *dest_dirs = 0;
check_buttons (void)
{
x_flush_events ();
-
+
if (op_dlg->running)
return FILE_CONT;
op_win_callback (struct Dlg_head *h, int id, int msg)
{
switch (msg){
-#ifndef HAVE_X
+#ifndef HAVE_X
case DLG_DRAW:
attrset (COLOR_NORMAL);
dlg_erase (h);
int minus = verbose ? 0 : 3;
int eta_offset = with_eta ? (WX_ETA_EXTRA) / 2 : 0;
-#ifdef HAVE_XVIEW
+#ifdef HAVE_XVIEW
char *sixty = " ";
char *fifteen = " ";
#else
char *sixty = "";
char *fifteen = "";
-#endif
+#endif
replace_result = 0;
recursive_result = 0;
showing_eta = with_eta;
if ((op_dlg->y + op_dlg->lines) > last_hint_line)
the_hint->widget.y = op_dlg->y + op_dlg->lines+1;
#endif
-
+
x_set_dialog_title (op_dlg, "");
tk_new_frame (op_dlg, "b.");
XV_WLAY_CENTERROW);
tk_new_frame (op_dlg, "2.");
- add_widgetl (op_dlg, ProgressGauge [2] = gauge_new (7, FCOPY_GAUGE_X, 0, 100, 0, "g-1"),
+ add_widgetl (op_dlg, ProgressGauge [2] = gauge_new (7, FCOPY_GAUGE_X, 0, 100, 0, "g-1"),
XV_WLAY_RIGHTOF);
- add_widgetl (op_dlg, ProgressLabel [2] = label_new (7, FCOPY_LABEL_X, fifteen, "l-1"),
+ add_widgetl (op_dlg, ProgressLabel [2] = label_new (7, FCOPY_LABEL_X, fifteen, "l-1"),
XV_WLAY_NEXTROW);
add_widgetl (op_dlg, bps_label = label_new (7, WX, "", "bps-label"), XV_WLAY_NEXTROW);
tk_new_frame (op_dlg, "1.");
- add_widgetl (op_dlg, ProgressGauge [1] = gauge_new (8, FCOPY_GAUGE_X, 0, 100, 0, "g-2"),
+ add_widgetl (op_dlg, ProgressGauge [1] = gauge_new (8, FCOPY_GAUGE_X, 0, 100, 0, "g-2"),
XV_WLAY_RIGHTOF);
- add_widgetl (op_dlg, ProgressLabel [1] = label_new (8, FCOPY_LABEL_X, fifteen, "l-2"),
+ add_widgetl (op_dlg, ProgressLabel [1] = label_new (8, FCOPY_LABEL_X, fifteen, "l-2"),
XV_WLAY_RIGHTOF);
add_widgetl (op_dlg, stalled_label = label_new (8, WX, "", "stalled"), XV_WLAY_NEXTROW);
-
+
tk_new_frame (op_dlg, "0.");
- add_widgetl (op_dlg, ProgressGauge [0] = gauge_new (6, FCOPY_GAUGE_X, 0, 100, 0, "g-3"),
+ add_widgetl (op_dlg, ProgressGauge [0] = gauge_new (6, FCOPY_GAUGE_X, 0, 100, 0, "g-3"),
XV_WLAY_RIGHTOF);
- add_widgetl (op_dlg, ProgressLabel [0] = label_new (6, FCOPY_LABEL_X, fifteen, "l-3"),
+ add_widgetl (op_dlg, ProgressLabel [0] = label_new (6, FCOPY_LABEL_X, fifteen, "l-3"),
XV_WLAY_RIGHTOF);
add_widgetl (op_dlg, eta_label = label_new (6, WX, "", "eta_label"), XV_WLAY_NEXTROW);
-
+
tk_new_frame (op_dlg, "f1.");
add_widgetl (op_dlg, FileString [1] = label_new (4, FCOPY_GAUGE_X, sixty, "fs-l-1"),
XV_WLAY_RIGHTOF);
- add_widgetl (op_dlg, FileLabel [1] = label_new (4, FCOPY_LABEL_X, fifteen, "fs-l-2"),
+ add_widgetl (op_dlg, FileLabel [1] = label_new (4, FCOPY_LABEL_X, fifteen, "fs-l-2"),
XV_WLAY_NEXTROW);
tk_new_frame (op_dlg, "f0.");
add_widgetl (op_dlg, FileString [0] = label_new (3, FCOPY_GAUGE_X, sixty, "fs-x-1"),
XV_WLAY_RIGHTOF);
- add_widgetl (op_dlg, FileLabel [0] = label_new (3, FCOPY_LABEL_X, fifteen, "fs-x-2"),
+ add_widgetl (op_dlg, FileLabel [0] = label_new (3, FCOPY_LABEL_X, fifteen, "fs-x-2"),
XV_WLAY_NEXTROW);
-
+
/* We will manage the dialog without any help, that's why
we have to call init_dlg */
init_dlg (op_dlg);
int i = strlen (cpanel->cwd);
/* We remove the full path we have added before */
- if (!strncmp (s, cpanel->cwd, i)){
+ if (!strncmp (s, cpanel->cwd, i)){
if (s[i] == PATH_SEP)
s += i + 1;
}
#endif /* WITH_FULL_PATHS */
-
+
label_set_text (FileLabel [0], _("Source"));
label_set_text (FileString [0], truncFileString (s));
return check_buttons ();
if (!showing_eta)
return;
-
+
eta_hours = eta_secs / (60 * 60);
eta_mins = (eta_secs - (eta_hours * 60 * 60)) / 60;
eta_s = eta_secs - ((eta_hours * 60 * 60) + eta_mins * 60 );
sprintf (bps_buffer, "%.2f MBS", bps / (1024*1024.0));
} else
sprintf (bps_buffer, "%.2f KBS", bps / 1024.0);
- } else
+ } else
sprintf (bps_buffer, "%ld BPS", bps);
label_set_text (bps_label, bps_buffer);
}
int next_reg;
enum CaseConvs case_conv = NO_CONV;
static char fntarget [MC_MAXPATHLEN];
-
+
len = strlen (fnsource);
j = re_match (&rx, fnsource, len, 0, ®s);
if (j != len) {
next_reg = dest_mask [j] - '0';
/* Fall through */
}
-
+
case '*':
if (next_reg < 0 || next_reg >= RE_NREGS
|| regs.start [next_reg] < 0) {
fntarget [k++] = convert_case (fnsource [l], &case_conv);
next_reg ++;
break;
-
+
default:
fntarget [k++] = convert_case (dest_mask [j], &case_conv);
break;
free_linklist (struct link **linklist)
{
struct link *lp, *lp2;
-
+
for (lp = *linklist; lp != NULL; lp = lp2){
lp2 = lp -> next;
free (lp);
}
#ifdef USE_VFS
-int
+int
is_in_linklist (struct link *lp, char *path, struct stat *sb)
{
ino_t ino = sb->st_ino;
dev_t dev = sb->st_dev;
vfs *vfs = vfs_type (path);
-
+
while (lp) {
if (lp->vfs == vfs && lp->ino == ino && lp->dev == dev )
return 1;
return 0;
}
#else
-int
+int
is_in_linklist (struct link *lp, char *path, struct stat *sb)
{
ino_t ino = sb->st_ino;
dev_t dev = sb->st_dev;
-
+
while (lp) {
if (lp->ino == ino && lp->dev == dev )
return 1;
/* FIXME: Announce we couldn't make the hardlink */
return 0;
}
- lp = (struct link *) xmalloc (sizeof (struct link) + strlen (src_name)
+ lp = (struct link *) xmalloc (sizeof (struct link) + strlen (src_name)
+ strlen (dst_name) + 1, "Hardlink cache");
if (lp){
lp->vfs = my_vfs;
If dst_path is an existing symlink it will be deleted silently
(upper levels take already care of existing files at dst_path).
*/
-static int
+static int
make_symlink (char *src_path, char *dst_path)
{
char link_target[MC_MAXPATHLEN];
int return_status;
struct stat sb;
int dst_is_symlink;
-
- if (mc_lstat (dst_path, &sb) == 0 && S_ISLNK (sb.st_mode))
+
+ if (mc_lstat (dst_path, &sb) == 0 && S_ISLNK (sb.st_mode))
dst_is_symlink = 1;
else
dst_is_symlink = 0;
}
link_target[len] = 0;
- if (stable_symlinks && (!vfs_file_is_local (src_path) ||
+ if (stable_symlinks && (!vfs_file_is_local (src_path) ||
!vfs_file_is_local (dst_path))) {
message_1s (1, MSG_ERROR, _(" Cannot make stable symlinks across "
"non-local filesystems: \n\n"
" Option Stable Symlinks will be disabled "));
stable_symlinks = 0;
}
-
+
if (stable_symlinks && *link_target != PATH_SEP) {
char *p, *q, *r, *s;
int return_status, temp_status;
int do_remote_copy = 0;
int appending = 0;
- /* bitmask used to remember which resourses we should release on return
- A single goto label is much easier to handle than a bunch of gotos ;-). */
- unsigned resources = 0;
+ /* bitmask used to remember which resourses we should release on return
+ A single goto label is much easier to handle than a bunch of gotos ;-). */
+ unsigned resources = 0;
return_status = FILE_RETRY;
if (return_status == FILE_RETRY)
goto retry_src_xstat;
return return_status;
- }
-
+ }
+
if (dst_exists){
/* .ado: For OS/2 or NT: no st_ino exists, it is better to just try to
* overwrite the target file
do_reget = -1;
else
do_reget = 0;
-
+
return_status = query_replace (dst_path, &sb, &sb2);
if (return_status != FILE_CONT)
return return_status;
if (!do_append) {
/* .ado: OS2 and NT don't have hardlinks */
-#ifndef OS2_NT
+#ifndef OS2_NT
/* Check the hardlinks */
- if (!op_follow_links && sb.st_nlink > 1 &&
+ if (!op_follow_links && sb.st_nlink > 1 &&
check_hardlinks (src_path, dst_path, &sb) == 1) {
/* We have made a hardlink - no more processing is necessary */
return return_status;
}
-
+
if (S_ISLNK (sb.st_mode))
return make_symlink (src_path, dst_path);
-
+
#endif /* !OS_NT */
if (S_ISCHR (sb.st_mode) || S_ISBLK (sb.st_mode) || S_ISFIFO (sb.st_mode)
|| S_ISSOCK (sb.st_mode)){
- retry_mknod:
+ retry_mknod:
if (mc_mknod (dst_path, sb.st_mode & umask_kill, sb.st_rdev) < 0){
return_status = file_error
(_(" Cannot create special file \"%s\" \n %s "), dst_path);
return return_status;
}
/* Success */
-
+
#ifndef OS2_NT
retry_mknod_uidgid:
if (preserve_uidgid && mc_chown (dst_path, sb.st_uid, sb.st_gid)){
return FILE_CONT;
}
}
-
+
if (!do_append && !vfs_file_is_local (src_path) && vfs_file_is_local (dst_path)){
mc_setctl (src_path, MCCTL_SETREMOTECOPY, dst_path);
}
resources |= 1;
do_remote_copy = mc_ctl (source_desc, MCCTL_ISREMOTECOPY, 0);
-
+
if (!do_remote_copy) {
retry_src_fstat:
if (mc_fstat (source_desc, &sb)){
do_append = 0;
goto ret;
}
-#if 0
- /* Im not sure if we can delete this. sb is already filled by
+#if 0
+ /* Im not sure if we can delete this. sb is already filled by
(*xstat)() - Norbert. */
} else {
retry_src_rstat:
do_append = 0;
goto ret;
}
-#endif
+#endif
}
src_mode = sb.st_mode;
#ifndef OS2_NT
if (!do_remote_copy) {
retry_dst_open:
- if ((do_append &&
+ if ((do_append &&
(dest_desc = mc_open (dst_path, O_WRONLY | O_APPEND)) < 0) ||
(!do_append &&
(dest_desc = mc_open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0)) {
int i, size, secs, update_secs;
long dt;
char *stalled_msg;
-
+
gettimeofday (&tv_transfer_start, (struct timezone *) NULL);
tv_last_update = tv_transfer_start;
eta_secs = 0.0;
-
+
for (i = 1; i;) {
switch (size = mc_ctl (source_desc, MCCTL_REMOTECOPYCHUNK, 8192)) {
case MCERR_TARGETOPEN:
case MCERR_DATA_ON_STDIN:
break;
case MCERR_FINISH:
- resources |= 8;
+ resources |= 8;
i = 0;
break;
}
- /* the first time we reach this line the target file has been created
+ /* the first time we reach this line the target file has been created
or truncated and we actually have a short target file.
Do we really want to delete the target file when the ftp transfer
fails? If we don't delete it we would be able to use reget later.
|(S_IXOTH|S_IWOTH|S_IROTH) /* other */
|(S_IXGRP|S_IWGRP|S_IRGRP)))) /* group */
src_mode = S_IRUSR|S_IWUSR|S_IROTH|S_IRGRP;
-
+
gettimeofday (&tv_last_input, NULL);
}
/* Timed operations: */
/* 3. Compute ETA */
if (secs > 2 || eta_secs == 0.0){
dt = (tv_current.tv_sec - tv_transfer_start.tv_sec);
-
+
if (n_read_total){
eta_secs = ((dt / (double) n_read_total) * file_size) - dt;
bps = n_read_total / ((dt < 1) ? 1 : dt);
bps_time = 1;
bps = n_read_total / bps_time;
}
-
+
label_set_text (stalled_label, stalled_msg);
return_status = show_file_progress (n_read_total, file_size);
ret:
if (buf)
free (buf);
-
+
retry_src_close:
if ((resources & 1) && mc_close (source_desc) < 0){
temp_status = file_error
goto retry_dst_close;
return_status = temp_status;
}
-
+
if (resources & 4) {
/* Remove short file */
mc_unlink (dst_path);
}
} else if (resources & (2|8)) {
/* no short file and destination file exists */
-#ifndef OS2_NT
+#ifndef OS2_NT
if (!appending && preserve_uidgid) {
retry_dst_chown:
if (mc_chown (dst_path, src_uid, src_gid)){
goto retry_dst_chmod;
return_status = temp_status;
}
-
+
if (!appending && preserve)
mc_utime (dst_path, &utb);
}
goto retry_src_stat;
return return_status;
}
-
+
if (is_in_linklist (dest_dirs, s, &cbuf)) {
- /* Don't copy a directory we created before (we don't want to copy
+ /* Don't copy a directory we created before (we don't want to copy
infinitely if a directory is copied into itself) */
/* FIXME: should there be an error message and FILE_SKIP? - Norbert */
return FILE_CONT;
}
-/* Hmm, hardlink to directory??? - Norbert */
+/* Hmm, hardlink to directory??? - Norbert */
/* FIXME: In this step we should do something
- in case the destination already exist */
+ in case the destination already exist */
/* Check the hardlinks */
if (preserve && cbuf.st_nlink > 1 && check_hardlinks (s, d, &cbuf) == 1) {
/* We have made a hardlink - no more processing is necessary */
goto retry_src_stat;
return return_status;
}
-
-#ifndef OS2_NT
+
+#ifndef OS2_NT
if (is_in_linklist (parent_dirs, s, &cbuf)) {
/* we found a cyclic symbolic link */
message_2s (1, MSG_ERROR, _(" Cannot copy cyclic symbolic link \n `%s' "), s);
return FILE_SKIP;
}
-#endif
-
+#endif
+
lp = xmalloc (sizeof (struct link), "parent_dirs");
lp->vfs = vfs_type (s);
lp->ino = cbuf.st_ino;
*/
#if 1
/* Again, I'm getting curious. Is not d already what we wanted, incl.
- * masked source basename? Is not this just a relict of the past versions?
+ * masked source basename? Is not this just a relict of the past versions?
* I'm afraid this will lead into a two level deep dive :(
*
* I think this is indeed the problem. I can not remember any case where
*/
if (toplevel && dive_into_subdirs){
dest_dir = concat_dir_and_file (d, x_basename (s));
- } else
+ } else
#endif
{
dest_dir = copy_strings (d, 0);
goto retry_dst_mkdir;
goto ret;
}
-
+
lp = xmalloc (sizeof (struct link), "dest_dirs");
mc_stat (dest_dir, &buf);
lp->vfs = vfs_type (dest_dir);
lp->dev = buf.st_dev;
lp->next = dest_dirs;
dest_dirs = lp;
-
-#ifndef OS2_NT
+
+#ifndef OS2_NT
if (preserve_uidgid) {
retry_dst_chown:
if (mc_chown (dest_dir, cbuf.st_uid, cbuf.st_gid)){
if ((reading = mc_opendir (s)) == 0){
goto ret;
}
-
+
while ((next = mc_readdir (reading)) && return_status != FILE_ABORT){
/*
- * Now, we don't want '.' and '..' to be created / copied at any time
+ * Now, we don't want '.' and '..' to be created / copied at any time
*/
if (!strcmp (next->d_name, "."))
continue;
/* get the filename and add it to the src directory */
path = concat_dir_and_file (s, next->d_name);
-
+
(*xstat)(path, &buf);
if (S_ISDIR (buf.st_mode)){
mdpath = concat_dir_and_file (dest_dir, next->d_name);
dest_file = concat_dir_and_file (dest_dir, x_basename (path));
return_status = copy_file_file (path, dest_file, 1);
free (dest_file);
- }
+ }
if (delete && return_status == FILE_CONT) {
if (erase_at_end) {
static struct link *tail;
if (erase_list) {
tail->next = lp;
tail = lp;
- } else
+ } else
erase_list = tail = lp;
} else {
if (S_ISDIR (buf.st_mode)) {
return_status = erase_file (path);
}
}
-
+
#ifdef __os2__
/* The OS/2 mc_readdir returns a block of memory DIR
* next should be freed: .ado
free (path);
}
mc_closedir (reading);
-
+
/* .ado: Directories can not have permission set in OS/2 */
#ifndef __os2__
if (preserve) {
do_reget = -1;
else
do_reget = 0;
-
+
return_status = query_replace (d, &src_stats, &dst_stats);
if (return_status != FILE_CONT)
return return_status;
/* Ok to overwrite */
}
#if 0
- retry_rename:
+ retry_rename:
#endif
if (!do_append) {
if (S_ISLNK (src_stats.st_mode) && stable_symlinks) {
#if 0
/* Comparison to EXDEV seems not to work in nfs if you're moving from
one nfs to the same, but on the server it is on two different
- filesystems. Then nfs returns EIO instead of EXDEV.
+ filesystems. Then nfs returns EIO instead of EXDEV.
Hope it will not hurt if we always in case of error try to copy/delete. */
else
errno = EXDEV; /* Hack to copy (append) the file and then delete it */
goto retry_rename;
return return_status;
}
-#endif
+#endif
/* Failed because filesystem boundary -> copy the file instead */
if ((return_status = copy_file_file (s, d, 0)) != FILE_CONT)
free (destdir);
return return_status;
}
-
+
retry_rename:
if (mc_rename (s, destdir) == 0){
return_status = FILE_CONT;
if (!strcmp (s, ".."))
return 1;
-
+
reading = mc_opendir (s);
-
+
if (!reading)
return 1;
-
+
while ((next = mc_readdir (reading)) && return_status == FILE_CONT){
if (!strcmp (next->d_name, "."))
continue;
if (mc_lstat (path, &buf)){
free (path);
return 1;
- }
+ }
if (S_ISDIR (buf.st_mode))
return_status = (recursive_erase (path) != FILE_CONT);
else
return FILE_CONT;
}
-/* Return -1 on error, 1 if there are no entries besides "." and ".."
+/* Return -1 on error, 1 if there are no entries besides "." and ".."
in the directory path points to, 0 else. */
-static int
+static int
check_dir_is_empty(char *path)
{
DIR *dir;
/* No problem with Gnome, as get_current_type never returns view_tree there */
if (get_current_type () == view_tree){
WTree *tree = (WTree *)get_panel_widget (get_current_index ());
-
+
mc_stat (tree->selected_ptr->name, stat_buf);
return tree->selected_ptr->name;
- }
+ }
if (panel->marked){
for (i = 0; i < panel->count; i++)
return 0;
}
-/* Sets all global variables used by copy_file_file/move_file_file to a
+/* Sets all global variables used by copy_file_file/move_file_file to a
resonable default
(file_mask_dialog sets these global variables interactively)
*/
op_follow_links = 0;
dive_into_subdirs = 0;
xstat = mc_lstat;
-
+
preserve = 1;
umask_kill = 0777777;
preserve_uidgid = (geteuid () == 0) ? 1 : 0;
/* follow symlinks and preserve Attributes must be the first */
{ quick_checkbox, 3, 64, 8, FMDY, N_("preserve &Attributes"), 9, 0,
&op_preserve, 0, XV_WLAY_BELOWCLOSE, "preserve" },
- { quick_checkbox, 3, 64, 7, FMDY, N_("follow &Links"), 7, 0,
+ { quick_checkbox, 3, 64, 7, FMDY, N_("follow &Links"), 7, 0,
&op_follow_links, 0, XV_WLAY_BELOWCLOSE, "follow" },
#ifdef HAVE_XVIEW
#define FMDI1 5
#define FMDI2 2
#define FMDC 4
- { quick_input, 3, 64, 6, FMDY, "", 58, 0,
+ { quick_input, 3, 64, 6, FMDY, "", 58, 0,
0, 0, XV_WLAY_BELOWCLOSE, "input2" },
#endif
{ quick_label, 3, 64, 5, FMDY, N_("to:"), 0, 0, 0, 0, XV_WLAY_BELOWOF,"to"},
- { quick_checkbox, 37, 64, 4, FMDY, N_("&Using shell patterns"), 0, 0,
+ { quick_checkbox, 37, 64, 4, FMDY, N_("&Using shell patterns"), 0, 0,
0/* &source_easy_patterns */, 0, XV_WLAY_BELOWCLOSE, "using-shell" },
- { quick_input, 3, 64, 3, FMDY, "", 58,
+ { quick_input, 3, 64, 3, FMDY, "", 58,
0, 0, 0, XV_WLAY_BELOWCLOSE, "input-def" },
-#ifndef HAVE_XVIEW
+#ifndef HAVE_XVIEW
#define FMDI1 4
#define FMDI2 5
#define FMDC 3
- { quick_input, 3, 64, 6, FMDY, "", 58, 0,
+ { quick_input, 3, 64, 6, FMDY, "", 58, 0,
0, 0, XV_WLAY_BELOWCLOSE, "input2" },
-#endif
-#define FMDI0 6
+#endif
+#define FMDI0 6
{ quick_label, 3, 64, 2, FMDY, "", 0, 0, 0, 0, XV_WLAY_DONTCARE, "ql" },
#define FMBRGT 7
{ quick_button, 42, 64, 9, FMDY, N_("&Cancel"), 0, B_CANCEL, 0, 0, XV_WLAY_DONTCARE,
{ quick_button, 14, 64, 9, FMDY, N_("&Ok"), 0, B_ENTER, 0, 0, XV_WLAY_NEXTROW, "ok" },
{ quick_checkbox, 42, 64, 8, FMDY, N_("&Stable Symlinks"), 0, 0,
&stable_symlinks, 0, XV_WLAY_BELOWCLOSE, "stab-sym" },
- { quick_checkbox, 31, 64, 7, FMDY, N_("&Dive into subdir if exists"), 0, 0,
+ { quick_checkbox, 31, 64, 7, FMDY, N_("&Dive into subdir if exists"), 0, 0,
&dive_into_subdirs, 0, XV_WLAY_BELOWOF, "dive" },
{ 0 } };
len = strlen (fmd_widgets [FMCB12].text)
+ strlen (fmd_widgets [FMCB22].text) + 15;
fmd_xlen = max (fmd_xlen, len);
-
+
len = strlen (fmd_widgets [FMBRGT].text)
+ strlen (fmd_widgets [FMBLFT].text) + 11;
const char *error;
struct stat buf;
int val;
-
+
QuickDialog Quick_input;
if (!fmd_i18n_flag)
Quick_input.help = "[Mask Copy/Rename]";
Quick_input.ylen = FMDY;
Quick_input.i18n = 1;
-
+
if (operation == OP_COPY) {
Quick_input.class = "quick_file_mask_copy";
Quick_input.widgets = fmd_widgets;
xstat = mc_stat;
else
xstat = mc_lstat;
-
+
if (op_preserve || operation == OP_MOVE) {
preserve = 1;
umask_kill = 0777777;
case 'f':
if (only_one)
{
- cp = S_ISDIR (src_stat->st_mode) ?
+ cp = S_ISDIR (src_stat->st_mode) ?
prompt_parts [2] : prompt_parts [0];
}
else
{
- cp = (panel->marked == panel->dirs_marked)
- ? prompt_parts [3]
- : (panel->dirs_marked ? prompt_parts [4]
+ cp = (panel->marked == panel->dirs_marked)
+ ? prompt_parts [3]
+ : (panel->dirs_marked ? prompt_parts [4]
: prompt_parts [1]);
}
break;
message (1, MSG_ERROR, _(" Can't operate on \"..\"! "));
return 0;
}
-
+
if (operation < OP_COPY || operation > OP_DELETE)
return 0;
-
+
/* Generate confirmation prompt */
- source = generate_prompt(cmd_buf, panel, operation, only_one, &src_stat);
-
+ source = generate_prompt(cmd_buf, panel, operation, only_one, &src_stat);
+
/* Show confirmation dialog */
if (operation == OP_DELETE && confirm_delete){
if (know_not_what_am_i_doing)
return 0;
} else if (operation != OP_DELETE) {
char *dest_dir;
-
+
if (thedefault != NULL)
dest_dir = thedefault;
else if (get_other_type () == view_listing)
/* Did the user select to do a background operation? */
if (do_bg){
int v;
-
+
v = do_background (copy_strings (operation_names [operation], ": ", panel->cwd, 0));
if (v == -1){
message (1, MSG_ERROR, _(" Sorry, I could not put the job in background "));
/* We turn on ETA display if the source is an ftp file system */
create_op_win (operation, vfs_file_is_ftp (panel->cwd));
ftpfs_hint_reread (0);
-
+
/* Now, let's do the job */
/* This code is only called by the tree and panel code */
if (only_one){
/* One file: FIXME mc_chdir will take user out of any vfs */
if (operation != OP_COPY && get_current_type () == view_tree)
mc_chdir (PATH_SEP_STR);
-
+
/* The source and src_stat variables have been initialized before */
#ifdef WITH_FULL_PATHS
source_with_path = concat_dir_and_file (panel->cwd, source);
#endif
-
+
if (operation == OP_DELETE){
/* Delete operation */
if (S_ISDIR (src_stat.st_mode))
vfs_shut ();
tell_parent (MSG_CHILD_EXITING);
exit (1);
- }
+ }
#endif
return 1;
}
{
char nfile1 [16];
char nfile2 [16];
-
+
strcpy (nfile1, name_trunc (file1, 15));
strcpy (nfile2, name_trunc (file2, 15));
-
+
sprintf (cmd_buf, format, nfile1, nfile2, unix_error_string (errno));
return do_file_error (cmd_buf);
}
static struct
{
char* text;
- int ypos, xpos;
+ int ypos, xpos;
int value; /* 0 for labels */
char* tkname;
WLay layout;
6, 4, 0, "target-date",XV_WLAY_CENTERROW},
{N_("Source date: %s, size %d"),
5, 4, 0, "source-date",XV_WLAY_CENTERROW}
-};
+};
#define ADD_RD_BUTTON(i)\
add_widgetl (replace_dlg,\
if (!i18n_flag)
{
int l1, l2, l, row;
- register int i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
+ register int i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
while (i--)
rd_widgets [i].text = _(rd_widgets [i].text);
- /*
- *longest of "Overwrite..." labels
+ /*
+ *longest of "Overwrite..." labels
* (assume "Target date..." are short enough)
*/
l1 = max (strlen (rd_widgets [6].text), strlen (rd_widgets [11].text));
/* Now place buttons */
l1 += 5; /* start of first button in the row */
i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
-
+
for (l = l1, row = 0; --i > 1;)
{
if (rd_widgets [i].value != 0)
replace_colors [1] = COLOR_NORMAL;
replace_colors [2] = ERROR_COLOR;
replace_colors [3] = COLOR_NORMAL;
-
+
replace_dlg = create_dlg (0, 0, 16, rd_xlen, replace_colors, replace_callback,
"[ Replace ]", "replace", DLG_CENTER);
-
+
x_set_dialog_title (replace_dlg,
mode == Foreground ? _(" File exists ") : _(" Background process: File exists "));
ADD_RD_LABEL(0, name_trunc (replace_filename, rd_trunc - strlen (rd_widgets [0].text)), 0 );
- ADD_RD_BUTTON(1);
-
+ ADD_RD_BUTTON(1);
+
tk_new_frame (replace_dlg, "a.");
ADD_RD_BUTTON(2);
ADD_RD_BUTTON(9);
ADD_RD_BUTTON(10);
ADD_RD_LABEL(11,0,0);
-
+
tk_new_frame (replace_dlg, "i.");
ADD_RD_LABEL(12, file_date (d_stat->st_mtime), (int) d_stat->st_size);
ADD_RD_LABEL(13, file_date (s_stat->st_mtime), (int) s_stat->st_size);
return FILE_SKIP;
else
return FILE_CONT;
-
+
case REPLACE_REGET:
do_reget = _d_stat->st_size;
-
+
case REPLACE_APPEND:
do_append = 1;
-
+
case REPLACE_YES:
case REPLACE_ALWAYS:
do_refresh ();
query_set_sel (1);
recursive_result = query_dialog (text, msg, D_ERROR, 5,
_("&Yes"), _("&No"), _("a&ll"), _("non&E"), _("&Abort"));
-
-
+
+
if (recursive_result != RECURSIVE_ABORT)
do_refresh ();
free (text);
Written 1995 by Miguel de Icaza
Complete rewrote.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#ifdef ENABLE_NLS
static int i18n_flag = 0;
-
+
if (!i18n_flag)
{
register int i = sizeof(labs)/sizeof(labs[0]);
int l1, maxlen = 0;
-
+
while (i--)
{
l1 = strlen (labs [i] = _(labs [i]));
i = maxlen + ilen + 7;
if (i > FIND_X)
FIND_X = i;
-
+
for (i = sizeof(buts)/sizeof(buts[0]), l1 = 0; i--; )
{
l1 += strlen (buts [i] = _(buts [i]));
ilen = FIND_X - 7 - maxlen; /* for the case of very long buttons :) */
istart = FIND_X - 3 - ilen;
-
+
b1 = b0 + strlen(buts[0]) + 7;
b2 = FIND_X - (strlen(buts[2]) + 6);
-
+
i18n_flag = 1;
}
-
+
#endif /* ENABLE_NLS */
find_par_start:
in_start_name = strdup (easy_patterns ? "*" : ".");
if (!in_contents)
in_contents = strdup ("");
-
+
find_dlg = create_dlg (0, 0, FIND_Y, FIND_X, dialog_colors,
common_dialog_callback, "[Find File]", "findfile",
DLG_CENTER | DLG_GRID);
if (in_with->buffer [0]){
*content = strdup (in_with->buffer);
in_contents = strdup (*content);
- } else
+ } else
*content = in_contents = NULL;
free (in_start_dir);
}
destroy_dlg (find_dlg);
-
+
return return_value;
}
static char*
pop_directory (void)
{
- char *name;
+ char *name;
dir_stack *next;
if (dir_stack_base){
old_dir = strdup (dir);
dirname = listbox_add_item (find_list, 0, 0, dir, 0);
}
-
+
tmp_name = copy_strings (" ", file, 0);
listbox_add_item (find_list, 0, 0, tmp_name, dirname);
free (tmp_name);
int p = ++matches & 7;
insert_file (dir, file);
-
+
/* Scroll nicely */
if (!p)
listbox_select_last (find_list, 1);
else
listbox_select_last (find_list, 0);
-
+
#ifndef HAVE_X
/* Updates the current listing */
send_message (h, &find_list->widget, WIDGET_DRAW, 0);
if (p == 7)
mc_refresh ();
-#endif
+#endif
}
char *
};
struct stat s;
char **p;
-
+
for (p = &paths [0]; *p; p++){
if (stat (*p, &s) == 0)
return *p;
return "egrep";
}
-/*
+/*
* search_content:
*
* Search with egrep the global (FIXME) content_pattern string in the
free (fname);
return;
}
-
+
file_fd = mc_open (fname, O_RDONLY);
free (fname);
-
+
if (file_fd == -1)
return;
#else /* GREP_STDIN */
pipe = mc_doublepopen (file_fd, -1, &pid, egrep_path, egrep_path, "-n", content_pattern, "-", NULL);
#endif /* GREP STDIN */
-
+
if (pipe == -1){
mc_close (file_fd);
return;
}
-
+
sprintf (buffer, _("Grepping in %s"), name_trunc (filename, FIND2_X_USE));
label_set_text (status_label, buffer);
mc_refresh ();
p = buffer;
ignoring = 0;
-
+
enable_interrupt_key ();
got_interrupt ();
while (1){
i = read (pipe, &c, 1);
if (i != 1)
break;
-
+
if (c == '\n'){
p = buffer;
ignoring = 0;
}
if (ignoring)
continue;
-
+
if (c == ':'){
char *the_name;
-
+
*p = 0;
ignoring = 1;
the_name = copy_strings (buffer, ":", filename, NULL);
*p++ = c;
else
*p = 0;
- }
+ }
}
disable_interrupt_key ();
if (i == -1)
do_search_begin:
while (!dp){
-
+
if (dirp){
mc_closedir (dirp);
dirp = 0;
}
-
+
while (!dirp){
char *tmp;
-#ifndef HAVE_X
+#ifndef HAVE_X
attrset (REVERSE_COLOR);
#endif
while (1) {
break;
} else
break;
- }
-
+ }
+
strcpy (directory, tmp);
free (tmp);
dp = mc_readdir (dirp);
#ifdef HAVE_XVIEW
xv_post_proc (h, (void (*)(void *))do_search, (void *)h);
-#endif
+#endif
return;
}
-
+
tmp_name = get_full_name (directory, dp->d_name);
if (subdirs_left){
if (regexp_match (find_pattern, dp->d_name, match_file)){
if (content_pattern)
search_content (h, directory, dp->d_name);
- else
+ else
find_add_match (h, directory, dp->d_name);
}
-
+
free (tmp_name);
dp = mc_readdir (dirp);
find_callback (struct Dlg_head *h, int id, int Msg)
{
switch (Msg){
-#ifndef HAVE_X
+#ifndef HAVE_X
case DLG_DRAW:
common_dialog_repaint (h);
break;
init_find_vars (void)
{
char *dir;
-
+
if (old_dir){
free (old_dir);
old_dir = 0;
int l1 = fbuts[2].len + fbuts[3].len + l0 + fbuts[4].len;
int l2 = fbuts[5].len + fbuts[6].len + fbuts[7].len;
int r1, r2;
-
+
FIND2_X = COLS - 16;
/* Check, if both button rows fit within FIND2_X */
fbuts [6].x = fbuts [5].x + fbuts [5].len + l2;
fbuts [7].x = fbuts [6].x + fbuts [6].len + l2;
}
-
+
find_dlg = create_dlg (0, 0, FIND2_Y, FIND2_X, dialog_colors,
find_callback, "[Find File]", "mfind", DLG_CENTER | DLG_GRID);
-
+
x_set_dialog_title (find_dlg, _("Find file"));
add_widgetl (find_dlg,
- button_new (FIND2_Y-3, fbuts[7].x, B_VIEW, NORMAL_BUTTON,
+ button_new (FIND2_Y-3, fbuts[7].x, B_VIEW, NORMAL_BUTTON,
fbuts[7].text, find_do_edit_file, find_dlg, "button-edit"), 0);
add_widgetl (find_dlg,
button_new (FIND2_Y-3, fbuts[6].x, B_VIEW, NORMAL_BUTTON,
fbuts[0].text, start_stop, find_dlg, "start-stop");
add_widgetl (find_dlg, stop_button, XV_WLAY_RIGHTOF);
add_widgetl (find_dlg,
- button_new (FIND2_Y-4, fbuts[3].x, B_AGAIN, NORMAL_BUTTON,
+ button_new (FIND2_Y-4, fbuts[3].x, B_AGAIN, NORMAL_BUTTON,
fbuts[3].text, 0, 0, "button-again"), XV_WLAY_RIGHTOF);
- add_widgetl (find_dlg,
+ add_widgetl (find_dlg,
button_new (FIND2_Y-4, fbuts[2].x, B_ENTER, DEFPUSH_BUTTON,
fbuts[2].text, 0, 0, "button-chdir"), XV_WLAY_CENTERROW);
/* FIXME: Need to cleanup this, this ought to be passed non-globaly */
find_pattern = pattern;
content_pattern = content;
-
+
set_idle_proc (find_dlg, 1);
init_find_vars ();
push_directory (start_dir);
#ifdef HAVE_XVIEW
xv_post_proc (find_dlg, (void (*)(void *))do_search, (void *)find_dlg);
-#endif
+#endif
run_dlg (find_dlg);
return_value = find_dlg->ret_value;
/* Remove all the items in the stack */
while ((dir = pop_directory ()) != NULL)
free (dir);
-
+
listbox_get_current (find_list, &file_tmp, &dir_tmp);
if (dir_tmp)
char *filename, *dirname;
int v, dir_and_file_set;
int done = 0;
-
+
while (!done){
if (!find_parameters (&start_dir, &pattern, &content))
break;
v = find_file (start_dir, pattern, content, &dirname, &filename);
free (start_dir);
free (pattern);
-
+
if (v == B_ENTER){
if (dirname || filename){
if (dirname){
do_cd (dirname, cd_exact);
if (filename)
- try_to_select (cpanel, filename + (content ?
+ try_to_select (cpanel, filename + (content ?
(strchr (filename + 4, ':') - filename + 1) : 4) );
} else if (filename)
do_cd (filename, cd_exact);
paint_panel (cpanel);
select_item (cpanel);
}
- if (dirname)
+ if (dirname)
free (dirname);
- if (filename)
+ if (filename)
free (filename);
break;
}
- if (content)
+ if (content)
free (content);
dir_and_file_set = dirname && filename;
if (dirname) free (dirname);
if (filename) free (filename);
if (v == B_CANCEL)
break;
-
+
if (v == B_PANELIZE){
if (dir_and_file_set){
try_to_select (cpanel, NULL);
#define __FIND_H
#define MAX_FIND_MENU 4 /* Maximum Menu */
-#define MAX_FIND_FLINES 11 /* Size of Window Where files are stored */
+#define MAX_FIND_FLINES 11 /* Size of Window Where files are stored */
#define MAX_FIND_TLINES 4 /* Size of Window Where Menu and text .. */
#define MAX_FIND_COLS 48 /* Length of Windows */
#define FIND_DIALOG_SIZE MAX_FIND_FLINES+MAX_FIND_TLINES
int isdir; /* For adding a '\t' on FALSE */
char *fname; /* Name of the file */
char *path; /* For changing panel */
- struct find_list *up;
+ struct find_list *up;
struct find_list *down;
}find_list;
typedef struct FStack{ /* The Stack will be used to store */
char *dir_name; /* the directories to search */
- struct FStack *next; /* single-linked */
+ struct FStack *next; /* single-linked */
}FStack;
void do_find(void);
/* HLP converter
Copyright (C) 1994, 1995 Janne Kukonlehto
Copyright (C) 1995 Jakub Jelinek
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
for (i = 0; i < strlen (buffer); i ++)
{
c = buffer [i];
- if (c == CHAR_LINK_POINTER)
+ if (c == CHAR_LINK_POINTER)
link_flag = 1; /* Link target name starts */
else if (c == CHAR_LINK_END)
link_flag = 0; /* Link target name ends */
p = strchr (buffer, CHAR_LINK_POINTER);
if (p) {
char *q;
-
+
*p = 0;
print_string (buffer);
q = strchr (p + 1, CHAR_LINK_END);
buffer = strtok (buffer, " \t\n");
/* Repeat for each word */
while (buffer){
- /* Skip empty strings */
+ /* Skip empty strings */
if (strlen (buffer) > 0){
len = string_len (buffer);
/* Change the line if about to break the right margin */
int len; /* Length of input line */
char buffer [BUFFER_SIZE]; /* Input line */
int i, j;
- char *p;
+ char *p;
int ignore_newline = 0;
/* Validity check for arguments */
fprintf (stderr, _("Usage: fixhlp <width> <tocname>\n"));
return 3;
}
-
+
if ((toc_file = fopen (argv[2], "w")) == NULL) {
fprintf (stderr, _("fixhlp: Cannot open toc for writing"));
return 4;
} else {
char *p, *q;
int i;
-
+
for (p = buffer, q = strchr (p, CHAR_RESERVED); q != NULL;
p = q + 1, q = strchr (p, CHAR_RESERVED)) {
*q = 0;
/* Hypertext file browser.
Copyright (C) 1994, 1995 Miguel de Icaza.
Copyright (C) 1994, 1995 Janne Kukonlehto
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
and uses mainly the dialog to achieve the help work. there is only
one specialized widget and it's only used to forward the mouse messages
to the appropiate routine.
-
+
*/
#include <config.h>
#define HISTORY_SIZE 20
#define HELP_WINDOW_WIDTH 62
-/* "$Id: help.c,v 1.1 2001/12/30 09:55:25 sedwards Exp $" */
+/* "$Id$" */
static char *data; /* Pointer to the loaded data file */
static int help_lines = 18; /* Lines in help viewer */
if (!start)
return 0;
-
+
for (; *e && *e != CHAR_NODE_END; e++){
if (*d == *e)
d++;
char *e;
e = start;
-
+
for (; *e && (*e != CHAR_NODE_END); e += direction){
if (*e == the_char)
return e;
if (!selected_item)
return start;
-
+
for (p = selected_item; *p && *p != CHAR_NODE_END && *p != CHAR_LINK_POINTER; p++)
;
if (*p == CHAR_LINK_POINTER){
if (!current_link)
return 0;
-
+
p = current_link - 1;
if (p <= start)
return 0;
-
+
p = search_char_node (p, CHAR_LINK_START, -1);
return p;
}
int active_col, active_line;/* Active link position */
do {
-
+
line = col = acs = active_col = active_line = repeat_paint = 0;
-
+
clear_link_areas ();
if (selected_item < paint_start)
selected_item = NULL;
-
+
for (p = paint_start; *p != CHAR_NODE_END && line < help_lines; p++){
c = *p;
switch (c){
continue;
if (col > HELP_WINDOW_WIDTH-1)
continue;
-
+
dlg_move (h, line+2, col+2);
if (acs){
if (c == ' ' || c == '.')
/* The event is relative to the dialog window, adjust it: */
event->y -= 2;
-
+
if (event->buttons & GPM_B_RIGHT){
currentpoint = startpoint = history [history_ptr].page;
selected_item = history [history_ptr].link;
history_ptr--;
if (history_ptr < 0)
history_ptr = HISTORY_SIZE-1;
-
+
help_callback (w->parent, 0, DLG_DRAW);
return 0;
}
history [history_ptr].link = selected_item;
currentpoint = startpoint = search_string (data, "[How to use help]") + 1;
selected_item = NULL;
-#ifndef HAVE_XVIEW
+#ifndef HAVE_XVIEW
help_callback (h, 0, DLG_DRAW);
-#endif
+#endif
}
void help_index_cmd (Dlg_head *h)
else
currentpoint = startpoint = new_item + 1;
selected_item = NULL;
-#ifndef HAVE_XVIEW
+#ifndef HAVE_XVIEW
help_callback (h, 0, DLG_DRAW);
-#endif
+#endif
}
static void quit_cmd (void *x)
{
Dlg_head *h = (Dlg_head *) x;
-
+
dlg_stop (x);
}
history_ptr--;
if (history_ptr < 0)
history_ptr = HISTORY_SIZE-1;
-
-#ifndef HAVE_XVIEW
+
+#ifndef HAVE_XVIEW
help_callback (h, 0, DLG_DRAW);
-#endif
+#endif
}
static int md_callback (Dlg_head *h, Widget *w, int msg, int par)
case KEY_LEFT:
prev_node_cmd (h);
break;
-
+
case '\n':
case KEY_RIGHT:
/* follow link */
history_ptr--;
if (history_ptr < 0)
history_ptr = HISTORY_SIZE-1;
-
+
currentpoint = startpoint = history [history_ptr].page;
selected_item = history [history_ptr].link;
#endif
}
selected_item = NULL;
break;
-
+
case KEY_DOWN:
case '\t':
/* select next link */
else
selected_item = NULL;
break;
-
+
case KEY_UP:
case ALT ('\t'):
/* select previous link */
}
}
break;
-
+
case 'n':
/* Next node */
new_item = currentpoint;
selected_item = NULL;
}
break;
-
+
case 'p':
/* Previous node */
new_item = currentpoint;
currentpoint = new_item + 2;
selected_item = NULL;
break;
-
+
case 'c':
help_index_cmd (h);
break;
-
+
case ESC_CHAR:
case XCTRL('g'):
dlg_stop (h);
default:
return 0;
-
+
}
help_callback (h, 0, DLG_DRAW);
return 1;
{
WButtonBar *help_bar;
Widget *md;
-
+
if ((data = load_file (filename)) == 0){
message (1, MSG_ERROR, _(" Can't open file %s \n %s "),
filename, unix_error_string (errno));
/* allow us to process the tab key */
whelp->raw = 1;
-#endif
+#endif
selected_item = search_string_node (main, STRING_LINK_START) - 1;
currentpoint = startpoint = main + 1;
help_bar = buttonbar_new (keybar_visible);
help_bar->widget.y -= whelp->y;
help_bar->widget.x -= whelp->x;
-
+
md = mousedispatch_new (1, 1, help_lines, HELP_WINDOW_WIDTH-2);
-
+
add_widget (whelp, help_bar);
add_widget (whelp, md);
Janne did the original Hotlist code, Andrej made the groupable
hotlist; the move hotlist and revamped the file format and made
it stronger.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
hl->head =
hl->up =
hl->next = 0;
-
+
return hl;
}
{
dialog_repaint (dlg, COLOR_NORMAL, COLOR_HOT_NORMAL);
attrset (COLOR_NORMAL);
- draw_box (dlg, 2, 5,
+ draw_box (dlg, 2, 5,
dlg->lines - (hotlist_state.moving ? 6 : 10),
dlg->cols - (UX*2));
if (!hotlist_state.moving)
if (list->current){
if (list->current->data != 0) {
struct hotlist *hlp = (struct hotlist *)list->current->data;
-
+
if (hlp->type == HL_TYPE_ENTRY)
text = hlp->directory;
else
text = _("Subgroup - press ENTER to see list");
-
+
#ifndef HAVE_X
p = copy_strings (" ", current_group->label, " ", (char *)0);
if (!hotlist_state.moving)
entry->next =
entry->up = 0;
}
-
+
static void add_new_entry_cmd (void);
static void init_movelist (int, struct hotlist *);
static int hotlist_callback (Dlg_head * h, int Par, int Msg)
{
switch (Msg) {
-#ifndef HAVE_X
+#ifndef HAVE_X
case DLG_DRAW:
hotlist_refresh (h);
break;
-#endif
+#endif
case DLG_UNHANDLED_KEY:
switch (Par) {
row = hotlist_but [i].y;
- if (hotlist_but [i].x != 0)
+ if (hotlist_but [i].x != 0)
{
/* not first int the row */
if (!strcmp (hotlist_but [i].text, cancel_but))
- hotlist_but [i].x =
+ hotlist_but [i].x =
cols - strlen (hotlist_but [i].text) - 13;
else
hotlist_but [i].x = cur_x [row];
+ (hotlist_but [i].flags == DEFPUSH_BUTTON ? 5 : 3);
}
}
-
+
return cols;
}
"expanded_view_of_groups", 0, profile_name);
hotlist_dlg = create_dlg (0, 0, LINES-2, hotlist_cols, dialog_colors,
- hotlist_callback,
+ hotlist_callback,
list_type == LIST_VFSLIST ? "[vfshot]" : "[Hotlist]",
list_type == LIST_VFSLIST ? "vfshot" : "hotlist",
DLG_CENTER|DLG_GRID);
}
#undef XTRACT
- /* We add the labels.
+ /* We add the labels.
* pname will hold entry's pathname;
* pname_group will hold name of current group
*/
} else
fill_listbox ();
- add_widgetl (hotlist_dlg, l_hotlist, XV_WLAY_EXTENDWIDTH);
+ add_widgetl (hotlist_dlg, l_hotlist, XV_WLAY_EXTENDWIDTH);
/* add listbox to the dialogs */
}
add_widget (movelist_dlg, movelist_group);
#endif
/* get new listbox */
- l_movelist = listbox_new (UY + 1, UX + 1,
+ l_movelist = listbox_new (UY + 1, UX + 1,
movelist_dlg->cols - 2*UX - 2, movelist_dlg->lines - 8,
listbox_cback, l_call, "listbox");
fill_listbox ();
- add_widgetl (movelist_dlg, l_movelist, XV_WLAY_EXTENDWIDTH);
+ add_widgetl (movelist_dlg, l_movelist, XV_WLAY_EXTENDWIDTH);
/* add listbox to the dialogs */
}
{ quick_input, 4, 80, 3, 0, "", 58, 0, 0, 0, XV_WLAY_BELOWCLOSE, "input-lbl" },
{ quick_label, 3, 80, 2, 0, 0, 0, 0, 0, 0, XV_WLAY_DONTCARE, "label-lbl" },
{ 0 } };
-
+
int len;
int i;
int lines1, lines2;
char *my_str1, *my_str2;
-
+
#ifdef ENABLE_NLS
static int i18n_flag = 0;
#endif /* ENABLE_NLS */
quick_widgets [5].str_result = &my_str1;
quick_widgets [3].str_result = &my_str2;
-
+
Quick_input.widgets = quick_widgets;
if ((i = quick_dialog (&Quick_input)) != B_CANCEL){
*r1 = *(quick_widgets [5].str_result);
{ quick_input, 4, 80, 0, 0, "", 58, 0, 0, 0, XV_WLAY_BELOWCLOSE, "input" },
{ quick_label, 3, 80, 2, 0, 0, 0, 0, 0, 0, XV_WLAY_DONTCARE, "label" },
{ 0 } };
-
+
int len;
int i;
int lines;
#ifdef ENABLE_NLS
static int i18n_flag = 0;
#endif /* ENABLE_NLS */
-
+
len = max (strlen (header), msglen (label, &lines)) + 4;
len = max (len, 64);
quick_widgets [3].str_result = &my_str;
quick_widgets [3].text = "";
-
+
Quick_input.widgets = quick_widgets;
if ((ret = quick_dialog (&Quick_input)) != B_CANCEL){
*result = *(quick_widgets [3].str_result);
}
}
-
+
static void remove_from_hotlist (struct hotlist *entry)
{
if (entry->type == HL_TYPE_GROUP) {
char *key, *value;
char *group_section;
struct hotlist *current = 0;
-
+
group_section = find_group_section (grp);
profile_keys = profile_init_iterator (group_section, profile_name);
while ((c = getc (hotlist_file)) != EOF && c != '\n' && isspace (c))
;
return c;
-
+
}
static int hot_next_token ()
if (hotlist_state.loaded) {
stat (hotlist_file_name, &stat_buf);
- if (hotlist_file_mtime < stat_buf.st_mtime)
+ if (hotlist_file_mtime < stat_buf.st_mtime)
done_hotlist ();
else
return;
if (!hotlist_file_name)
hotlist_file_name = concat_dir_and_file (home_dir, HOTLIST_FILENAME);
-
+
hotlist = new_hotlist ();
hotlist->type = HL_TYPE_GROUP;
hotlist->label = strdup (_(" Top level group "));
_(" and then delete [Hotlist] section there"), NULL);
message (0, _(" Hotlist Load "), msg);
free (msg);
-
+
load_group (hotlist);
hotlist_state.loaded = 1;
/*
char *group_section;
group_section = find_group_section (grp);
-
+
profile_clean_section (group_section, profile_name);
for (;current && current->type == HL_TYPE_GROUP; current = current->next){
WritePrivateProfileString (group_section,
current && current->type == HL_TYPE_GROUP;
current = current->next)
save_group (current);
-
+
profile_clean_section (grp->directory, profile_name);
for (;current; current = current->next){
WritePrivateProfileString (grp->directory,
{
int saved = 0;
struct stat stat_buf;
-
+
if (!hotlist_state.readonly && hotlist_state.modified && hotlist_file_name) {
char *fbak = copy_strings (hotlist_file_name, ".bak", 0);
/* Panel managing.
Copyright (C) 1994, 1995 Janne Kukonlehto
Copyright (C) 1995 Miguel de Icaza
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
if (!info->ready)
return;
-
+
my_statfs (&myfs_stats, cpanel->cwd);
buf = cpanel->dir.list [cpanel->selected].buf;
#ifdef OS2_NT
if ((signed char) buf.st_dev < 0)
return;
#endif
-
+
#ifndef HAVE_X
/* Print only lines which fit */
switch (info->widget.y-2){
/* Note: all cases are fall-throughs */
-
+
default:
case 16:
myfs_stats.nodes);
else
addstr (_("No node information"));
-
+
case 15:
widget_move (&info->widget, 15, 3);
if (myfs_stats.avail > 0 || myfs_stats.total > 0){
case 11:
widget_move (&info->widget, 11, 3);
printw (_("Accessed: %s"), file_date (buf.st_atime));
-
+
case 10:
widget_move (&info->widget, 10, 3);
printw (_("Modified: %s"), file_date (buf.st_mtime));
-
+
case 9:
widget_move (&info->widget, 9, 3);
printw (_("Created: %s"), file_date (buf.st_ctime));
printw (_(" (%d blocks)"), buf.st_blocks);
#endif
}
-
+
case 7:
widget_move (&info->widget, 7, 3);
printw (_("Owner: %s/%s"), get_owner (buf.st_uid),
get_group (buf.st_gid));
-
+
case 6:
widget_move (&info->widget, 6, 3);
printw (_("Links: %d"), buf.st_nlink);
-
+
case 5:
widget_move (&info->widget, 5, 3);
printw (_("Mode: %s (%04o)"),
string_perm (buf.st_mode), buf.st_mode & 07777);
-
+
case 4:
widget_move (&info->widget, 4, 3);
printw (_("Location: %Xh:%Xh"), buf.st_dev, buf.st_ino);
-
+
case 3:
widget_move (&info->widget, 3, 2);
/* .ado: fname is invalid if selected == 0 && ifno called from current panel */
info->widget.cols - 15));
} else
printw (_("File: None"));
-
+
case 2:
case 1:
case 0:
{
WInfo *info = (WInfo *) data;
Widget *other_widget;
-
+
other_widget = get_panel_widget (get_current_index ());
if (!other_widget)
return;
if (dlg_overlap (&info->widget, other_widget))
return;
-
+
info->ready = 1;
info_show_info (info);
}
#endif
break;
-#ifndef HAVE_X
+#ifndef HAVE_X
case WIDGET_DRAW:
info_hook (info);
info_show_info (info);
return 1;
-#endif
+#endif
case WIDGET_FOCUS:
return 0;
}
return default_proc (h, msg, par);
}
-
+
WInfo *info_new ()
{
WInfo *info = xmalloc (sizeof (WInfo), "panel_info");
1994, 1995 Janne Kukonlehto.
1995 Jakub Jelinek.
1997 Norbert Warmuth
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include "tty.h"
#include <ctype.h>
#include <errno.h>
-#include <malloc.h>
+#include <malloc.h>
#include "util.h" /* For xmalloc prototype */
#include "mad.h" /* The memory debugger */
#include "global.h"
#include "x.h"
-/* "$Id: key.c,v 1.1 2001/12/30 09:55:25 sedwards Exp $" */
+/* "$Id$" */
/* This macros were stolen from gpm 0.15 */
#define GET_TIME(tv) (gettimeofday(&tv, (struct timezone *)NULL))
#define DIF_TIME(t1,t2) ((t2.tv_sec -t1.tv_sec) *1000+ \
(t2.tv_usec-t1.tv_usec)/1000)
-
+
/* timeout for old_esc_mode in usec */
#define ESCMODE_TIMEOUT 1000000
{
SelectList *p = select_list;
SelectList *prev = 0;
-
+
while (p){
if (p->fd == fd){
if (prev)
if (disabled_channels)
return 0;
-
+
for (p = select_list; p; p = p->next){
FD_SET (p->fd, select_set);
if (p->fd > top_fd)
if (disabled_channels)
return;
-
+
for (p = select_list; p; p = p->next)
if (FD_ISSET (p->fd, select_set))
(*p->callback)(p->fd, p->info);
{
#ifndef HAVE_X
int i;
-
+
for (i = 0; kd [i].code; i++)
define_sequence(kd [i].code, kd [i].seq, kd [i].action);
-#endif
+#endif
}
/* This has to be called before slang_init or whatever routine
{
#ifndef HAVE_X
char *term = (char *) getenv ("TERM");
-
+
/* This has to be the first define_sequence */
/* So, we can assume that the first keys member has ESC */
define_sequences (mc_default_keys);
-
+
/* Terminfo on irix does not have some keys */
if ((!strncmp (term, "iris-ansi", 9)) || (!strncmp (term, "xterm", 5)))
define_sequences (xterm_key_defines);
-
+
define_sequences (mc_bindings);
-
+
/* load some additional keys (e.g. direct Alt-? support) */
load_xtra_key_defines();
-
+
#ifdef __QNX__
if (strncmp(term, "qnx", 3) == 0){
/* Modify the default value of use_8th_bit_as_meta: we would
* like to provide a working mc for a newbie who knows nothing
* about [Options|Display bits|Full 8 bits input]...
- *
- * Don't use 'meta'-bit, when we are dealing with a
+ *
+ * Don't use 'meta'-bit, when we are dealing with a
* 'qnx*'-type terminal: clear the default value!
* These terminal types use 0xFF as an escape character,
* so use_8th_bit_as_meta==1 must not be enabled!
- *
+ *
* [mc-4.1.21+,slint.c/getch(): the DEC_8BIT_HACK stuff
* is not used now (doesn't even depend on use_8th_bit_as_meta
* as in mc-3.1.2)...GREAT!...no additional code is required!]
/* Variable btn has following meaning: */
/* 0 = btn1 dn, 1 = btn2 dn, 2 = btn3 dn, 3 = btn up */
btn = xgetch () - 32;
-
+
/* There seems to be no way of knowing which button was released */
/* So we assume all the buttons were released */
clicks %= 3;
} else
clicks = 0;
-
+
switch (btn) {
case 0:
ev->buttons = GPM_B_LEFT;
p = xmalloc (sizeof (key_def), "create_sequence");
if (!base) base = p;
if (attach) attach->child = p;
-
+
p->ch = *seq;
p->code = code;
p->child = p->next = NULL;
{
if (!seq_append)
seq_append = seq_buffer;
-
+
if (seq_append == &(seq_buffer [sizeof (seq_buffer)-2]))
return 0;
*(seq_append++) = c;
if (strlen (seq) > sizeof (seq_buffer)-1)
return;
-
+
for (base = keys; (base != 0) && *seq; ){
if (*seq == base->ch){
if (base->child == 0){
}
}
keys = create_sequence (seq, code, action);
-#endif
+#endif
}
#ifndef HAVE_X
if (c == KEY_F(0))
return KEY_F(10);
- if (!alternate_plus_minus)
+ if (!alternate_plus_minus)
switch (c) {
case KEY_KP_ADD: c = '+'; break;
case KEY_KP_SUBTRACT: c = '-'; break;
static key_def *this = NULL, *parent;
static struct timeval esctime = { -1, -1 };
static int lastnodelay = -1;
-
+
if (no_delay != lastnodelay) {
this = NULL;
lastnodelay = no_delay;
nodelay (stdscr, FALSE);
#endif
if (c == ERR) {
- if (this != NULL && parent != NULL &&
+ if (this != NULL && parent != NULL &&
parent->action == MCKEY_ESCAPE && old_esc_mode) {
struct timeval current, timeout;
-
+
if (esctime.tv_sec == -1)
return ERR;
GET_TIME (current);
}
if (current.tv_sec < timeout.tv_sec)
return ERR;
- if (current.tv_sec == timeout.tv_sec &&
+ if (current.tv_sec == timeout.tv_sec &&
current.tv_usec < timeout.tv_usec)
return ERR;
this = NULL;
this = NULL;
return ERR;
}
-
+
/* Search the key on the root */
if (!no_delay || this == NULL) {
this = keys;
} else {
/* We got a complete match, return and reset search */
int code;
-
+
pending_keys = seq_append = NULL;
code = this->code;
this = NULL;
if (isalpha(c)
|| (c == '\n') || (c == '\t') || (c == XCTRL('h'))
|| (c == KEY_BACKSPACE) || (c == '!') || (c == '\r')
- || c == 127 || c == '+' || c == '-' || c == '\\'
+ || c == 127 || c == '+' || c == '-' || c == '\\'
|| c == '?')
c = ALT(c);
else if (isdigit(c))
FD_ZERO (&select_set);
FD_SET (input_fd, &select_set); /* Add stdin */
add_selects (&select_set);
-
+
if (set_timeout){
timeout.tv_sec = 0;
timeout.tv_usec = 100000;
dirty++;
vfs_timeout_handler ();
-
+
/* Ok, we use (event->x < 0) to signal that the event does not contain
a suitable position for the mouse, so we can't use show_mouse_pointer
on it.
time_addr = &timeout;
} else {
int seconds;
-
+
if ((seconds = vfs_timeouts ())){
/* the timeout could be improved and actually be
* the number of seconds until the next vfs entry
enable_interrupt_key ();
flag = select (FD_SETSIZE, &select_set, NULL, NULL, time_addr);
disable_interrupt_key ();
-
+
/* select timed out: it could be for any of the following reasons:
* redo_event -> it was because of the MOU_REPEAT handler
* !block -> we did not block in the select call
return EV_NONE;
check_selects (&select_set);
-
+
if (FD_ISSET (input_fd, &select_set))
break;
}
# endif
c = block ? getch_with_delay () : get_key_code(1);
-
+
# ifndef HAVE_SLANG
if (flag)
touchwin (stdscr);
# endif
-
+
if (c == MCKEY_MOUSE) { /* Mouse event */
xmouse_get_event (event);
return EV_MOUSE;
int c = xgetch ();
char buffer [256];
char *p = buffer;
-
+
while (c == ERR)
c = xgetch (); /* Sanity check, should be unnecessary */
learn_store_key (buffer, &p, c);
}
if (c == ERR)
break;
- learn_store_key (buffer, &p, c);
+ learn_store_key (buffer, &p, c);
}
#ifdef BUGGY_CURSES
notimeout (stdscr, TRUE);
application_keypad_mode (void)
{
if (console_flag || xterm_flag) {
- fprintf (stdout, "\033=");
+ fprintf (stdout, "\033=");
fflush (stdout);
}
}
#else
-void done_key ()
+void done_key ()
{
}
Copyright (C) 1998 the Free Software Foundation.
Written by: 1998, Gyorgy Tamasi
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/*
* PURPOSE:
- *
+ *
* We would like to support the direct ALT-?/META-? and some other 'extra'
* keyboard functionality provided by some terminals under some OSes (and
* not supported by the 'learn keys...' facility of 'mc'.
* (First target platform: QNX.)
- *
+ *
* REMARK:
- *
+ *
* Implementation strategy: we don't want to rely on a specific terminal
* information database management API (termcap,terminfo,SLang,...), so we
* try to define a superset of the possible key identifiers here.
/* define the OS/implementation-specific __TK() format */
#define __TK(_tis,_tcs,_tisx,_qtisn) __QTISX(_qtisn)
-
+
#endif /* __USE_QNX_TI */
-
+
#endif /* __QNX__ */
/* {{{ */
-
+
/* general key definitions:
- *
+ *
* format:
- *
+ *
* terminfo name,
* termcap name,
* index in the terminfo string table (ncurses),
* field name in the QNX terminfo strings struct
*/
-
+
#define Key_backspace __TK("kbs", "kb", 55, _ky_backspace )
#define Key_catab __TK("ktbc", "ka", 56, _ky_catab )
#define Key_clear __TK("kclr", "kC", 57, _ky_clear )
/* don't force pre-defining of base keys under QNX */
#define FORCE_BASE_KEY_DEFS 0
-
+
/* OS specific key aliases */
#define Key_alt_a Key_clear
#define Key_alt_b Key_stab
#define Key_alt_enter Key_ctl_enter /* map ALT-ENTER to CTRL-ENTER */
#ifdef __USE_QNX_TI
-
+
/* OS/implementation specific key-define struct */
typedef struct qnx_key_define_s {
int mc_code;
if (term_setup_ok != 1)
return;
- for (idx = 0;
+ for (idx = 0;
idx < sizeof(xtra_key_defines) / sizeof(xtra_key_defines[0]);
idx++) {
str_idx = xtra_key_defines[idx].str_idx;
/* Panel layout module for the Midnight Commander
Copyright (C) 1995 the Free Software Foundation
-
+
Written: 1995 Janne Kukonlehto
1995 Miguel de Icaza
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
#include "x.h"
-/* "$Id: layout.c,v 1.1 2001/12/30 09:55:24 sedwards Exp $" */
+/* "$Id$" */
/* Controls the display of the rotating dash on the verbose mode */
int nice_rotating_dash = 1;
static Dlg_head *layout_dlg;
static char *s_split_direction [2] = {
- N_("&Vertical"),
+ N_("&Vertical"),
N_("&Horizontal")
};
WRadio *radio_widget;
/* Check split has to be done before testing if it changed, since
it can change due to calling _check_split() as well*/
_check_split ();
-
+
/* To avoid setting the cursor to the wrong place */
if ((old_first_panel_size == _first_panel_size) &&
(old_horizontal_split == _horizontal_split)){
}
old_first_panel_size = _first_panel_size;
- old_horizontal_split = _horizontal_split;
-
+ old_horizontal_split = _horizontal_split;
+
attrset (COLOR_NORMAL);
dlg_move (layout_dlg, 6, 6);
printw ("%03d", _first_panel_size);
char* ok_button = _("&Ok");
char* cancel_button = _("&Cancel");
char* save_button = _("&Save");
-
+
if (!i18n_layt_flag)
{
register int l1;
-
+
first_width = 19; /* length of line with '<' '>' buttons */
-
+
layout_title = _(" Layout ");
title1 = _(" Panel split ");
title2 = _(" Highlight... ");
title3 = _(" Other options ");
output_lines_label = _("output lines");
-
+
while (i--)
{
s_split_direction [i] = _(s_split_direction [i]);
l1 = strlen (title1) + 1;
if (l1 > first_width)
first_width = l1;
-
+
l1 = strlen (title2) + 1;
if (l1 > first_width)
first_width = l1;
-
+
second_width = strlen (title3) + 1;
for (i = 0; i < 6; i++)
second_width = l1;
}
- /*
+ /*
* alex@bcs.zp.ua:
* To be completely correct, one need to check if layout_title
* does not exceed dialog length and total length of 3 buttons
l1 = 11 + strlen (ok_button) /* 14 - all brackets and inner space */
+ strlen (save_button) /* notice: it is 3 char less because */
+ strlen (cancel_button); /* of '&' char in button text */
-
+
i = (first_width + second_width - l1) / 4;
b1 = 5 + i;
b2 = b1 + strlen(ok_button) + i + 6;
i18n_layt_flag = 1;
}
- layout_dlg = create_dlg (0, 0, 15, first_width + second_width + 9,
+ layout_dlg = create_dlg (0, 0, 15, first_width + second_width + 9,
dialog_colors, layout_callback,
"[Layout]", "layout", DLG_CENTER | DLG_GRID);
-
+
x_set_dialog_title (layout_dlg, _("Layout"));
add_widgetl (layout_dlg,
- button_new (BY, b3, B_CANCEL, NORMAL_BUTTON, cancel_button, 0, 0, "c"),
+ button_new (BY, b3, B_CANCEL, NORMAL_BUTTON, cancel_button, 0, 0, "c"),
XV_WLAY_RIGHTOF);
add_widgetl (layout_dlg,
button_new (BY, b2, B_EXIT, NORMAL_BUTTON, save_button, 0, 0, "s"),
button_new (9, 12 + first_width, B_MINUS, NARROW_BUTTON, "&-",
bminus_cback, 0, NULL));
add_widget (layout_dlg,
- button_new (9, 7 + first_width, B_PLUS, NARROW_BUTTON, "&+",
+ button_new (9, 7 + first_width, B_PLUS, NARROW_BUTTON, "&+",
bplus_cback, 0, NULL));
}
-#endif
+#endif
#define XTRACT(i) *check_options[i].variable, check_options[i].text, check_options[i].tkname
XV_WLAY_NEXTCOLUMN);
add_widgetl (layout_dlg, label_new (2, 5, _("Panel split"), "ps"),
XV_WLAY_NEXTCOLUMN);
-#endif
+#endif
check_options [8].widget = check_new (10, 6, XTRACT(8));
add_widgetl (layout_dlg, check_options [8].widget, XV_WLAY_BELOWCLOSE);
check_options [7].widget = check_new (9, 6, XTRACT(7));
old_first_panel_size = -1;
old_horizontal_split = -1;
old_output_lines = -1;
-
+
_first_panel_size = first_panel_size;
_output_lines = output_lines;
#ifndef HAVE_X
setup_panels ();
layout_do_change = 0;
#ifndef HAVE_X
- /* re-init the menu, because perhaps there was a change in the way
+ /* re-init the menu, because perhaps there was a change in the way
how the panel are split (horizontal/vertical). */
done_menu();
init_menu();
for (i = 0; check_options [i].text; i++)
if (check_options [i].widget)
*check_options [i].variable = check_options [i].widget->state & C_BOOL;
-#ifndef HAVE_X
+#ifndef HAVE_X
horizontal_split = radio_widget->sel;
first_panel_size = _first_panel_size;
output_lines = _output_lines;
layout_do_change = 1;
-#endif
+#endif
}
if (result == B_EXIT){
save_layout ();
init_colors ();
}
#endif /* ! HAVE_SLANG */
-void done_screen ()
-{
- if (!(quit & SUBSHELL_EXIT))
- clr_scr ();
- reset_shell_mode ();
- mc_noraw_mode ();
- if (use_mouse_p)
- shut_mouse ();
- keypad (stdscr, FALSE);
-}
+void done_screen ()
+{
+ if (!(quit & SUBSHELL_EXIT))
+ clr_scr ();
+ reset_shell_mode ();
+ mc_noraw_mode ();
+ if (use_mouse_p)
+ shut_mouse ();
+ keypad (stdscr, FALSE);
+}
#else
void init_curses ()
{
if (panels [0].type == view_listing){
x_panel_set_size (0);
}
-
+
if (panels [1].type == view_listing){
x_panel_set_size (1);
}
#ifdef HAVE_XVIEW
panel_do_cols (0);
panel_do_cols (1);
-#endif
+#endif
}
#else
/* The column computing is defered until panel_do_cols */
if (horizontal_split){
- widget_set_size (panels [0].widget, start_y, 0,
+ widget_set_size (panels [0].widget, start_y, 0,
first_panel_size, 0);
-
+
widget_set_size (panels [1].widget, start_y+first_panel_size, 0,
height-first_panel_size, 0);
} else {
widget_set_size (panels [1].widget, start_y, first_x,
height, 0);
-
+
}
panel_do_cols (0);
panel_do_cols (1);
-
+
promptl = strlen (prompt);
widget_set_size (&the_menubar->widget, 0, 0, 1, COLS);
widget_set_size (&cmdline->input.widget, 0, 0, 0, 0);
winput_set_origin (&cmdline->input, 0, 0);
widget_set_size (&the_prompt->widget, LINES, COLS, 0, 0);
- }
+ }
widget_set_size (&the_bar->widget, LINES-1, 0, 1, COLS);
the_bar->visible = keybar_visible;
-
+
/* Output window */
if (console_flag && output_lines){
output_start_y = LINES -command_prompt-keybar_visible-
show_console_contents (output_start_y,
LINES-output_lines-keybar_visible-1,
LINES-keybar_visible-1);
- }
+ }
if (message_visible && (!xterm_hintbar || !xterm_flag))
widget_set_size (&the_hint->widget, height+start_y, 0, 1,COLS);
else
widget_set_size (&the_hint->widget, 0, 0, 0, 0);
-
+
load_hint ();
}
#endif
#if defined TIOCGWINSZ && !defined SCO_FLAVOR
extern Dlg_head *view_dlg;
extern Dlg_head *edit_dlg;
-
+
#ifndef NCURSES_VERSION
mc_noraw_mode ();
endwin ();
if (current_dlg == edit_dlg)
edit_adjust_size (edit_dlg);
#endif
-
+
#ifdef RESIZABLE_MENUBAR
menubar_arrange(the_menubar);
#endif
-
+
/* Now, force the redraw */
do_refresh ();
touchwin (stdscr);
ok_to_refresh--;
}
-void set_hintbar(char *str)
+void set_hintbar(char *str)
{
#ifndef HAVE_X
if (xterm_flag && xterm_hintbar) {
va_end(ap);
if (midnight_shutdown || !the_hint || !the_hint->widget.parent)
return;
-
+
if (message_visible || (xterm_flag && xterm_hintbar)) {
set_hintbar(str);
}
send a draw message only to the affected views. But for now
this is fine.
*/
-
+
move (0, COLS-1);
addch (' ');
-#endif
+#endif
}
char *get_nth_panel_name (int num)
{
static char buffer [20];
-
+
if (!num)
return "New Left Panel";
else if (num == 1)
return;
}
-
+
/* Get rid of it */
if (panels [num].widget){
Widget *w = panels [num].widget;
WPanel *panel = (WPanel *) panels [num].widget;
-
+
x = w->x;
y = w->y;
cols = w->cols;
}
new_widget = 0;
-
+
switch (type){
case view_listing:
new_widget = (Widget *) panel_new (get_nth_panel_name (num));
break;
-
+
case view_info:
new_widget = (Widget *) info_new ();
-
+
break;
case view_tree:
the_other_panel->dir.list[the_other_panel->selected].fname;
else
file_name = "";
-
+
view_init ((WView *) new_widget, 0, file_name, 0);
break;
}
panels [num].type = type;
panels [num].widget = (Widget *) new_widget;
-
+
/* We set the same size the old widget had */
widget_set_size ((Widget *) new_widget, y, x, lines, cols);
-
+
/* We wanna the new widget at the same position */
/* XView sets wcontainer to !0 <- Not XView, but we, when we create it */
/* Ok, the XView support code does it */
WPanel panel;
WPanel *panel1, *panel2;
int tmp_type;
-
+
#if 0
#ifdef HAVE_PORTABLE_TOKEN_PASTING
#define panelswap(e) panel.##e = panel1->##e; panel1->##e = panel2->##e; panel2->##e = panel.##e;
panelswap (selected);
panelswap (is_panelized);
panelswap (dir_stat);
-
+
panel1->searching = 0;
panel2->searching = 0;
if (cpanel == panel1)
dlg_select_widget (midnight_dlg, (void *) panels [0].widget);
} else {
WPanel *tmp_panel;
-
+
tmp_panel=right_panel;
right_panel=left_panel;
left_panel=tmp_panel;
-
+
if (panels [0].type == view_listing) {
if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) {
free (panel1->panel_name);
panel2->panel_name = strdup (get_nth_panel_name (0));
}
}
-
+
tmp.x = panels [0].widget->x;
tmp.y = panels [0].widget->y;
tmp.cols = panels [0].widget->cols;
panels [1].widget->y = tmp.y;
panels [1].widget->cols = tmp.cols;
panels [1].widget->lines = tmp.lines;
-
+
tmp_widget = panels [0].widget;
panels [0].widget = panels [1].widget;
panels [1].widget = tmp_widget;
/* Learn keys
Copyright (C) 1995 The Free Software Foundation
-
+
Written by: 1995 Jakub Jelinek
This program is free software; you can redistribute it and/or modify
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
{
attrset (COLOR_NORMAL);
dlg_erase (learn_dlg);
-
+
draw_box (learn_dlg, 1, 2, learn_dlg->lines - 2, learn_dlg->cols - 4);
-
+
attrset (COLOR_HOT_NORMAL);
dlg_move (learn_dlg, 1, (learn_dlg->cols - strlen (learn_title)) / 2);
addstr (learn_title);
"Then, press it again to see if OK appears\n"
"next to its button.\n\n"
"If you want to escape, press a single Escape key\n"
-"and wait as well."),
+"and wait as well."),
_(key_name_conv_tab [action - B_USER].longname));
mc_refresh ();
if (learnkeys [action - B_USER].sequence != NULL) {
* regular characters
*/
if (*seq && strcmp (seq, "\\e") && strcmp (seq, "\\e\\e")
- && strcmp (seq, "^m" )
+ && strcmp (seq, "^m" )
&& (seq [1] || (*seq < ' ' || *seq > '~'))){
-
+
learnchanged = 1;
learnkeys [action - B_USER].sequence = seq;
seq = convert_controls (seq);
- define_sequence (key_name_conv_tab [action - B_USER].code, seq,
+ define_sequence (key_name_conv_tab [action - B_USER].code, seq,
MCKEY_NOACTION);
} else {
message (0, _(" Cannot accept this key "),
_(" You have entered \"%s\""), seq);
}
-
+
free (seq);
}
-
+
dlg_run_done (d);
destroy_dlg (d);
dlg_select_widget (learn_dlg, learnkeys [action - B_USER].button);
static int learn_move (int right)
{
int i, totalcols;
-
+
totalcols = (learn_total - 1) / ROWS + 1;
for (i = 0; i < learn_total; i++)
if (learnkeys [i].button == learn_dlg->current->widget) {
if (right) {
if (i < learn_total - ROWS)
i += ROWS;
- else
+ else
i %= ROWS;
} else {
if (i / ROWS)
if (learnok >= learn_total) {
learn_dlg->ret_value = B_CANCEL;
if (learnchanged) {
- if (query_dialog (learn_title,
+ if (query_dialog (learn_title,
_("It seems that all your keys already\n"
"work fine. That's great."),
1, 2, _("&Save"), _("&Discard")) == 0)
case 'k':
dlg_one_up (learn_dlg);
return 1;
- }
+ }
/* Prevent from disappearing if a non-defined sequence is pressed
and contains s or c. Use ALT('s') or ALT('c'). */
if (!i18n_flag)
{
char* cp;
-
+
learn_but [0].text = _(learn_but [0].text);
learn_but [0].x = 78 / 2 + 4;
for (i = 0; i < BUTTONS; i++)
add_widget (learn_dlg, button_new (XTRACT (i)));
-
+
x = UX;
y = UY;
for (key = key_name_conv_tab, j = 0; key->name != NULL &&
}
}
- /* On the one hand no good idea to save the complete setup but
- * without 'Auto save setup' the new key-definitions will not be
- * saved unless the user does an 'Options/Save Setup'.
- * On the other hand a save-button that does not save anything to
+ /* On the one hand no good idea to save the complete setup but
+ * without 'Auto save setup' the new key-definitions will not be
+ * saved unless the user does an 'Options/Save Setup'.
+ * On the other hand a save-button that does not save anything to
* disk is much worse.
*/
if (profile_changed)
{
int save_old_esc_mode = old_esc_mode;
int save_alternate_plus_minus = alternate_plus_minus;
-
+
old_esc_mode = 0; /* old_esc_mode cannot work in learn keys dialog */
alternate_plus_minus = 1; /* don't translate KP_ADD, KP_SUBTRACT and
KP_MULTIPLY to '+', '-' and '*' in
init_learn ();
run_dlg (learn_dlg);
-
+
old_esc_mode = save_old_esc_mode;
alternate_plus_minus = save_alternate_plus_minus;
numeric_keypad_mode ();
#endif
-
+
switch (learn_dlg->ret_value) {
case B_ENTER:
learn_save ();
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
{
attrset (COLOR_NORMAL);
dlg_erase (listmode_dlg);
-
+
draw_box (listmode_dlg, 1, 2, 20, 70);
draw_box (listmode_dlg, UY, UX, 4, 63);
draw_box (listmode_dlg, UY + 4, UX, 11, 18);
static int listmode_callback (Dlg_head * h, int Par, int Msg)
{
switch (Msg) {
-#ifndef HAVE_X
+#ifndef HAVE_X
case DLG_DRAW:
listmode_refresh ();
break;
-#endif
+#endif
case DLG_POST_KEY:
/* fall */
listmode_dlg = create_dlg (0, 0, 22, 74, dialog_colors,
listmode_callback, listmode_section, "listmode",
DLG_CENTER);
- x_set_dialog_title (listmode_dlg, "Listing format edit");
+ x_set_dialog_title (listmode_dlg, "Listing format edit");
#define XTRACT(i) BY+listmode_but[i].y, BX+listmode_but[i].x, listmode_but[i].ret_cmd, listmode_but[i].flags, listmode_but[i].text, 0, 0, NULL
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
void mad_free (void *ptr, char *file, int line)
{
int i;
-
+
mad_check (file, line);
if (watch_free_pointer && ptr == watch_free_pointer){
printf ("watch free pointer found\n");
}
-
+
if (ptr == NULL){
fprintf (stderr, "MAD: Attempted to free a NULL pointer in file \"%s\" at line %d.\n",
file, line);
void mad_finalize (char *file, int line)
{
int i;
-
+
mad_check (file, line);
/* Following can be commented out if you don't want to see the
#define __MAD_H
#ifdef HAVE_MAD
-# define INLINE
+# define INLINE
#else
# ifndef INLINE
# define INLINE inline
/* Main program for the Midnight Commander
Copyright (C) 1994, 1995, 1996, 1997 The Free Software Foundation
-
+
Written by: 1994, 1995, 1996, 1997 Miguel de Icaza
1994, 1995 Janne Kukonlehto
1997 Norbert Warmuth
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include "popt.h"
-/* "$Id: main.c,v 1.1 2001/12/30 09:55:24 sedwards Exp $" */
+/* "$Id$" */
/* When the modes are active, left_panel, right_panel and tree_panel */
/* Point to a proper data structure. You should check with the functions */
/* If true message "The shell is already running a command" never */
int force_subshell_execution = 0;
-/* If true program softkeys (HP terminals only) on startup and after every
- command ran in the subshell to the description found in the termcap/terminfo
+/* If true program softkeys (HP terminals only) on startup and after every
+ command ran in the subshell to the description found in the termcap/terminfo
database */
int reset_hp_softkeys = 0;
try_to_select (panel, panel->lwd);
else
#ifdef USE_VFS
- if ((!strncmp (panel->lwd, "tar:", 4) &&
+ if ((!strncmp (panel->lwd, "tar:", 4) &&
!strncmp (panel->lwd + 4, panel->cwd, strlen (panel->cwd))) ||
- ((i = extfs_prefix_to_type (panel->lwd)) != -1 &&
- !strncmp (panel->lwd + (j = strlen (extfs_get_prefix (i)) + 1),
+ ((i = extfs_prefix_to_type (panel->lwd)) != -1 &&
+ !strncmp (panel->lwd + (j = strlen (extfs_get_prefix (i)) + 1),
panel->cwd, strlen (panel->cwd)))) {
p = strdup (panel->lwd + j + strlen (panel->cwd));
q = strchr (p, PATH_SEP);
{
int i, j;
dir_list *list = &panel->dir;
-
+
if (panel != cpanel)
mc_chdir (panel->cwd);
for (i = 0, j = 0; i < panel->count; i++){
- if (list->list [i].f.marked) {
+ if (list->list [i].f.marked) {
/* Unmark the file in advance. In case the following mc_lstat
* fails we are done, else we have to mark the file again
* (Note: do_file_mark depends on a valid "list->list [i].buf").
ftpfs_flushdir ();
bzero (&(panel->dir_stat), sizeof (panel->dir_stat));
}
-
+
/* If current_file == -1 (an invalid pointer) then preserve selection */
if (current_file == UP_KEEPSEL){
free_pointer = 1;
current_file = strdup (panel->dir.list [panel->selected].fname);
} else
free_pointer = 0;
-
+
if (panel->is_panelized)
reload_panelized (panel);
else
{
if (i >= panel->count)
return;
-
+
unselect_item (panel);
panel->selected = i;
-#ifndef HAVE_X
+#ifndef HAVE_X
while (panel->selected - panel->top_file >= ITEMS (panel)){
/* Scroll window half screen */
panel->top_file += ITEMS (panel)/2;
paint_dir (panel);
select_item (panel);
- }
+ }
while (panel->selected < panel->top_file){
/* Scroll window half screen */
panel->top_file -= ITEMS (panel)/2;
if (panel->top_file < 0) panel->top_file = 0;
paint_dir (panel);
- }
+ }
#endif
select_item (panel);
}
int i;
FILE *file;
struct stat s;
-
+
if ((file = fopen (control_file, "r")) == NULL){
return;
}
}
data [s.st_size] = 0;
fclose (file);
-
+
/* The Control file has now been loaded to memory -> start parsing. */
current = strtok (data, " \t\n");
while (current && *current){
#endif
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
-
+
parse_control_file ();
#ifndef __os2__
unlink (control_file);
}
panel->dir_history = panel->dir_history->next;
panel->dir_history->text = strdup (s);
-
+
panel_update_marks (panel);
}
{
char *directory, *olddir;
char temp [MC_MAXPATHLEN];
-#ifdef USE_VFS
+#ifdef USE_VFS
vfs *oldvfs;
vfsid oldvfsid;
struct vfs_stamping *parent;
-#endif
+#endif
olddir = strdup (panel->cwd);
/* Convert *new_path to a suitable pathname, handle ~user */
-
+
if (cd_type == cd_parse_command){
while (*new_dir == ' ')
new_dir++;
-
+
if (!strcmp (new_dir, "-")){
strcpy (temp, panel->lwd);
new_dir = temp;
/* Success: save previous directory, shutdown status of previous dir */
strcpy (panel->lwd, olddir);
free_completions (input_w (cmdline));
-
+
mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2);
#ifdef USE_VFS
do_panel_cd (WPanel *panel, char *new_dir, enum cd_enum cd_type)
{
int r;
-
+
r = _do_panel_cd (panel, new_dir, cd_type);
if (r)
directory_history_add (cpanel, cpanel->cwd);
{
if (!read_subshell_prompt (QUIETLY))
return 0;
-
+
if (command_prompt){
int prompt_len;
label_set_text (the_prompt, prompt);
winput_set_origin ((WInput *)cmdline, prompt_len, COLS-prompt_len);
- /* since the prompt has changed, and we are called from one of the
+ /* since the prompt has changed, and we are called from one of the
* get_event channels, the prompt updating does not take place
* automatically: force a cursor update and a screen refresh
*/
set_sort_to (WPanel *p, sortfn *sort_order)
{
p->sort_type = sort_order;
-
+
/* The directory is already sorted, we have to load the unsorted stuff */
if (sort_order == (sortfn *) unsorted){
char *current_file;
-
+
current_file = strdup (cpanel->dir.list [cpanel->selected].fname);
panel_reload (cpanel);
try_to_select (cpanel, current_file);
/* The directory is already sorted, we have to load the unsorted stuff */
if (sort_order == (sortfn *) unsorted){
char *current_file;
-
+
current_file = strdup (cpanel->dir.list [cpanel->selected].fname);
panel_reload (cpanel);
try_to_select (cpanel, current_file);
/* NOTICE: hotkeys specified here are overriden in menubar_paint_idx (alex) */
static menu_entry PanelMenu [] = {
{ ' ', N_("&Listing mode..."), 'L', listing_cmd },
- { ' ', N_("&Quick view C-x q"), 'Q', quick_view_cmd },
+ { ' ', N_("&Quick view C-x q"), 'Q', quick_view_cmd },
{ ' ', N_("&Info C-x i"), 'I', info_cmd },
{ ' ', N_("&Tree"), 'T', tree_cmd },
- { ' ', "", ' ', 0 },
+ { ' ', "", ' ', 0 },
{ ' ', N_("&Sort order..."), 'S', sort_cmd },
- { ' ', "", ' ', 0 },
+ { ' ', "", ' ', 0 },
{ ' ', N_("&Filter..."), 'F', filter_cmd },
-#ifdef USE_NETCODE
- { ' ', "", ' ', 0 },
+#ifdef USE_NETCODE
+ { ' ', "", ' ', 0 },
{ ' ', N_("&Network link..."), 'N', netlink_cmd },
{ ' ', N_("FT&P link..."), 'P', ftplink_cmd },
#endif
static menu_entry RightMenu [] = {
{ ' ', N_("&Listing mode..."), 'L', listing_cmd },
- { ' ', N_("&Quick view C-x q"), 'Q', quick_view_cmd },
+ { ' ', N_("&Quick view C-x q"), 'Q', quick_view_cmd },
{ ' ', N_("&Info C-x i"), 'I', info_cmd },
{ ' ', N_("&Tree"), 'T', tree_cmd },
- { ' ', "", ' ', 0 },
+ { ' ', "", ' ', 0 },
{ ' ', N_("&Sort order..."), 'S', sort_cmd },
- { ' ', "", ' ', 0 },
+ { ' ', "", ' ', 0 },
{ ' ', N_("&Filter..."), 'F', filter_cmd },
-#ifdef USE_NETCODE
- { ' ', "", ' ', 0 },
+#ifdef USE_NETCODE
+ { ' ', "", ' ', 0 },
{ ' ', N_("&Network link..."), 'N', netlink_cmd },
{ ' ', N_("FT&P link..."), 'P', ftplink_cmd },
#endif
{ ' ', N_("&Edit F4"), 'E', edit_cmd },
{ ' ', N_("&Copy F5"), 'C', copy_cmd },
{ ' ', N_("c&Hmod C-x c"), 'H', chmod_cmd },
-#ifndef OS2_NT
+#ifndef OS2_NT
{ ' ', N_("&Link C-x l"), 'L', link_cmd },
{ ' ', N_("&SymLink C-x s"), 'S', symlink_cmd },
{ ' ', N_("edit s&Ymlink C-x C-s"), 'Y', edit_symlink_cmd },
{ ' ', N_("ch&Own C-x o"), 'O', chown_cmd },
{ ' ', N_("&Advanced chown "), 'A', chown_advanced_cmd },
-#endif
+#endif
{ ' ', N_("&Rename/Move F6"), 'R', ren_cmd },
{ ' ', N_("&Mkdir F7"), 'M', mkdir_cmd },
{ ' ', N_("&Delete F8"), 'D', delete_cmd },
*/
{ ' ', N_("&Directory tree"), 'D', tree_box },
{ ' ', N_("&Find file M-?"), 'F', find_cmd },
-#ifndef HAVE_XVIEW
+#ifndef HAVE_XVIEW
{ ' ', N_("s&Wap panels C-u"), 'W', swap_cmd },
{ ' ', N_("switch &Panels on/off C-o"), 'P', view_other_cmd },
-#endif
+#endif
{ ' ', N_("&Compare directories C-x d"), 'C', compare_dirs_cmd },
{ ' ', N_("e&Xternal panelize C-x !"), 'X', external_panelize },
#ifdef HAVE_DUSUM
#if !defined(HAVE_X) && !defined(OS2_NT)
{ ' ', N_("learn &Keys..."), 'K', learn_keys },
#endif
-#ifdef USE_VFS
+#ifdef USE_VFS
{ ' ', N_("&Virtual FS..."), 'V', configure_vfs },
#endif
- { ' ', "", ' ', 0 },
+ { ' ', "", ' ', 0 },
{ ' ', N_("&Save setup"), 'S', save_setup_cmd }
};
{
int i;
-#ifdef HAVE_X
+#ifdef HAVE_X
MenuBar [0] = create_menu (_(" Left "), PanelMenu, menu_entries (PanelMenu));
#else
- MenuBar [0] = create_menu ( horizontal_split ? _(" Above ") : _(" Left "),
+ MenuBar [0] = create_menu ( horizontal_split ? _(" Above ") : _(" Left "),
PanelMenu, menu_entries (PanelMenu));
#endif
MenuBar [1] = create_menu (_(" File "), FileMenu, menu_entries (FileMenu));
#ifdef HAVE_X
MenuBar [4] = create_menu (_(" Right "), RightMenu, menu_entries (PanelMenu));
#else
- MenuBar [4] = create_menu (horizontal_split ? _(" Below ") : _(" Right "),
+ MenuBar [4] = create_menu (horizontal_split ? _(" Below ") : _(" Right "),
RightMenu, menu_entries (PanelMenu));
for (i = 0; i < 5; i++)
MenuBarEmpty [i] = create_menu (MenuBar [i]->name, 0, 0);
}
}
#endif
-
+
static void
menu_last_selected_cmd (void)
{
{
if (the_menubar->active)
return;
-
+
if (get_current_index () == 0)
the_menubar->selected = 0;
else
char original_dir [1024];
original_dir [0] = 0;
-
+
if (boot_current_is_left){
current_index = 0;
other_index = 1;
the_hint->auto_adjust_cols = 0;
the_hint->widget.cols = COLS;
#endif
-
+
#ifndef HAVE_XVIEW
the_menubar = menubar_new (0, 0, COLS, MenuBar, 5);
#else
char buffer [MC_MAXPATHLEN];
char *p = concat_dir_and_file (panel->cwd, selection (panel)->fname);
int i;
-
+
i = mc_readlink (p, buffer, MC_MAXPATHLEN);
free (p);
if (i > 0) {
tmp = name_quote (selection (cpanel)->fname, 1);
stuff (input_w (cmdline), tmp, 1);
free (tmp);
-}
+}
static void copy_tagged (WPanel *panel)
{
}
input_enable_update (input_w (cmdline));
}
-
+
static void copy_current_tagged (void)
{
copy_tagged (cpanel);
#ifndef OS2_NT
{
struct sigaction sigtstp_action;
-
+
/* Make sure that the SIGTSTP below will suspend us directly,
without calling ncurses' SIGTSTP handler; we *don't* want
ncurses to redraw the screen immediately after the SIGCONT */
sigaction (SIGTSTP, &startup_handler, &sigtstp_action);
-
+
kill (getpid (), SIGTSTP);
/* Restore previous SIGTSTP action */
sigaction (SIGTSTP, &sigtstp_action, NULL);
}
#endif
-
+
if (console_flag && !use_subshell)
handle_console (CONSOLE_SAVE);
-
+
edition_post_exec ();
}
{ ALT('\r'), copy_prog_name },
{ ALT('a'), copy_current_pathname },
{ ALT('A'), copy_other_pathname },
-
+
{ ALT('c'), quick_cd_cmd },
/* To access the directory hotlist */
#endif
/* The filtered view command */
{ ALT('!'), filtered_view_cmd_cpanel },
-
+
/* Find file */
{ ALT('?'), find_cmd },
-
+
/* Panel refresh */
{ XCTRL('r'), reread_cmd },
{ ALT('t'), toggle_listing_cmd },
-
+
#ifndef HAVE_X
/* Swap panels */
{ XCTRL('u'), swap_cmd },
/* View output */
{ XCTRL('o'), view_other_cmd },
#endif
-
+
/* Control-X keybindings */
{ XCTRL('x'), ctl_x_cmd },
{
#ifndef OS2_NT
struct sigaction act, oact;
-
+
# if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
# ifdef SIGWINCH
act.sa_handler = flag_winch;
setup_post ()
{
setup_sigwinch ();
-
+
init_uid_gid_cache ();
#ifndef HAVE_X
return;
#endif
setup_panels ();
-
+
#ifdef HAVE_SUBSHELL_SUPPORT
if (use_subshell)
add_select_channel (subshell_pty, load_prompt, 0);
#endif
-
+
setup_post ();
}
static void done_mc ()
{
done_menu ();
-
+
/* Setup shutdown
*
* We sync the profiles since the hotlist may have changed, while
{
if (cpanel->dirty)
panel_update_contents (cpanel);
-
+
if ((get_other_type () == view_listing) && opanel->dirty)
panel_update_contents (opanel);
}
int midnight_callback (struct Dlg_head *h, int id, int msg)
{
int i;
-
+
switch (msg){
#ifndef HAVE_XVIEW
case DLG_PRE_EVENT:
make_panels_dirty ();
return MSG_HANDLED;
-
+
case DLG_KEY:
if (ctl_x_map_enabled){
ctl_x_map_enabled = 0;
return MSG_HANDLED;
}
}
-
+
if (id == KEY_F(10) && !the_menubar->active){
quit_cmd ();
return MSG_HANDLED;
return MSG_HANDLED;
}
} else if (command_prompt && !strlen (input_w (cmdline)->buffer)) {
- /* Special treatement '+', '-', '\', '*' only when this is
+ /* Special treatement '+', '-', '\', '*' only when this is
* first char on input line
*/
-
+
if (id == '+') {
select_cmd ();
return MSG_HANDLED;
}
-
+
if (check_key_backslash (id) || id == '-') {
unselect_cmd ();
return MSG_HANDLED;
}
-
+
if (id == '*') {
reverse_selection_cmd ();
return MSG_HANDLED;
}
- }
- }
+ }
+ }
break;
case DLG_HOTKEY_HANDLED:
if (get_current_type () == view_listing)
cpanel->searching = 0;
break;
-
+
case DLG_UNHANDLED_KEY:
if (command_prompt){
int v;
-
+
v = send_message_to (h, (Widget *) cmdline, WIDGET_KEY, id);
if (v)
return v;
}
}
return MSG_NOT_HANDLED;
-
+
#endif
#ifndef HAVE_X
/* We handle the special case of the output lines */
LINES-keybar_visible-1);
break;
#endif
-
+
}
return default_dlg_callback (h, id, msg);
}
if (!the_hint->widget.parent)
return;
-
+
if (!message_visible && (!xterm_flag || !xterm_hintbar)){
label_set_text (the_hint, 0);
return;
add_widget (midnight_dlg, get_panel_widget (first));
add_widget (midnight_dlg, get_panel_widget (second));
add_widget (midnight_dlg, the_menubar);
-
+
init_labels (get_panel_widget (0));
init_labels (get_panel_widget (1));
if (!(view_one_file || edit_one_file))
return 0;
-
+
/* Invoke the internal view/edit routine with:
* the default processing and forcing the internal viewer/editor
*/
if (mc_maybe_editor_or_viewer ())
return;
#endif
-
+
setup_mc ();
#ifndef HAVE_GNOME
setup_panels_and_run_mc ();
#endif
-
+
/* Program end */
midnight_shutdown = 1;
last_wd_string = strdup (cpanel->cwd);
}
done_mc ();
-
+
#ifndef HAVE_GNOME
destroy_dlg (midnight_dlg);
current_panel = 0;
fprintf (stderr, "The Midnight Commander %s\n", VERSION);
if (!verbose)
return;
-
+
#ifndef HAVE_X
fprintf (stderr,
_("with mouse support on xterm%s.\n"),
OS_Setup ()
{
SetConsoleTitle ("GNU Midnight Commander");
-
+
shell = getenv ("COMSPEC");
if (!shell || !*shell)
shell = get_default_shell ();
-
+
/* Default opening mode for files is binary, not text (CR/LF translation) */
#ifndef __EMX__
_fmode = O_BINARY;
{
char *termvalue;
char *mc_libdir;
-
+
termvalue = getenv ("TERM");
if (!termvalue){
fprintf (stderr, _("The TERM environment variable is unset!\n"));
sprintf (control_file, CONTROL_FILE, getpid ());
my_putenv ("MC_CONTROL_FILE", control_file);
-
+
/* This is the directory, where MC was installed, on Unix this is LIBDIR */
/* and can be overriden by the MCHOME environment variable */
if ((mc_libdir = getenv ("MCHOME")) != NULL) {
if (!console_flag)
return;
-
+
/* COMMENT: if it were true that after the call to handle_console(..INIT)
the value of console_flag never changed, we could simply not install
this handler at all if (!console_flag && !use_subshell). */
#ifndef SCO_FLAVOR
pid = waitpid (cons_saver_pid, &status, WUNTRACED | WNOHANG);
-
+
if (pid == cons_saver_pid){
/* {{{ Someone has stopped or killed cons.saver; restart it */
sa.sa_hanlder = mc_fatal_signal;
sa.sa_mask = 0;
sa.sa_flags = 0;
-
+
sigaction (SIGSEGV, &sa, NULL);
sigaction (SIGBUS, &sa, NULL);
sigaction (SIGFPE, &sa, NULL);
}
#else
-#define init_sigfatals()
+#define init_sigfatals()
#endif
void
#endif
sigaction (SIGCHLD, &sigchld_action, NULL);
-}
+}
#endif /* _OS_NT, __os2__, UNIX */
version (0);
fprintf (stderr,
"Usage is:\n\n"
- "mc [flags] [this_dir] [other_panel_dir]\n\n"
+ "mc [flags] [this_dir] [other_panel_dir]\n\n"
#if defined(HAVE_SLANG) && !defined(OS2_NT)
"-a, --stickchars Force use of +, -, | for line drawing.\n"
#endif
#if defined(HAVE_SLANG) && defined(OS2_NT)
"-S, --createcmdile Create command file to set default directory upon exit.\n"
#endif
-
+
#ifdef HAVE_SUBSHELL_SUPPORT
"-u, --nosubshell Disable the concurrent subshell mode.\n"
"-U, --subshell Force the concurrent subshell mode.\n"
version (1);
finish_program = 1;
break;
-
+
case 'c':
disable_colors = 0;
#ifdef HAVE_SLANG
force_colors = 1;
#endif
break;
-
+
case 'f':
fprintf (stderr, _("Library directory for the Midnight Commander: %s\n"), mc_home);
finish_program = 1;
break;
-
+
case 'm':
fprintf (stderr, _("Option -m is obsolete. Please look at Display Bits... in the Option's menu\n"));
finish_program = 1;
break;
-
+
#ifdef USE_NETCODE
case 'l':
ftpfs_set_debug (option_arg);
break;
#endif
-
+
#ifdef OS2_NT
case 'S':
print_last_wd = 2;
batch_file_name = option_arg;
break;
#endif
-
+
case 'd':
use_mouse_p = NO_MOUSE;
break;
-
+
case 'X':
#ifdef HAVE_SUBSHELL_SUPPORT
debug_subshell = 1;
#endif
break;
-
+
case 'U':
#ifdef HAVE_SUBSHELL_SUPPORT
use_subshell = 1;
#endif
break;
-
+
case 'u':
#ifdef HAVE_SUBSHELL_SUPPORT
use_subshell = 0;
force_subshell_execution = 1;
#endif
break;
-
+
case 'H':
print_color_usage ();
finish_program = 1;
break;
-
+
case 'h':
#ifndef PORT_WANTS_ARGP
print_mc_usage ();
#endif
#if defined(HAVE_SLANG) && defined(OS2_NT)
{ "createcmdfile", 'S', "CMDFILE", , 0, N_("Create command file to set default directory upon exit."), 1 },
-#endif
+#endif
{ "color", 'c', NULL, 0, N_("Force color mode."), 0 },
{ "colors", 'C', "COLORS", 0, N_("Specify colors (use --help-colors to get a list)."), 1 },
#ifdef HAVE_SUBSHELL_SUPPORT
case 'b':
disable_colors = 1;
return 0;
-
+
case 'P':
print_last_wd = 1;
return 0;
-
+
case 'k':
reset_hp_softkeys = 1;
return 0;
case 'x':
force_xterm = 1;
return 0;
-
+
#if defined(HAVE_SLANG) && !defined(OS2_NT)
case 't':
SLtt_Try_Termcap = 1;
case NOWIN_KEY:
nowindows = 1;
-
+
case ARGP_KEY_ARG:
break;
case ARGP_KEY_INIT:
case ARGP_KEY_FINI:
return 0;
-
+
default:
process_args (key, arg);
}
edit_one_file = strdup (arg);
else if (view_one_file)
view_one_file = strdup (arg);
- else
+ else
directory_list = g_list_append (directory_list, arg);
}
return 0;
argp_options, parse_an_arg, N_("[this dir] [other dir]"), NULL, NULL, NULL, NULL
};
-#else
+#else
static struct poptOption argumentTable[] = {
#ifdef WITH_BACKGROUND
if (c < -1){
print_mc_usage ();
- fprintf(stderr, "%s: %s\n",
- poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
+ fprintf(stderr, "%s: %s\n",
+ poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(c));
finish_program = 1;
}
char *full_o_name = concat_dir_and_file (home_dir, o_name);
char *full_n_name = copy_strings (home_dir, MC_BASE, n_name, NULL);
int move;
-
+
move = 0 == rename (full_o_name, full_n_name);
free (full_o_name);
free (full_n_name);
{
struct stat s;
int move;
-
+
if (stat (mc_dir, &s) == 0)
return;
if (errno != ENOENT)
return;
-
+
if (mkdir (mc_dir, 0777) == -1)
return;
compatibility_move_mc_files (void)
{
char *mc_dir = concat_dir_and_file (home_dir, ".mc");
-
+
do_compatibility_move (mc_dir);
free (mc_dir);
}
/* Initialize list of all user group for timur_clr_mode */
init_groups ();
-
+
OS_Setup ();
vfs_init ();
if (base){
if (strcmp (base, "mcedit") == 0)
edit_one_file = "";
-
+
if (strcmp (base, "mcview") == 0)
view_one_file = "";
}
gnome_init ("gmc", &mc_argp_parser, argc, argv, 0, NULL);
probably_finish_program ();
#endif
-
+
if (xtoolkit_init (&argc, argv) == -1)
exit (1);
#endif /* HAVE_X */
-
+
#ifdef HAVE_SLANG
SLtt_Ignore_Beep = 1;
#endif
#ifndef PORT_WANTS_ARGP
handle_args (argc, argv);
#endif
-
+
/* Used to report the last working directory at program end */
if (print_last_wd){
-#ifndef OS2_NT
+#ifndef OS2_NT
stdout_fd = dup (1);
close (1);
if (open (ttyname (0), O_RDWR) < 0)
if (open ("/dev/tty", O_RDWR) < 0) {
/* Try if stderr is not redirected as the last chance */
char *p = strdup (ttyname (0));
-
+
if (!strcmp (p, ttyname (2)))
dup2 (2, 1);
else {
/* Must be done before installing the SIGCHLD handler [[FIXME]] */
handle_console (CONSOLE_INIT);
# endif
-
+
# ifdef HAVE_SUBSHELL_SUPPORT
subshell_get_console_attributes ();
# endif
-
+
/* Install the SIGCHLD handler; must be done before init_subshell() */
init_sigchld ();
init_sigfatals ();
-
+
/* This variable is used by the subshell */
home_dir = getenv ("HOME");
if (!home_dir) {
}
compatibility_move_mc_files ();
-
+
# ifdef HAVE_X
/* We need this, since ncurses endwin () doesn't restore the signals */
save_stop_handler ();
/* FIXME: Should be removed and LINES and COLS computed on subshell */
slang_init ();
/* NOTE: This call has to be after slang_init. It's the small part from
- the previous init_key which had to be moved after the call of slang_init */
+ the previous init_key which had to be moved after the call of slang_init */
init_key_input_fd ();
load_setup ();
#ifdef HAVE_GNOME
use_subshell = 0;
#endif
-
+
# ifdef HAVE_SUBSHELL_SUPPORT
/* Done here to ensure that the subshell doesn't */
/* inherit the file descriptors opened below, etc */
if (use_subshell)
- init_subshell ();
+ init_subshell ();
# endif
# ifndef HAVE_X
/* Also done after init_subshell, to save any shell init file messages */
if (console_flag)
handle_console (CONSOLE_SAVE);
-
+
if (alternate_plus_minus)
application_keypad_mode ();
# endif
" are now stored in the ~/.mc directory, the \n"
" files have been moved now\n"));
}
-
+
# ifdef HAVE_SUBSHELL_SUPPORT
if (use_subshell){
prompt = strip_ctrl_codes (subshell_prompt);
/* Program main loop */
do_nc ();
-
+
/* Virtual File System shutdown */
vfs_shut ();
#ifndef OS2_NT
signal (SIGCHLD, SIG_DFL); /* Disable the SIGCHLD handler */
#endif
-
+
# ifndef HAVE_X
if (console_flag)
handle_console (CONSOLE_DONE);
/* Man page to help file converter
Copyright (C) 1994, 1995 Janne Kukonlehto
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
for (i = 0; i < strlen (buffer); i ++)
{
c = buffer [i];
- if (c == CHAR_LINK_POINTER)
+ if (c == CHAR_LINK_POINTER)
link_flag = 1; /* Link target name starts */
else if (c == CHAR_LINK_END)
link_flag = 0; /* Link target name ends */
buffer = strtok (buffer, " \t\n");
/* Repeat for each word */
while (buffer){
- /* Skip empty strings */
+ /* Skip empty strings */
if (strlen (buffer) > 0){
len = string_len (buffer);
/* Change the line if about to break the right margin */
printf_string ("<%c>%s</%c>", type, buffer, type);
newline ();
} else /* HLP format */
- printf_string ("%c%s%c",
- (type == 'I') ? CHAR_ITALIC_ON : CHAR_BOLD_ON,
+ printf_string ("%c%s%c",
+ (type == 'I') ? CHAR_ITALIC_ON : CHAR_BOLD_ON,
buffer, CHAR_BOLD_OFF);
}
}
#define index strchr
# endif
-# ifndef rindex
+# ifndef rindex
# define rindex strrchr
# endif
/* Pulldown menu code.
Copyright (C) 1994 Miguel de Icaza.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include "win.h"
#include "key.h" /* For mi_getch() */
-/* "$Id: menu.c,v 1.1 2001/12/30 09:55:23 sedwards Exp $" */
+/* "$Id$" */
extern int is_right;
int menubar_visible = 1; /* This is the new default */
{
const int items = menubar->items;
int i;
-
+
/* First draw the complete menubar */
attrset (SELECTED_COLOR);
widget_move (&menubar->widget, 0, 0);
if (menubar->dropped)
menubar_draw_drop (menubar);
- else
- widget_move (&menubar->widget, 0,
+ else
+ widget_move (&menubar->widget, 0,
menubar-> menu[menubar->selected]->start_x);
}
static void menubar_execute (WMenu *menubar, int entry)
{
const Menu menu = menubar->menu [menubar->selected];
-
+
is_right = menubar->selected != 0;
(*menu->entries [entry].call_back)(0);
menubar_finish (menubar);
menubar->subsel += step;
if (menubar->subsel < 0)
menubar->subsel = menu->count - 1;
-
+
menubar->subsel %= menu->count;
} while (!menu->entries [menubar->subsel].call_back);
menubar_paint_idx (menubar, menubar->subsel, MENU_SELECTED_COLOR);
/* Lowercase */
if (key < 256 && isalpha (key)) /* Linux libc.so.5.x.x bug fix */
key = tolower (key);
-
+
if (is_abort_char (key)){
menubar_finish (menubar);
return 1;
/* Hack, we should check for the upper case letter */
if (tolower (menu->name [1]) == key){
menubar_drop (menubar, i);
- return 1;
+ return 1;
}
}
if (key == KEY_ENTER || key == XCTRL ('n') || key == KEY_DOWN
const int selected = menubar->selected;
const Menu menu = menubar->menu [selected];
const int items = menu->count;
-
+
for (i = 0; i < items; i++){
if (!menu->entries [i].call_back)
continue;
-
+
if (key != menu->entries [i].hot_key)
continue;
-
+
menubar_execute (menubar, i);
return 1;
}
menubar_execute (menubar, menubar->subsel);
return 1;
}
-
-
+
+
if (key == KEY_DOWN || key == XCTRL ('n'))
menubar_move (menubar, 1);
-
+
if (key == KEY_UP || key == XCTRL ('p'))
menubar_move (menubar, -1);
}
case WIDGET_CURSOR:
/* Put the cursor in a suitable place */
return 0;
-
+
case WIDGET_UNFOCUS:
if (menubar->active)
return 0;
if (!(event->type & (GPM_UP|GPM_DOWN|GPM_DRAG)))
return MOU_NORMAL;
-
+
if (!menubar->dropped){
menubar->previous_selection = dlg_item_number(menubar->widget.parent);
menubar->active = 1;
if (event->y == 1 || !was_active){
if (event->type & GPM_UP)
return MOU_NORMAL;
-
+
new_selection = 0;
- while (new_selection < menubar->items
+ while (new_selection < menubar->items
&& event->x > menubar->menu[new_selection]->start_x
)
new_selection++;
if (new_selection) /* Don't set the invalid value -1 */
--new_selection;
-
+
if (!was_active){
menubar->selected = new_selection;
dlg_select_widget (menubar->widget.parent, menubar);
menubar_draw (menubar);
return MOU_NORMAL;
}
-
+
menubar_remove (menubar);
menubar->selected = new_selection;
if (!menubar->dropped)
return MOU_NORMAL;
-
+
/* Ignore the events on anything below the third line */
if (event->y <= 2)
return MOU_NORMAL;
-
+
/* Else, the mouse operation is on the menus or it is not */
left_x = menubar->menu[menubar->selected]->start_x;
right_x = left_x + menubar->max_entry_len + 4;
if (!menubar->menu [menubar->selected]->entries [pos].call_back)
return MOU_NORMAL;
-
+
menubar_paint_idx (menubar, menubar->subsel, MENU_ENTRY_COLOR);
menubar->subsel = pos;
menubar_paint_idx (menubar, menubar->subsel, MENU_SELECTED_COLOR);
} else
if (event->type & GPM_DOWN)
menubar_finish (menubar);
-
+
return MOU_NORMAL;
}
WMenu *menubar_new (int y, int x, int cols, Menu menu [], int items)
{
WMenu *menubar = (WMenu *) xmalloc (sizeof (WMenu), "menubar_new");
-
+
memset(menubar, 0, sizeof(*menubar)); /* FIXME: subsel used w/o being set */
init_widget (&menubar->widget, y, x, 1, cols,
(callback_fn) menubar_callback,
* include this header, you have to move it to the group of HAVE_X dependant
* modules in {xv|tk}/Makefile.in !!!
*/
-
+
#include "dlg.h"
#include "widget.h"
enum states state = header;
int prev = 0;
int c;
-
+
while ((c = getchar ()) != EOF){
if (c != '\n'){
- switch (state){
+ switch (state){
case header:
putchar ('_');
putchar ('\b');
break;
-
+
case definition:
putchar (c);
putchar ('\b');
if (state == definition && c == '\n')
state = header;
-
+
prev = c;
}
}
int state = newline;
int space_seen;
int c;
-
+
while ((c = getchar ()) != EOF){
switch (state){
case plain:
state = newline;
putchar (c);
break;
-
+
case newline:
if (c == 'F')
state = seen_f;
putchar (c);
}
break;
-
+
case seen_f:
if (c == 'r')
state = seen_r;
else {
state = plain;
printf ("Fr%c", c);
- }
+ }
break;
case seen_o:
printf ("From%c", c);
}
break;
-
+
case header_new:
space_seen = 0;
if (c == ' ' || c == '\t') {
putchar (c);
break;
}
-
+
case header:
if (c == '\n'){
putchar (c);
/* Mouse managing
Copyright (C) 1994 Miguel de Icaza.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* Events received by clients of this library have their coordinates 0 */
/* based */
-/* "$Id: mouse.c,v 1.1 2001/12/30 09:55:23 sedwards Exp $" */
+/* "$Id$" */
#include <config.h>
#include <sys/types.h>
int x = last_x = gpm_event->x;
int y = last_y = gpm_event->y;
int redo = 0;
-
+
/* DEBUGM ((log, "Mouse [%d, %d]\n", x, y)); */
/* Call any registered event handlers */
fflush (stdout);
/* turn on */
- xmouse_flag = 1;
+ xmouse_flag = 1;
define_sequence (MCKEY_MOUSE, ESC_STR "[M", MCKEY_NOACTION);
}
break;
default:
/* nothing */
break;
- } /* switch (use_mouse_p) */
+ } /* switch (use_mouse_p) */
}
void shut_mouse (void)
#define GPM_B_LEFT 4
#define GPM_B_MIDDLE 2
#define GPM_B_RIGHT 1
-
+
/* Xterm mouse support supports only GPM_DOWN and GPM_UP */
/* If you use others make sure your code also works without them */
enum Gpm_Etype {
GPM_SINGLE=16, /* at most one in three is set */
GPM_DOUBLE=32,
GPM_TRIPLE=64,
-
+
GPM_MFLAG=128, /* motion during click? */
GPM_HARD=256 /* if set in the defaultMask, force an already
used event to pass over to another handler */
#ifdef DEBUGMOUSE
#define DEBUGM(data) fprintf data
#else
-#define DEBUGM(data)
+#define DEBUGM(data)
#endif
#ifdef HAVE_LIBGPM
/* This is fast, but unusefull if ! pc_system - doesn't use
Alt_Char_Pairs [] :( */
#else
- /* This is slow, but works well :| */
-# define one_vline() SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), slow_terminal ? ' ' : ACS_VLINE)
-# define one_hline() SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), slow_terminal ? ' ' : ACS_HLINE)
-#endif
+ /* This is slow, but works well :| */
+# define one_vline() SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), slow_terminal ? ' ' : ACS_VLINE)
+# define one_hline() SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), slow_terminal ? ' ' : ACS_HLINE)
+#endif
void enable_interrupt_key ();
void disable_interrupt_key ();
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
{
switch (Msg) {
case DLG_DRAW:
-#ifndef HAVE_X
+#ifndef HAVE_X
attrset (COLOR_NORMAL);
dlg_erase (h);
draw_box (h, 1, 2, h->lines - 2, h->cols - 4);
l1 = 11 + strlen (ok_button)
+ strlen (save_button)
+ strlen (cancel_button);
-
+
i = (first_width + second_width - l1) / 4;
b1 = 5 + i;
b2 = b1 + strlen(ok_button) + i + 6;
add_widgetl (conf_dlg,
button_new (BY, b2, B_EXIT, NORMAL_BUTTON, save_button, 0, 0, "button-save"),
XV_WLAY_RIGHTOF);
-
+
add_widgetl (conf_dlg,
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON, ok_button, 0, 0, "button-ok"),
XV_WLAY_CENTERROW);
void configure_box (void)
{
int result, i;
-
+
init_configure ();
run_dlg (conf_dlg);
#ifndef __OPTION_H
#define __OPTION_H
void configure_box (void);
-#endif
+#endif
typedef struct {
Widget widget;
dir_list dir; /* Directory contents */
-
+
int list_type; /* listing type (was view_type) */
int active; /* If panel is currently selected */
char cwd [MC_MAXPATHLEN];/* Current Working Directory */
format_e *status_format; /* Mini status format */
int format_modified; /* If the format was changed this is set */
-
+
char *panel_name; /* The panel name */
struct stat dir_stat; /* Stat of current dir: used by execute () */
int total_width;
int ascent;
int descent;
-
+
int searching;
char search_buffer [256];
-
+
int has_dir_sizes; /* Set if directories have sizes = to du -s */
#ifdef HAVE_GNOME
/* These are standard GtkWidgets */
-
+
void *xwindow; /* The toplevel window */
-
+
void *table;
void *list;
void *icons;
/* External panelize
Copyright (C) 1995 The Free Software Foundation
-
+
Written by: 1995 Janne Kukonlehto
1995 Jakub Jelinek
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
{
attrset (COLOR_NORMAL);
dlg_erase (panelize_dlg);
-
+
draw_box (panelize_dlg, 1, 2, panelize_dlg->lines-2, panelize_dlg->cols-4);
draw_box (panelize_dlg, UY, UX, panelize_dlg->lines-10, panelize_dlg->cols-10);
-
+
attrset (COLOR_HOT_NORMAL);
dlg_move (panelize_dlg, 1, (panelize_dlg->cols - strlen(panelize_title)) / 2);
addstr (panelize_title);
{
if (l_panelize->pos != last_listitem) {
last_listitem = l_panelize->pos;
- assign_text (pname,
+ assign_text (pname,
((struct panelize *) l_panelize->current->data)->command);
pname->point = 0;
update_input (pname, 1);
panelize_callback (Dlg_head * h, int Par, int Msg)
{
switch (Msg) {
-#ifndef HAVE_X
+#ifndef HAVE_X
case DLG_DRAW:
panelize_refresh ();
break;
-#endif
+#endif
case DLG_POST_KEY:
/* fall */
#ifdef ENABLE_NLS
static int i18n_flag = 0;
static int maxlen = 0;
-
+
if (!i18n_flag)
{
i = sizeof(panelize_but) / sizeof(panelize_but[0]);
i18n_flag = 1;
}
panelize_cols = max(panelize_cols, maxlen);
-
- panelize_but [2].x = panelize_but [3].x
+
+ panelize_but [2].x = panelize_but [3].x
+ strlen (panelize_but [3].text) + 7;
- panelize_but [1].x = panelize_but [2].x
+ panelize_but [1].x = panelize_but [2].x
+ strlen (panelize_but [2].text) + 5;
- panelize_but [0].x = panelize_cols
+ panelize_but [0].x = panelize_cols
- strlen (panelize_but[0].text) - 8 - BX;
#endif /* ENABLE_NLS */
-
+
last_listitem = 0;
-
+
do_refresh ();
panelize_dlg = create_dlg (0, 0, 22, panelize_cols, dialog_colors,
}
/* add listbox to the dialogs */
- add_widgetl (panelize_dlg, l_panelize, XV_WLAY_EXTENDWIDTH);
+ add_widgetl (panelize_dlg, l_panelize, XV_WLAY_EXTENDWIDTH);
- listbox_select_entry (l_panelize,
+ listbox_select_entry (l_panelize,
listbox_search_text (l_panelize, _("Other command")));
}
char *label;
if (pname->buffer && (*pname->buffer)) {
- label = input_dialog (_(" Add to external panelize "),
- _(" Enter command label: "),
+ label = input_dialog (_(" Add to external panelize "),
+ _(" Enter command label: "),
"");
if (!label)
return;
free (label);
return;
}
-
+
add2panelize (label, strdup(pname->buffer));
}
}
}
init_panelize ();
-
+
/* display file info */
attrset (SELECTED_COLOR);
{
void *profile_keys;
char *key, *value;
-
+
profile_keys = profile_init_iterator (panelize_section, profile_name);
-
+
add2panelize (strdup (_("Other command")), strdup (""));
if (!profile_keys){
add2panelize (strdup (_("Find SUID and SGID programs")), strdup ("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print"));
return;
}
-
+
while (profile_keys){
profile_keys = profile_iterator_next (profile_keys, &key, &value);
add2panelize (strdup (key), strdup (value));
void save_panelize (void)
{
struct panelize *current = panelize;
-
+
profile_clean_section (panelize_section, profile_name);
for (;current; current = current->next){
if (strcmp (current->label, _("Other command")))
int flags;
};
-poptContext poptGetContext(char * name ,int argc, char ** argv,
+poptContext poptGetContext(char * name ,int argc, char ** argv,
struct poptOption * options, int flags) {
poptContext con = malloc(sizeof(*con));
con->aliases = NULL;
con->numAliases = 0;
con->flags = 0;
-
+
if (!name)
con->appName = NULL;
else
int i;
while (!done) {
- while (!con->os->nextCharArg && con->os->next == con->os->argc
+ while (!con->os->nextCharArg && con->os->next == con->os->argc
&& con->os > con->optionStack)
con->os--;
if (!con->os->nextCharArg && con->os->next == con->os->argc)
return -1;
if (!con->os->nextCharArg) {
-
+
origOptString = con->os->argv[con->os->next++];
if (con->restLeftover || *origOptString != '-') {
return POPT_ERROR_BADOPT;
/* Make a copy we can hack at */
- localOptString = optString =
- strcpy(malloc(strlen(origOptString) + 1),
+ localOptString = optString =
+ strcpy(malloc(strlen(origOptString) + 1),
origOptString);
if (optString[1] == '-' && !optString[2]) {
} else if (optString[1] == '-') {
optString += 2;
- if (!con->os->currAlias || !con->os->currAlias->longName ||
+ if (!con->os->currAlias || !con->os->currAlias->longName ||
strcmp(con->os->currAlias->longName, optString)) {
i = con->numAliases - 1;
if (i >= 0) {
free(localOptString);
- if ((con->os - con->optionStack + 1)
+ if ((con->os - con->optionStack + 1)
== POPT_OPTION_DEPTH)
return POPT_ERROR_OPTSTOODEEP;
free(localOptString);
return POPT_ERROR_BADOPT;
}
- } else
+ } else
con->os->nextCharArg = origOptString + 1;
free(localOptString);
}
-
+
if (con->os->nextCharArg) {
origOptString = con->os->nextCharArg;
con->os->nextCharArg = NULL;
- if (!con->os->currAlias || *origOptString !=
+ if (!con->os->currAlias || *origOptString !=
con->os->currAlias->shortName) {
i = con->numAliases - 1;
}
opt = con->options;
- while ((opt->longName || opt->shortName) &&
+ while ((opt->longName || opt->shortName) &&
*origOptString != opt->shortName) opt++;
if (!opt->longName && !opt->shortName) return POPT_ERROR_BADOPT;
con->os->nextCharArg = origOptString;
}
- if (opt->arg && opt->argInfo == POPT_ARG_NONE)
+ if (opt->arg && opt->argInfo == POPT_ARG_NONE)
*((int *)opt->arg) = 1;
else if (opt->argInfo != POPT_ARG_NONE) {
if (longArg) {
} else if (con->os->nextCharArg) {
con->os->nextArg = con->os->nextCharArg;
con->os->nextCharArg = NULL;
- } else {
- while (con->os->next == con->os->argc &&
+ } else {
+ while (con->os->next == con->os->argc &&
con->os > con->optionStack)
con->os--;
if (con->os->next == con->os->argc)
case POPT_ARG_INT:
case POPT_ARG_LONG:
aLong = strtol(con->os->nextArg, &end, 0);
- if (*end)
+ if (*end)
return POPT_ERROR_BADNUMBER;
if (aLong == LONG_MIN || aLong == LONG_MAX)
if (!con->aliases)
con->aliases = malloc(sizeof(newAlias) * con->numAliases);
else
- con->aliases = realloc(con->aliases,
+ con->aliases = realloc(con->aliases,
sizeof(newAlias) * con->numAliases);
alias = con->aliases + aliasNum;
-
+
*alias = newAlias;
if (alias->longName)
- alias->longName = strcpy(malloc(strlen(alias->longName) + 1),
+ alias->longName = strcpy(malloc(strlen(alias->longName) + 1),
alias->longName);
else
alias->longName = NULL;
int nameLength = strlen(con->appName);
char * opt;
struct poptAlias alias;
-
+
if (strncmp(line, con->appName, nameLength)) return;
line += nameLength;
if (!*line || !isspace(*line)) return;
if (fd < 0) {
if (errno == ENOENT)
return 0;
- else
+ else
return POPT_ERROR_ERRNO;
}
case '\\':
*dst++ = *chptr++;
if (chptr < end) {
- if (*chptr == '\n')
- dst--, chptr++;
+ if (*chptr == '\n')
+ dst--, chptr++;
/* \ at the end of a line does not insert a \n */
else
*dst++ = *chptr++;
alias.longName = envValue + 2;
alias.shortName = '\0';
} else if (*envValue == '-' && strlen(envValue) == 2) {
- alias.longName = NULL;
+ alias.longName = NULL;
alias.shortName = envValue[1];
} else {
skip = 1;
typedef struct poptContext_s * poptContext;
-poptContext poptGetContext(char * name, int argc, char ** argv,
+poptContext poptGetContext(char * name, int argc, char ** argv,
struct poptOption * options, int flags);
void poptResetContext(poptContext con);
int poptStuffArgs(poptContext con, char ** argv);
int poptAddAlias(poptContext con, struct poptAlias alias, int flags);
int poptReadConfigFile(poptContext con, char * fn);
-/* like above, but reads /etc/popt and $HOME/.popt along with environment
+/* like above, but reads /etc/popt and $HOME/.popt along with environment
vars */
int poptReadDefaultConfig(poptContext con, int useEnv);
/* argv should be freed -- this allows ', ", and \ quoting, but ' is treated
* From the Wine project
Copyright (C) 1993, 1994 Miguel de Icaza.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* "$Id: profile.c,v 1.1 2001/12/30 09:55:22 sedwards Exp $" */
+/* "$Id$" */
#include <config.h>
#include <stdio.h>
TKeys *Keys;
struct TSecHeader *link;
} TSecHeader;
-
+
typedef struct TProfile {
char *FileName;
TSecHeader *Section;
char CharBuffer [STRSIZE];
char *next = ""; /* Not needed */
int c;
-
+
if ((f = fopen (file, "r"))==NULL)
return NULL;
while ((c = getc (f)) != EOF){
if (c == '\r') /* Ignore Carriage Return */
continue;
-
+
switch (state){
case OnSecHeader:
case KeyDefOnKey:
if (c == '['){
TSecHeader *temp;
-
+
temp = SecHeader;
SecHeader = (TSecHeader *) xmalloc (sizeof (TSecHeader),
"KeyDef");
}
if (state == FirstBrace) /* On first pass, don't allow dangling keys */
break;
-
+
if ((c == ' ' && state != KeyDefOnKey) || c == '\t')
break;
-
+
if (c == '\n' || overflow) /* Abort Definition */
next = CharBuffer;
-
+
if (c == '=' || overflow){
TKeys *temp;
} else
*next++ = c;
break;
-
+
} /* switch */
-
+
} /* while ((c = getc (f)) != EOF) */
if (c == EOF && state == KeyValue){
*next = '\0';
static void new_key (TSecHeader *section, char *KeyName, char *Value)
{
TKeys *key;
-
+
key = (TKeys *) xmalloc (sizeof (TKeys), "new_key");
key->KeyName = strdup (KeyName);
key->Value = strdup (Value);
char *GetSetProfileChar (int set, char *AppName, char *KeyName,
char *Default, char *FileName)
{
-
+
TProfile *New;
TSecHeader *section;
TKeys *key;
section = New->Section;
Current = New;
}
-
+
/* Start search */
for (; section; section = section->link){
if (section->AppName == 0 || strcasecmp (section->AppName, AppName))
return 0;
}
}
-
+
/* Non existent section */
if (set && Default){
section = (TSecHeader *) xmalloc (sizeof (TSecHeader), "GSP3");
new_key (section, KeyName, Default);
section->link = Current->Section;
Current->Section = section;
- }
+ }
return Default;
}
{
char *s;
-
+
s = GetSetProfileChar (set, AppName, KeyName, Default, FileName);
if (!set){
ReturnedString [Size-1] = 0;
}
#if 0
-int GetProfileString (char * AppName, char * KeyName, char * Default,
+int GetProfileString (char * AppName, char * KeyName, char * Default,
char * ReturnedString, int Size)
{
return GetPrivateProfileString (AppName, KeyName, Default,
static char buf [15];
sprintf (buf, "%d", Default);
-
+
/* Check the exact semantic with the SDK */
GetPrivateProfileString (AppName, KeyName, buf, IntBuf, 15, File);
if (!strcasecmp (IntBuf, "true"))
static void dump_profile (TProfile *p)
{
FILE *profile;
-
+
if (!p)
return;
dump_profile (p->link);
void free_profile_name (char *s)
{
TProfile *p;
-
+
if (!s)
return;
-
+
for (p = Base; p; p = p->link){
if (strcmp (s, p->FileName) == 0){
free_sections (p->Section);
{
TProfile *New;
TSecHeader *section;
-
+
if (!is_loaded (file, §ion)){
New = (TProfile *) xmalloc (sizeof (TProfile), "GetSetProfile");
New->link = Base;
char * Default, char * ReturnedString,
short Size, char * FileName);
-int GetProfileString (char * AppName, char * KeyName, char * Default,
+int GetProfileString (char * AppName, char * KeyName, char * Default,
char * ReturnedString, int Size);
int GetPrivateProfileInt (char * AppName, char * KeyName, int Default,
/* This must be nonzero for the wordchar and notwordchar pattern
commands in re_match_2. */
-#ifndef Sword
+#ifndef Sword
#define Sword 1
#endif
use `alloca' instead of `malloc'. This is because using malloc in
re_search* or re_match* could cause memory leaks when C-g is used in
Emacs; also, malloc is slower and causes storage fragmentation. On
- the other hand, malloc is more portable, and easier to debug.
-
+ the other hand, malloc is more portable, and easier to debug.
+
Because we sometimes use alloca, some routines have to be macros,
not functions -- `alloca'-allocated space disappears at the end of the
function it is called in. */
#ifndef _AIX /* Already did AIX, up at the top. */
char *alloca ();
#endif /* not _AIX */
-#endif /* not HAVE_ALLOCA_H */
+#endif /* not HAVE_ALLOCA_H */
#endif /* not __GNUC__ */
#endif /* not alloca */
/* Analogously, for end of buffer/string. */
endbuf,
-
+
/* Followed by two byte relative address to which to jump. */
- jump,
+ jump,
/* Same as jump, but marks the end of an alternative. */
jump_past_alt,
/* Followed by two-byte relative address of place to resume at
in case of failure. */
on_failure_jump,
-
+
/* Like on_failure_jump, but pushes a placeholder instead of the
current string position when executed. */
on_failure_keep_string_jump,
-
+
/* Throw away latest failure point and then jump to following
two-byte relative address. */
pop_failure_jump,
int *dest;
unsigned char *source;
{
- int temp = SIGN_EXTEND_CHAR (*(source + 1));
+ int temp = SIGN_EXTEND_CHAR (*(source + 1));
*dest = *source & 0377;
*dest += temp << 8;
}
extract_number_and_incr (destination, source)
int *destination;
unsigned char **source;
-{
+{
extract_number (destination, *source);
*source += 2;
}
char *fastmap;
{
unsigned was_a_range = 0;
- unsigned i = 0;
-
+ unsigned i = 0;
+
while (i < (1 << BYTEWIDTH))
{
if (fastmap[i++])
}
}
}
- putchar ('\n');
+ putchar ('\n');
}
printf ("(null)\n");
return;
}
-
+
/* Loop over pattern commands. */
while (p < pend)
{
printf ("/charset [%s",
(re_opcode_t) *(p - 1) == charset_not ? "^" : "");
-
+
assert (p + *p < pend);
for (c = 0; c < 256; c++)
putchar (last);
in_range = 0;
}
-
+
if (! in_range)
putchar (c);
case push_dummy_failure:
printf ("/push_dummy_failure");
break;
-
+
case maybe_pop_jump:
extract_number_and_incr (&mcnt, &p);
printf ("/maybe_pop_jump to %d", p + mcnt - start);
case pop_failure_jump:
extract_number_and_incr (&mcnt, &p);
printf ("/pop_failure_jump to %d", p + mcnt - start);
- break;
-
+ break;
+
case jump_past_alt:
extract_number_and_incr (&mcnt, &p);
printf ("/jump_past_alt to %d", p + mcnt - start);
- break;
-
+ break;
+
case jump:
extract_number_and_incr (&mcnt, &p);
printf ("/jump to %d", p + mcnt - start);
break;
- case succeed_n:
+ case succeed_n:
extract_number_and_incr (&mcnt, &p);
extract_number_and_incr (&mcnt2, &p);
printf ("/succeed_n to %d, %d times", p + mcnt - start, mcnt2);
break;
-
- case jump_n:
+
+ case jump_n:
extract_number_and_incr (&mcnt, &p);
extract_number_and_incr (&mcnt2, &p);
printf ("/jump_n to %d, %d times", p + mcnt - start, mcnt2);
break;
-
- case set_number_at:
+
+ case set_number_at:
extract_number_and_incr (&mcnt, &p);
extract_number_and_incr (&mcnt2, &p);
printf ("/set_number_at location %d to %d", p + mcnt - start, mcnt2);
break;
-
+
case wordbound:
printf ("/wordbound");
break;
case wordbeg:
printf ("/wordbeg");
break;
-
+
case wordend:
printf ("/wordend");
-
+
#ifdef emacs
case before_dot:
printf ("/before_dot");
mcnt = *p++;
printf ("/%d", mcnt);
break;
-
+
case notsyntaxspec:
printf ("/notsyntaxspec");
mcnt = *p++;
case wordchar:
printf ("/wordchar");
break;
-
+
case notwordchar:
printf ("/notwordchar");
break;
int size2;
{
unsigned this_char;
-
+
if (where == NULL)
printf ("(null)");
else
for (this_char = where - string1; this_char < size1; this_char++)
putchar (string1[this_char]);
- where = string2;
+ where = string2;
}
for (this_char = where - string2; this_char < size2; this_char++)
reg_syntax_t syntax;
{
reg_syntax_t ret = re_syntax_options;
-
+
re_syntax_options = syntax;
return ret;
}
ralloc heap) shift the data out from underneath the regexp
routines.
- Here's another reason to avoid allocation: Emacs
+ Here's another reason to avoid allocation: Emacs
processes input from X in a signal handler; processing X input may
call malloc; if input arrives while a matching routine is calling
malloc, then we're scrod. But Emacs can't just block input while
/* Failure stack declarations and macros; both re_compile_fastmap and
re_match_2 use a failure stack. These have to be macros because of
REGEX_ALLOCATE_STACK. */
-
+
/* Number of failure points for which to initially allocate space
when matching. If this number is exceeded, we allocate more
/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items.
Return 1 if succeeds, and 0 if either ran out of memory
- allocating space for it or it was already too large.
-
+ allocating space for it or it was already too large.
+
REGEX_REALLOCATE_STACK requires `destination' be declared. */
#define DOUBLE_FAIL_STACK(fail_stack) \
1)))
-/* Push pointer POINTER on FAIL_STACK.
+/* Push pointer POINTER on FAIL_STACK.
Return 1 if was able to do so and 0 if ran out of memory allocating
space to do so. */
#define PUSH_PATTERN_OP(POINTER, FAIL_STACK) \
/* Push the information about the state we will need
- if we ever fail back to it.
-
+ if we ever fail back to it.
+
Requires variables fail_stack, regstart, regend, reg_info, and
num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be
declared.
-
+
Does `return FAILURE_CODE' if runs out of memory. */
#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \
LOW_REG, HIGH_REG -- the highest and lowest active registers.
REGSTART, REGEND -- arrays of string positions.
REG_INFO -- array of information about each subexpression.
-
+
Also assumes the variables `fail_stack' and (if debugging), `bufp',
`pend', `string1', `size1', `string2', and `size2'. */
Other register information, such as the
starting and ending positions (which are addresses), and the list of
inner groups (which is a bits list) are maintained in separate
- variables.
-
+ variables.
+
We are making a (strictly speaking) nonportable assumption here: that
the compiler will pack our bit fields into something that fits into
the type of `word', i.e., is something that fits into one item on the
static boolean group_in_compile_stack ();
static reg_errcode_t compile_range ();
-/* Fetch the next character in the uncompiled pattern---translating it
+/* Fetch the next character in the uncompiled pattern---translating it
if necessary. Also cast from a signed character in the constant
string passed to us by the user to an unsigned char that we can use
as an array index (in, e.g., `translate'). */
pattern_offset_t begalt_offset;
pattern_offset_t fixup_alt_jump;
pattern_offset_t inner_group_offset;
- pattern_offset_t laststart_offset;
+ pattern_offset_t laststart_offset;
regnum_t regnum;
} compile_stack_elt_t;
PATFETCH (c); \
} \
} \
- }
+ }
#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
static const char ** regstart, ** regend;
static const char ** old_regstart, ** old_regend;
static const char **best_regstart, **best_regend;
-static register_info_type *reg_info;
+static register_info_type *reg_info;
static const char **reg_dummy;
static register_info_type *reg_info_dummy;
`fastmap_accurate' is zero;
`re_nsub' is the number of subexpressions in PATTERN;
`not_bol' and `not_eol' are zero;
-
+
The `fastmap' and `newline_anchor' fields are neither
examined nor set. */
`char *' (i.e., signed), we declare these variables as unsigned, so
they can be reliably used as array indices. */
register unsigned char c, c1;
-
+
/* A random temporary spot in PATTERN. */
const char *p1;
/* Points to the end of the buffer, where we should append. */
register unsigned char *b;
-
+
/* Keeps track of unclosed groups. */
compile_stack_type compile_stack;
/* Points to the current (ending) position in the pattern. */
const char *p = pattern;
const char *pend = pattern + size;
-
+
/* How to translate the characters in the pattern. */
char *translate = bufp->translate;
/* Place in the uncompiled pattern (i.e., the {) to
which to go back if the interval is invalid. */
const char *beg_interval;
-
+
/* Address of the place where a forward jump should go to the end of
the containing expression. Each alternative of an `or' -- except the
last -- ends with a forward jump of this sort. */
if (debug)
{
unsigned debug_count;
-
+
for (debug_count = 0; debug_count < size; debug_count++)
putchar (pattern[debug_count]);
putchar ('\n');
printer (for debugging) will think there's no pattern. We reset it
at the end. */
bufp->used = 0;
-
+
/* Always count groups, whether or not bufp->no_sub is set. */
- bufp->re_nsub = 0;
+ bufp->re_nsub = 0;
#if !defined (emacs) && !defined (SYNTAX_TABLE)
/* Initialize the syntax table. */
case '$':
{
if ( /* If at end of pattern, it's an operator. */
- p == pend
+ p == pend
/* If context independent, it's an operator. */
|| syntax & RE_CONTEXT_INDEP_ANCHORS
/* Otherwise, depends on what's next. */
{
/* Are we optimizing this jump? */
boolean keep_string_p = false;
-
+
/* 1 means zero (many) matches is allowed. */
char zero_times_ok = 0, many_times_ok = 0;
/* Star, etc. applied to an empty pattern is equivalent
to an empty pattern. */
- if (!laststart)
+ if (!laststart)
break;
/* Now we know whether or not zero matches is allowed
{ /* More than one repetition is allowed, so put in at the
end a backward relative jump from `b' to before the next
jump we're going to put in below (which jumps from
- laststart to after this jump).
+ laststart to after this jump).
But if we are at the `*' in the exact sequence `.*\n',
insert an unconditional jump backwards to the .,
/* We test `*p == '^' twice, instead of using an if
statement, so we only need one BUF_PUSH. */
- BUF_PUSH (*p == '^' ? charset_not : charset);
+ BUF_PUSH (*p == '^' ? charset_not : charset);
if (*p == '^')
p++;
was a character: if this is a hyphen not at the
beginning or the end of a list, then it's the range
operator. */
- if (c == '-'
- && !(p - 2 >= pattern && p[-2] == '[')
+ if (c == '-'
+ && !(p - 2 >= pattern && p[-2] == '[')
&& !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^')
&& *p != ']')
{
/* Move past the `-'. */
PATFETCH (c1);
-
+
ret = compile_range (&p, pend, translate, syntax, b);
if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
}
str[c1] = '\0';
/* If isn't a word bracketed by `[:' and:`]':
- undo the ending character, the letters, and leave
+ undo the ending character, the letters, and leave
the leading `:' and `[' (but set bits for them). */
if (c == ':' && *p == ']')
{
boolean is_space = STREQ (str, "space");
boolean is_upper = STREQ (str, "upper");
boolean is_xdigit = STREQ (str, "xdigit");
-
+
if (!IS_CHAR_CLASS (str))
FREE_STACK_RETURN (REG_ECTYPE);
/* Throw away the ] at the end of the character
class. */
- PATFETCH (c);
+ PATFETCH (c);
if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
else
{
c1++;
- while (c1--)
+ while (c1--)
PATUNFETCH;
SET_LIST_BIT ('[');
SET_LIST_BIT (':');
/* Discard any (non)matching list bytes that are all 0 at the
end of the map. Decrease the map-length byte too. */
- while ((int) b[-1] > 0 && b[b[-1] - 1] == 0)
- b[-1]--;
+ while ((int) b[-1] > 0 && b[b[-1] - 1] == 0)
+ b[-1]--;
b += b[-1];
}
break;
regnum++;
if (COMPILE_STACK_FULL)
- {
+ {
RETALLOC (compile_stack.stack, compile_stack.size << 1,
compile_stack_elt_t);
if (compile_stack.stack == NULL) return REG_ESPACE;
whole pattern moves because of realloc, they will still
be valid. */
COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer;
- COMPILE_STACK_TOP.fixup_alt_jump
+ COMPILE_STACK_TOP.fixup_alt_jump
= fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0;
COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer;
COMPILE_STACK_TOP.regnum = regnum;
COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2;
BUF_PUSH_3 (start_memory, regnum, 0);
}
-
+
compile_stack.avail++;
fixup_alt_jump = 0;
`pop_failure_jump' to pop. See comments at
`push_dummy_failure' in `re_match_2'. */
BUF_PUSH (push_dummy_failure);
-
+
/* We allocated space for this jump when we assigned
to `fixup_alt_jump', in the `handle_alt' case below. */
STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1);
as in `(ab)c(de)' -- the second group is #2. */
regnum_t this_group_regnum;
- compile_stack.avail--;
+ compile_stack.avail--;
begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset;
fixup_alt_jump
= COMPILE_STACK_TOP.fixup_alt_jump
- ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1
+ ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1
: 0;
laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset;
this_group_regnum = COMPILE_STACK_TOP.regnum;
{
unsigned char *inner_group_loc
= bufp->buffer + COMPILE_STACK_TOP.inner_group_offset;
-
+
*inner_group_loc = regnum - this_group_regnum;
BUF_PUSH_3 (stop_memory, this_group_regnum,
regnum - this_group_regnum);
jump (put in below, which in turn will jump to the next
(if any) alternative's such jump, etc.). The last such
jump jumps to the correct final destination. A picture:
- _____ _____
- | | | |
- | v | v
- a | b | c
+ _____ _____
+ | | | |
+ | v | v
+ a | b | c
If we are at `b', then fixup_alt_jump right now points to a
three-byte space after `a'. We'll put in the jump, set
break;
- case '{':
+ case '{':
/* If \{ is a literal. */
if (!(syntax & RE_INTERVALS)
- /* If we're at `\{' and it's not the open-interval
+ /* If we're at `\{' and it's not the open-interval
operator. */
|| ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
|| (p - 2 == pattern && p == pend))
{
if (syntax & RE_NO_BK_BRACES)
goto unfetch_interval;
- else
+ else
FREE_STACK_RETURN (REG_BADBR);
}
- if (!(syntax & RE_NO_BK_BRACES))
+ if (!(syntax & RE_NO_BK_BRACES))
{
if (c != '\\') FREE_STACK_RETURN (REG_EBRACE);
{
if (syntax & RE_NO_BK_BRACES)
goto unfetch_interval;
- else
+ else
FREE_STACK_RETURN (REG_BADBR);
}
jump_n <succeed_n addr> <jump count>
(The upper bound and `jump_n' are omitted if
`upper_bound' is 1, though.) */
- else
+ else
{ /* If the upper bound is > 1, we need to insert
more at the end of the loop. */
unsigned nbytes = 10 + (upper_bound > 1) * 10;
lower_bound);
b += 5;
- /* Code to initialize the lower bound. Insert
+ /* Code to initialize the lower bound. Insert
before the `succeed_n'. The `5' is the last two
bytes of this `set_number_at', plus 3 bytes of
the following `succeed_n'. */
{ /* More than one repetition is allowed, so
append a backward jump to the `succeed_n'
that starts this interval.
-
+
When we've reached this during matching,
we'll have matched the interval once, so
jump back only `upper_bound - 1' times. */
so everything is getting moved up by 5.
Conclusion: (b - 2) - (laststart + 3) + 5,
i.e., b - laststart.
-
+
We insert this at the beginning of the loop
so that if we fail during matching, we'll
reinitialize the bounds. */
beg_interval = NULL;
/* normal_char and normal_backslash need `c'. */
- PATFETCH (c);
+ PATFETCH (c);
if (!(syntax & RE_NO_BK_BRACES))
{
BUF_PUSH (at_dot);
break;
- case 's':
+ case 's':
laststart = b;
PATFETCH (c);
BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]);
/* Expects the character in `c'. */
normal_char:
/* If no exactn currently being built. */
- if (!pending_exact
+ if (!pending_exact
/* If last exactn not at current position. */
|| pending_exact + *pending_exact + 1 != b
-
+
/* We have only one byte following the exactn for the count. */
|| *pending_exact == (1 << BYTEWIDTH) - 1
: (p[0] == '\\' && p[1] == '{'))))
{
/* Start building a new exactn. */
-
+
laststart = b;
BUF_PUSH_2 (exactn, 0);
pending_exact = b - 1;
}
-
+
BUF_PUSH (c);
(*pending_exact)++;
break;
} /* switch (c) */
} /* while p != pend */
-
+
/* Through the pattern now. */
-
+
if (fixup_alt_jump)
STORE_JUMP (jump_past_alt, fixup_alt_jump, b);
- if (!COMPILE_STACK_EMPTY)
+ if (!COMPILE_STACK_EMPTY)
FREE_STACK_RETURN (REG_EPAREN);
/* If we don't want backtracking, force success
#ifdef emacs
if (! fail_stack.stack)
fail_stack.stack
- = (fail_stack_elt_t *) xmalloc (fail_stack.size
+ = (fail_stack_elt_t *) xmalloc (fail_stack.size
* sizeof (fail_stack_elt_t));
else
fail_stack.stack
#else /* not emacs */
if (! fail_stack.stack)
fail_stack.stack
- = (fail_stack_elt_t *) malloc (fail_stack.size
+ = (fail_stack_elt_t *) malloc (fail_stack.size
* sizeof (fail_stack_elt_t));
else
fail_stack.stack
re_opcode_t op;
unsigned char *loc;
int arg;
- unsigned char *end;
+ unsigned char *end;
{
register unsigned char *pfrom = end;
register unsigned char *pto = end + 3;
while (pfrom != loc)
*--pto = *--pfrom;
-
+
store_op1 (op, loc, arg);
}
re_opcode_t op;
unsigned char *loc;
int arg1, arg2;
- unsigned char *end;
+ unsigned char *end;
{
register unsigned char *pfrom = end;
register unsigned char *pto = end + 5;
while (pfrom != loc)
*--pto = *--pfrom;
-
+
store_op2 (op, loc, arg1, arg2);
}
{
const char *prev = p - 2;
boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
-
+
return
/* After a subexpression? */
(*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash))
const char *next = p;
boolean next_backslash = *next == '\\';
const char *next_next = p + 1 < pend ? p + 1 : 0;
-
+
return
/* Before a subexpression? */
(syntax & RE_NO_BK_PARENS ? *next == ')'
}
-/* Returns true if REGNUM is in one of COMPILE_STACK's elements and
+/* Returns true if REGNUM is in one of COMPILE_STACK's elements and
false if it's not. */
static boolean
{
int this_element;
- for (this_element = compile_stack.avail - 1;
- this_element >= 0;
+ for (this_element = compile_stack.avail - 1;
+ this_element >= 0;
this_element--)
if (compile_stack.stack[this_element].regnum == regnum)
return true;
starting character is in `P[-2]'. (`P[-1]' is the character `-'.)
Then we set the translation of all bits between the starting and
ending characters (inclusive) in the compiled pattern B.
-
+
Return an error code.
-
+
We use these short variable names so we can use the same macros as
`regex_compile' itself. */
const char *p = *p_ptr;
int range_start, range_end;
-
+
if (p == pend)
return REG_ERANGE;
is set, the range endpoints will be negative if we fetch using a
signed char *.
- We also want to fetch the endpoints without translating them; the
+ We also want to fetch the endpoints without translating them; the
appropriate translation is done in the bit-setting loop below. */
/* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */
range_start = ((const unsigned char *) p)[-2];
{
SET_LIST_BIT (TRANSLATE (this_char));
}
-
+
return REG_NOERROR;
}
\f
The caller must supply the address of a (1 << BYTEWIDTH)-byte data
area as BUFP->fastmap.
-
+
We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in
the pattern buffer.
#endif
/* We don't push any register information onto the failure stack. */
unsigned num_regs = 0;
-
+
register char *fastmap = bufp->fastmap;
unsigned char *pattern = bufp->buffer;
unsigned long size = bufp->used;
boolean succeed_n_p = false;
assert (fastmap != NULL && p != NULL);
-
+
INIT_FAIL_STACK ();
bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */
bufp->fastmap_accurate = 1; /* It will be when we're done. */
bufp->can_be_null = 0;
-
+
while (1)
{
if (p == pend || *p == succeed)
/* We should never be about to go beyond the end of the pattern. */
assert (p < pend);
-
+
switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++))
{
case jump_past_alt:
case dummy_failure_jump:
EXTRACT_NUMBER_AND_INCR (j, p);
- p += j;
+ p += j;
if (j > 0)
continue;
-
+
/* Jump backward implies we just went through the body of a
loop and matched nothing. Opcode jumped to should be
`on_failure_jump' or `succeed_n'. Just treat it like an
p++;
EXTRACT_NUMBER_AND_INCR (j, p);
- p += j;
-
+ p += j;
+
/* If what's on the stack is where we are now, pop it. */
- if (!FAIL_STACK_EMPTY ()
+ if (!FAIL_STACK_EMPTY ()
&& fail_stack.stack[fail_stack.avail - 1].pointer == p)
fail_stack.avail--;
case succeed_n:
/* Get to the number of times to succeed. */
- p += 2;
+ p += 2;
/* Increment p past the n for when k != 0. */
EXTRACT_NUMBER_AND_INCR (k, p);
int size, startpos, range;
struct re_registers *regs;
{
- return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
+ return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
regs, size);
}
/* Using the compiled pattern in BUFP->buffer, first tries to match the
virtual concatenation of STRING1 and STRING2, starting first at index
STARTPOS, then at STARTPOS + 1, and so on.
-
+
STRING1 and STRING2 have length SIZE1 and SIZE2, respectively.
-
+
RANGE is how far to scan while trying to match. RANGE = 0 means try
only at STARTPOS; in general, the last start tried is STARTPOS +
RANGE.
-
+
In REGS, return the indices of the virtual concatenation of STRING1
and STRING2 that matched the entire BUFP->buffer and its contained
subexpressions.
-
+
Do not consider matching one past the index STOP in the virtual
concatenation of STRING1 and STRING2.
/* Check for out-of-range STARTPOS. */
if (startpos < 0 || startpos > total_size)
return -1;
-
+
/* Fix up RANGE if it might eventually take us outside
the virtual concatenation of STRING1 and STRING2. */
if (endpos < -1)
if (fastmap && !bufp->fastmap_accurate)
if (re_compile_fastmap (bufp) == -2)
return -2;
-
+
/* Loop through the string, looking for a place to start matching. */
for (;;)
- {
+ {
/* If a fastmap is supplied, skip quickly over characters that
cannot be the start of a match. If the pattern can match the
null string, however, we don't need to skip characters; we want
lim = range - (size1 - startpos);
d = (startpos >= size1 ? string2 - size1 : string1) + startpos;
-
+
/* Written out as an if-else to avoid testing `translate'
inside the loop. */
if (translate)
else /* Searching backwards. */
{
register char c = (size1 == 0 || startpos >= size1
- ? string2[startpos - size1]
+ ? string2[startpos - size1]
: string1[startpos]);
if (!fastmap[(unsigned char) TRANSLATE (c)])
if (val >= 0)
return startpos;
-
+
if (val == -2)
return -2;
advance:
- if (!range)
+ if (!range)
break;
- else if (range > 0)
+ else if (range > 0)
{
- range--;
+ range--;
startpos++;
}
else
{
- range++;
+ range++;
startpos--;
}
}
/* Test if at very beginning or at very end of the virtual concatenation
of `string1' and `string2'. If only one string, it's `string2'. */
#define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2)
-#define AT_STRINGS_END(d) ((d) == end2)
+#define AT_STRINGS_END(d) ((d) == end2)
/* Test if D points to a character which is word-constituent. We have
the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1
and SIZE2, respectively). We start matching at POS, and stop
matching at STOP.
-
+
If REGS is non-null and the `no_sub' field of BUFP is nonzero, we
store offsets for the substring each group matched in REGS. See the
documentation for exactly how many groups we fill.
/* Where we are in the data, and the end of the current string. */
const char *d, *dend;
-
+
/* Where we are in the pattern, and the end of the pattern. */
unsigned char *p = bufp->buffer;
register unsigned char *pend = p + bufp->used;
return, for use in backreferences. The number here includes
an element for register zero. */
unsigned num_regs = bufp->re_nsub + 1;
-
+
/* The currently active registers. */
unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG;
unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG;
subexpression. These two fields get reset each time through any
loop their register is in. */
#ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */
- register_info_type *reg_info;
+ register_info_type *reg_info;
#endif
/* The following record the register info as found in the above
- variables when we find a match better than any we've seen before.
+ variables when we find a match better than any we've seen before.
This happens as we backtrack through the failure points, which in
turn happens only if we have not yet matched the entire string. */
unsigned best_regs_set = false;
#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */
const char **best_regstart, **best_regend;
#endif
-
+
/* Logically, this is `best_regend[0]'. But we don't want to have to
allocate space for that if we're not allocating space for anything
else (see below). Also, we never need info about register 0 for
#ifdef DEBUG
/* Counts the total number of registers pushed. */
- unsigned num_regs_pushed = 0;
+ unsigned num_regs_pushed = 0;
#endif
DEBUG_PRINT1 ("\n\nEntering re_match_2.\n");
-
+
INIT_FAIL_STACK ();
-
+
#ifdef MATCH_MAY_ALLOCATE
/* Do not bother to initialize all the register variables if there are
no groups in the pattern, as it takes a fair amount of time. If
reg_dummy = REGEX_TALLOC (num_regs, const char *);
reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type);
- if (!(regstart && regend && old_regstart && old_regend && reg_info
- && best_regstart && best_regend && reg_dummy && reg_info_dummy))
+ if (!(regstart && regend && old_regstart && old_regend && reg_info
+ && best_regstart && best_regend && reg_dummy && reg_info_dummy))
{
FREE_VARIABLES ();
return -2;
FREE_VARIABLES ();
return -1;
}
-
+
/* Initialize subexpression text positions to -1 to mark ones that no
start_memory/stop_memory has been seen for. Also initialize the
register information struct. */
for (mcnt = 1; mcnt < num_regs; mcnt++)
{
- regstart[mcnt] = regend[mcnt]
+ regstart[mcnt] = regend[mcnt]
= old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE;
-
+
REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE;
IS_ACTIVE (reg_info[mcnt]) = 0;
MATCHED_SOMETHING (reg_info[mcnt]) = 0;
EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0;
}
-
+
/* We move `string1' into `string2' if the latter's empty -- but not if
`string1' is null. */
if (size2 == 0 && string1 != NULL)
end_match_2 = string2 + stop - size1;
}
- /* `p' scans through the pattern as `d' scans through the data.
+ /* `p' scans through the pattern as `d' scans through the data.
`dend' is the end of the input string that `d' points within. `d'
is advanced into the following input string whenever necessary, but
this happens before fetching; therefore, at the beginning of the
DEBUG_PRINT1 ("The string to match is: `");
DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2);
DEBUG_PRINT1 ("'\n");
-
+
/* This loops over pattern commands. It exits by returning from the
function if the match is complete, or it drops through if the match
fails at this starting point in the input data. */
if (p == pend)
{ /* End of pattern means we might have succeeded. */
DEBUG_PRINT1 ("end of pattern ... ");
-
+
/* If we haven't matched the entire string, and we want the
longest match, try backtracking. */
if (d != end_match_2)
{
/* 1 if this match ends in the same string (string1 or string2)
as the best previous match. */
- boolean same_str_p = (FIRST_STRING_P (match_end)
+ boolean same_str_p = (FIRST_STRING_P (match_end)
== MATCHING_IN_FIRST_STRING);
/* 1 if this match is the best seen so far. */
boolean best_match_p;
best_match_p = !MATCHING_IN_FIRST_STRING;
DEBUG_PRINT1 ("backtracking.\n");
-
+
if (!FAIL_STACK_EMPTY ())
{ /* More failure points to try. */
{
best_regs_set = true;
match_end = d;
-
+
DEBUG_PRINT1 ("\nSAVING match as best so far.\n");
-
+
for (mcnt = 1; mcnt < num_regs; mcnt++)
{
best_regstart[mcnt] = regstart[mcnt];
best_regend[mcnt] = regend[mcnt];
}
}
- goto fail;
+ goto fail;
}
/* If no failure points, don't restore garbage. And if
strings `x-' and `y-z-', if the two strings are
not consecutive in memory. */
DEBUG_PRINT1 ("Restoring best registers.\n");
-
+
d = match_end;
dend = ((d >= string1 && d <= end1)
? end_match_1 : end_match_2);
? ((regoff_t) (d - string1))
: ((regoff_t) (d - string2 + size1)));
}
-
+
/* Go through the first `min (num_regs, regs->num_regs)'
registers, since that is all we initialized. */
for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++)
= (regoff_t) POINTER_TO_OFFSET (regend[mcnt]);
}
}
-
+
/* If the regs structure we return has more elements than
were in the pattern, set the extra elements to -1. If
we (re)allocated the registers, this is the case,
nfailure_points_pushed - nfailure_points_popped);
DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed);
- mcnt = d - pos - (MATCHING_IN_FIRST_STRING
- ? string1
+ mcnt = d - pos - (MATCHING_IN_FIRST_STRING
+ ? string1
: string2 - size1);
DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt);
p += 1 + *p;
if (!not) goto fail;
-
+
SET_REGS_MATCHED ();
d++;
break;
/* Find out if this group can match the empty string. */
p1 = p; /* To send to group_match_null_string_p. */
-
+
if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE)
- REG_MATCH_NULL_STRING_P (reg_info[*p])
+ REG_MATCH_NULL_STRING_P (reg_info[*p])
= group_match_null_string_p (&p1, pend, reg_info);
/* Save the position in the string where we were the last time
old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
? REG_UNSET (regstart[*p]) ? d : regstart[*p]
: regstart[*p];
- DEBUG_PRINT2 (" old_regstart: %d\n",
+ DEBUG_PRINT2 (" old_regstart: %d\n",
POINTER_TO_OFFSET (old_regstart[*p]));
regstart[*p] = d;
/* Clear this whenever we change the register activity status. */
set_regs_matched_done = 0;
-
+
/* This is the new highest active register. */
highest_active_reg = *p;
-
+
/* If nothing was active before, this is the new lowest active
register. */
if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
number, and the number of inner groups. */
case stop_memory:
DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]);
-
+
/* We need to save the string position the last time we were at
this close-group operator in case the group is operated
upon by a repetition operator, e.g., with `((a*)*(b*)*)*'
old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
? REG_UNSET (regend[*p]) ? d : regend[*p]
: regend[*p];
- DEBUG_PRINT2 (" old_regend: %d\n",
+ DEBUG_PRINT2 (" old_regend: %d\n",
POINTER_TO_OFFSET (old_regend[*p]));
regend[*p] = d;
unsigned char r = *p - 1;
while (r > 0 && !IS_ACTIVE (reg_info[r]))
r--;
-
+
/* If we end up at register zero, that means that we saved
the registers as the result of an `on_failure_jump', not
a `start_memory', and we jumped to past the innermost
else
highest_active_reg = r;
}
-
+
/* If just failed to match something this time around with a
group that's operated on by a repetition operator, try to
force exit from the ``loop'', and restore the register
last match. */
if ((!MATCHED_SOMETHING (reg_info[*p])
|| just_past_start_mem == p - 1)
- && (p + 2) < pend)
+ && (p + 2) < pend)
{
boolean is_a_jump_n = false;
-
+
p1 = p + 2;
mcnt = 0;
switch ((re_opcode_t) *p1++)
if (is_a_jump_n)
p1 += 2;
break;
-
+
default:
/* do nothing */ ;
}
p1 += mcnt;
-
+
/* If the next operation is a jump backwards in the pattern
to an on_failure_jump right before the start_memory
corresponding to this stop_memory, exit from the loop
failed match, e.g., with `(a*)*b' against `ab' for
regstart[1], and, e.g., with `((a*)*(b*)*)*'
against `aba' for regend[3].
-
+
Also restore the registers for inner groups for,
e.g., `((a*)(b*))*' against `aba' (register 3 would
otherwise get trashed). */
-
+
if (EVER_MATCHED_SOMETHING (reg_info[*p]))
{
- unsigned r;
-
+ unsigned r;
+
EVER_MATCHED_SOMETHING (reg_info[*p]) = 0;
-
+
/* Restore this and inner groups' (if any) registers. */
for (r = *p; r < *p + *(p + 1); r++)
{
/* xx why this test? */
if (old_regend[r] >= regstart[r])
regend[r] = old_regend[r];
- }
+ }
}
p1++;
EXTRACT_NUMBER_AND_INCR (mcnt, p1);
goto fail;
}
}
-
+
/* Move past the register number and the inner group count. */
p += 2;
break;
/* Can't back reference a group which we've never matched. */
if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno]))
goto fail;
-
+
/* Where in input to try to start matching. */
d2 = regstart[regno];
-
+
/* Where to stop matching; if both the place to start and
the place to stop matching are in the same string, then
set to the place to stop, otherwise, for now have to use
the end of the first string. */
- dend2 = ((FIRST_STRING_P (regstart[regno])
+ dend2 = ((FIRST_STRING_P (regstart[regno])
== FIRST_STRING_P (regend[regno]))
? regend[regno] : end_match_1);
for (;;)
/* How many characters left in this segment to match. */
mcnt = dend - d;
-
+
/* Want how many consecutive characters we can match in
one shot, so, if necessary, adjust the count. */
if (mcnt > dend2 - d2)
mcnt = dend2 - d2;
-
+
/* Compare that many; failure if mismatch, else move
past them. */
- if (translate
- ? bcmp_translate (d, d2, mcnt, translate)
+ if (translate
+ ? bcmp_translate (d, d2, mcnt, translate)
: bcmp (d, d2, mcnt))
goto fail;
d += mcnt, d2 += mcnt;
`newline_anchor' is set, after newlines. */
case begline:
DEBUG_PRINT1 ("EXECUTING begline.\n");
-
+
if (AT_STRINGS_BEG (d))
{
if (!bufp->not_bol) break;
{
if (!bufp->not_eol) break;
}
-
+
/* We have to ``prefetch'' the next character. */
else if ((d == end1 ? *string2 : *d) == '\n'
&& bufp->newline_anchor)
then the . fails against the \n. But the next thing we want
to do is match the \n against the \n; if we restored the
string value, we would be back at the foo.
-
+
Because this is used only in specific cases, we don't need to
check all the things that `on_failure_jump' does, to make
sure the right things get saved on the stack. Hence we don't
case; that seems worse than this. */
case on_failure_keep_string_jump:
DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump");
-
+
EXTRACT_NUMBER_AND_INCR (mcnt, p);
DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt);
/* Uses of on_failure_jump:
-
+
Each alternative starts with an on_failure_jump that points
to the beginning of the next alternative. Each alternative
except the last ends with a jump that in effect jumps past
would have to backtrack because of (as in, e.g., `a*a')
then we can change to pop_failure_jump, because we'll
never have to backtrack.
-
+
This is not true in the case of alternatives: in
`(a|ab)*' we do need to backtrack to the `ab' alternative
(e.g., if the string was `ab'). But instead of trying to
p1 = p + mcnt;
/* p1[0] ... p1[2] are the `on_failure_jump' corresponding
- to the `maybe_finalize_jump' of this case. Examine what
+ to the `maybe_finalize_jump' of this case. Examine what
follows. */
/* If we're at the end of the pattern, we can change. */
DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n",
c, p1[5]);
}
-
+
else if ((re_opcode_t) p1[3] == charset
|| (re_opcode_t) p1[3] == charset_not)
{
int not = (re_opcode_t) p1[3] == charset_not;
-
+
if (c < (unsigned char) (p1[4] * BYTEWIDTH)
&& p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
not = !not;
DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n",
c, p1[5]);
}
-
+
else if ((re_opcode_t) p1[3] == charset_not)
{
int idx;
}
/* Note fall through. */
-
+
/* Unconditionally jump (without popping any failure points). */
case jump:
unconditional_jump:
DEBUG_PRINT2 ("(to 0x%x).\n", p);
break;
-
+
/* We need this opcode so we can detect where alternatives end
in `group_match_null_string_p' et al. */
case jump_past_alt:
/* Have to succeed matching what follows at least n times.
After that, handle like `on_failure_jump'. */
- case succeed_n:
+ case succeed_n:
EXTRACT_NUMBER (mcnt, p + 2);
DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt);
goto on_failure;
}
break;
-
- case jump_n:
+
+ case jump_n:
EXTRACT_NUMBER (mcnt, p + 2);
DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt);
{
mcnt--;
STORE_NUMBER (p + 2, mcnt);
- goto unconditional_jump;
+ goto unconditional_jump;
}
/* If don't have to jump any more, skip over the rest of command. */
- else
- p += 4;
+ else
+ p += 4;
break;
-
+
case set_number_at:
{
DEBUG_PRINT1 ("EXECUTING set_number_at.\n");
if (PTR_CHAR_POS ((unsigned char *) d) >= point)
goto fail;
break;
-
+
case at_dot:
DEBUG_PRINT1 ("EXECUTING at_dot.\n");
if (PTR_CHAR_POS ((unsigned char *) d) != point)
goto fail;
break;
-
+
case after_dot:
DEBUG_PRINT1 ("EXECUTING after_dot.\n");
if (PTR_CHAR_POS ((unsigned char *) d) <= point)
SET_REGS_MATCHED ();
d++;
break;
-
+
case notwordchar:
DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n");
PREFETCH ();
d++;
break;
#endif /* not emacs */
-
+
default:
abort ();
}
if (p < pend)
{
boolean is_a_jump_n = false;
-
+
/* If failed to a backwards jump that's part of a repetition
loop, need to pop this failure point and use the next one. */
switch ((re_opcode_t) *p)
case jump:
p1 = p + 1;
EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- p1 += mcnt;
+ p1 += mcnt;
if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n)
|| (!is_a_jump_n
/* We are passed P pointing to a register number after a start_memory.
-
+
Return true if the pattern up to the corresponding stop_memory can
match the empty string, and false otherwise.
-
+
If we find the matching stop_memory, sets P to point to one past its number.
Otherwise, sets P to an undefined byte less than or equal to END.
int mcnt;
/* Point to after the args to the start_memory. */
unsigned char *p1 = *p + 2;
-
+
while (p1 < end)
{
/* Skip over opcodes that can match nothing, and return true or
false, as appropriate, when we get to one that can't, or to the
matching stop_memory. */
-
+
switch ((re_opcode_t) *p1)
{
/* Could be either a loop or a series of alternatives. */
case on_failure_jump:
p1++;
EXTRACT_NUMBER_AND_INCR (mcnt, p1);
-
+
/* If the next operation is not a jump backwards in the
pattern. */
/on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6
/on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3
- /exactn/1/c
+ /exactn/1/c
So, we have to first go through the first (n-1)
alternatives and then deal with the last one separately. */
is, including the ending `jump_past_alt' and
its number. */
- if (!alt_match_null_string_p (p1, p1 + mcnt - 3,
+ if (!alt_match_null_string_p (p1, p1 + mcnt - 3,
reg_info))
return false;
/* Move to right after this alternative, including the
jump_past_alt. */
- p1 += mcnt;
+ p1 += mcnt;
/* Break if it's the beginning of an n-th alternative
that doesn't begin with an on_failure_jump. */
if ((re_opcode_t) *p1 != on_failure_jump)
break;
-
+
/* Still have to check that it's not an n-th
alternative that starts with an on_failure_jump. */
p1++;
} /* if mcnt > 0 */
break;
-
+
case stop_memory:
assert (p1[1] == **p);
*p = p1 + 2;
return true;
-
- default:
+
+ default:
if (!common_op_match_null_string_p (&p1, end, reg_info))
return false;
}
/* Similar to group_match_null_string_p, but doesn't deal with alternatives:
It expects P to be the first byte of a single alternative and END one
byte past the last. The alternative can contain groups. */
-
+
static boolean
alt_match_null_string_p (p, end, reg_info)
unsigned char *p, *end;
{
int mcnt;
unsigned char *p1 = p;
-
+
while (p1 < end)
{
- /* Skip over opcodes that can match nothing, and break when we get
+ /* Skip over opcodes that can match nothing, and break when we get
to one that can't. */
-
+
switch ((re_opcode_t) *p1)
{
/* It's a loop. */
EXTRACT_NUMBER_AND_INCR (mcnt, p1);
p1 += mcnt;
break;
-
- default:
+
+ default:
if (!common_op_match_null_string_p (&p1, end, reg_info))
return false;
}
/* Deals with the ops common to group_match_null_string_p and
- alt_match_null_string_p.
-
+ alt_match_null_string_p.
+
Sets P to one after the op and its arguments, if any. */
static boolean
reg_no = *p1;
assert (reg_no > 0 && reg_no <= MAX_REGNUM);
ret = group_match_null_string_p (&p1, end, reg_info);
-
+
/* Have to set this here in case we're checking a group which
contains a group and a back reference to it. */
if (!ret)
return false;
break;
-
+
/* If this is an optimized succeed_n for zero times, make the jump. */
case jump:
EXTRACT_NUMBER_AND_INCR (mcnt, p1);
case succeed_n:
/* Get to the number of times to succeed. */
- p1 += 2;
+ p1 += 2;
EXTRACT_NUMBER_AND_INCR (mcnt, p1);
if (mcnt == 0)
return false;
break;
- case duplicate:
+ case duplicate:
if (!REG_MATCH_NULL_STRING_P (reg_info[*p1]))
return false;
break;
/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN
bytes; nonzero otherwise. */
-
+
static int
bcmp_translate (s1, s2, len, translate)
unsigned char *s1, *s2;
/* re_compile_pattern is the GNU regular expression compiler: it
compiles PATTERN (of length SIZE) and puts the result in BUFP.
Returns 0 if the pattern was valid, otherwise an error string.
-
+
Assumes the `allocated' (and perhaps `buffer') and `translate' fields
are set in BUFP on entry.
-
+
We call regex_compile to do the actual compilation. */
const char *
struct re_pattern_buffer *bufp;
{
reg_errcode_t ret;
-
+
/* GNU code is written to assume at least RE_NREGS registers will be set
(and at least one extra will be -1). */
bufp->regs_allocated = REGS_UNALLOCATED;
-
+
/* And GNU code determines whether or not to get register information
by passing null for the REGS argument to re_match, etc., not by
setting no_sub. */
bufp->no_sub = 0;
-
+
/* Match anchors at newline. */
bufp->newline_anchor = 1;
-
+
ret = regex_compile (pattern, length, re_syntax_options, bufp);
if (!ret)
return NULL;
return gettext (re_error_msgid[(int) ret]);
-}
+}
\f
/* Entry points compatible with 4.2 BSD regex library. We don't define
them unless specifically requested. */
const char *s;
{
reg_errcode_t ret;
-
+
if (!s)
{
if (!re_comp_buf.buffer)
re_comp_buf.newline_anchor = 1;
ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf);
-
+
if (!ret)
return NULL;
int
regcomp (preg, pattern, cflags)
regex_t *preg;
- const char *pattern;
+ const char *pattern;
int cflags;
{
reg_errcode_t ret;
preg->buffer = 0;
preg->allocated = 0;
preg->used = 0;
-
+
/* Don't bother to use a fastmap when searching. This simplifies the
REG_NEWLINE case: if we used a fastmap, we'd have to put all the
characters after newlines into the fastmap. This way, we just try
every character. */
preg->fastmap = 0;
-
+
if (cflags & REG_ICASE)
{
unsigned i;
-
+
preg->translate = (char *) malloc (CHAR_SET_SIZE);
if (preg->translate == NULL)
return (int) REG_ESPACE;
preg->no_sub = !!(cflags & REG_NOSUB);
- /* POSIX says a null character in the pattern terminates it, so we
+ /* POSIX says a null character in the pattern terminates it, so we
can use strlen here in compiling the pattern. */
ret = regex_compile (pattern, strlen (pattern), syntax, preg);
-
+
/* POSIX doesn't distinguish between an unmatched open-group and an
unmatched close-group: both are REG_EPAREN. */
if (ret == REG_ERPAREN) ret = REG_EPAREN;
-
+
return (int) ret;
}
/* regexec searches for a given pattern, specified by PREG, in the
string STRING.
-
+
If NMATCH is zero or REG_NOSUB was set in the cflags argument to
`regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at
least NMATCH elements, and we set them to the offsets of the
corresponding matched substrings.
-
+
EFLAGS specifies `execution flags' which affect matching: if
REG_NOTBOL is set, then ^ does not match at the beginning of the
string; if REG_NOTEOL is set, then $ does not match at the end.
-
+
We return 0 if we find a match and REG_NOMATCH if not. */
int
regexec (preg, string, nmatch, pmatch, eflags)
const regex_t *preg;
- const char *string;
- size_t nmatch;
- regmatch_t pmatch[];
+ const char *string;
+ size_t nmatch;
+ regmatch_t pmatch[];
int eflags;
{
int ret;
boolean want_reg_info = !preg->no_sub && nmatch > 0;
private_preg = *preg;
-
+
private_preg.not_bol = !!(eflags & REG_NOTBOL);
private_preg.not_eol = !!(eflags & REG_NOTEOL);
-
+
/* The user has told us exactly how many registers to return
information about, via `nmatch'. We have to pass that on to the
matching routines. */
private_preg.regs_allocated = REGS_FIXED;
-
+
if (want_reg_info)
{
regs.num_regs = nmatch;
ret = re_search (&private_preg, string, len,
/* start: */ 0, /* range: */ len,
want_reg_info ? ®s : (struct re_registers *) 0);
-
+
/* Copy the register information to the POSIX structure. */
if (want_reg_info)
{
if (errcode < 0
|| errcode >= (sizeof (re_error_msgid) / sizeof (re_error_msgid[0])))
- /* Only error codes returned by the rest of the code should be passed
+ /* Only error codes returned by the rest of the code should be passed
to this routine. If we are given anything else, or if other regex
code generates an invalid error code, then the program has a bug.
Dump core so we can fix it. */
msg = gettext (re_error_msgid[errcode]);
msg_size = strlen (msg) + 1; /* Includes the null. */
-
+
if (errbuf_size != 0)
{
if (msg_size > errbuf_size)
if (preg->buffer != NULL)
free (preg->buffer);
preg->buffer = NULL;
-
+
preg->allocated = 0;
preg->used = 0;
#define RE_BACKSLASH_ESCAPE_IN_LISTS (1)
/* If this bit is not set, then + and ? are operators, and \+ and \? are
- literals.
+ literals.
If set, then \+ and \? are operators and + and ? are literals. */
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
^ is an anchor if it is at the beginning of a regular
expression or after an open-group or an alternation operator;
$ is an anchor if it is at the end of a regular expression, or
- before a close-group or an alternation operator.
+ before a close-group or an alternation operator.
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
POSIX draft 11.2 says that * etc. in leading positions is undefined.
/* If this bit is set, then special characters are always special
regardless of where they are in the pattern.
If this bit is not set, then special characters are special only in
- some contexts; otherwise they are ordinary. Specifically,
+ some contexts; otherwise they are ordinary. Specifically,
* + ? and intervals are only special when not after the beginning,
open-group, or alternation operator. */
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
/* If this bit is set, either \{...\} or {...} defines an
- interval, depending on RE_NO_BK_BRACES.
+ interval, depending on RE_NO_BK_BRACES.
If not set, \{, \}, {, and } are literals. */
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
If not set, then \<digit> is a back-reference. */
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
-/* If this bit is set, then | is an alternation operator, and \| is literal.
+/* If this bit is set, then | is an alternation operator, and \| is literal.
If not set, then \| is an alternation operator, and | is literal. */
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
\f
/* Define combinations of the above bits for the standard possibilities.
(The [[[ comments delimit what gets put into the Texinfo file, so
- don't delete them!) */
+ don't delete them!) */
/* [[[begin syntaxes]]] */
#define RE_SYNTAX_EMACS 0
#ifdef RE_DUP_MAX
#undef RE_DUP_MAX
#endif
-#define RE_DUP_MAX ((1 << 15) - 1)
+#define RE_DUP_MAX ((1 << 15) - 1)
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
/* If this bit is set, then ignore case when matching.
If not set, then case is significant. */
#define REG_ICASE (REG_EXTENDED << 1)
-
+
/* If this bit is set, then anchors do not match at newline
characters in the string.
If not set, then anchors do match at newlines. */
REG_EESCAPE, /* Trailing backslash. */
REG_ESUBREG, /* Invalid back reference. */
REG_EBRACK, /* Unmatched left bracket. */
- REG_EPAREN, /* Parenthesis imbalance. */
+ REG_EPAREN, /* Parenthesis imbalance. */
REG_EBRACE, /* Unmatched \{. */
REG_BADBR, /* Invalid contents of \{\}. */
REG_ERANGE, /* Invalid range end. */
unsigned long allocated;
/* Number of bytes actually used in `buffer'. */
- unsigned long used;
+ unsigned long used;
/* Syntax setting with which the pattern was compiled. */
reg_syntax_t syntax;
unsigned no_sub : 1;
/* If set, a beginning-of-line anchor doesn't match at the
- beginning of the string. */
+ beginning of the string. */
unsigned not_bol : 1;
/* Similarly for an end-of-line anchor. */
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
-extern int re_match_2
+extern int re_match_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
int start, struct re_registers *regs, int stop));
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
/* Panel managing.
Copyright (C) 1994, 1995 Miguel de Icaza.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#endif
#ifndef PORT_HAS_PANEL_RESET_SORT_LABELS
-# define x_reset_sort_labels(x)
+# define x_reset_sort_labels(x)
#endif
/* This macro extracts the number of available lines in a panel */
delete_format (format_e *format)
{
format_e *next;
-
+
while (format){
next = format->next;
free (format);
add_permission_string (char *dest, int width, file_entry *fe, int attr, int color, int is_octal)
{
int i, r, l;
-
+
l = get_user_rights (&fe->buf);
-
+
if (is_octal){
/* Place of the access bit in octal mode */
l = width + l - 3;
l = l * 3 + 1;
r = l + 3;
}
-
+
for(i = 0; i < width; i++){
if (i >= l && i < r){
if (attr == SELECTED || attr == MARKED_SELECTED)
attrset (MARKED_COLOR);
} else
attrset (color);
-
+
addch (dest[i]);
}
}
#ifdef HAVE_ST_RDEV
if (S_ISBLK (fe->buf.st_mode) || S_ISCHR (fe->buf.st_mode))
- sprintf (buffer, "%3d,%3d", (int) (fe->buf.st_rdev >> 8),
+ sprintf (buffer, "%3d,%3d", (int) (fe->buf.st_rdev >> 8),
(int) (fe->buf.st_rdev & 0xff));
else
-#endif
- {
+#endif
+ {
sprintf (buffer, "%lu", (unsigned long) fe->buf.st_size);
if (len && (i = strlen (buffer)) > len) {
if (i - 2 > len) {
file_compute_color (int attr, file_entry *fe)
{
int color;
-
+
switch (attr){
case SELECTED:
color = SELECTED_COLOR;
char *cdest = dest;
format_e *format, *home;
file_entry *fe;
-
+
length = 0;
empty_line = (file_index >= panel->count);
- home = (isstatus) ? panel->status_format : panel->format;
+ home = (isstatus) ? panel->status_format : panel->format;
fe = &panel->dir.list [file_index];
if (!empty_line)
for (format = home; format; format = format->next){
if (format->string_fn){
int len;
-
+
if (empty_line)
txt = " ";
else
/* What shall we do? Will we color each line according to
* the file type? Any suggestions to mc@timur.kazan.su
*/
-
+
attrset (color);
-
+
if (permission_mode && !strcmp(format->id, "perm"))
add_permission_string (old_pos, format->field_len, fe, attr, color, 0);
else if (permission_mode && !strcmp(format->id, "mode"))
length++;
}
}
-
+
if (length < width){
int still = width - length;
while (still--)
offset = 0;
if (!isstatus && panel->split){
-
+
second_column = (file_index - panel->top_file) / llines (panel);
width = (panel->widget.cols - 2)/2 - 1;
-
+
if (second_column){
offset = 1 + width;
width = (panel->widget.cols-2) - (panel->widget.cols-2)/2 - 1;
- }
+ }
} else
width = (panel->widget.cols - 2);
} else
widget_move (&panel->widget, file_index - panel->top_file + 2, 1);
}
-
+
format_file (buffer, panel, file_index, width, attr, isstatus);
-
+
if (!isstatus && panel->split){
if (second_column)
addch (' ');
{
if (!show_mini_info)
return;
-
+
widget_move (&panel->widget, llines (panel)+3, 1);
-
+
if (panel->searching){
attrset (INPUT_COLOR);
printw ("/%-*s", panel->widget.cols-3, panel->search_buffer);
if (panel->marked){
char buffer [100];
char *p;
-
+
attrset (MARKED_COLOR);
printw ("%*s", panel->widget.cols-2, " ");
widget_move (&panel->widget, llines (panel)+3, 1);
/* Status resolves links and show them */
set_colors (panel);
-#ifndef OS2_NT
+#ifndef OS2_NT
if (S_ISLNK (panel->dir.list [panel->selected].buf.st_mode)){
char *link, link_target [MC_MAXPATHLEN];
int len;
link_target[len] = 0;
printw ("-> %-*s", panel->widget.cols - 5,
name_trunc (link_target, panel->widget.cols - 5));
- } else
+ } else
addstr (_("<readlink failed>"));
return;
}
int items; /* Number of items */
items = llines (panel) * (panel->split ? 2 : 1);
-
+
for (i = 0; i < items; i++){
if (i+panel->top_file >= panel->count)
color = 0;
color = 2 * (panel->dir.list [i+panel->top_file].f.marked);
color += (panel->selected==i+panel->top_file && panel->active);
}
- repaint_file (panel, i+panel->top_file, 1, color, 0);
+ repaint_file (panel, i+panel->top_file, 1, color, 0);
}
standend ();
panel->dirty = 0;
{
if (!show_mini_info)
return;
-
+
standend ();
widget_move (&panel->widget, llines (panel)+2, 1);
#ifdef HAVE_SLANG
#else
hline ((slow_terminal ? '-' : ACS_HLINE) | NORMAL_COLOR,
panel->widget.cols-2);
-#endif
+#endif
}
void
panel->widget.y, panel->widget.x,
panel->widget.lines, panel->widget.cols);
-#ifdef HAVE_SLANG
+#ifdef HAVE_SLANG
if (show_mini_info) {
#ifdef linux_unicode
if (SLtt_Unicode) {
- SLsmg_draw_unicode (panel->widget.y + llines (panel) + 2,
+ SLsmg_draw_unicode (panel->widget.y + llines (panel) + 2,
panel->widget.x, SLUNI_DSLTEE_CHAR);
- SLsmg_draw_unicode (panel->widget.y + llines (panel) + 2,
+ SLsmg_draw_unicode (panel->widget.y + llines (panel) + 2,
panel->widget.x + panel->widget.cols - 1, SLUNI_DSRTEE_CHAR);
} else
#endif /* linux_unicode */
}
}
#endif /* have_slang */
-
+
if (panel->active)
attrset (REVERSE_COLOR);
addstr (">");
widget_move (&panel->widget, 0, panel->widget.cols-3);
addstr ("v");
-
+
if (panel->active)
standend ();
}
adjust_top_file (WPanel *panel)
{
int old_top = panel->top_file;
-
+
if (panel->selected - old_top > llines (panel))
panel->top_file = panel->selected;
if (old_top - panel->count > llines (panel))
{
int i;
char *subdir;
-
+
if (!name){
panel->selected = 0;
panel->top_file = 0;
}
if (subdir < name)
subdir = name;
-
+
/* Search that subdirectory, if found select it */
for (i = 0; i < panel->count; i++){
if (strcmp (subdir, panel->dir.list [i].fname))
panel_update_cols (Widget *widget, int frame_size)
{
int cols, origin;
-
+
if (horizontal_split){
widget->cols = COLS;
return;
origin = first_panel_size;
}
}
-
+
widget->cols = cols;
widget->x = origin;
}
panel_save_name (WPanel *panel)
{
extern int saving_setup;
-
+
/* If the program is shuting down */
if ((midnight_shutdown && auto_save_setup) || saving_setup)
return copy_strings (panel->panel_name, 0);
panel_save_setup (p, name);
x_panel_destroy (p);
clean_dir (&p->dir, p->count);
-
+
/* save and clean history */
if (p->dir_history){
Hist *current, *old;
delete_format (p->format);
delete_format (p->status_format);
-
+
free (p->user_format);
for (i = 0; i < LIST_TYPES; i++)
free (p->user_status_format [i]);
panel = xmalloc (sizeof (WPanel), "panel_new");
memset (panel, 0, sizeof (WPanel));
-
+
/* No know sizes of the panel at startup */
init_widget (&panel->widget, 0, 0, 0, 0, (callback_fn)
panel_callback, (destroy_fn) panel_destroy,
/* We do not want the cursor */
widget_want_cursor (panel->widget, 0);
-
+
mc_get_current_wd (panel->cwd, sizeof (panel->cwd)-2);
strcpy (panel->lwd, ".");
panel->is_panelized = 0;
panel->has_dir_sizes = 0;
panel->format = 0;
- panel->status_format = 0;
+ panel->status_format = 0;
panel->format_modified = 1;
-
+
panel->panel_name = strdup (panel_name);
panel->user_format = strdup (DEFAULT_USER_FORMAT);
-
+
for(i = 0; i < LIST_TYPES; i++)
panel->user_status_format [i] = strdup (DEFAULT_USER_FORMAT);
-
+
panel->search_buffer [0] = 0;
panel->frame_size = frame_half;
section = copy_strings ("Temporal:", panel->panel_name, 0);
}
set_panel_formats (panel);
}
-
+
/* Load the default format */
panel->count = do_load_dir (&panel->dir, panel->sort_type,
panel->reverse, panel->case_sensitive, panel->filter);
bzero (&(panel->dir_stat), sizeof (panel->dir_stat));
show_dir (panel);
}
-
+
panel->count = do_reload_dir (&panel->dir, panel->sort_type, panel->count,
panel->reverse, panel->case_sensitive, panel->filter);
panel->marked = 0;
int header_len;
int spaces, extra;
int side, width;
-
+
char *txt, buffer[30]; /*Hope that this is enough ;-) */
if (!panel->split)
adjust_top_file (panel);
-
+
widget_erase (&panel->widget);
show_dir (panel);
for (side = 0; side <= panel->split; side++){
format_e *format;
-
+
if (side){
attrset (NORMAL_COLOR);
one_vline ();
width = panel->widget.cols/2 - 3;
else
width = panel->widget.cols - 2;
-
+
for (format = panel->format; format; format = format->next){
if (format->string_fn){
txt = format->title;
-
+
header_len = strlen (txt);
if (header_len > format->field_len){
strcpy (buffer, txt);
txt [format->field_len] = 0;
header_len = strlen (txt);
}
-
+
attrset (MARKED_COLOR);
spaces = (format->field_len - header_len) / 2;
extra = (format->field_len - header_len) % 2;
continue;
}
}
-
+
if (width > 0)
printw ("%*s", width, "");
}
panel->frame_size = frame;
panel->split = 0;
}
-
+
/* Now, the optional column specifier */
format = skip_separators (format);
-
+
if (*format == '1' || *format == '2'){
if (!isstatus)
panel->split = *format == '2';
if (!isstatus)
panel_update_cols (&(panel->widget), panel->frame_size);
-
+
return skip_separators (format);
}
opt_size := : size [opt_expand]
size := [0-9]+
opt_expand := +
-
+
*/
format_e *
int i;
*error = 0;
-
+
/*
* This makes sure that the panel and mini status full/half mode
* setting is equal
int found = 0;
darr = xmalloc (sizeof (format_e), "parse_display_format");
-
+
/* I'm so ugly, don't look at me :-) */
if (!home)
home = old = darr;
-
+
old->next = darr;
darr->next = 0;
old = darr;
-
+
format = skip_separators (format);
if (*format == '<' || *format == '>'){
format = skip_separators (format+1);
} else
set_justify = 0;
-
+
for (i = 0; i < ELEMENTS(formats); i++){
int klen = strlen (formats [i].id);
darr->title = "";
darr->id = formats [i].id;
darr->expand = formats [i].expands;
-
+
if (set_justify)
darr->just_mode = justify;
else
}
if (!found){
char old_char;
-
+
int pos = min (8, strlen (format));
delete_format (home);
old_char = format [pos];
}
total_cols += darr->requested_field_len;
}
-
+
*res_total_cols = total_cols;
if (home)
home->items = items;
char *expand_list [MAX_EXPAND]; /* Expand at most 4 fields. */
int i;
format_e *darr, *home;
-
+
if (!format)
format = DEFAULT_USER_FORMAT;
-
+
home = parse_display_format (panel, format, error, isstatus, &total_cols);
if (*error)
return 0;
-
+
/* Status needn't to be split */
usable_columns = ((panel->widget.cols-2)/((isstatus)
? 1
: (panel->split+1))) - (!isstatus && panel->split);
-
+
/* Clean expand list */
for (i = 0; i < MAX_EXPAND; i++)
expand_list [i] = '\0';
-
-
+
+
/* Look for the expandable fields and set field_len based on the requested field len */
for (darr = home; darr && expand_top < MAX_EXPAND; darr = darr->next){
darr->field_len = darr->requested_field_len;
if (darr->expand)
expand_list [expand_top++] = darr->id;
}
-
+
/* If we used more columns than the available columns, adjust that */
if (total_cols > usable_columns){
int pdif, dif = total_cols - usable_columns;
-
+
while (dif){
pdif = dif;
for (darr = home; darr; darr = darr->next){
/* avoid endless loop if num fields > 40 */
if (pdif == dif)
- break;
+ break;
}
total_cols = usable_columns; /* give up, the rest should be truncated */
}
set_panel_formats (WPanel *p)
{
format_e *form;
- char *err;
+ char *err;
int retcode = 0;
-
+
form = use_display_format (p, panel_format (p), &err, 0);
-
+
if (err){
free (err);
retcode = 1;
else {
if (p->format)
delete_format (p->format);
-
+
p->format = form;
}
-
+
if (show_mini_info){
-
+
form = use_display_format (p, mini_status_format (p), &err, 1);
-
+
if (err){
free (err);
retcode += 2;
else {
if (p->status_format)
delete_format (p->status_format);
-
+
p->status_format = form;
}
}
-
+
panel_format_modified (p);
panel_update_cols (&(p->widget), p->frame_size);
-
+
return retcode;
}
{
int repaint = 0;
int items = ITEMS (panel);
-
+
/* Although currently all over the code we set the selection and
top file to decent values before calling select_item, I could
forget it someday, so it's better to do the actual fitting here */
int old_top;
old_top = panel->top_file;
#endif
-
+
if (panel->top_file < 0){
repaint = 1;
panel->top_file = 0;
repaint = 1;
panel->top_file = panel->count-1;
}
-
+
if ((panel->count - panel->top_file) < items){
repaint = 1;
panel->top_file = panel->count - items;
if (panel->top_file < 0)
panel->top_file = 0;
}
-
+
if (panel->selected < panel->top_file){
repaint = 1;
panel->top_file = panel->selected;
panel->top_file = panel->selected - items + 1;
}
-#ifndef HAVE_X
+#ifndef HAVE_X
if (repaint)
paint_panel (panel);
else
{
if (panel->selected+1 == panel->count)
return;
-
+
unselect_item (panel);
panel->selected++;
move_rel (WPanel *panel, int rel)
{
unselect_item (panel);
-
+
if (rel < 0){
if (panel->selected + rel < 0)
panel->selected = 0;
panel->top_file += lines;
adjust = 1;
}
-
+
if (panel->selected - panel->top_file < 0){
panel->top_file += lines;
adjust = 1;
}
-
+
if (adjust){
if (panel->top_file > panel->selected)
panel->top_file = panel->selected;
if (panel->list_type == list_icons){
do_move_up (panel);
return 1;
- } else {
+ } else {
if (panel->split){
move_selection (panel, -llines (panel));
return 1;
- } else
+ } else
return maybe_cd (c_code, 0);
}
}
if (panel->selected == 0)
return;
unselect_item (panel);
-
+
if (torben_fj_mode){
int middle_pos = panel->top_file + (ITEMS (panel)/2);
return;
}
}
-
+
panel->top_file = 0;
panel->selected = 0;
return;
}
}
-
+
panel->selected = panel->count-1;
#ifndef HAVE_X
paint_dir (panel);
if (panel->has_dir_sizes)
panel->total += panel->dir.list [idx].buf.st_size;
panel->dirs_marked++;
- } else
+ } else
panel->total += panel->dir.list [idx].buf.st_size;
-#ifndef HAVE_XVIEW
+#ifndef HAVE_XVIEW
set_colors (panel);
#endif
} else {
int i, mark;
mark = !panel->dir.list [start].f.marked;
-
+
for (i = start; i < end; i++)
do_file_mark (panel, i, mark);
}
{
int idx = panel->selected;
do_file_mark (panel, idx, selection (panel)->f.marked ? 0 : 1);
-#ifndef HAVE_XVIEW
+#ifndef HAVE_XVIEW
repaint_file (panel, idx, 1, 2*panel->dir.list [idx].f.marked+1, 0);
-#endif
+#endif
if (mark_moves_down && do_move)
move_down (panel);
}
if (!found)
panel->search_buffer [--l] = 0;
-#ifndef HAVE_X
+#ifndef HAVE_X
paint_panel (panel);
#endif
}
|| link_isdir (selection (panel))){
do_cd (selection (panel)->fname, cd_exact);
return;
- } else {
+ } else {
if (is_exe (selection (panel)->buf.st_mode) &&
if_link_is_exe (selection (panel))) {
-#ifdef USE_VFS
- if (vfs_current_is_local ())
-#endif
+#ifdef USE_VFS
+ if (vfs_current_is_local ())
+#endif
{
char *tmp = name_quote (selection (panel)->fname, 0);
char *cmd = copy_strings (".", PATH_SEP_STR, tmp, 0);
execute (cmd);
free (tmp);
free (cmd);
- }
-#ifdef USE_VFS
+ }
+#ifdef USE_VFS
else if (vfs_current_is_extfs ()) {
char *tmp = vfs_get_current_dir();
char *tmp2;
extfs_run(tmp2);
free (tmp2);
}
-#endif /* USE_VFS */
+#endif /* USE_VFS */
return;
} else {
regex_command (selection (panel)->fname, "Open", NULL, 0);
change_panel ();
move_down (panel);
-
+
free (new_dir);
}
char buffer [MC_MAXPATHLEN], *p;
int i;
struct stat mybuf;
-
+
i = readlink (selection (panel)->fname, buffer, MC_MAXPATHLEN);
if (i < 0)
return;
change_panel ();
do_cd (new_dir, cd_exact);
change_panel ();
-
+
move_down (panel);
-
+
free (new_dir);
}
}
{ ALT(KEY_F(12)), drive_cmd_b },
{ ALT('d'), drive_chg },
#endif
-
+
/* Emacs-like bindings */
{ XCTRL('v'), next_page }, /* C-v like emacs */
{ ALT('v'), prev_page }, /* M-v like emacs */
{ KEY_KP_SUBTRACT, unselect_cmd_panel },
{ ALT('*'), reverse_selection_cmd_panel },
{ KEY_KP_MULTIPLY, reverse_selection_cmd_panel },
-
+
#ifdef HAVE_GNOME
{ '+', select_cmd_panel },
{ KEY_F(7), mkdir_panel_cmd },
{ KEY_F(8), delete_cmd },
#endif
-
+
{ 0, 0 }
};
-
+
static inline int
panel_key (WPanel *panel, int key)
{
define_label (h, (Widget *)panel, 7, _("Mkdir"), mkdir_panel_cmd);
define_label (h, (Widget *)panel, 8, _("Delete"), delete_cmd);
x_create_panel (h, h->wdata, panel);
-#endif
+#endif
return 1;
-
+
case WIDGET_DRAW:
#ifndef HAVE_XVIEW
paint_panel (panel);
#else
- show_dir (panel);
+ show_dir (panel);
#endif
break;
panel->cwd, unix_error_string (errno));
} else
subshell_chdir (panel->cwd);
-
+
show_dir (panel);
focus_select_item (panel);
-#ifndef HAVE_X
+#ifndef HAVE_X
define_label (h, (Widget *)panel, 1, _("Help"), help_cmd);
define_label (h, (Widget *)panel, 2, _("Menu"), user_menu_cmd);
define_label (h, (Widget *)panel, 3, _("View"), view_panel_cmd);
/* Chain behaviour */
default_proc (h, WIDGET_FOCUS, par);
return 1;
-
+
case WIDGET_UNFOCUS:
/* Janne: look at this for the multiple panel options */
if (panel->searching){
panel->searching = 0;
display_mini_info (panel);
}
-#ifdef HAVE_X
+#ifdef HAVE_X
show_dir (panel);
unfocus_unselect_item (panel);
panel->active = 0;
unselect_item (panel);
#endif
return 1;
-
+
case WIDGET_KEY:
return panel_key (panel, par);
break;
panel_event (Gpm_Event *event, WPanel *panel)
{
const int lines = panel->count;
-
+
int my_index;
extern void change_panel (void);
if (my_index >= panel->count)
my_index = panel->count - 1;
-
+
if (my_index != panel->selected){
unselect_item (panel);
panel->selected = my_index;
/* This one is new */
mark_if_marking (panel, event);
-
+
} else if ((event->type & (GPM_UP|GPM_DOUBLE)) == (GPM_UP|GPM_DOUBLE)){
if (event->y > 0 && event->y <= lines)
do_enter (panel);
panel_event (Gpm_Event *event, WPanel *panel)
{
const int lines = llines (panel);
-
+
int my_index;
extern void change_panel (void);
if (my_index >= panel->count)
my_index = panel->count - 1;
-
+
if (my_index != panel->selected){
unselect_item (panel);
panel->selected = my_index;
/* This one is new */
mark_if_marking (panel, event);
-
+
} else if ((event->type & (GPM_UP|GPM_DOUBLE)) == (GPM_UP|GPM_DOUBLE)){
if (event->y > 0 && event->y <= lines)
do_enter (panel);
/* Setup loading/saving.
Copyright (C) 1994 Miguel de Icaza
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
extern int ftpfs_use_unix_list_options;
#endif
-/* "$Id: setup.c,v 1.1 2001/12/30 09:55:21 sedwards Exp $" */
+/* "$Id$" */
#ifdef USE_VFS
extern int vfs_timeout;
{ "tree", view_tree },
{ 0, 0 }
};
-
+
static struct {
char *opt_name;
int *opt_addr;
(follow links, stable symlinks) -Norbert */
{ "tree_navigation_flag", &tree_navigation_flag },
#endif
-#ifdef USE_VFS
+#ifdef USE_VFS
{ "tar_gzipped_memlimit", &tar_gzipped_memlimit },
{ "vfs_timeout", &vfs_timeout },
{ "vfs_use_targz_memlimit", &vfs_use_limit },
{
char buffer [40];
int i;
-
+
sprintf (buffer, "%d", panel->reverse);
save_string (section, "reverse", buffer, profile_name);
sprintf (buffer, "%d", panel->case_sensitive);
save_string (section, PORT_LIST_MODE_NAME, list_types [i].key, profile_name);
break;
}
-
+
save_string (section, "user_format",
panel->user_format, profile_name);
-
+
for (i = 0; i < LIST_TYPES; i++){
sprintf (buffer, "user_status%d", i);
- save_string (section, buffer,
+ save_string (section, buffer,
panel->user_status_format [i], profile_name);
}
-
+
sprintf (buffer, "%d", panel->user_mini_status);
save_string (section, "user_mini_status", buffer,
profile_name);
static void panel_save_type (char *section, int type)
{
int i;
-
+
for (i = 0; panel_types [i].opt_name; i++)
if (panel_types [i].opt_type == type){
save_string (section, "display", panel_types [i].opt_name,
save_panelize ();
save_panel_types ();
/* directory_history_save (); */
-
+
#ifdef USE_VFS
#ifdef USE_NETCODE
WritePrivateProfileString ("Misc", "ftpfs_password",
{
int i;
char buffer [40];
-
+
panel->reverse = load_int (section, "reverse", 0);
panel->case_sensitive = load_int (section, "case_sensitive", OS_SORT_CASE_SENSITIVE_DEFAULT);
-
+
/* Load sort order */
load_string (section, "sort_order", "name", buffer, sizeof (buffer));
panel->sort_type = (sortfn *) sort_name;
strdup (get_profile_string (section, buffer,
DEFAULT_USER_FORMAT, profile_name));
}
-
+
panel->user_mini_status =
load_int (section, "user_mini_status", 0);
static void load_layout (char *profile_name)
{
int i;
-
+
for (i = 0; layout [i].opt_name; i++)
*layout [i].opt_addr =
load_int ("Layout", layout [i].opt_name,
{
char buffer [20];
int i;
-
+
int mode = view_listing;
-
+
/* Load the display mode */
load_string (section, "display", "listing", buffer, sizeof (buffer));
{
char *buffer = xmalloc (128, "dls");
char *p;
-
+
load_string (s, ss, def, buffer, 128);
p = strdup (buffer);
profile = buffer;
}
free (inifile);
-
+
profile_name = profile;
/* Load integer boolean options */
/* At least one of the panels is a listing panel */
if (startup_left_mode != view_listing && startup_right_mode!=view_listing)
startup_left_mode = view_listing;
-
+
if (!other_dir){
buffer = (char*) malloc (MC_MAXPATHLEN);
load_string ("Dirs", "other_dir", ".", buffer,
#endif
boot_current_is_left =
GetPrivateProfileInt ("Dirs", "current_is_left", 1, profile);
-
+
load_string ("Misc", "find_ignore_dirs", "", setup_color_string,
sizeof (setup_color_string));
if (setup_color_string [0])
find_ignore_dirs = copy_strings (":", setup_color_string, ":", 0);
-
+
/* The default color and the terminal dependent color */
load_string ("Colors", "base_color", "", setup_color_string,
sizeof (setup_color_string));
free (section_name);
return;
}
-
+
while (profile_keys){
profile_keys = profile_iterator_next (profile_keys, &key, &value);
key_code = lookup_key (key);
/* Slang interface to the Midnight Commander
This emulates some features of ncurses on top of slang
-
+
Copyright (C) 1995, 1996 The Free Software Foundation.
Author Miguel de Icaza
Norbert Warmuth
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
{
unsigned int imax;
unsigned int ch;
-
+
if (SLang_Input_Buffer_Len)
{
ch = (unsigned int) *SLang_Input_Buffer;
SLang_Input_Buffer_Len--;
imax = SLang_Input_Buffer_Len;
-
- memcpy ((char *) SLang_Input_Buffer,
+
+ memcpy ((char *) SLang_Input_Buffer,
(char *) (SLang_Input_Buffer + 1), imax);
return(ch);
}
int n;
unsigned char c;
if (SLang_Input_Buffer_Len) return (int) SLang_Input_Buffer_Len;
-#if SLANG_VERSION >= 10000
+#if SLANG_VERSION >= 10000
n = _SLsys_input_pending (tsecs);
#else
n = SLsys_input_pending (tsecs);
#endif
if (n <= 0) return 0;
-
+
c = (unsigned char) SLang_getkey2 ();
SLang_ungetkey_string (&c, 1);
-
+
return n;
}
/* }}} */
enable_interrupt_key(void)
{
struct sigaction act;
-
+
act.sa_handler = slang_intr;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
disable_interrupt_key(void)
{
struct sigaction act;
-
+
act.sa_handler = SIG_IGN;
act.sa_flags = 0;
sigemptyset (&act.sa_mask);
extern int SLtt_Has_Alt_Charset;
extern int force_ugly_line_drawing;
struct sigaction act, oact;
-
+
SLtt_get_terminfo ();
tcgetattr (fileno (stdin), &boot_mode);
/* 255 = ignore abort char; XCTRL('g') for abort char = ^g */
- SLang_init_tty (XCTRL('c'), 1, 0);
-
+ SLang_init_tty (XCTRL('c'), 1, 0);
+
/* If SLang uses fileno(stderr) for terminal input MC will hang
if we call SLang_getkey between calls to open_error_pipe and
close_error_pipe, e.g. when we do a growing view of an gzipped
slang_shutdown ()
{
char *op_cap;
-
+
slang_shell_mode ();
do_exit_ca_mode ();
SLang_reset_tty ();
/* HP Terminals have capabilities (pfkey, pfloc, pfx) to program function keys.
elm 2.4pl15 invoked with the -K option utilizes these softkeys and the
- consequence is that function keys don't work in MC sometimes.
- Unfortunately I don't now the one and only escape sequence to turn off
- softkeys (elm uses three different capabilities to turn on softkeys and two
- capabilities to turn them off).
- Among other things elm uses the pair we already use in slang_keypad. That's
+ consequence is that function keys don't work in MC sometimes.
+ Unfortunately I don't now the one and only escape sequence to turn off
+ softkeys (elm uses three different capabilities to turn on softkeys and two
+ capabilities to turn them off).
+ Among other things elm uses the pair we already use in slang_keypad. That's
the reason why I call slang_reset_softkeys from slang_keypad. In lack of
something better the softkeys are programmed to their defaults from the
termcap/terminfo database.
- The escape sequence to program the softkeys is taken from elm and it is
- hardcoded because neither slang nor ncurses 4.1 know how to 'printf' this
+ The escape sequence to program the softkeys is taken from elm and it is
+ hardcoded because neither slang nor ncurses 4.1 know how to 'printf' this
sequence. -- Norbert
- */
-
+ */
+
void
slang_reset_softkeys (void)
{
char *send;
char *display = " ";
char tmp[100];
-
+
for ( key = 1; key < 9; key++ ) {
sprintf ( tmp, "k%d", key);
send = (char *) SLtt_tgetstr (tmp);
{
char *keypad_string;
extern int reset_hp_softkeys;
-
+
keypad_string = (char *) SLtt_tgetstr (set ? "ks" : "ke");
if (keypad_string)
SLtt_write_string (keypad_string);
last_x = SLsmg_get_column ();
last_y = SLsmg_get_row ();
-
+
if (ch == 0)
ch = ACS_HLINE;
}
}
}
-
+
/* Setup emulated colors */
if (SLtt_Use_Ansi_Colors){
if (use_colors){
init_pair (A_REVERSE, "black", "lightgray");
init_pair (A_BOLD, "white", "black");
init_pair (A_BOLD_REVERSE, "white", "lightgray");
- }
+ }
} else {
SLtt_set_mono (A_BOLD, NULL, SLTT_BOLD_MASK);
SLtt_set_mono (A_REVERSE, NULL, SLTT_REV_MASK);
SLsmg_set_color (color);
return;
}
-
+
if (color & A_BOLD){
if (color == A_BOLD)
SLsmg_set_color (A_BOLD);
{ KEY_F(17), "F7" },
{ KEY_F(18), "F8" },
{ KEY_F(19), "F9" },
- { KEY_F(20), "FA" },
+ { KEY_F(20), "FA" },
{ KEY_IC, "kI" },
{ KEY_NPAGE, "kN" },
{ KEY_PPAGE, "kP" },
{ KEY_END, "@7" },
{ 0, 0}
};
-
+
void
do_define_key (int code, char *strcap)
{
/* {{{ Declarations */
-#include <stdio.h>
+#include <stdio.h>
#include <stdlib.h> /* For errno, putenv, etc. */
#include <errno.h> /* For errno on SunOS systems */
#include <termios.h> /* tcgetattr(), struct termios, etc. */
/* Braindead tcsh can't redirect output to a file descriptor? */
char tcsh_fifo[sizeof "/tmp/mc.pipe.1234567890"];
-
+
#ifdef SYNC_PTY_SIDES
/* Used to wait for a SIGUSR1 signal from the subprocess */
sigset_t sigusr1_mask, old_mask;
subshell_alive = TRUE;
subshell_stopped = FALSE;
subshell_pid = fork ();
-
+
if (subshell_pid == -1)
{
perror (__FILE__": couldn't spawn the subshell process");
if (subshell_pid == 0) /* We are in the child process */
{
char *init_file = NULL;
-
+
setsid (); /* Get a fresh terminal session */
/* {{{ Open the slave side of the pty: again */
init_sigchld ();
- /* We could have received the SIGCHLD signal for the subshell
+ /* We could have received the SIGCHLD signal for the subshell
* before installing the init_sigchld */
pid = waitpid (subshell_pid, &status, WUNTRACED | WNOHANG);
if (pid == subshell_pid){
/* {{{ Fiddle with terminal modes */
static struct termios raw_mode = {0};
-
+
/* MC calls reset_shell_mode() in pre_exec() to set the real tty to its */
/* original settings. However, here we need to make this tty very raw, */
/* so that all keyboard signals, XON/XOFF, etc. will get through to the */
tcsetattr (STDOUT_FILENO, TCSANOW, &raw_mode);
/* }}} */
-
+
/* Make the subshell change to MC's working directory */
if (new_dir)
do_subshell_chdir (cpanel->cwd, TRUE, 1);
-
+
if (command == NULL) /* The user has done "C-o" from MC */
{
if (subshell_state == INACTIVE)
clear_now = TRUE;
if (!pty_buffer [i])
continue;
-
+
subshell_prompt[prompt_pos++] = pty_buffer[i];
if (prompt_pos == prompt_size)
subshell_prompt = (char *) realloc (subshell_prompt,
int exit_subshell (void)
{
int quit = TRUE;
-
+
if (subshell_state != INACTIVE && subshell_alive)
quit = !query_dialog (_(" Warning "), _(" The shell is still active. Quit anyway? "),
0, 2, _("&Yes"), _("&No"));
if (unlink (pty_buffer) == -1)
perror (__FILE__": couldn't remove named pipe /tmp/mc.pipe.NNN");
}
-
+
return quit;
}
void do_subshell_chdir (char *directory, int do_update, int reset_prompt)
{
char *temp;
-
+
if (!(subshell_state == INACTIVE && strcmp (subshell_cwd, cpanel->cwd))){
/* We have to repaint the subshell prompt if we read it from
* the main program. Please note that in the code after this
do_update_prompt ();
return;
}
-
+
/* The initial space keeps this out of the command history (in bash
because we set "HISTCONTROL=ignorespace") */
write (subshell_pty, " cd ", 4);
if (*directory) {
temp = name_quote (directory, 0);
- write (subshell_pty, temp, strlen (temp));
+ write (subshell_pty, temp, strlen (temp));
free (temp);
} else {
write (subshell_pty, "/", 1);
}
write (subshell_pty, "\n", 1);
-
+
subshell_state = RUNNING_COMMAND;
feed_subshell (QUIETLY, FALSE);
-
+
if (subshell_alive && strcmp (subshell_cwd, cpanel->cwd) && strcmp (cpanel->cwd, "."))
fprintf (stderr, _("Warning: Couldn't change to %s.\n"), cpanel->cwd);
#ifndef HAVE_X
#ifndef SCO_FLAVOR
pid = waitpid (cons_saver_pid, &status, WUNTRACED | WNOHANG);
-
+
if (pid == cons_saver_pid) {
/* {{{ Someone has stopped or killed cons.saver; restart it */
fd_set read_set; /* For `select' */
int bytes; /* For the return value from `read' */
int i; /* Loop counter */
-
+
struct timeval wtime; /* Maximum time we wait for the subshell */
struct timeval *wptr;
/* }}} */
/* we wait up to 10 seconds if fail_on_error */
wtime.tv_sec = 10;
wtime.tv_usec = 0;
-
+
for (wptr = fail_on_error ? &wtime : NULL;;)
{
if (!subshell_alive)
/* From now on: block forever on the select call */
wptr = NULL;
-
+
if (FD_ISSET (subshell_pty, &read_set))
/* {{{ Read from the subshell, write to stdout */
{
int pty_slave;
struct group *group_info = getgrnam ("terminal");
-
+
if (group_info != NULL)
{
/* The following two calls will only succeed if we are root */
close (pty_slave);
return -1;
}
-
+
if (!ioctl (pty_slave, I_FIND, "ldterm"))
if (ioctl (pty_slave, I_PUSH, "ldterm") == -1)
{
/* Term name pollution avoiding.
Copyright (C) 1994 Miguel de Icaza
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* FIXME: Missing on slang endwin? */
reset_prog_mode ();
flushinp ();
-
+
keypad (stdscr, TRUE);
mc_raw_mode ();
channels_up ();
channels_down ();
if (use_mouse_p)
shut_mouse ();
-
+
reset_shell_mode ();
keypad (stdscr, FALSE);
endwin ();
-
+
numeric_keypad_mode ();
-
+
/* on xterms: maybe endwin did not leave the terminal on the shell
* screen page: do it now.
*
Written: 1994, 1996 Janne Kukonlehto
1997 Norbert Warmuth
1996 Miguel de Icaza
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
static int tree_callback (Dlg_head *h, WTree *tree, int msg, int par);
#define tcallback (callback_fn) tree_callback
-/* "$Id: tree.c,v 1.1 2001/12/30 09:55:21 sedwards Exp $" */
+/* "$Id$" */
/* Returns number of common characters */
static inline int str_common (char *s1, char *s2)
/etc.old/X11
/etc.old/rc.d
/usr
-
- i.e. the required collating sequence when comparing two directory names is
+
+ i.e. the required collating sequence when comparing two directory names is
'\0' < PATH_SEP < all-other-characters-in-encoding-order
-
+
Since strcmp doesn't fulfil this requirement we use pathcmp when
- inserting directory names into the list. The meaning of the return value
- of pathcmp and strcmp are the same (an integer less than, equal to, or
- greater than zero if p1 is found to be less than, to match, or be greater
+ inserting directory names into the list. The meaning of the return value
+ of pathcmp and strcmp are the same (an integer less than, equal to, or
+ greater than zero if p1 is found to be less than, to match, or be greater
than p2.
*/
int
for ( ;*p1 == *p2; p1++, p2++)
if (*p1 == '\0' )
return 0;
-
+
if (*p1 == '\0')
return -1;
if (*p2 == '\0')
if (!tree)
return 0;
-
+
if (tree->tree_last && tree->tree_last->next)
abort ();
#if 0
old = current;
current = current->next;
}
-
+
if (flag == 0)
return current; /* Already in the list */
if (name [0] == PATH_SEP && name [1] == 0)
return;
/* Miguel Ugly hack end */
-
+
base = whereis (tree, name);
if (!base)
return; /* Doesn't exist */
tree = (WTree *) find_widget_type (current_dlg, tcallback);
if (!tree)
return;
-
+
/* Search for the start of subdirectories */
mc_get_current_wd (tree->check_name, MC_MAXPATHLEN);
tree->check_start = NULL;
current = tree->check_start;
while (current && (flag = pathcmp (current->name, name)) < 0)
current = current->next;
-
+
if (flag != 0)
/* Doesn't exist -> add it */
current = tree_add_entry (tree, name);
tree = (WTree *) find_widget_type (current_dlg, tcallback);
if (!tree)
return;
-
+
/* Check delete marks and delete if found */
len = strlen (tree->check_name);
file = fopen (filename, "r");
free (filename);
}
-
+
if (file){
/* File open -> read contents */
oldname [0] = 0;
}
#ifdef OS2_NT
/* .ado: Drives for NT and OS/2 */
- if ((len > 2) &&
- isalpha(name[0]) &&
- (name[1] == ':') &&
+ if ((len > 2) &&
+ isalpha(name[0]) &&
+ (name[1] == ':') &&
(name[2] == '\\')) {
tree_add_entry (tree, name);
strcpy (oldname, name);
line = tree_lines+2;
} else
line = tree_lines+1;
-
+
widget_move (&tree->widget, line, 1);
hline (' ', tree_cols);
widget_move (&tree->widget, line, 1);
-
+
if (tree->searching){
/* Show search string */
attrset (TREE_NORMALC);
attrset (FOCUSC);
addch (PATH_SEP);
-
+
addstr (name_trunc (tree->search_buffer, tree_cols-2));
addch (' ');
attrset (FOCUSC);
tree->topdiff = 0;
}
current = tree->selected_ptr;
-
+
/* Calculate the directory which is to be shown on the topmost line */
if (tree_navigation_flag){
i = 0;
if (!current)
continue;
-
+
tree->tree_shown [i] = current;
if (current->sublevel == topsublevel){
addch (ACS_LTEE);
addch (ACS_HLINE);
noacs ();
-
+
if (tree->active && current == tree->selected_ptr)
/* Selected directory -> change color */
if (!use_colors && !tree->is_panel)
tree_cols - 2 - 4 - 3 * j));
}
addch (' ');
-
+
/* Return to normal color */
attrset (TREE_NORMALC);
{
tree_entry *current;
int j = 0;
-
+
if (tree_navigation_flag){
current = tree->selected_ptr;
while (j < i && current->prev
{
tree_entry *current;
tree_entry *old;
-
+
if (!tree->selected_ptr)
return 0;
old = tree->selected_ptr;
if (tree->is_panel)
event->y--;
-
+
event->y--;
if (!tree->active)
if (!search_tree (tree, tree->search_buffer))
tree->search_buffer [--l] = 0;
-
+
show_tree (tree);
maybe_chdir (tree);
}
if (!tree->selected_ptr || !mc_get_current_wd (old_dir, MC_MAXPATHLEN) ||
mc_chdir (tree->selected_ptr->name))
return;
-
+
start_tree_check (tree);
dirp = opendir (".");
if (dirp){
static int move_left (WTree *tree)
{
int v;
-
+
if (tree_navigation_flag){
v = tree_move_to_parent (tree);
show_tree (tree);
int i;
if (tree->searching){
-
+
if (tree->selected_ptr == tree->tree_last)
tree_move_to_top(tree);
else {
- /* set navigation mode temporarily to 'Static' because in
+ /* set navigation mode temporarily to 'Static' because in
* dynamic navigation mode tree_move_forward will not move
* to a lower sublevel if necessary (sequent searches must
* start with the directory followed the last found directory)
- */
+ */
i = tree_navigation_flag;
tree_navigation_flag = 0;
tree_move_forward (tree, 1);
if (tree->is_panel)
draw_double_box (h, tree->widget.y, tree->widget.x, tree->widget.lines,
tree->widget.cols);
-
+
if (show_mini_info && tree->is_panel){
widget_move (tree, tlines (tree) + 1, 1);
hline (ACS_HLINE, tree->widget.cols - 2);
case WIDGET_FOCUS:
tree->active = 1;
define_label (h, (Widget *)tree, 1, _("Help"), (voidfn) tree_help_cmd);
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
2, _("Rescan"), (buttonbarfn)tree_rescan_cmd, tree);
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
3, _("Forget"), (buttonbarfn)tree_forget_cmd, tree);
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
5, _("Copy"), (buttonbarfn) tree_copy_cmd, tree);
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
6, _("RenMov"), (buttonbarfn) tree_move_cmd, tree);
#if 0
/* FIXME: mkdir is currently defunct */
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
7, _("Mkdir"), (buttonbarfn) tree_mkdir_cmd, tree);
#else
define_label (h, (Widget *)tree, 7, "", 0);
#endif
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
8, _("Rmdir"), (buttonbarfn) tree_rmdir_cmd, tree);
set_navig_label (h);
redraw_labels (h, (Widget *)tree);
-
+
/* FIXME: Should find a better way of only displaying the
- currently selected item */
+ currently selected item */
show_tree (tree);
return 1;
tree->searching = 0;
tree->done = 0;
tree->active = 0;
-
+
/* We do not want to keep the cursor */
widget_want_cursor (tree->widget, 0);
load_tree (tree);
{
char *p, *q;
int result;
-
+
if (!mc_mkdir (s, mode))
return 0;
free (p);
if (!(result = my_mkdir_rec (q, mode))) {
result = mc_mkdir (s, mode);
- }
+ }
free (q);
return result;
}
int my_mkdir (char *s, mode_t mode)
{
int result;
-#if FIXME
+#if FIXME
WTree *tree = 0;
-#endif
+#endif
result = mc_mkdir (s, mode);
#ifdef OS2_NT
#endif
if (result) {
char *p = vfs_canon (s);
-
+
result = my_mkdir_rec (p, mode);
free (p);
}
int my_rmdir (char *s)
{
int result;
-#if FIXME
+#if FIXME
WTree *tree = 0;
-#endif
+#endif
/* FIXME: Should receive a Wtree! */
result = mc_rmdir (s);
# define ACS_MAP(x) '*'
# define NO_COLOR_SUPPORT
-# define untouchwin(win)
+# define untouchwin(win)
# define xgetch x_getch
# define wtouchln(win,b,c,d) touchwin(win)
# define derwin(win,x,y,z,w) win
/* User Menu implementation
Copyright (C) 1994 Miguel de Icaza, Janne Kukonlehto
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include "view.h" /* for default_* externs */
-/* "$Id: user.c,v 1.1 2001/12/30 09:55:20 sedwards Exp $" */
+/* "$Id$" */
#define MAX_ENTRIES 40
#define MAX_ENTRY_LEN 60
ascii, hex, nroff, unformated and
If the format letter is in uppercase, it refers to the other panel.
-
+
With a number followed the % character you can turn quoting on (default)
and off. For example:
%f quote expanded macro
} else if (!strncmp (q, "unformated", 10)){
default_nroff_flag = 0;
q += 9;
- }
+ }
}
if (*q == '}')
q++;
char *var_name;
char *value;
char *dots;
-
+
*v = 0;
dots = 0;
if (!strncmp (p, "var{", 4)){
: " The %%var macros does not have a variable " );
return 0;
}
-
+
/* Copy the variable name */
var_name = xmalloc (dots - p, "check_format_var");
strncpy (var_name, p+4, dots-2 - (p+3));
{
WPanel *panel;
char *(*quote_func)(const char *, int);
-
+
if (quote)
quote_func = name_quote;
else
if (c == '%')
return strdup ("%");
-
+
if (islower (c))
panel = cpanel;
else {
panel = cpanel;
c = tolower (c);
-
+
switch (c){
- case 'f':
+ case 'f':
case 'p': return (*quote_func) (panel->dir.list [panel->selected].fname, 0);
case 'b':
return strip_ext((*quote_func) (panel->dir.list [panel->selected].fname, 0));
{
int length = 2, i;
char *block, *tmp;
-
+
for (i = 0; i < panel->count; i++)
if (panel->dir.list [i].f.marked)
length += strlen (panel->dir.list [i].fname) + 1;
} /* switch */
/* Add one debug statement */
debug_out (&operator, NULL, *result);
-
+
} /* while (*p != '\n') */
/* Report debug message */
debug_out (NULL, NULL, 1);
return;
}
commands++;
-
+
for (col = 0; *commands; commands++){
if (col == 0 && (*commands != ' ' && *commands != '\t'))
break;
if (isdigit (*commands)) {
do_quote = atoi (commands);
for ( ; isdigit (*commands); commands++)
- ;
+ ;
}
if (*commands == '{')
parameter_found = 1;
unlink (file_name);
}
-/*
+/*
** Check owner of the menu file. Using menu file is allowed, if
** owner of the menu is root or the actual user. In either case
** file should not be group and word-writable.
-**
+**
** Q. Should we apply this routine to system and home menu (and .ext files)?
*/
static int
int col, i, accept_entry = 1;
int selected, old_patterns;
Listbox *listbox;
-
+
if (!vfs_current_is_local ()){
message (1, _(" Oops... "),
_(" I can't run programs while logged on a non local directory "));
return;
}
-
+
menu = strdup (MC_LOCAL_MENU);
if (!exist_file (menu) || !menu_file_own (menu)){
free (menu);
return;
}
free (menu);
-
+
max_cols = 0;
for (i = 0; i < MAX_ENTRIES; i++)
entries [i] = 0;
if (*(p+1) == '='){
/* Combined adding and default */
char *q = p++;
-
+
p = test_line (q, &accept_entry);
if (selected == 0 && accept_entry)
selected = menu_lines;
/* Create listbox */
listbox = create_listbox_window (max_cols+2, menu_lines, _(" User menu "),
"[Menu File Edit]");
-
+
/* insert all the items found */
for (i = 0; i < menu_lines; i++)
LISTBOX_APPEND_TEXT (listbox, entries [i][0],
/* Select the default entry */
listbox_select_by_number (listbox->list, selected);
-
+
selected = run_listbox (listbox);
if (selected >= 0)
execute_menu_command (entries [selected]);
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include "user.h" /* expand_format */
#include "../vfs/vfs.h"
-/* "$Id: util.c,v 1.2 2003/06/27 21:10:35 gvg Exp $" */
+/* "$Id$" */
char app_text [] = "Midnight-Commander";
{
int max = 0;
int line_len = 0;
-
+
for (*lines = 1;*text; text++){
if (*text == '\n'){
line_len = 0;
char *trim (char *s, char *d, int len)
{
int source_len = strlen (s);
-
+
if (source_len > len){
strcpy (d, s+(source_len-len));
d [0] = '.';
name_quote (const char *s, int quote_percent)
{
char *ret, *d;
-
+
d = ret = xmalloc (strlen (s)*2 + 2 + 1, "quote_name");
if (*s == '-') {
*d++ = '.';
if (!txt)
txt = PATH_SEP_STR;
-
+
if (trunc_len > sizeof (x)-1){
fprintf (stderr, _("name_trunc: too big"));
trunc_len = sizeof (x)-1;
static char x [30];
long int divisor = 1;
char *xtra = "";
-
+
if (size > 999999999L){
divisor = 1024;
xtra = "kb";
strip_password (char *path)
{
char *at, *inner_colon, *dir;
-
+
if ((dir = strchr (path, PATH_SEP)) != NULL)
*dir = '\0';
/* search for any possible user */
newdir [0] = '~';
strcpy (&newdir [1], &dir [strlen (home_dir)]);
return newdir;
- }
-#ifdef USE_NETCODE
+ }
+#ifdef USE_NETCODE
else if (!strncmp (dir, "ftp://", 6)) {
strip_password (strcpy (newdir, dir) + 6);
if ((p = strchr (newdir + 6, PATH_SEP)) != NULL) {
} else if (!strncmp (dir, "mc:", 3)) {
char *pth;
strcpy (newdir, dir);
- if (newdir[3] == '/' && newdir[4] == '/') {
+ if (newdir[3] == '/' && newdir[4] == '/') {
pth = newdir + 5;
strip_password ( newdir + 5);
- } else {
+ } else {
pth = newdir + 3;
strip_password (newdir + 3);
}
*p = 0;
q = mcfs_gethome (newdir);
*p = PATH_SEP;
- if (q != NULL ) {
+ if (q != NULL ) {
if (strcmp (q, PATH_SEP_STR) && !strncmp (p, q, strlen (q) - 1)) {
strcpy (p, "/~");
strcat (newdir, p + strlen (q) - 1);
}
free (q);
- }
+ }
}
return (newdir);
}
-#endif
+#endif
return dir;
}
*d++ = '.';
*d = '*';
break;
-
+
case '?':
d = maybe_start_group (d, do_group, &was_wildcard);
*d = '.';
break;
-
+
case '.':
d = maybe_end_group (d, do_group, &was_wildcard);
*d++ = '\\';
if (!strlen (filename))
return "";
-
+
d = filename + strlen (filename) - 1;
for (;d >= filename; d--){
if (*d == '.')
{
return x;
- /* Buggy code
+ /* Buggy code
if (!align_extensions)
return x;
if (strlen (x) >= pad)
return x;
-
+
if ((ext = extension (x)) == x || *ext == 0)
return x;
l = strlen (ext);
for (i = 0; i < l; i++)
xbuf [pad-i] = *(ext+l-i-1);
- for (i = xbuf + (ext - x); i <
+ for (i = xbuf + (ext - x); i <
return xbuf; */
}
struct stat s;
char *data;
long read_size,i;
-
+
if (stat (filename, &s) != 0){
return 0;
}
{
static char tmp_line [500];
char *t = tmp_line;
-
+
while (*s && *s != '\n' && (t - tmp_line) < sizeof (tmp_line)-1 && s < top)
*t++ = *s++;
*t = 0;
{
static char buffer [256];
char *error_msg;
-
+
#ifdef HAVE_STRERROR
error_msg = strerror (error_num);
#else
if (!first)
return 0;
-
+
len = strlen (first);
va_start (ap, first);
return result;
}
-
+
long blocks2kilos (int blocks, int bsize)
{
if (bsize > 1024){
if (!s)
return 0;
-
+
for (i = 0, j = 0; s [i+j]; ++i)
if (s [i+j] != ESC_CHAR){
if (j)
long int is_gunzipable (int fd, int *type)
{
unsigned char magic [4];
-
+
*type = ISGUNZIPABLE_GUNZIP;
-
+
/* Read the magic signature */
CHECK (mc_read (fd, &magic [0], 1));
CHECK (mc_read (fd, &magic [1], 1));
CHECK (mc_read (fd, &magic [2], 1));
CHECK (mc_read (fd, &magic [3], 1));
-
+
/* GZIP_MAGIC and OLD_GZIP_MAGIC */
if (magic [0] == 037 && (magic [1] == 0213 || magic [1] == 0236)){
/* Read the uncompressed size of the file */
mc_lseek (fd, 8, SEEK_SET);
CHECK (mc_read (fd, &magic [0], 1));
CHECK (mc_read (fd, &magic [1], 1));
-
+
/* Gzip can handle only deflated (8) or stored (0) files */
if ((magic [0] != 8 && magic [0] != 0) || magic [1] != 0)
return 0;
case '0':
*type = ISGUNZIPABLE_BZIP;
return 5*mc_lseek (fd, 0, SEEK_END);
- case 'h':
+ case 'h':
*type = ISGUNZIPABLE_BZIP2;
return 5*mc_lseek (fd, 0, SEEK_END);
}
switch (type){
case ISGUNZIPABLE_GUNZIP:
return "gzip -cdf";
-
+
case ISGUNZIPABLE_BZIP:
return "bzip -d";
-
+
case ISGUNZIPABLE_BZIP2:
return "bzip2 -dc";
}
*flags = "-d";
return;
-
+
case ISGUNZIPABLE_BZIP2:
*cmd = "bzip2";
*flags = "-dc";
}
*cmd = 0;
*flags = 0;
-
+
/* Should never reach this place */
fprintf (stderr, "Fatal: decompress_command called with an unknown argument\n");
}
new_hook->hook_fn = hook_fn;
new_hook->next = *hook_list;
new_hook->hook_data = data;
-
+
*hook_list = new_hook;
}
/* We copy the hook list first so tahat we let the hook
* function call delete_hook
*/
-
+
while (hook_list){
add_hook (&new_hook, hook_list->hook_fn, hook_list->hook_data);
hook_list = hook_list->next;
}
p = new_hook;
-
+
while (new_hook){
(*new_hook->hook_fn)(new_hook->hook_data);
new_hook = new_hook->next;
}
-
+
for (hook_list = p; hook_list;){
p = hook_list;
hook_list = hook_list->next;
Hook *current, *new_list, *next;
new_list = 0;
-
+
for (current = *hook_list; current; current = next){
next = current->next;
if (current->hook_fn == hook_fn)
int hook_present (Hook *hook_list, void (*hook_fn)(void *))
{
Hook *p;
-
+
for (p = hook_list; p; p = p->next)
if (p->hook_fn == hook_fn)
return 1;
void wipe_password (char *passwd)
{
char *p = passwd;
-
+
for (;*p ; p++)
*p = 0;
free (passwd);
int len = strlen (string);
int i;
const int steps = len/2;
-
+
for (i = 0; i < steps; i++){
char c = string [i];
-
+
string [i] = string [len-i-1];
string [len-i-1] = c;
}
char *buf, *buf2, *p, *q, *r, c;
int len;
struct stat mybuf;
-
+
if (*path != PATH_SEP)
return NULL;
r = buf = xmalloc (MC_MAXPATHLEN, "resolve symlinks");
- buf2 = xmalloc (MC_MAXPATHLEN, "resolve symlinks");
+ buf2 = xmalloc (MC_MAXPATHLEN, "resolve symlinks");
*r++ = PATH_SEP;
*r = 0;
p = path;
/* Finds out a relative path from first to second, i.e. goes as many ..
* as needed up in first and then goes down using second */
-char *diff_two_paths (char *first, char *second)
+char *diff_two_paths (char *first, char *second)
{
char *p, *q, *r, *s, *buf = 0;
int i, j, prevlen = -1, currlen;
-
+
first = resolve_symlinks (first);
if (first == NULL)
return NULL;
#ifdef OS2_NT
if(_chsize(fd, size))
return -1;
- else
+ else
return 0;
#else
struct flock lk;
-
+
lk.l_whence = 0;
lk.l_start = size;
lk.l_len = 0;
-
+
return fcntl (fd, F_FREESP, &lk);
#endif
}
{
int fd;
int res;
-
+
fd = open (path, O_RDWR, 0);
if (fd < 0)
return fd;
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
if (pwd == 0)
return;
-
+
setgrent ();
while ((grp = getgrent ()))
for (i = 0; grp->gr_mem[i]; i++)
static char ibuf [8];
char *name;
static int uid_last;
-
+
if ((name = i_cache_match (uid, uid_cache, UID_CACHE_SIZE)) != NULL)
return name;
-
+
pwd = getpwuid (uid);
if (pwd){
i_cache_add (uid, uid_cache, UID_CACHE_SIZE, pwd->pw_name, &uid_last);
static char gbuf [8];
char *name;
static int gid_last;
-
+
if ((name = i_cache_match (gid, gid_cache, GID_CACHE_SIZE)) != NULL)
return name;
-
+
grp = getgrgid (gid);
if (grp){
i_cache_add (gid, gid_cache, GID_CACHE_SIZE, grp->gr_name, &gid_last);
pid_t pid;
int status = 0;
int as_shell_command = flags & EXECUTE_AS_SHELL;
-
+
ignore.sa_handler = SIG_IGN;
sigemptyset (&ignore.sa_mask);
ignore.sa_flags = 0;
-
- sigaction (SIGINT, &ignore, &save_intr);
+
+ sigaction (SIGINT, &ignore, &save_intr);
sigaction (SIGQUIT, &ignore, &save_quit);
/* Restore the original SIGTSTP handler, we don't want ncurses' */
#if 0
prepare_environment ();
#endif
-
+
if (as_shell_command)
execl (shell, shell, "-c", command, (char *) 0);
else
sigaction (SIGQUIT, &save_quit, NULL);
sigaction (SIGTSTP, &save_stop, NULL);
-#ifdef SCO_FLAVOR
+#ifdef SCO_FLAVOR
waitpid(-1, NULL, WNOHANG);
#endif /* SCO_FLAVOR */
char *p;
char *name;
int len;
-
+
if (*directory != '~')
return strdup (directory);
directory++;
-
+
p = strchr (directory, PATH_SEP);
-
+
/* d = "~" or d = "~/" */
if (!(*directory) || (*directory == PATH_SEP)){
passwd = getpwuid (geteuid ());
#define closepipes() close(pipe0[0]);close(pipe0[1]);close(pipe1[0]);close(pipe1[1])
#define is_a_pipe_fd(f) ((pipe0[0] == f) || (pipe0[1] == f) || (pipe1[0] == f) || (pipe1[1] == f))
-
+
pipe (pipe0); pipe (pipe1);
ignore.sa_handler = SIG_IGN;
sigemptyset (&ignore.sa_mask);
ignore.sa_flags = 0;
-
+
sigaction (SIGINT, &ignore, &save_intr);
sigaction (SIGQUIT, &ignore, &save_quit);
sigaction (SIGTSTP, &startup_handler, &save_stop);
int nulldevice;
port_shutdown_extra_fds ();
-
+
nulldevice = open ("/dev/null", O_WRONLY);
close (0);
dup (pipe0 [0]);
close (pipe1 [0]);
close (pipe1 [1]);
while ((i = mc_read (inhandle, buffer,
- (inlen == -1 || inlen > 8192)
+ (inlen == -1 || inlen > 8192)
? 8192 : inlen)) > 0) {
write (pipe0 [1], buffer, i);
if (inlen != -1) {
int mc_doublepclose (int pipe, pid_t pid)
{
int status = 0;
-
+
close (pipe);
waitpid (pid, &status, 0);
#ifdef SCO_FLAVOR
sigaction (SIGQUIT, &save_quit, NULL);
sigaction (SIGTSTP, &save_stop, NULL);
- return status;
+ return status;
}
/* Canonicalize path, and return a new path. Do everything in situ.
continue;
}
- /* Handle `../' or trailing `..' by itself.
+ /* Handle `../' or trailing `..' by itself.
Remove the previous ?/ part with the exception of
../, which we should leave intact. */
if (path[i + 1] == '.' && (path[i + 2] == PATH_SEP || !path[i + 2])) {
{
struct timeb tb;
struct tm * l;
-
+
ftime( &tb );
if (errno == EFAULT)
return -1;
const char *const name_end = strchr (string, '=');
register size_t size;
register char **ep;
-
+
if (name_end == NULL){
/* Remove the variable from the environment. */
size = strlen (string);
return 0;
}
}
-
+
size = 0;
for (ep = __environ; *ep != NULL; ++ep)
if (!strncmp (*ep, string, name_end - string) &&
break;
else
++size;
-
+
if (*ep == NULL){
static char **last_environ = NULL;
char **new_environ = (char **) malloc ((size + 2) * sizeof (char *));
}
else
*ep = (char *) string;
-
+
return 0;
}
#endif /* !HAVE_PUTENV */
#endif
return -1;
}
-
+
/*
* Now link these two stream together with an I_FDINSERT ioctl.
*/
-
+
ins.ctlbuf.buf = (char *) &pointer; /* no control information, just the pointer */
ins.ctlbuf.maxlen = sizeof pointer;
ins.ctlbuf.len = sizeof pointer;
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#endif
/* Maxlimit for skipping updates */
-int max_dirt_limit =
+int max_dirt_limit =
#ifdef OS2_NT
0;
#else
int altered_nroff_flag = 0;
/* }}} */
-/* "$Id: view.c,v 1.1 2001/12/30 09:55:20 sedwards Exp $" */
+/* "$Id$" */
static char hex_char[] = "0123456789ABCDEF";
free_file (WView *view)
{
int i;
-
+
#ifdef HAVE_MMAP
if (view->mmapping){
mc_munmap (view->data, view->s.st_size);
close_view_file (view);
- } else
+ } else
#endif /* HAVE_MMAP */
{
if (view->reading_pipe){
/* Check error messages */
if (!view->have_frame)
check_error_pipe ();
-
+
/* Close pipe */
pclose (view->stdfile);
view->stdfile = NULL;
-
+
/* Ignore errors because we don't want to hear about broken pipe */
close_error_pipe (-1, NULL);
} else
int offset = byte_index % VIEW_PAGE_SIZE;
int i, n;
block_ptr_t *tmp;
-
+
if (view->growing_buffer){
if (page > view->blocks){
tmp = xmalloc (sizeof (block_ptr_t) * page, "get_byte");
bcopy (view->block_ptr, tmp, sizeof (block_ptr_t) *
view->blocks);
free (view->block_ptr);
- }
+ }
view->block_ptr = tmp;
for (i = view->blocks; i < page; i++){
char *p = malloc (VIEW_PAGE_SIZE);
if (!view->hexedit_mode || view->growing_buffer != 0)
return;
-
+
/* Has there been a change at this position ? */
node = view->change_list;
- while (node) {
+ while (node) {
if (node->offset != view->edit_cursor)
node = node->next;
else
if (node) {
#ifndef HAVE_MMAP
- /*
+ /*
** alex@bcs.zaporizhzhe.ua: here we are using file copy
** completely loaded into memory, so we can replace bytes
** in view->data array to allow changes to be reflected
{
struct hexedit_change_node *node = view->change_list;
int fp;
-
+
fp = open (view->filename, O_WRONLY);
if (fp >= 0) {
while (node) {
{
int r;
char *text;
-
+
if (!view->change_list)
return 1;
-
+
query_set_sel (1);
text = copy_strings (_("File: \n\n "), view->filename,
_("\n\nhas been modified, do you want to save the changes?\n"), NULL);
-
+
r = query_dialog (_(" Save changes "), text, 2, 3, _("&Yes"), _("&No"), _("&Cancel"));
free (text);
-
+
switch (r) {
case 0:
save_edit_changes (view);
/* return values: 0 for success, else points to error message */
static char *
-init_growing_view (WView *view, char *name, char *filename)
+init_growing_view (WView *view, char *name, char *filename)
{
view->growing_buffer = 1;
close_view_file (view);
return init_growing_view (view, 0, filename);
}
-
+
/* First, try to open a compressed file */
if (view->viewer_magic_flag && (is_gunzipable (view->file, &type)) != 0){
close_view_file (view);
return copy_strings (" Can't mmap file \n ",
unix_error_string (errno), " ", 0);*/
return init_growing_view (view, 0, filename);
-
+
}
view->first = 0;
view->mmapping = 1;
return 0;
#else /* ! HAVE_MMAP */
- /*
+ /*
** For those OS that dont provide mmap call. Try to load all the file
** into memory (alex@bcs.zaporizhzhe.ua)
*/
view->marker = 0;
for (i = 0; i < 10; i++)
view->marks [i] = 0;
-
+
if (!view->have_frame){
view->start_col = 0;
view->s.st_size = view->bytes_read = strlen (view->data);
}
view->last_byte = view->first + view->s.st_size;
-
+
if (start_line > 1 && !error){
int saved_wrap_mode = view->wrap_mode;
cols = view->widget.cols - 2;
else
cols = view->widget.cols;
-
+
view->bottom_first = -1;
view->bytes_per_line = 2 * (cols - 7) / 9;
view->bytes_per_line &= 0xfffc;
(view->last_byte == view->last ? 100 :
(p)*100 / view->s.st_size);
#endif
-
+
widget_move (view, view->have_frame, w - 5);
printw ("%3d%% ", percent);
}
/* FIXME: Should I use widget_erase only and repaint the box? */
if (view->have_frame){
int i;
-
+
draw_double_box (view->widget.parent, view->widget.y, view->widget.x,
view->widget.lines, view->widget.cols);
for (i = 1; i < height; i++){
int c;
int boldflag = 0;
struct hexedit_change_node *curr = view->change_list;
-
+
height = view->widget.lines - frame_shift;
width = view->widget.cols - frame_shift;
from = view->start_display;
if ((!view->hex_mode) && (ruler)){
char r_buff[4];
int cl;
-
+
view_set_color (view, BOLD_COLOR);
for (c = frame_shift; c < width; c++) {
- cl = c-view->start_col;
+ cl = c-view->start_col;
if (ruler == 1)
view_gotoyx (view, row, c);
else
view_gotoyx (view, row+height-2, c);
r_buff[0] = '-';
if ((cl % 10) == 0)
- r_buff[0] = '|';
+ r_buff[0] = '|';
else
if ((cl % 5) == 0)
- r_buff[0] = '*';
+ r_buff[0] = '*';
view_add_character (view, r_buff[0]);
if ((cl != 0) && (cl % 10) == 0){
sprintf(r_buff, "%03d", cl);
else
widget_move (view, row + height - 3, c - 1);
view_add_string (view, r_buff);
- }
- }
+ }
+ }
view_set_color (view, DEF_COLOR);
- if (ruler == 1)
+ if (ruler == 1)
row += 2;
else
- height -= 2;
+ height -= 2;
}
-
+
/* Find the first displayable changed byte */
while (curr) {
if (curr->offset < from)
if (view->hex_mode){
char hex_buff[10]; /* A temporary buffer for sprintf and mvwaddstr */
int bytes; /* Number of bytes already printed on the line */
-
+
/* Start of text column */
int text_start = width - view->bytes_per_line - 1 + frame_shift;
-
+
for (;row < height && from < view->last_byte; row++){
/* Print the hex offset */
sprintf (hex_buff, "%05X", (int) (from - view->first));
widget_move (view, row, frame_shift);
view_add_string (view, hex_buff);
-
+
/* Hex dump starts from column seven */
col = 7;
-
+
/* Each hex number is two digits */
hex_buff[2] = 0;
for (bytes = 0; bytes < view->bytes_per_line
view_set_color (view, 7);
} else
c = (unsigned char) get_byte (view, from);
-
+
if (view->found_len && from >= view->search_start
&& from < view->search_start + view->found_len){
boldflag = 1;
if (boldflag == 1 &&
from == view->search_start + view->found_len - 1)
view_set_color (view, DEF_COLOR);
-
+
/* Hex numbers are printed in the groups of four */
/* Groups are separated by a vline */
-
+
view_add_character (view, ' ');
one_vline ();
view_gotoyx (view, row, col + 1);
col += 2;
-
+
if (boldflag && from==view->search_start+view->found_len-1)
view_set_color (view, BOLD_COLOR);
-
+
}
- if (boldflag && from < view->search_start + view->found_len - 1
+ if (boldflag && from < view->search_start + view->found_len - 1
&& bytes != view->bytes_per_line - 1)
view_add_character (view, ' ');
-
+
/* Print the corresponding ascii character */
view_gotoyx (view, row, text_start + bytes);
-
+
if (!is_printable (c))
c = '.';
switch (boldflag) {
}
}
view_add_character (view, c);
-
+
if (boldflag){
boldflag = 0;
view_set_color (view, DEF_COLOR);
c = '.';
view_add_character (view, c);
- }
+ }
col++;
if (boldflag){
boldflag = 0;
shift = view->nib_shift;
else
shift = 0;
-
+
widget_move (&view->widget, view->cursor_row, view->cursor_col + shift);
}
q++;
for (line = col = 0, p = current; p < q; p++){
int c;
-
+
if (lines != -1 && line >= lines)
return p;
c = get_byte (view, p);
-
+
if (view->wrap_mode){
if (c == '\r')
continue; /* This characters is never displayed */
I suspect I got that fix from Jakub, same applies
for d. */
int d = get_byte (view, p+2);
-
- if (p + 2 >= view->last_byte || !is_printable (c) ||
- !view->viewer_nroff_flag || get_byte (view, p + 1) != '\b' ||
+
+ if (p + 2 >= view->last_byte || !is_printable (c) ||
+ !view->viewer_nroff_flag || get_byte (view, p + 1) != '\b' ||
!is_printable (d)){
col = 0;
-
+
if (c == '\n' || get_byte (view, p+1) != '\n')
line++;
}
if (!view->hex_mode && current == view->first)
return current;
-
+
if (view->hex_mode){
p = current - lines * view->bytes_per_line;
p = (p < view->first) ? view->first : p;
if (!have_fast_cpu && !really)
return INT_MAX;
-
+
if (!do_not_cache && view->bottom_first != -1)
return view->bottom_first;
}
bottom_first = move_backward2 (view, view->last_byte, vheight - 1);
-
+
if (view->hex_mode)
bottom_first = (bottom_first + view->bytes_per_line - 1)
/ view->bytes_per_line * view->bytes_per_line;
view->bottom_first = bottom_first;
-
+
return view->bottom_first;
}
view->found_len = 0;
view->last = view->first + ((LINES-2) * view->bytes_per_line);
view->nib_shift = 0;
- view->edit_cursor = view->start_display;
+ view->edit_cursor = view->start_display;
view->dirty++;
}
view->nib_shift = 1 - view->nib_shift;
if (view->nib_shift == 1)
return;
- }
+ }
view->edit_cursor = (++view->edit_cursor < view->last_byte) ?
view->edit_cursor : view->last_byte - 1;
if (view->edit_cursor >= view->last) {
view->nib_shift = 1 - view->nib_shift;
if (view->nib_shift == 0)
return;
- }
+ }
view->edit_cursor = (--view->edit_cursor < view->first) ?
view->first : view->edit_cursor;
if (view->edit_cursor < view->start_display) {
int p = 0, lng;
char *q;
- p = (q = _icase_search (text, data, &lng)) != 0;
+ p = (q = _icase_search (text, data, &lng)) != 0;
if (p) {
view->found_len = lng;
view->search_start = q - data - view->found_len;
direction = view->direction;
buffer_size = usable_size = 0;
-
+
i = ch = 0;
for (;pos >= 0 && (ch = get_byte (view, pos))!= -1; pos += direction, i++){
i--;
buffer [0] = ' ';
buffer [i+1] = 0;
-
+
/* If we are searching backwards, reverse the string */
if (view->direction < 0)
reverse_string (buffer);
long t;
/* Clear interrupt status */
got_interrupt ();
-
+
if (verbose){
d = message (D_INSERT, _(" Search "), _("Searching %s"), text);
mc_refresh ();
enable_interrupt_key ();
if (!s)
break;
-
+
search_status = (*search) (view, text, s + 1, match_normal);
if (search_status < 0)
break;
continue;
/* We found the string */
-
+
if (!isatbeg && !view->search_start){
-
+
/* We do not want to match a
* ^ regexp when not at the real
* beginning of some line
else
view->start_display = t;
}
-
+
free (s);
break;
}
search_update_steps (view);
update_activate = 0;
-
+
for (; e < view->last_byte; e++){
if (e >= update_activate){
update_activate += update_steps;
break;
}
b = get_byte (view, e);
-
+
if (*d == b){
d++;
} else {
long pos; /* Where did we found the string */
char *p; /* Temporary */
int state = normal; /* Initial state of the micro-scanner */
-
+
/* First convert the string to a stream of bytes */
for (i = block_len = 0; text [i] && block_len < sizeof (buffer); i++){
switch (state){
view->found_len = 0;
return;
}
-
+
view->search_start = pos + 1;
view->found_len = block_len;
/* Set the edit cursor to the search position, left nibble */
view->edit_cursor = view->search_start;
view->nib_shift = 0;
-
+
/* Adjust the file offset */
view->start_display = (pos & (~(view->bytes_per_line-1)));
if (view->start_display > get_bottom_first (view, 0, 0))
static void do_regexp_search (void *xview, char *regexp)
{
WView *view = (WView *) xview;
-
+
view->search_exp = regexp;
search (view, regexp, regexp_view_search);
/* Had a refresh here */
static void do_normal_search (void *xview, char *text)
{
WView *view = (WView *) xview;
-
+
view->search_exp = text;
if (view->hex_mode)
hex_search (view, text);
- else
+ else
search (view, text, icase_search_p);
/* Had a refresh here */
view->dirty++;
view->dirty++;
view_update (view);
return;
- }
+ }
view->wrap_mode = 1 - view->wrap_mode;
get_bottom_first (view, 1, 1);
if (view->wrap_mode)
save_edit_changes(view);
return;
}
-
+
regexp = old ? old : regexp;
regexp = input_dialog (_(" Search "), _(" Enter regexp:"), regexp);
if ((!regexp) || (!*regexp)){
view_labels (WView *view)
{
Dlg_head *h = view->widget.parent;
-
+
define_label (h, (Widget *) view, 1, _("Help"), help_cmd);
-
+
my_define (h, 10, _("Quit"), view_quit_cmd, view);
my_define (h, 4, view->hex_mode ? _("Ascii"): _("Hex"), toggle_hex_mode, view);
my_define (h, 5, _("Line"), goto_line, view);
view->growing_buffer ? "" : _("Edit") :
view->wrap_mode ? _("UnWrap") : _("Wrap"),
toggle_wrap_mode, view);
-
+
my_define (h, 7, view->hex_mode ? _("HxSrch") : _("Search"),
normal_search_cmd, view);
-
+
my_define (h, 8, view->viewer_magic_flag ? _("Raw") : _("Parse"),
change_viewer, view);
change_nroff, view);
my_define (h, 3, _("Quit"), view_quit_cmd, view);
}
-
+
redraw_labels (h, (Widget *) view);
}
set_monitor (WView *view, int set_on)
{
int old = view->monitor;
-
+
view->monitor = set_on;
-
+
if (view->monitor){
move_to_bottom (view);
view->bottom_first = -1;
int prev_monitor = view->monitor;
set_monitor (view, off);
-
+
if (view->hex_mode) {
switch (c) {
case 0x09: /* Tab key */
view->edit_cursor -= view->edit_cursor % view->bytes_per_line;
view->dirty++;
return 1;
-
+
case XCTRL('b'): /* Character back */
move_left(view);
return 1;
view->edit_cursor += view->bytes_per_line - 1;
view->dirty++;
return 1;
-
+
case XCTRL('f'): /* Character forward */
move_right(view);
return 1;
}
-
+
/* Trap 0-9,A-F,a-f for left side data entry (hex editing) */
if (view->view_side == view_side_left){
- if ((c >= '0' && c <= '9') ||
+ if ((c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'F') ||
(c >= 'a' && c <= 'f')){
-
+
put_editkey (view, c);
return 1;
}
}
-
+
/* Trap all printable characters for right side data entry */
/* Also enter the value of the Enter key */
if (view->view_side == view_side_right){
}
}
}
-
+
if (check_left_right_keys (view, c))
return 1;
-
+
if (check_movement_keys (c, 1, vheight, view, (movefn) view_move_backward, (movefn) view_move_forward,
(movefn) move_to_top, (movefn) move_to_bottom)){
return 1;
case '?':
regexp_search (view, -1);
return 1;
-
+
case '/':
regexp_search (view, 1);
return 1;
case 'h':
move_left (view);
return 1;
-
+
case 'j':
case '\n':
case 'e':
view_move_forward (view, 1);
return 1;
-
+
case 'd':
view_move_forward (view, vheight / 2);
return 1;
-
+
case 'u':
view_move_backward (view, vheight / 2);
return 1;
-
+
case 'k':
case 'y':
view_move_backward (view, 1);
return 1;
-
+
case 'l':
move_right (view);
return 1;
-
+
case ' ':
case 'f':
view_move_forward (view, vheight - 1);
case '!':
exec_shell ();
return 1;
-
+
case 'F':
set_monitor (view, on);
return 1;
-
+
case 'b':
view_move_backward (view, vheight - 1);
return 1;
-
+
case KEY_IC:
view_move_backward (view, 2);
return 1;
-
+
case KEY_DC:
view_move_forward (view, 2);
return 1;
view->start_display = view->marks [view->marker];
view->dirty++;
return 1;
-
+
/* Use to indicate parent that we want to see the next/previous file */
/* Only works on full screen mode */
case XCTRL('f'):
/* Restore the monitor status */
set_monitor (view, prev_monitor);
-
+
/* Key not used */
return 0;
}
view_move_forward (view, vheight / 2 - 1);
else
view_move_forward (view, 1);
- *result = MOU_REPEAT;
+ *result = MOU_REPEAT;
return 1;
}
}
real_view_event (Gpm_Event *event, void *x)
{
int result;
-
+
if (view_event ((WView *) x, event, &result))
view_update ((WView *) x);
return result;
error = view_init (wview, _command, _file, start_line);
if (!error){
- x_view (wview);
+ x_view (wview);
}
*move_dir_p = 0;
return !error;
WView *wview;
WButtonBar *bar;
Dlg_head *our_dlg;
-
+
/* Create dialog and widgets, put them on the dialog */
our_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors,
view_mode_callback, "[Internal File Viewer]",
*move_dir_p = wview->move_dir;
}
destroy_dlg (our_dlg);
-
+
return !error;
}
#endif
}
delete_hook (&idle_hook, view_hook);
-
+
if (get_current_type () == view_listing)
panel = cpanel;
else if (get_other_type () == view_listing)
if (!S_ISREG (panel->dir.list [panel->selected].buf.st_mode))
return;
}
-
+
view_init (view, 0, panel->dir.list [panel->selected].fname, 0);
display (view);
view_status (view);
{
WView *view = (WView *) v;
int i;
-
+
switch (msg){
case WIDGET_INIT:
x_create_viewer (view);
else
view_labels (view);
break;
-
+
case WIDGET_DRAW:
display (view);
view_status (view);
view_status (view);
sleep (1);
return 1;
-
+
case WIDGET_FOCUS:
x_focus_view (view);
view_labels (view);
return 1;
-
+
}
return default_proc (h, msg, par);
}
view_new (int y, int x, int cols, int lines, int is_panel)
{
WView *view = xmalloc (sizeof (WView), "view_new");
-
+
init_widget (&view->widget, y, x, lines, cols,
(callback_fn) view_callback,
(destroy_fn) view_destroy,
view->last_byte = -1;
view->monitor = 0;
view->wrap_mode = global_wrap_mode;
-
+
x_init_view (view);
widget_want_cursor (view->widget, 0);
char *localcopy;
int view_active;
int have_frame;
-
+
unsigned char *data; /* Memory area for the file to be viewed */
/* File information */
long start_display; /* First char displayed */
int start_col; /* First displayed column, negative */
int edit_cursor; /* HexEdit cursor position in file */
- char hexedit_mode; /* Hexidecimal editing mode flag */
+ char hexedit_mode; /* Hexidecimal editing mode flag */
char nib_shift; /* A flag for inserting nibbles into bytes */
enum ViewSide view_side; /* A flag for the active editing panel */
int file_dirty; /* Number of changes */
- int start_save; /* Line start shift between Ascii and Hex */
+ int start_save; /* Line start shift between Ascii and Hex */
int cursor_col; /* Cursor column */
int cursor_row; /* Cursor row */
struct hexedit_change_node *change_list; /* Linked list of changes */
int dirty; /* Number of skipped updates */
int wrap_mode; /* wrap_mode */
-
+
/* Mode variables */
int hex_mode; /* Hexadecimal mode flag */
int bytes_per_line; /* Number of bytes per line in hex mode */
int viewer_magic_flag; /* Selected viewer */
int viewer_nroff_flag; /* Do we do nroff style highlighting? */
-
+
/* Growing buffers information */
int growing_buffer; /* Use the growing buffers? */
block_ptr_t *block_ptr; /* Pointer to the block pointers */
int blocks; /* The number of blocks in *block_ptr */
-
+
/* Search variables */
int search_start; /* First character to start searching from */
int found_len; /* Length of found string or 0 if none was found */
/* Markers */
int marker; /* mark to use */
int marks [10]; /* 10 marks: 0..9 */
-
+
#ifdef HAVE_TK
/* Tk version, line cache */
int current_line; /* The current screen line cached */
int last_col; /* last column used */
int status_shown; /* Have we show the file information? */
#endif
-
+
#ifdef HAVE_GNOME
int current_x, current_y; /* Current x,y position */
int color; /* Current color */
void *gtk_percent; /* percent */
void *sadj; /* scrollbar adjustment */
#endif
-
- int move_dir; /* return value from widget:
+
+ int move_dir; /* return value from widget:
* 0 do nothing
* -1 view previous file
* 1 view next file
/* Widgets for the Midnight Commander
Copyright (C) 1994, 1995, 1996 the Free Software Foundation
-
+
Authors: 1994, 1995 Radek Doulik
1994, 1995 Miguel de Icaza
1995 Jakub Jelinek
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* "$Id: widget.c,v 1.1 2001/12/30 09:55:20 sedwards Exp $" */
+/* "$Id$" */
#include <config.h>
#include <string.h>
char *txt, buf[256];
int stop = 0;
int off = 0;
-
+
switch (Msg){
case WIDGET_INIT:
return x_create_button (h, h->wdata, b);
return 1;
} else
return 0;
-
+
case WIDGET_KEY:
if (Par != ' ' && Par != '\n')
break;
case WIDGET_CURSOR:
{
char *s = b->action == B_ENTER ? ".button" : "";
-
+
tk_evalf ("focus %s%s", (char *)(b->widget.wdata)+1, s);
/* Do not call default_proc: we did the tk focus command */
return 1;
}
#else
-
+
case WIDGET_CURSOR:
switch (b->flags) {
case DEFPUSH_BUTTON:
case WIDGET_UNFOCUS:
case WIDGET_FOCUS:
case WIDGET_DRAW:
- if (Msg==WIDGET_UNFOCUS)
+ if (Msg==WIDGET_UNFOCUS)
b->selected = 0;
- else if (Msg==WIDGET_FOCUS)
+ else if (Msg==WIDGET_FOCUS)
b->selected = 1;
switch (b->flags){
else
return 1;
break;
-#endif
+#endif
#endif /* !HAVE_XVIEW */
- }
+ }
return default_proc (h, Msg, Par);
}
}
WButton *
-button_new (int y, int x, int action, int flags, char *text,
+button_new (int y, int x, int action, int flags, char *text,
int (*callback)(int, void *), void *callback_data, char *tkname)
{
WButton *b = xmalloc (sizeof (WButton), "new_button");
init_widget (&b->widget, y, x, 1, button_len (text, flags),
(callback_fn) button_callback,
(destroy_fn) button_destroy, (mouse_h)button_event, tkname);
-
+
b->action = action;
b->flags = flags;
b->selected = 0;
radio_callback (Dlg_head *h, WRadio *r, int Msg, int Par)
{
int i;
-
+
switch (Msg) {
case WIDGET_INIT:
return x_create_radio (h, h->wdata, r);
-
+
#ifndef HAVE_XVIEW
case WIDGET_HOTKEY:
{
int i, lp = tolower(Par);
char *cp;
-
+
for (i = 0; i < r->count; i++){
cp = strchr (r->texts [i], '&');
if (cp != NULL && cp[1] != '\0'){
int c = tolower (cp [1]);
-
+
if (c != lp)
continue;
r->pos = i;
}
}
return 0;
-
+
case WIDGET_KEY:
switch (Par){
case ' ':
return 1;
}
return 0;
-
+
case KEY_DOWN:
case KEY_RIGHT:
if (r->count - 1 > r->pos) {
return 1;
#endif
#endif
-
+
#ifndef HAVE_X
case WIDGET_CURSOR:
(*h->callback) (h, h->current->dlg_id, DLG_ACTION);
radio_callback (h, r, WIDGET_FOCUS, ' ');
widget_move (&r->widget, r->pos, 1);
break;
-
+
case WIDGET_UNFOCUS:
case WIDGET_FOCUS:
case WIDGET_DRAW:
{
if (*cp == '&')
{
- attrset ((i==r->pos && Msg==WIDGET_FOCUS)
+ attrset ((i==r->pos && Msg==WIDGET_FOCUS)
? HOT_FOCUSC : HOT_NORMALC);
addch(*++cp);
attrset ((i==r->pos && Msg==WIDGET_FOCUS) ? FOCUSC : NORMALC);
}
return 1;
break;
-#endif
+#endif
}
return default_proc (h, Msg, Par);
}
#ifndef HAVE_X
if (event->type & (GPM_DOWN|GPM_UP)){
Dlg_head *h = r->widget.parent;
-
+
r->pos = event->y - 1;
dlg_select_widget (h, r);
if (event->type & GPM_UP){
r->texts = texts;
r->upper_letter_is_hotkey = use_hotkey;
widget_want_hotkey (r->widget, 1);
-
+
return r;
}
check_callback (h, c, WIDGET_FOCUS, ' ');
return 1;
-#ifndef HAVE_X
+#ifndef HAVE_X
case WIDGET_CURSOR:
widget_move (&c->widget, 0, 1);
break;
-
+
case WIDGET_FOCUS:
- case WIDGET_UNFOCUS:
+ case WIDGET_UNFOCUS:
case WIDGET_DRAW:
attrset ((Msg == WIDGET_FOCUS) ? FOCUSC : NORMALC);
widget_move (&c->widget, 0, 0);
#ifndef HAVE_X
if (event->type & (GPM_DOWN|GPM_UP)){
Dlg_head *h = c->widget.parent;
-
+
dlg_select_widget (h, c);
if (event->type & GPM_UP){
check_callback (h, c, WIDGET_KEY, ' ');
{
WCheck *c = xmalloc (sizeof (WCheck), "check_new");
char *s, *t;
-
+
init_widget (&c->widget, y, x, 1, strlen (text),
(callback_fn)check_callback,
(destroy_fn)check_destroy, (mouse_h) check_event, tkname);
{
if (Msg == WIDGET_INIT)
return x_create_label (h, h->wdata, l);
-
+
/* We don't want to get the focus */
if (Msg == WIDGET_FOCUS)
return 0;
attrset (NORMALC);
for (;;){
int xlen;
-
+
q = strchr (p, '\n');
if (q){
c = *q;
}
return 1;
}
-#endif
+#endif
return default_proc (h, Msg, Par);
}
label_set_text (WLabel *label, char *text)
{
int newcols = label->widget.cols;
-
+
if (label->text && text && !strcmp (label->text, text))
return; /* Flickering is not nice */
}
} else
label->text = 0;
-
+
if (label->widget.parent)
#ifdef HAVE_X
x_label_set_text (label, text);
if (Msg == WIDGET_INIT)
return x_create_gauge (h, h->wdata, g);
-
+
/* We don't want to get the focus */
if (Msg == WIDGET_FOCUS)
return 0;
else {
long percentage, columns;
long total = g->max, done = g->current;
-
+
if (total <= 0 || done < 0) {
done = 0;
total = 100;
}
return 1;
}
-#endif
+#endif
return default_proc (h, Msg, Par);
}
if (max == 0)
max = 1; /* I do not like division by zero :) */
#ifdef HAVE_X
-/* NOTE: x_gauge_set_value has to be called before we change actual
+/* NOTE: x_gauge_set_value has to be called before we change actual
* max and current values in g, since it assumes g->max and
* g->current as the previous values and max and current
* as the new ones :) */
x_gauge_set_value (g, max, current);
-#endif
+#endif
g->current = current;
g->max = max;
#ifndef HAVE_X
x_gauge_show (g);
#else
gauge_callback (g->widget.parent, g, WIDGET_DRAW, 0);
-#endif
+#endif
}
static void
/* Input widget */
/* {{{ history button */
-
+
#define LARGE_HISTORY_BUTTON 1
-
+
#ifdef LARGE_HISTORY_BUTTON
# define HISTORY_BUTTON_WIDTH 3
#else
# define HISTORY_BUTTON_WIDTH 1
#endif
-
+
#define should_show_history_button(in) \
(in->history && in->field_len > HISTORY_BUTTON_WIDTH * 2 + 1 && in->widget.parent)
addch (c);
#endif
}
-
+
/* }}} history button */
/* Adjust the mark */
if (in->mark > buf_len)
in->mark = buf_len;
-
+
#ifdef HAVE_X
if (clear_first && in->first)
in->first = -1;
draw_history_button (in);
attrset (in->color);
-
+
widget_move (&in->widget, 0, 0);
for (i = 0; i < in->field_len - has_history; i++)
addch (' ');
widget_move (&in->widget, 0, 0);
-
+
for (i = 0, j = in->first_shown; i < in->field_len - has_history && in->buffer [j]; i++){
c = in->buffer [j++];
c = is_printable (c) ? c : '.';
int i;
Hist *old = 0, *new = 0;
char *profile;
-
+
if (!num_history_items_recorded) /* this is how to disable */
return 0;
if (!input_name)
if (!*input_name)
return;
-
+
if (!h)
return;
h = h->next;
/* go back 60 places */
- for (i = 0; i < num_history_items_recorded - 1 && h->prev; i++)
+ for (i = 0; i < num_history_items_recorded - 1 && h->prev; i++)
h = h->prev;
i = 0;
{
Hist *new;
char *p;
-
+
for (p = text; *p == ' ' || *p == '\t'; p++);
if (!*p)
return 0;
if (c_code == -1)
return 0;
-
+
in->need_push = 1;
if (strlen (in->buffer)+1 == in->current_max_len){
/* Expand the buffer */
#define key_left backward_char
#define key_right forward_char
#endif
-
+
static void
backward_delete (WInput *in)
{
int i;
-
+
if (!in->point)
return;
for (i = in->point; in->buffer [i-1]; i++)
{
int first = min (x_first, x_last);
int last = max (x_first, x_last);
-
+
if (last == first)
return;
-
+
if (kill_buffer)
free (kill_buffer);
-
+
kill_buffer = xmalloc (last-first + 1, "copy_region");
strncpy (kill_buffer, in->buffer+first, last-first);
kill_buffer [last-first] = 0;
yank (WInput *in)
{
char *p;
-
+
if (!kill_buffer)
return;
for (p = kill_buffer; *p; p++)
return;
}
}
-
+
if (!in->history)
return;
assign_text (in, "");
return;
}
-
+
in->history = in->history->next;
assign_text (in, in->history->text);
in->need_push = 0;
{ KEY_RIGHT, key_right },
{ XCTRL('f'), forward_char },
{ ALT('f'), forward_word },
-
- /* Editing */
+
+ /* Editing */
{ 0177, backward_delete },
{ KEY_BACKSPACE, backward_delete },
{ XCTRL('h'), backward_delete },
{ ALT(KEY_BACKSPACE), back_kill_word },
{ ALT(XCTRL('h')), back_kill_word },
{ ALT(127), back_kill_word },
-
+
/* Region manipulation */
{ 0, set_mark },
{ XCTRL('w'), kill_region },
{ ALT('w'), kill_save },
{ XCTRL('y'), yank },
{ XCTRL('k'), kill_line },
-
- /* History */
+
+ /* History */
{ ALT('p'), hist_prev },
{ ALT('n'), hist_next },
{ ALT('h'), do_show_hist },
-
+
/* Completion */
{ ALT('\t'), complete },
-
+
{ 0, 0 }
};
is_in_input_map (WInput *in, int c_code)
{
int i;
-
+
for (i = 0; input_map [i].fn; i++)
if (c_code == input_map [i].key_code)
if (input_map [i].fn == complete)
v = 0;
-#ifdef HAVE_TK
+#ifdef HAVE_TK
in->inserted_one = 0;
#endif
if (quote){
case WIDGET_KEY:
if (Par == XCTRL('q')){
int v;
-
+
quote = 1;
v = handle_char (in, mi_getch ());
quote = 0;
return handle_char (in, Par);
case WIDGET_FOCUS:
- case WIDGET_UNFOCUS:
+ case WIDGET_UNFOCUS:
case WIDGET_DRAW:
update_input (in, 0);
break;
widget_move (&in->widget, 0, in->point - in->first_shown);
return 1;
#endif
-
+
}
return default_proc (h, Msg, Par);
}
/* Not declared static, since we check against this value in dlg.c */
/* FIXME: Declare static again and provide an identification mechanism */
-int
-input_event (Gpm_Event *event, WInput *in)
-{
+int
+input_event (Gpm_Event *event, WInput *in)
+{
#ifndef HAVE_X
- if (event->type & (GPM_DOWN|GPM_DRAG)){
- dlg_select_widget (in->widget.parent, in);
+ if (event->type & (GPM_DOWN|GPM_DRAG)){
+ dlg_select_widget (in->widget.parent, in);
if (event->x >= in->field_len - HISTORY_BUTTON_WIDTH + 1 && should_show_history_button (in)) {
do_show_hist (in);
in->point = 0;
update_input (in, 1);
- }
- }
+ }
+ }
#endif
- return MOU_NORMAL;
-}
+ return MOU_NORMAL;
+}
WInput *
input_new (int y, int x, int color, int len, char *def_text, char *tkname)
int line;
int i, top;
int max_line = l->height-1;
-
+
/* Are we at the top? */
widget_move (&l->widget, 0, l->width);
if (l->list == l->top)
line = 1+ ((l->pos * (l->height-2)) / l->count);
else
line = 0;
-
+
for (i = 1; i < max_line; i++){
widget_move (&l->widget, i, l->width);
if (i != line)
addch ('*');
}
}
-
+
static void
listbox_draw (WListbox *l, Dlg_head *h, int focused)
{
int i;
int sel_line;
int normalc, selc;
- char *text;
+ char *text;
if (focused){
normalc = NORMALC;
sel_line = -1;
for (e = l->top, i = 0; (i < l->height); i++){
-
+
/* Display the entry */
if (e == l->current && sel_line == -1){
sel_line = i;
{
int i;
WLEntry *e;
-
+
i = 0;
e = l->list;
if (!e)
return 0;
-
+
while (1){
/* If we didn't find anything, return */
if (e->hotkey == key)
return e;
-
+
i++;
e = e->next;
}
}
#endif
p = l->list;
-
+
while (l->count--) {
q = p->next;
free (p->text);
listbox_remove_current (WListbox *l, int force)
{
WLEntry *p;
-
+
/* Ok, note: this won't allow for emtpy lists */
if (!force && (!l->count || l->count == 1))
return;
-
+
#ifdef HAVE_X
if (l->widget.wdata != (widget_data) NULL) {
x_listbox_delete_nth (l, l->pos);
if (p->next == l->list) {
l->current = p->prev;
l->pos--;
- }
- else
+ }
+ else
l->current = p->next;
-
+
if (p == l->list)
l->list = l->top = p->next;
} else {
WLEntry *e;
int pos;
int top_seen;
-
+
top_seen = 0;
-
+
/* Special case */
for (pos = 0, e = l->list; pos < l->count; e = e->next, pos++){
if (e == l->top)
top_seen = 1;
-
+
if (e == dest){
l->current = e;
if (top_seen){
if (!l->list)
return 0;
-
+
switch (key){
case KEY_HOME:
case KEY_A1:
l->current = l->top = l->list;
l->pos = 0;
return 1;
-
+
case KEY_END:
case KEY_C1:
l->current = l->top = l->list->prev;
l->top = l->top->prev;
l->pos = l->count - 1;
return 1;
-
+
case XCTRL('p'):
case KEY_UP:
listbox_back (l);
return 1;
-
+
case XCTRL('n'):
case KEY_DOWN:
listbox_fwd (l);
for (i = 0; i < l->height-1; i++)
j |= listbox_fwd (l);
return j > 0;
-
+
case KEY_PPAGE:
case ALT('v'):
for (i = 0; i < l->height-1; i++)
WLEntry *e;
/* int selected_color; Never used */
int ret_code;
-
+
switch (msg){
case WIDGET_INIT:
return x_create_listbox (h, h->wdata, l);
-
+
#ifndef HAVE_XVIEW
case WIDGET_HOTKEY:
if ((e = listbox_check_hotkey (l, par)) != NULL){
return 1;
} else
return 0;
-
+
case WIDGET_KEY:
if ((ret_code = listbox_key (l, par)))
listbox_draw (l, h, 1);
case WIDGET_CURSOR:
widget_move (&l->widget, l->cursor_y, 0);
return 1;
-
+
case WIDGET_FOCUS:
case WIDGET_UNFOCUS:
case WIDGET_DRAW:
listbox_draw (l, h, msg != WIDGET_UNFOCUS);
return 1;
-#endif
+#endif
#endif /* !HAVE_XVIEW */
}
return default_proc (h, msg, par);
{
#ifndef HAVE_X
int i;
-
+
Dlg_head *h = l->widget.parent;
-
+
/* Single click */
if (event->type & GPM_DOWN)
dlg_select_widget (l->widget.parent, l);
else
listbox_select_entry (l, listbox_select_pos (l, l->top,
event->y - 1));
-
+
/* We need to refresh ourselves since the dialog manager doesn't */
/* know about this event */
listbox_callback (h, l, WIDGET_DRAW, 0);
return MOU_NORMAL;
if (event->y < 1 || event->y > l->height)
return MOU_NORMAL;
-
+
dlg_select_widget (l->widget.parent, l);
- listbox_select_entry (l, listbox_select_pos (l, l->top, event->y - 1));
+ listbox_select_entry (l, listbox_select_pos (l, l->top, event->y - 1));
switch (l->action){
case listbox_nothing:
return MOU_ENDLOOP;
}
}
-#endif
+#endif
return MOU_NORMAL;
}
{
WListbox *l = xmalloc (sizeof (WListbox), "listbox_new");
extern int slow_terminal;
-
+
init_widget (&l->widget, y, x, height, width,
(callback_fn)listbox_callback,
(destroy_fn) listbox_destroy, (mouse_h)listbox_event, tkname);
l->allow_duplicates = 1;
l->scrollbar = slow_terminal ? 0 : 1;
widget_want_hotkey (l->widget, 1);
-
+
return l;
}
if (!l->allow_duplicates)
if (listbox_search_text (l, text))
return 0;
-
+
entry = xmalloc (sizeof (WLEntry), "listbox_add_item");
entry->text = strdup (text);
entry->data = data;
entry->hotkey = hotkey;
listbox_append_item (l, entry, pos);
-
+
return entry->text;
}
e = l->list;
if (!e)
return NULL;
-
+
do {
if(!strcmp (e->text, text))
return e;
buttonbar_callback (Dlg_head *h, WButtonBar *bb, int msg, int par)
{
int i;
-
+
switch (msg){
case WIDGET_INIT:
return x_create_buttonbar (h, h->wdata, bb);
}
}
return 0;
-
+
#ifndef HAVE_X
case WIDGET_DRAW:
if (!bb->visible)
init_widget (&bb->widget, LINES-1, 0, 1, COLS,
(callback_fn) buttonbar_callback,
(destroy_fn) buttonbar_destroy, (mouse_h) buttonbar_event, NULL);
-
+
bb->visible = visible;
for (i = 0; i < 10; i++){
bb->labels [i].text = 0;
bb = 0;
continue;
}
-#endif
+#endif
break;
}
}
WButtonBar *bb = find_buttonbar (h, paneletc);
if (!bb)
return;
-
+
set_label_text (bb, idx, text);
bb->labels [idx-1].function = (void (*)(void *)) cback;
bb->labels [idx-1].data = data;
Widget widget;
unsigned int state; /* check button state */
char *text; /* text of check button */
- int hotkey; /* hot KEY */
+ int hotkey; /* hot KEY */
int hotpos; /* offset hot KEY char in text */
} WCheck;
} WButtonBar;
/* Constructors */
-WButton *button_new (int y, int x, int action, int flags, char *text,
+WButton *button_new (int y, int x, int action, int flags, char *text,
int (*callback)(int, void *), void *extra, char *tkname);
WRadio *radio_new (int y, int x, int count, char **text, int use_hotkey, char *tkname);
WCheck *check_new (int y, int x, int state, char *text, char *tkname);
/* Curses utilities
Copyright (C) 1995 Miguel de Icaza, Janne Kukonlehto
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#include "layout.h"
#include "global.h"
-/* "$Id: win.c,v 1.1 2001/12/30 09:55:20 sedwards Exp $" */
+/* "$Id$" */
typedef void (*fnptr)(void);
void print_bytesize (int size, int scale)
{
char buffer [10];
-
+
sprint_bytesize (buffer, size, scale);
printw (buffer);
}
if (!fkey_table_list)
return 0;
-
+
switch (c){
case KEY_F(1):
fkey = 1;
case XCTRL ('p'):
(*backfn)(data, 1);
return 1;
-
+
case KEY_DOWN:
case XCTRL ('n'):
(*forfn)(data, 1);
return 1;
-
+
case KEY_PPAGE:
case ALT('v'):
(*backfn)(data, page_size-1);
return 1;
-
+
case KEY_NPAGE:
case XCTRL('v'):
(*forfn)(data, page_size-1);
return 1;
-
+
case KEY_HOME:
case KEY_A1:
(*topfn)(data, 0);
}
if (additional)
switch (c){
- case 'b':
+ case 'b':
case XCTRL('h'):
case KEY_BACKSPACE:
case 0177:
{ KEY_KP_ADD, "kpplus", N_("+ on keypad") },
{ KEY_KP_SUBTRACT,"kpminus", N_("- on keypad") },
{ KEY_KP_MULTIPLY,"kpasterix", N_("* on keypad") },
-/* From here on, these won't be shown in Learn keys (no space) */
+/* From here on, these won't be shown in Learn keys (no space) */
{ KEY_LEFT, "kpleft", N_("Left arrow keypad") },
{ KEY_RIGHT, "kpright", N_("Right arrow keypad") },
{ KEY_UP, "kpup", N_("Up arrow keypad") },
/* Widget based utility functions.
Copyright (C) 1994, 1995 the Free Software Foundation
-
+
Authors: 1994, 1995, 1996 Miguel de Icaza
1994, 1995 Radek Doulik
1995 Jakub Jelinek
/* }}} */
-/* [] = "$Id: wtools.c,v 1.1 2001/12/30 09:55:20 sedwards Exp $" */
+/* [] = "$Id$" */
#include <config.h>
#include <string.h>
/* no &, but 4 spaces around button for brackets and such */
if (cols < (len = strlen(cancel_string) + 3))
cols = len;
-
+
cols = cols > COLS-6 ? COLS-6 : cols;
/* I'm not sure if this -2 is safe, should test it */
/* Create components */
listbox->dlg = create_dlg (ypos, xpos, lines+6, cols+4, dialog_colors,
listbox_callback, help, "listbox", DLG_CENTER|DLG_GRID);
- x_set_dialog_title (listbox->dlg, title);
-
+ x_set_dialog_title (listbox->dlg, title);
+
listbox->list = listbox_new (2, 2, cols, lines, listbox_finish, 0, "li");
add_widget (listbox->dlg,
- button_new (lines+3, (cols/2 + 2) - len/2,
+ button_new (lines+3, (cols/2 + 2) - len/2,
B_CANCEL, NORMAL_BUTTON, cancel_string, 0, 0, "c"));
add_widget (listbox->dlg, listbox->list);
#ifndef HAVE_X
int run_listbox (Listbox *l)
{
int val;
-
+
run_dlg (l->dlg);
if (l->dlg->ret_value == B_CANCEL)
val = -1;
struct text_struct *info;
info = (struct text_struct *) h->data;
-
+
switch (Msg){
-#ifndef HAVE_X
+#ifndef HAVE_X
case DLG_DRAW:
/* designate window */
attrset (NORMALC);
char *cur_name;
static int query_colors [4];
static struct text_struct pass;
-#ifdef HAVE_X
+#ifdef HAVE_X
static char *buttonnames [10];
#endif
-
+
/* set dialog colors */
query_colors [0] = (flags & D_ERROR) ? ERROR_COLOR : Q_UNSELECTED_COLOR;
query_colors [1] = (flags & D_ERROR) ? REVERSE_COLOR : Q_SELECTED_COLOR;
query_colors [2] = (flags & D_ERROR) ? ERROR_COLOR : COLOR_HOT_NORMAL;
query_colors [3] = (flags & D_ERROR) ? COLOR_HOT_NORMAL : COLOR_HOT_FOCUS;
-
+
if (header == MSG_ERROR)
header = _(" Error ");
-
+
if (count > 0){
va_start (ap, count);
for (i = 0; i < count; i++)
x_set_dialog_title (query_dlg, header);
/* The data we need to pass to the callback */
- query_dlg->cols = cols;
- query_dlg->lines = lines;
+ query_dlg->cols = cols;
+ query_dlg->lines = lines;
query_dlg->data = &pass;
-
+
query_dlg->direction = DIR_BACKWARD;
if (count > 0){
add_widget (query_dlg, button_new
(lines-3, cols, B_USER+i, NORMAL_BUTTON, cur_name,
0, 0, NULL));
-#else
+#else
buttonnames [i] = cur_name;
-#endif
+#endif
cols += xpos;
if (i == sel_pos)
query_dlg->initfocus = query_dlg->current;
#ifdef HAVE_XVIEW
for (i = count - 1; i >= 0; i--)
add_widgetl (query_dlg, button_new
- (0, 0, B_USER+i, NORMAL_BUTTON, buttonnames [i], 0, 0, NULL),
+ (0, 0, B_USER+i, NORMAL_BUTTON, buttonnames [i], 0, 0, NULL),
i ? XV_WLAY_RIGHTOF : XV_WLAY_CENTERROW);
-#endif
+#endif
add_widget (query_dlg, label_new (2, 3, text, NULL));
-
+
/* run dialog and make result */
run_dlg (query_dlg);
switch (query_dlg->ret_value){
vsprintf (&buffer [1], text, args);
strcat (buffer, "\n");
va_end (args);
-
+
query_dialog (header, buffer, error, 0);
#ifndef HAVE_XVIEW
d = last_query_dlg;
tk_dispatch_all ();
return d;
}
-#else
+#else
init_dlg (d);
if (!(error & D_INSERT)){
mi_getch ();
} else
return d;
#endif
-#endif
+#endif
return 0;
}
#endif
static int remove_callback (int i, void *data)
{
Chooser *c = (Chooser *) data;
-
+
listbox_remove_current (c->listbox, 0);
dlg_select_widget (c->dialog, c->listbox);
dlg_select_nth_widget (c->dialog, 0);
-
+
/* Return: do not abort dialog */
return 0;
}
c = (Chooser *) xmalloc (sizeof (Chooser), "new_chooser");
c->dialog = create_dlg (0, 0, lines, cols, dialog_colors, common_dialog_callback,
help, "chooser", DLG_CENTER | DLG_GRID);
-
+
c->dialog->lines = lines;
c->dialog->cols = cols;
-
+
button_lines = flags & CHOOSE_EDITABLE ? 3 : 0;
-
+
c->listbox = listbox_new (1, 1, cols-2, lines-button_lines,
listbox_finish, 0, "listbox");
-
+
if (button_lines){
add_widget (c->dialog, button_new (lines-button_lines+1,
20, B_ENTER, DEFPUSH_BUTTON, _("&Remove"),
add_widget (c->dialog, button_new (lines-button_lines+1,
4, B_CANCEL, NORMAL_BUTTON, _("&Cancel"),
0, 0, "button-cancel"));
- }
+ }
add_widget (c->dialog, c->listbox);
return c;
}
static int quick_callback (struct Dlg_head *h, int id, int Msg)
{
switch (Msg){
-#ifndef HAVE_X
+#ifndef HAVE_X
case DLG_DRAW:
attrset (COLOR_NORMAL);
dlg_erase (h);
draw_box (h, 1, 1, h->lines-2, h->cols-2);
-
+
attrset (COLOR_HOT_NORMAL);
dlg_move (h, 1,((h->cols-strlen (h->data))/2));
addstr (h->data);
break;
-#endif
+#endif
case DLG_KEY:
if (id == '\n'){
h->ret_value = B_ENTER;
qd->title = _(qd->title);
} else
do_int = 0;
-
+
if (qd->xpos == -1)
dd = create_dlg (0, 0, qd->ylen, qd->xlen, dialog_colors, quick_callback,
qd->help, qd->class, DLG_CENTER | DLG_TRYUP | DLG_GRID);
else
- dd = create_dlg (qd->ypos, qd->xpos, qd->ylen, qd->xlen, dialog_colors,
+ dd = create_dlg (qd->ypos, qd->xpos, qd->ylen, qd->xlen, dialog_colors,
quick_callback,
qd->help, qd->class, DLG_GRID);
x_set_dialog_title (dd, qd->title);
-
+
/* We pass this to the callback */
dd->cols = qd->xlen;
dd->lines = qd->ylen;
xpos = (qd->xlen * qw->relative_x)/qw->x_divisions;
ypos = (qd->ylen * qw->relative_y)/qw->y_divisions;
#endif
-
+
switch (qw->widget_type){
case quick_checkbox:
widget = check_new (ypos, xpos, *qw->result, I18N (qw->text), qw->tkname);
r->pos = r->sel = qw->value;
widget = r;
break;
-
+
case quick_button:
widget = button_new (ypos, xpos, qw->value, (qw->value==B_ENTER) ? DEFPUSH_BUTTON : NORMAL_BUTTON,
I18N (qw->text), 0, 0, qw->tkname);
case quick_label:
widget = label_new (ypos, xpos, I18N(qw->text), qw->tkname);
break;
-
+
default:
widget = 0;
fprintf (stderr, "QuickWidget: unknown widget type\n");
case quick_radio:
*qw->result = ((WRadio *) qw->the_widget)->sel;
break;
-
+
case quick_input:
*qw->str_result = strdup (((WInput *) qw->the_widget)->buffer);
break;
}
return_val = dd->ret_value;
destroy_dlg (dd);
-
+
return return_val;
}
{ quick_input, 4, 80, 0, 0, "", 58, 0, 0, 0, XV_WLAY_NEXTROW, 0 },
{ quick_label, 3, 80, 2, 0, "", 0, 0, 0, 0, XV_WLAY_NEXTROW, "label" },
{ 0 } };
-
+
int len;
int i;
int lines;
char *my_str;
char tk_name[64] = "inp|";
-
+
/* we need a unique name for tkname because widget.c:history_tool()
needs a unique name for each dialog - using the header is ideal */
}
#ifdef ENABLE_NLS
- /*
+ /*
* An attempt to place buttons symmetrically, based on actual i18n
* length of the string. It looks nicer with i18n (IMO) - alex
*/
quick_widgets [0].relative_x = len/2 + 4;
- quick_widgets [1].relative_x =
+ quick_widgets [1].relative_x =
len/2 - (strlen (_(quick_widgets [1].text)) + 9);
quick_widgets [0].x_divisions = quick_widgets [1].x_divisions = len;
#endif /* ENABLE_NLS */
-
+
Quick_input.xlen = len;
Quick_input.xpos = -1;
Quick_input.title = header;
quick_widgets [i].relative_y += 2 + lines;
quick_widgets [INPUT_INDEX].str_result = &my_str;
-
+
Quick_input.widgets = quick_widgets;
if (quick_dialog (&Quick_input) != B_CANCEL){
return *(quick_widgets [INPUT_INDEX].str_result);
{ quick_input, 4, 80, 3, 0, "", 58, 0, 0, 0, XV_WLAY_BELOWCLOSE, "input-lbl" },
{ quick_label, 3, 80, 2, 0, "", 0, 0, 0, 0, XV_WLAY_DONTCARE, "label-lbl" },
{ 0 } };
-
+
int len;
int i;
int lines1, lines2;
char *my_str1, *my_str2;
-
+
len = max (strlen (header), msglen (text1, &lines1));
len = max (len, msglen (text2, &lines2)) + 4;
len = max (len, 64);
quick_widgets [4].str_result = &my_str1;
quick_widgets [2].str_result = &my_str2;
-
+
Quick_input.widgets = quick_widgets;
if (quick_dialog (&Quick_input) != B_CANCEL){
*r1 = *(quick_widgets [4].str_result);
if (expanded){
free (result);
return expanded;
- } else
+ } else
return result;
}
return result;
/* Quick Widgets */
enum {
- quick_end, quick_checkbox,
+ quick_end, quick_checkbox,
quick_button, quick_input,
quick_label, quick_radio
} /* quick_t */;
char *tkname; /* Name of the widget used for Tk only */
void *the_widget; /* For the quick quick dialog manager */
} QuickWidget;
-
+
typedef struct {
int xlen, ylen;
int xpos, ypos; /* if -1, then center the dialog */
/* Glue code to run with bsd curses.
Copyright (C) 1994 Miguel de Icaza
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* Routines expected by the Midnight Commander
-
+
Copyright (C) 1999 The Free Software Foundation.
Author Miguel de Icaza
FIXME: This expects the user to always use slang instead of ncurses.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
void
enable_interrupt_key(void) {}
-
+
void
disable_interrupt_key(void) {}
/* Declarations for the extfs.
Copyright (C) 1995 The Free Software Foundation
-
+
Written by: 1995 Jakub Jelinek
This program is free software; you can redistribute it and/or modify
#endif
/* Our virtual file system layer */
-
+
typedef void * vfsid;
struct vfs_stamping;
-
+
typedef struct {
void *(*open)(char *fname, int flags, int mode);
int (*close)(void *vfs_info);
int (*ferrno)(void);
int (*lseek)(void *vfs_info, off_t offset, int whence);
int (*mknod)(char *path, int mode, int dev);
-
+
vfsid (*getid)(char *path, struct vfs_stamping **parent);
int (*nothingisopen)(vfsid id);
void (*free)(vfsid id);
-
+
char *(*getlocalcopy)(char *filename);
void (*ungetlocalcopy)(char *filename, char *local, int has_changed);
int (*mkdir)(char *path, mode_t mode);
int (*rmdir)(char *path);
-
+
int (*ctl)(void *vfs_info, int ctlop, int arg);
int (*setctl)(char *path, int ctlop, char *arg);
void (*forget_about)(char *path);
#ifdef HAVE_MMAP
caddr_t (*mmap)(caddr_t addr, size_t len, int prot, int flags, void *vfs_info, off_t offset);
int (*munmap)(caddr_t addr, size_t len, void *vfs_info);
-#endif
+#endif
} vfs;
/* Other file systems */
extern vfs ftpfs_vfs_ops;
extern vfs mcfs_vfs_ops;
-
+
extern vfs extfs_vfs_ops;
extern vfs undelfs_vfs_ops;
int vfs_file_is_local (char *name);
int vfs_file_is_ftp (char *filename);
char *vfs_get_current_dir (void);
-
+
void vfs_stamp (vfs *, vfsid);
void vfs_rmstamp (vfs *, vfsid, int);
void vfs_addstamp (vfs *, vfsid, struct vfs_stamping *);
void ftpfs_flushdir(void);
#else
# define ftpfs_flushdir()
-# define ftpfs_hint_reread(x)
+# define ftpfs_hint_reread(x)
#endif
/* They fill the file system names */
void mcfs_fill_names (void (*)(char *));
void ftpfs_fill_names (void (*)(char *));
void tarfs_fill_names (void (*)(char *));
-
+
char *ftpfs_gethome (char *);
char *mcfs_gethome (char *);
-
+
char *ftpfs_getupdir (char *);
char *mcfs_getupdir (char *);
# define vfs_free_resources()
# define vfs_timeout_handler()
# define vfs_timeouts() 0
-# define vfs_force_expire ()
+# define vfs_force_expire ()
typedef int vfs;
-
+
# define mc_getlocalcopy(x) NULL
# define mc_ungetlocalcopy(x,y,z)
-# define ftpfs_hint_reread(x)
+# define ftpfs_hint_reread(x)
# define ftpfs_flushdir()
#ifdef _OS_NT
* strtok 4=[402] length=3
* strtok 5=[573] length=3
* strtok 6=[1000] length=4
- *
+ *
* (Strtok:)
* Strtok 1=[] length=0
* Strtok 2=[] length=0
}
if (strchr(delims, (int) *end) != NULL) {
*end++ = '\0';
- p = end;
+ p = end;
break;
}
}
}
if (strchr(delims, (int) *end) != NULL) {
++end;
- p = end;
+ p = end;
break;
}
if (dst < lim) /* Don't overrun token size. */
/* Define if scanning a "long long" with "%qd" works. */
#undef SCANF_LONG_LONG_QD
-
+
/* Define to the type of arg1 for select(). */
#undef SELECT_TYPE_ARG1
cip->errNo = kErrInvalidDirParam;
} else {
if (cdCwd[0] == '\0') /* But allow FTPChdir(cip, ".") to go through. */
- result = 2;
+ result = 2;
else if (strcmp(cdCwd, "..") == 0)
result = FTPCmd(cip, "CDUP");
else
cip->errNo = kErrBadLineList;
break;
}
- onceResult = FTPCmd(cip, "SITE CHMOD %s %s", mode, file);
+ onceResult = FTPCmd(cip, "SITE CHMOD %s %s", mode, file);
if (onceResult < 0) {
batchResult = onceResult;
break;
batchResult = kErrDELEFailed;
cip->errNo = kErrDELEFailed;
} else {
- onceResult = FTPCmd(cip, "RMD %s", file);
+ onceResult = FTPCmd(cip, "RMD %s", file);
if (onceResult < 0) {
batchResult = onceResult;
break;
Error(cip, kDontPerror, "Malloc failed.\n");
} else {
if (strcmp(cdCwd, "..") == 0)
- result = RCmd(cip, rp, "CDUP");
+ result = RCmd(cip, rp, "CDUP");
else
result = RCmd(cip, rp, "CWD %s", cdCwd);
if (result == 2) {
}
/* else: (flags | kChdirOneSubdirAtATime) == true */
-
+
cp = cip->buf;
cp[cip->bufSize - 1] = '\0';
(void) Strncpy(cip->buf, cdCwd, cip->bufSize);
if (cp[cip->bufSize - 1] != '\0')
return (kErrBadParameter);
-
+
mkd = (flags & kChdirAndMkdir);
pwd = (flags & kChdirAndGetCWD);
if ((newname == NULL) || (oldname[0] == '\0'))
return (kErrBadParameter);
-
+
result = FTPCmd(cip, "RNFR %s", oldname);
if (result < 0)
return (result);
cip->errNo = kErrRenameFailed;
return (cip->errNo);
}
-
+
result = FTPCmd(cip, "RNTO %s", newname);
if (result < 0)
return (result);
cip->errNo = kErrBadLineList;
break;
}
- onceResult = FTPCmd(cip, "RMD %s", file);
+ onceResult = FTPCmd(cip, "RMD %s", file);
if (onceResult < 0) {
batchResult = onceResult;
break;
cip->errNo = kErrNoSuchFileOrDirectory;
return (kErrNoSuchFileOrDirectory);
}
- /* else keep going */
+ /* else keep going */
}
if (trySIZE != 0) {
* if (result == kErrSIZEFailed)
* return (kErrNoSuchFileOrDirectory);
*/
- /* else keep going */
+ /* else keep going */
}
cip->errNo = kErrNoSuchFileOrDirectory;
return (kErrNoSuchFileOrDirectory);
}
- /* else keep going */
+ /* else keep going */
}
if (trySTAT != 0) {
cip->errNo = kErrNoSuchFileOrDirectory;
return (kErrNoSuchFileOrDirectory);
}
- /* else keep going */
+ /* else keep going */
}
if (tryNLST != 0) {
cip->errNo = kErrNoSuchFileOrDirectory;
return (kErrNoSuchFileOrDirectory);
}
- /* else keep going */
+ /* else keep going */
}
cip->errNo = kErrCantTellIfFileExists;
cip->errNo = kErrMallocFailed;
Error(cip, kDontPerror, "Malloc failed.\n");
} else {
- result = RCmd(cip, rp, "SITE UTIME %s %s %s %s UTC", file, astr, mstr, cstr);
+ result = RCmd(cip, rp, "SITE UTIME %s %s %s %s UTC", file, astr, mstr, cstr);
if (result < 0) {
DoneWithResponse(cip, rp);
return (result);
#define _libncftp_errno_c_ 1
#include "syshdrs.h"
-
+
static const char *gErrList[kErrLast - kErrFirst + 2] = {
"gethostname() failed", /* -100 */
"hostname does not include domain name", /* -101 */
"timed out while waiting for server response", /* -193 */
"data transfer timed out", /* -194 */
"canceled by user", /* -195 */
- NULL,
+ NULL,
};
int gLibNcFTP_Uses_Me_To_Quiet_Variable_Unused_Warnings = 0;
if (err != kNoErr) {
if (err == eerr) {
if ((s2 == NULL) || (s2[0] == '\0')) {
- if ((s1 == NULL) || (s1[0] == '\0')) {
+ if ((s1 == NULL) || (s1[0] == '\0')) {
(void) fprintf(stderr, "server said: %s\n", cip->lastFTPCmdResultStr);
} else {
(void) fprintf(stderr, "%s: server said: %s\n", s1, cip->lastFTPCmdResultStr);
}
- } else if ((s1 == NULL) || (s1[0] == '\0')) {
+ } else if ((s1 == NULL) || (s1[0] == '\0')) {
(void) fprintf(stderr, "%s: server said: %s\n", s2, cip->lastFTPCmdResultStr);
} else {
(void) fprintf(stderr, "%s %s: server said: %s\n", s1, s2, cip->lastFTPCmdResultStr);
}
} else {
if ((s2 == NULL) || (s2[0] == '\0')) {
- if ((s1 == NULL) || (s1[0] == '\0')) {
+ if ((s1 == NULL) || (s1[0] == '\0')) {
(void) fprintf(stderr, "%s.\n", FTPStrError(cip->errNo));
} else {
(void) fprintf(stderr, "%s: %s.\n", s1, FTPStrError(cip->errNo));
}
- } else if ((s1 == NULL) || (s1[0] == '\0')) {
+ } else if ((s1 == NULL) || (s1[0] == '\0')) {
(void) fprintf(stderr, "%s: %s.\n", s2, FTPStrError(cip->errNo));
} else {
(void) fprintf(stderr, "%s %s: %s.\n", s1, s2, FTPStrError(cip->errNo));
{
struct in_addr ip;
struct hostent *hp;
-
+
/* See if the host was given in the dotted IP format, like "36.44.0.2."
* If it was, inet_addr will convert that to a 32-bit binary value;
* it not, inet_addr will return (-1L).
*/
return (2); /* Success */
}
-
+
hp = gethostbyname(host);
if (hp != NULL) {
/* Maybe the host entry has the full name. */
}
}
# endif /* HAVE_RES_INIT && HAVE__RES_DEFDNAME */
-
+
if (domain[0] == '\0') {
FILE *fp;
char line[256];
cip->servCtlAddr.sin_family = hp->h_addrtype;
/* We'll fill in the rest of the structure below. */
}
-
+
/* After obtaining a socket, try to connect it to a remote
* address. If we didn't get a host entry, we will only have
* one thing to try (ip_address); if we do have one, we can try
#endif /* NO_SIGNALS */
}
}
-
+
if (err < 0) {
/* Could not connect. Close up shop and go home. */
else
(void) STRNCPY(cip->actualHost, (char *) hp->h_name);
- /* Read the startup message from the server. */
+ /* Read the startup message from the server. */
rp = InitResponse();
if (rp == NULL) {
Error(cip, kDontPerror, "Malloc failed.\n");
secondLine = NULL;
if (rp->msg.first->next != NULL)
secondLine = rp->msg.first->next->line;
-
+
if (strstr(firstLine, "Version wu-") != NULL) {
cip->serverType = kServerTypeWuFTPd;
srvr = "wu-ftpd";
cip->connected = 1;
DoneWithResponse(cip, rp);
return (kNoErr);
-
+
fatal:
if (sockfd > 0)
(void) closesocket(sockfd);
if (sock2fd > 0)
- (void) closesocket(sock2fd);
+ (void) closesocket(sock2fd);
CloseFile(&cip->cin);
CloseFile(&cip->cout);
cip->ctrlSocketR = kClosedFileDescriptor;
cip->ourDataAddr.sin_port = 0;
if (Rbind(dataSocket, (struct sockaddr *) &cip->ourDataAddr,
(int) sizeof (cip->ourDataAddr),
- cip->servCtlAddr.sin_addr.s_addr) < 0)
+ cip->servCtlAddr.sin_addr.s_addr) < 0)
#else
if (BindToEphemeralPortNumber(dataSocket, &cip->ourDataAddr, (int) cip->ephemLo, (int) cip->ephemHi) < 0)
#endif
cip->errNo = kErrBindDataSocket;
goto bad;
}
-
+
/* Need to do this so we can figure out which port the system
* gave to us.
*/
if ((result = GetSocketAddress(cip, dataSocket, &cip->ourDataAddr)) < 0)
goto bad;
-
+
if (listen(dataSocket, 1) < 0) {
Error(cip, kDoPerror, "listen failed");
result = kErrListenDataSocket;
cip->errNo = kErrListenDataSocket;
goto bad;
}
-
+
if ((result = SendPort(cip, &cip->ourDataAddr)) < 0)
goto bad;
-
+
cip->dataPortMode = kSendPortMode;
} else {
/* Passive mode. Let the other side decide where to send. */
-
+
cip->servDataAddr = cip->servCtlAddr;
cip->servDataAddr.sin_family = AF_INET;
cip->ourDataAddr = cip->ourCtlAddr;
if (Passive(cip, &cip->servDataAddr, &weirdPort) < 0) {
Error(cip, kDontPerror, "Passive mode refused.\n");
cip->hasPASV = kCommandNotAvailable;
-
+
/* We can try using regular PORT commands, which are required
* by all FTP protocol compliant programs, if you said so.
*
cip->ourDataAddr.sin_port = 0;
if (Rbind(dataSocket, (struct sockaddr *) &cip->ourDataAddr,
(int) sizeof (cip->ourDataAddr),
- cip->servCtlAddr.sin_addr.s_addr) < 0)
+ cip->servCtlAddr.sin_addr.s_addr) < 0)
#else
if (BindToEphemeralPortNumber(dataSocket, &cip->ourDataAddr, (int) cip->ephemLo, (int) cip->ephemHi) < 0)
#endif
cip->errNo = kErrConnectDataSocket;
goto bad;
}
-
+
/* Need to do this so we can figure out which port the system
* gave to us.
*/
return (kErrAcceptDataSocket);
}
}
-
+
cip->dataSocket = newSocket;
}
if (cip->cout != NULL)
(void) fflush(cip->cout);
-
+
msg[0] = (char) (unsigned char) IAC;
msg[1] = (char) (unsigned char) IP;
(void) send(cip->ctrlSocketW, msg, 2, 0);
#else
{
long fsize2 = 0L;
-
+
(void) sscanf(sizestart, "%ld", &fsize2);
*fsize = (longest_int) fsize2;
}
int ec;
size_t len;
char line[1024];
-
+
memset(mlip, 0, sizeof(MLstItem));
mlip->mode = -1;
mlip->fsize = kSizeUnknown;
} else if (ISTREQ(fact, "UNIX.mode")) {
if (val[0] == '0')
sscanf(val, "%o", &mlip->mode);
- else
+ else
sscanf(val, "%i", &mlip->mode);
if (mlip->mode != (-1))
mlip->mode &= 00777;
if ((result = FTPChdir(cip, cwd)) < 0) {
return (result);
}
- }
+ }
return (kNoErr);
} /* FTPRemoteRecursiveFileList */
}
(void) strcpy(cp, file); /* append name after slash */
- (void) strcpy(c2, file);
+ (void) strcpy(c2, file);
if (Lstat(fullpath, st) < 0) {
Error(cip, kDoPerror, "could not stat %s.\n", fullpath);
continue; /* skip "." and ".." directories. */
(void) strcpy(cp, dirp->d_name); /* append name after slash */
- (void) strcpy(c2, dirp->d_name);
+ (void) strcpy(c2, dirp->d_name);
if (Lstat(fullpath, st) < 0) {
Error(cip, kDoPerror, "could not stat %s.\n", fullpath);
continue;
{
LinePtr filePtr, nextFilePtr;
#if defined(WIN32) || defined(_WINDOWS)
- char fullpath[_MAX_PATH + 1];
+ char fullpath[_MAX_PATH + 1];
char relpath[_MAX_PATH + 1];
#else
- char fullpath[512];
+ char fullpath[512];
char relpath[512];
#endif
struct Stat st;
if ((doGlob == 1) && (GLOBCHARSINSTR(pattern))) {
/* Use NLST, which lists files one per line. */
lsflags = "";
-
+
/* Optimize for "NLST *" case which is same as "NLST". */
if (strcmp(pattern, "*") == 0) {
pattern = "";
return; /* Bad user -- leave it alone. */
#endif
}
-
+
(void) Strncpy(pattern, firstent, siz);
if (rest != NULL) {
(void) Strncat(pattern, LOCAL_PATH_DELIM_STR, siz);
longstring gfile;
FILE *fp;
FTPSigProc sp;
-
+
/* Do it the easy way and have the shell do the dirty
* work for us.
*/
(void) sprintf(cmd, "%s -c \"%s %s %s\"", "/bin/sh", "/bin/ls",
"-d", pattern);
#endif
-
+
fp = (FILE *) popen(cmd, "r");
if (fp == NULL) {
Error(cip, kDoPerror, "Could not Lglob: [%s]\n", cmd);
return (kErrBadParameter);
(void) STRNCPY(pattern2, pattern); /* Don't nuke the original. */
-
- /* Pre-process for ~'s. */
+
+ /* Pre-process for ~'s. */
ExpandTilde(pattern2, sizeof(pattern2));
InitLineList(fileList);
result = kNoErr;
Error(cip, kDoPerror, "Could not fdopen.\n");
return (result);
}
-
+
for (;;) {
result = SReadline(&lsSrl, line, sizeof(line) - 2);
if (result == kTimeoutErr) {
#else /* NO_SIGNALS */
-
+
if (result == 0) {
/* This line sets the buffer pointer so that the first thing
* BufferGets will do is reset and fill the buffer using
Error(cip, kDoPerror, "Could not fdopen.\n");
return (result);
}
-
+
for (;;) {
result = SReadline(&lsSrl, line, sizeof(line) - 1);
if (result == kTimeoutErr) {
* for Windows' file timestamps being
* imprecise to one second.
*/
- zaction = kConfirmResumeProcSaidOverwrite;
+ zaction = kConfirmResumeProcSaidOverwrite;
} else if ((longest_int) st.st_size == startPoint) {
/* Already sent file, done. */
- zaction = kConfirmResumeProcSaidSkip;
+ zaction = kConfirmResumeProcSaidSkip;
} else if ((startPoint != kSizeUnknown) && ((longest_int) st.st_size > startPoint)) {
- zaction = kConfirmResumeProcSaidResume;
+ zaction = kConfirmResumeProcSaidResume;
} else {
- zaction = kConfirmResumeProcSaidOverwrite;
+ zaction = kConfirmResumeProcSaidOverwrite;
}
}
return (kErrBadParameter);
if (strcmp(cip->magic, kLibraryMagic))
return (kErrBadMagic);
-
+
if ((dstfile == NULL) || (dstfile[0] == '\0'))
return (kErrBadParameter);
if (fdtouse < 0) {
} else if (nread == 0) {
break;
}
-#else
+#else
gCanBrokenDataJmp = 1;
if (cip->xferTimeout > 0)
(void) alarm(cip->xferTimeout);
return (kErrBadParameter);
if (strcmp(cip->magic, kLibraryMagic))
return (kErrBadMagic);
-
+
if ((file == NULL) || (file[0] == '\0'))
return (kErrBadParameter);
if (fdtouse < 0) {
DisposeLineListContents(LineListPtr list)
{
LinePtr lp, lp2;
-
+
for (lp = list->first; lp != NULL; ) {
lp2 = lp;
lp = lp->next;
RemoveLine(LineListPtr list, LinePtr killMe)
{
LinePtr nextLine, prevLine;
-
- nextLine = killMe->next;
- prevLine = killMe->prev;
+
+ nextLine = killMe->next;
+ prevLine = killMe->prev;
if (killMe->line != NULL) {
killMe->line[0] = '\0'; /* Make it useless just in case. */
free(killMe->line);
if (prevLine != NULL)
prevLine->next = nextLine;
- free(killMe);
+ free(killMe);
list->nLines--;
return (nextLine);
} /* RemoveLine */
{
LinePtr lp;
char *buf;
-
+
lp = (LinePtr) malloc(sizeof(Line));
if (lp != NULL) {
buf = StrDup(buf1);
CopyLineList(LineListPtr dst, LineListPtr src)
{
LinePtr lp, lp2;
-
+
InitLineList(dst);
for (lp = src->first; lp != NULL; ) {
lp2 = lp;
DisposeFileInfoListContents(FileInfoListPtr list)
{
FileInfoPtr lp, lp2;
-
+
for (lp = list->first; lp != NULL; ) {
lp2 = lp;
lp = lp->next;
RemoveFileInfo(FileInfoListPtr list, FileInfoPtr killMe)
{
FileInfoPtr nextFileInfo, prevFileInfo;
-
- nextFileInfo = killMe->next;
- prevFileInfo = killMe->prev;
+
+ nextFileInfo = killMe->next;
+ prevFileInfo = killMe->prev;
if (killMe->lname != NULL) {
killMe->lname[0] = '\0'; /* Make it useless just in case. */
free(killMe->lname);
if (prevFileInfo != NULL)
prevFileInfo->next = nextFileInfo;
- free(killMe);
+ free(killMe);
list->nFileInfos--;
return (nextFileInfo);
} /* RemoveFileInfo */
AddFileInfo(FileInfoListPtr list, FileInfoPtr src)
{
FileInfoPtr lp;
-
+
lp = (FileInfoPtr) malloc(sizeof(FileInfo));
if (lp != NULL) {
(void) memcpy(lp, src, sizeof(FileInfo));
{
FileInfoPtr lp, lp2;
FileInfo newfi;
-
+
for (lp = src->first; lp != NULL; lp = lp2) {
lp2 = lp->next;
newfi = *lp;
/* Suggested timeout values, in seconds, if you use timeouts. */
#define kSuggestedDefaultXferTimeout (0) /* No timeout on data blocks. */
#define kSuggestedDefaultConnTimeout 30
-#define kSuggestedDefaultCtrlTimeout 135 /* 2*MSL, + slop */
+#define kSuggestedDefaultCtrlTimeout 135 /* 2*MSL, + slop */
#define kSuggestedAbortTimeout 10
#define kDefaultMaxDials 3
case 421: /* 421 Service not available, closing control connection. */
result = kErrHostDisconnectedDuringLogin;
goto done;
-
+
case 331: /* 331 User name okay, need password. */
if ((cip->firewallType == kFirewallNotInUse) || (fwloggedin != 0)) {
if ((cip->pass[0] == '\0') && (cip->passphraseProc != NoGetPassphraseProc))
case 503: /* Bad sequence of commands. */
case 550: /* Can't set guest privileges. */
goto done;
-
+
default:
unknown:
if (rp->msg.first == NULL) {
DoneWithResponse(cip, rp);
}
}
-
+
CloseControlConnection(cip);
/* Dispose dynamic data structures, so you won't leak
if (*cp == '@') {
if (at1 == NULL)
at1 = cp;
- else
+ else
return (kMalformedURL);
} else if ((*cp == '\0') || (*cp == '/')) {
hend = cp;
if (lastslash == NULL) {
/* no path, okay */
return (0);
- }
+ }
*lastslash = '\0';
if ((semi = strchr(lastslash + 1, ';')) != NULL) {
int
FTPInitLibrary(const FTPLIPtr lip)
{
- struct servent *ftp;
+ struct servent *ftp;
if (lip == NULL)
return (kErrBadParameter);
InitResponse(void)
{
ResponsePtr rp;
-
+
rp = (ResponsePtr) calloc(SZ(1), sizeof(Response));
if (rp != NULL)
InitLineList(&rp->msg);
TraceResponse(const FTPCIPtr cip, ResponsePtr rp)
{
LinePtr lp;
-
+
if (rp != NULL) {
lp = rp->msg.first;
if (lp != NULL) {
PrintResponse(const FTPCIPtr cip, LineListPtr llp)
{
LinePtr lp;
-
+
if (llp != NULL) {
for (lp = llp->first; lp != NULL; lp = lp->next)
PrintF(cip, "%s\n", lp->line);
* same numerical value of IAC, 255, the sender denotes
* that by having an IAC followed by another IAC.
*/
-
+
/* Get the telnet command. */
c = fgetc(cin);
-
+
switch (c) {
case WILL:
case WONT:
/* Get the option code. */
c = fgetc(cin);
-
+
/* Tell the other side that we don't want
* to do what they're offering to do.
*/
case DONT:
/* Get the option code. */
c = fgetc(cin);
-
+
/* The other side said they are DOing (or not)
* something, which would happen if our side
* asked them to. Since we didn't do that,
addChar:
/* If the buffer supplied has room, add this character to it. */
if (n < siz) {
- *cp++ = c;
+ *cp++ = c;
++n;
}
}
/* Read reply, but EOF was there also. */
rp->hadEof = 1;
}
-
+
while (continuation) {
#ifdef NO_SIGNALS
/* To transfer data, we do these things in order as specifed by
* the RFC.
- *
+ *
* First, we tell the other side to set up a data line. This
* is done below by calling OpenDataConnection(), which sets up
* the socket. When we do that, the other side detects a connection
#endif /* NO_SIGNALS */
result = SendCommand(cip, cmdspec, ap);
va_end(ap);
- if (result < 0) {
+ if (result < 0) {
#ifndef NO_SIGNALS
if (cip->ctrlTimeout > 0)
(void) alarm(0);
-void
+void
FTPAbortDataTransfer(const FTPCIPtr cip)
{
ResponsePtr rp;
cwdBufSize *= 2;
cwdBuf = (char *) Realloc(cwdBuf, cwdBufSize);
}
-
+
return (Strncpy(buf, cwdBuf, size));
#else
#ifdef HAVE_GETWD
static char *cwdBuf = NULL;
char *dp;
-
+
/* Due to the way getwd is usually implemented, it's
* important to have a buffer large enough to hold the
* whole thing. getwd usually starts at the end of the
FGets(char *str, size_t size, FILE *fp)
{
char *cp, *nlptr;
-
+
cp = fgets(str, ((int) size) - 1, fp);
if (cp != NULL) {
cp[((int) size) - 1] = '\0'; /* ensure terminator */
{
char *cp;
struct passwd *pw;
-
+
cp = getlogin();
if (cp == NULL) {
cp = (char *) getenv("LOGNAME");
ZERO(local_tm);
ZERO(utc_tm);
utcOffset = 0;
-
+
local_tm.tm_year = 94; /* Doesn't really matter. */
local_tm.tm_mon = mon;
local_tm.tm_mday = mday;
local_tm.tm_hour = 12;
local_tm.tm_isdst = -1;
local_t = mktime(&local_tm);
-
+
if (local_t != (time_t) -1) {
utc_tmptr = gmtime(&local_t);
utc_tm.tm_year = utc_tmptr->tm_year;
&ut.tm_hour,
&ut.tm_min,
&ut.tm_sec) == 6)
- {
+ {
--ut.tm_mon;
ut.tm_year -= 1900;
mt = mktime(&ut);
*
* |ext1|ext2|ext3|...|extN|
*
- * I.e, each filename extension is delimited with
+ * I.e, each filename extension is delimited with
* a pipe, and we always begin and end the string
* with a pipe.
*/
-/* bookmark.c
+/* bookmark.c
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
}
return NULL; /* Okay to not have one yet. */
}
-
+
(void) chmod(pathName, 00600);
if (FGets(line, sizeof(line), fp) == NULL) {
(void) fprintf(stderr, "%s: invalid format.\n", pathName);
(void) fclose(fp);
return NULL;
}
-
+
/* Sample line we're looking for:
* "NcFTP bookmark-file version: 8"
*/
* "Number of entries: 28" or "# # # 1"
*/
numBookmarks = -1;
-
+
/* At the moment, we can't trust the number stored in the
* file. It's there for future use.
*/
static int
BookmarkSortProc(const void *a, const void *b)
{
- return (ISTRCMP((*(Bookmark *)a).bookmarkName, (*(Bookmark *)b).bookmarkName));
+ return (ISTRCMP((*(Bookmark *)a).bookmarkName, (*(Bookmark *)b).bookmarkName));
} /* BookmarkSortProc */
static int
BookmarkSearchProc(const void *key, const void *b)
{
- return (ISTRCMP((char *) key, (*(Bookmark *)b).bookmarkName));
+ return (ISTRCMP((char *) key, (*(Bookmark *)b).bookmarkName));
} /* BookmarkSearchProc */
const char *cp;
(void) STRNCPY(str, src);
-
+
/* Pick the first "significant" part of the hostname. Usually
* this is the first word in the name, but if it's something like
* ftp.unl.edu, we would want to choose "unl" and not "ftp."
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
typedef struct Bookmark *BookmarkPtr;
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
PrintResp(LineListPtr llp)
{
LinePtr lp;
-
+
if (llp != NULL) {
for (lp = llp->first; lp != NULL; lp = lp->next) {
if ((lp == llp->first) && (ISTRNCMP(lp->line, "CWD command", 11) == 0))
} else {
cdCwdLen = strlen(cdCwd);
if (strcmp(cdCwd, "..") == 0) {
- result = RCmd(cip, rp, "CDUP");
+ result = RCmd(cip, rp, "CDUP");
} else {
result = RCmd(cip, rp, "CWD %s", cdCwd);
}
cip->errNo = kErrInvalidDirParam;
return result;
}
-
+
if ((cdCwd[0] == '\0') || (strcmp(cdCwd, ".") == 0)) {
result = 0;
return (result);
if (np > 0)
(void) printf(" ");
(void) printf("%s", lp->line);
- np++;
+ np++;
}
}
}
return (kConfirmResumeProcSaidBestGuess);
tstr[sizeof(tstr) - 1] = '\0';
- (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &localmtime));
+ (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &localmtime));
(void) printf(
#if defined(HAVE_LONG_LONG) && defined(PRINTF_LONG_LONG_LLD)
"\nThe local file \"%s\" already exists.\n\tLocal: %12lld bytes, dated %s.\n",
);
if ((remotemtime != kModTimeUnknown) && (remotesize != kSizeUnknown)) {
- (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &remotemtime));
+ (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &remotemtime));
(void) printf(
#if defined(HAVE_LONG_LONG) && defined(PRINTF_LONG_LONG_LLD)
"\tRemote: %12lld bytes, dated %s.\n",
remotesize
);
} else if (remotemtime != kModTimeUnknown) {
- (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &remotemtime));
+ (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &remotemtime));
(void) printf(
"\tRemote: size unknown, dated %s.\n",
tstr
/* Leave an extra bit of whitespace for the margins between columns. */
widestName += 2;
-
+
nCols = (screenColumns + 0) / widestName;
nRows = nCmds2Print / nCols;
if ((nCmds2Print % nCols) > 0)
OurInstallationPath(ncftpbookmarks, sizeof(ncftpbookmarks), "ncftpbookmarks.exe");
- hMailSlot = CreateMailslot(kNcFTPBookmarksMailslot, kNcFTPBookmarksMailslotMsgSize, MAILSLOT_WAIT_FOREVER, NULL);
+ hMailSlot = CreateMailslot(kNcFTPBookmarksMailslot, kNcFTPBookmarksMailslotMsgSize, MAILSLOT_WAIT_FOREVER, NULL);
if (hMailSlot == INVALID_HANDLE_VALUE) {
SysPerror("CreateMailslot");
(void) fprintf(stderr, "%s", "This means if you select a bookmark to connect to that NcFTP\n");
(void) fprintf(stderr, "%s", "will not get the message from %s.\n", "ncftpbookmarks.exe");
}
-
+
winExecResult = WinExec(prog, SW_SHOWNORMAL);
if (winExecResult <= 31) switch (winExecResult) {
case ERROR_BAD_FORMAT:
&dwRead,
NULL
);
-
+
if (!rc) {
SysPerror("ReadFile");
} else {
ARGSUSED(gUnusedArg);
shortMode = 1;
-
+
GetoptReset();
while ((opt = Getopt(argc, argv, "v")) >= 0) {
if (opt == 'v')
Trace(-1, " Alias: %s\n", *cpp);
for (j = 0, cpp = hp->h_addr_list; *cpp != NULL; cpp++, ++j) {
MyInetAddr(ipStr, sizeof(ipStr), hp->h_addr_list, j);
- Trace(-1, " Address: %s\n", ipStr);
+ Trace(-1, " Address: %s\n", ipStr);
}
}
}
linePtr = nextLinePtr)
{
nextLinePtr = linePtr->next;
- (void) fprintf(stdout, "%s\n", linePtr->line);
- Trace(0, "%s\n", linePtr->line);
+ (void) fprintf(stdout, "%s\n", linePtr->line);
+ Trace(0, "%s\n", linePtr->line);
}
}
}
linePtr = nextLinePtr)
{
nextLinePtr = linePtr->next;
- (void) fprintf(stdout, "%s\n", linePtr->line);
- Trace(0, "%s\n", linePtr->line);
+ (void) fprintf(stdout, "%s\n", linePtr->line);
+ Trace(0, "%s\n", linePtr->line);
}
}
}
OpenMsg("Connecting to %s...", ipstr);
} else {
OpenMsg("Connecting to %s via %s...", gConn.host, gConn.firewallHost);
- Trace(0, "Fw: %s Type: %d User: %s Pass: %s Port: %u\n",
+ Trace(0, "Fw: %s Type: %d User: %s Pass: %s Port: %u\n",
gConn.firewallHost,
gConn.firewallType,
gConn.firewallUser,
gConn.printResponseProc = NcFTPOpenPrintResponseProc;
gConn.onConnectMsgProc = NcFTPOnConnectMessageProc;
gConn.onLoginMsgProc = NcFTPOnLoginMessageProc;
- gConn.redialStatusProc = NcFTPRedialStatusProc;
+ gConn.redialStatusProc = NcFTPRedialStatusProc;
#ifdef SIGALRM
osigalrm = NcSignal(SIGALRM, (FTPSigProc) SIG_IGN);
#else
result = FTPOpenHost(&gConn);
#endif
-
+
if (gConn.firewallType == kFirewallNotInUse)
(void) STRNCPY(gConn.host, ohost); /* Put it back. */
if (result >= 0) {
}
if (MayUseFirewall(gConn.host, gFirewallType, gFirewallExceptionList) != 0) {
- gConn.firewallType = gFirewallType;
+ gConn.firewallType = gFirewallType;
(void) STRNCPY(gConn.firewallHost, gFirewallHost);
(void) STRNCPY(gConn.firewallUser, gFirewallUser);
(void) STRNCPY(gConn.firewallPass, gFirewallPass);
(void) STRNCPY(gConn.acct, "");
break;
case 'P':
- gConn.port = atoi(gOptArg);
+ gConn.port = atoi(gOptArg);
break;
case 'u':
if (uOptInd <= argc)
printf("\nThe remote file \"%s\" already exists.\n", *remotepath);
if ((localmtime != kModTimeUnknown) && (localsize != kSizeUnknown)) {
- (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &localmtime));
+ (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &localmtime));
(void) printf(
#if defined(HAVE_LONG_LONG) && defined(PRINTF_LONG_LONG_LLD)
"\tLocal: %12lld bytes, dated %s.\n",
localsize
);
} else if (localmtime != kModTimeUnknown) {
- (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &localmtime));
+ (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &localmtime));
(void) printf(
"\tLocal: size unknown, dated %s.\n",
tstr
tstr[sizeof(tstr) - 1] = '\0';
if ((remotemtime != kModTimeUnknown) && (remotesize != kSizeUnknown)) {
- (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &remotemtime));
+ (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &remotemtime));
(void) printf(
#if defined(HAVE_LONG_LONG) && defined(PRINTF_LONG_LONG_LLD)
"\tRemote: %12lld bytes, dated %s.\n",
remotesize
);
} else if (remotemtime != kModTimeUnknown) {
- (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &remotemtime));
+ (void) strftime(tstr, sizeof(tstr) - 1, "%c", localtime((time_t *) &remotemtime));
(void) printf(
"\tRemote: size unknown, dated %s.\n",
tstr
if (np > 0)
(void) printf(" ");
(void) printf("%s", lp->line);
- np++;
+ np++;
}
}
}
STRNCPY(s2, s);
cp = strchr(s2, ':');
if ((s2[0] == 'n') || (s2[0] == '+')) {
- /* "now + XX hours" or
+ /* "now + XX hours" or
* "+ XX hours"
*/
cp = strchr(s2, '+');
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
/* cmds.c */
-/* Based on: "$Id: getline.c,v 1.1 2001/12/30 06:30:21 sedwards Exp $"; */
+/* Based on: "$Id$"; */
static const char copyright[] = "getline: Copyright (C) 1991, 1992, 1993, Chris Thewalt";
/*
* Copyright (C) 1991, 1992, 1993 by Chris Thewalt (thewalt@ce.berkeley.edu)
*
- * Permission to use, copy, modify, and distribute this software
+ * Permission to use, copy, modify, and distribute this software
* for any purpose and without fee is hereby granted, provided
* that the above copyright notices appear in all copies and that both the
* copyright notice and this permission notice appear in supporting
gl_char_cleanup(void) /* undo effects of gl_char_init */
{
#ifdef __unix__
-# ifdef HAVE_TERMIOS_H
+# ifdef HAVE_TERMIOS_H
tcsetattr(0, TCSANOW, &old_termios);
# elif defined(TIOCSETN) /* BSD */
ioctl(0, TIOCSETN, &old_tty);
static int
gl_getcx(int tlen)
-{
+{
int i, c;
c = (-2);
static void
gl_puts(const char *const buf)
{
- int len;
-
+ int len;
+
if (buf) {
len = (int) strlen(buf);
write(1, buf, len);
gl_check_inputrc_for_vi();
}
- gl_init();
+ gl_init();
gl_prompt = (prompt)? prompt : "";
gl_buf[0] = 0;
if (gl_in_hook)
static void
gl_addchar(int c)
-
+
/* adds the character c to the input buffer at current location */
{
int i;
len = (int) strlen(gl_killbuf);
if (len > 0) {
if (gl_overwrite == 0) {
- if (gl_cnt + len >= GL_BUF_SIZE - 1)
+ if (gl_cnt + len >= GL_BUF_SIZE - 1)
gl_error("\n*** Error: getline(): input buffer overflow\n");
for (i=gl_cnt; i >= gl_pos; i--)
gl_buf[i+len] = gl_buf[i];
gl_fixup(gl_prompt, gl_pos, gl_pos+len);
} else {
if (gl_pos + len > gl_cnt) {
- if (gl_pos + len >= GL_BUF_SIZE - 1)
+ if (gl_pos + len >= GL_BUF_SIZE - 1)
gl_error("\n*** Error: getline(): input buffer overflow\n");
gl_buf[gl_pos + len] = 0;
}
int len = gl_cnt;
int loc = gl_width - 5; /* shifts line back to start position */
- if (gl_cnt >= GL_BUF_SIZE - 1)
+ if (gl_cnt >= GL_BUF_SIZE - 1)
gl_error("\n*** Error: getline(): input buffer overflow\n");
if (gl_out_hook) {
change = gl_out_hook(gl_buf);
len = (int) strlen(gl_buf);
- }
+ }
if (loc > len)
loc = len;
gl_fixup(gl_prompt, change, loc); /* must do this before appending \n */
static void
gl_del(int loc, int killsave)
-
+
/*
* Delete a character. The loc variable can be:
* -1 : delete character to left of cursor
static void
gl_kill(int pos)
-
+
/* delete from pos to the end of line */
{
if (pos < gl_cnt) {
int i;
if (direction > 0) { /* forward */
- while (!isspace(gl_buf[pos]) && pos < gl_cnt)
+ while (!isspace(gl_buf[pos]) && pos < gl_cnt)
pos++;
while (isspace(gl_buf[pos]) && pos < gl_cnt)
pos++;
pos--;
while (isspace(gl_buf[pos]) && pos > 0)
pos--;
- while (!isspace(gl_buf[pos]) && pos > 0)
+ while (!isspace(gl_buf[pos]) && pos > 0)
pos--;
if (pos < gl_cnt && isspace(gl_buf[pos])) /* move onto word */
pos++;
static void
gl_word(int direction)
-
+
/* move forward or backword one word */
{
int pos = gl_pos;
if (direction > 0) { /* forward */
- while (!isspace(gl_buf[pos]) && pos < gl_cnt)
+ while (!isspace(gl_buf[pos]) && pos < gl_cnt)
pos++;
while (isspace(gl_buf[pos]) && pos < gl_cnt)
pos++;
pos--;
while (isspace(gl_buf[pos]) && pos > 0)
pos--;
- while (!isspace(gl_buf[pos]) && pos > 0)
+ while (!isspace(gl_buf[pos]) && pos > 0)
pos--;
if (pos < gl_cnt && isspace(gl_buf[pos])) /* move onto word */
pos++;
static void
gl_fixup(const char *prompt, int change, int cursor)
-
-
+
+
/*
* This function is used both for redrawing when input changes or for
* moving within the input line. The parameters are:
}
if (off_right || (off_left && cursor < gl_shift + gl_width - gl_scroll / 2))
extra = 2; /* shift the scrolling boundary */
- else
+ else
extra = 0;
new_shift = cursor + extra + gl_scroll - gl_width;
if (new_shift > 0) {
}
off_right = (gl_cnt > gl_shift + gl_width - 1)? 1 : 0;
right = (off_right)? gl_shift + gl_width - 2 : gl_cnt;
- new_right = (gl_extent && (right > left + gl_extent))?
+ new_right = (gl_extent && (right > left + gl_extent))?
left + gl_extent : right;
}
pad -= (off_right)? gl_width - 1 : gl_cnt - gl_shift;
if (off_right && new_right == right) {
gl_putc('$');
gl_pos++;
- } else {
+ } else {
for (i=0; i < pad; i++) /* erase remains of prev line */
gl_putc(' ');
gl_pos += pad;
hist_init();
gl_init_done = 0;
}
- while (*p == ' ' || *p == '\t' || *p == '\n')
+ while (*p == ' ' || *p == '\t' || *p == '\n')
p++;
if (*p) {
len = (int) strlen(buf);
if (strchr(p, '\n')) /* previously line already has NL stripped */
len--;
- if ((prev == 0) || ((int) strlen(prev) != len) ||
+ if ((prev == 0) || ((int) strlen(prev) != len) ||
strncmp(prev, buf, (size_t) len) != 0) {
hist_buf[hist_last] = hist_save(buf);
prev = hist_buf[hist_last];
if (hist_buf[hist_pos] != 0 && next != hist_last) {
hist_pos = next;
p = hist_buf[hist_pos];
- }
+ }
if (p == 0) {
p = hist_empty_elem;
gl_beep();
if (hist_pos != hist_last) {
hist_pos = (hist_pos+1) % HIST_SIZE;
p = hist_buf[hist_pos];
- }
+ }
if (p == 0) {
p = hist_empty_elem;
gl_beep();
static char *
hist_save(char *p)
-
+
/* makes a copy of the string */
{
char *s = 0;
strcpy(s, p);
}
}
- if (s == 0)
+ if (s == 0)
gl_error("\n*** Error: hist_save() failed on malloc\n");
return s;
}
fprintf(fp, "%s\n", p);
}
fclose(fp);
- }
+ }
} /* gl_histsavefile */
static int search_forw_flg = 0; /* search direction flag */
static int search_last = 0; /* last match found */
-static void
+static void
search_update(int c)
{
if (c == 0) {
}
}
-static void
+static void
search_addchar(int c)
{
char *loc;
}
}
-static void
+static void
search_term(void)
{
gl_search_mode = 0;
gl_fixup(gl_prompt, 0, gl_pos);
}
-static void
+static void
search_back(int new_search)
{
int found = 0;
search_forw_flg = 0;
if (gl_search_mode == 0) {
- search_last = hist_pos = hist_last;
- search_update(0);
+ search_last = hist_pos = hist_last;
+ search_update(0);
gl_search_mode = 1;
gl_buf[0] = 0;
gl_fixup(search_prompt, 0, 0);
if (new_search)
search_last = hist_pos;
found = 1;
- }
+ }
}
} else {
}
}
-static void
+static void
search_forw(int new_search)
{
int found = 0;
search_forw_flg = 1;
if (gl_search_mode == 0) {
- search_last = hist_pos = hist_last;
- search_update(0);
+ search_last = hist_pos = hist_last;
+ search_update(0);
gl_search_mode = 1;
gl_buf[0] = 0;
gl_fixup(search_prompt, 0, 0);
if (new_search)
search_last = hist_pos;
found = 1;
- }
+ }
}
} else {
gl_beep();
if (ncol < 1)
ncol = 1;
- colw = (gl_termw - 8) / ncol;
+ colw = (gl_termw - 8) / ncol;
nrow = nmax / ncol;
if ((nused % ncol) != 0)
nrow++;
if (nrow > (gl_termh - 4)) {
nrow = gl_termh - 4;
- nmax = ncol * nrow;
+ nmax = ncol * nrow;
}
for (i=0; i<(int) sizeof(buf2); i++)
gl_fixup(gl_prompt, gl_pos, gl_pos + 3);
memcpy(curposp, ellipsessave, (size_t) 4);
}
-
+
qmode = 0;
qstart = NULL;
lastspacestart = NULL;
startp = lastspacestart + 1;
else
startp = buf;
-
+
cp = startp;
mlen = (curposp - cp);
nalloced = ntoalloc;
for (i=nused; i<=nalloced; i++)
gl_matchlist[i] = NULL;
-
+
gl_completion_exact_match_extra_char = ' ';
for (nprocused = 0;; nprocused++) {
if (nused == nalloced) {
return;
}
}
-
+
wdir[0] = '\0';
if (GetWindowsDirectory(wdir, sizeof(wdir) - 1) < 1)
(void) strncpy(wdir, ".", sizeof(wdir));
memcpy(dirtoopen2 + len, "*.*", (size_t) 4);
else
memcpy(dirtoopen2 + len, "\\*.*", (size_t) 5);
-
+
/* "Open" the directory. */
memset(&ffd, 0, sizeof(ffd));
searchHandle = FindFirstFile(dirtoopen2, &ffd);
filepfx = start + filepfxoffset;
goto next;
}
-
+
for (;;) {
-
+
name = ffd.cFileName;
if ((name[0] == '.') && ((name[1] == '\0') || ((name[1] == '.') && (name[2] == '\0'))))
goto next; /* Skip . and .. */
-
+
if ((filepfxlen == 0) || (strnicmp(name, filepfx, filepfxlen) == 0)) {
/* match */
len = strlen(name);
searchHandle = NULL;
return NULL;
}
-
+
/* no more items */
FindClose(searchHandle);
searchHandle = NULL;
-
+
if (idx == 1) {
/* There was exactly one match.
* In this special case, we
#ifndef GETLINE_H
#define GETLINE_H
-/* unix systems can #define POSIX to use termios, otherwise
- * the bsd or sysv interface will be used
+/* unix systems can #define POSIX to use termios, otherwise
+ * the bsd or sysv interface will be used
*/
#define GL_BUF_SIZE 1024
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include <stdio.h>
gOptArg = gOptPlace;
else if (nargc <= ++gOptInd) { /* no arg */
gOptPlace = kGetoptErrMsg;
- if (gOptErr)
+ if (gOptErr)
(void) fprintf(stderr, "%s%s%c\n", *nargv, ": option requires an argument -- ", gOptOpt);
return(kGetoptBadChar);
} else /* white space */
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#define kGetoptBadChar ((int) '?')
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#if defined(WIN32) || defined(_WINDOWS)
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
ncol = (screenColumns - 1) / ((int) dirp->maxFileLen + 2 + /*1or0*/ endChars);
if (ncol < 1)
ncol = 1;
- colw = (screenColumns - 1) / ncol;
+ colw = (screenColumns - 1) / ncol;
n = dirp->nFileInfos;
nrow = n / ncol;
if ((n % ncol) != 0)
}
if (rlisted != 0) {
- Trace(0, "Remote listing contents {\n");
+ Trace(0, "Remote listing contents {\n");
for (linePtr = dirContents.first;
linePtr != NULL;
linePtr = nextLinePtr)
{
nextLinePtr = linePtr->next;
- Trace(0, " %s\n", linePtr->line);
+ Trace(0, " %s\n", linePtr->line);
}
- Trace(0, "}\n");
+ Trace(0, "}\n");
}
if (parsed >= 0) {
linePtr = nextLinePtr)
{
nextLinePtr = linePtr->next;
- (void) fprintf(stream, "%s\n", linePtr->line);
- Trace(0, " %s\n", linePtr->line);
+ (void) fprintf(stream, "%s\n", linePtr->line);
+ Trace(0, " %s\n", linePtr->line);
}
}
DisposeLineListContents(&dirContents);
} /* Ls */
-
-
+
+
#if defined(WIN32) || defined(_WINDOWS)
/* Prints a local directory listing in the specified format on the specified
* output stream.
if (strpbrk(itempath, "*?") == NULL)
STRNCAT(itempath, "\\*.*");
}
-
+
InitLineList(&ll);
result = FTPLocalGlob(&gConn, &ll, itempath, kGlobYes);
if (result < 0) {
if (LineListToFileInfoList(&ll, &fil) < 0)
return;
DisposeLineListContents(&ll);
-
+
for (fip = fil.first; fip != NULL; fip = fip2) {
fip2 = fip->next;
if (Stat(fip->relname, &st) < 0) {
else
LsC(&fil, endChars, stream);
}
-
+
DisposeFileInfoListContents(&fil);
} /* LLs */
#endif
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#define kLsCacheItemLifetime 900 /* seconds */
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
}
if (MayUseFirewall(gConn.host, gFirewallType, gFirewallExceptionList) != 0) {
- gConn.firewallType = gFirewallType;
+ gConn.firewallType = gFirewallType;
(void) STRNCPY(gConn.firewallHost, gFirewallHost);
(void) STRNCPY(gConn.firewallUser, gFirewallUser);
(void) STRNCPY(gConn.firewallPass, gFirewallPass);
}
gURLMode = 1;
if (MayUseFirewall(gConn.host, gFirewallType, gFirewallExceptionList) != 0) {
- gConn.firewallType = gFirewallType;
+ gConn.firewallType = gFirewallType;
(void) STRNCPY(gConn.firewallHost, gFirewallHost);
(void) STRNCPY(gConn.firewallUser, gFirewallUser);
(void) STRNCPY(gConn.firewallPass, gFirewallPass);
if (gNumProgramRuns <= 1)
(void) printf("\n%s\n", gCopyright + 5);
- Trace(0, "Fw: %s Type: %d User: %s Pass: %s Port: %u\n",
+ Trace(0, "Fw: %s Type: %d User: %s Pass: %s Port: %u\n",
gFirewallHost,
gFirewallType,
gFirewallUser,
while ((c = Getopt(argc, argv, "P:u:p:j:J:rd:g:FVLD")) > 0) switch(c) {
case 'P':
- gConn.port = atoi(gOptArg);
+ gConn.port = atoi(gOptArg);
break;
case 'u':
(void) STRNCPY(gConn.user, gOptArg);
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
/* main.c */
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
{
char buf[256];
char *a, *b;
-
+
memcpy(buf, gOneTimeMessagesSeen, sizeof(buf));
for (a = buf; (b = strtok(a, ",\n")) != NULL; a = NULL) {
if (strcmp(msg, b) == 0)
else {
STRNCAT(gOneTimeMessagesSeen, ",");
STRNCAT(gOneTimeMessagesSeen, msg);
- }
+ }
} /* SetSeenOneTimeMessage */
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#if defined(WIN32) || defined(_WINDOWS)
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
FileToURL(url, sizeof(url), cip->rname, gRemoteCWD, cip->startingWorkingDirectory, cip->user, cip->pass, cip->host, cip->port);
LogXfer((cip->netMode == kNetReading) ? "get" : "put", url);
- }
+ }
#endif
break;
}
FileToURL(url, sizeof(url), cip->rname, gRemoteCWD, cip->startingWorkingDirectory, cip->user, cip->pass, cip->host, cip->port);
LogXfer((cip->netMode == kNetReading) ? "get" : "put", url);
- }
+ }
#endif
break;
}
(cip->netMode == kNetReading) ? "Receiving" : "Sending",
cip->lname
);
-
+
for (i=0; i < (int) sizeof(bar) - 1; i++)
bar[i] = '=';
bar[i] = '\0';
maxBarLen = gScreenColumns - 1 - 28;
for (s = cip->expectedSize; s > 0; s /= 10L)
maxBarLen--;
-
+
/* Create a specification we can hand to printf. */
#if defined(HAVE_LONG_LONG) && defined(PRINTF_LONG_LONG_LLD)
(void) sprintf(spec1, " 0 %%%ds %%lld bytes. ETA: --:--", maxBarLen);
-
+
/* Print the first invocation, which is an empty graph
* plus the other stuff.
*/
*/
if (curBarLen < 1)
curBarLen = 1;
-
+
bar[curBarLen - 1] = '>';
bar[curBarLen] = '\0';
STRNCPY(spec1, "\r%3d%% 0 ");
#if defined(HAVE_LONG_LONG) && defined(PRINTF_LONG_LONG_LLD)
- (void) sprintf(spec3, "%%%ds %%lld bytes. %s%%3d:%%02d",
+ (void) sprintf(spec3, "%%%ds %%lld bytes. %s%%3d:%%02d",
maxBarLen - curBarLen,
"ETA:"
);
#elif defined(HAVE_LONG_LONG) && defined(PRINTF_LONG_LONG_QD)
- (void) sprintf(spec3, "%%%ds %%qd bytes. %s%%3d:%%02d",
+ (void) sprintf(spec3, "%%%ds %%qd bytes. %s%%3d:%%02d",
maxBarLen - curBarLen,
"ETA:"
);
#elif defined(HAVE_LONG_LONG) && defined(PRINTF_LONG_LONG_I64D)
- (void) sprintf(spec3, "%%%ds %%I64d bytes. %s%%3d:%%02d",
+ (void) sprintf(spec3, "%%%ds %%I64d bytes. %s%%3d:%%02d",
maxBarLen - curBarLen,
"ETA:"
);
#else
- (void) sprintf(spec3, "%%%ds %%ld bytes. %s%%3d:%%02d",
+ (void) sprintf(spec3, "%%%ds %%ld bytes. %s%%3d:%%02d",
maxBarLen - curBarLen,
"ETA:"
);
#endif
-
+
/* We also show the percentage as a number at the left side. */
perc = (int) (cip->percentCompleted);
secsLeft = (int) (cip->secLeft);
minLeft = 999;
secsLeft = 59;
}
-
+
/* Print the updated information. */
fprintf(stderr, spec1, perc);
fprintf(stderr, "%s%s%s", tcap_reverse, bar, tcap_normal);
FileToURL(url, sizeof(url), cip->rname, gRemoteCWD, cip->startingWorkingDirectory, cip->user, cip->pass, cip->host, cip->port);
LogXfer((cip->netMode == kNetReading) ? "get" : "put", url);
- }
+ }
#endif
break;
}
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#define kKilobyte 1024
* Note: It should still be simple to backport the old GNU Readline
* support in here. Feel free to do that if you hate NcFTP's built-in
* implementation.
- *
+ *
*/
#include "syshdrs.h"
gXterm = gXtermTitle = 1;
#else
const char *term;
-
+
gXterm = gXtermTitle = 0;
gCurXtermTitleStr[0] = '\0';
} else if ((flags & kCompletePrefOpt) != 0) {
cp = PrefOptCompletionFunction(text, state);
return cp;
- }
+ }
return NULL;
} /* CompletionFunction */
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#if defined(WIN32) || defined(_WINDOWS)
#define IDI_NCFTP_ICON 101
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
* to match only one name in the list.
*/
canp = (CommandPtr) bsearch(name, gCommands, gNumCommands, sizeof(Command), (bsearch_proc_t) CommandSubSearchCmp);
-
+
if (canp != kNoCommand) {
/* Check the entry above us and see if the name we're looking
* for would match that, too.
ai.noglobargv, 0);
if (bUsed <= 0)
break;
- tUsed += bUsed;
+ tUsed += bUsed;
if (ai.cargc == 0)
continue;
gRunningCommand = 1;
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
typedef struct ArgvInfo {
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
time_t t;
int fd;
- if (gOurDirectoryPath[0] != '\0') {
+ if (gOurDirectoryPath[0] != '\0') {
time(&t);
t -= 86400;
(void) OurDirectoryPath(f, sizeof(f), kSpoolLog);
*sdir = '\0';
/* Don't create in root directory. */
- if (gOurDirectoryPath[0] != '\0') {
+ if (gOurDirectoryPath[0] != '\0') {
(void) OurDirectoryPath(sdir, size, kSpoolDir);
if ((stat(sdir, &st) < 0) && (MkDirs(sdir, 00700) < 0)) {
perror(sdir);
}
prog = ncftpbatch;
OurInstallationPath(ncftpbatch, sizeof(ncftpbatch), "ncftpbatch.exe");
-
+
winExecResult = WinExec(prog, SW_SHOWNORMAL);
if (winExecResult <= 31) switch (winExecResult) {
case ERROR_BAD_FORMAT:
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#define kSpoolDir "spool"
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#if defined(HAVE_CONFIG_H)
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#if defined(WIN32) || defined(_WINDOWS)
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
#include "syshdrs.h"
{
struct in_addr ip;
struct hostent *hp;
-
+
/* See if the host was given in the dotted IP format, like "36.44.0.2."
* If it was, inet_addr will convert that to a 32-bit binary value;
* it not, inet_addr will return (-1L).
dwSize = (DWORD) (sizeof(gOurInstallationPath) - 1);
dwType = 0;
if (RegQueryValueEx(
- hkey,
- NULL,
- (DWORD *) 0,
- &dwType,
- (LPBYTE) gOurInstallationPath,
+ hkey,
+ NULL,
+ (DWORD *) 0,
+ &dwType,
+ (LPBYTE) gOurInstallationPath,
&dwSize) == ERROR_SUCCESS)
{
// This gave us the path to ncftp.exe;
}
RegCloseKey(hkey);
}
-
+
if (gOurInstallationPath[0] == '\0') {
if (GetModuleFileName(NULL, gOurInstallationPath, (DWORD) sizeof(gOurInstallationPath) - 1) <= 0) {
ZeroMemory(gOurInstallationPath, (DWORD) sizeof(gOurInstallationPath));
-int
+int
StrToBool(const char *const s)
{
int c;
int result;
-
+
c = *s;
if (isupper(c))
c = tolower(c);
&ut.tm_hour,
&ut.tm_min,
&ut.tm_sec) == 6)
- {
+ {
--ut.tm_mon;
ut.tm_year -= 1900;
result = mktime(&ut);
void SysPerror(const char *const errMsg)
{
char reason[128];
-
+
FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
*
* Copyright (c) 1992-2001 by Mike Gleason.
* All rights reserved.
- *
+ *
*/
typedef int (*qsort_proc_t)(const void *, const void *);
}
if (errno != EINTR)
break;
- }
+ }
alarm(0);
(void) SSignal(SIGALRM, (sio_sigproc_t) sigalrm);
errno = 0;
result = connect(sfd, (struct sockaddr *) addr,
(int) sizeof(struct sockaddr_in));
- if (result == 0)
+ if (result == 0)
return 0; /* Already?!? */
- if ((result < 0)
+ if ((result < 0)
#if defined(WIN32) || defined(_WINDOWS)
&& ((wsaErrno = WSAGetLastError()) != WSAEWOULDBLOCK)
&& (wsaErrno != WSAEINPROGRESS)
/* ready */
break;
} else if (result == 0) {
- /* timeout */
+ /* timeout */
errno = ETIMEDOUT;
SETWSATIMEOUTERR
/* Don't bother turning off FIONBIO */
}
goto done;
}
-
+
if (!firstRead || ((retry & kNoFirstSelect) == 0)) {
forever {
errno = 0;
/* ready */
break;
} else if (result == 0) {
- /* timeout */
+ /* timeout */
nread = size - nleft;
if ((nread > 0) && ((retry & (kFullBufferRequired|kFullBufferRequiredExceptLast)) == 0))
return (nread);
* set buf[nread - 1] = '\0', if nread > 0.
*/
-int
+int
SReadline(SReadlineInfo *srl, char *const linebuf, size_t linebufsize)
{
int err;
/* ready */
break;
} else if (result == 0) {
- /* timeout */
+ /* timeout */
nread = size - nleft;
if ((nread > 0) && (retry == kFullBufferNotRequired))
return (nread);
nread = 0;
forever {
alen = sizeof(struct sockaddr_in);
-
+
forever {
errno = 0;
FD_ZERO(&ss);
done = now + tlen;
tleft = (int) (done - now);
forever {
-
+
for (;;) {
errno = 0;
FD_ZERO(&ss);
/* ready */
break;
} else if (result == 0) {
- /* timeout */
+ /* timeout */
nwrote = size - nleft;
if (nwrote > 0)
return (nwrote);
/* ready */
break;
} else if (result == 0) {
- /* timeout */
+ /* timeout */
errno = ETIMEDOUT;
SETWSATIMEOUTERR
return (kTimeoutErr);
/* ready */
break;
} else if (result == 0) {
- /* timeout */
+ /* timeout */
errno = ETIMEDOUT;
return (kTimeoutErr);
} else if (errno != EINTR) {
#include "syshdrs.h"
-/*
+/*
* Return zero if the operation timed-out or erred-out, otherwise non-zero.
*/
int
-/*
+/*
* Return zero if the operation timed-out or erred-out, otherwise non-zero.
*/
int
/* ready */
break;
} else if (result == 0) {
- /* timeout */
+ /* timeout */
nwrote = size - nleft;
if (nwrote > 0)
return (nwrote);
}
firstWrite = 0;
}
-
+
#if defined(WIN32) || defined(_WINDOWS)
nwrote = send(sfd, buf, size, 0);
#else
* if l_onoff == 0:
* close(2) returns immediately; any buffered data is sent later
* (default)
- *
+ *
* if l_onoff != 0:
* if l_linger == 0, close(2) returns after discarding any unsent data
* if l_linger != 0, close(2) does not return until buffered data is sent
/* #undef HAVE_SOCKADDR_UN_SUN_LEN */
/* #define HAVE_STRUCT_CMSGDHR 1 */
-
+
/* Define to the type of arg1 for select(). */
#define SELECT_TYPE_ARG1 int
int nAdapterCount;
int i;
- char* PacketLibraryVersion;
+ char* PacketLibraryVersion;
// Attemp to load the WinPCap dynamic link library
-/* $Id: notevil.c,v 1.5 2001/02/18 19:31:38 phreak Exp $
+/* $Id$
*
* notevil.c
- *
+ *
* --------------------------------------------------------------------
*
* This software is free software; you can redistribute it and/or
* You should have received a copy of the GNU Library General Public
* License along with this software; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 675 Mass Ave,
- * Cambridge, MA 02139, USA.
+ * Cambridge, MA 02139, USA.
*
* --------------------------------------------------------------------
* ReactOS Coders Console Parade
LARGE_INTEGER lint;
DWORD Written;
COORD Coord = { 0, 0 };
-
+
myself = GetModuleHandle(NULL);
GetConsoleScreenBufferInfo (GetStdHandle(STD_OUTPUT_HANDLE),
//======================================================================
//
-// $Id: chkdsk.c,v 1.3 2000/04/25 23:22:57 ea Exp $
+// $Id$
//
// Chkdskx
//
// Copyright (c) 1998 Mark Russinovich
// Systems Internals
// http://www.sysinternals.com/
-//
+//
// --------------------------------------------------------------------
//
// This software is free software; you can redistribute it and/or
// You should have received a copy of the GNU Library General Public
// License along with this software; see the file COPYING.LIB. If
// not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-// Cambridge, MA 02139, USA.
+// Cambridge, MA 02139, USA.
//
// --------------------------------------------------------------------
-//
+//
// Chkdsk clone that demonstrates the use of the FMIFS file system
// utility library.
//
// 1999 February (Emanuele Aliberti)
// Adapted for ReactOS and lcc-win32.
-//
+//
// 1999 April (Emanuele Aliberti)
// Adapted for ReactOS and egcs.
//
//----------------------------------------------------------------------
-//
+//
// Usage
//
// Tell the user how to use the program
PBOOLEAN status;
PTEXTOUTPUT output;
- //
+ //
// We get other types of commands,
// but we don't have to pay attention to them
//
case UNKNOWN2:
wprintf(L"UNKNOWN2\r");
break;
-
+
case UNKNOWN3:
wprintf(L"UNKNOWN3\r");
break;
-
+
case UNKNOWN4:
wprintf(L"UNKNOWN4\r");
break;
-
+
case UNKNOWN5:
wprintf(L"UNKNOWN5\r");
break;
-
+
case UNKNOWN7:
wprintf(L"UNKNOWN7\r");
break;
-
+
case UNKNOWN8:
wprintf(L"UNKNOWN8\r");
break;
-
+
case UNKNOWN9:
wprintf(L"UNKNOWN9\r");
break;
-
+
case UNKNOWNA:
wprintf(L"UNKNOWNA\r");
break;
-
+
case UNKNOWNC:
wprintf(L"UNKNOWNC\r");
break;
-
+
case UNKNOWND:
wprintf(L"UNKNOWND\r");
break;
-
+
case INSUFFICIENTRIGHTS:
wprintf(L"INSUFFICIENTRIGHTS\r");
break;
-
+
case STRUCTUREPROGRESS:
wprintf(L"STRUCTUREPROGRESS\r");
break;
-
+
case DONEWITHSTRUCTURE:
wprintf(L"DONEWITHSTRUCTURE\r");
break;
-
+
case PROGRESS:
percent = (PDWORD) Argument;
wprintf(L"%d percent completed.\r", *percent);
//----------------------------------------------------------------------
-//
+//
// WMain
//
-// Engine. Just get command line switches and fire off a chkdsk. This
-// could also be done in a GUI like Explorer does when you select a
+// Engine. Just get command line switches and fire off a chkdsk. This
+// could also be done in a GUI like Explorer does when you select a
// drive and run a check on it.
//
// We do this in UNICODE because the chkdsk command expects PWCHAR
return -1;
}
- //
+ //
// Get the drive's format
//
if( !Drive )
Drive = CurrentDirectory;
//
- // Determine the drive's file system format, which we need to
+ // Determine the drive's file system format, which we need to
// tell chkdsk
//
if( !GetVolumeInformationW(
- Drive,
+ Drive,
volumeName,
- sizeof volumeName,
+ sizeof volumeName,
& serialNumber,
& maxComponent,
- & flags,
+ & flags,
fileSystem,
sizeof fileSystem
)
);
volumeHandle = CreateFileW(
volumeName,
- GENERIC_WRITE,
+ GENERIC_WRITE,
0,
NULL,
- OPEN_EXISTING,
+ OPEN_EXISTING,
0,
- 0
+ 0
);
if( volumeHandle == INVALID_HANDLE_VALUE )
{
/* $Id$
- *
+ *
* chklib.c
- *
+ *
* Copyright (C) 1998, 1999 Emanuele Aliberti.
*
* --------------------------------------------------------------------
* You should have received a copy of the GNU General Public
* License along with this software; see the file COPYING. If
* not, write to the Free Software Foundation, Inc., 675 Mass Ave,
- * Cambridge, MA 02139, USA.
+ * Cambridge, MA 02139, USA.
*
* --------------------------------------------------------------------
* Check a PE DLL for loading and get an exported symbol's address
ModuleName,
& Zero
);
- if (Size == 0)
+ if (Size == 0)
{
PrintWin32Error(
L"GetFileVersionInfoSize",
}
/*
VerQueryValue(
- vi,
- L"\\StringFileInfo\\040904E4\\FileDescription",
+ vi,
+ L"\\StringFileInfo\\040904E4\\FileDescription",
& lpBuffer,
& dwBytes
);
)
{
FARPROC EntryPoint;
-
+
printf(
"[%s]\n",
SymbolName
HINSTANCE dll;
TCHAR ModuleName [_MAX_PATH];
- if (argc < 2)
+ if (argc < 2)
{
fprintf(
- stderr,
+ stderr,
"\
ReactOS System Tools\n\
Check a Dynamic Link Library (DLL) for loading\n\
"%s: loading %s failed (%d).\n",
argv[0],
argv[1],
- LastError
+ LastError
);
exit(EXIT_FAILURE);
}
#ifndef _INC_CONFIG_H
#define _INC_CONFIG_H
-/* $Id: config.h,v 1.1 1999/05/16 07:27:35 ea Exp $ */
+/* $Id$ */
#define FMIFS_IMPORT_DLL
#define REACTOS_NO_SECURITY_SS
#endif /* ndef _INC_CONFIG_H */
ctm.c - main program file
Written by: Aleksey Bragin (aleksey@studiocerebral.com)
-
+
Most of the code dealing with getting system parameters is taken from
ReactOS Task Manager written by Brian Palmer (brianp@reactos.org)
-
+
Localization features added by Hervé Poussineau (hpoussineau@fr.st)
History:
20 March 2003 - v0.03, works good under ReactOS, and allows process
killing
18 March 2003 - Initial version 0.01, doesn't work under RectOS
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
TCHAR lpSeparator[80];
TCHAR lpHeader[80];
TCHAR lpMemUnit[3];
-TCHAR lpIdleProcess[80];;
+TCHAR lpIdleProcess[80];
TCHAR lpTitle[80];
TCHAR lpHeader[80];
TCHAR lpMenu[80];
// Footer
pos.X = 2; pos.Y = ProcPerScreen+6;
WriteConsoleOutputCharacter(hStdout, lpSeparator, _tcslen(lpSeparator), pos, &numChars);
-
+
// Menu
pos.X = 2; pos.Y = ProcPerScreen+7;
WriteConsoleOutputCharacter(hStdout, lpEmpty, _tcslen(lpEmpty), pos, &numChars);
TCHAR lpMemUsg[12];
TCHAR lpPageFaults[15];
WORD wColor;
-
+
for (i = 0; i < 80; i++)
lpStr[i] = _T(' ');
if (idx < lines && scrolled + idx < ProcessCount)
{
// image name
-#ifdef _UNICODE
- len = wcslen(pPerfData[scrolled+idx].ImageName);
+#ifdef _UNICODE
+ len = wcslen(pPerfData[scrolled+idx].ImageName);
#else
WideCharToMultiByte(CP_ACP, 0, pPerfData[scrolled+idx].ImageName, -1,
imgName, MAX_PATH, NULL, NULL);
pos.X = 3; pos.Y = 6+idx;
if (selection == idx)
{
- wColor = BACKGROUND_GREEN |
- FOREGROUND_RED |
- FOREGROUND_GREEN |
+ wColor = BACKGROUND_GREEN |
+ FOREGROUND_RED |
+ FOREGROUND_GREEN |
FOREGROUND_BLUE;
}
else
{
wColor = BACKGROUND_BLUE |
- FOREGROUND_RED |
- FOREGROUND_GREEN |
+ FOREGROUND_RED |
+ FOREGROUND_GREEN |
FOREGROUND_BLUE;
}
- FillConsoleOutputAttribute(
- hStdout, // screen buffer handle
- wColor, // color to fill with
+ FillConsoleOutputAttribute(
+ hStdout, // screen buffer handle
+ wColor, // color to fill with
columnRightPositions[0] - 1, // number of cells to fill
- pos, // first cell to write to
- &numChars); // actual number written
+ pos, // first cell to write to
+ &numChars); // actual number written
}
return;
HANDLE hProcess;
pId = pPerfData[selection+scrolled].ProcessId;
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pId);
-
+
if (hProcess)
{
if (!TerminateProcess(hProcess, 0))
Sleep(1000);
}
}
-
+
first = 0;
}
else if (key == VK_UP)
else if ((selection == MAX_PROC-1) && (selection+scrolled < ProcessCount-1))
scrolled++;
}
-
+
return FALSE;
}
if (status != NO_ERROR)
return;
#endif
- // Get processor information
+ // Get processor information
SysProcessorTimeInfo = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)malloc(sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberProcessors);
status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberProcessors, &ulSize);
// CurrentCpuIdle = IdleTime / SystemTime
dbIdleTime = dbIdleTime / dbSystemTime;
dbKernelTime = dbKernelTime / dbSystemTime;
-
+
// CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors
- dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberProcessors;// + 0.5;
+ dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberProcessors;// + 0.5;
dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.NumberProcessors;// + 0.5;
}
{
int i;
TCHAR lpStr[80];
-
+
for (i = 0; i < 80; i++)
lpEmpty[i] = lpHeader[i] = _T(' ');
lpEmpty[79] = _T('\0');
columnRightPositions[4] = columnRightPositions[3] + _tcslen(lpStr) + 3;
_tcsncpy(&lpHeader[columnRightPositions[3] + 2], lpStr, _tcslen(lpStr));
}
-
+
for (i = 0; i < columnRightPositions[4]; i++)
lpSeparator[i] = _T('-');
lpHeader[0] = _T('|');
lpSeparator[columnRightPositions[4] + 1] = _T('\0');
lpHeader[columnRightPositions[4] + 1] = _T('\0');
-
+
if (!LoadString(hInst, IDS_APP_TITLE, lpTitle, 80))
lpTitle[0] = _T('\0');
if (!LoadString(hInst, IDS_COLUMN_MEM_UNIT, lpMemUnit, 3))
lpMenu[0] = _T('\0');
if (!LoadString(hInst, IDS_IDLE_PROCESS, lpIdleProcess, 80))
lpIdleProcess[0] = _T('\0');
-
+
if (LoadString(hInst, IDS_MENU_QUIT, lpStr, 2))
KEY_QUIT = lpStr[0];
if (LoadString(hInst, IDS_MENU_KILL_PROCESS, lpStr, 2))
ctm.h - header file for main program
Written by: Aleksey Bragin (aleksey@studiocerebral.com)
-
+
Most of this file content is taken from
ReactOS Task Manager written by Brian Palmer (brianp@reactos.org)
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#ifndef _FMIFS_H
#define _FMIFS_H
-/* $Id: fmifs.h,v 1.1 1999/05/16 07:27:35 ea Exp $
+/* $Id$
*
* fmifs.h
*
{
DWORD Lines;
PCHAR Output;
-
+
} TEXTOUTPUT, *PTEXTOUTPUT;
VOID
STDCALL
ChkDsk(
- PWCHAR DriveRoot,
+ PWCHAR DriveRoot,
PWCHAR Format,
- BOOL CorrectErrors,
- BOOL Verbose,
+ BOOL CorrectErrors,
+ BOOL Verbose,
BOOL CheckOnlyIfDirty,
- BOOL ScanDrive,
- PVOID Unused2,
+ BOOL ScanDrive,
+ PVOID Unused2,
PVOID Unused3,
PFMIFSCALLBACK Callback
);
VOID
STDCALL
ChkDskEx(
- PWCHAR DriveRoot,
+ PWCHAR DriveRoot,
PWCHAR Format,
- BOOL CorrectErrors,
- BOOL Verbose,
+ BOOL CorrectErrors,
+ BOOL Verbose,
BOOL CheckOnlyIfDirty,
- BOOL ScanDrive,
- PVOID Unused2,
+ BOOL ScanDrive,
+ PVOID Unused2,
PVOID Unused3,
PFMIFSCALLBACK Callback
);
// Copyright (c) 1998 Mark Russinovich
// Systems Internals
// http://www.sysinternals.com/
-//
+//
// This software is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License as
// published by the Free Software Foundation; either version 2 of the
// You should have received a copy of the GNU Library General Public
// License along with this software; see the file COPYING.LIB. If
// not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-// Cambridge, MA 02139, USA.
+// Cambridge, MA 02139, USA.
//
// ---------------------------------------------------------------------
// Format clone that demonstrates the use of the FMIFS file system
//
// 1999 February (Emanuele Aliberti)
// Adapted for ReactOS and lcc-win32.
-//
+//
// 1999 April (Emanuele Aliberti)
// Adapted for ReactOS and egcs.
//
{
WCHAR SizeString [16];
DWORD ClusterSize;
-
+
} SIZEDEFINITION, *PSIZEDEFINITION;
//----------------------------------------------------------------------
-//
+//
// Usage
//
// Tell the user how to use the program
else if( !wcsnicmp( & argv[i][1], L"A:", 2 ))
{
if ( gotSize ) return -1;
- j = 0;
+ j = 0;
while ( LegalSizes[j].ClusterSize &&
wcsicmp(
LegalSizes[j].SizeString,
PBOOLEAN status;
//static createStructures = FALSE;
- //
+ //
// We get other types of commands, but we don't have to pay attention to them
//
switch ( Command )
//----------------------------------------------------------------------
-//
+//
// WMain
//
-// Engine. Just get command line switches and fire off a format. This
-// could also be done in a GUI like Explorer does when you select a
+// Engine. Just get command line switches and fire off a format. This
+// could also be done in a GUI like Explorer does when you select a
// drive and run a check on it.
//
// We do this in UNICODE because the chkdsk command expects PWCHAR
wmain( int argc, WCHAR *argv[] )
{
int badArg;
-
+
DWORD media = 0;
DWORD driveType;
-
+
WCHAR fileSystem [1024];
WCHAR volumeName [1024];
WCHAR input [1024];
-
+
DWORD serialNumber;
DWORD flags,
maxComponent;
-
+
ULARGE_INTEGER freeBytesAvailableToCaller,
totalNumberOfBytes,
totalNumberOfFreeBytes;
-
+
wprintf( L"\
\nFormatx v1.0 by Mark Russinovich\n\
Systems Internals - http://www.sysinternals.com\n\
Usage(argv[0]);
return -1;
}
- //
+ //
// Get the drive's format
//
if( !Drive )
// Determine the drive's file system format
//
if ( !GetVolumeInformationW(
- RootDirectory,
+ RootDirectory,
volumeName,
- WBUFSIZE(volumeName),
+ WBUFSIZE(volumeName),
& serialNumber,
& maxComponent,
- & flags,
+ & flags,
fileSystem,
WBUFSIZE(fileSystem) )
) {
return -1;
}
if( !GetDiskFreeSpaceExW(
- RootDirectory,
+ RootDirectory,
& freeBytesAvailableToCaller,
& totalNumberOfBytes,
& totalNumberOfFreeBytes )
stdin
);
input[ wcslen( input ) - 1 ] = 0;
-
+
if ( !wcsicmp( input, volumeName ))
{
break;
if ( (input[0] == L'Y') || (input[0] == L'y') ) break;
if ( (input[0] == L'N') || (input[0] == L'n') )
- {
+ {
wprintf(L"\n");
return 0;
}
}
media = FMIFS_HARDDISK;
- }
+ }
//
// Tell the user we're doing a long format if appropriate
//
if ( !QuickFormat )
- {
+ {
if ( totalNumberOfBytes.QuadPart > 1024*1024*10 )
{
-
+
wprintf(
L"Verifying %dM\n",
(DWORD) (totalNumberOfBytes.QuadPart/(1024*1024))
- );
+ );
}
else
{
wprintf(
- L"Verifying %.1fM\n",
+ L"Verifying %.1fM\n",
((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0)
);
}
else
{
if ( totalNumberOfBytes.QuadPart > 1024*1024*10 )
- {
+ {
wprintf(
L"QuickFormatting %dM\n",
(DWORD) (totalNumberOfBytes.QuadPart / (1024 * 1024))
- );
+ );
}
else
{
wprintf(
- L"QuickFormatting %.2fM\n",
+ L"QuickFormatting %.2fM\n",
((float)(LONGLONG)totalNumberOfBytes.QuadPart) / (float)(1024.0*1024.0)
);
}
}
//
// Format away!
- //
+ //
FormatEx(
RootDirectory,
media,
GetLastError()
);
return -1;
- }
+ }
}
if ( !GetVolumeInformationW(
- RootDirectory,
+ RootDirectory,
volumeName,
- WBUFSIZE(volumeName),
+ WBUFSIZE(volumeName),
& serialNumber,
& maxComponent,
- & flags,
+ & flags,
fileSystem,
WBUFSIZE(fileSystem) )
) {
);
return -1;
}
- //
+ //
// Print out some stuff including the formatted size
//
if ( !GetDiskFreeSpaceExW(
- RootDirectory,
+ RootDirectory,
& freeBytesAvailableToCaller,
& totalNumberOfBytes,
& totalNumberOfFreeBytes )
) {
- PrintWin32Error(
+ PrintWin32Error(
L"Could not query volume size",
GetLastError()
);
// Get the drive's serial number
//
if ( !GetVolumeInformationW(
- RootDirectory,
+ RootDirectory,
volumeName,
- WBUFSIZE(volumeName),
+ WBUFSIZE(volumeName),
& serialNumber,
& maxComponent,
- & flags,
+ & flags,
fileSystem,
WBUFSIZE(fileSystem) )
) {
- PrintWin32Error(
+ PrintWin32Error(
L"Could not query volume",
GetLastError()
);
{
char * NextDosDevice = SymbolicLinks;
char * NextDevice;
-
+
while (TRUE == GetNextString (
SymbolicLinks,
DosDeviceName,
else
{
PrintWin32Error (
- L"ldd: ",
+ L"ldd: ",
GetLastError ()
);
}
else
{
PrintWin32Error (
- L"ldd: ",
+ L"ldd: ",
GetLastError ()
);
return EXIT_FAILURE;
* PROJECT : ReactOS Operating System
* DESCRIPTION: manual file browser (Use Linux man file syntax)
* DATE : 2004-03-29
- * LICENSE : GPL
+ * LICENSE : GPL
*/
-
+
/* Known issues.
* 1. Scroll screen
* 2. Non ENVIRONMENT manpath varrible
* 3. At the end of man page must be ./" tag!
*/
-
+
#include <stdio.h>
#include <string.h>
{
int retval=0;
char *manpath_local=(char*)malloc(sizeof(char)*MAXLINE);
-
+
strcpy(manpath_local, manpath); //save mandir value
-
+
if((manfile=fopen((strcat(manpath_local,name)),"r"))!=NULL)
- {
+ {
OpenFlag=1;
AnalyzeFile();
}
- else
+ else
retval=-1;
-
- strcpy(manpath_local, manpath);
+
+ strcpy(manpath_local, manpath);
return retval;
}
CloseF()
{
int retval=0;
-
+
if(fclose(manfile))
OpenFlag=0;
else retval=-1;
-
+
return retval;
}
-
+
void
Usage()
{
char *keys[]={"--help","/h","/?","-h"};
char *sections[]={".1",".2",".3",".4",".5",".6",".7",".8",".9"};
char *filename=(char*)malloc(sizeof(char)*MAXLINE);
-
+
strcpy(filename,argument); //save argument value
-
+
for(element=0; element < 5;element++)
if(!strcmp(keys[element],argument))
{
}
element = 0;
-
+
if(!HelpFlag)
-
+
if(OpenF(filename))
while(OpenF(strcat(filename,sections[element])) && (element<9))
{
strcpy(filename,argument);
element++;
- }
-
- if(element>8) printf("No manual for %s\n",argument);
-
+ }
+
+ if(element>8) printf("No manual for %s\n",argument);
+
return element;
}
char *cur_string=(char*)malloc(sizeof(char)*MAXLINE);
int symbol=0;
char *THtag=(char*)malloc(sizeof(char)*MAXLINE);
-
-
+
+
void sh_outp(void)
{
putchar('\n');
putchar('\n');
for(symbol=3;putchar(cur_string[symbol]); symbol++);
}
-
+
void th_outp(void)
{
putchar('\n');
SetCl(ITALIC);
for(symbol=3;putchar(THtag[symbol]); symbol++);
putchar('\n');
- SetCl(NORMAL);
+ SetCl(NORMAL);
}
void text_outp(void)
{
char TagFlag=0;
symbol=0;
-
+
if(cur_string[0]=='.')
while(cur_string[symbol]!=' ')
symbol++;
-
+
if(symbol) TagFlag=1;
-
+
for(;cur_string[symbol]!='\n'; symbol++)
putchar(cur_string[symbol]);
putchar(' ');
}
-
+
while(fgets(cur_string,MAXLINE,manfile))
-
+
/* TAGs processing */
if((cur_string[0]=='.')&&(cur_string[1]=='S')&&
(cur_string[2]=='H')) // .SH tag
- {
+ {
SetCl(BOLD);
sh_outp();
SetCl(NORMAL);
else
if((cur_string[0]=='.')&&(cur_string[1]=='/')&&
(cur_string[2]=='\"')); // ./" tag (comment)
-
+
else
if((cur_string[0]=='.')&&(cur_string[1]=='T')&&
(cur_string[2]=='H')) // .TH tag
else
if((cur_string[0]=='.')&&(cur_string[1]=='N')&&
(cur_string[2]=='L'))
- {
+ {
putchar('\n');
putchar(' ');
- }
-
+ }
+
else text_outp(); // print plane text
th_outp();
/* END of TAGs processing */
return 0;
}
-
-
+
+
int
main(int argc, char *argv[])
{
case 2: AnalyzeArgv(argv[1]);break;
default: Usage();break;
}
-
+
if(OpenFlag)CloseF();
SetCl(NORMAL);
return 0;
// $Id$
//
-// This program was written by Sang Cho, assistant professor at
-// the department of
+// This program was written by Sang Cho, assistant professor at
+// the department of
// computer science and engineering
// chongju university
// this program is based on the program pefile.c
// which is written by Randy Kath(Microsoft Developmer Network Technology Group)
// in june 12, 1993.
// I have investigated P.E. file format as thoroughly as possible,
-// but I cannot claim that I am an expert yet, so some of its information
+// but I cannot claim that I am an expert yet, so some of its information
// may give you wrong results.
//
//
// Dialog Box Resources .................. added by sang cho.
-// A dialog box is contained in a single resource and has a header and
+// A dialog box is contained in a single resource and has a header and
// a portion repeated for each control in the dialog box.
// The item DWORD IStyle is a standard window style composed of flags found
// in WINDOWS.H.
// The default style for a dialog box is:
// WS_POPUP | WS_BORDER | WS_SYSMENU
-//
+//
// The itme marked "Name or Ordinal" are :
// If the first word is an 0xffff, the next two bytes contain an ordinal ID.
// Otherwise, the first one or more WORDS contain a double-null-terminated string.
// An empty string is represented by a single WORD zero in the first location.
-//
+//
// The WORD wPointSize and WCHAR szFontName entries are present if the FONT
// statement was included for the dialog box. This can be detected by checking
// the entry IStyle. If IStyle & DS_SETFONT ( which is 0x40), then these
/**********************************************************************
* NAME
- *
+ *
* DESCRIPTION
* Copy DOS header information to structure.
*
* ARGUMENTS
*/
-BOOL WINAPI
+BOOL WINAPI
GetDosHeader (
LPVOID lpFile,
PIMAGE_DOS_HEADER pHeader
/* return file signature */
-DWORD WINAPI
+DWORD WINAPI
ImageFileType (
LPVOID lpFile)
{
/* copy file header information to structure */
-BOOL WINAPI
+BOOL WINAPI
GetPEFileHeader (
LPVOID lpFile,
PIMAGE_FILE_HEADER pHeader)
/* copy optional header info to structure */
-BOOL WINAPI
+BOOL WINAPI
GetPEOptionalHeader (
LPVOID lpFile,
PIMAGE_OPTIONAL_HEADER pHeader)
/* function returns the entry point for an exe module lpFile must
be a memory mapped file pointer to the beginning of the image file */
-LPVOID WINAPI
+LPVOID WINAPI
GetModuleEntryPoint (
LPVOID lpFile)
{
/* return the total number of sections in the module */
-int WINAPI
+int WINAPI
NumOfSections (
LPVOID lpFile)
{
/* retrieve entry point */
-LPVOID WINAPI
+LPVOID WINAPI
GetImageBase (
LPVOID lpFile)
{
//
/* function returns the actual address of given RVA, lpFile must
be a memory mapped file pointer to the beginning of the image file */
-LPVOID WINAPI
+LPVOID WINAPI
GetActualAddress (
LPVOID lpFile,
DWORD dwRVA)
//
//
/* return offset to specified IMAGE_DIRECTORY entry */
-LPVOID WINAPI
+LPVOID WINAPI
ImageDirectoryOffset (
LPVOID lpFile,
DWORD dwIMAGE_DIRECTORY)
/* function retrieve names of all the sections in the file */
-int WINAPI
+int WINAPI
GetSectionNames (
LPVOID lpFile,
char **pszSections)
/* function gets the function header for a section identified by name */
-BOOL WINAPI
+BOOL WINAPI
GetSectionHdrByName (
LPVOID lpFile,
IMAGE_SECTION_HEADER * sh,
//
//
/* get import modules names separated by null terminators, return module count */
-int WINAPI
+int WINAPI
GetImportModuleNames (
LPVOID lpFile,
char **pszModules)
//
//
/* get import module function names separated by null terminators, return function count */
-int WINAPI
+int WINAPI
GetImportFunctionNamesByModule (
LPVOID lpFile,
char *pszModule,
// October 6, 1997
//
/* get numerically expressed string length */
-int WINAPI
+int WINAPI
GetStringLength (
char *psz)
{
//
/* translate parameter part of condensed name */
-void WINAPI
+void WINAPI
GetPreviousParamString (
char *xpin, // read-only source
char *xpout) // translated result
//
/* translate parameter part of condensed name */
-void WINAPI
+void WINAPI
TranslateParameters (
char **ppin, // read-only source
char **ppout, // translated result
//
/* translate parameter part of condensed name */
-BOOL WINAPI
+BOOL WINAPI
StringExpands (
char **ppin, // read-only source
char **ppout, // translated result
//} Str_P;
//----------------------------------------------------------------------
//
-// I think I knocked it down finally. But who knows?
+// I think I knocked it down finally. But who knows?
// october 12, 1997 ... sang
//
// well I have to rewrite whole part of TranslateFunctionName..
// and i hope this will take care of every symptoms i have experienced..
// october 10, 1997 .... sang
// It took a lot of time for me to figure out what is all about....
-// but still some prefixes like z (static)
+// but still some prefixes like z (static)
// -- or some types like b (byte) ,g (long double) ,s (short) --
// -- or postfix like M ( * )
// -- or $or ( & ) which is pretty wierd. .. added.. october 12
-// -- also $t business is quite tricky too. (templates)
+// -- also $t business is quite tricky too. (templates)
// there may be a lot of things undiscovered yet....
// I am not so sure my interpretation is correct or not
// If I am wrong please let me know.
// October 5, 1997
//
/* translate condesed import function name */
-LPVOID WINAPI
+LPVOID WINAPI
TranslateFunctionName (
char *psz)
{
Str_P tok; // String token
- Str_P c_str; // current string
+ Str_P c_str; // current string
int iend = 0;
char *endTab[8]; // end of string position check
// string mode restored...
else;
}
- else; // do nothing..
+ else; // do nothing..
}
break;
//---------------------------------------------------------------
- // string part processing : no '$' met yet
+ // string part processing : no '$' met yet
// or inside of '%' block
// or inside of '#' block (numbered string)
//---------------------------------------------------------------
*pout++ = *pin++;
//else if (is > 1) *pout++ = *pin++;
- //------------------------------------------------
+ //------------------------------------------------
// parameter part processing: '$' met
//------------------------------------------------
if (tok.flag == '%')
{
- // pop '%' token and set c_str
+ // pop '%' token and set c_str
//if (*pin)
//printf("\n pop percent token..next char = %c", *pin);
//else printf("\n pop percent token..next char = NULL");
//
// sometimes we need string to use as constructor name or destructor name
//
- else if (c == '@') // get string from previous marker upto here.
+ else if (c == '@') // get string from previous marker upto here.
{
pin++;
//
//
/* get exported function names separated by null terminators, return count of functions */
-int WINAPI
+int WINAPI
GetExportFunctionNames (
LPVOID lpFile,
char **pszFunctions)
char *pfns[8192] =
{NULL,}; // maximum number of functions
- //=============================
+ //=============================
char buff[256]; // enough for any string ??
/* determine the total number of resources in the section */
-int WINAPI
+int WINAPI
GetNumberOfResources (
LPVOID lpFile)
{
//
//
/* name each type of resource in the section */
-int WINAPI
+int WINAPI
GetListOfResourceTypes (
LPVOID lpFile,
char **pszResTypes)
// October 12, 1997
//
/* copy menu information */
-void WINAPI
+void WINAPI
StrangeMenuFill (
char **psz, // results
WORD ** pMenu, // read-only
// October 1, 1997
//
/* obtain menu information */
-int WINAPI
+int WINAPI
MenuScan (
int *len,
WORD ** pMenu)
if (flag1 & 0x0080)
break;
}
-// fill # of details to num above
+// fill # of details to num above
//(*len) += 2;
*pMenu = pwd;
return flag;
// October 2, 1997
//
/* copy menu information */
-int WINAPI
+int WINAPI
MenuFill (
char **psz,
WORD ** pMenu)
if (flag1 & 0x0080)
break;
}
-// fill # of details to num above
+// fill # of details to num above
//*(WORD *)pTemp = (WORD)num;
*pMenu = pwd;
*psz = ptr;
//
//==============================================================================
// The following program is based on preorder-tree-traversal.
-// once you understand how to traverse.....
+// once you understand how to traverse.....
// the rest is pretty straight forward.
// still we need to scan it first and fill it next time.
// and finally we can print it.
// supermenuname null terminated string, only ascii is considered.
// flag tells : node is a leaf or a internal node.
// popupname null terminated string
-//
+//
// flag normal menu flag (leaf node)
// id normal menu id
// name normal menu name
// or or
// flag popup menu flag (internal node)
-// popupname popup menu name
-//
+// popupname popup menu name
+//
// flag it may folows
// id normal menu id
// name normal menu name
// but usually, it only goes a few steps,...
// ------------------------------------------------------------------------------
/* scan menu and copy menu */
-int WINAPI
+int WINAPI
GetContentsOfMenu (
LPVOID lpFile,
char **pszResTypes)
// normally wVersion and cbHeaderSize should be zero
// but if it is not then nothing is known to us...
// so let's do our best ... namely guessing .... and trying ....
- // ... and suffering ...
+ // ... and suffering ...
// it gave me many sleepless (not exactly but I like to say this) nights.
//
// expect to return the length needed to report.
// sixteen more bytes to do something
sLength += 16 + size;
- //StrangeMenuScan (&sLength, &pwd, size);
+ //StrangeMenuScan (&sLength, &pwd, size);
}
// normal case
else
// October 12, 1997
//
/* print contents of menu */
-int WINAPI
+int WINAPI
PrintStrangeMenu (
char **psz)
{
// October 2, 1997
//
/* print contents of menu */
-int WINAPI
+int WINAPI
PrintMenu (
int indent,
char **psz)
PrintMenu (indent + 5, psz);
ptr = *psz;
}
- else // ispopup == 0
+ else // ispopup == 0
{
printf ("\n");
// October 2, 1997
//
/* the format of menu is not known so I'll do my best */
-int WINAPI
+int WINAPI
dumpMenu (
char **psz,
int size)
// October 13, 1997
//
/* scan dialog box and copy dialog box */
-int WINAPI
+int WINAPI
GetContentsOfDialog (
LPVOID lpFile,
char **pszResTypes)
// October 14, 1997
//
/* print contents of dialog */
-void WINAPI
+void WINAPI
PrintNameOrOrdinal (
char **psz)
{
// October 14, 1997
//
/* print contents of dialog */
-void WINAPI
+void WINAPI
PrintDialog (
char **psz)
{
while (*(WORD *) ptr)
ptr += 2; // WCHARs
- ptr += 2; // double null
+ ptr += 2; // double null
}
if (c<0) c+=256;
buff[j] = c;
printf ("%02X",c);
- ptr++;
+ ptr++;
if (ptr >= pmax) break;
n++;
- if (n%4 == 0) printf (" ");
+ if (n%4 == 0) printf (" ");
}
n++; if (n%4 == 0) printf (" ");
l = j;
j++;
- for (; j<16; j++)
+ for (; j<16; j++)
{ n++; if (n%4 == 0) printf (" "); else printf (" "); }
printf (" ");
for (k=0; k<l; k++)
/* function indicates whether debug info has been stripped from file */
-BOOL WINAPI
+BOOL WINAPI
IsDebugInfoStripped (
LPVOID lpFile)
{
/* retrieve the module name from the debug misc. structure */
-int WINAPI
+int WINAPI
RetrieveModuleName (
LPVOID lpFile,
char **pszModule)
/* determine if this is a valid debug file */
-BOOL WINAPI
+BOOL WINAPI
IsDebugFile (
LPVOID lpFile)
{
/* copy separate debug header structure from debug file */
-BOOL WINAPI
+BOOL WINAPI
GetSeparateDebugHeader (
LPVOID lpFile,
PIMAGE_SEPARATE_DEBUG_HEADER psdh)
//
// I tried to immitate the output of w32dasm disassembler.
// which is a pretty good program.
-// but I am disappointed with this program and I myself
+// but I am disappointed with this program and I myself
// am writting a disassembler.
// This PEdump program is a byproduct of that project.
// so enjoy this program and I hope we will have a little more
#define MAXSECTIONNUMBER 16
#define MAXNAMESTRNUMBER 40
-int
+int
main (
int argc,
char **argv
pst = pmNameBuff;
printf ("\nNumber of Menus = %4d (decimal)", nMenus);
- //dumpMenu(&pst, 8096);
+ //dumpMenu(&pst, 8096);
for (i = 0; i < nMenus; i++)
{
// menu ID print
-/* $Id: qsi.c,v 1.7 2001/07/12 11:58:57 ekohl Exp $
+/* $Id$
*
* PROJECT : ReactOS Operating System (see http://www.reactos.com/)
* DESCRIPTION: Tool to query system information
* AUTHOR : Emanuele Aliberti
* LICENSE : GNU GPL (see http://www.gnu.org/)
* DATE : 1999-07-28
- *
+ *
* BUILD INSTRUCTIONS
* If you got this code directly from the CVS repository on
* mok.lcvm.com, it should be ok to run "make sqi.exe" from the
BOOL Active;
HANDLE Heap;
INT ExitCode;
-
+
} Application =
{
{0, 0},
{
return;
}
- while (Size > 0)
+ while (Size > 0)
{
printf ("%04x: ", (Buffer - Base));
for ( i = 0;
INT Size;
LONG Length = 0;
-
+
Size = step = (step > 0 ? step : 1);
while ( (Size < sizeof Buffer)
&& (Status == STATUS_INFO_LENGTH_MISMATCH)
PrintStatus (NTSTATUS Status)
{
LPCSTR StatusName = NULL;
-
+
switch (Status)
{
case STATUS_INVALID_INFO_CLASS:
UtcTimeFields.Minute,
UtcTimeFields.Second,
UtcTimeFields.Milliseconds
- );
+ );
printf (
Template,
UtcTimeString
/**********************************************************************
- *
+ *
* DESCRIPTION
* Dump whatever we get by calling NtQuerySystemInformation with
* a user provided system information class id.
PBYTE Buffer = NULL;
NTSTATUS Status;
-
+
printf ("SystemInformation %d:\n", _id);
/* Find buffer size */
Size = FindRequiredBufferSize (_id, 1);
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
{
NTSTATUS Status;
SYSTEM_PROCESSOR_INFORMATION Info;
-
+
RtlZeroMemory (
(PVOID) & Info,
sizeof Info
/**********************************************************************
- *
+ *
* DESCRIPTION
* System performance information.
- *
+ *
* NOTE
* Class 2.
*/
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
* A snapshot of the process+thread tables.
*
pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
/* FIXME: check NULL==pInfo */
-
+
/*
* Obtain required buffer size
*/
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
NTSTATUS Status;
SYSTEM_PROCESSORTIME_INFO Info;
ULONG Length = 0;
-
+
Status = NtQuerySystemInformation (
8,
& Info,
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
NTSTATUS Status;
SYSTEM_FLAGS_INFORMATION Info;
ULONG Length = 0;
-
+
Status = NtQuerySystemInformation (
9,
& Info,
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/*
* Allocate buffer
*/
- pInfo = GlobalAlloc (GMEM_ZEROINIT, Length);
+ pInfo = GlobalAlloc (GMEM_ZEROINIT, Length);
if (NULL == pInfo)
{
printf ("Could not allocate memory.\n");
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/*
* Allocate buffer
*/
- pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
+ pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
if (NULL == pInfo)
{
printf ("Could not allocate memory.\n");
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/*
* Allocate buffer
*/
- pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
+ pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
if (NULL == pInfo)
{
printf ("\tCould not allocate memory.\n");
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
NTSTATUS Status;
PSYSTEM_PAGEFILE_INFORMATION pInfo = NULL;
LONG Length = 0;
-
+
pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
/* FIXME: check pInfo */
-
+
Status = NtQuerySystemInformation(
18,
pInfo,
/*
* Allocate buffer
*/
- pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
+ pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
if (NULL == pInfo)
{
printf ("Could not allocate memory.\n");
}
DumpData (Length, pInfo);
-
+
GlobalFree (pInfo);
return EXIT_SUCCESS;
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
{
NTSTATUS Status;
SYSTEM_CACHE_INFORMATION Si;
-
+
RtlZeroMemory (
(PVOID) & Si,
sizeof Si
/**********************************************************************
- *
+ *
* DESCRIPTION
* Get statistic data about tagged pools. Not implemented in the
* free build.
pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
/* FIXME: check pInfo */
-
+
Status = NtQuerySystemInformation(
22,
pInfo,
/*
* Allocate buffer
*/
- pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
+ pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
if (NULL == pInfo)
{
printf ("Could not allocate memory.\n");
}
DumpData (Length, pInfo);
-
+
GlobalFree (pInfo);
return EXIT_SUCCESS;
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
printf ("\tTimerResolution = %ld\n", Info.TimerResolution);
printf ("\tnDPCBypasses = %ld\n", Info.nDPCBypasses);
printf ("\tnAPCBypasses = %ld\n", Info.nAPCBypasses);
-
+
DumpData (sizeof Info, & Info);
return EXIT_SUCCESS;
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
CMD_NOT_IMPLEMENTED
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
* Dump the system TIME_ZONE_INFORMATION object.
*
" Bias........: %ld'\n",
Tzi.Bias /* LONG */
);
-
+
printf (" Standard\n");
RtlZeroMemory (
(PVOID) Name,
L"\tName: \"%s\"\n",
Name
);
-
+
PrintUtcDateTime (
"\tDate: %s\n",
(PTIME) & Tzi.StandardDate /* SYSTEMTIME */
);
-
+
printf ("\tBias: %ld'\n",
Tzi.StandardBias /* LONG */
);
-
+
printf (" Daylight\n");
RtlZeroMemory (
(PVOID) Name,
);
lstrcpynW (
Name,
- Tzi.DaylightName, /* WCHAR [32] */
+ Tzi.DaylightName, /* WCHAR [32] */
32
);
wprintf (
L"\tName: \"%s\"\n",
Name
);
-
+
PrintUtcDateTime (
"\tDate: %s\n",
- (PTIME) & Tzi.DaylightDate /* SYSTEMTIME */
+ (PTIME) & Tzi.DaylightDate /* SYSTEMTIME */
);
-
+
printf (
"\tBias: %ld'\n",
- Tzi.DaylightBias /* LONG */
+ Tzi.DaylightBias /* LONG */
);
return EXIT_SUCCESS;
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
/**********************************************************************
- *
+ *
* DESCRIPTION
*
* NOTE
CMD_DEF(ver)
{
INT Total = 0;
-
+
Total =
printf (
"ReactOS Operating System - http://www.reactos.com/\n"
CMD_DEF(help)
{
int i;
-
+
if (Application.Flag.Verbose)
{
printf ("Commands:\n");
"\nReactOS (http://www.reactos.com/):\n"
"\tEmanuele Aliberti\n"
"\tEric Kohl\n\n"
-
+
"HandleEx:\n"
"\tMark Russinovich (http://www.sysinternals.com/)\n\n"
"Undocumented SYSTEM_POOL_INFORMATION:\n"
"\tKlaus P. Gerlicher\n\n"
-
+
"Undocumented Windows NT:\n"
"\tPrasad Dabak, Sandeep Phadke, and Milind Borate\n\n"
Commands [] =
{
/* System information classes */
-
+
{ /* 0 Q */
"basic",
CMD_REF(0),
"Basic system information"
},
{ /* 1 Q */
- "processor",
+ "processor",
CMD_REF(1),
"Processor characteristics"
},
{ /* 2 Q */
- "perf",
+ "perf",
CMD_REF(2),
"System performance data"
},
"Bop (VDM)"
},
{ /* 21 QS */
- "cache",
+ "cache",
CMD_REF(21),
"File cache"
},
CMD_REF(verbose),
"Enable/disable printing unused, unknown, and service fields"
},
-
+
{ NULL, NULL }
};
printf ("Unknown command (type help for a list of valid commands).\n");
}
}
-
+
}
if (! Application.Flag.Batch)
{
-/* $Id: ArgumentParser.h,v 1.2 2001/01/13 23:53:46 narnaoud Exp $ */
+/* $Id$ */
// ArgumentParser.h: interface for the CArgumentParser class.
//
-/* $Id: Completion.h,v 1.2 2001/01/13 23:54:07 narnaoud Exp $ */
+/* $Id$ */
// Completion.h - declaration for completion related functions
-/* $Id: Console.h,v 1.4 2001/01/13 23:54:07 narnaoud Exp $ */
-
+/* $Id$ */
+
// Console.h: interface for the CConsole class.
//
//////////////////////////////////////////////////////////////////////
#include "TextHistory.h"
#include "Completion.h"
-class CConsole
+class CConsole
{
public:
void EnableWrite();
-/* $Id: CrtSupplement.c,v 1.2 2002/09/03 18:44:18 chorns Exp $
+/* $Id$
*
* Written by EA because ReactOS hasn't yet _ui64toa()
- * (it's in msvcrt.dll, and not in crtdll.dll).
+ * (it's in msvcrt.dll, and not in crtdll.dll).
*/
#include <stdlib.h>
string [i ++] = *(-- w);
}
string [len] = '\0';
-
+
return string;
}
-/* $Id: Pattern.h,v 1.1 2001/01/10 01:25:29 narnaoud Exp $ */
+/* $Id$ */
// Pattern.h: decalration for pattern functions
-/* $Id: RegistryKey.h,v 1.4 2001/01/13 23:54:41 narnaoud Exp $ */
+/* $Id$ */
// RegistryKey.h: interface for the CRegistryKey class.
//
#if !defined(REGISTRYKEY_H__FEF419ED_6EB6_11D3_907D_204C4F4F5020__INCLUDED_)
#define REGISTRYKEY_H__FEF419ED_6EB6_11D3_907D_204C4F4F5020__INCLUDED_
-class CRegistryKey
+class CRegistryKey
{
public:
// Constructor. Call InitXXX methods to make real construct.
CRegistryKey();
-
+
// Call this key to init root key.
//
// Parameters:
// S_OK - All ok.
// E_XXX - Error.
HRESULT Uninit();
-
+
// Destructor
virtual ~CRegistryKey();
// If the method succeeds, the return value is ERROR_SUCCESS.
// If the method fails, the return value is a nonzero error code defined in winerror.h.
LONG OpenSubkey(REGSAM samDesired, const TCHAR *pszSubkeyName, HKEY &rhKey);
-
+
// Call this method to open existing subkey of this key.
//
// Parameters:
BYTE *pbValueDataBuffer,
DWORD dwValueDataBufferSize,
DWORD *pdwType);
-
+
// Call this method to get next value name/data/type. Name/data/type is/are stored in buffer(s) specified in call to InitValueEnumeration.
//
// Parameters:
// If the method fails, the return value is a nonzero error code defined in winerror.h.
// If no more items available, return error is ERROR_NO_MORE_ITEMS.
LONG GetNextValue(DWORD *pdwNameActualSize = NULL, DWORD *pdwDataActualSize = NULL);
-
+
// Call this method to get count of values.
//
// Parameters:
// pbValueDataBuffer - optional pointer to buffer receiving default value data. NULL if not requred.
// dwValueDataBufferSize - size of buffer pointer by pbValueDataBuffer. Ignored if pbValueDataBuffer is NULL.
// pdwValueDataActualSize - optional pointer to variable receiving size, in bytes, of data stored into buffer. If pbValueDataBuffer is NULL, returned value is size of default value data, in bytes.
- //
+ //
// Return value:
// If the method succeeds, the return value is ERROR_SUCCESS.
// If the method fails, the return value is a nonzero error code defined in winerror.h.
// Return value:
// text representation od value type.
static const TCHAR * GetValueTypeName(DWORD dwType);
-
+
DWORD GetValue(TCHAR *pchValueName, DWORD *pdwType, LPBYTE lpValueDataBuffer, DWORD *pdwValueDataSize);
// Call this method to create subkey of this key.
// If the method succeeds, the return value is ERROR_SUCCESS.
// If the method fails, the return value is a nonzero error code defined in winerror.h.
LONG CreateSubkey(REGSAM samDesired, const TCHAR *pszKeyName, HKEY &rhKey, BOOL *pblnOpened = NULL, BOOL blnVolatile = FALSE);
-
+
LONG GetLastWriteTime(SYSTEMTIME& st);
const TCHAR * GetLastWriteTime();
-
+
LONG DeleteValue(const TCHAR *pszValueName);
LONG DeleteSubkey(const TCHAR *pszPatternSubkeyName);
-
+
LONG SetValue(LPCTSTR pszValueName, DWORD dwType, BYTE *lpData, DWORD dwDataSize);
TCHAR * GetSubKeyNameByIndex(DWORD dwIndex);
LONG GetSecurityDescriptor(SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, LPDWORD lpcbSecurityDescriptor);
DWORD m_dwCurrentSubKeyIndex;
TCHAR *m_pchSubkeyNameBuffer;
DWORD m_dwSubkeyNameBufferSize;
-
+
DWORD m_dwCurrentValueIndex;
TCHAR *m_pszValueNameBuffer;
DWORD m_dwValueNameBufferSize;
BYTE *m_pbValueDataBuffer;
DWORD m_dwValueDataBufferSize;
DWORD *m_pdwType;
-
+
HKEY m_hKey;
TCHAR *m_pszKeyName;
TCHAR *m_pszMachineName;
-/* $Id: RegistryTree.h,v 1.2 2001/01/10 01:25:29 narnaoud Exp $ */
+/* $Id$ */
// RegistryTree.h: interface for the CRegistryTree class.
//
// Max size of error description.
#define ERROR_MSG_BUFFER_SIZE 1024
-class CRegistryTree
+class CRegistryTree
{
public:
// Constructor
// TRUE - key opened successfully.
// FALSE - error. Call GetLastErrorDescription() to get error description.
BOOL DeleteSubkeys(const TCHAR *pszKeyPattern, const TCHAR *pszPath, BOOL blnRecursive = FALSE);
-
+
BOOL NewKey(const TCHAR *pszKeyName, const TCHAR *pszPath, BOOL blnVolatile = FALSE);
-
+
BOOL SetMachineName(LPCTSTR pszMachineName);
// Internal methods
BOOL InternalGetSubkey(const TCHAR *pszSubkeyName, REGSAM DesiredAccess, CRegistryKey& rKey);
void GotoRoot();
BOOL DeleteSubkeys(CRegistryKey& rKey, const TCHAR *pszKeyPattern, BOOL blnRecursive);
-
+
private:
class CNode
{
CNode *m_pUp;
CRegistryKey m_Key;
} m_Root;
-
+
CNode *m_pCurrentKey; // The current key.
TCHAR m_ErrorMsg[ERROR_MSG_BUFFER_SIZE+1]; // Last error description buffer.
LPTSTR m_pszMachineName; // Pointer to buffer containing machine name with leading backslashes. NULL if local.
-/* $Id: SecurityDescriptor.h,v 1.3 2001/01/13 23:54:41 narnaoud Exp $ */
+/* $Id$ */
// SecurityDescriptor.h: interface for the CSecurityDescriptor class.
//
const TCHAR * GetSidTypeName(SID_NAME_USE Use);
-class CSecurityDescriptor
+class CSecurityDescriptor
{
public:
void GetCurrentACE_Flags(BYTE& bFlags);
-/* $Id: Settings.h,v 1.2 2001/04/24 22:53:00 narnaoud Exp $ */
+/* $Id$ */
#ifndef OPTIONS_H__a7382d2d_96b4_4472_974d_801281bd5327___INCLUDED
#define OPTIONS_H__a7382d2d_96b4_4472_974d_801281bd5327___INCLUDED
-/* $Id: ShellCommand.h,v 1.2 2001/01/13 23:55:36 narnaoud Exp $ */
+/* $Id$ */
// ShellCommand.h: interface for the CShellCommand class.
//
#include "ArgumentParser.h"
// this class provides common interface to shell commands
-class CShellCommand
+class CShellCommand
{
public:
CShellCommand();
-/* $Id: ShellCommandChangeKey.h,v 1.2 2001/01/13 23:55:36 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandChangeKey.h: interface for the CShellCommandChangeKey class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandChangeKey : public CShellCommand
+class CShellCommandChangeKey : public CShellCommand
{
public:
CShellCommandChangeKey(CRegistryTree& rTree);
-/* $Id: ShellCommandConnect.h,v 1.2 2001/01/13 23:55:36 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandConnect.h: interface for the CShellCommandConnect class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandConnect : public CShellCommand
+class CShellCommandConnect : public CShellCommand
{
public:
CShellCommandConnect(CRegistryTree& rTree);
-/* $Id: ShellCommandDACL.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandDACL.h: interface for the CShellCommandDACL class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandDACL : public CShellCommand
+class CShellCommandDACL : public CShellCommand
{
public:
CShellCommandDACL(CRegistryTree& rTree);
-/* $Id: ShellCommandDOKA.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandDOKA.h: interface for the CShellCommandDOKA class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandDOKA : public CShellCommand
+class CShellCommandDOKA : public CShellCommand
{
public:
CShellCommandDOKA(CRegistryTree& rTree);
-/* $Id: ShellCommandDeleteKey.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandDeleteKey.h: interface for the CShellCommandDeleteKey class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandDeleteKey : public CShellCommand
+class CShellCommandDeleteKey : public CShellCommand
{
public:
CShellCommandDeleteKey(CRegistryTree& rTree);
-/* $Id: ShellCommandDeleteValue.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandDeleteValue.h: interface for the CShellCommandDeleteValue class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandDeleteValue : public CShellCommand
+class CShellCommandDeleteValue : public CShellCommand
{
public:
CShellCommandDeleteValue(CRegistryTree& rTree);
-/* $Id: ShellCommandDir.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandDir.h: interface for the CShellCommandDir class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandDir : public CShellCommand
+class CShellCommandDir : public CShellCommand
{
public:
CShellCommandDir(CRegistryTree& rTree);
-/* $Id: ShellCommandExit.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandExit.h: interface for the CShellCommandExit class.
//
#include "ShellCommand.h"
-class CShellCommandExit : public CShellCommand
+class CShellCommandExit : public CShellCommand
{
public:
CShellCommandExit();
-/* $Id: ShellCommandHelp.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandHelp.h: interface for the CShellCommandHelp class.
//
#include "ShellCommand.h"
#include "ShellCommandsLinkedList.h"
-class CShellCommandHelp : public CShellCommand
+class CShellCommandHelp : public CShellCommand
{
public:
CShellCommandHelp(CShellCommandsLinkedList& rCommandsLinkedList);
-/* $Id: ShellCommandNewKey.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandNewKey.h: interface for the CShellCommandNewKey class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandNewKey : public CShellCommand
+class CShellCommandNewKey : public CShellCommand
{
public:
CShellCommandNewKey(CRegistryTree& rTree);
-/* $Id: ShellCommandOwner.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandOwner.h: interface for the CShellCommandOwner class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandOwner : public CShellCommand
+class CShellCommandOwner : public CShellCommand
{
public:
CShellCommandOwner(CRegistryTree& rTree);
-/* $Id: ShellCommandSACL.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandSACL.h: interface for the CShellCommandSACL class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandSACL : public CShellCommand
+class CShellCommandSACL : public CShellCommand
{
public:
CShellCommandSACL(CRegistryTree& rTree);
-/* $Id: ShellCommandSetValue.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandSetValue.h: interface for the CShellCommandSetValue class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandSetValue : public CShellCommand
+class CShellCommandSetValue : public CShellCommand
{
public:
CShellCommandSetValue(CRegistryTree& rTree);
-/* $Id: ShellCommandValue.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandValue.h: interface for the CShellCommandValue class.
//
#include "ShellCommand.h"
#include "RegistryTree.h"
-class CShellCommandValue : public CShellCommand
+class CShellCommandValue : public CShellCommand
{
public:
CShellCommandValue(CRegistryTree& rTree);
-/* $Id: ShellCommandVersion.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandVersion.h: interface for the CShellCommandVersion class.
//
#include "ShellCommand.h"
-class CShellCommandVersion : public CShellCommand
+class CShellCommandVersion : public CShellCommand
{
public:
CShellCommandVersion();
-/* $Id: ShellCommandsLinkedList.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// ShellCommandsLinkedList.h: interface for the CShellCommandsLinkedList class.
//
#define POSITION int *
-class CShellCommandsLinkedList
+class CShellCommandsLinkedList
{
public:
CShellCommandsLinkedList(CConsole& rConsole);
-/* $Id: TextHistory.h,v 1.2 2001/01/13 23:55:37 narnaoud Exp $ */
+/* $Id$ */
// TextHistory.h: interface for the CTextHistory class.
//
#if !defined(TEXTHISTORY_H__AD9C6555_1D97_11D4_9F58_204C4F4F5020__INCLUDED_)
#define TEXTHISTORY_H__AD9C6555_1D97_11D4_9F58_204C4F4F5020__INCLUDED_
-class CTextHistory
+class CTextHistory
{
public:
CTextHistory();
-/* $Id: shutdown.c,v 1.2 2000/04/25 23:22:57 ea Exp $
- *
+/* $Id$
+ *
* EAU shutdown.c 1.4.1
- *
+ *
* Copyright (C) 1997,1998,1999 Emanuele Aliberti
*
* --------------------------------------------------------------------
* You should have received a copy of the GNU Library General Public
* License along with this software; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 675 Mass Ave,
- * Cambridge, MA 02139, USA.
+ * Cambridge, MA 02139, USA.
*
* --------------------------------------------------------------------
* 1999-05-14 (Emanuele Aliberti)
#endif
-struct _EWX
+struct _EWX
{
CHAR mode;
UINT id;
static
-const
+const
char * usage = "\
Shutdown ver. 1.4.1 (compiled on %s, at %s)\n\
Copyright (C) 1997-1999 Emanuele Aliberti\n\n\
HANDLE h;
TOKEN_PRIVILEGES tp;
- mode = (argc == 2)
+ mode = (argc == 2)
? DecodeArg(argv[1])
: DecodeArg("-?");
if (mode == (UINT) -1)
usage,
__DATE__,
__TIME__,
- argv[0]
+ argv[0]
);
return EXIT_SUCCESS;
}
- /*
- * Get the current process token handle
- * so we can get shutdown privilege.
+ /*
+ * Get the current process token handle
+ * so we can get shutdown privilege.
*/
if (FALSE == OpenProcessToken(
GetCurrentProcess(),
*/
if (FALSE == LookupPrivilegeValue(
NULL,
- SE_SHUTDOWN_NAME,
+ SE_SHUTDOWN_NAME,
& tp.Privileges[0].Luid
)
) {
* PROJECT : ReactOS Operating System
* DESCRIPTION: file concatenation tool
* DATE : 2004-01-21
- * LICENSE : GPL
+ * LICENSE : GPL
*/
-
+
#include <stdio.h>
#include <string.h>
#define F_O_ERR "can not open file"
{
puts("File concatenation tool");
puts("Usage: cat [file]");
-}
+}
int main(int argc, char *argv[])
{
if ((!strcmp(argv[1],keys[0]))||(!strcmp(argv[1],keys[1])))
help();
else
- {
+ {
if((srcf=fopen(argv[1],"r"))!=NULL)
{
while(i!=EOF)
putchar(i);
}
fclose(srcf);
- }
- else
+ }
+ else
{
printf("%s %s %s\n",argv[0],F_O_ERR,argv[1]);
ret=-1;
INT d = 0;
LPWSTR Module = L"";
LPWSTR Title = L"";
-
+
for (d = 0; d < Depth; d ++) printf (" ");
GetProcessInfo (pInfo, & Module, & Title);
wprintf (
pInfo = (PSYSTEM_PROCESS_INFORMATION)((PBYTE)pInfo + pInfo->NextEntryOffset);
} while (0 != pInfo->NextEntryOffset);
-
+
return EXIT_SUCCESS;
}
pInfo->InheritedFromUniqueProcessId
);
}
- else
+ else
{
if (ALREADY_PROCESSED != (DWORD)pInfo->InheritedFromUniqueProcessId)
{
pInfo = PsaWalkNextProcess(pInfo);
}
-
+
PsaFreeCapture(pInfoBase);
-
+
return EXIT_SUCCESS;
}
PSYSTEM_THREAD_INFORMATION CurThread;
if (NULL == pInfo) return EXIT_FAILURE;
-
+
CurThread = PsaWalkFirstThread(pInfo);
wprintf (L" NumberOfThreads: %d\n", pInfo->NumberOfThreads);
{
continue;
}
-
+
Status = NtQueryInformationThread (
hThread,
ThreadBasicInformation,
NtClose (hThread);
continue;
}
-
+
NtClose (hThread);
/* Now print the collected information */
0 /* FIXME: ((PTEB) tInfo.TebBaseAddress)->LastErrorValue */,
ThreadStateName[CurThread->ThreadState]
);
- }
+ }
return EXIT_SUCCESS;
}
OBJECT_ATTRIBUTES Oa = {0};
CLIENT_ID ClientId = {0, 0};
-
+
ClientId.UniqueProcess = (PVOID) atol (PidStr);
-
+
if (FALSE == AcquirePrivileges ())
{
return EXIT_FAILURE;
}
-
+
Status = NtOpenProcess (
& hProcess,
PROCESS_QUERY_INFORMATION,
LONG pInfoBaseLength = 0;
LPWSTR Module = L"";
LPWSTR Title = L"";
-
+
Status = NtQueryInformationProcess (
hProcess,
ProcessBasicInformation,
if (NULL == pInfo) return EXIT_FAILURE;
GetProcessInfo (pInfo, & Module, & Title);
-
+
wprintf (L"%4d %s\n", ClientId.UniqueProcess, Module);
#if 0
printf (" CWD: %s\n", ""); /* it won't appear if empty */
((LONG) PsVm.WorkingSetSize / 1024),
((LONG) PsVm.PeakWorkingSetSize / 1024)
);
-
+
PrintThreads (pInfo);
PrintModules ();
PsaFreeCapture(pInfoBase);
-
+
NtClose (hProcess);
-
+
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
* Copyright (c) 1998 Mark Russinovich
* Systems Internals
* http://www.sysinternals.com/
- *
+ *
* --------------------------------------------------------------------
*
* This software is free software; you can redistribute it and/or
* You should have received a copy of the GNU Library General Public
* License along with this software; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 675 Mass Ave,
- * Cambridge, MA 02139, USA.
+ * Cambridge, MA 02139, USA.
*
* --------------------------------------------------------------------
- *
+ *
* Print a Win32 error.
*
* 1999 February (Emanuele Aliberti)
* Taken from chkdskx.c and formatx.c by Mark Russinovich
* to be used in all sysutils.
- */
+ */
#include <windows.h>
#include <stdio.h>
)
{
PVOID lpMsgBuf;
-
+
FormatMessageW(
(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM),
NULL,
- ErrorCode,
+ ErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)& lpMsgBuf,
0,
wchar_t ** wargv;
int i;
int ec;
-
+
wargv = (wchar_t **) GlobalAlloc(
sizeof(void*) * argc,
0
#define _USE_MSG_PUMP_
typedef struct tagDialogData {
- HWND hWnd;
+ HWND hWnd;
LONG lData;
-} DialogData;
+} DialogData;
HINSTANCE hInst;
HWND hTabWnd;
LRESULT CALLBACK PageWndProc1(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK PageWndProc2(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK PageWndProc3(HWND, UINT, WPARAM, LPARAM);
-
+
////////////////////////////////////////////////////////////////////////////////
static BOOL OnCreate(HWND hWnd, LONG lData)
hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);
if (!hgbl)
return -1;
-
+
lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl);
-
+
// Define a dialog box.
lpdt->style = WS_POPUP | WS_BORDER | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION;
lpdt->cdit = 3; // number of controls
*lpw++ = 0xFFFF;
*lpw++ = 0x0082; // static class
- for (lpwsz = (LPWSTR)lpw;
+ for (lpwsz = (LPWSTR)lpw;
*lpwsz++ = (WCHAR)*lpszMessage++;
);
lpw = (LPWORD)lpwsz;
lpw = lpwAlign(lpw); // align creation data on DWORD boundary
*lpw++ = 0; // no creation data
- GlobalUnlock(hgbl);
- ret = DialogBoxIndirect(hinst, (LPDLGTEMPLATE)hgbl, hwndOwner, (DLGPROC)DialogWndProc);
+ GlobalUnlock(hgbl);
+ ret = DialogBoxIndirect(hinst, (LPDLGTEMPLATE)hgbl, hwndOwner, (DLGPROC)DialogWndProc);
if (ret == 0) {
TRACE(_T("DialogBoxIndirect() failed due to invalid handle to parent window: 0x%08X"), hwndOwner);
} else if (ret == -1) {
DWORD error = GetLastError();
TRACE(_T("DialogBoxIndirect() failed, GetLastError returned 0x%08X"), error);
}
- GlobalFree(hgbl);
- return ret;
+ GlobalFree(hgbl);
+ return ret;
}
////////////////////////////////////////////////////////////////////////////////
#include "trace.h"
-#define XBITMAP 80
-#define YBITMAP 20
-
-#define BUFFER_LEN MAX_PATH
-
+#define XBITMAP 80
+#define YBITMAP 20
+
+#define BUFFER_LEN MAX_PATH
+
extern HINSTANCE hInst;
-HBITMAP hbmpPicture;
-HBITMAP hbmpOld;
+HBITMAP hbmpPicture;
+HBITMAP hbmpOld;
////////////////////////////////////////////////////////////////////////////////
-static void AddItem(HWND hListBox, LPCTSTR lpstr, HBITMAP hbmp)
-{
- int nItem = SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)lpstr);
- SendMessage(hListBox, LB_SETITEMDATA, nItem, (LPARAM)hbmp);
-}
+static void AddItem(HWND hListBox, LPCTSTR lpstr, HBITMAP hbmp)
+{
+ int nItem = SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)lpstr);
+ SendMessage(hListBox, LB_SETITEMDATA, nItem, (LPARAM)hbmp);
+}
static TCHAR* items[] = {
_T("services"),
SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)szBuffer);
}
- SetFocus(hListBox);
- SendMessage(hListBox, LB_SETCURSEL, 0, 0);
+ SetFocus(hListBox);
+ SendMessage(hListBox, LB_SETCURSEL, 0, 0);
}
static void OnDrawItem(HWND hWnd, LPARAM lParam)
{
-// int nItem;
- TCHAR tchBuffer[BUFFER_LEN];
-// HBITMAP hbmp;
- TEXTMETRIC tm;
- int y;
- HDC hdcMem;
- LPDRAWITEMSTRUCT lpdis;
- RECT rcBitmap;
-
- lpdis = (LPDRAWITEMSTRUCT)lParam;
- // If there are no list box items, skip this message.
- if (lpdis->itemID != -1) {
- // Draw the bitmap and text for the list box item. Draw a rectangle around the bitmap if it is selected.
- switch (lpdis->itemAction) {
- case ODA_SELECT:
- case ODA_DRAWENTIRE:
- // Display the bitmap associated with the item.
- hbmpPicture = (HBITMAP)SendMessage(lpdis->hwndItem, LB_GETITEMDATA, lpdis->itemID, (LPARAM)0);
- hdcMem = CreateCompatibleDC(lpdis->hDC);
- hbmpOld = SelectObject(hdcMem, hbmpPicture);
- BitBlt(lpdis->hDC,
- lpdis->rcItem.left, lpdis->rcItem.top,
- lpdis->rcItem.right - lpdis->rcItem.left,
- lpdis->rcItem.bottom - lpdis->rcItem.top,
- hdcMem, 0, 0, SRCCOPY);
- // Display the text associated with the item.
- SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, (LPARAM)tchBuffer);
- GetTextMetrics(lpdis->hDC, &tm);
- y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
- TextOut(lpdis->hDC, XBITMAP + 6, y, tchBuffer, _tcslen(tchBuffer));
- SelectObject(hdcMem, hbmpOld);
- DeleteDC(hdcMem);
- // Is the item selected?
- if (lpdis->itemState & ODS_SELECTED) {
- // Set RECT coordinates to surround only the bitmap.
- rcBitmap.left = lpdis->rcItem.left;
- rcBitmap.top = lpdis->rcItem.top;
- rcBitmap.right = lpdis->rcItem.left + XBITMAP;
- rcBitmap.bottom = lpdis->rcItem.top + YBITMAP;
- // Draw a rectangle around bitmap to indicate the selection.
- DrawFocusRect(lpdis->hDC, &rcBitmap);
- }
- break;
- case ODA_FOCUS:
- // Do not process focus changes. The focus caret (outline rectangle)
- // indicates the selection. The IDOK button indicates the final selection.
- break;
- }
- }
+// int nItem;
+ TCHAR tchBuffer[BUFFER_LEN];
+// HBITMAP hbmp;
+ TEXTMETRIC tm;
+ int y;
+ HDC hdcMem;
+ LPDRAWITEMSTRUCT lpdis;
+ RECT rcBitmap;
+
+ lpdis = (LPDRAWITEMSTRUCT)lParam;
+ // If there are no list box items, skip this message.
+ if (lpdis->itemID != -1) {
+ // Draw the bitmap and text for the list box item. Draw a rectangle around the bitmap if it is selected.
+ switch (lpdis->itemAction) {
+ case ODA_SELECT:
+ case ODA_DRAWENTIRE:
+ // Display the bitmap associated with the item.
+ hbmpPicture = (HBITMAP)SendMessage(lpdis->hwndItem, LB_GETITEMDATA, lpdis->itemID, (LPARAM)0);
+ hdcMem = CreateCompatibleDC(lpdis->hDC);
+ hbmpOld = SelectObject(hdcMem, hbmpPicture);
+ BitBlt(lpdis->hDC,
+ lpdis->rcItem.left, lpdis->rcItem.top,
+ lpdis->rcItem.right - lpdis->rcItem.left,
+ lpdis->rcItem.bottom - lpdis->rcItem.top,
+ hdcMem, 0, 0, SRCCOPY);
+ // Display the text associated with the item.
+ SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, (LPARAM)tchBuffer);
+ GetTextMetrics(lpdis->hDC, &tm);
+ y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
+ TextOut(lpdis->hDC, XBITMAP + 6, y, tchBuffer, _tcslen(tchBuffer));
+ SelectObject(hdcMem, hbmpOld);
+ DeleteDC(hdcMem);
+ // Is the item selected?
+ if (lpdis->itemState & ODS_SELECTED) {
+ // Set RECT coordinates to surround only the bitmap.
+ rcBitmap.left = lpdis->rcItem.left;
+ rcBitmap.top = lpdis->rcItem.top;
+ rcBitmap.right = lpdis->rcItem.left + XBITMAP;
+ rcBitmap.bottom = lpdis->rcItem.top + YBITMAP;
+ // Draw a rectangle around bitmap to indicate the selection.
+ DrawFocusRect(lpdis->hDC, &rcBitmap);
+ }
+ break;
+ case ODA_FOCUS:
+ // Do not process focus changes. The focus caret (outline rectangle)
+ // indicates the selection. The IDOK button indicates the final selection.
+ break;
+ }
+ }
}
void OnMeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
- HFONT hFont;
+ HFONT hFont;
LOGFONT lf;
- hFont = GetStockObject(SYSTEM_FONT);
+ hFont = GetStockObject(SYSTEM_FONT);
GetObject(hFont, sizeof(LOGFONT), &lf);
if (lf.lfHeight < 0)
- lpMeasureItemStruct->itemHeight = -lf.lfHeight;
+ lpMeasureItemStruct->itemHeight = -lf.lfHeight;
else
- lpMeasureItemStruct->itemHeight = lf.lfHeight;
+ lpMeasureItemStruct->itemHeight = lf.lfHeight;
}
LRESULT CALLBACK PageWndProc1(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG:
InitListCtrl(hDlg);
return TRUE;
- case WM_SETFONT:
+ case WM_SETFONT:
OnSetFont(hDlg, wParam, lParam);
return TRUE;
- case WM_MEASUREITEM:
+ case WM_MEASUREITEM:
OnMeasureItem((LPMEASUREITEMSTRUCT)lParam);
- return TRUE;
- case WM_DRAWITEM:
+ return TRUE;
+ case WM_DRAWITEM:
OnDrawItem(hDlg, lParam);
- return TRUE;
+ return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
/////////////////////////////////////////////////////////////////////////////
// Diagnostic Trace
//
-#include <stdio.h>
+#include <stdio.h>
#include <stdarg.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifdef _MSC_VER
#include "stdafx.h"
#else
#include <process.h>
#include <stdio.h>
#endif
-
+
#include "main.h"
#include "about.h"
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifndef __ABOUT_H__
#define __ABOUT_H__
#include <process.h>
#include <stdio.h>
#endif
-
+
#include <assert.h>
#define ASSERT assert
LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM);
-
+
#ifdef __cplusplus
};
#include <process.h>
#include <stdio.h>
#endif
-
+
#include "main.h"
#include "about.h"
#include "framewnd.h"
LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM);
-
+
#ifdef __cplusplus
};
#include <process.h>
#include <stdio.h>
#endif
-
+
#include "main.h"
#include "framewnd.h"
#include "childwnd.h"
CheckMenuItem(hMenuOptions, ID_OPTIONS_TOOLBAR, MF_BYCOMMAND|MF_CHECKED);
// Create the status bar
- hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
+ hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
"", hFrameWnd, IDC_STATUSBAR);
if (!hStatusBar)
return FALSE;
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_MDI_APP, szFrameClass, MAX_LOADSTRING);
LoadString(hInstance, IDC_MDI_APP_CHILD, szChildClass, MAX_LOADSTRING);
-
+
// Allow only one running instance
EnumWindows(EnumWndProc, (LPARAM)szFrameClass);
if (g_foundPrevInstance)
hMDIClient = GetWindow(hFrameWnd, GW_CHILD);
// Main message loop:
- while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
- if (!TranslateMDISysAccel(hMDIClient, &msg) &&
- !TranslateAccelerator(hFrameWnd, hAccel, &msg)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
+ while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
+ if (!TranslateMDISysAccel(hMDIClient, &msg) &&
+ !TranslateAccelerator(hFrameWnd, hAccel, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
ExitInstance();
return msg.wParam;
}
#include <process.h>
#include <stdio.h>
#endif
-
+
#include <assert.h>
#define ASSERT assert
LRESULT CALLBACK PanelWndProc(HWND, UINT, WPARAM, LPARAM);
-
+
#ifdef __cplusplus
};
#define IDC_STATIC -1
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 138
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifdef _MSC_VER
#include "stdafx.h"
#else
}
-/*
+/*
*/
\ No newline at end of file
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifndef __ROS2WIN_H__
#define __ROS2WIN_H__
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
-/* $Id: alive.c,v 1.1 2004/10/21 04:48:44 sedwards Exp $
+/* $Id$
*
*/
#include <windows.h>
HINSTANCE HInst;
const char* WndClassName = "GMainWnd";
-LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
+LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
LPARAM LParam);
-
-WINBOOL
+
+WINBOOL
STDCALL
GdiAlphaBlend(HDC hdcDst,LONG DstX,LONG DstY,LONG DstCx,LONG DstCy,HDC hdcSrc,LONG SrcX,LONG SrcY,LONG SrcCx,LONG SrcCy,BLENDFUNCTION BlendFunction);
HInst = HInstance;
memset(&wc, 0, sizeof(WNDCLASS));
-
+
wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = MainWndProc;
wc.hInstance = HInstance;
if (RegisterClass(&wc))
{
- HWND HWnd =
+ HWND HWnd =
CreateWindow(
WndClassName, TEXT("AlphaBlend Rendering Demo"),
- WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION |
+ WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION |
WS_VISIBLE | WS_CLIPSIBLINGS,
0, 0, 320, 430,
NULL, NULL, HInst, NULL
);
-
+
if (HWnd)
{
ShowWindow(HWnd, nCmdShow);
{
TranslateMessage(&msg);
DispatchMessage(&msg);
- }
+ }
}
}
return 0;
HBITMAP bmpalpha;
SelectObject(hDC, H32BppBitmap);
BitBlt(hDC, 0, 0, bmp->bmWidth, bmp->bmHeight, HMemDC, 0, 0, SRCCOPY);
-
+
/* load and apply alpha channel */
- bmpalpha = LoadImage(HInst, TEXT("lenaalpha.bmp"), IMAGE_BITMAP,
+ bmpalpha = LoadImage(HInst, TEXT("lenaalpha.bmp"), IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE);
if(bmpalpha)
{
return FALSE;
}
SelectObject(hdcTemp, bmpalpha);
-
+
for(y = 0; y < bmp->bmHeight; y++)
{
for(x = 0; x < bmp->bmWidth; x++)
*col++ |= Color;
}
}
-
+
DeleteObject(bmpalpha);
DeleteDC(hdcTemp);
return TRUE;
return FALSE;
}
-LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
+LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
LPARAM LParam)
{
switch (Msg)
{
case WM_CREATE:
- {
+ {
/* create a memory DC */
HMemDC = CreateCompatibleDC(NULL);
if (HMemDC)
{
/* load a bitmap from file */
- HBITMAP HBmp =
+ HBITMAP HBmp =
/* static_cast<HBITMAP> */(
- LoadImage(HInst, filename, IMAGE_BITMAP,
+ LoadImage(HInst, filename, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE)
- );
+ );
if (HBmp)
- {
+ {
/* extract dimensions of the bitmap */
GetObject(HBmp, sizeof(BITMAP), &bmp);
return 0;
}
}
- }
+ }
}
case WM_PAINT:
{
try
#endif
{
-
+
BlendFunc.BlendOp = AC_SRC_OVER;
BlendFunc.BlendFlags = 0;
BlendFunc.SourceConstantAlpha = 128;
BlendFunc.AlphaFormat = 0;
-
- BitBlt(Hdc, 100, 90,
+
+ BitBlt(Hdc, 100, 90,
bmp.bmWidth, bmp.bmHeight,
- HMemDC2, 0, 0,
- SRCCOPY);
+ HMemDC2, 0, 0,
+ SRCCOPY);
GdiAlphaBlend(Hdc, 0, 0, bmp.bmWidth, bmp.bmHeight,
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
BlendFunc);
GdiAlphaBlend(Hdc, bmp.bmWidth - 15, 10, bmp.bmWidth / 2, bmp.bmHeight / 2,
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
BlendFunc);
-
+
BlendFunc.SourceConstantAlpha = 255;
BlendFunc.AlphaFormat = AC_SRC_ALPHA;
-
+
GdiAlphaBlend(Hdc, 140, 200, bmp.bmWidth, bmp.bmHeight,
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
BlendFunc);
GdiAlphaBlend(Hdc, 20, 210, (bmp.bmWidth / 3) * 2, (bmp.bmHeight / 3) * 2,
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
BlendFunc);
- }
+ }
#if 0
catch (...)
{
HANDLE OutputHandle;
HANDLE InputHandle;
-VOID STDCALL
+VOID STDCALL
ApcRoutine(PVOID Context,
PIO_STATUS_BLOCK IoStatus,
ULONG Reserved)
CHAR Buffer[256];
HANDLE EventHandle;
LARGE_INTEGER off;
-
+
AllocConsole();
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
printf("APC test program\n");
-
+
EventHandle = CreateEventW(NULL,
FALSE,
FALSE,
printf("Failed to create event\n");
return 0;
}
-
+
printf("Opening file\n");
InitializeObjectAttributes(&ObjectAttributes,
&FileName,
0,
NULL,
NULL);
-
+
printf("Creating file\n");
FileHandle = CreateFileW(L"C:\\a.txt",
FILE_GENERIC_READ | FILE_GENERIC_WRITE,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
-
+
if (FileHandle == INVALID_HANDLE_VALUE)
{
printf("Open failed last err 0x%lu\n",GetLastError());
return 0;
}
-
+
off.QuadPart = 0;
-
+
printf("Reading file\n");
Status = ZwReadFile(FileHandle,
NULL,
&IoStatus,
Buffer,
256,//len
- &off ,//offset must exist if file was opened for asynch. i/o aka. OVERLAPPED
- NULL);
-
+ &off ,//offset must exist if file was opened for asynch. i/o aka. OVERLAPPED
+ NULL);
+
if (!NT_SUCCESS(Status))
{
printf("Read failed status 0x%lu\n",Status);
VOID CALLBACK TimerApcProc(
LPVOID lpArg,
DWORD dwTimerLowValue,
- DWORD dwTimerHighValue )
+ DWORD dwTimerHighValue )
{
printf("APC Callback %lu\n", *(PDWORD)lpArg);
}
-int main()
+int main()
{
HANDLE hTimer;
BOOL bSuccess;
DWORD value = 1;
hTimer = CreateWaitableTimer(NULL, FALSE, NULL );
-
+
if (!hTimer)
{
printf("CreateWaitableTimer failed!\n");
return 0;
- }
+ }
DueTime.QuadPart = -(LONGLONG)(5 * 10000000);
return 0;
}
- for (;value <= 10; value++ )
+ for (;value <= 10; value++ )
{
SleepEx(INFINITE, TRUE /*alertable*/ );
}
/*
- *
+ *
*/
int main(int argc, char* argv[])
{
-
+
}
}
printf("All threads created...\n");
-
+
/*
* Waiting for threads is not implemented yet.
* If you want to see all threads running, uncomment the
* Created by Damon Chandler <dmc27@ee.cornell.edu>
* Updates can be downloaded at: <www.coriolis.com>
*
- * Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
+ * Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
* if you have any questions about this code.
*/
HINSTANCE HInst;
const char* WndClassName = "GMainWnd";
-LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
+LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
LPARAM LParam);
HInst = HInstance;
memset(&wc, 0, sizeof(WNDCLASS));
-
+
wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = MainWndProc;
wc.hInstance = HInstance;
if (RegisterClass(&wc))
{
- HWND HWnd =
+ HWND HWnd =
CreateWindow(
WndClassName, TEXT("BitBlt Bitmap Rendering Demo"),
- WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION |
+ WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION |
WS_VISIBLE | WS_CLIPSIBLINGS,
0, 0, 220, 230,
NULL, NULL, HInst, NULL
);
-
+
if (HWnd)
{
ShowWindow(HWnd, nCmdShow);
{
TranslateMessage(&msg);
DispatchMessage(&msg);
- }
+ }
}
}
return 0;
HDC HMemDC = NULL;
HBITMAP HOldBmp = NULL;
-LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
+LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
LPARAM LParam)
{
switch (Msg)
{
case WM_CREATE:
- {
+ {
/* create a memory DC */
HMemDC = CreateCompatibleDC(NULL);
if (HMemDC)
{
/* load a bitmap from file */
- HBITMAP HBmp =
+ HBITMAP HBmp =
/* static_cast<HBITMAP> */(
- LoadImage(HInst, filename, IMAGE_BITMAP,
+ LoadImage(HInst, filename, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE)
- );
+ );
if (HBmp)
- {
+ {
/* extract dimensions of the bitmap */
GetObject(HBmp, sizeof(BITMAP), &bmp);
(SelectObject(HMemDC, HBmp)
);
}
- }
+ }
}
case WM_PAINT:
{
try
#endif
{
-
+
/* TODO: add palette support (see Chapter 9)... */
-
- BitBlt(Hdc, 20, 15,
+
+ BitBlt(Hdc, 20, 15,
bmp.bmWidth, bmp.bmHeight,
- HMemDC, 0, 0,
- SRCCOPY);
- }
+ HMemDC, 0, 0,
+ SRCCOPY);
+ }
#if 0
catch (...)
#endif
HFONT tf;
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
hbtn[11] = CreateWindow(
"BUTTON","BS_DEFPUSHBUTTON|BS_LEFT",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_LEFT,
480, 10, 250, 40, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL);
-
+
hbtn[12] = CreateWindow(
"BUTTON","BS_DEFPUSHBUTTON|BS_RIGHT|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_RIGHT |BS_MULTILINE,
740, 10, 150, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL);
-/* $Id: capclock.c,v 1.1 2004/10/21 05:11:59 sedwards Exp $
+/* $Id$
*
* DESCRIPTION: Simple Win32 Caption Clock
* PROJECT : ReactOS (test applications)
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
WNDCLASS wc;
MSG msg;
HWND hWnd;
-
+
CaretBitmap = LoadBitmap(hInstance, (LPCTSTR)IDB_CARET);
wc.lpszClassName = "CaretTestClass";
break;
}
break;
-
+
case WM_KEYDOWN:
if(!GetCaretPos(&pt))
{
if(!SetCaretPos(pt.x, pt.y))
DbgPrint("SetCaretPos() failed!\n");
break;
-
+
case WM_RBUTTONDOWN:
if(!CreateCaret(hWnd, CaretBitmap, 0, 0))
DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd);
if(!ShowCaret(hWnd))
DbgPrint("ShowCaret(0x%x)\n", hWnd);
break;
-
+
case WM_LBUTTONDOWN:
if(!CreateCaret(hWnd, (HBITMAP)0, CaretWidth, CaretHeight))
DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd);
if(!ShowCaret(hWnd))
DbgPrint("ShowCaret(0x%x)\n", hWnd);
break;
-
+
case WM_CREATE:
if(!CreateCaret(hWnd, (HBITMAP)0, CaretWidth, CaretHeight))
DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd);
if(!SetCaretPos(1, 1))
DbgPrint("SetCaretPos(%i, %i) failed!\n", 1, 1);
break;
-
+
case WM_DESTROY:
if(!DestroyCaret())
DbgPrint("DestroyCaret() failed!\n");
PostQuitMessage(0);
break;
-
+
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
{"WS_VSCROLL",WS_VSCROLL}
};
-/* The number of check buttons we have.
+/* The number of check buttons we have.
* Maybe some calculations at compile time would be better
*/
g_hwnd,
(HMENU) id,
g_hInst,
- NULL
+ NULL
);
yButPos += 21;
return h;
LRESULT
CALLBACK
WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
- {
+ {
int i;
switch ( msg )
{
{
int i;
buf += 7;
-
+
for (i=0;i<8;i++)
{
*buf-- = hexvals[val & 0x0000000F];
ULONG x[SIZE / 4096];
int main()
-{
+{
int i;
PUCHAR BaseAddress;
-
+
BaseAddress = VirtualAlloc(NULL,
SIZE,
MEM_COMMIT,
printf("%.8x ", i*4096);
x[i] = BaseAddress[i*4096];
}
-
+
return(0);
}
DWORD wrote;
int c;
- DeleteTestFile(filename);
- file = CreateFile(filename,
- GENERIC_READ | GENERIC_WRITE,
- 0,
- NULL,
- CREATE_ALWAYS,
- 0,
+ DeleteTestFile(filename);
+ file = CreateFile(filename,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ 0,
0);
-
+
if (INVALID_HANDLE_VALUE == file) {
fprintf(stderr, "CreateFile failed with code %lu\n", GetLastError());
exit(1);
}
CloseHandle(file);
-
+
diskattr = GetFileAttributes(filename);
if (INVALID_FILE_ATTRIBUTES == diskattr) {
fprintf(stderr, "GetFileAttributes failed with code %lu\n", GetLastError());
-/* $Id: count.c,v 1.1 2004/10/21 05:12:00 sedwards Exp $
+/* $Id$
*
*/
#include <stdio.h>
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
static char selected[MAX_PATH + 1];
INT_PTR
-CALLBACK
+CALLBACK
DlgMainProc(
HWND hwndDlg,
UINT uMsg,
)
{
char dir[MAX_PATH + 1];
-
+
switch(uMsg)
{
case WM_COMMAND:
{
char file[MAX_PATH + 1];
int len;
-
+
if(!DlgDirSelectEx(hwndDlg, file, MAX_PATH, IDC_DIRS))
{
GetCurrentDirectory(MAX_PATH, selected);
return FALSE;
}
-int WINAPI
+int WINAPI
WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
* PROJECT: ReactOS diskspeed.exe
* FILE: apps/tests/diskspeed/diskspeed.c
* PURPOSE: Determines disk transfer rates
- * PROGRAMMER: Hartmut Birr
+ * PROGRAMMER: Hartmut Birr
*/
#include <windows.h>
INQUIRYDATA InquiryData;
- Drive = 0;
+ Drive = 0;
while (1)
{
sprintf(Name, "\\\\.\\PHYSICALDRIVE%ld", Drive);
printf("Transfer Size (kB) 1 2 4 8 16 32 64 128 256\n");
printf("Transfer Rate (MB/s)\n");
printf("-------------------------------------------------------------------------------\n");
-
+
Buffer = VirtualAlloc(NULL, 512 * 1024, MEM_COMMIT, PAGE_READWRITE);
}
Result = GetInquiryData(hDevice, &InquiryData);
while( AddrResponse ) {
if( AddrResponse->wType == DNS_TYPE_A ) {
Addr = ntohl( AddrResponse->Data.A.IpAddress );
- printf( "www.reactos.com == %d.%d.%d.%d\n",
+ printf( "www.reactos.com == %d.%d.%d.%d\n",
(int)(Addr >> 24) & 0xff,
(int)(Addr >> 16) & 0xff,
(int)(Addr >> 8) & 0xff,
while( AddrResponse ) {
if( AddrResponse->wType == DNS_TYPE_A ) {
Addr = ntohl( AddrResponse->Data.A.IpAddress );
- printf( "www.reactos.com == %d.%d.%d.%d\n",
+ printf( "www.reactos.com == %d.%d.%d.%d\n",
(int)(Addr >> 24) & 0xff,
(int)(Addr >> 16) & 0xff,
(int)(Addr >> 8) & 0xff,
{
int i;
- printf("TickCountLow: %lx\n",
+ printf("TickCountLow: %lx\n",
SharedUserData->TickCountLow);
printf("Drives: ");
for (i = 0; i < 26; i++)
#define BUFFERLEN 80 /* Size of buffer to hold result strings */
/* Edit is created with this text */
-#define TestStr "The quick brown fox jumps over the lazy dog"
+#define TestStr "The quick brown fox jumps over the lazy dog"
#define TestStrW L"This is a WCHAR string" /* Wide to support unicode edits */
HDC hdc;
hdc = GetDC (g_hwnd);
SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
-
+
TextOut (hdc, x,y,Text,len);
ReleaseDC (g_hwnd, hdc);
ValidateRect (g_hwnd, &rect);
VOID
HandlePrintPasswdChar(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
{
- HDC hdc;
+ HDC hdc;
int ret = SendMessage(handle,Msg,wParam,lParam);
int s;
{"EM_GETMODIFY",EM_GETMODIFY,0,0,&HandlePrintReturnHex},
{"EM_SETMODIFY",EM_SETMODIFY,TRUE,0,&HandlePrintReturnHex},
-
+
{"EM_GETSEL",EM_GETSEL,(WPARAM)&StartP,(LPARAM)&EndP,&HandlePrintReturnHex},
{"EM_GETTHUMB",EM_GETTHUMB,0,0,&HandlePrintReturnHex},
-
+
{"EM_LIMITTEXT",EM_LIMITTEXT,10,0,&HandlePrintReturnHex},
{"EM_LINEFROMCHAR",EM_LINEFROMCHAR,-1,0,&HandlePrintReturnHex},
{"EM_POSFROMCHAR",EM_POSFROMCHAR,10,0,&HandlePrintReturnHex},
{"WM_CUT",WM_CUT,0,0,&HandlePrintReturnHex},
{"WM_COPY",WM_COPY,0,0,&HandlePrintReturnHex}
-
+
};
DWORD EditStyles[] = {
g_hwnd,
(HMENU) id,
g_hInst,
- NULL
+ NULL
);
yButPos += 21;
return h;
LRESULT
CALLBACK
WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
-{
+{
int i;
switch ( msg )
{
Buttons[i++] = CreatePushButton("CreateWindowA",140,CREATEWINDOW,WS_VISIBLE);
Buttons[i++] = CreatePushButton("CreateWindowExA",140,CREATEWINDOWEX,WS_VISIBLE);
Buttons[i++] = CreatePushButton("CreateWindowExW",140,CREATEWINDOWW,WS_VISIBLE);
-
+
/* ---- The 1st page of buttons ---- */
wc.lpfnWndProc = WndProc; /* window procedure */
wc.hInstance = hInst; /* owner of the class */
- wc.lpszClassName = className;
+ wc.lpszClassName = className;
wc.hCursor = LoadCursor ( 0, (LPCTSTR)IDC_ARROW );
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.style = CS_HREDRAW | CS_VREDRAW;
{
int i;
buf += 7;
-
+
for (i=0;i<8;i++)
{
*buf-- = hexvals[val & 0x0000000F];
SIZE EnhMetafileSize;
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
MSG msg;
HWND hWnd;
ENHMETAHEADER emh;
-
+
EnhMetafile = GetEnhMetaFile("test.emf");
if(!EnhMetafile)
{
- fprintf(stderr, "GetEnhMetaFile failed (last error 0x%lX)\n",
+ fprintf(stderr, "GetEnhMetaFile failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
//tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
// ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
// DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
-
+
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&msg, NULL, 0, 0))
TranslateMessage(&msg);
DispatchMessage(&msg);
}
-
+
DeleteEnhMetaFile(EnhMetafile);
//DeleteObject(tf);
RECT rc;
HDC hDC;
int bk;
-
+
GetClientRect(hWnd, &rc);
hDC = BeginPaint(hWnd, &ps);
rc.left = (rc.right / 2) - (EnhMetafileSize.cx / 2);
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
-/* $Id: fiber.c,v 1.1 2004/10/21 05:12:02 sedwards Exp $
+/* $Id$
*/
#include <assert.h>
++ k;
continue;
}
-
+
ple = (PLIST_ENTRY)a_leQueues[nQueue].Flink;
}
else
-#include <stdio.h>\r
-#include <winsock2.h>\r
-\r
-int main( int argc, char **argv ) {\r
- WSADATA wdata;\r
-\r
- WSAStartup( 0x0101, &wdata );\r
-\r
- if( argc > 1 ) {\r
- struct hostent *he = gethostbyname( argv[1] );\r
- if( !he ) {\r
- printf( "lookup of host %s failed: %d\n", argv[1], WSAGetLastError() );\r
- return 1;\r
- } else {\r
- printf( "Lookup of host %s returned %s\n", \r
- argv[1], inet_ntoa(*((struct in_addr *)he->h_addr_list[0])) );\r
- return 0;\r
- }\r
- } else\r
- return 1;\r
-}\r
+#include <stdio.h>
+#include <winsock2.h>
+
+int main( int argc, char **argv ) {
+ WSADATA wdata;
+
+ WSAStartup( 0x0101, &wdata );
+
+ if( argc > 1 ) {
+ struct hostent *he = gethostbyname( argv[1] );
+ if( !he ) {
+ printf( "lookup of host %s failed: %d\n", argv[1], WSAGetLastError() );
+ return 1;
+ } else {
+ printf( "Lookup of host %s returned %s\n",
+ argv[1], inet_ntoa(*((struct in_addr *)he->h_addr_list[0])) );
+ return 0;
+ }
+ } else
+ return 1;
+}
/*
** This define controls the size of a memory allocation request.
-** For this test suite to really be comprehensive, we should
+** For this test suite to really be comprehensive, we should
** probably be testing many different block sizes.
*/
#define MEM_BLOCK_SIZE 0x80000
/*---------------------------------------------------------------------------
** This is a relation used to combine two test statuses.
-** The combine rules are as follows:
+** The combine rules are as follows:
** FAIL & Anything == FAIL
** SKIPPED & Anything == Anything
**
case FAILED: result = FAILED; break;
case SKIPPED: result = b; break;
}
-
+
return result;
}
memset(output, 0, DISPLAY_COLUMNS + 2);
- /*If this line is longer than DISPLAY_COLUMNS,
+ /*If this line is longer than DISPLAY_COLUMNS,
* break it at the first space.
*/
if (DISPLAY_COLUMNS - 2 < strlen(szLine))
output[1] = ' ';
output[strlen(output)] = '\n';
printf(output);
-
+
OUTPUT_Line(szLine + spaceIndex + 1);
}
else
sprintf(output,"| %s\n", szLine);
printf(output);
}
-
+
}
/*---------------------------------------------------------------------------
{
OUTPUT_Line("Fixed Memory");
}
-
+
if (pFlags & GMEM_ZEROINIT)
{
OUTPUT_Line("Zero Initialized Memory");
TEST_STATUS TEST_MemoryWrite(LPVOID mem, DWORD cbSize)
{
TEST_STATUS result = FAILED;
-
+
if (0 == IsBadWritePtr(mem, cbSize))
{
result = PASSED;
}
- return result;
+ return result;
}
/*---------------------------------------------------------------------------
TEST_STATUS TEST_MemoryRead(LPVOID mem, DWORD cbSize)
{
TEST_STATUS result = FAILED;
-
+
if (0 == IsBadReadPtr(mem, cbSize))
{
result = PASSED;
}
- return result;
+ return result;
}
/*---------------------------------------------------------------------------
rc = 1;
}
GlobalUnlock(hMem);
-
+
return rc;
}
TEST_STATUS status = SKIPPED;
HGLOBAL hTest = 0;
OUTPUT_Banner("Testing the GlobalAlloc and GlobalFree calls");
- OUTPUT_Line("Allocate a buffer");
+ OUTPUT_Line("Allocate a buffer");
OutputAllocFlags(allocFlags);
LPVOID pMem = 0;
TEST_STATUS subtest = SKIPPED;
TEST_STATUS result = FAILED;
-
+
OUTPUT_Banner("Testing the GlobalLock/Unlock functions.");
OutputAllocFlags(allocFlags);
OUTPUT_Line("");
if (0 != hMem)
{
OUTPUT_Line("Allocated a memory block");
-
+
OUTPUT_Line("Testing Lock");
pMem = GlobalLock(hMem);
if (0 != pMem)
{
OUTPUT_Result(PASSED);
-
+
OUTPUT_Line("Testing memory for read.");
subtest = TEST_MemoryRead(pMem, MEM_BLOCK_SIZE);
OUTPUT_Result(subtest);
result = TEST_CombineStatus(PASSED, subtest);
-
+
OUTPUT_Line("Testing memory for write.");
subtest = TEST_MemoryRead(pMem, MEM_BLOCK_SIZE);
OUTPUT_Result(subtest);
result = TEST_CombineStatus(result, subtest);
-
+
OUTPUT_Line("Unlocking memory");
if (GlobalUnlock(hMem))
LPVOID pMem = 0;
TEST_STATUS subtest = SKIPPED;
TEST_STATUS result = SKIPPED;
-
+
OUTPUT_Line("Testing GlobalReAlloc() on memory allocated as GMEM_FIXED");
/* Case 1: convert a fixed block to a movable block. */
OUTPUT_HexDword((DWORD)hReAlloced);
if (hMem == hReAlloced)
{
- OUTPUT_Line("GlobalReAlloc returned the same pointer. The documentation states that this is wrong, but Windows NT works this way.");
+ OUTPUT_Line("GlobalReAlloc returned the same pointer. The documentation states that this is wrong, but Windows NT works this way.");
}
-
+
hMem = hReAlloced;
subtest = TEST_CombineStatus(subtest, PASSED);
subtest = TEST_CombineStatus(subtest, TEST_MemoryRead((LPVOID)hMem, MEM_BLOCK_SIZE - 100));
LPVOID pMem = 0;
TEST_STATUS subtest = SKIPPED;
TEST_STATUS result = SKIPPED;
-
+
OUTPUT_Line("Testing GlobalReAlloc() on memory allocated as GMGM_MOVEABLE");
-
+
/* case 1 test reallocing a movable block that is unlocked. */
OUTPUT_Line("Allocating buffer");
hMem = GlobalAlloc(GMEM_MOVEABLE, MEM_BLOCK_SIZE);
OUTPUT_HexDword((DWORD)hMem);
OUTPUT_Line("ReAlloced Handle: ");
OUTPUT_HexDword((DWORD)hReAlloced);
-
+
pMem = GlobalLock(hReAlloced);
hMem = hReAlloced;
subtest = TEST_CombineStatus(subtest, PASSED);
}
GlobalUnlock(hMem);
-
+
GlobalFree(hMem);
}
else
OUTPUT_Line("");
result = TEST_CombineStatus(result, subtest);
-
+
OUTPUT_Line("");
return result;
}
result = TEST_CombineStatus(result, TestGlobalReAllocFixed());
result = TEST_CombineStatus(result, TestGlobalReAllocMovable());
-
+
OUTPUT_Line("GlobalReAlloc test result:");
OUTPUT_Result(result);
return result;
result = TEST_CombineStatus(result, FAILED);
}
OUTPUT_Result(result);
-
+
OUTPUT_Line("Pointer from handle: ");
OUTPUT_HexDword((DWORD)GlobalLock(hMem));
-
+
OUTPUT_Line("Testing after a lock");
OUTPUT_Line("Testing for a lock of 1");
uFlags = GlobalFlags(hMem);
OUTPUT_Line("Testing for a discarded flag");
uFlags = GlobalFlags(hMem);
if (0 != (uFlags & GMEM_DISCARDED)) /*discarded*/
- {
+ {
result = TEST_CombineStatus(result, PASSED);
}
else
OUTPUT_Line("GlobalAlloc failed!");
result = TEST_CombineStatus(result, FAILED);
}
-
+
return result;
}
/*---------------------------------------------------------------------------
{
OUTPUT_Banner("Testing GlobalFlags()");
TEST_STATUS result = SKIPPED;
-
- result = TEST_CombineStatus(result, TestGlobalFlagsFixed());
- result = TEST_CombineStatus(result, TestGlobalFlagsMoveable());
-
+
+ result = TEST_CombineStatus(result, TestGlobalFlagsFixed());
+ result = TEST_CombineStatus(result, TestGlobalFlagsMoveable());
+
OUTPUT_Line("GlobalFlags result:");
OUTPUT_Result(result);
return result;
TEST_STATUS result = SKIPPED;
OUTPUT_Banner("Testing GlobalHandle()");
-
+
OUTPUT_Line("Testing GlobalHandle with a block of GMEM_FIXED memory");
hMem = GlobalAlloc(GMEM_FIXED, MEM_BLOCK_SIZE);
if (0 != hMem)
OUTPUT_Line("Allocation handle: ");
OUTPUT_HexDword((DWORD)hMem);
-
+
hTest = GlobalHandle(hMem);
if (hMem == hTest)
{
OUTPUT_Line("Result from subtest:");
OUTPUT_Result(subtest);
result = TEST_CombineStatus(result, subtest);
-
+
OUTPUT_Line("Global Handle test results:");
OUTPUT_Result(result);
TEST_STATUS subtest = SKIPPED;
TEST_STATUS result = SKIPPED;
OUTPUT_Banner("Testing GlobalSize()");
-
+
OUTPUT_Line("Testing GlobalSize with a block of GMEM_FIXED memory");
hMem = GlobalAlloc(GMEM_FIXED, MEM_BLOCK_SIZE);
if (0 != hMem)
OUTPUT_Line("Testing GlobalSize with a block of GMEM_MOVEABLE memory");
hMem = GlobalAlloc(GMEM_MOVEABLE, MEM_BLOCK_SIZE);
if (0 != hMem)
- {
+ {
size = GlobalSize(hMem);
if (MEM_BLOCK_SIZE <= size)
{
{
OUTPUT_Line("Allocation handle: ");
OUTPUT_HexDword((DWORD)hMem);
-
+
hTest = GlobalDiscard(hMem);
if (0 == hTest)
{
test_set = TEST_CombineStatus(test_set, TestGlobalLockNUnlock(GHND));
test_set = TEST_CombineStatus(test_set, TestGlobalLockNUnlock(GMEM_FIXED));
test_set = TEST_CombineStatus(test_set, TestGlobalLockNUnlock(GMEM_MOVEABLE));
-
+
test_set = TEST_CombineStatus(test_set, TestGlobalReAlloc());
test_set = TEST_CombineStatus(test_set, TestGlobalFlags());
-
+
test_set = TEST_CombineStatus(test_set, TestGlobalHandle());
-
+
test_set = TEST_CombineStatus(test_set, TestGlobalSize());
-
+
test_set = TEST_CombineStatus(test_set, TestGlobalDiscard());
/* output the result for the entire set of tests*/
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
GRADIENT_TRIANGLE gTRi[3];
GRADIENT_RECT gRect[2];
hDC = BeginPaint(hWnd, &ps);
-
+
vert [0] .x = 0;
vert [0] .y = 0;
vert [0] .Red = 0xff00;
vert [1] .Green = 0x0000;
vert [1] .Blue = 0xff00;
vert [1] .Alpha = 0x0000;
-
+
vert [2] .x = 100;
- vert [2] .y = 200;
+ vert [2] .y = 200;
vert [2] .Red = 0xff00;
vert [2] .Green = 0x0000;
vert [2] .Blue = 0x0000;
vert [2] .Alpha = 0x0000;
vert [3] .x = 250;
- vert [3] .y = 300;
+ vert [3] .y = 300;
vert [3] .Red = 0x8000;
vert [3] .Green = 0x8000;
vert [3] .Blue = 0x0000;
vert [3] .Alpha = 0x0000;
vert [4] .x = 325;
- vert [4] .y = 300;
+ vert [4] .y = 300;
vert [4] .Red = 0x0000;
vert [4] .Green = 0xff00;
vert [4] .Blue = 0x0000;
vert [0] .Alpha = 0x0000;
vert [1] .x = 90;
- vert [1] .y = 240;
+ vert [1] .y = 240;
vert [1] .Red = 0x0000;
vert [1] .Green = 0x0000;
vert [1] .Blue = 0xff00;
vert [1] .Alpha = 0x0000;
-
+
vert [2] .x = 5;
vert [2] .y = 245;
vert [2] .Red = 0x0000;
vert [2] .Alpha = 0x0000;
vert [3] .x = 90;
- vert [3] .y = 300;
+ vert [3] .y = 300;
vert [3] .Red = 0x0000;
vert [3] .Green = 0x0000;
vert [3] .Blue = 0xff00;
gRect[0].UpperLeft = 0;
gRect[0].LowerRight = 1;
-
+
gRect[1].UpperLeft = 2;
gRect[1].LowerRight = 3;
-
+
GdiGradientFill(hDC,vert,4,&gRect[0],1,GRADIENT_FILL_RECT_H);
GdiGradientFill(hDC,vert,4,&gRect[1],1,GRADIENT_FILL_RECT_V);
//HFONT tf;
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
gti.cbSize = sizeof(GUITHREADINFO);
GetGUIThreadInfo(0, >i);
-
+
SetTimer(hWnd, 1, 1000, NULL);
ShowWindow(hWnd, nCmdShow);
if(gti.flags & GUI_POPUPMENUMODE) lstrcat(str, "GUI_POPUPMENUMODE ");
if(gti.flags & GUI_SYSTEMMENUMODE) lstrcat(str, "GUI_SYSTEMMENUMODE ");
TextOut(hDC, 10, 10, str, strlen(str));
-
+
wsprintf(str, "hwndActive == %08X", gti.hwndActive);
TextOut(hDC, 10, 30, str, strlen(str));
wsprintf(str, "hwndFocus == %08X", gti.hwndFocus);
TextOut(hDC, 10, 130, str, strlen(str));
wsprintf(str, "rcCaret == (%lu, %lu, %lu, %lu)", gti.rcCaret.left, gti.rcCaret.top, gti.rcCaret.right, gti.rcCaret.bottom);
TextOut(hDC, 10, 150, str, strlen(str));
-
+
wsprintf(str, "GetGuiResources for the current process: %08X", GetCurrentProcess());
TextOut(hDC, 10, 180, str, strlen(str));
wsprintf(str, "GetGuiResources: GR_GDIOBJECTS == %04X", GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS));
TextOut(hDC, 10, 220, str, strlen(str));
EndPaint(hWnd, &ps);
break;
-
+
case WM_TIMER:
GetGUIThreadInfo(0, >i);
InvalidateRect(hWnd, NULL, TRUE);
#include <string.h>
int main(int argc, char* argv[])
-{
+{
printf("Hello world\n");
return(0);
}
void test1(void)
{
HKEY hKey = NULL, hKey1;
- OBJECT_ATTRIBUTES ObjectAttributes;
- NTSTATUS Status;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ NTSTATUS Status;
#if 0
UNICODE_STRING KeyName = ROS_STRING_INITIALIZER(L"\\Registry");
#endif
void test3(void)
{
HKEY hKey;
- OBJECT_ATTRIBUTES ObjectAttributes;
+ OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
- NTSTATUS Status;
+ NTSTATUS Status;
char Buffer[10];
DWORD Result;
dprintf("NtCreateKey non volatile: \n");
L"System\\Setup",
0,
KEY_ALL_ACCESS,
- &hKey1);
+ &hKey1);
dprintf("\t\tdwError =%x\n",dwError);
if (dwError == ERROR_SUCCESS)
{
L"System\\ControlSet001\\Services\\Serial",
0,
KEY_ALL_ACCESS,
- &hKey);
+ &hKey);
dprintf ("\t\t\t\t\tdwError %x\n", dwError);
RegDataSize = sizeof(GlobalFifoEnable);
if (dwError == ERROR_SUCCESS)
HKEY hKey;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
- NTSTATUS Status;
+ NTSTATUS Status;
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
ULONG Length,i;
HKEY hKey;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
- NTSTATUS Status;
+ NTSTATUS Status;
dprintf("Open link key\n");
dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
UNICODE_STRING KeyName;
NTSTATUS Status;
LONG dwError;
- TOKEN_PRIVILEGES NewPrivileges;
+ TOKEN_PRIVILEGES NewPrivileges;
HANDLE Token,hKey;
- LUID Luid;
+ LUID Luid;
BOOLEAN bRes;
Status=NtOpenProcessToken(GetCurrentProcess()
,TOKEN_ADJUST_PRIVILEGES,&Token);
dprintf("\t\t\t\tStatus =%x\n",Status);
// bRes=LookupPrivilegeValueA(NULL,SE_RESTORE_NAME,&Luid);
// dprintf("\t\t\t\tbRes =%x\n",bRes);
- NewPrivileges.PrivilegeCount = 1;
- NewPrivileges.Privileges[0].Luid = Luid;
+ NewPrivileges.PrivilegeCount = 1;
+ NewPrivileges.Privileges[0].Luid = Luid;
// NewPrivileges.Privileges[0].Luid.u.LowPart=18;
// NewPrivileges.Privileges[0].Luid.u.HighPart=0;
- NewPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
-
-// Status = NtAdjustPrivilegesToken(
- bRes = AdjustTokenPrivileges(
- Token,
- FALSE,
- &NewPrivileges,
- 0,
- NULL,
- NULL
- );
+ NewPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+// Status = NtAdjustPrivilegesToken(
+ bRes = AdjustTokenPrivileges(
+ Token,
+ FALSE,
+ &NewPrivileges,
+ 0,
+ NULL,
+ NULL
+ );
dprintf("\t\t\t\tbRes =%x\n",bRes);
-
-// Status=NtClose(Token);
+
+// Status=NtClose(Token);
// dprintf("\t\t\t\tStatus =%x\n",Status);
void test9(void)
{
HKEY hKey = NULL, hKey1;
- OBJECT_ATTRIBUTES ObjectAttributes;
- NTSTATUS Status;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ NTSTATUS Status;
UNICODE_STRING KeyName = ROS_STRING_INITIALIZER(L"\\Registry");
ULONG Index,Length,i;
KEY_BASIC_INFORMATION KeyInformation[5];
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
HWND hWnd;
hInst = hInstance;
-
+
#ifdef _GetCursorInfo
GetCursorInfo = (GETCURSORINFO)GetProcAddress(GetModuleHandleW(L"user32.dll"), "GetCursorInfo");
#endif
DbgPrint("CreateWindow failed (last error 0x%X)\n", GetLastError());
return(1);
}
-
+
tf = CreateFontA(14,0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
ShowWindow(hWnd, nCmdShow);
-
+
SetTimer(hWnd, 1, 1000, NULL);
while(GetMessage(&msg, NULL, 0, 0))
BITMAP bmp;
RECT rc;
CHAR str[20];
-
+
switch(msg)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
SelectObject(hDC, tf);
SetBkMode(hDC, TRANSPARENT);
-
+
TextOut(hDC, 160, 10, file, strlen(file));
TextOut(hDC, 15, 85, titleDrwIco, strlen(titleDrwIco));
TextOut(hDC, 160, 85, titleMask, strlen(titleMask));
TextOut(hDC, 300, 85, titleXor, strlen(titleXor));
-
+
hIcon = LoadImage(NULL, "icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE|LR_LOADFROMFILE);
DrawIcon(hDC,50,50,hIcon);
DeleteObject(iconinfo.hbmMask);
DeleteObject(iconinfo.hbmColor);
-
+
TextOut(hDC, 145, 150, res, strlen(res));
TextOut(hDC, 15, 225, titleDrwIco, strlen(titleDrwIco));
TextOut(hDC, 160, 225, titleMask, strlen(titleMask));
TextOut(hDC, 300, 225, titleXor, strlen(titleXor));
-
- hIcon = LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
+
+ hIcon = LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
DrawIcon(hDC,50,190,hIcon);
-
+
GetIconInfo(hIcon, &iconinfo);
- DestroyIcon(hIcon);
-
+ DestroyIcon(hIcon);
+
SelectObject(hMemDC, iconinfo.hbmMask);
BitBlt(hDC, 200, 190, 32, 32, hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, iconinfo.hbmColor);
DeleteObject(iconinfo.hbmMask);
DeleteObject(iconinfo.hbmColor);
-
+
cursorinfo.cbSize = sizeof(CURSORINFO);
if(GetCursorInfo(&cursorinfo))
{
DrawIcon(hDC, 50, 330, cursorinfo.hCursor);
GetIconInfo(cursorinfo.hCursor, &iconinfo);
TextOut(hDC, 15, 365, titleDrwIco, strlen(titleDrwIco));
-
+
sprintf(str, "Hotspot: %ld; %ld", iconinfo.xHotspot, iconinfo.yHotspot);
TextOut(hDC, 15, 380, str, strlen(str));
-
+
if(iconinfo.hbmMask)
{
GetObjectW(iconinfo.hbmMask, sizeof(BITMAP), &bmp);
BitBlt(hDC, 200, 330, bmp.bmWidth, bmp.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteObject(iconinfo.hbmMask);
TextOut(hDC, 160, 365 - 32 + bmp.bmHeight, cursormask, strlen(cursormask));
-
+
sprintf(str, "%dBPP", bmp.bmBitsPixel);
TextOut(hDC, 160, 380 - 32 + bmp.bmHeight, str, strlen(str));
}
-
+
if(iconinfo.hbmColor)
{
GetObjectW(iconinfo.hbmColor, sizeof(BITMAP), &bmp);
BitBlt(hDC, 350, 330, bmp.bmWidth, bmp.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteObject(iconinfo.hbmColor);
TextOut(hDC, 300, 365 - 32 + bmp.bmHeight, cursorcolor, strlen(cursorcolor));
-
+
sprintf(str, "%dBPP", bmp.bmBitsPixel);
TextOut(hDC, 300, 380 - 32 + bmp.bmHeight, str, strlen(str));
}
}
}
-
+
SelectObject(hMemDC, hOld);
-
- DeleteObject(hMemDC);
+
+ DeleteObject(hMemDC);
EndPaint(hWnd, &ps);
break;
-
+
case WM_TIMER:
rc.left = 0;
rc.top = 330;
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
const TCHAR* CLASS_NAME = _T("LineTestClass");
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
HDC hDC;
RECT clr;
HBRUSH hbr;
-
+
switch(msg)
{
case WM_PAINT:
DrawLines(hDC);
EndPaint(hWnd, &ps);
break;
-
+
case WM_DESTROY:
PostQuitMessage(0);
break;
-
+
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
-/* $Id: conport.c,v 1.1 2004/10/21 04:58:59 sedwards Exp $
+/* $Id$
*
* reactos/apps/lpc/conport.c
*
* "\SmApiPort" as argument. Do not try to
* connect to "\Windows\ApiPort" since that
* reboots immeditely.
- *
+ *
* Use Russinovich' HandleEx to verify
* conport.exe owns two unnamed LPC ports:
* the one created by kernel32.dll connecting
IN ULONG Length,
OUT PULONG ResultLength
);
-
+
NTSTATUS
(STDCALL * YieldExecution)(VOID);
-/* $Id: creport.c,v 1.1 2004/10/21 04:58:59 sedwards Exp $
+/* $Id$
*
* reactos/apps/lpc/creport.c
*
* To be run in a real WNT 4.0 system to
* create an LPC named port.
- *
+ *
* Use Russinovich' HandleEx to verify
* creport.exe owns the named LPC port
* you asked to create.
(STDCALL * CreatePort)(
/*OUT PHANDLE PortHandle,*/
PVOID Buffer,
- IN POBJECT_ATTRIBUTES PortAttributes OPTIONAL,
+ IN POBJECT_ATTRIBUTES PortAttributes OPTIONAL,
IN ACCESS_MASK DesiredAccess,
IN DWORD Unknown3,
IN ULONG Flags
IN ULONG Length,
OUT PULONG ResultLength
);
-
+
NTSTATUS
(STDCALL * YieldExecution)(VOID);
-/* $Id: dumpinfo.c,v 1.1 2004/10/21 04:58:59 sedwards Exp $
+/* $Id$
*
* reactos/apps/lpc/dumpinfo.c
*
* Added code to find the basic information buffer size
* for the LPC port object.
* 19990710 (EA)
- *
+ *
*/
#include <windows.h>
#include <stdio.h>
{
BYTE ObjectInformation [BUF_SIZE] = {0};
ULONG ResultLength;
-
+
wprintf(
L"Port \"%s\" %s:\n",
Name,
PLPC_PORT_BASIC_INFORMATION i;
i = (PLPC_PORT_BASIC_INFORMATION) ObjectInformation;
-
+
printf( "\tUnknown01 = 0x%08X\n", i->Unknown0 );
printf( "\tUnknown02 = 0x%08X\n", i->Unknown1 );
printf( "\tUnknown03 = 0x%08X\n", i->Unknown2 );
OBJECT_TYPE_INFORMATION * i;
i = (OBJECT_TYPE_INFORMATION *) ObjectInformation;
-
+
wprintf(
L"\tName: \"%s\"\n",
(i->Name.Length ? i->Name.Buffer : L"")
-/* $Id: lpcclt.c,v 1.1 2004/10/21 04:58:59 sedwards Exp $
+/* $Id$
*
* DESCRIPTION: Simple LPC Client
* PROGRAMMER: David Welch
ULONG ConnectInfo;
ULONG ConnectInfoLength = 0;
SECURITY_QUALITY_OF_SERVICE Sqos;
-
+
printf("%s: Lpc test client\n", MyName);
-
+
printf("%s: Connecting to port \"%s\"...\n", MyName, TEST_PORT_NAME);
ConnectInfoLength = 0;
ZeroMemory (& Sqos, sizeof Sqos);
ZeroMemory(& Request, sizeof Request);
strcpy(Request.Data, GetCommandLineA());
Request.Header.DataSize = strlen(Request.Data);
- Request.Header.MessageSize = sizeof(LPC_MESSAGE) +
+ Request.Header.MessageSize = sizeof(LPC_MESSAGE) +
Request.Header.DataSize;
-
- printf("%s: Sending to port 0x%x message \"%s\"...\n",
+
+ printf("%s: Sending to port 0x%x message \"%s\"...\n",
MyName,
PortHandle,
(char *) Request.Data);
- Status = NtRequestPort(PortHandle,
+ Status = NtRequestPort(PortHandle,
&Request.Header);
if (!NT_SUCCESS(Status))
{
- printf("%s: NtRequestPort(0x%x) failed with status = 0x%8X.\n",
+ printf("%s: NtRequestPort(0x%x) failed with status = 0x%8X.\n",
MyName,
PortHandle,
Status);
return EXIT_FAILURE;
}
-
+
printf("%s: Sending datagram to port 0x%x succeeded.\n", MyName, PortHandle);
Sleep(2000);
-/* $Id: lpcsrv.c,v 1.1 2004/10/21 04:58:59 sedwards Exp $
+/* $Id$
*
* DESCRIPTION: Simple LPC Server
* PROGRAMMER: David Welch
HANDLE NamedPortHandle;
HANDLE PortHandle;
LPC_MAX_MESSAGE ConnectMsg;
-
+
printf("%s: Lpc test server\n", MyName);
InitializeObjectAttributes(&ObjectAttributes,
0,
NULL,
NULL);
-
+
printf("%s: Creating port \"%s\"...\n", MyName, TEST_PORT_NAME);
Status = NtCreatePort(&NamedPortHandle,
&ObjectAttributes,
return EXIT_FAILURE;
}
printf("%s: Port \"%s\" created (0x%x).\n\n", MyName, TEST_PORT_NAME, NamedPortHandle);
-
+
for (;;)
- {
+ {
printf("%s: Listening for connections requests on port 0x%x...\n", MyName, NamedPortHandle);
Status = NtListenPort(NamedPortHandle,
&ConnectMsg.Header);
ConnectMsg.Header.MessageId, NamedPortHandle);
printf("%s: Request from: PID=%x, TID=%x.\n", MyName,
ConnectMsg.Header.ClientId.UniqueProcess, ConnectMsg.Header.ClientId.UniqueThread);
-
- printf("%s: Accepting connection request 0x%08x...\n", MyName,
+
+ printf("%s: Accepting connection request 0x%08x...\n", MyName,
ConnectMsg.Header.MessageId);
Status = NtAcceptConnectPort(&PortHandle,
NamedPortHandle,
{
printf("%s: NtAcceptConnectPort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
- }
- printf("%s: Connection request 0x%08x accepted as port 0x%x.\n", MyName,
+ }
+ printf("%s: Connection request 0x%08x accepted as port 0x%x.\n", MyName,
ConnectMsg.Header.MessageId, PortHandle);
-
- printf("%s: Completing connection for port 0x%x (0x%08x).\n", MyName,
+
+ printf("%s: Completing connection for port 0x%x (0x%08x).\n", MyName,
PortHandle, ConnectMsg.Header.MessageId);
Status = NtCompleteConnectPort(PortHandle);
if (!NT_SUCCESS(Status))
printf("%s: NtCompleteConnectPort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
-
- printf("%s: Entering server loop for port 0x%x...\n", MyName, PortHandle);
+
+ printf("%s: Entering server loop for port 0x%x...\n", MyName, PortHandle);
for(;;)
{
LPC_MAX_MESSAGE Request;
-
+
Status = NtReplyWaitReceivePort(PortHandle,
0,
NULL,
if (LPC_DATAGRAM == PORT_MESSAGE_TYPE(Request))
{
printf("%s: Datagram message contents are <%s>.\n",
- MyName,
+ MyName,
Request.Data);
}
else
if( argc == 2 ) {
file_map = (void *)atoi(argv[1]);
} else {
- file_map = CreateFileMapping( INVALID_HANDLE_VALUE,
- NULL,
- PAGE_READWRITE | SEC_RESERVE,
+ file_map = CreateFileMapping( INVALID_HANDLE_VALUE,
+ NULL,
+ PAGE_READWRITE | SEC_RESERVE,
0, 0x1000, NULL );
- if( !SetHandleInformation( file_map,
- HANDLE_FLAG_INHERIT,
+ if( !SetHandleInformation( file_map,
+ HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT ) ) {
fprintf( stderr, "%lu: Could not make handle inheritable.\n",
GetCurrentProcessId() );
return 100;
}
}
-
+
if( !file_map ) {
fprintf( stderr, "%lu: Could not create anonymous file map.\n",
GetCurrentProcessId() );
return 1;
}
-
+
file_view = MapViewOfFile( file_map,
FILE_MAP_WRITE,
0,
0,
0x1000 );
-
+
if( !file_view ) {
fprintf( stderr, "%lu: Could not map view of file.\n",
GetCurrentProcessId() );
return 2;
}
-
+
if( !VirtualAlloc( file_view, 0x1000, MEM_COMMIT, PAGE_READWRITE ) ) {
fprintf( stderr, "%lu: VirtualAlloc failed to realize the page.\n",
GetCurrentProcessId() );
return 3;
}
-
+
x = (int *)file_view;
x[0] = 0x12345678;
-
+
if( x[0] != 0x12345678 ) {
fprintf( stderr, "%lu: Can't write to the memory (%08x != 0x12345678)\n",
GetCurrentProcessId(), x[0] );
// Send the TB_BUTTONSTRUCTSIZE message, which is required for
// backward compatibility.
SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
-
+
tbab.hInst = HINST_COMMCTRL;
tbab.nID = IDB_STD_SMALL_COLOR;
SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);
HWND hChild = CreateNewMDIChild(g_hMDIClient);
if(hChild)
{
- DoFileOpen(hChild);
+ DoFileOpen(hChild);
}
}
break;
{
DefFrameProc(hwnd, g_hMDIClient, WM_COMMAND, wParam, lParam);
}
- else
+ else
{
HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0);
if(hChild)
// Create Edit Control
- hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
- WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
+ hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
+ WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_EDIT, GetModuleHandle(NULL), NULL);
if(hEdit == NULL)
MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);
return DefMDIChildProc(hwnd, msg, wParam, lParam);
default:
return DefMDIChildProc(hwnd, msg, wParam, lParam);
-
+
}
return 0;
}
#define ID_EDIT_PASTE 40017
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
WORD wVersionRequested;
WSADATA wsaData;
int err;
-
+
/*
* Initialization.
*/
-
+
wVersionRequested = MAKEWORD( 2, 2 );
-
+
DBG("Calling WSAStartup\n");
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
DBG("WSAStartup failed\n");
return 1;
}
-
+
/* Confirm that the WinSock DLL supports 2.2.*/
/* Note that if the DLL supports versions greater */
/* than 2.2 in addition to 2.2, it will still return */
/* 2.2 in wVersion since that is the version we */
/* requested. */
-
+
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
DBG("WSAStartup version unacceptable\n");
WSACleanup( );
- return 1;
+ return 1;
}
-
+
/* The WinSock DLL is acceptable. Proceed. */
DBG("Calling socket\n");
DBG("socket failed\n");
goto failed;
}
-
+
selfAddr.sin_family = AF_INET;
selfAddr.sin_port = 0;
selfAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* BugZilla: 35408 */
LPSTR lpszMailslotName = "\\\\.\\MAILSLOT\\mymailslot";
LPSTR lpszTestMessage = "Mailslot test message!";
DWORD cbLength, cbWritten;
-
+
hMailslot = CreateFile(lpszMailslotName,
GENERIC_WRITE,
FILE_SHARE_READ,
printf("CreateFile() failed\n");
return 0;
}
-
+
cbLength = (ULONG)strlen(lpszTestMessage)+1;
-
+
WriteFile(hMailslot,
lpszTestMessage,
cbLength,
&cbWritten,
NULL);
-
+
CloseHandle(hMailslot);
-
+
return 0;
}
MSG msg;
char caption[64];
PTHRDCREATEWIN cw = (PTHRDCREATEWIN)lpParameter;
-
+
sprintf(caption, cw->Caption, GetCurrentThreadId());
-
+
cw->Window = CreateWindow("MultiClass",
caption,
cw->Style | WS_VISIBLE,
NULL,
hAppInstance,
NULL);
-
+
SetEvent(WinCreatedEvent);
-
+
if(!cw->Window)
{
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
TranslateMessage(&msg);
DispatchMessage(&msg);
}
-
+
return 0;
}
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
WNDCLASS wc;
int i;
HANDLE Threads[3];
-
+
hAppInstance = hInstance;
-
+
WinCreatedEvent = CreateEvent(NULL,
FALSE,
FALSE,
NULL);
-
+
if(!WinCreatedEvent)
{
fprintf(stderr, "Failed to create event (last error 0x%lX)\n",
wnds[0].Position.x = wnds[0].Position.y = 0;
wnds[0].Size.cx = 320;
wnds[0].Size.cy = 240;
-
+
wnds[1].Caption = "Child1 of TopLevel1 (ThreadID: %d)";
wnds[1].Parent = &wnds[0].Window;
wnds[1].Style = WS_CHILD | WS_BORDER | WS_CAPTION | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
wnds[1].Position.x = 20;
wnds[1].Position.y = 120;
wnds[1].Size.cx = wnds[1].Size.cy = 240;
-
+
wnds[2].Caption = "TopLevel2 (ThreadID: %d)";
wnds[2].Parent = NULL;
wnds[2].Style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
wnds[2].Position.y = 0;
wnds[2].Size.cx = 160;
wnds[2].Size.cy = 490;
-
+
for(i = 0; i < (sizeof(wnds) / sizeof(THRDCREATEWIN)); i++)
{
wnds[i].hThread = CreateThread(NULL,
}
WaitForSingleObject(WinCreatedEvent, INFINITE);
}
-
+
WaitForMultipleObjects(sizeof(Threads) / sizeof(HANDLE), &Threads[0], TRUE, INFINITE);
-
+
UnregisterClass("MultiClass", hInstance);
-
+
return 0;
}
RECT Client;
HBRUSH Brush;
DWORD Ret;
-
+
static COLORREF Colors[] =
{
RGB(0x00, 0x00, 0x00),
}
EndPaint(hWnd, &ps);
break;
-
+
case WM_COMMAND:
switch(LOWORD(wParam))
{
break;
}
break;
-
+
case WM_DESTROY:
PostQuitMessage(0);
break;
static UINT WindowCount;
LRESULT WINAPI MultiWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
GetNetworkParams(pFixedInfo,&OutBufLen);
- for( Addr = &pFixedInfo->DnsServerList;
+ for( Addr = &pFixedInfo->DnsServerList;
Addr;
Addr = Addr->Next ) {
- printf( "%c%s\n",
+ printf( "%c%s\n",
Addr == pFixedInfo->CurrentDnsServer ? '*' : ' ',
Addr->IpAddress.String );
}
/*
- * $Id: noexecute.c,v 1.1 2004/10/21 04:59:00 sedwards Exp $
+ * $Id$
*/
#include <stdio.h>
DWORD cbBytesRead, cbReplyBytes, cbWritten;
BOOL fSuccess;
HANDLE hPipe;
-
+
hPipe = (HANDLE)lpvParam;
while (1)
{
hDC = GetDC(ActiveWindow);
GetClientRect(ActiveWindow,&dest);
-
+
Context = CreateCompatibleDC(0);
dflBmp = SelectObject(Context, hBM);
BitBlt(hDC, 0, 0, dest.right, dest.bottom, Context, 0, 0, SRCCOPY);
else
c++; // It's operation of incrementing of c variable, not reference of a cool OO language :-)
}
-
+
DoBlt(hBM);
}
// Create palette
PalHan = CreatePalette((LOGPALETTE*)&palInf);
-
+
// Select it into hDC
SelectPalette(hDC,PalHan,FALSE);
-
+
// Realize palette in hDC
RealizePalette(hDC);
-
+
// Delete handle to palette
DeleteObject(PalHan);
ShowWindow(hWnd,nCmdShow);
// Prepare bitmap to be bitblt
- InitBitmap(&hBM);
+ InitBitmap(&hBM);
// Main message loop
while (!exit)
{
UpdatePalette(hBM);
Sleep(200);
-
+
if(PeekMessage(&msg,0,0,0,PM_NOREMOVE) == TRUE)
{
if (!GetMessage(&msg,0,0,0))
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
{
POINT pos;
HMENU Menu;
-
+
pos.x = LOWORD(lParam);
pos.y = HIWORD(lParam);
ClientToScreen(hWnd, &pos);
-
+
if((Menu = GetMenu(hWnd)) && (Menu = GetSubMenu(Menu, 1)))
{
TrackPopupMenu(Menu, 0, pos.x, pos.y, 0, hWnd, NULL);
// Created by Damon Chandler <dmc27@ee.cornell.edu>
// Updates can be downloaded at: <www.coriolis.com>
//
-// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
+// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
// if you have any questions about this code.
// ------------------------------------------------------------------
static const ULONG FS_STRIKEOUT = 0x00000008;
// creates a logical font
-HFONT MakeFont(IN HDC hDestDC, IN LPCSTR typeface_name,
- IN int point_size, IN const BYTE charset = ANSI_CHARSET,
+HFONT MakeFont(IN HDC hDestDC, IN LPCSTR typeface_name,
+ IN int point_size, IN const BYTE charset = ANSI_CHARSET,
IN const DWORD style = FS_NONE);
}
{
int x;
PTEB Teb;
-
+
printf("TEB dumpper\n");
__asm__("movl %%fs:0x18, %0\n\t"
: "=a" (x)
-/* $Id: regcmds.c,v 1.1 2004/10/21 04:59:00 sedwards Exp $
+/* $Id$
*
* ReactOS regedit
*
-/* $Id: regdump.c,v 1.1 2004/10/21 04:59:00 sedwards Exp $
+/* $Id$
*
* ReactOS regedit
*
#include <process.h>
#include <stdio.h>
#include <wchar.h>
-
+
#include <ctype.h>
#include <limits.h>
#include <winnt.h>
#endif
#ifdef UNICODE
-#define _TEOF WEOF
+#define _TEOF WEOF
#else
-#define _TEOF EOF
+#define _TEOF EOF
#endif
/******************************************************************************
printf( "Returns an HKEY_LOCAL_MACHINE value from the given key.\n" );
return 1;
}
-
- if ( RegOpenKeyExA( HKEY_LOCAL_MACHINE, argv[1], 0, KEY_READ, &RegKey )
+
+ if ( RegOpenKeyExA( HKEY_LOCAL_MACHINE, argv[1], 0, KEY_READ, &RegKey )
!= 0 ) {
printf( "Could not open key %s\n", argv[1] );
return 2;
printf( "The value %S does not exist.\n", ValueNameWC );
return 5;
}
-
+
WcharResult = malloc( (ResultSize + 1) * sizeof(WCHAR) );
-
+
if( !WcharResult ) {
printf( "Could not alloc %d wchars\n", (int)(ResultSize + 1) );
return 6;
}
- RegQueryValueExW( RegKey, ValueNameWC, NULL, NULL, (LPBYTE)WcharResult,
+ RegQueryValueExW( RegKey, ValueNameWC, NULL, NULL, (LPBYTE)WcharResult,
&ResultSize );
-
+
printf( "wchar Value: %S\n", WcharResult );
fflush( stdout );
}
RegQueryValueExA( RegKey, argv[2], NULL, NULL, CharResult, &ResultSize );
-
+
printf( " char Value: %s\n", CharResult );
fflush( stdout );
void test1(void)
{
HKEY hKey = NULL, hKey1;
- OBJECT_ATTRIBUTES ObjectAttributes;
- NTSTATUS Status;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ NTSTATUS Status;
UNICODE_STRING KeyName = ROS_STRING_INITIALIZER(L"\\Registry");
ULONG Index,Length,i;
KEY_BASIC_INFORMATION KeyInformation[5];
void test2(void)
{
HKEY hKey,hKey1;
- OBJECT_ATTRIBUTES ObjectAttributes;
+ OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
- NTSTATUS Status;
+ NTSTATUS Status;
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
ULONG Index,Length,i;
char Buffer[10];
void test3(void)
{
HKEY hKey,hKey1;
- OBJECT_ATTRIBUTES ObjectAttributes;
+ OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
- NTSTATUS Status;
+ NTSTATUS Status;
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
ULONG Index,Length,i;
char Buffer[10];
L"System\\Setup",
0,
KEY_ALL_ACCESS,
- &hKey1);
+ &hKey1);
dprintf("\t\tdwError =%x\n",dwError);
if (dwError == ERROR_SUCCESS)
{
L"System\\ControlSet001\\Services\\Serial",
0,
KEY_ALL_ACCESS,
- &hKey);
+ &hKey);
dprintf ("\t\t\t\t\tdwError %x\n", dwError);
RegDataSize = sizeof(GlobalFifoEnable);
if (dwError == ERROR_SUCCESS)
HKEY hKey;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
- NTSTATUS Status;
+ NTSTATUS Status;
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
ULONG Length,i;
HKEY hKey;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
- NTSTATUS Status;
+ NTSTATUS Status;
dprintf("Open link key\n");
dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
UNICODE_STRING KeyName;
NTSTATUS Status;
LONG dwError;
- TOKEN_PRIVILEGES NewPrivileges;
+ TOKEN_PRIVILEGES NewPrivileges;
HANDLE Token,hKey;
- LUID Luid;
+ LUID Luid;
BOOLEAN bRes;
Status=NtOpenProcessToken(GetCurrentProcess()
,TOKEN_ADJUST_PRIVILEGES,&Token);
dprintf("\t\t\t\tStatus =%x\n",Status);
// bRes=LookupPrivilegeValueA(NULL,SE_RESTORE_NAME,&Luid);
// dprintf("\t\t\t\tbRes =%x\n",bRes);
- NewPrivileges.PrivilegeCount = 1;
- NewPrivileges.Privileges[0].Luid = Luid;
+ NewPrivileges.PrivilegeCount = 1;
+ NewPrivileges.Privileges[0].Luid = Luid;
// NewPrivileges.Privileges[0].Luid.u.LowPart=18;
// NewPrivileges.Privileges[0].Luid.u.HighPart=0;
- NewPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
-
-// Status = NtAdjustPrivilegesToken(
- bRes = AdjustTokenPrivileges(
- Token,
- FALSE,
- &NewPrivileges,
- 0,
- NULL,
- NULL
- );
+ NewPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+// Status = NtAdjustPrivilegesToken(
+ bRes = AdjustTokenPrivileges(
+ Token,
+ FALSE,
+ &NewPrivileges,
+ 0,
+ NULL,
+ NULL
+ );
dprintf("\t\t\t\tbRes =%x\n",bRes);
-
-// Status=NtClose(Token);
+
+// Status=NtClose(Token);
// dprintf("\t\t\t\tStatus =%x\n",Status);
void test9(void)
{
HKEY hKey = NULL, hKey1;
- OBJECT_ATTRIBUTES ObjectAttributes;
- NTSTATUS Status;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ NTSTATUS Status;
UNICODE_STRING KeyName = ROS_STRING_INITIALIZER(L"\\Registry");
ULONG Index,Length,i;
KEY_BASIC_INFORMATION KeyInformation[5];
-/* $Id: sectest.c,v 1.1 2004/10/21 04:53:21 sedwards Exp $ */
+/* $Id$ */
#define UNICODE
#define _UNICODE
#include <windows.h>
HANDLE hFile;
HANDLE Section;
PVOID BaseAddress;
-
+
printf("Section Test\n");
-
+
hFile = CreateFile(_T("sectest.txt"),
- GENERIC_READ | GENERIC_WRITE,
- 0,
- NULL,
- CREATE_ALWAYS,
- 0,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ 0,
0);
if (hFile == INVALID_HANDLE_VALUE)
{
printf("Failed to create file (err=%ld)", GetLastError());
return 1;
}
-
+
Section = CreateFileMapping(hFile,
NULL,
- PAGE_READWRITE,
+ PAGE_READWRITE,
0,
4096,
NULL);
printf("Failed to create section (err=%ld)", GetLastError());
return 1;
}
-
+
printf("Mapping view of section\n");
BaseAddress = MapViewOfFile(Section,
FILE_MAP_ALL_ACCESS,
printf("Failed to map section (%ld)\n", GetLastError());
return 1;
}
-
+
printf("Clearing section\n");
FillMemory(BaseAddress, 4096, ' ');
printf("Copying test data to section\n");
strcpy(BaseAddress, "test data");
-
+
if (!UnmapViewOfFile(BaseAddress))
- {
+ {
printf("Failed to unmap view of file (%ld)\n", GetLastError());
return 1;
}
-
+
if (!CloseHandle(hFile))
- {
+ {
printf("Failed to close file (%ld)\n", GetLastError());
return 1;
}
-
+
return 0;
}
}
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
switch(msg)
{
-
+
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
shaptest( hDC );
HANDLE Section;
PVOID BaseAddress;
char buffer[256];
-
+
printf("Shm test server\n");
-
+
Section = OpenFileMappingW (
// PAGE_EXECUTE_READWRITE, invalid parameter
FILE_MAP_WRITE,
printf("Failed to open section (err=%d)", GetLastError());
return 1;
}
-
+
BaseAddress = MapViewOfFile(Section,
FILE_MAP_ALL_ACCESS,
0,
printf("Copying from section\n");
strcpy(buffer, BaseAddress);
printf("Copyed <%s>\n", buffer);
-
+
// for(;;);
return 0;
}
-/* $Id: shmsrv.c,v 1.1 2004/10/21 04:59:01 sedwards Exp $
+/* $Id$
*
* FILE : reactos/apps/shm/shmsrv.c
* AUTHOR: David Welch
{
HANDLE Section;
PVOID BaseAddress;
-
+
printf("Shm test server\n");
-
+
Section = CreateFileMappingW (
(HANDLE) 0xFFFFFFFF,
NULL,
- PAGE_READWRITE,
+ PAGE_READWRITE,
0,
8192,
L"TestSection"
printf("Failed to create section (err=%d)", GetLastError());
return 1;
}
-
+
printf("Mapping view of section\n");
BaseAddress = MapViewOfFile(Section,
FILE_MAP_ALL_ACCESS,
{
printf("Failed to map section\n");
}
-
+
printf("Copying to section\n");
printf("Copying %s\n", GetCommandLineA());
strcpy(BaseAddress, GetCommandLineA());
-
+
Sleep(INFINITE);
return 0;
static WNDPROC SavedWndProcW;
static WNDPROC SavedWndProcA;
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
-/* tcpServer.c
+/* tcpServer.c
*
* Simple Winsock TCP server test.
- * Later will be used as base for ReactOS telnetd
- *
- * HISTORY:
+ * Later will be used as base for ReactOS telnetd
+ *
+ * HISTORY:
* 6-15-02 - Added Winsock support to UNIX tcp test
* 6-16-02 - Removed Unix support
* 6-17-02 - Added extra comments to code
int read_line();
int main (int argc, char *argv[]) {
-
+
WORD wVersionRequested;
WSADATA WsaData;
INT Status;
int sd, newSd, cliLen;
struct sockaddr_in cliAddr, servAddr;
- char line[MAX_MSG];
+ char line[MAX_MSG];
wVersionRequested = MAKEWORD(2, 2);
-
+
Status = WSAStartup(wVersionRequested, &WsaData);
if (Status != 0) {
- printf("Could not initialize winsock dll.\n");
+ printf("Could not initialize winsock dll.\n");
return FALSE;
}
WSACleanup();
return ERROR;
}
-
+
/* bind server port */
servAddr.sin_family = AF_INET;
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
servAddr.sin_port = htons(SERVER_PORT);
-
+
if(bind(sd, (struct sockaddr *) &servAddr, sizeof(servAddr))<0) {
perror("cannot bind port ");
WSACleanup();
}
listen(sd,5);
-
+
while(1) {
printf("%s: \n"
WSACleanup();
return ERROR;
}
-
+
/* init line */
memset(line,0x0,MAX_MSG);
-
+
/* receive segments */
while(read_line(newSd,line)!=ERROR) {
-
- printf("%s: received from %s:TCP%d : %s\n", argv[0],
+
+ printf("%s: received from %s:TCP%d : %s\n", argv[0],
inet_ntoa(cliAddr.sin_addr),
ntohs(cliAddr.sin_port), line);
/* init line */
memset(line,0x0,MAX_MSG);
-
+
} /* while(read_line) */
-
+
} /* while (1) */
}
/* You can set END_CHAR to whatever means endofline for you. (0x0A is \n)*/
/* read_lin returns the number of bytes returned in line_to_return */
int read_line(int newSd, char *line_to_return) {
-
+
static int rcv_ptr=0;
static char rcv_msg[MAX_MSG];
static int n;
- int offset;
+ int offset;
offset=0;
return ERROR;
}
}
-
+
/* if new data read on socket */
/* OR */
/* if another line is still in buffer */
offset++;
rcv_ptr++;
}
-
+
/* end of line + end of buffer => return line */
- if(rcv_ptr==n-1) {
+ if(rcv_ptr==n-1) {
/* set last byte to END_LINE */
*(line_to_return+offset)=END_LINE;
rcv_ptr=0;
return ++offset;
- }
-
+ }
+
/* end of line but still some data in buffer => return line */
if(rcv_ptr <n-1) {
/* set last byte to END_LINE */
/* wait for more data to arrive on socket */
if(rcv_ptr == n) {
rcv_ptr = 0;
- }
-
+ }
+
} /* while */
}
-
-
+
+
DWORD z = 0;
context.ContextFlags=CONTEXT_CONTROL;
-
+
while (z < 50)
{
z++;
NULL,
0,
&thread_id);
-
+
if(!thread)
{
printf("Error: could not create thread ...\n");
ExitProcess(0);
}
-
+
Sleep(1000);
-
+
printf("T");
if ((z % 5) == 0)
{
printf("S");
SuspendThread(thread);
printf("R");
- ResumeThread(thread);
+ ResumeThread(thread);
TerminateThread(thread, 0);
}
-/* $Id: thread.c,v 1.1 2004/10/21 04:48:45 sedwards Exp $
+/* $Id$
*
*
*
DWORD WINAPI thread_main1(LPVOID param)
{
ULONG s;
-
+
printf("Thread %ld running\n", (DWORD)param);
s = nr = ((nr * 1103515245) + 12345) & 0x7fffffff;
s = s % 10;
// showHelp();
// return 1;
// }
-
+
// nr = atoi(argv[1]);
nr = 500;
printf("Seed %ld\n", nr);
-
+
printf("Creating %d threads...\n",NR_THREADS*2);
for (i=0;i<NR_THREADS;i++)
{
assert( PostThreadMessage( id, WM_QUIT, 0,0 ) );
WaitForSingleObject( hOkToTerminate, INFINITE );
- printf( "Test complete.\n" );
+ printf( "Test complete.\n" );
return 0;
}
{
int i, nTests;
static HANDLE hEvent;
-
+
hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if(hEvent == NULL)
{
_tprintf(_T("Unable to create event!"));
return;
}
-
+
nTests = sizeof(Tests) / sizeof(TEST);
-
+
for(i = 0; i < nTests; i++)
{
Tests[i].id = i + 1;
-
+
if(Tests[i].Routine == NULL)
{
continue;
}
-
+
_tprintf(_T("+++ TEST %d: %s\n"), Tests[i].id, Tests[i].description);
-
+
Tests[i].Routine(&Tests[i], hEvent);
-
+
WaitForSingleObject(hEvent, INFINITE);
-
+
_tprintf(_T("\n\n"));
}
-
+
CloseHandle(hEvent);
}
{
int i, nTests, nsuccess = 0, nfailed = 0;
TCHAR *status;
-
+
nTests = sizeof(Tests) / sizeof(TEST);
-
+
for(i = 0; i < nTests; i++)
{
if(Tests[i].Routine == NULL)
status = _T("FAILED ");
nfailed++;
}
-
+
_tprintf(_T("Test %d: %s %s\n"), i, status, Tests[i].description);
}
-
+
_tprintf(_T("\nTests succeeded: %d, failed: %d\n"), nsuccess, nfailed);
if(nfailed == 0)
{
} Test1;
struct
{
- HANDLE hWaitEvent;
+ HANDLE hWaitEvent;
} Test2;
struct
{
VOID CALLBACK TimerCallback1(PVOID Param, BOOLEAN Fired)
{
PTESTINFO Info = (PTESTINFO)Param;
-
+
_tprintf(_T("[%d]TimerCallback(0x%x, %d) called (%d)\n"), (int)Info->Test->id, (int)Info->hTimer, (int)Fired, --Info->secsleft);
-
+
if(Info->secsleft == 0)
{
BOOL stat;
-
+
_tprintf(_T("[%d]Timout finished, delete timer queue..."), (int)Info->Test->id);
stat = DeleteTimerQueueTimer(NULL, Info->hTimer, NULL);
if(stat)
else
{
int error = GetLastError();
-
+
switch(error)
{
case ERROR_IO_PENDING:
break;
}
}
-
+
/* set the event to continue tests */
SetEvent(Info->hEvent);
}
VOID Test1(PTEST Test, HANDLE hEvent)
{
static TESTINFO Info;
-
+
Info.Test = Test;
Info.hEvent = hEvent;
Info.secsleft = N_TIMEOUT;
-
+
if(!CreateTimerQueueTimer(&Info.hTimer, NULL, TimerCallback1, &Info, 1000, 1000, 0))
{
_tprintf(_T("[%d]CreateTimerQueueTimer() failed, LastError: %d!"), (int)Info.Test->id, (int)GetLastError());
SetEvent(hEvent);
return;
}
-
+
_tprintf(_T("[%d]CreateTimerQueueTimer() created timer 0x%x, countdown (%d sec)...\n"), (int)Info.Test->id, (int)Info.hTimer, (int)Info.secsleft);
}
VOID CALLBACK TimerCallback2(PVOID Param, BOOLEAN Fired)
{
PTESTINFO Info = (PTESTINFO)Param;
-
+
_tprintf(_T("[%d]TimerCallback(0x%x, %d) called (%d)\n"), (int)Info->Test->id, (int)Info->hTimer, (int)Fired, --Info->secsleft);
-
+
if(Info->secsleft == 0)
{
/* set the event to continue tests */
SetEvent(Info->Test2.hWaitEvent);
-
+
/* sleep a bit */
- Sleep(1500);
+ Sleep(1500);
}
}
{
static TESTINFO Info;
BOOL stat;
-
+
Info.Test = Test;
Info.hEvent = hEvent;
Info.secsleft = N_TIMEOUT;
-
+
Info.Test2.hWaitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if(Info.Test2.hWaitEvent == NULL)
{
_tprintf(_T("[%d]Unable to create event!\n"), (int)Info.Test->id);
return;
}
-
+
if(!CreateTimerQueueTimer(&Info.hTimer, NULL, TimerCallback2, &Info, 1000, 1000, 0))
{
_tprintf(_T("[%d]CreateTimerQueueTimer() failed, LastError: %d!"), (int)Info.Test->id, (int)GetLastError());
-
+
CloseHandle(Info.Test2.hWaitEvent);
/* we failed, set the event to continue tests */
SetEvent(hEvent);
return;
}
-
+
_tprintf(_T("[%d]CreateTimerQueueTimer() created timer 0x%x, countdown (%d sec)...\n"), (int)Test->id, (int)Info.hTimer, (int)Info.secsleft);
-
+
WaitForSingleObject(Info.Test2.hWaitEvent, INFINITE);
-
+
_tprintf(_T("[%d]Timout finished, delete timer queue..."), (int)Test->id);
stat = DeleteTimerQueueTimer(NULL, Info.hTimer, INVALID_HANDLE_VALUE);
if(stat)
else
{
int error = GetLastError();
-
+
switch(error)
{
case ERROR_IO_PENDING:
break;
}
}
-
+
SetEvent(Info.hEvent);
}
VOID CALLBACK TimerCallback3(PVOID Param, BOOLEAN Fired)
{
PTESTINFO Info = (PTESTINFO)Param;
-
+
_tprintf(_T("[%d]TimerCallback(0x%x, %d) called (%d)\n"), (int)Info->Test->id, (int)Info->hTimer, (int)Fired, --Info->secsleft);
-
+
if(Info->secsleft == 0)
{
/* set the event to continue tests */
SetEvent(Info->Test3.hWaitEvent);
-
+
/* sleep a bit */
- Sleep(1500);
+ Sleep(1500);
}
}
{
static TESTINFO Info;
BOOL stat;
-
+
Info.Test = Test;
Info.hEvent = hEvent;
Info.secsleft = N_TIMEOUT;
-
+
Info.Test3.hWaitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if(Info.Test3.hWaitEvent == NULL)
{
_tprintf(_T("[%d]Unable to create event!\n"), (int)Info.Test->id);
return;
}
-
+
Info.Test3.hNotification = CreateEvent(NULL, FALSE, FALSE, NULL);
if(Info.Test3.hNotification == NULL)
{
_tprintf(_T("[%d]Unable to create notification event!\n"), (int)Info.Test->id);
return;
}
-
+
if(!CreateTimerQueueTimer(&Info.hTimer, NULL, TimerCallback3, &Info, 1000, 1000, 0))
{
_tprintf(_T("[%d]CreateTimerQueueTimer() failed, LastError: %d!"), (int)Info.Test->id, (int)GetLastError());
-
+
CloseHandle(Info.Test3.hWaitEvent);
CloseHandle(Info.Test3.hNotification);
/* we failed, set the event to continue tests */
SetEvent(hEvent);
return;
}
-
+
_tprintf(_T("[%d]CreateTimerQueueTimer() created timer 0x%x, countdown (%d sec)...\n"), (int)Test->id, (int)Info.hTimer, (int)Info.secsleft);
-
+
WaitForSingleObject(Info.Test3.hWaitEvent, INFINITE);
-
+
_tprintf(_T("[%d]Timout finished, delete timer queue..."), (int)Test->id);
stat = DeleteTimerQueueTimer(NULL, Info.hTimer, Info.Test3.hNotification);
if(stat)
else
{
int error = GetLastError();
-
+
switch(error)
{
case ERROR_IO_PENDING:
break;
}
}
-
+
WaitForSingleObject(Info.Test3.hNotification, INFINITE);
-
+
CloseHandle(Info.Test3.hWaitEvent);
CloseHandle(Info.Test3.hNotification);
-
+
SetEvent(Info.hEvent);
}
InitTests(VOID)
{
ZeroMemory(Tests, sizeof(Tests));
-
+
Tests[0].description = _T("non-blocking DeleteTimerQueueTimer() call from callback");
Tests[0].Routine = Test1;
-
+
Tests[1].description = _T("blocking DeleteTimerQueueTimer() call");
Tests[1].Routine = Test2;
-
+
Tests[2].description = _T("blocking DeleteTimerQueueTimer() call with specified event");
Tests[2].Routine = Test3;
}
int main(int argc, char* argv[])
{
_tprintf(_T("+++ TimerQueue test running +++\n\n"));
-
+
InitTests();
-
- RunTests();
-
+
+ RunTests();
+
_tprintf(_T("\n+++ RESULTS +++\n"));
-
+
PrintTestResults();
-
+
return 0;
}
#define INITIAL_PRIV_ENABLED SE_PRIVILEGE_ENABLED_BY_DEFAULT|SE_PRIVILEGE_ENABLED
#define INITIAL_PRIV_DISABLED 0
-LUID_AND_ATTRIBUTES InitialPrivilegeSet[] =
+LUID_AND_ATTRIBUTES InitialPrivilegeSet[] =
{
{ { 0x00000007, 0x00000000 }, INITIAL_PRIV_ENABLED }, // SeTcbPrivilege
{ { 0x00000002, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeCreateTokenPrivilege
free(p);
return 0;
}
-
+
return p;
}
// Created by Damon Chandler <dmc27@ee.cornell.edu>
// Updates can be downloaded at: <www.coriolis.com>
//
-// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
+// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
// if you have any questions about this code.
// ------------------------------------------------------------------
static const ULONG FS_STRIKEOUT = 0x00000008;
// creates a logical font
-HFONT MakeFont(IN HDC hDestDC, IN LPCSTR typeface_name,
- IN int point_size, IN const BYTE charset = ANSI_CHARSET,
+HFONT MakeFont(IN HDC hDestDC, IN LPCSTR typeface_name,
+ IN int point_size, IN const BYTE charset = ANSI_CHARSET,
IN const DWORD style = FS_NONE);
}
{
PVOID Base;
PVOID Ret;
-
+
Base = VirtualAlloc(NULL,
1048576,
MEM_RESERVE,
{
printf("VirtualAlloc failed 1\n");
}
-
+
Ret = VirtualAlloc(Base + 4096,
4096,
MEM_COMMIT,
{
printf("VirtualAlloc failed 2\n");
}
-
+
Ret = VirtualAlloc(Base + 12288,
4096,
MEM_COMMIT,
{
printf("VirtualAlloc failed 3\n");
}
-
+
Ret = VirtualAlloc(Base + 20480,
4096,
MEM_COMMIT,
{
printf("VirtualAlloc failed 4\n");
}
-
+
Ret = VirtualAlloc(Base + 4096,
28672,
MEM_RESERVE,
BOOLEAN bolWM_CHAR;
BOOLEAN bolWM_KEYDOWN;
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
switch(msg)
{
-
+
case WM_CHAR:
- {
-
+ {
+
hDC = GetDC(hWnd);
TCHAR text[2];
text[0] = (TCHAR)wParam;
text[1] = _T('\0');
-
+
//Write in window
if( bolWM_KEYDOWN )
{
TextOut(hDC, 400, 10, "WM_CHAR:", strlen("WM_CHAR:"));
bolWM_KEYDOWN = 1;
}
- TextOut(hDC, 530, 10, text, strlen(text));
-
+ TextOut(hDC, 530, 10, text, strlen(text));
+
#if 0
// Make a line depending on the typed key
Rect.left = 10;
Rect.right = 610;
Rect.bottom = 85;
FillRect(hDC, &Rect, hbrWhite);
-
+
Rect.left=308;
Rect.right=312;
FillRect(hDC, &Rect, hbrRed);
-
+
Rect.left = 310;
Rect.top = 75;
Rect.right = 310 +text[0]*2;
}
case WM_KEYDOWN:
- {
-
+ {
+
hDC = GetDC(hWnd);
RECT Rect;
TCHAR text[2];
text[0] = (TCHAR)wParam;
text[1] = _T('\0');
-
-
+
+
/* Write in window */
Rect.left = 400;
Rect.top = 50;
}
case WM_KEYUP:
- {
-
+ {
+
hDC = GetDC(hWnd);
RECT Rect;
TCHAR text[2];
text[0] = (TCHAR)wParam;
text[1] = _T('\0');
-
+
/* Write in window */
Rect.left = 400;
Rect.bottom = 70;
FillRect(hDC, &Rect, hbrWhite);
TextOut(hDC, 400, 50, "WM_KEYUP:", strlen("WM_KEYUP:"));
- TextOut(hDC, 530, 50, text, strlen(text));
+ TextOut(hDC, 530, 50, text, strlen(text));
ReleaseDC(hWnd, hDC);
return 0;
}
hDC = GetDC(hWnd);
x = LOWORD(lParam);
y = HIWORD(lParam);
-
+
Rect.left = x - 5;
Rect.top = y - 5;
Rect.right = x + 5;
Rect.bottom = y + 5;
FillRect(hDC, &Rect, hbrRed);
-
+
Rect.left = x - 3;
Rect.top = y - 3;
Rect.right = x + 3;
hDC = GetDC(hWnd);
x = LOWORD(lParam);
y = HIWORD(lParam);
-
+
Rect.left = x - 5;
Rect.top = y - 5;
Rect.right = x + 5;
Rect.bottom = y + 5;
FillRect(hDC, &Rect, hbrRed);
-
+
Rect.left = x - 3;
Rect.top = y - 3;
Rect.right = x + 3;
Rect.bottom = y + 3;
FillRect(hDC, &Rect, hbrGray);
-
+
ReleaseDC(hWnd, hDC);
break;
- }
+ }
case WM_MBUTTONDOWN:
{
ULONG x, y;
hDC = GetDC(hWnd);
x = LOWORD(lParam);
y = HIWORD(lParam);
-
+
Rect.left = x - 5;
Rect.top = y - 5;
Rect.right = x + 5;
Rect.bottom = y + 5;
FillRect(hDC, &Rect, hbrBlue);
-
+
Rect.left = x - 3;
Rect.top = y - 3;
Rect.right = x + 3;
Rect.bottom = y + 3;
FillRect(hDC, &Rect, hbrBlack);
-
+
ReleaseDC(hWnd, hDC);
break;
}
hDC = GetDC(hWnd);
x = LOWORD(lParam);
y = HIWORD(lParam);
-
+
Rect.left = x - 5;
Rect.top = y - 5;
Rect.right = x + 5;
Rect.bottom = y + 5;
FillRect(hDC, &Rect, hbrBlue);
-
+
Rect.left = x - 3;
Rect.top = y - 3;
Rect.right = x + 3;
Rect.bottom = y + 3;
FillRect(hDC, &Rect, hbrGray);
-
- ReleaseDC(hWnd, hDC);
+
+ ReleaseDC(hWnd, hDC);
break;
}
case WM_RBUTTONDOWN:
hDC = GetDC(hWnd);
x = LOWORD(lParam);
y = HIWORD(lParam);
-
+
Rect.left = x - 5;
Rect.top = y - 5;
Rect.right = x + 5;
Rect.bottom = y + 5;
FillRect(hDC, &Rect, hbrYellow);
-
+
Rect.left = x - 3;
Rect.top = y - 3;
Rect.right = x + 3;
Rect.bottom = y + 3;
FillRect(hDC, &Rect, hbrBlack);
-
+
ReleaseDC(hWnd, hDC);
break;
}
hDC = GetDC(hWnd);
x = LOWORD(lParam);
y = HIWORD(lParam);
-
+
Rect.left = x - 5;
Rect.top = y - 5;
Rect.right = x + 5;
Rect.bottom = y + 5;
FillRect(hDC, &Rect, hbrYellow);
-
+
Rect.left = x - 3;
Rect.top = y - 3;
Rect.right = x + 3;
Rect.bottom = y + 3;
FillRect(hDC, &Rect, hbrGray);
-
- ReleaseDC(hWnd, hDC);
+
+ ReleaseDC(hWnd, hDC);
break;
}
-
+
case WM_MOUSEMOVE:
- {
+ {
int fwKeys;
int x;
int y;
TCHAR text[256];
hDC = GetDC(hWnd);
- fwKeys = wParam; // key flags
- x = LOWORD(lParam); // horizontal position of cursor
- y = HIWORD(lParam); // vertical position of cursor
-
+ fwKeys = wParam; // key flags
+ x = LOWORD(lParam); // horizontal position of cursor
+ y = HIWORD(lParam); // vertical position of cursor
+
Rect.left = 10;
Rect.top = 100;
Rect.right = 160;
Rect.bottom = 300;
FillRect(hDC, &Rect, hbrWhite);
-
+
temp = _sntprintf ( text, sizeof(text)/sizeof(*text), _T("x: %d"), x );
TextOut(hDC,10,100,text,strlen(text));
temp = _sntprintf ( text, sizeof(text)/sizeof(*text), _T("y: %d"), y );
Rect.top = y - 2;
Rect.right = x + 2;
Rect.bottom = y + 2;
-
+
switch ( fwKeys )
{
case MK_CONTROL:
- TextOut(hDC,10,140,"Control",strlen("Control"));
+ TextOut(hDC,10,140,"Control",strlen("Control"));
break;
case MK_SHIFT:
- TextOut(hDC,10,160,"Shift",strlen("Shift"));
+ TextOut(hDC,10,160,"Shift",strlen("Shift"));
break;
case MK_LBUTTON:
- TextOut(hDC,10,180,"Left",strlen("Left"));
- FillRect(hDC, &Rect, hbrRed);
+ TextOut(hDC,10,180,"Left",strlen("Left"));
+ FillRect(hDC, &Rect, hbrRed);
break;
case MK_MBUTTON:
- TextOut(hDC,10,200,"Middle",strlen("Middle"));
- FillRect(hDC, &Rect, hbrBlue);
+ TextOut(hDC,10,200,"Middle",strlen("Middle"));
+ FillRect(hDC, &Rect, hbrBlue);
break;
case MK_RBUTTON:
- TextOut(hDC,10,220,"Right",strlen("Right"));
- FillRect(hDC, &Rect, hbrYellow);
+ TextOut(hDC,10,220,"Right",strlen("Right"));
+ FillRect(hDC, &Rect, hbrYellow);
break;
}
ReleaseDC(hWnd, hDC);
break;
}
-
+
case WM_HSCROLL:
{
int nPos;
HWND hwndScrollBar;
TCHAR text[256];
SCROLLINFO Scrollparameter;
- nScrollCode = (int) LOWORD(wParam); // scroll bar value
- nPos = (short int) HIWORD(wParam); // scroll box position
- hwndScrollBar = (HWND) lParam; // handle to scroll bar
+ nScrollCode = (int) LOWORD(wParam); // scroll bar value
+ nPos = (short int) HIWORD(wParam); // scroll box position
+ hwndScrollBar = (HWND) lParam; // handle to scroll bar
hDC = GetDC(hWnd);
-
+
Scrollparameter.cbSize = sizeof(Scrollparameter);
- Scrollparameter.fMask = SIF_ALL;
+ Scrollparameter.fMask = SIF_ALL;
GetScrollInfo ( hWnd, SB_HORZ, &Scrollparameter );
-
+
Rect.left = 200;
Rect.top = 100;
Rect.right = 350;
Rect.bottom = 300;
FillRect(hDC, &Rect, hbrWhite);
-
+
switch ( nScrollCode )
{
- case SB_ENDSCROLL: //Ends scroll.
+ case SB_ENDSCROLL: //Ends scroll.
TextOut(hDC,200,120,"SB_ENDSCROLL ",16);
Scrollparameter.nPos = Scrollparameter.nPos;
break;
- case SB_LEFT: //Scrolls to the upper left.
+ case SB_LEFT: //Scrolls to the upper left.
TextOut(hDC,200,140,"SB_LEFT ",16);
Scrollparameter.nPos = Scrollparameter.nMin;
break;
- case SB_RIGHT: //Scrolls to the lower right.
+ case SB_RIGHT: //Scrolls to the lower right.
TextOut(hDC,200,160,"SB_RIGHT ",16);
Scrollparameter.nPos = Scrollparameter.nMax;
break;
- case SB_LINELEFT: //Scrolls left by one unit.
+ case SB_LINELEFT: //Scrolls left by one unit.
TextOut(hDC,200,180,"SB_LINELEFT ",16);
Scrollparameter.nPos--;
break;
- case SB_LINERIGHT: //Scrolls right by one unit.
+ case SB_LINERIGHT: //Scrolls right by one unit.
TextOut(hDC,200,200,"SB_LINERIGHT ",16);
Scrollparameter.nPos++;
break;
- case SB_PAGELEFT: //Scrolls left by the width of the window.
+ case SB_PAGELEFT: //Scrolls left by the width of the window.
TextOut(hDC,200,220,"SB_PAGELEFT ",16);
Scrollparameter.nPos -= Scrollparameter.nPage;
break;
- case SB_PAGERIGHT: //Scrolls right by the width of the window.
+ case SB_PAGERIGHT: //Scrolls right by the width of the window.
TextOut(hDC,200,240,"PAGERIGHT ",16);
Scrollparameter.nPos += Scrollparameter.nPage;
break;
- case SB_THUMBPOSITION: //The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
+ case SB_THUMBPOSITION: //The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
TextOut(hDC,200,260,"SB_THUMBPOSITION",16);
Scrollparameter.nPos = Scrollparameter.nTrackPos;
break;
Scrollparameter.nPos = Scrollparameter.nTrackPos;
break;
}
-
+
SetScrollInfo(
hWnd, // handle to window with scroll bar
SB_HORZ, // scroll bar flag
ReleaseDC(hWnd, hDC);
return 0;
}
-
+
case WM_VSCROLL:
{
int nPos;
HWND hwndScrollBar;
TCHAR text[256];
SCROLLINFO Scrollparameter;
- nScrollCode = (int) LOWORD(wParam); // scroll bar value
- nPos = (short int) HIWORD(wParam); // scroll box position
- hwndScrollBar = (HWND) lParam; // handle to scroll bar
+ nScrollCode = (int) LOWORD(wParam); // scroll bar value
+ nPos = (short int) HIWORD(wParam); // scroll box position
+ hwndScrollBar = (HWND) lParam; // handle to scroll bar
hDC = GetDC(hWnd);
-
+
Scrollparameter.cbSize = sizeof(Scrollparameter);
- Scrollparameter.fMask = SIF_ALL;
+ Scrollparameter.fMask = SIF_ALL;
GetScrollInfo ( hWnd, SB_VERT, &Scrollparameter );
-
+
Rect.left = 400;
Rect.top = 100;
Rect.right = 550;
Rect.bottom = 300;
FillRect(hDC, &Rect, hbrWhite);
-
+
switch ( nScrollCode )
{
- case SB_ENDSCROLL: //Ends scroll.
+ case SB_ENDSCROLL: //Ends scroll.
TextOut(hDC,400,120,"SB_ENDSCROLL ",16);
Scrollparameter.nPos = Scrollparameter.nPos;
break;
- case SB_LEFT: //Scrolls to the upper left.
+ case SB_LEFT: //Scrolls to the upper left.
TextOut(hDC,400,140,"SB_LEFT ",16);
Scrollparameter.nPos = Scrollparameter.nMin;
break;
- case SB_RIGHT: //Scrolls to the lower right.
+ case SB_RIGHT: //Scrolls to the lower right.
TextOut(hDC,400,160,"SB_RIGHT ",16);
Scrollparameter.nPos = Scrollparameter.nMax;
break;
- case SB_LINELEFT: //Scrolls left by one unit.
+ case SB_LINELEFT: //Scrolls left by one unit.
TextOut(hDC,400,180,"SB_LINELEFT ",16);
Scrollparameter.nPos--;
break;
- case SB_LINERIGHT: //Scrolls right by one unit.
+ case SB_LINERIGHT: //Scrolls right by one unit.
TextOut(hDC,400,200,"SB_LINERIGHT ",16);
Scrollparameter.nPos++;
break;
- case SB_PAGELEFT: //Scrolls left by the width of the window.
+ case SB_PAGELEFT: //Scrolls left by the width of the window.
TextOut(hDC,400,220,"SB_PAGELEFT ",16);
Scrollparameter.nPos -= Scrollparameter.nPage;
break;
- case SB_PAGERIGHT: //Scrolls right by the width of the window.
+ case SB_PAGERIGHT: //Scrolls right by the width of the window.
TextOut(hDC,400,240,"PAGERIGHT ",16);
Scrollparameter.nPos += Scrollparameter.nPage;
break;
- case SB_THUMBPOSITION: //The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
+ case SB_THUMBPOSITION: //The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
TextOut(hDC,400,260,"SB_THUMBPOSITION",16);
Scrollparameter.nPos = Scrollparameter.nTrackPos;
break;
Scrollparameter.nPos = Scrollparameter.nTrackPos;
break;
}
-
+
SetScrollInfo(
hWnd, // handle to window with scroll bar
SB_VERT, // scroll bar flag
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
- si.nMin = 0;
- si.nMax = 100;
- si.nPage = 5;
+ si.nMin = 0;
+ si.nMax = 100;
+ si.nPage = 5;
si.nPos = 0;
-
+
SetScrollInfo ( hWnd, SB_HORZ, &si, FALSE );
SetScrollInfo ( hWnd, SB_VERT, &si, FALSE );
((LPCREATESTRUCT) lParam)->hInstance,
NULL
);
-
+
return 0;
break;
}
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
- TextOut(hDC, 10, 10, "Hello World from ReactOS!",
+ TextOut(hDC, 10, 10, "Hello World from ReactOS!",
strlen("Hello World from ReactOS!"));
- TextOut(hDC, 10, 80, "Press Ctrl+C or Ctrl+Alt+F1 to test Hotkey support.",
+ TextOut(hDC, 10, 80, "Press Ctrl+C or Ctrl+Alt+F1 to test Hotkey support.",
strlen("Press Ctrl+C or Ctrl+Alt+F1 to test Hotkey support."));
GetClientRect(hWnd, &clr);
GetWindowRect(hWnd, &wir);
}
return 0;
break;
-
+
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
// Created by Damon Chandler <dmc27@ee.cornell.edu>
// Updates can be downloaded at: <www.coriolis.com>
//
-// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
+// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
// if you have any questions about this code.
// ------------------------------------------------------------------
const char* WndClassName = "GMainWnd";
-LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
+LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
LPARAM LParam);
MSG msg;
WNDCLASS wc;
memset(&wc, 0, sizeof(WNDCLASS));
-
+
wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = MainWndProc;
wc.hInstance = HInstance;
if (RegisterClass(&wc))
{
- HWND HWnd =
+ HWND HWnd =
CreateWindow(WndClassName, TEXT("WM_PAINT Demo"),
WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 200, 150,
NULL, NULL, HInstance, NULL);
-
+
if (HWnd)
{
ShowWindow(HWnd, nCmdShow);
//------------------------------------------------------------------
-LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
+LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
LPARAM LParam)
{
- const char* text = "Persistent Text";
+ const char* text = "Persistent Text";
switch (Msg)
{
case WM_PAINT:
{
- // determine the invalidated area of the window
+ // determine the invalidated area of the window
RECT RUpdate;
HDC Hdc;
GetUpdateRect(HWnd, &RUpdate, FALSE);
GetClientRect(HWnd, &RClient);
// set the clipping region
- IntersectClipRect(Hdc, RUpdate.left, RUpdate.top,
+ IntersectClipRect(Hdc, RUpdate.left, RUpdate.top,
RUpdate.right, RUpdate.bottom);
// fill the client area with the background brush
- //HBRUSH HBrush =
+ //HBRUSH HBrush =
//reinterpret_cast<HBRUSH>
(HBRUSH)(GetClassLong(HWnd, GCL_HBRBACKGROUND)
);
FillRect(Hdc, &RClient, NULL);
-
+
// render the persistent text
SetTextColor(Hdc, PALETTERGB(0, 0, 255));
DrawText(Hdc, text, strlen(text), &RClient,
// release the device context
ReleaseDC(HWnd, Hdc);
- // validate the update area
+ // validate the update area
ValidateRect(HWnd, &RUpdate);
}
// release the device context
ReleaseDC(HWnd, Hdc);
- // validate the update area
+ // validate the update area
ValidateRect(HWnd, &RUpdate);
break;
(actualContext->EFlags & ZWC_EFLAGS_BITS) ==
(continueContext.EFlags & ZWC_EFLAGS_BITS)
);
-
+
assert(actualContext->Esp == continueContext.Esp);
-
+
assert
(
(actualContext->SegSs & ZWC_SEGMENT_BITS) ==
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: welcome.c,v 1.1 2002/08/23 16:15:09 ekohl Exp $
+/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS welcome/autorun application
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include "main.h"
#include "about.h"
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifndef __ABOUT_H__
#define __ABOUT_H__
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include <windowsx.h>
#include <ctype.h>
#include <assert.h>
{
if ((int)wParam == TREE_WINDOW) {
- switch (((LPNMHDR)lParam)->code) {
- case TVN_ITEMEXPANDING:
+ switch (((LPNMHDR)lParam)->code) {
+ case TVN_ITEMEXPANDING:
// return !OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
return FALSE;
// UpdateStatus(hWnd, pChildWnd->left.cur->down);
}
- case TVN_GETDISPINFO:
- OnGetDispInfo((NMTVDISPINFO*)lParam);
- break;
+ case TVN_GETDISPINFO:
+ OnGetDispInfo((NMTVDISPINFO*)lParam);
+ break;
/*
HKEY hKey;
TCHAR keyPath[1000];
}
/*
{
- int idCtrl = (int)wParam;
+ int idCtrl = (int)wParam;
//NMHDR* pnmh = (NMHDR*)lParam;
//return pane_notify(pnmh->idFrom==IDW_HEADER_LEFT? &pChildWnd->left: &pChildWnd->right, pnmh);
if ((int)wParam == TREE_WINDOW) {
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include "main.h"
#include "debug.h"
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include <shellapi.h>
//#include <winspool.h>
#include <windowsx.h>
////////////////////////////////////////////////////////////////////////////////
/*
-TotalFileSize [in] Specifies the total size of the file, in bytes.
-TotalBytesTransferred [in] Specifies the total number of bytes transferred from the source file to the destination file since the copy operation began.
-StreamSize [in] Specifies the total size of the current file stream, in bytes.
-StreamBytesTransferred [in] Specifies the total number of bytes in the current stream that have been transferred from the source file to the destination file since the copy operation began.
-dwStreamNumber [in] Handle to the current stream. The stream number is 1 the first time CopyProgressRoutine is called.
-dwCallbackReason [in] Specifies the reason that CopyProgressRoutine was called. This parameter can be one of the following values. Value Meaning
- CALLBACK_CHUNK_FINISHED Another part of the data file was copied.
- CALLBACK_STREAM_SWITCH Another stream was created and is about to be copied. This is the callback reason given when the callback routine is first invoked.
-hSourceFile [in] Handle to the source file.
-hDestinationFile [in] Handle to the destination file
-lpData [in] The argument passed to CopyProgressRoutine by the CopyFileEx or MoveFileWithProgress function.
+TotalFileSize [in] Specifies the total size of the file, in bytes.
+TotalBytesTransferred [in] Specifies the total number of bytes transferred from the source file to the destination file since the copy operation began.
+StreamSize [in] Specifies the total size of the current file stream, in bytes.
+StreamBytesTransferred [in] Specifies the total number of bytes in the current stream that have been transferred from the source file to the destination file since the copy operation began.
+dwStreamNumber [in] Handle to the current stream. The stream number is 1 the first time CopyProgressRoutine is called.
+dwCallbackReason [in] Specifies the reason that CopyProgressRoutine was called. This parameter can be one of the following values. Value Meaning
+ CALLBACK_CHUNK_FINISHED Another part of the data file was copied.
+ CALLBACK_STREAM_SWITCH Another stream was created and is about to be copied. This is the callback reason given when the callback routine is first invoked.
+hSourceFile [in] Handle to the source file.
+hDestinationFile [in] Handle to the destination file
+lpData [in] The argument passed to CopyProgressRoutine by the CopyFileEx or MoveFileWithProgress function.
Return Values The CopyProgressRoutine function should return one of the following values.
- Value Meaning
- PROGRESS_CONTINUE Continue the copy operation.
- PROGRESS_CANCEL Cancel the copy operation and delete the destination file.
- PROGRESS_STOP Stop the copy operation. It can be restarted at a later time.
- PROGRESS_QUIET Continue the copy operation, but stop invoking CopyProgressRoutine to report progress.
+ Value Meaning
+ PROGRESS_CONTINUE Continue the copy operation.
+ PROGRESS_CANCEL Cancel the copy operation and delete the destination file.
+ PROGRESS_STOP Stop the copy operation. It can be restarted at a later time.
+ PROGRESS_QUIET Continue the copy operation, but stop invoking CopyProgressRoutine to report progress.
*/
DWORD CALLBACK CopyProgressRoutine(
LARGE_INTEGER TotalFileSize, // file size
case VFT_FONT:
str = _T("The file contains a font. If dwFileType is VFT_FONT, dwFileSubtype contains a more specific description of the font file.");
switch (pFixedFileInfo->dwFileSubtype) {
- case VFT2_UNKNOWN: str = _T("The font type is unknown the system."); break;
- case VFT2_FONT_RASTER: str = _T("The file contains a raster font."); break;
- case VFT2_FONT_VECTOR: str = _T("The file contains a vector font."); break;
- case VFT2_FONT_TRUETYPE: str = _T("The file contains a TrueType font."); break;
+ case VFT2_UNKNOWN: str = _T("The font type is unknown the system."); break;
+ case VFT2_FONT_RASTER: str = _T("The file contains a raster font."); break;
+ case VFT2_FONT_VECTOR: str = _T("The file contains a vector font."); break;
+ case VFT2_FONT_TRUETYPE: str = _T("The file contains a TrueType font."); break;
}
break;
TCHAR* pVal;
UINT nValLen;
- wsprintf(SubBlock, TEXT("\\StringFileInfo\\%04x%04x\\%s"),
+ wsprintf(SubBlock, TEXT("\\StringFileInfo\\%04x%04x\\%s"),
lpTranslate.wLanguage, lpTranslate.wCodePage, info_str);
- // Retrieve file description for language and code page "i".
+ // Retrieve file description for language and code page "i".
if (VerQueryValue(pVersionData, SubBlock, (PVOID)&pVal, &nValLen)) {
ListBox_InsertItemData(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_TYPES), i, info_str);
// ListBox_InsertItemData(pane->hwnd, idx, entry);
}
}
-static TCHAR* InfoStrings[] = {
- TEXT("Comments"),
- TEXT("InternalName"),
- TEXT("ProductName"),
- TEXT("CompanyName"),
- TEXT("LegalCopyright"),
- TEXT("ProductVersion"),
- TEXT("FileDescription"),
- TEXT("LegalTrademarks"),
- TEXT("PrivateBuild"),
- TEXT("FileVersion"),
- TEXT("OriginalFilename"),
+static TCHAR* InfoStrings[] = {
+ TEXT("Comments"),
+ TEXT("InternalName"),
+ TEXT("ProductName"),
+ TEXT("CompanyName"),
+ TEXT("LegalCopyright"),
+ TEXT("ProductVersion"),
+ TEXT("FileDescription"),
+ TEXT("LegalTrademarks"),
+ TEXT("PrivateBuild"),
+ TEXT("FileVersion"),
+ TEXT("OriginalFilename"),
TEXT("SpecialBuild"),
TEXT(""),
NULL
/*
wsprintf(SubBlock, TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
lpTranslate[i].wLanguage, lpTranslate[i].wCodePage);
- // Retrieve file description for language and code page "i".
+ // Retrieve file description for language and code page "i".
if (VerQueryValue(pVersionData, SubBlock, &pVal, &nValLen)) {
ListBox_InsertItemData(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_TYPES), i, _T("FileDescription"));
SendMessage(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_VALUES), WM_SETTEXT, 0, pVal);
//entry->bhfi.nFileSizeHigh;
//entry->bhfi.ftCreationTime
wsprintf(buffer, _T("%u"), entry->bhfi.nFileSizeLow);
- if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, buffer, &numFmt,
+ if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, buffer, &numFmt,
buffer + MAX_PATH/2, MAX_PATH/2)) {
SetDlgItemText(hDlg, IDC_STATIC_PROP_SIZE, buffer + MAX_PATH/2);
} else {
#include <process.h>
#include <stdio.h>
#endif
-
+
#include "main.h"
#include "draw.h"
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifndef __DRAW_H__
#define __DRAW_H__
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include "main.h"
#include "settings.h"
#include "framewnd.h"
while (count) {
// SendMessage(Globals.hDriveCombo, CB_DELETESTRING, (WPARAM)--count, 0);
}
- SendMessage(Globals.hDriveCombo, CB_RESETCONTENT, 0, 0);
-
+ SendMessage(Globals.hDriveCombo, CB_RESETCONTENT, 0, 0);
+
memset(Globals.drives, 0, BUFFER_LEN);
GetLogicalDriveStrings(BUFFER_LEN, Globals.drives);
drivebarBtn.fsStyle = TBSTYLE_BUTTON;
vol[0] = toupper(vol[0]);
vol[1] = _T(':'); vol[2] = _T('\\'); vol[3] = _T('\0');
if (drivebarBtn.iBitmap != 1 /*DRIVE_REMOVABLE*/ &&
- GetVolumeInformation(vol, szVolumeNameBuffer,
- sizeof(szVolumeNameBuffer)/sizeof(TCHAR),
- NULL, NULL, NULL, NULL, 0) &&
+ GetVolumeInformation(vol, szVolumeNameBuffer,
+ sizeof(szVolumeNameBuffer)/sizeof(TCHAR),
+ NULL, NULL, NULL, NULL, 0) &&
szVolumeNameBuffer[0] != _T('\0')) {
vol[2] = _T(' '); vol[3] = _T('['); vol[4] = _T('\0');
_tcscat(vol, szVolumeNameBuffer);
cbei.iImage = drivebarBtn.iBitmap;
// cbei.iSelectedImage = IInf[iCnt].iSelectedImage;
// cbei.iIndent = IInf[iCnt].iIndent;
- SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
+ SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
drivebarBtn.idCommand++;
drivebarBtn.iString++;
} ITEMINFO, *PITEMINFO;
ITEMINFO IInf[] = {
- { 0, 3, 0, _T("A:")},
+ { 0, 3, 0, _T("A:")},
{ 1, 4, 1, _T("C: [SYSTEM]")},
{ 2, 5, 2, _T("D:")},
{ 0, 3, 0, _T("E: [SOFT_RAID_1]")},
// cbei.iImage = IInf[iCnt].iImage;
// cbei.iSelectedImage = IInf[iCnt].iSelectedImage;
// cbei.iIndent = IInf[iCnt].iIndent;
- SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
+ SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
}
}
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifndef __DRIVEBAR_H__
#define __DRIVEBAR_H__
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include <windowsx.h>
#include "main.h"
#ifndef _NO_EXTENSIONS
entry->unix_dir = FALSE;
#endif
-
+
while(entry) {
while(*s && *s!=_T('\\') && *s!=_T('/'))
*d++ = *s++;
passed on subsequent calls as the fmtID parameter to
"format the same type you did last time".
- *****************************************************************/
+ *****************************************************************/
DWORD WINAPI SHFormatDrive(HWND hWnd,
UINT drive,
UINT fmtID,
UINT options);
- //
+ //
// Special value of fmtID which means "use the defaultformat"
- //
+ //
#define SHFMT_ID_DEFAULT 0xFFFF
- //
+ //
// Option bits for options parameter
- //
+ //
#define SHFMT_OPT_FULL 0x0001
#define SHFMT_OPT_SYSONLY 0x0002
- //
+ //
// Special return values. PLEASE NOTE that these are DWORD values.
- //
+ //
#define SHFMT_ERROR 0xFFFFFFFFL // Error on last format,
// drive may be formatable
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
//#include <shellapi.h>
#include <windowsx.h>
#include <assert.h>
szChildClass, path, hInst,
// CW_USEDEFAULT, CW_USEDEFAULT,
// CW_USEDEFAULT, CW_USEDEFAULT,
- 20, 20, 200, 200,
+ 20, 20, 200, 200,
WS_MAXIMIZE, (LPARAM)pChildWnd
// 0/*style*/, 0/*lParam*/
};
_tsplitpath(path, drv1, 0, 0, 0);
// search for a already open window for the same drive
- for (child_wnd = GetNextWindow(Globals.hMDIClient,GW_CHILD);
- child_wnd;
+ for (child_wnd = GetNextWindow(Globals.hMDIClient,GW_CHILD);
+ child_wnd;
child_wnd = GetNextWindow(child_wnd, GW_HWNDNEXT)) {
ChildWnd* pChildWnd = (ChildWnd*) GetWindowLong(child_wnd, GWL_USERDATA);
if (pChildWnd) {
UINT cmd = LOWORD(wParam);
HWND hChildWnd;
// HWND hwndClient = (HWND)SendMessage(Globals.hMDIClient, WM_MDIGETACTIVE, 0, 0);
-// if (hwndClient)
+// if (hwndClient)
// if (SendMessage(hwndClient, WM_DISPATCH_COMMAND, wParam, lParam))
// return 0;
SetErrorMode(OldMode & ~SEM_FAILCRITICALERRORS); // Force O/S to handle
// Call SHFormatDrive here.
SHFormatDrive(hWnd, 0 /* A: */, SHFMT_ID_DEFAULT, 0);
- SetErrorMode(OldMode); // Put it back the way it was.
+ SetErrorMode(OldMode); // Put it back the way it was.
}
#endif
break;
{0, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
{0, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
};
-
+
static LRESULT MsgNotify(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
LPNMHDR lpnmhdr;
static LPTBBUTTON lpSaveButtons;
//LPARAM lParam;
-
+
lpnmhdr = (LPNMHDR)lparam;
/*
- // The following code allows the toolbar to be customized.
+ // The following code allows the toolbar to be customized.
// If you return FALSE the Customize Toolbar dialog flashes
// and goes away.
-
+
if (lpnmhdr->code == TBN_QUERYINSERT || lpnmhdr->code == TBN_QUERYDELETE) {
return TRUE;
}
-
+
if (lpnmhdr->code == TBN_GETBUTTONINFO) {
LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam;
TCHAR szBuffer[20];
{0, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
{0, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
};
-
+
// 20 = total number of buttons.
// tbButton and tbButtonNew send information about
// the other 12 buttons in tbButtonNew.
TCHAR szBuffer[20];
/*
typedef struct _TBBUTTON {
- int iBitmap;
- int idCommand;
- BYTE fsState;
- BYTE fsStyle;
- DWORD dwData;
- INT_PTR iString;
-} TBBUTTON, NEAR* PTBBUTTON, FAR* LPTBBUTTON;
+ int iBitmap;
+ int idCommand;
+ BYTE fsState;
+ BYTE fsStyle;
+ DWORD dwData;
+ INT_PTR iString;
+} TBBUTTON, NEAR* PTBBUTTON, FAR* LPTBBUTTON;
*/
// 20 = total number of buttons.
// tbButton and tbButtonNew send information about
{
LPTBNOTIFY lpTB = (LPTBNOTIFY)lparam;
int i;
-
+
// Allocate memory to store the button information.
nResetCount = SendMessage(lpTB->hdr.hwndFrom, TB_BUTTONCOUNT, 0, 0);
lpSaveButtons = (LPTBBUTTON)GlobalAlloc(GPTR, sizeof(TBBUTTON) * nResetCount);
-
+
// Save the current configuration so if the user presses
// reset, the original toolbar can be restored.
for (i = 0; i < nResetCount; i++) {
}
}
return TRUE;
-
+
case TBN_RESET:
{
LPTBNOTIFY lpTB = (LPTBNOTIFY)lparam;
int nCount, i;
-
+
// Remove all of the existing buttons starting with the last and working down.
nCount = SendMessage(lpTB->hdr.hwndFrom, TB_BUTTONCOUNT, 0, 0);
for (i = nCount - 1; i >= 0; i--) {
SendMessage(lpTB->hdr.hwndFrom, TB_DELETEBUTTON, i, 0);
}
-
+
// Restore the buttons that were saved.
SendMessage(lpTB->hdr.hwndFrom, TB_ADDBUTTONS, (WPARAM)nResetCount, (LPARAM)lpSaveButtons);
}
return TRUE;
-
+
case TBN_ENDADJUST:
// Free the memory allocated during TBN_BEGINADJUST
GlobalFree((HGLOBAL)lpSaveButtons);
// if (nmhdr->code == NM_HOVER || nmhdr->code == NM_NCHITTEST) return 0;
-// switch (((LPNMHDR)lParam)->code) {
- switch (nmhdr->code) {
+// switch (((LPNMHDR)lParam)->code) {
+ switch (nmhdr->code) {
case NM_OUTOFMEMORY:
case NM_CLICK:
case NM_DBLCLK:
if (MsgNotify(hWnd, message, wParam, lParam)) return TRUE;
}
// return MsgNotify(hWnd, message, wParam, lParam);
- switch (((LPNMHDR)lParam)->code) {
+ switch (((LPNMHDR)lParam)->code) {
#ifdef _MSC_VER
- case TTN_GETDISPINFO:
- {
- LPTOOLTIPTEXT lpttt;
- lpttt = (LPTOOLTIPTEXT)lParam;
- lpttt->hinst = hInst;
+ case TTN_GETDISPINFO:
+ {
+ LPTOOLTIPTEXT lpttt;
+ lpttt = (LPTOOLTIPTEXT)lParam;
+ lpttt->hinst = hInst;
// load appropriate string
- lpttt->lpszText = MAKEINTRESOURCE(lpttt->hdr.idFrom);
- }
- break;
+ lpttt->lpszText = MAKEINTRESOURCE(lpttt->hdr.idFrom);
+ }
+ break;
#endif
default:
break;
}
break;
-
+
case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
// if (LOWORD(wParam) > ID_CMD_FIRST && LOWORD(wParam) < ID_CMD_LAST) {
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include <windowsx.h>
#include "main.h"
#include "listview.h"
//
static void AddEntryToList(HWND hwndLV, int idx, Entry* entry)
-{
+{
LVITEM item;
- item.mask = LVIF_TEXT | LVIF_PARAM;
- item.iItem = 0;//idx;
- item.iSubItem = 0;
- item.state = 0;
- item.stateMask = 0;
-// item.pszText = entry->data.cFileName;
-// item.cchTextMax = strlen(entry->data.cFileName);
- item.pszText = LPSTR_TEXTCALLBACK;
- item.cchTextMax = 0;
- item.iImage = 0;
-// item.iImage = I_IMAGECALLBACK;
+ item.mask = LVIF_TEXT | LVIF_PARAM;
+ item.iItem = 0;//idx;
+ item.iSubItem = 0;
+ item.state = 0;
+ item.stateMask = 0;
+// item.pszText = entry->data.cFileName;
+// item.cchTextMax = strlen(entry->data.cFileName);
+ item.pszText = LPSTR_TEXTCALLBACK;
+ item.cchTextMax = 0;
+ item.iImage = 0;
+// item.iImage = I_IMAGECALLBACK;
item.lParam = (LPARAM)entry;
#if (_WIN32_IE >= 0x0300)
item.iIndent = 0;
if (entry->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue;
#endif
- AddEntryToList(hWnd, idx, entry);
+ AddEntryToList(hWnd, idx, entry);
++idx;
}
ShowWindow(hWnd, SW_SHOW);
TCHAR szText[50];
int index;
LV_COLUMN lvC;
-
+
// Create columns.
lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvC.pszText = szText;
}
}
-// OnGetDispInfo - processes the LVN_GETDISPINFO notification message.
+// OnGetDispInfo - processes the LVN_GETDISPINFO notification message.
static void OnGetDispInfo(NMLVDISPINFO* plvdi)
{
SYSTEMTIME SystemTime;
plvdi->item.pszText = NULL;
switch (plvdi->item.iSubItem) {
case 0:
- plvdi->item.pszText = entry->data.cFileName;
-// item.cchTextMax = strlen(entry->data.cFileName);
+ plvdi->item.pszText = entry->data.cFileName;
+// item.cchTextMax = strlen(entry->data.cFileName);
// plvdi->item.pszText = rgPetInfo[plvdi->item.iItem].szKind;
break;
case 1:
//entry->bhfi.nFileSizeHigh;
//entry->bhfi.ftCreationTime
wsprintf(buffer, _T("%u"), entry->bhfi.nFileSizeLow);
- if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, buffer, &numFmt,
+ if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, buffer, &numFmt,
buffer + sizeof(buffer)/2, sizeof(buffer)/2)) {
plvdi->item.pszText = buffer + sizeof(buffer)/2;
} else {
plvdi->item.pszText = buffer;
break;
}
-}
+}
/*
-FILE_ATTRIBUTE_ARCHIVE The file or directory is an archive file. Applications use this attribute to mark files for backup or removal.
-FILE_ATTRIBUTE_COMPRESSED The file or directory is compressed. For a file, this means that all of the data in the file is compressed. For a directory, this means that compression is the default for newly created files and subdirectories.
-FILE_ATTRIBUTE_DIRECTORY The handle identifies a directory.
-FILE_ATTRIBUTE_ENCRYPTED The file or directory is encrypted. For a file, this means that all data in the file is encrypted. For a directory, this means that encryption is the default for newly created files and subdirectories.
-FILE_ATTRIBUTE_HIDDEN The file or directory is hidden. It is not included in an ordinary directory listing.
-FILE_ATTRIBUTE_NORMAL The file has no other attributes. This attribute is valid only if used alone.
-FILE_ATTRIBUTE_OFFLINE The file data is not immediately available. This attribute indicates that the file data has been physically moved to offline storage. This attribute is used by Remote Storage, the hierarchical storage management software in Windows 2000. Applications should not arbitrarily change this attribute.
-FILE_ATTRIBUTE_READONLY The file or directory is read-only. Applications can read the file but cannot write to it or delete it. In the case of a directory, applications cannot delete it.
-FILE_ATTRIBUTE_REPARSE_POINT The file has an associated reparse point.
-FILE_ATTRIBUTE_SPARSE_FILE The file is a sparse file.
-FILE_ATTRIBUTE_SYSTEM The file or directory is part of the operating system or is used exclusively by the operating system.
+FILE_ATTRIBUTE_ARCHIVE The file or directory is an archive file. Applications use this attribute to mark files for backup or removal.
+FILE_ATTRIBUTE_COMPRESSED The file or directory is compressed. For a file, this means that all of the data in the file is compressed. For a directory, this means that compression is the default for newly created files and subdirectories.
+FILE_ATTRIBUTE_DIRECTORY The handle identifies a directory.
+FILE_ATTRIBUTE_ENCRYPTED The file or directory is encrypted. For a file, this means that all data in the file is encrypted. For a directory, this means that encryption is the default for newly created files and subdirectories.
+FILE_ATTRIBUTE_HIDDEN The file or directory is hidden. It is not included in an ordinary directory listing.
+FILE_ATTRIBUTE_NORMAL The file has no other attributes. This attribute is valid only if used alone.
+FILE_ATTRIBUTE_OFFLINE The file data is not immediately available. This attribute indicates that the file data has been physically moved to offline storage. This attribute is used by Remote Storage, the hierarchical storage management software in Windows 2000. Applications should not arbitrarily change this attribute.
+FILE_ATTRIBUTE_READONLY The file or directory is read-only. Applications can read the file but cannot write to it or delete it. In the case of a directory, applications cannot delete it.
+FILE_ATTRIBUTE_REPARSE_POINT The file has an associated reparse point.
+FILE_ATTRIBUTE_SPARSE_FILE The file is a sparse file.
+FILE_ATTRIBUTE_SYSTEM The file or directory is part of the operating system or is used exclusively by the operating system.
FILE_ATTRIBUTE_TEMPORARY The file is being used for temporary storage. File systems attempt to keep all the data in memory for quicker access, rather than flushing the data back to mass storage. A temporary file should be deleted by the application as soon as it is no longer needed.
*/
- // OnEndLabelEdit - processes the LVN_ENDLABELEDIT
- // notification message.
- // Returns TRUE if the label is changed, or FALSE otherwise.
+ // OnEndLabelEdit - processes the LVN_ENDLABELEDIT
+ // notification message.
+ // Returns TRUE if the label is changed, or FALSE otherwise.
static BOOL OnEndLabelEdit(NMLVDISPINFO* plvdi)
-{
- if (plvdi->item.iItem == -1)
- return FALSE;
-
- // Copy the new label text to the application-defined structure.
+{
+ if (plvdi->item.iItem == -1)
+ return FALSE;
+
+ // Copy the new label text to the application-defined structure.
// lstrcpyn(rgPetInfo[plvdi->item.iItem].szKind, plvdi->item.pszText, 10);
-
+
return TRUE;
// To make a more robust application you should send an EM_LIMITTEXT
// message to the edit control to prevent the user from entering too
- // many characters in the field.
-}
+ // many characters in the field.
+}
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
case WM_DISPATCH_COMMAND:
return _CmdWndProc(hWnd, message, wParam, lParam);
case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code) {
- case LVN_GETDISPINFO:
- OnGetDispInfo((NMLVDISPINFO*)lParam);
+ switch (((LPNMHDR)lParam)->code) {
+ case LVN_GETDISPINFO:
+ OnGetDispInfo((NMLVDISPINFO*)lParam);
return 0;
case NM_DBLCLK:
{
NMITEMACTIVATE* nmitem = (LPNMITEMACTIVATE)lParam;
LVHITTESTINFO info;
- if (nmitem->hdr.hwndFrom != hWnd) break;
-// if (nmitem->hdr.idFrom != IDW_LISTVIEW) break;
-// if (nmitem->hdr.code != ???) break;
+ if (nmitem->hdr.hwndFrom != hWnd) break;
+// if (nmitem->hdr.idFrom != IDW_LISTVIEW) break;
+// if (nmitem->hdr.code != ???) break;
#ifdef _MSC_VER
switch (nmitem->uKeyFlags) {
- case LVKF_ALT: // The ALT key is pressed.
+ case LVKF_ALT: // The ALT key is pressed.
// properties dialog box ?
break;
case LVKF_CONTROL: // The CTRL key is pressed.
// run dialog box for providing parameters...
break;
- case LVKF_SHIFT: // The SHIFT key is pressed.
+ case LVKF_SHIFT: // The SHIFT key is pressed.
break;
}
#endif
}
}
return 0;
- case LVN_ENDLABELEDIT:
+ case LVN_ENDLABELEDIT:
return OnEndLabelEdit((NMLVDISPINFO*)lParam);
}
break;
void CreateListWnd(HWND parent, Pane* pane, int id, LPTSTR lpszPathName)
{
- RECT rcClient; // dimensions of client area
+ RECT rcClient; // dimensions of client area
Entry* entry = pane->root;
// pane->treePane = 0;
- GetClientRect(parent, &rcClient);
- pane->hWnd = CreateWindowEx(0, WC_LISTVIEW, _T("List View"),
- WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT/* | LVS_NOCOLUMNHEADER*/,
- 0, 0, rcClient.right, rcClient.bottom,
- parent, (HMENU)id, hInst, NULL);
- // Initialize the image list, and add items to the control.
+ GetClientRect(parent, &rcClient);
+ pane->hWnd = CreateWindowEx(0, WC_LISTVIEW, _T("List View"),
+ WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT/* | LVS_NOCOLUMNHEADER*/,
+ 0, 0, rcClient.right, rcClient.bottom,
+ parent, (HMENU)id, hInst, NULL);
+ // Initialize the image list, and add items to the control.
/*
- if (!InitListViewImageLists(pane->hWnd) ||
- !InitListViewItems(pane->hWnd, lpszPathName)) {
- DestroyWindow(pane->hWnd);
- return FALSE;
- }
+ if (!InitListViewImageLists(pane->hWnd) ||
+ !InitListViewItems(pane->hWnd, lpszPathName)) {
+ DestroyWindow(pane->hWnd);
+ return FALSE;
+ }
*/
ListView_SetExtendedListViewStyle(pane->hWnd, LVS_EX_FULLROWSELECT);
CreateListColumns(pane->hWnd);
}
HWND CreateListView(HWND hwndParent, ChildWnd* pChildWnd, int id)
-{
+{
RECT rcClient;
HWND hwndLV;
-
- // Get the dimensions of the parent window's client area, and create the list view control.
- GetClientRect(hwndParent, &rcClient);
- hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"),
- WS_VISIBLE | WS_CHILD | LVS_REPORT,
- 0, 0, rcClient.right, rcClient.bottom,
- hwndParent, (HMENU)id, hInst, NULL);
+
+ // Get the dimensions of the parent window's client area, and create the list view control.
+ GetClientRect(hwndParent, &rcClient);
+ hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"),
+ WS_VISIBLE | WS_CHILD | LVS_REPORT,
+ 0, 0, rcClient.right, rcClient.bottom,
+ hwndParent, (HMENU)id, hInst, NULL);
ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT);
-
- // Initialize the image list, and add items to the control.
+
+ // Initialize the image list, and add items to the control.
/*
- if (!InitListViewImageLists(hwndLV) ||
- !InitListViewItems(hwndLV, szName)) {
- DestroyWindow(hwndLV);
- return FALSE;
- }
+ if (!InitListViewImageLists(hwndLV) ||
+ !InitListViewItems(hwndLV, szName)) {
+ DestroyWindow(hwndLV);
+ return FALSE;
+ }
*/
CreateListColumns(hwndLV);
g_orgListWndProc = SubclassWindow(hwndLV, ListWndProc);
return hwndLV;
-}
+}
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include "main.h"
#include "settings.h"
#include "framewnd.h"
#define DRIVEBOX_HEIGHT 8
/*
typedef struct _TBBUTTON {
- int iBitmap;
- int idCommand;
- BYTE fsState;
- BYTE fsStyle;
- DWORD dwData;
- INT_PTR iString;
-} TBBUTTON, NEAR* PTBBUTTON, FAR* LPTBBUTTON;
+ int iBitmap;
+ int idCommand;
+ BYTE fsState;
+ BYTE fsStyle;
+ DWORD dwData;
+ INT_PTR iString;
+} TBBUTTON, NEAR* PTBBUTTON, FAR* LPTBBUTTON;
*/
TBBUTTON toolbarBtns[] = {
{DRIVEBOX_WIDTH+10, 0, 0, TBSTYLE_SEP},
{0, 0, 0, TBSTYLE_SEP},
-// {1, ID_FILE_OPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_OPEN },
-// {2, ID_FILE_MOVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_MOVE},
-// {3, ID_FILE_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_COPY},
-// {4, ID_FILE_COPY_CLIPBOARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_COPY_CLIPBOARD},
- {5, ID_FILE_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {6, ID_FILE_RENAME, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {7, ID_FILE_PROPERTIES, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {8, ID_FILE_COMPRESS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {9, ID_FILE_UNCOMPRESS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {10, ID_FILE_RUN, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {10, ID_FILE_PRINT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {11, ID_FILE_ASSOCIATE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {12, ID_FILE_CREATE_DIRECTORY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {13, ID_FILE_SEARCH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {14, ID_FILE_SELECT_FILES, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {16, ID_FILE_EXIT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {15, ID_DISK_COPY_DISK, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {16, ID_DISK_LABEL_DISK, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {17, ID_DISK_FORMAT_DISK, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {18, ID_DISK_CONNECT_NETWORK_DRIVE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {19, ID_DISK_DISCONNECT_NETWORK_DRIVE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {20, ID_DISK_SHARE_AS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {21, ID_DISK_STOP_SHARING, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {24, ID_DISK_SELECT_DRIVE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {25, ID_TREE_EXPAND_ONE_LEVEL, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {26, ID_TREE_EXPAND_BRANCH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {27, ID_TREE_EXPAND_ALL, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {28, ID_TREE_COLLAPSE_BRANCH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {22, ID_TREE_INDICATE_EXPANDABLE_BRANCHES, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {30, ID_VIEW_TREE_DIRECTORY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {31, ID_VIEW_TREE_ONLY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {32, ID_VIEW_DIRECTORY_ONLY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {33, ID_VIEW_SPLIT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {23, ID_VIEW_NAME, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {24, ID_VIEW_ALL_FILE_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {25, ID_VIEW_PARTIAL_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {37, ID_VIEW_SORT_BY_NAME, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {38, ID_VIEW_SORT_BY_TYPE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {39, ID_VIEW_SORT_BY_SIZE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {40, ID_VIEW_SORT_BY_DATE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {26, ID_VIEW_BY_FILE_TYPE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {27, ID_OPTIONS_CONFIRMATION, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {28, ID_OPTIONS_FONT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {29, ID_OPTIONS_CUSTOMISE_TOOLBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {45, ID_OPTIONS_TOOLBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {46, ID_OPTIONS_DRIVEBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {47, ID_OPTIONS_STATUSBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {30, ID_OPTIONS_OPEN_NEW_WINDOW_ON_CONNECT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {31, ID_OPTIONS_MINIMISE_ON_USE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {32, ID_OPTIONS_SAVE_ON_EXIT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {33, ID_SECURITY_PERMISSIONS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {34, ID_SECURITY_AUDITING, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {35, ID_SECURITY_OWNER, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {36, ID_WINDOW_NEW_WINDOW, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {37, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {38, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {39, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {40, ID_WINDOW_ARRANGE_ICONS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {41, ID_WINDOW_REFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
- {42, ID_HELP_CONTENTS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {61, ID_HELP_SEARCH_HELP, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {62, ID_HELP_HOW_TO_USE_HELP, TBSTATE_ENABLED, TBSTYLE_BUTTON},
-// {63, ID_HELP_ABOUT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {1, ID_FILE_OPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_OPEN },
+// {2, ID_FILE_MOVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_MOVE},
+// {3, ID_FILE_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_COPY},
+// {4, ID_FILE_COPY_CLIPBOARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_COPY_CLIPBOARD},
+ {5, ID_FILE_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {6, ID_FILE_RENAME, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {7, ID_FILE_PROPERTIES, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {8, ID_FILE_COMPRESS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {9, ID_FILE_UNCOMPRESS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {10, ID_FILE_RUN, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {10, ID_FILE_PRINT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {11, ID_FILE_ASSOCIATE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {12, ID_FILE_CREATE_DIRECTORY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {13, ID_FILE_SEARCH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {14, ID_FILE_SELECT_FILES, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {16, ID_FILE_EXIT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {15, ID_DISK_COPY_DISK, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {16, ID_DISK_LABEL_DISK, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {17, ID_DISK_FORMAT_DISK, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {18, ID_DISK_CONNECT_NETWORK_DRIVE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {19, ID_DISK_DISCONNECT_NETWORK_DRIVE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {20, ID_DISK_SHARE_AS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {21, ID_DISK_STOP_SHARING, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {24, ID_DISK_SELECT_DRIVE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {25, ID_TREE_EXPAND_ONE_LEVEL, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {26, ID_TREE_EXPAND_BRANCH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {27, ID_TREE_EXPAND_ALL, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {28, ID_TREE_COLLAPSE_BRANCH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {22, ID_TREE_INDICATE_EXPANDABLE_BRANCHES, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {30, ID_VIEW_TREE_DIRECTORY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {31, ID_VIEW_TREE_ONLY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {32, ID_VIEW_DIRECTORY_ONLY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {33, ID_VIEW_SPLIT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {23, ID_VIEW_NAME, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {24, ID_VIEW_ALL_FILE_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {25, ID_VIEW_PARTIAL_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {37, ID_VIEW_SORT_BY_NAME, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {38, ID_VIEW_SORT_BY_TYPE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {39, ID_VIEW_SORT_BY_SIZE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {40, ID_VIEW_SORT_BY_DATE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {26, ID_VIEW_BY_FILE_TYPE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {27, ID_OPTIONS_CONFIRMATION, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {28, ID_OPTIONS_FONT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {29, ID_OPTIONS_CUSTOMISE_TOOLBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {45, ID_OPTIONS_TOOLBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {46, ID_OPTIONS_DRIVEBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {47, ID_OPTIONS_STATUSBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {30, ID_OPTIONS_OPEN_NEW_WINDOW_ON_CONNECT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {31, ID_OPTIONS_MINIMISE_ON_USE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {32, ID_OPTIONS_SAVE_ON_EXIT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {33, ID_SECURITY_PERMISSIONS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {34, ID_SECURITY_AUDITING, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {35, ID_SECURITY_OWNER, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {36, ID_WINDOW_NEW_WINDOW, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {37, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {38, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {39, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {40, ID_WINDOW_ARRANGE_ICONS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {41, ID_WINDOW_REFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+ {42, ID_HELP_CONTENTS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {61, ID_HELP_SEARCH_HELP, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {62, ID_HELP_HOW_TO_USE_HELP, TBSTATE_ENABLED, TBSTYLE_BUTTON},
+// {63, ID_HELP_ABOUT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
// {0, ID_WINDOW_NEW_WINDOW, TBSTATE_ENABLED, TBSTYLE_BUTTON},
{
// Create the edit control. Notice that the parent of
- // the toolbar, is used as the parent of the edit control.
- //hWndEdit = CreateWindowEx(0L, WC_COMBOBOXEX, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE
+ // the toolbar, is used as the parent of the edit control.
+ //hWndEdit = CreateWindowEx(0L, WC_COMBOBOXEX, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE
#if 0
- Globals.hDriveCombo = CreateWindowEx(0L, _T("ComboBox"), NULL,
- WS_CHILD | WS_BORDER | WS_VISIBLE | CBS_DROPDOWNLIST | ES_LEFT | ES_AUTOVSCROLL | ES_MULTILINE,
+ Globals.hDriveCombo = CreateWindowEx(0L, _T("ComboBox"), NULL,
+ WS_CHILD | WS_BORDER | WS_VISIBLE | CBS_DROPDOWNLIST | ES_LEFT | ES_AUTOVSCROLL | ES_MULTILINE,
10, 0, DRIVEBOX_WIDTH, DRIVEBOX_HEIGHT, Globals.hMainWnd, (HMENU)IDW_DRIVEBOX, hInstance, 0);
#else
#ifndef __GNUC__
// Set the toolbar window as the parent of the edit control
// window. You must set the toolbar as the parent of the edit
// control for it to appear embedded in the toolbar.
- SetParent(Globals.hDriveCombo, Globals.hToolBar);
+ SetParent(Globals.hDriveCombo, Globals.hToolBar);
}
}
// Create the drive bar
- Globals.hDriveBar = CreateToolbarEx(Globals.hMainWnd,
+ Globals.hDriveBar = CreateToolbarEx(Globals.hMainWnd,
WS_CHILD|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_FLAT|TBSTYLE_LIST|TBSTYLE_WRAPABLE,
// WS_CHILD|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_LIST|TBSTYLE_TRANSPARENT|TBSTYLE_WRAPABLE,
- IDW_DRIVEBAR, 2, hInstance, IDB_DRIVEBAR,
- &drivebarBtn, 1/*iNumButtons*/,
- 25/*dxButton*/, 16/*dyButton*/,
+ IDW_DRIVEBAR, 2, hInstance, IDB_DRIVEBAR,
+ &drivebarBtn, 1/*iNumButtons*/,
+ 25/*dxButton*/, 16/*dyButton*/,
0/*dxBitmap*/, 0/*dyBitmap*/, sizeof(TBBUTTON));
-// 16/*dxButton*/, 13/*dyButton*/,
+// 16/*dxButton*/, 13/*dyButton*/,
// 16/*dxBitmap*/, 13/*dyBitmap*/, sizeof(TBBUTTON));
CheckMenuItem(Globals.hMenuOptions, ID_OPTIONS_DRIVEBAR, MF_BYCOMMAND|MF_CHECKED);
ConfigureDriveBar(Globals.hDriveBar);
// Create the status bar
- Globals.hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
+ Globals.hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
_T(""), Globals.hMainWnd, IDW_STATUS_WINDOW);
if (!Globals.hStatusBar)
return FALSE;
UpdateStatusBar();
return TRUE;
}
-
+
////////////////////////////////////////////////////////////////////////////////
void SetupStatusBar(BOOL bResize)
}
/*
-struct _cpinfo {
- UINT MaxCharSize;
- BYTE DefaultChar[MAX_DEFAULTCHAR];
- BYTE LeadByte[MAX_LEADBYTES];
-} CPINFO, *LPCPINFO;
+struct _cpinfo {
+ UINT MaxCharSize;
+ BYTE DefaultChar[MAX_DEFAULTCHAR];
+ BYTE LeadByte[MAX_LEADBYTES];
+} CPINFO, *LPCPINFO;
*/
int APIENTRY WinMain(HINSTANCE hInstance,
// hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_WINFILE);
hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDR_ACCELERATOR1);
-
+
hMDIClient = GetWindow(Globals.hMainWnd, GW_CHILD);
// Main message loop:
- while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
- if (!TranslateMDISysAccel(hMDIClient, &msg) &&
- !TranslateAccelerator(Globals.hMainWnd/*hwndFrame*/, hAccel, &msg)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
+ while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
+ if (!TranslateMDISysAccel(hMDIClient, &msg) &&
+ !TranslateAccelerator(Globals.hMainWnd/*hwndFrame*/, hAccel, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
SaveSettings();
ExitInstance();
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include "main.h"
#include "network.h"
NETRESOURCE netResouce;
CONNECTDLGSTRUCT connectDlg;
- //netResouce.dwScope;
- //netResouce.dwType;
+ //netResouce.dwScope;
+ //netResouce.dwType;
netResouce.dwDisplayType = 0;
- //netResouce.dwUsage;
- //netResouce.lpLocalName;
- //netResouce.lpRemoteName;
- //netResouce.lpComment;
- //netResouce.lpProvider;
+ //netResouce.dwUsage;
+ //netResouce.lpLocalName;
+ //netResouce.lpRemoteName;
+ //netResouce.lpComment;
+ //netResouce.lpProvider;
//connectDlg.cbStructure;
connectDlg.hwndOwner = hWnd;
////////////////////////////////////
static BOOL WINAPI EnumerateFunc(HWND hwnd, HDC hdc, LPNETRESOURCE lpnr)
-{
+{
DWORD dwResult;
DWORD dwResultEnum;
HANDLE hEnum;
lpnr, // NULL first time the function is called
&hEnum); // handle to the resource
- if (dwResult != NO_ERROR) {
+ if (dwResult != NO_ERROR) {
// Process errors with an application-defined error handler.
NetErrorHandler(hwnd, dwResult, (LPTSTR)_T("WNetOpenEnum"));
return FALSE;
// Call the GlobalAlloc function to allocate resources.
lpnrLocal = (LPNETRESOURCE)GlobalAlloc(GPTR, cbBuffer);
-
- do {
+
+ do {
// Initialize the buffer.
ZeroMemory(lpnrLocal, cbBuffer);
// Call WNetCloseEnum to end the enumeration.
dwResult = pWNetCloseEnum(hEnum);
-
- if (dwResult != NO_ERROR) {
+
+ if (dwResult != NO_ERROR) {
// Process errors.
NetErrorHandler(hwnd, dwResult, (LPTSTR)_T("WNetCloseEnum"));
return FALSE;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifndef __NETWORK_H__
#define __NETWORK_H__
#define IDC_STATIC -1
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 149
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include <shellapi.h>
#include "main.h"
typedef void (WINAPI *RUNFILEDLG)(
- HWND hwndOwner,
- HICON hIcon,
- LPCSTR lpstrDirectory,
- LPCSTR lpstrTitle,
+ HWND hwndOwner,
+ HICON hIcon,
+ LPCSTR lpstrDirectory,
+ LPCSTR lpstrTitle,
LPCSTR lpstrDescription,
- UINT uFlags);
+ UINT uFlags);
//
// Flags for RunFileDlg
//
-#define RFF_NOBROWSE 0x01 // Removes the browse button.
-#define RFF_NODEFAULT 0x02 // No default item selected.
+#define RFF_NOBROWSE 0x01 // Removes the browse button.
+#define RFF_NODEFAULT 0x02 // No default item selected.
#define RFF_CALCDIRECTORY 0x04 // Calculates the working directory from the file name.
-#define RFF_NOLABEL 0x08 // Removes the edit box label.
+#define RFF_NOLABEL 0x08 // Removes the edit box label.
#define RFF_NOSEPARATEMEM 0x20 // Removes the Separate Memory Space check box (Windows NT only).
/*
typedef struct _SHELLEXECUTEINFO{
- DWORD cbSize;
- ULONG fMask;
- HWND hwnd;
- LPCTSTR lpVerb;
- LPCTSTR lpFile;
- LPCTSTR lpParameters;
- LPCTSTR lpDirectory;
- int nShow;
- HINSTANCE hInstApp;
-
- // Optional members
- LPVOID lpIDList;
- LPCSTR lpClass;
- HKEY hkeyClass;
- DWORD dwHotKey;
+ DWORD cbSize;
+ ULONG fMask;
+ HWND hwnd;
+ LPCTSTR lpVerb;
+ LPCTSTR lpFile;
+ LPCTSTR lpParameters;
+ LPCTSTR lpDirectory;
+ int nShow;
+ HINSTANCE hInstApp;
+
+ // Optional members
+ LPVOID lpIDList;
+ LPCSTR lpClass;
+ HKEY hkeyClass;
+ DWORD dwHotKey;
union {
HANDLE hIcon;
HANDLE hMonitor;
};
- HANDLE hProcess;
-} SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
+ HANDLE hProcess;
+} SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
*/
BOOL OpenTarget(HWND hWnd, TCHAR* target)
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
// run.h - definitions necessary to use Microsoft's "Run" dialog
// Undocumented Windows call
// use the type below to declare a function pointer
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include "main.h"
#include "settings.h"
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include "main.h"
#include "shell.h"
#include "format.h"
UINT OldMode = SetErrorMode(0); // Get the current Error Mode settings.
SetErrorMode(OldMode & ~SEM_FAILCRITICALERRORS); // Force O/S to handle
pSHFormatDrive(0/*hWnd*/, 0 /* A: */, SHFMT_ID_DEFAULT, 0);
- SetErrorMode(OldMode); // Put it back the way it was.
+ SetErrorMode(OldMode); // Put it back the way it was.
}
FreeLibrary(hShell32);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifndef __SHELL_H__
#define __SHELL_H__
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include <windowsx.h>
#include <shellapi.h>
#include <ctype.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include "main.h"
/////////////////////////////////////////////////////////////////////////////
// Diagnostic Trace
//
-#include <stdio.h>
+#include <stdio.h>
#include <stdarg.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "trace.h"
-// Global variables and constants
-// Image_Open, Image_Closed, and Image_Root - integer variables for indexes of the images.
-// CX_BITMAP and CY_BITMAP - width and height of an icon.
-// NUM_BITMAPS - number of bitmaps to add to the image list.
-int Image_Open;
-int Image_Closed;
-int Image_Root;
+// Global variables and constants
+// Image_Open, Image_Closed, and Image_Root - integer variables for indexes of the images.
+// CX_BITMAP and CY_BITMAP - width and height of an icon.
+// NUM_BITMAPS - number of bitmaps to add to the image list.
+int Image_Open;
+int Image_Closed;
+int Image_Root;
static int s_init = 0;
#if 0
HTREEITEM AddEntryToTree(HWND hwndTV, Entry* entry)
-{
+{
HTREEITEM hItem = 0;
- TVITEM tvi;
- TVINSERTSTRUCT tvins;
- static HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
- static HTREEITEM hPrevRootItem = NULL;
- static HTREEITEM hPrevLev2Item = NULL;
-
- //TRACE("AddEntryToTree(level:%u - %s)\n", entry->level, entry->data.cFileName);
- tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
+ TVITEM tvi;
+ TVINSERTSTRUCT tvins;
+ static HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
+ static HTREEITEM hPrevRootItem = NULL;
+ static HTREEITEM hPrevLev2Item = NULL;
+
+ //TRACE("AddEntryToTree(level:%u - %s)\n", entry->level, entry->data.cFileName);
+ tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
tvi.pszText = LPSTR_TEXTCALLBACK;
tvi.cchTextMax = 0;
tvi.iImage = I_IMAGECALLBACK;
tvi.iSelectedImage = I_IMAGECALLBACK;
tvi.cChildren = I_CHILDRENCALLBACK;
- // Save the entry pointer in the item's application-defined data area.
- tvi.lParam = (LPARAM)entry;
- tvins.item = tvi;
- tvins.hInsertAfter = hPrev;
- // Set the parent item based on the specified level.
+ // Save the entry pointer in the item's application-defined data area.
+ tvi.lParam = (LPARAM)entry;
+ tvins.item = tvi;
+ tvins.hInsertAfter = hPrev;
+ // Set the parent item based on the specified level.
if (entry->level == 0) {
- tvins.hParent = TVI_ROOT;
+ tvins.hParent = TVI_ROOT;
} else if (entry->level == 1) {
- tvins.hParent = hPrevRootItem;
+ tvins.hParent = hPrevRootItem;
} else {
- tvins.hParent = hPrevLev2Item;
+ tvins.hParent = hPrevLev2Item;
if (hPrevLev2Item) {
- tvins.hParent = entry->up->hTreeItem;
+ tvins.hParent = entry->up->hTreeItem;
}
}
- // Add the item to the tree view control.
- hPrev = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
- // Save the handle to the item.
- if (entry->level == 0)
- hPrevRootItem = hPrev;
- else if (entry->level == 1)
- hPrevLev2Item = hPrev;
- hItem = hPrev;
+ // Add the item to the tree view control.
+ hPrev = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
+ // Save the handle to the item.
+ if (entry->level == 0)
+ hPrevRootItem = hPrev;
+ else if (entry->level == 1)
+ hPrevLev2Item = hPrev;
+ hItem = hPrev;
return hItem;
}
#else
static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, Root* entry, DWORD dwChildren)
-{
+{
HTREEITEM hItem = 0;
- TVITEM tvi;
- TVINSERTSTRUCT tvins;
-
- tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
- tvi.pszText = label;
- tvi.cchTextMax = lstrlen(tvi.pszText);
- tvi.iImage = Image_Closed;
- tvi.iSelectedImage = Image_Open;
- tvi.cChildren = dwChildren;
+ TVITEM tvi;
+ TVINSERTSTRUCT tvins;
+
+ tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
+ tvi.pszText = label;
+ tvi.cchTextMax = lstrlen(tvi.pszText);
+ tvi.iImage = Image_Closed;
+ tvi.iSelectedImage = Image_Open;
+ tvi.cChildren = dwChildren;
tvi.lParam = (LPARAM)entry;
- tvins.item = tvi;
- if (entry) tvins.hInsertAfter = (HTREEITEM)TVI_LAST;
- else tvins.hInsertAfter = (HTREEITEM)TVI_SORT;
- tvins.hParent = hParent;
+ tvins.item = tvi;
+ if (entry) tvins.hInsertAfter = (HTREEITEM)TVI_LAST;
+ else tvins.hInsertAfter = (HTREEITEM)TVI_SORT;
+ tvins.hParent = hParent;
hItem = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
return hItem;
}
// don't display entries "." and ".." in the left pane
if ((entry->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && entry->data.cFileName[0]==_T('.')) {
if (entry->data.cFileName[1] == _T('\0') ||
- (entry->data.cFileName[1] == _T('.') &&
+ (entry->data.cFileName[1] == _T('.') &&
entry->data.cFileName[2] == _T('\0'))) {
continue;
}
}
if (entry->hTreeItem) continue;
-// entry->hTreeItem = AddEntryToTree(hWnd, entry);
+// entry->hTreeItem = AddEntryToTree(hWnd, entry);
if (entry->up && entry->up->hTreeItem) {
-// entry->hTreeItem = AddEntryToTree(hWnd, entry->up->hTreeItem, entry->data.cFileName, entry, 0);
- entry->hTreeItem = AddEntryToTree(hWnd, entry->up->hTreeItem, entry->data.cFileName, NULL, 1);
+// entry->hTreeItem = AddEntryToTree(hWnd, entry->up->hTreeItem, entry->data.cFileName, entry, 0);
+ entry->hTreeItem = AddEntryToTree(hWnd, entry->up->hTreeItem, entry->data.cFileName, NULL, 1);
} else {
- entry->hTreeItem = AddEntryToTree(hWnd, TVI_ROOT, entry->data.cFileName, NULL, 0);
+ entry->hTreeItem = AddEntryToTree(hWnd, TVI_ROOT, entry->data.cFileName, NULL, 0);
// AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwCount);
}
if (entry->expanded) {
ShowWindow(hWnd, SW_SHOW);
}
-static BOOL InitTreeViewItems(HWND hwndTV, ChildWnd* pChildWnd)
-{
+static BOOL InitTreeViewItems(HWND hwndTV, ChildWnd* pChildWnd)
+{
TVITEM tvi;
TVINSERTSTRUCT tvins;
HTREEITEM hRoot;
TCHAR buffer[MAX_PATH];
wsprintf(buffer, _T("%s - [%s]"), pChildWnd->pRoot->path, pChildWnd->pRoot->fs);
- tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
+ tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
tvi.pszText = buffer;
tvi.cchTextMax = lstrlen(tvi.pszText);
tvi.iImage = Image_Root;
s_init = 1;
init_output(hwndTV);
}
- return TRUE;
-}
+ return TRUE;
+}
-// InitTreeViewImageLists - creates an image list, adds three bitmaps
-// to it, and associates the image list with a tree view control.
-// Returns TRUE if successful, or FALSE otherwise.
-// hwndTV - handle to the tree view control.
+// InitTreeViewImageLists - creates an image list, adds three bitmaps
+// to it, and associates the image list with a tree view control.
+// Returns TRUE if successful, or FALSE otherwise.
+// hwndTV - handle to the tree view control.
-static BOOL InitTreeViewImageLists(HWND hwndTV)
-{
- HIMAGELIST himl; // handle to image list
- HBITMAP hbmp; // handle to bitmap
+static BOOL InitTreeViewImageLists(HWND hwndTV)
+{
+ HIMAGELIST himl; // handle to image list
+ HBITMAP hbmp; // handle to bitmap
- // Create the image list.
- if ((himl = ImageList_Create(CX_BITMAP, CY_BITMAP,
- FALSE, NUM_BITMAPS, 0)) == NULL)
- return FALSE;
+ // Create the image list.
+ if ((himl = ImageList_Create(CX_BITMAP, CY_BITMAP,
+ FALSE, NUM_BITMAPS, 0)) == NULL)
+ return FALSE;
- // Add the open file, closed file, and document bitmaps.
- hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FOLDER_RED));
- Image_Open = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
- DeleteObject(hbmp);
+ // Add the open file, closed file, and document bitmaps.
+ hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FOLDER_RED));
+ Image_Open = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
+ DeleteObject(hbmp);
- hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FOLDER_OPEN));
- Image_Closed = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
- DeleteObject(hbmp);
+ hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FOLDER_OPEN));
+ Image_Closed = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
+ DeleteObject(hbmp);
- hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FOLDER));
- Image_Root = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
- DeleteObject(hbmp);
+ hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FOLDER));
+ Image_Root = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
+ DeleteObject(hbmp);
- // Fail if not all of the images were added.
- if (ImageList_GetImageCount(himl) < 3)
- return FALSE;
+ // Fail if not all of the images were added.
+ if (ImageList_GetImageCount(himl) < 3)
+ return FALSE;
- // Associate the image list with the tree view control.
- TreeView_SetImageList(hwndTV, himl, TVSIL_NORMAL);
+ // Associate the image list with the tree view control.
+ TreeView_SetImageList(hwndTV, himl, TVSIL_NORMAL);
- return TRUE;
-}
+ return TRUE;
+}
BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
-{
+{
Root* pRoot = NULL;
TCHAR szPath[1000];
int keyPathLen = 0;
insert_tree_entries(hwndTV, pRoot->entry.down, 0);
-// entry->hTreeItem = AddEntryToTree(hWnd, entry->up->hTreeItem, entry->data.cFileName, NULL, 1);
+// entry->hTreeItem = AddEntryToTree(hWnd, entry->up->hTreeItem, entry->data.cFileName, NULL, 1);
/*
HKEY hNewKey;
}
expanding = FALSE;
return TRUE;
-}
+}
/*
static void read_directory_win(Entry* parent, LPCTSTR path)
{
ptvdi->item.cChildren = 5;
}
if (ptvdi->item.mask & TVIF_IMAGE) {
- ptvdi->item.iImage = Image_Root;
+ ptvdi->item.iImage = Image_Root;
}
if (ptvdi->item.mask & TVIF_SELECTEDIMAGE) {
- ptvdi->item.iSelectedImage = Image_Closed;
+ ptvdi->item.iSelectedImage = Image_Closed;
}
if (ptvdi->item.mask & TVIF_TEXT) {
-// ptvdi->item.pszText = entry->data.cFileName;
-// ptvdi->item.cchTextMax = lstrlen(entry->data.cFileName);
+// ptvdi->item.pszText = entry->data.cFileName;
+// ptvdi->item.cchTextMax = lstrlen(entry->data.cFileName);
}
-}
+}
void UpdateStatus(HWND hWnd, Entry* pEntry)
{
}
}
-// CreateTreeView - creates a tree view control.
-// Returns the handle to the new control if successful, or NULL otherwise.
-// hwndParent - handle to the control's parent window.
+// CreateTreeView - creates a tree view control.
+// Returns the handle to the new control if successful, or NULL otherwise.
+// hwndParent - handle to the control's parent window.
-HWND CreateTreeView(HWND hwndParent, ChildWnd* pChildWnd, int id)
-{
+HWND CreateTreeView(HWND hwndParent, ChildWnd* pChildWnd, int id)
+{
RECT rcClient;
HWND hwndTV;
-
- // Get the dimensions of the parent window's client area, and create the tree view control.
- GetClientRect(hwndParent, &rcClient);
- hwndTV = CreateWindowEx(0, WC_TREEVIEW, _T("Tree View"),
+
+ // Get the dimensions of the parent window's client area, and create the tree view control.
+ GetClientRect(hwndParent, &rcClient);
+ hwndTV = CreateWindowEx(0, WC_TREEVIEW, _T("Tree View"),
WS_VISIBLE | WS_CHILD | WS_BORDER | WS_EX_CLIENTEDGE | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
- 0, 0, rcClient.right, rcClient.bottom,
- hwndParent, (HMENU)id, hInst, NULL);
- // Initialize the image list, and add items to the control.
- if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pChildWnd)) {
- DestroyWindow(hwndTV);
- return NULL;
- }
+ 0, 0, rcClient.right, rcClient.bottom,
+ hwndParent, (HMENU)id, hInst, NULL);
+ // Initialize the image list, and add items to the control.
+ if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pChildWnd)) {
+ DestroyWindow(hwndTV);
+ return NULL;
+ }
SendMessage(hwndTV, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
return hwndTV;
-}
+}
////////////////////////////////////////////////////////////////////////////////
static WNDPROC g_orgTreeWndProc;
-// OnEndLabelEdit - processes the LVN_ENDLABELEDIT notification message.
-// Returns TRUE if the label is changed, or FALSE otherwise.
+// OnEndLabelEdit - processes the LVN_ENDLABELEDIT notification message.
+// Returns TRUE if the label is changed, or FALSE otherwise.
static BOOL OnEndLabelEdit(NMTVDISPINFO* ptvdi)
-{
-// if (ptvdi->item.iItem == -1)
-// return FALSE;
-
- // Copy the new label text to the application-defined structure.
+{
+// if (ptvdi->item.iItem == -1)
+// return FALSE;
+
+ // Copy the new label text to the application-defined structure.
// lstrcpyn(rgPetInfo[ptvdi->item.iItem].szKind, ptvdi->item.pszText, 10);
-
+
return TRUE;
// To make a more robust application you should send an EM_LIMITTEXT
// message to the edit control to prevent the user from entering too
- // many characters in the field.
-}
+ // many characters in the field.
+}
static LRESULT CALLBACK TreeWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
break;
#endif
case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code) {
-// case TVM_EXPAND:
+ switch (((LPNMHDR)lParam)->code) {
+// case TVM_EXPAND:
// OnTreeExpand((int)wParam, (HTREEITEM*)lParam);
// break;
- case TVN_GETDISPINFO:
- OnGetDispInfo((NMTVDISPINFO*)lParam);
- break;
- case TVN_ITEMEXPANDING:
+ case TVN_GETDISPINFO:
+ OnGetDispInfo((NMTVDISPINFO*)lParam);
+ break;
+ case TVN_ITEMEXPANDING:
return OnTreeExpanding(hWnd, (NMTREEVIEW*)lParam);
break;
case TVN_SELCHANGED:
TRACE("TreeWndProc(...) TVN_SINGLEEXPAND\n");
//lpnmtv = (LPNMTREEVIEW)lParam;
//return TVNRET_DEFAULT;
-// return TVNRET_SKIPOLD; // Skip default processing of the item being unselected.
-// return TVNRET_SKIPNEW; // Skip default processing of the item being selected.
+// return TVNRET_SKIPOLD; // Skip default processing of the item being unselected.
+// return TVNRET_SKIPNEW; // Skip default processing of the item being selected.
break;
#endif
- case TVN_ENDLABELEDIT:
+ case TVN_ENDLABELEDIT:
return OnEndLabelEdit((NMTVDISPINFO*)lParam);
break;
}
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include <windowsx.h>
#include <ctype.h>
prect->bottom = wp.rcNormalPosition.bottom-wp.rcNormalPosition.top-
2*(GetSystemMetrics(SM_CYSIZEFRAME)+GetSystemMetrics(SM_CYEDGE))-
GetSystemMetrics(SM_CYCAPTION)-GetSystemMetrics(SM_CYMENUSIZE);
- }
+ }
if (IsWindowVisible(Globals.hToolBar)) {
GetClientRect(Globals.hToolBar, &rt);
prect->top += rt.bottom+2;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-
+
#include <windowsx.h>
#include <process.h>
#include <assert.h>
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifndef __WORKER_H__
#define __WORKER_H__