小编Sea*_*ght的帖子

如何在Linux中添加汇编代码

我正在Fedora core 6上编写Linux内核模块,我想知道是否有人可以告诉我如何将下面显示的汇编代码添加到我的程序中.汇编代码是为Windows编写的,我不知道如何转换为Linux内核程序.

#ifdef _MSC_VER

unsigned char lookKbits(char k)
{
    _asm {
        mov dl, k
        mov cl, 16
        sub cl, dl
        mov eax, [wordval]
        shr eax, cl
    }
}

unsigned char WORD_hi_lo(char byte_high, char byte_low)
{
    _asm {
        mov ah,byte_high
        mov al,byte_low
    }
}

#endif
Run Code Online (Sandbox Code Playgroud)

linux assembly kernel

2
推荐指数
1
解决办法
1589
查看次数

在运行时使对象不可变[C#]

是否有任何方法(利用我希望的反射),我可以使实例化对象与其所有公共属性一起不可变?我有一个来自别人的代码库(没有可用的源代码)的类,我需要利用它,如果任何代码片段在实例化之后尝试调用此类中的公共setter,我基本上都希望抛出异常.

注意:我不想在类周围创建一个包装器对象来实现它.我很懒.

.net c# reflection setter immutability

2
推荐指数
2
解决办法
613
查看次数

如何在try catch语句中重新请求输入

string l = Console.ReadLine();

try
{
    int.Parse(l);
}
catch (FormatException)
{
    Console.WriteLine("Invalid input. Please enter 1, 2, or 3.");
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我已经要求输入,但如果用户输入一个非整数的答案,如字母"f",catch语句会捕获它,但之后再次抛出异常,因为变量"l"仍然等于"f".救命?

c#

2
推荐指数
1
解决办法
4654
查看次数

具有多个参数的htaccess重写规则

这是我的.htaccess档案:

Options +FollowSymLinks
Options -Multiviews

RewriteEngine On
RewriteBase /website/

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [S=20]

RewriteRule ^(.*)$ $1.php 
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)(/)?$ index.php?occ=$1&cat=$2
Run Code Online (Sandbox Code Playgroud)

现在这两行一起不起作用:

如果我要去contact.php,我会输入我的网址:localhost/website/contact,它会起作用

但是,如果我想通过在我的url:localhost/website/occasion/category中键入这个来访问location/website/index.php?occ = occasion&cat = category,它将仅在我删除第一个重写规则时有用

但是我不能再去localhost/website/contact了

我在这里想念的是什么?

php .htaccess mod-rewrite

2
推荐指数
1
解决办法
5914
查看次数

如何按用户给出的完整路径打开文件?

我写了这段代码.我想向用户询问文件的完整路径,然后转到该路径并打开文件.但不幸的是程序无法找到该文件.例如,我在这个路径G:\ project 2 \newfile中创建了一个文件但是当我在c ++控制台中输入它时,它说"打开文件时出错".我真的需要解决这个问题.请帮我解决一下这个.谢谢

#include <iostream>
#include <fstream>
#include <conio.h>
#include <windows.h>

using namespace std;

int main()
{
    string address;
    cout << "Enter the full path of the file" << endl;
    cin >> address;
    ifstream file(address.c_str());

    if (!file) {
        cout << "Error while opening the file" << endl;
        return 1;
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ file

2
推荐指数
1
解决办法
2158
查看次数

cd命令不能与execvp一起使用

#include <stdio.h>
#include <sys/types.h>
#include <string.h>

int main()
{
    char *ip;
    char *temp[10];
    pid_t pid;

    pid = fork();

    if (pid == 0) {
        int i = 0;

        do {
            gets(ip);

            temp[0] = strtok(ip, " ");
            while (temp[++i] != NULL) {
                temp[i] = strtok(NULL," ");
            }

            pid_t pid2;

            pid2 = fork();
            if (pid2 == 0) {
                execvp(temp[0], temp);
            }
        } while(strcmp(temp[0], "quit"));

        if (!strcmp(temp[0],"quit")) {
            return;
        }
    } else if (pid < 0) {
        fprintf(stderr,"error in creating child");
    } else if …
Run Code Online (Sandbox Code Playgroud)

c linux

2
推荐指数
1
解决办法
7029
查看次数

为除尖括号外的非字符之外的每个单词添加标签

我正在处理包含图像标记和新行标记的文本段落.目标是通过将所有单词charachter的颜色更改为白色来使所有非单词charechter显示清楚.我正在使用java作为编程语言.我想使用正则表达式,但问题它改变了图像标签内的单词charechters.

String RegEx = "\\w|[àÀâÂäÄáÁéÉèÈêÊëËìÌîÎïÏòÒôÔöÖùÙûÛüÜçÇ’ñ]";

try {
    Pattern mypattern = Pattern.compile(RegEx, Pattern.CASE_INSENSITIVE);
    Matcher myMatcher = mypattern.matcher(sentence);
    int offset = 0;
    while (myMatcher.find()) {
        int start = myMatcher.start() + offset;
        int end = myMatcher.end() + offset;
        sentence = sentence.substring(0, start) + "<font color=\"white\">" + sentence.substring(start, end) + "</font>" + sentence.substring(end, sentence.length());
        offset += 28;
    }
} catch (Exception e) {
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

所需结果的例子.输入: Most implementations<img title="hello:" alt="hello:{}" src="http://images.doctissimo.fr/hello.gif" class="wysiwyg_smiley" /> provide ASDF as a module, and you can …

html java regex

2
推荐指数
1
解决办法
427
查看次数

Angular 6错误TS1135:应使用参数表达式

我正在跟踪有关如何通过此链接构建MEAN堆栈的教程:https : //www.youtube.com/watch?v= wtIvu085uU0,但是我仍然坚持在59:34左右创建角度部分。本教程使用angular2,而我使用angular6。阻止我前进的主要部分是contact.service.ts,并使addContacts,getContacts和deleteContact方法能够正常工作,因为.map方法自从angular 2开始就发生了变化。

getContacts() {
    return this.http.get('http://localhost:3000/api/contacts')
        .map(res => res.json());
}
Run Code Online (Sandbox Code Playgroud)

返回“属性'地图'在'可观察'类型上不存在”的错误

getContacts() {
    return this.http.get('http://localhost:3000/api/contacts')
        .pipe(
            .map(res => res.json())
        );
}
Run Code Online (Sandbox Code Playgroud)

现在返回“ src / app / contact.service.ts(17,7)中的错误:错误TS1135:期望参数表达式。” 在控制台中,我认为我已经克服了地图错误,但是我不知道Argument表达式预期的错误是什么意思。在将地图更改为管道之前和之后,其他两种方法都存在相同的问题。现在,它不会编译并显示视频中显示的“联系人工作”页面,该页面位于1:03:37。控制台在其他类中没有显示其他错误,因此我认为这是唯一的错误。

mean-stack angular

2
推荐指数
1
解决办法
3688
查看次数

PHP &gt; 下载 ZIP:网络错误

我的 php 代码有一个大问题,我使用 html 表单来获取“文件名”,工作完美,但我的问题是:当我启动下载时,所有浏览器都下载 zip 文件,并出现网络错误,例如:578ko / 600ko:网络错误。

<?php
$dir = "lol/"; // trailing slash is important
$file = $dir .$_POST['filename'] ;

if (file_exists($file)) {
    header('Pragma: public');
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: public");
    header("Content-Transfer-Encoding: binary");
    header("Content-type: application/zip");
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Cache-Control: must-revalidate');
    header('Content-Length: ' . filesize($file));

    readfile($file);

} else {
    echo "Le fichier $file n'existe pas.";
}
exit;
?>
Run Code Online (Sandbox Code Playgroud)

php

2
推荐指数
1
解决办法
1412
查看次数

为什么我的简单"如果"不起作用?PHP

所以,我正在尝试做一些非常简单的事情:检查一个数字是否等于另一个数字 - 但由于某种原因它只是不想工作.

$exhibitions = "20,21,24";
$parent = "[[*parent]]";
$id = "[[*id]]";

if ($id == 5) {
    $chunk = "listExhibitions";
}
if (stripos($exhibitions, $parent) == TRUE) {
    $chunk = "Exhibitions";
}
return "[[$" . $chunk . "]]";
Run Code Online (Sandbox Code Playgroud)

这是我试图开始工作的第一个"如果".如果我放了!在==之前,页面显示"listExhibitions"块 - 但是当id等于5时我需要它.我也试过把这个数字放在一边.此外,当我简单地输出$ id时,数字5显示出来.

我究竟做错了什么?

php modx

2
推荐指数
1
解决办法
129
查看次数

标签 统计

php ×3

c# ×2

linux ×2

.htaccess ×1

.net ×1

angular ×1

assembly ×1

c ×1

c++ ×1

file ×1

html ×1

immutability ×1

java ×1

kernel ×1

mean-stack ×1

mod-rewrite ×1

modx ×1

reflection ×1

regex ×1

setter ×1