示例#1
0
void readyPintos(){
  pipeOpen("open -a Sublime\\ Text\\ 2.app");
  pipeOpen("open -a Terminal.app");
  pipeOpen("open /Users/jowon/Dropbox/OS/Pintos.pdf");
  cout << "Jasfom speaking..." << endl;
  cout << "   Now you can do pintos programming. Sir." << endl;
  pipeOpen("say Now you can do pintos programming. Sir.");
  
}
示例#2
0
void exitMac() {
  cout << "Jasfom speaking..." << endl;
  cout << "   Do you really want to shutdown MacBook? (y/n)" << endl;
  pipeOpen("say Do you really want to shutdown MacBook?");
  char ch;
  cin>>ch;
  if (ch == 'y')
    pipeOpen("sudo shutdown -h +0");
  else if(ch == 'n')
    cout << "   Canceled!   " <<endl;
}
示例#3
0
void SVNManager::CommitJob::run()
{
    QString command;
    FILE *fp;
    char buffer[256];

    command += "svn ci ";

    foreach(const SVNEntry *entry, SVNManager::getInstance().entryList) {
        if(entry->isSelected()) {
            command += "\"" + entry->getRelativePath() + "\" ";
        }
    }

    command += "-m \"" + message + "\"";

    fp = pipeOpen(command.toAscii(), "r");

    if (fp == NULL)
        return;

    while (fgets(buffer, 256, fp) != NULL) {
        addLog(buffer);
    }

    pipeClose(fp);

    QMetaObject::invokeMethod(&MainWindow::getInstance(), "commitTerminated", Qt::QueuedConnection, Q_ARG(bool, true));
}
示例#4
0
void SVNManager::AnalyzeJob::run()
{
    QString command;
    FILE *fp;
    char buffer[256];

    addLogLine("Analyzing " + path + " ..." );

    command += "svn st";

    fp = pipeOpen(command.toAscii(), "r");

    if (fp == NULL)
        return;

    while (fgets(buffer, 256, fp) != NULL) {
        SVNManager::getInstance().parseLine(buffer);
        addLog(".");
    }

    pipeClose(fp);


    SVNManager::getInstance().currentPath = path;

    QMetaObject::invokeMethod(&MainWindow::getInstance(), "analyzeTerminated", Qt::QueuedConnection, Q_ARG(bool, true));
}
示例#5
0
static ULONG vioShowBuf( USHORT usIndex, PVOID pargs )
{
    PVIOSHOWBUFPARAM p = pargs;

    HPIPE   hpipe;
    ULONG   cbActual;

    CALL_VIO( VioShowBuf, p->usOfs, p->usLen, p->hvio );

    if( m_LVBPtr )
    {
        USHORT  usStart = p->usOfs & -2;
        USHORT  usEnd = ( p->usOfs + p->usLen + 1 ) & -2;
        USHORT  usLen;

        if( usEnd > m_LVBLen )
            usEnd = m_LVBLen;

        usLen = usEnd - usStart;

        pipeOpen( &hpipe );

        DosWrite( hpipe, &usIndex, sizeof( USHORT ), &cbActual );
        DosWrite( hpipe, &usStart, sizeof( USHORT ), &cbActual );
        DosWrite( hpipe, &usLen, sizeof( USHORT ), &cbActual );
        DosWrite( hpipe, m_LVBPtr + usStart, usLen, &cbActual );

        pipeClose( hpipe );
    }

    return 0;
}
示例#6
0
void informTime(){
  
  struct tm *t;
  time_t timer;
  timer = time(NULL);
  t = localtime(&timer);
  
  char popenParam[100];
  char oTime[10];
  FILE * file;
  
  int hour = t->tm_hour;
  if (t->tm_min < 10){
    sprintf(oTime, "%d:0%d", hour, t->tm_min );
  }else {
    sprintf(oTime, "%d:%d", hour, t->tm_min );
  }
  
  
  cout << "Jasfom speaking..." << endl;
  
  if (hour <5)
  {
    cout << "   It's " << oTime  <<" AM. Sir, you have to sleep now." << endl;
    sprintf(popenParam, "say Its %d %d AM. Sir, you have to sleep now.", hour, t->tm_min);
    pipeOpen(popenParam);
    
  }else if(hour < 12)
  {
    cout << "   It's " << oTime  <<" AM. Good morning, Sir. It is Great day." << endl;
    sprintf(popenParam, "say Its %d, %d AM. Good morning, Sir. It is Great day.", t->tm_hour, t->tm_min);
    pipeOpen(popenParam);
  }
  else if(hour >= 12)
  {
    cout << "   It's " << oTime  <<" PM. Good afternoon, Sir. Enjoy your day." << endl;
    sprintf(popenParam, "say Its %d %d PM. Good afternoon, Sir. Enjoy your day.", hour, t->tm_min);
    pipeOpen(popenParam);
  }
  else
  {
    cout << "   It's " << oTime  <<" AM. Sir, Today is the first day of the rest of your life." << endl;
    sprintf(popenParam, "say Its %d %d AM. Sir, Today is the first day of the rest of your life.", t->tm_hour, t->tm_min);
    pipeOpen(popenParam);
  }
}
示例#7
0
int main(int argc, const char*argv[])
{
  string args;
  string parameters[8] = {"who", "slack", "weather", "wt", "time", "man", "amac", "exit"};
  
  if (argc == 2){
    
    /* when "jasfom who" command */
    if (!(strcmp(argv[1], parameters[0].c_str())))
    {
      outputJasfomInfo();
    }
    
    /* when "jasfom slack" command */
    if(!(strcmp(argv[1], parameters[1].c_str())))
    {
      postSlack();
    }
    
    /* when "jasfom wt or weather" command */
    if (!(strcmp(argv[1], parameters[2].c_str())) || !(strcmp(argv[1], parameters[3].c_str()))){
      informWeather();
    }
    
    /* when "jasfom time" command */
    if (!(strcmp(argv[1], parameters[4].c_str()))){
      informTime();
    }
    /* when "jasfom man" command */
    if (!(strcmp(argv[1], parameters[5].c_str()))){
      man();
    }
    
    /* when "jasfom amac" command */
    if (!(strcmp(argv[1], parameters[6].c_str()))){
      outputMacInfo();
    }
    
    /* when "jasfom exit" command */
    if (!(strcmp(argv[1], parameters[7].c_str()))){
      exitMac();
    }
  }
  
  /* long argv */
  if (argc > 2)
  {
    answerBySentences(argv[1]);
  }
  
  if (argc == 1) {
    /* when just input jasfom*/
    cout << "Jasfom speaking..." << endl;
    cout << "   What can I help you?, Sir." << endl;
    pipeOpen("say What can I help you?, Sir.");
  }
  return 0;
}
示例#8
0
void outputJasfomInfo(){
  cout << "Jasfom speaking..." << endl;
  cout << "\nI am your secretary " << endl;
  cout << "     ________  __          _________  ________  ________    __    __        " << endl;
  cout << "    /____  _/ /  \\        / _______/ / ______/ / ____   \\  /  \\  /  \\       " << endl;
  cout << "        / /  / /\\ \\       \\ \\___    / /_____  / /    \\  / / /\\ \\/ /\\ \\      " << endl;
  cout << "   __  / /  / /__\\ \\       \\___ \\  / ______/ / /     / / / /  \\__/  \\ \\     " << endl;
  cout << "   \\ \\/ /  /  ____  \\   ______/ / / /       /  \\____/ / / /          \\ \\    " << endl;
  cout << "    \\__/  /_/      \\_\\ /_______/ /_/        \\________/ /_/            \\_\\   " << endl << endl;
  pipeOpen("say I am your secretary Jasfom, Sir.");
}
示例#9
0
UcciCommEnum BootLine(void) {
  char szLineStr[SE_LINE_INPUT_MAX_CHAR];
  pipeOpen();
  while (!pipeInputReadLine(szLineStr)) {
    Idle();
  }
  if (StrEqv(szLineStr, "ucci")) {
    return UCCI_COMM_UCCI;
  } else {
    return UCCI_COMM_UNKNOWN;
	}
}
示例#10
0
void man(){
  cout << "Jasfom speaking..." << endl;
  cout << "	This is manuals of me. Sir" << endl;
  cout << " ------------------------------------- " << endl;
  cout << "	jasfom who" << endl;
  cout << "	jasfom exit" << endl;
  cout << "	jasfom pintos" << endl;
  cout << "	jasfom weather or wt" << endl;
  cout << "	jasfom time" << endl;
  cout << "	jasfom amac" << endl;
  cout << " ------------------------------------- " << endl;
  pipeOpen("say This is manuals of me. Sir");
}
示例#11
0
void outputMacInfo(){
  cout << "\nJasfom Speaking..." << endl;
  cout << "   This imformations are about your MacBook Air. Sir\n" << endl;
  cout << pipeOpen("scutil --get ComputerName;", "r");
  
  cout << pipeOpen("sysctl -n machdep.cpu.brand_string;", "r");
  cout << pipeOpen("sysctl -n hw.memsize | awk '{print $0/1073741824\"GB RAM\"}';", "r");
  cout << pipeOpen("sw_vers | awk -F':\t' '{print $2}' | paste -d ' ' - - -;", "r");
  cout << pipeOpen("df -Hl | grep 'disk1' | awk '{print $4\"B/\"$2\"B free (\"$5\" used)\"}'", "r");
  pipeOpen("say This imformations are about your MacBook Air. Sir");
  
}
示例#12
0
static ULONG vioSetCurType( USHORT usIndex, PVOID pargs )
{
    PVIOSETCURTYPEPARAM p = pargs;

    HPIPE   hpipe;
    ULONG   cbActual;

    CALL_VIO( VioSetCurType, p->pvci, p->hvio );

    pipeOpen( &hpipe );

    DosWrite( hpipe, &usIndex, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, p->pvci, sizeof( VIOCURSORINFO ), &cbActual );

    pipeClose( hpipe );

    return 0;
}
示例#13
0
static ULONG vioSetCurPos( USHORT usIndex, PVOID pargs )
{
    PVIOSETCURPOSPARAM p = pargs;

    HPIPE   hpipe;
    ULONG   cbActual;

    CALL_VIO( VioSetCurPos, p->usRow, p->usCol, p->hvio );

    pipeOpen( &hpipe );

    DosWrite( hpipe, &usIndex, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usCol, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usRow, sizeof( USHORT ), &cbActual );

    pipeClose( hpipe );

    return 0;
}
示例#14
0
static ULONG vioWrtNChar( USHORT usIndex, PVOID pargs )
{
    PVIOWRTNCHARPARAM p = pargs;

    HPIPE   hpipe;
    ULONG   cbActual;

    CALL_VIO( VioWrtNChar, p->pch, p->usTimes, p->usRow, p->usCol, p->hvio );

    pipeOpen( &hpipe );

    DosWrite( hpipe, &usIndex, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usCol, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usRow, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usTimes, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, p->pch, sizeof( CHAR ), &cbActual );

    pipeClose( hpipe );

    return 0;
}
示例#15
0
static ULONG vioWrtNCell( USHORT usIndex, PVOID pargs )
{
    PVIOWRTNCELLPARAM p = pargs;

    HPIPE   hpipe;
    ULONG   cbActual;

    CALL_VIO( VioWrtNCell, p->pbCell, p->usTimes, p->usRow, p->usCol, p->hvio );

    pipeOpen( &hpipe );

    DosWrite( hpipe, &usIndex, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usCol, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usRow, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usTimes, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, p->pbCell, sizeof( BYTE ) * VIO_CELLSIZE, &cbActual );

    pipeClose( hpipe );

    return 0;
}
示例#16
0
static ULONG vioWrtCellStr( USHORT usIndex, PVOID pargs )
{
    PVIOWRTCELLSTRPARAM p = pargs;

    HPIPE   hpipe;
    ULONG   cbActual;

    CALL_VIO( VioWrtCellStr, p->pchCellStr, p->usLen, p->usRow, p->usCol, p->hvio );

    pipeOpen( &hpipe );

    DosWrite( hpipe, &usIndex, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usCol, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usRow, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usLen, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, p->pchCellStr, p->usLen * sizeof( BYTE ) * VIO_CELLSIZE, &cbActual );

    pipeClose( hpipe );

    return 0;
}
示例#17
0
static ULONG vioSetMode( USHORT usIndex, PVOID pargs )
{
    PVIOSETMODEPARAM p = pargs;
    VIOMODEINFO      vmi;

    HPIPE   hpipe;
    ULONG   cbActual;

    CALL_VIO( VioSetMode, p->pvmi, p->hvio );

    vmi.cb = sizeof( VIOMODEINFO );
    CALL_VIO( VioGetMode, &vmi, p->hvio );

    pipeOpen( &hpipe );

    DosWrite( hpipe, &usIndex, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &vmi, sizeof( VIOMODEINFO ), &cbActual );

    pipeClose( hpipe );

    return 0;
}
示例#18
0
static ULONG vioWrtCharStrAtt( USHORT usIndex, PVOID pargs )
{
    PVIOWRTCHARSTRATTPARAM p = pargs;

    HPIPE   hpipe;
    ULONG   cbActual;

    CALL_VIO( VioWrtCharStrAtt, p->pchCharStr, p->usLen, p->usRow, p->usCol, p->pbAttr, p->hvio );

    pipeOpen( &hpipe );

    DosWrite( hpipe, &usIndex, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, p->pbAttr, sizeof( BYTE ), &cbActual );
    DosWrite( hpipe, &p->usCol, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usRow, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usLen, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, p->pchCharStr, p->usLen, &cbActual );

    pipeClose( hpipe );

    return 0;
}
示例#19
0
static ULONG vioScrollRt( USHORT usIndex, PVOID pargs )
{
    PVIOSCROLLRTPARAM p = pargs;

    HPIPE   hpipe;
    ULONG   cbActual;

    CALL_VIO( VioScrollRt, p->usTopRow, p->usLeftCol, p->usBotRow, p->usRightCol, p->usLines, p->pbCell, p->hvio );

    pipeOpen( &hpipe );

    DosWrite( hpipe, &usIndex, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, p->pbCell, sizeof( BYTE ) * VIO_CELLSIZE, &cbActual );
    DosWrite( hpipe, &p->usLines, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usRightCol, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usBotRow, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usLeftCol, sizeof( USHORT ), &cbActual );
    DosWrite( hpipe, &p->usTopRow, sizeof( USHORT ), &cbActual );

    pipeClose( hpipe );

    return 0;
}
示例#20
0
/* To display weather information : this function use function - pipOpen() */
void informWeather() {
  
  // today weather information
  vector<string> todayWInfo;
  // tonight weather information
  vector<string> tonightWInfo;
  
  // string of param
  char popenParam[STRINGSIZE];
  
  // to input vector<string token>
  string tempForToken;
  
  // token saver
  char * token;
  
  // weather information saver
  char * weatherInfo;
  
  /* TODAY procedure */
  /* pipe open to get TODAY's weather infomation, and save to buffer */
  
  weatherInfo = pipeOpen("curl -s https://weather.yahoo.com/south-korea/seoul/seoul-1132599/ | awk '/Today -/ || /Tomorrow -/'  | textutil -convert txt -stdin -stdout -format html", "r");
  
  weatherInfo = pipeOpen("curl -X POST --data-urlencode 'payload={\"channel\": \"#todos\", \"username\": \"jasfom\", \"text\": \"This message is from jasfom.\", \"icon_emoji\": \":ghost:\"}' https://hooks.slack.com/services/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", "r");
  
  /* tokenizing procedure */
  token = strtok (weatherInfo, ".");
  
  /* tokenize and push it to today's vector */
  while (token != NULL)
  {
    tempForToken = token;
    todayWInfo.push_back (tempForToken);
    tempForToken.clear();
    token = strtok (NULL, ".");
  }
  
  /* TONIGHT procedure */
  /* pipe open to get TONIGHT's weather infomation, and save to buffer */
  weatherInfo = pipeOpen("curl -s https://weather.yahoo.com/south-korea/seoul/seoul-1132599/ | awk '/Tonight -/' | textutil -convert txt -stdin -stdout -format html", "r");
  
  /* tokening procedure */
  token = strtok (weatherInfo, ".");
  
  /* tokenize and push it to tonight's vector */
  while (token != NULL)
  {
    tempForToken = token;
    tonightWInfo.push_back (tempForToken);
    tempForToken.clear();
    token = strtok (NULL, ".");
  }
  
  /* to erase last null string in vector */
  tonightWInfo.pop_back();
  todayWInfo.pop_back();
  
  /* check TODAY's chance of rain. */
  
  int flag = 0;
  /* when TODAY vector's last string's first token is "chance of ..." */
  if ( !strncmp(todayWInfo.back().c_str(), " Chance", 7) ){
    flag = 1;
  }
  
  /* check TONIGHT's chance of rain. */
  if ( !strncmp(tonightWInfo.back().c_str(), " Chance", 7) && flag == 1){
    flag = 3;
  }else if ( !strncmp(tonightWInfo.back().c_str(), "Chance", 7) && flag == 0 ){
    flag = 2;
  }
  
  cout << "Jasfom speaking..." << endl;
  cout << "    Seoul, South Korea" << endl;
  
  switch (flag) {
      
      /* There is no information about chance of rain. */
    case 0:
      snprintf(popenParam, STRINGSIZE, "say %s, and  %s,  Sir",
               todayWInfo[0].c_str(), tonightWInfo[0].c_str());
      /* output info */
      cout << "    " << todayWInfo[0] << "." << endl;
      cout << "    " << tonightWInfo[0] << "." << " Sir."<< endl;
      break;
      
      /* Just today has information about chanc of rain. */
    case 1:
      snprintf(popenParam, STRINGSIZE, "say %s, and  %s, %s,  Sir",
               todayWInfo[0].c_str(), todayWInfo.back().c_str(), tonightWInfo[0].c_str());
      /* output info */
      cout << "    " << todayWInfo[0] << "." << todayWInfo.back().c_str() << "." << endl;
      cout << "    " << tonightWInfo[0] << "." << " Sir."<< endl;
      
      break;
      
      /* Just tonight has information about chanc of rain. */
    case 2:
      snprintf(popenParam, STRINGSIZE, "say %s, and  %s, %s, Sir",
               todayWInfo[0].c_str(), tonightWInfo[0].c_str(), tonightWInfo.back().c_str());
      /* output info */
      cout << "    " << todayWInfo[0] << "." << endl;
      cout << "    " << tonightWInfo[0] << "." << tonightWInfo.back() <<" Sir."<< endl;
      break;
      
      /* Both has information about chance of rain. */
    case 3:
      snprintf(popenParam, STRINGSIZE, "say Seoul, South Korea, %s, and  %s, %s, %s, Sir",
               todayWInfo[0].c_str(), todayWInfo.back().c_str(), tonightWInfo[0].c_str(), tonightWInfo.back().c_str());
      /* output info */
      cout << "    " << todayWInfo[0] << "." << todayWInfo.back() << "." << endl;
      cout << "    " << tonightWInfo[0] << "." << tonightWInfo.back() <<" Sir."<< endl;
      break;
    default:
      break;
  }
  
  /* pipe open to say Today or Tonight - ... */
  pipeOpen(popenParam);
  /* clear vector */
  todayWInfo.clear();
  tonightWInfo.clear();
}
示例#21
0
void answerBySentences(const char * query) {
  cout << "Okay Sir." << endl;
  cout << "You have potential. If you work very hard, you will be better." << endl;
  pipeOpen("say Okay Sir.");
  pipeOpen("say You have potential ability. If you work very hard, you will be better.");
}
示例#22
0
void postSlack() {
  pipeOpen("curl -X POST --data-urlencode 'payload={\"channel\": \"#todos\", \"username\": \"jasfom\", \"text\": \"This message is from jasfom.\", \"icon_emoji\": \":ghost:\"}' https://hooks.slack.com/services/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", "r");
  cout << "Jasfom Sending..." << endl;
}