From 5747b18422deb95aa10be5e0c32b9d60d11db980 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 13 May 2019 17:09:33 -0700 Subject: . --- subx/015immediate_addressing.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/subx/015immediate_addressing.cc b/subx/015immediate_addressing.cc index 6682bc6d..6e70ce71 100644 --- a/subx/015immediate_addressing.cc +++ b/subx/015immediate_addressing.cc @@ -612,7 +612,7 @@ void test_shift_right_logical_negative_r32_with_imm8() { put_new(Name, "25", "EAX = bitwise AND of imm32 with EAX (and)"); :(code) -void test_and_imm32_with_EAX() { +void test_and_EAX_with_imm32() { Reg[EAX].i = 0xff; run( "== 0x1\n" // code segment @@ -704,7 +704,7 @@ void test_and_imm32_with_r32() { put_new(Name, "0d", "EAX = bitwise OR of imm32 with EAX (or)"); :(code) -void test_or_imm32_with_EAX() { +void test_or_EAX_with_imm32() { Reg[EAX].i = 0xd0c0b0a0; run( "== 0x1\n" // code segment @@ -794,7 +794,7 @@ void test_or_imm32_with_r32() { put_new(Name, "35", "EAX = bitwise XOR of imm32 with EAX (xor)"); :(code) -void test_xor_imm32_with_EAX() { +void test_xor_EAX_with_imm32() { Reg[EAX].i = 0xddccb0a0; run( "== 0x1\n" // code segment @@ -884,7 +884,7 @@ void test_xor_imm32_with_r32() { put_new(Name, "3d", "compare: set SF if EAX < imm32 (cmp)"); :(code) -void test_compare_imm32_with_EAX_greater() { +void test_compare_EAX_with_imm32_greater() { Reg[EAX].i = 0x0d0c0b0a; run( "== 0x1\n" // code segment @@ -930,7 +930,7 @@ void test_compare_EAX_with_imm32_lesser() { ); } -void test_compare_imm32_with_EAX_equal() { +void test_compare_EAX_with_imm32_equal() { Reg[EAX].i = 0x0d0c0b0a; run( "== 0x1\n" // code segment -- cgit 1.4.1-2-gfad0 /lynx-snapshots/stats/src/LYUpload.c'>stats
path: root/src/LYUpload.c
blob: d6cbb1c52068f81daa57de41b906959f8d67e2e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/* Routines to upload files to the local filesystem */
/* Created by: Rick Mallett, Carleton University */
/* Report problems to rmallett@ccs.carleton.ca */
/* Modified 15-Dec-95 George Lindholm (lindholm@ucs.ubc.ca):
	Reread the upload menu page every time, in case the "upload" directory
	  has changed (make the current directory that for the upload process).
	Prompt for the upload file name if there is no "%s" in the command
	  string. Most protocols allow the user to specify the file name
	  from the client side.  Xmodem appears to be the only that can't
	  figure out the filename from the transfer data so it needs the
	  information from lynx (or an upload script which prompts for it).
	  On the other hand, zmodem aborts when you give it a filename on
	  the command line (great way of bypassing the nodotfile code :=( ).
*/

#include "HTUtils.h"
#include "tcp.h"
#include "HTParse.h"
#include "HTAlert.h"
#include "LYCurses.h"
#include "LYUtils.h"
#include "LYGlobalDefs.h"
#include "LYSignal.h"
#include "LYStrings.h"
#include "LYClean.h"
#include "LYGetFile.h"
#include "LYUpload.h"
#include "LYSystem.h"
#include "LYLocal.h"

#include "LYexit.h"
#include "LYLeaks.h"

#define FREE(x) if (x) {free(x); x = NULL;}

/*
 *  LYUpload uploads a file to a given location using a 
 *  specified upload method.
 */

/* it parses an incoming link that looks like
 *
 *  LYNXDIRED://UPLOAD=<#>/TO=<STRING>
 */

PUBLIC int LYUpload ARGS1(char *,line) 
{
    char *method, *directory, *dir;
    int method_number;
    int count;
    char tmpbuf[256];
    char buffer[256];
    lynx_html_item_type *upload_command=0;
    int c;
    char *cp;
    FILE *fp;
    char cmd[512];
#ifdef VMS
    extern BOOLEAN HadVMSInterrupt;
#endif /* VMS */

    /* use configured upload commands */

    if((directory = (char *)strstr(line, "TO=")) == NULL)
	goto failed;
    *(directory-1) = '\0';
    /* go past "Directory=" */
    directory+=3;

    if((method = (char *)strstr(line, "UPLOAD=")) == NULL)
	goto failed;
    /* go past "Method=" */
    method+=7;
    method_number = atoi(method);

    for(count=0, upload_command=uploaders; count < method_number;
	count++, upload_command = upload_command->next)
      ; /* null body */

    /* Parsed out the Method and the Location? */
    if(upload_command->command == NULL) {
	_statusline("ERROR! - upload command is misconfigured");
	sleep(AlertSecs);
	goto failed;
    }

    /* Care about the local name? */
    if (strstr(upload_command->command, "%s")) {
	/*
	 * Commands have the form "command %s [etc]"
	 * where %s is the filename.
	 */

	_statusline("Enter a filename: ");
retry:
	*tmpbuf = '\0';
	if(LYgetstr(tmpbuf, VISIBLE, sizeof(tmpbuf), NORECALL) < 0)
	    goto cancelled;

	if(*tmpbuf=='\0')
	    goto cancelled;

	if (strstr(tmpbuf,"../") != NULL) {
	    _statusline(
		    "Illegal redirection \"../\" found! Request ignored. ");
	    sleep(AlertSecs);
	    goto cancelled;
	} else if(strchr(tmpbuf,'/') != NULL) {
	    _statusline("Illegal character \"/\" found! Request ignored. ");
	    sleep(AlertSecs);
	    goto cancelled;
	} else if (tmpbuf[0] == '~') {
	    _statusline(
		"Illegal redirection using \"~\" found! Request ignored. ");
	    sleep(AlertSecs);
	    goto cancelled;
	}
	sprintf(buffer,"%s/%s",directory,tmpbuf);

	if (no_dotfiles || !show_dotfiles) {
	    if (*buffer == '.' ||
#ifdef VMS
		((cp = strrchr(buffer, ':')) && *(cp+1) == '.') ||
		((cp = strrchr(buffer, ']')) && *(cp+1) == '.') ||
#endif /* VMS */
		((cp = strrchr(buffer, '/')) && *(cp+1) == '.')) {
		_statusline(
		  "File name may not begin with dot. Enter a new filename: ");
		goto retry;
	    }
	}

	/* See if it already exists. */
	if((fp = fopen(buffer,"r")) != NULL) {
	    fclose(fp);

#ifdef VMS
	    _statusline("File exists. Create higher version? (y/n)");
#else
	    _statusline("File exists. Overwrite? (y/n)");
#endif /* VMS */
	    c = 0;
	    while(TOUPPER(c)!='Y' && TOUPPER(c)!='N' && c != 7 && c != 3)
		c = LYgetch();
#ifdef VMS
	    if(HadVMSInterrupt) {
		HadVMSInterrupt = FALSE;
		goto cancelled;
	    }
#endif /* VMS */

	    if(c == 7 || c == 3) { /* Control-G or Control-C */
		goto cancelled;
	    }

	    if(TOUPPER(c) == 'N') {
		_statusline("Enter a filename: ");
		goto retry;
	    }
	}

	/* see if we can write to it */

	if((fp = fopen(buffer,"w")) != NULL) {
	    fclose(fp);
	    remove(buffer);
	} else {
	    _statusline("Cannot write to file. Enter a new filename: ");
	    goto retry;
	}

#ifdef VMS
	sprintf(tmpbuf,upload_command->command,buffer);
#else
	cp = quote_pathname(buffer); /* to prevent spoofing of the shell */
	sprintf(tmpbuf,upload_command->command,cp);
	FREE(cp);
#endif /* VMS */
    } else {			/* No substitution, no changes */
	strcpy(tmpbuf, upload_command->command);
    }

    dir = quote_pathname(directory);
    sprintf(cmd, "cd %s ; %s", dir, tmpbuf);
    FREE(dir);
    stop_curses();
    if(TRACE)
	fprintf(stderr,"command: %s\n",cmd);
    system(cmd);
    fflush(stdout);
    start_curses();
    /* don't remove(file); */

    return 1;

failed:

    _statusline("Unable to upload file.");
    sleep(AlertSecs);
    return 0;

cancelled:

    _statusline("Cancelling.");
    sleep(InfoSecs);
    return 0;

}

/*
 * LYUpload_options writes out the current upload choices to a file
 * so that the user can select printers in the same way that
 * they select all other links 
 * upload links look like
 *  LYNXDIRED//UPLOAD=<#>/TO=<STRING>
 */

PUBLIC int LYUpload_options ARGS2 (char **,newfile, char *,directory)
{
    char upload_filename[256];
    static char tempfile[128];
    static BOOLEAN first = TRUE;
    FILE *fp0;
    lynx_html_item_type *cur_upload;
    int count;
    static char curloc[256];
    char *cp;

    if (first) {
        tempname(tempfile, NEW_FILE);
	first = FALSE;
#ifdef VMS
    } else {
        remove(tempfile);   /* Remove duplicates on VMS. */
#endif /* VMS */
    }

    if ((fp0 = fopen(tempfile,"w")) == NULL) {
	HTAlert(CANNOT_OPEN_TEMP);
	return(-1);
    }

#ifdef VMS
    strcpy(curloc, "/sys$login");
#else
    cp = directory;
    if (!strncmp(cp,"file://localhost",16))
        cp += 16;
    else if (!strncmp(cp,"file:",5))
        cp += 5;
    strcpy(curloc,cp);
    HTUnEscape(curloc);
    if (curloc[strlen(curloc)-1] == '/')
        curloc[strlen(curloc)-1] = '\0';
#endif /* VMS */

    /* make the file a URL now */
#if defined (VMS) || defined (DOSPATH)
    sprintf(upload_filename,"file://localhost/%s",tempfile);
#else
    sprintf(upload_filename,"file://localhost%s",tempfile);
#endif /* VMS */
    StrAllocCopy(*newfile, upload_filename);

    fprintf(fp0,"<head>\n<title>%s</title>\n</head>\n<body>\n",
    		UPLOAD_OPTIONS_TITLE);

    fprintf(fp0,"<h1>Upload Options (%s Version %s)</h1>\n",
    				     LYNX_NAME, LYNX_VERSION);

    fputs("You have the following upload choices.<br>\n", fp0);
    fputs("Please select one:<br>\n<pre>\n", fp0);

    if(uploaders != NULL) {

       for(count=0, cur_upload=uploaders; cur_upload != NULL; 
	   cur_upload = cur_upload->next, count++) {

	  fprintf(fp0, "   <a href=\"LYNXDIRED://UPLOAD=%d/TO=%s\">",
	  	       count,curloc);

	  fprintf(fp0, (cur_upload->name ? 
			cur_upload->name : "No Name Given"));
	  fprintf(fp0, "</a>\n");
	}
    } else {
	fprintf(fp0, "\n   \
No other upload methods have been defined yet.  You may define\n   \
an unlimited number of upload methods using the lynx.cfg file.\n");

    }
    fprintf(fp0, "</pre>\n</body>\n");
    fclose(fp0);

    LYforce_no_cache = TRUE;

    return(0);
}