コード例 #1
0
ファイル: lab1main.c プロジェクト: konorati/CS360
int main()
{   int command_code = 0;
    initRoot();  // Initialize the '/' root directory of the tree
    cwd = root; // Set cwd to root
    while(command_code != 10)
    {
       printf("Enter a command or enter menu: ");
       getInput();
       command_code = findCommand();
       breakPathname();
      // printf("pathname = %s, command = %s, command code = %d, dirname = %s, basename = %s\n", pathname, command, command_code, dirname, basename); // For testing
       switch (command_code)
       {
          case 0: printMenu(); break;
          case 1: mkdir(); break;
          case 2: rmdir(); break;
          case 3: cd(); break;
          case 4: ls(); break;
          case 5: pwd(); break;
          case 6: creat(); break;
          case 7: rm(); break;
          case 8: save(); break;
          case 9: reload(); break;
          case 10: quit(); break;
          default: printf("Invalid command\n"); break;
       }
    }
   return 0;
}
コード例 #2
0
ファイル: simManager.cpp プロジェクト: belzilep/Torque3D
void init()
{
   initEventQueue();
   initRoot();

   InstantiateNamedSet(ActiveActionMapSet);
   InstantiateNamedSet(GhostAlwaysSet);
   InstantiateNamedSet(WayPointSet);
   InstantiateNamedSet(fxReplicatorSet);
   InstantiateNamedSet(fxFoliageSet);
   InstantiateNamedSet(MaterialSet);
   InstantiateNamedSet(SFXSourceSet);
   InstantiateNamedSet(SFXDescriptionSet);
   InstantiateNamedSet(SFXTrackSet);
   InstantiateNamedSet(SFXEnvironmentSet);
   InstantiateNamedSet(SFXStateSet);
   InstantiateNamedSet(SFXAmbienceSet);
   InstantiateNamedSet(TerrainMaterialSet);
   InstantiateNamedSet(DataBlockSet);
   InstantiateNamedGroup(ActionMapGroup);
   InstantiateNamedGroup(ClientGroup);
   InstantiateNamedGroup(GuiGroup);
   InstantiateNamedGroup(GuiDataGroup);
   InstantiateNamedGroup(TCPGroup);
   InstantiateNamedGroup(ClientConnectionGroup);
   InstantiateNamedGroup(SFXParameterGroup);
   InstantiateNamedSet(BehaviorSet);
   InstantiateNamedSet(sgMissionLightingFilterSet);

   gDataBlockGroup = new SimDataBlockGroup();
   gDataBlockGroup->registerObject("DataBlockGroup");
   gRootGroup->addObject(gDataBlockGroup);
   
   SimPersistID::init();
}
コード例 #3
0
ファイル: basketmodel.cpp プロジェクト: elemc/basketpwd
void BasketModel::setUpNewModel(QString pwd)
{
    beginResetModel();
    delete _rootTopItem;

    lastDBModified = QDateTime::currentDateTime();
    databaseIdentifier = tr("generic");

    initRoot();

    hashPassword = pwd;
    endResetModel();
}
コード例 #4
0
ファイル: basketmodel.cpp プロジェクト: elemc/basketpwd
BasketModel::BasketModel(QObject *parent) :
    QAbstractItemModel(parent)
{
    initRoot();
  
    showPasswords   = false;
    hashPassword    = QString();

    // иконки
    recordIcon = QIcon::fromTheme("code-variable");
    folderIcon = QIcon::fromTheme("document-open");
    folderCloseIcon = QIcon::fromTheme("document-open");
    primarySelectMode = false;

    reloadSettings();
}
コード例 #5
0
ファイル: FrequencyScene.cpp プロジェクト: aababy/Begins_New
bool FrequencyScene::init()
{
    if (CCLayer::init())
    {
        _widget = initRoot("R/FrequencyScene.json", this);

        Mission *mission = xMissionPool->_vMissions.at(xMissionPool->_iTodayIdx);
        
        for (int i = 0; i < 7; i++) {
            day[i] = (CheckBox*)Helper::seekWidgetByTag(_widget, MONDAY + i);

            if (mission->bFrequency[i]) {
                day[i]->setSelectedState(true);
            }
        }
        
        return true;
    }
    return false;
}
コード例 #6
0
ファイル: lab1a.c プロジェクト: konorati/CS360
// Load tree from given file
int reload()
{
   FILE *inFile = NULL;
   char type = 0;
   char buffer[128];
   //char *str;
   int i = 0, j = 0;
   inFile = fopen(pathname, "r");
   if(inFile)
   {
      if(fgets(buffer, 128, inFile) == NULL)
      {
         printf("No data to input\n");
         return 0;
      }
      initRoot();
      // printf("Root = %s", root->name); // For testing
      // Read file line by line until eof
      while(fgets(buffer, 128, inFile) != NULL)
      { 
            type = buffer[0];
            buffer[0] = ' ';
            //str = strtok(buffer, " ");
            i = 0, j = 0;
            while(buffer[i] != '/')                                    
            {
               i++;
            }
            // printf("%c\n", buffer[i]); // for testing
            while(buffer[i])
            {
               pathname[j++] = buffer[i++];
            }
            pathname[j] = 0;
            if(pathname[j-1] == '\n')
            {
               pathname[j-1] = 0;
               // printf("newline deleted\n");
            }
            //printf("pathname = %s\n", pathname); // For testing
            //strcpy(pathname, str);
            breakPathname();
            //printf("dirname = %s, basename = %s\n", dirname, basename); // For testing
            if(type == 'D')
            {
               mkdir();
            }
            else if (type == 'F')
            {
               creat();
            }
         
      }
   }
   else
   {
      printf("Could not open file\n");
      return 0;
   }
   return 1;
}
コード例 #7
0
ファイル: mac.c プロジェクト: JasonYSU/VETH3000Switch
/**
 * Function: generateMacData
 * Description: 生成Mac地址的相关信息函数,生成的信息包括了老化时间、学习模式和目前用户配置的所有静态Mac地址
 *
**/
char* generateMacData() {
    static char mac_status[1024];
    char static_table[100];
    struct MacLink *p;
    int current_age_time = 300;
    int disable_age = 0;
    unsigned char i;
    unsigned char mac_address[20];
    char change_status[PORTSNUM + 1];
    //unsigned char mac[10];
    uint16_t learn_mode;
    char port_mode[PORTSNUM + 1];
    int ports_vector[PORTSNUM];
    //char vector_str[5];
//		port_mode = (char*)malloc(ports_num * sizeof(char));
//		ports_vector = (int*)malloc(ports_num * sizeof(int));
    for(i = 0; i < ports_num; i++) {
        port_mode[i] = 'A';
    }
    port_mode[PORTSNUM] = 0;
    for(i = 0; i < ports_num; i++) {
        change_status[i] = '1';
    }
    change_status[PORTSNUM] = 0;
    initRoot();//初始化root节点
    //获取老化是否可用
//		current_age_time = Get_Age_time();
//		if(current_age_time == 0){
//				disable_age = 1;
//		}else{
//
//		}
    //获取端口学习模式
    learn_mode = Get_MAC_forbid();
    for(i = 0; i < ports_num; i++) {
        if((learn_mode & (0x01 << i))) {
            port_mode[i] = 'D';
        }
    }
    //sprintf(mac_status,"%d/%d/%s/%s/-|",board.mac_address.age_time,board.mac_address.disable_age,port_mode,change_status);
    memset(static_table,0,sizeof(static_table));
    memset(mac_status,0,sizeof(mac_status));
    sprintf(mac_status,"%d/%d/%s/%s|",board.mac_address.age_time,board.mac_address.disable_age,port_mode,change_status);
    if(mac_root) {
        for( p = mac_root; p; p = p->next ) {
            //得到静态Mac地址
            //printf("dym is %d\n\r",p->mac_entry.sta_or_dym);
            if(p->mac_entry.sta_or_dym == ENTRY_DYNAMIC || !Str_cmp(p->mac_entry.new_mac,board.sets_info.The_MAC,6)
                    || !Str_cmp(p->mac_entry.new_mac,MGMT_MAC,6)) {
                continue;
            }
            memset(static_table,0,sizeof(static_table));
            memset(ports_vector,0,ports_num * sizeof(int));
            getPortsVectorArray(p->mac_entry.port_vector,ports_vector);
            memset(mac_address,0,sizeof(mac_address));
            getMacString(mac_address,p->mac_entry.new_mac);
            //printf("mac_address is %s\n\r",mac_address);
            sprintf(static_table,"%s/%d/",mac_address,p->mac_entry.vlan_id);
            /* 拼接要发送的向量字符串 */
            concatVectorString(static_table,ports_vector);
            strcat(mac_status,static_table);
        }
    }
    //printf("mac_status is %s\n\r",mac_status);
    return mac_status;
}